[Commits] 4f74dead630: MDEV-13170: Database service (MySQL) stops after update with trigger
revision-id: 4f74dead6308f2928227f68b0f973a78a5aeaaa1 (mariadb-10.2.16-52-g4f74dead630) parent(s): fd378fc613851a12be346329d32e1666f10610d7 author: Varun Gupta committer: Varun Gupta timestamp: 2018-08-02 02:56:32 +0530 message: MDEV-13170: Database service (MySQL) stops after update with trigger The issue here is that we are not able to resolve the items in the order by clause of the window function. For name resolution the rule is that we look first in select list and then in the FROM clause. For prepared statements we do some caching as to we remember which table the item was resolved during the prepare state and try to reuse it. --- mysql-test/r/win.result | 13 +++++++++++++ mysql-test/t/win.test | 12 ++++++++++++ sql/sql_select.cc | 1 + 3 files changed, 26 insertions(+) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index b519b2bb223..7ce9cf00e70 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3314,3 +3314,16 @@ COUNT(DISTINCT t2.a2) rank() OVER (ORDER BY t2.b1) 1 2 1 3 DROP TABLE t1,t2; +# +# MDEV-13170: Database service (MySQL) stops after update with trigger +# +CREATE TABLE t1 (i INT, a char); +INSERT INTO t1 VALUES (1, 'a'),(2, 'b'); +create view v1 as select * from t1; +PREPARE stmt FROM "SELECT i, row_number() over (partition by i order by i) FROM v1"; +execute stmt; +i row_number() over (partition by i order by i) +1 1 +2 1 +drop table t1; +drop view v1; diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index b354a55d0d6..8ba1b8a0595 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2082,3 +2082,15 @@ SELECT COUNT(DISTINCT t2.a2), rank() OVER (ORDER BY t2.b1) FROM t2 ,t1 GROUP BY t2.b1 ORDER BY t1.a1; DROP TABLE t1,t2; + +--echo # +--echo # MDEV-13170: Database service (MySQL) stops after update with trigger +--echo # + +CREATE TABLE t1 (i INT, a char); +INSERT INTO t1 VALUES (1, 'a'),(2, 'b'); +create view v1 as select * from t1; +PREPARE stmt FROM "SELECT i, row_number() over (partition by i order by i) FROM v1"; +execute stmt; +drop table t1; +drop view v1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 47ca733468b..72942923fbc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22406,6 +22406,7 @@ find_order_in_list(THD *thd, Ref_ptr_array ref_pointer_array, 'shadowed' a table field with the same name, the table field will be chosen over the derived field. */ + ((Item_ident*)order_item)->cached_table= NULL; order->item= &ref_pointer_array[counter]; order->in_field_list=1; return FALSE;
participants (1)
-
Varun