1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-15940 Crash when using CURSOR with VALUES()

The function st_select_lex_unit::get_column_types() should
take into account that a unit may contain only a table
value constructor and nothing more.
This commit is contained in:
Igor Babaev
2018-04-21 17:20:20 -07:00
parent c39f8a80c9
commit 6242036f27
3 changed files with 46 additions and 1 deletions

View File

@ -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

View File

@ -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 ;|

View File

@ -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)
{