mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-21998: Server crashes in st_select_lex::add_table_to_list upon mix of KILL and sequences
Continue support the hack of current select equal builtin select if selects stack is empty even after subselects.
This commit is contained in:
@ -1893,4 +1893,12 @@ i
|
||||
1
|
||||
i
|
||||
2
|
||||
#
|
||||
# MDEV-21998: Server crashes in st_select_lex::add_table_to_list
|
||||
# upon mix of KILL and sequences
|
||||
#
|
||||
KILL ( SELECT 1 ) + LASTVAL(s);
|
||||
ERROR 42000: KILL does not support subqueries or stored functions
|
||||
KILL LASTVAL(s);
|
||||
ERROR 42000: KILL does not support subqueries or stored functions
|
||||
# End of 10.4 tests
|
||||
|
@ -1677,6 +1677,14 @@ $$
|
||||
|
||||
DELIMITER ;$$
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-21998: Server crashes in st_select_lex::add_table_to_list
|
||||
--echo # upon mix of KILL and sequences
|
||||
--echo #
|
||||
|
||||
--error ER_SUBQUERIES_NOT_SUPPORTED
|
||||
KILL ( SELECT 1 ) + LASTVAL(s);
|
||||
--error ER_SUBQUERIES_NOT_SUPPORTED
|
||||
KILL LASTVAL(s);
|
||||
|
||||
--echo # End of 10.4 tests
|
||||
|
@ -2285,13 +2285,13 @@ begin
|
||||
DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
SIGNAL foo SET MYSQL_ERRNO = `65`; /* illegal */
|
||||
end $$
|
||||
ERROR 42S22: Unknown column '65' in 'field list'
|
||||
ERROR 42000: Undeclared variable: 65
|
||||
create procedure test_signal()
|
||||
begin
|
||||
DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
SIGNAL foo SET MYSQL_ERRNO = `A`; /* illegal */
|
||||
end $$
|
||||
ERROR 42S22: Unknown column 'A' in 'field list'
|
||||
ERROR 42000: Undeclared variable: A
|
||||
create procedure test_signal()
|
||||
begin
|
||||
DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
@ -2342,7 +2342,7 @@ DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
SIGNAL foo SET MYSQL_ERRNO = 1000,
|
||||
MESSAGE_TEXT = `Hello`;
|
||||
end $$
|
||||
ERROR 42S22: Unknown column 'Hello' in 'field list'
|
||||
ERROR 42000: Undeclared variable: Hello
|
||||
create procedure test_signal()
|
||||
begin
|
||||
DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
|
@ -2546,7 +2546,7 @@ end $$
|
||||
call test_signal $$
|
||||
drop procedure test_signal $$
|
||||
|
||||
-- error ER_BAD_FIELD_ERROR
|
||||
-- error ER_SP_UNDECLARED_VAR
|
||||
create procedure test_signal()
|
||||
begin
|
||||
DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
@ -2554,7 +2554,7 @@ begin
|
||||
end $$
|
||||
|
||||
|
||||
-- error ER_BAD_FIELD_ERROR
|
||||
-- error ER_SP_UNDECLARED_VAR
|
||||
create procedure test_signal()
|
||||
begin
|
||||
DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
@ -2616,7 +2616,7 @@ end $$
|
||||
call test_signal $$
|
||||
drop procedure test_signal $$
|
||||
|
||||
-- error ER_BAD_FIELD_ERROR
|
||||
-- error ER_SP_UNDECLARED_VAR
|
||||
create procedure test_signal()
|
||||
begin
|
||||
DECLARE foo CONDITION FOR SQLSTATE '12345';
|
||||
|
@ -454,7 +454,7 @@ else
|
||||
set b = a;
|
||||
end if;
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'aa' in 'field list'
|
||||
ERROR 42000: Undeclared variable: aa
|
||||
create procedure bug4344() drop procedure bug4344|
|
||||
ERROR HY000: Can't drop or alter a PROCEDURE from within another stored routine
|
||||
create procedure bug4344() drop function bug4344|
|
||||
@ -1069,7 +1069,7 @@ IF bug13037_foo THEN
|
||||
SELECT 1;
|
||||
END IF;
|
||||
END|
|
||||
ERROR 42S22: Unknown column 'bug13037_foo' in 'field list'
|
||||
ERROR 42000: Undeclared variable: bug13037_foo
|
||||
CREATE PROCEDURE bug13037_p2()
|
||||
BEGIN
|
||||
SET @bug13037_foo = bug13037_bar;
|
||||
|
@ -615,7 +615,7 @@ call bug2653_1(1, @b)|
|
||||
|
||||
drop procedure bug2653_1|
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug2653_2(a int, out b int)
|
||||
begin
|
||||
if aa < 0 then
|
||||
@ -1508,7 +1508,7 @@ DROP PROCEDURE IF EXISTS bug13037_p3;
|
||||
|
||||
delimiter |;
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
CREATE PROCEDURE bug13037_p1()
|
||||
BEGIN
|
||||
IF bug13037_foo THEN
|
||||
|
@ -4186,7 +4186,7 @@ select v, isnull(v);
|
||||
end if;
|
||||
end;
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'undefined_var' in 'field list'
|
||||
ERROR 42000: Undeclared variable: undefined_var
|
||||
create procedure bug14643_2()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'boo' as 'Handler';
|
||||
@ -4198,7 +4198,7 @@ select 2;
|
||||
end case;
|
||||
select undefined_var;
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'undefined_var' in 'field list'
|
||||
ERROR 42000: Undeclared variable: undefined_var
|
||||
drop procedure if exists bug14304|
|
||||
drop table if exists t3, t4|
|
||||
create table t3(a int primary key auto_increment)|
|
||||
@ -4228,7 +4228,7 @@ create procedure bug14376()
|
||||
begin
|
||||
declare x int default x;
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'x' in 'field list'
|
||||
ERROR 42000: Undeclared variable: x
|
||||
create procedure bug14376()
|
||||
begin
|
||||
declare x int default 42;
|
||||
@ -4483,7 +4483,7 @@ select 'no' as 'v';
|
||||
end if;
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
ERROR 42000: Undeclared variable: v
|
||||
create procedure bug14498_2()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -4492,7 +4492,7 @@ select 'yes' as 'v';
|
||||
end while;
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
ERROR 42000: Undeclared variable: v
|
||||
create procedure bug14498_3()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -4501,7 +4501,7 @@ select 'maybe' as 'v';
|
||||
until v end repeat;
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
ERROR 42000: Undeclared variable: v
|
||||
create procedure bug14498_4()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -4515,7 +4515,7 @@ select '?' as 'v';
|
||||
end case;
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
ERROR 42000: Undeclared variable: v
|
||||
create procedure bug14498_5()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -4529,7 +4529,7 @@ select '?' as 'v';
|
||||
end case;
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
ERROR 42000: Undeclared variable: v
|
||||
drop table if exists t3|
|
||||
drop procedure if exists bug15231_1|
|
||||
drop procedure if exists bug15231_2|
|
||||
@ -8403,7 +8403,7 @@ DECLARE name VARCHAR(10);
|
||||
SET name="hello";
|
||||
call p1(name2);
|
||||
END|
|
||||
ERROR 42S22: Unknown column 'name2' in 'field list'
|
||||
ERROR 42000: Undeclared variable: name2
|
||||
call p2();
|
||||
a
|
||||
hello
|
||||
|
@ -5046,7 +5046,7 @@ drop procedure if exists bug14643_1|
|
||||
drop procedure if exists bug14643_2|
|
||||
--enable_warnings
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14643_1()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'boo' as 'Handler';
|
||||
@ -5062,7 +5062,7 @@ begin
|
||||
end;
|
||||
end|
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14643_2()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'boo' as 'Handler';
|
||||
@ -5117,7 +5117,7 @@ drop table t3, t4|
|
||||
drop procedure if exists bug14376|
|
||||
--enable_warnings
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14376()
|
||||
begin
|
||||
declare x int default x;
|
||||
@ -5344,7 +5344,7 @@ drop procedure if exists bug14498_4|
|
||||
drop procedure if exists bug14498_5|
|
||||
--enable_warnings
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14498_1()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -5357,7 +5357,7 @@ begin
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14498_2()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -5368,7 +5368,7 @@ begin
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14498_3()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -5379,7 +5379,7 @@ begin
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14498_4()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -5395,7 +5395,7 @@ begin
|
||||
select 'done' as 'End';
|
||||
end|
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
create procedure bug14498_5()
|
||||
begin
|
||||
declare continue handler for sqlexception select 'error' as 'Handler';
|
||||
@ -9931,7 +9931,7 @@ BEGIN
|
||||
call p1(name);
|
||||
END|
|
||||
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
CREATE OR REPLACE PROCEDURE p3 ()
|
||||
BEGIN
|
||||
DECLARE name VARCHAR(10);
|
||||
|
@ -1045,7 +1045,7 @@ NULL;
|
||||
END LOOP;
|
||||
END;
|
||||
$$
|
||||
ERROR 42000: Undefined CURSOR: c2
|
||||
ERROR 42000: Undeclared variable: c2
|
||||
# Make sure "rec" shadows other declarations outside the loop
|
||||
CREATE TABLE t1 (a INT, b VARCHAR(10));
|
||||
INSERT INTO t1 VALUES (10, 'b0');
|
||||
|
@ -1019,7 +1019,7 @@ LOOP
|
||||
EXIT WHEN unknown_ident IS NULL;
|
||||
END LOOP;
|
||||
END$$
|
||||
ERROR 42S22: Unknown column 'unknown_ident' in 'field list'
|
||||
ERROR 42000: Undeclared variable: unknown_ident
|
||||
CREATE PROCEDURE p1
|
||||
AS
|
||||
BEGIN
|
||||
@ -1028,7 +1028,7 @@ LOOP
|
||||
EXIT label WHEN unknown_ident IS NULL;
|
||||
END LOOP;
|
||||
END$$
|
||||
ERROR 42S22: Unknown column 'unknown_ident' in 'field list'
|
||||
ERROR 42000: Undeclared variable: unknown_ident
|
||||
CREATE PROCEDURE p1
|
||||
AS
|
||||
BEGIN
|
||||
@ -1036,7 +1036,7 @@ LOOP
|
||||
CONTINUE WHEN unknown_ident IS NULL;
|
||||
END LOOP;
|
||||
END$$
|
||||
ERROR 42S22: Unknown column 'unknown_ident' in 'field list'
|
||||
ERROR 42000: Undeclared variable: unknown_ident
|
||||
CREATE PROCEDURE p1
|
||||
AS
|
||||
BEGIN
|
||||
@ -1045,7 +1045,7 @@ LOOP
|
||||
CONTINUE label WHEN unknown_ident IS NULL;
|
||||
END LOOP;
|
||||
END$$
|
||||
ERROR 42S22: Unknown column 'unknown_ident' in 'field list'
|
||||
ERROR 42000: Undeclared variable: unknown_ident
|
||||
#
|
||||
# MDEV-10583 sql_mode=ORACLE: SQL%ROWCOUNT
|
||||
#
|
||||
|
@ -1128,7 +1128,7 @@ DELIMITER ;$$
|
||||
--echo # IN followed by an unknown cursor name
|
||||
|
||||
DELIMITER $$;
|
||||
--error ER_SP_CURSOR_MISMATCH
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
CREATE PROCEDURE p1 AS
|
||||
CURSOR c1 IS SELECT 'test' AS a FROM DUAL;
|
||||
BEGIN
|
||||
|
@ -1094,7 +1094,7 @@ DROP FUNCTION f1;
|
||||
--echo #
|
||||
|
||||
DELIMITER $$;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
CREATE PROCEDURE p1
|
||||
AS
|
||||
BEGIN
|
||||
@ -1106,7 +1106,7 @@ DELIMITER ;$$
|
||||
|
||||
|
||||
DELIMITER $$;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
CREATE PROCEDURE p1
|
||||
AS
|
||||
BEGIN
|
||||
@ -1119,7 +1119,7 @@ DELIMITER ;$$
|
||||
|
||||
|
||||
DELIMITER $$;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
CREATE PROCEDURE p1
|
||||
AS
|
||||
BEGIN
|
||||
@ -1131,7 +1131,7 @@ DELIMITER ;$$
|
||||
|
||||
|
||||
DELIMITER $$;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
--error ER_SP_UNDECLARED_VAR
|
||||
CREATE PROCEDURE p1
|
||||
AS
|
||||
BEGIN
|
||||
|
@ -7560,6 +7560,7 @@ Item *LEX::create_item_ident_sp(THD *thd, Lex_ident_sys_st *name,
|
||||
|
||||
const Sp_rcontext_handler *rh;
|
||||
sp_variable *spv;
|
||||
uint unused_off;
|
||||
DBUG_ASSERT(spcont);
|
||||
DBUG_ASSERT(sphead);
|
||||
if ((spv= find_variable(name, &rh)))
|
||||
@ -7598,7 +7599,9 @@ Item *LEX::create_item_ident_sp(THD *thd, Lex_ident_sys_st *name,
|
||||
return new (thd->mem_root) Item_func_sqlerrm(thd);
|
||||
}
|
||||
|
||||
if (!current_select)
|
||||
if (!select_stack_head() &&
|
||||
(current_select->parsing_place != FOR_LOOP_BOUND ||
|
||||
spcont->find_cursor(name, &unused_off, false) == NULL))
|
||||
{
|
||||
// we are out of SELECT or FOR so it is syntax error
|
||||
my_error(ER_SP_UNDECLARED_VAR, MYF(0), name->str);
|
||||
@ -9083,7 +9086,8 @@ Item *LEX::create_item_query_expression(THD *thd,
|
||||
|
||||
// Add the subtree of subquery to the current SELECT_LEX
|
||||
SELECT_LEX *curr_sel= select_stack_head();
|
||||
DBUG_ASSERT(current_select == curr_sel);
|
||||
DBUG_ASSERT(current_select == curr_sel ||
|
||||
(curr_sel == NULL && current_select == &builtin_select));
|
||||
if (!curr_sel)
|
||||
{
|
||||
curr_sel= &builtin_select;
|
||||
@ -9315,7 +9319,8 @@ SELECT_LEX *LEX::parsed_subselect(SELECT_LEX_UNIT *unit)
|
||||
|
||||
// Add the subtree of subquery to the current SELECT_LEX
|
||||
SELECT_LEX *curr_sel= select_stack_head();
|
||||
DBUG_ASSERT(current_select == curr_sel);
|
||||
DBUG_ASSERT(current_select == curr_sel ||
|
||||
(curr_sel == NULL && current_select == &builtin_select));
|
||||
if (curr_sel)
|
||||
{
|
||||
curr_sel->register_unit(unit, &curr_sel->context);
|
||||
@ -9391,7 +9396,8 @@ TABLE_LIST *LEX::parsed_derived_table(SELECT_LEX_UNIT *unit,
|
||||
|
||||
// Add the subtree of subquery to the current SELECT_LEX
|
||||
SELECT_LEX *curr_sel= select_stack_head();
|
||||
DBUG_ASSERT(current_select == curr_sel);
|
||||
DBUG_ASSERT(current_select == curr_sel ||
|
||||
(curr_sel == NULL && current_select == &builtin_select));
|
||||
|
||||
Table_ident *ti= new (thd->mem_root) Table_ident(unit);
|
||||
if (ti == NULL)
|
||||
|
@ -3632,8 +3632,9 @@ public:
|
||||
|
||||
if (unlikely(!select_stack_top))
|
||||
{
|
||||
current_select= NULL;
|
||||
DBUG_PRINT("info", ("Top Select is empty"));
|
||||
current_select= &builtin_select;
|
||||
DBUG_PRINT("info", ("Top Select is empty -> sel builtin: %p",
|
||||
current_select));
|
||||
}
|
||||
else
|
||||
current_select= select_stack[select_stack_top - 1];
|
||||
|
Reference in New Issue
Block a user