diff options
-rw-r--r-- | mysql-test/main/table_value_constr.result | 21 | ||||
-rw-r--r-- | mysql-test/main/table_value_constr.test | 24 | ||||
-rw-r--r-- | sql/sql_union.cc | 2 |
3 files changed, 46 insertions, 1 deletions
diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result index 39caba331ef..5a904cbca4b 100644 --- a/mysql-test/main/table_value_constr.result +++ b/mysql-test/main/table_value_constr.result @@ -2071,3 +2071,24 @@ ERROR HY000: Field reference 'b' can't be used in table value constructor select * from (values (1), (t1.b), (2)) as new_tvc; ERROR HY000: Field reference 't1.b' can't be used in table value constructor drop table t1; +# +# MDEV-MDEV-15940: cursor over TVC +# +BEGIN NOT ATOMIC +DECLARE v INT; +DECLARE cur CURSOR FOR VALUES(7); +OPEN cur; +FETCH cur INTO v; +SELECT v; +END; +| +v +7 +BEGIN NOT ATOMIC +DECLARE v INT DEFAULT 0; +FOR a IN (VALUES (7)) DO SET v = v + 1; END FOR; +SELECT v; +END; +| +v +1 diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index 578f8943fbb..84f196b92a2 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -1044,3 +1044,27 @@ select * from (values (1), (b), (2)) as new_tvc; select * from (values (1), (t1.b), (2)) as new_tvc; drop table t1; + +--echo # +--echo # MDEV-MDEV-15940: cursor over TVC +--echo # + +DELIMITER |; + +BEGIN NOT ATOMIC + DECLARE v INT; + DECLARE cur CURSOR FOR VALUES(7); + OPEN cur; + FETCH cur INTO v; + SELECT v; +END; +| + +BEGIN NOT ATOMIC +DECLARE v INT DEFAULT 0; +FOR a IN (VALUES (7)) DO SET v = v + 1; END FOR; +SELECT v; +END; +| + +DELIMITER ;| diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 4cc7de8897d..432ad8519c2 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1874,7 +1874,7 @@ bool st_select_lex_unit::change_result(select_result_interceptor *new_result, List<Item> *st_select_lex_unit::get_column_types(bool for_cursor) { SELECT_LEX *sl= first_select(); - bool is_procedure= MY_TEST(sl->join->procedure); + bool is_procedure= !sl->tvc && sl->join->procedure ; if (is_procedure) { |