mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +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:
@ -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;
|
select * from (values (1), (t1.b), (2)) as new_tvc;
|
||||||
ERROR HY000: Field reference 't1.b' can't be used in table value constructor
|
ERROR HY000: Field reference 't1.b' can't be used in table value constructor
|
||||||
drop table t1;
|
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
|
||||||
|
@ -1044,3 +1044,27 @@ select * from (values (1), (b), (2)) as new_tvc;
|
|||||||
select * from (values (1), (t1.b), (2)) as new_tvc;
|
select * from (values (1), (t1.b), (2)) as new_tvc;
|
||||||
|
|
||||||
drop table t1;
|
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 ;|
|
||||||
|
@ -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)
|
List<Item> *st_select_lex_unit::get_column_types(bool for_cursor)
|
||||||
{
|
{
|
||||||
SELECT_LEX *sl= first_select();
|
SELECT_LEX *sl= first_select();
|
||||||
bool is_procedure= MY_TEST(sl->join->procedure);
|
bool is_procedure= !sl->tvc && sl->join->procedure ;
|
||||||
|
|
||||||
if (is_procedure)
|
if (is_procedure)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user