Skip to content

Commit

Permalink
MDEV-21998: Server crashes in st_select_lex::add_table_to_list upon m…
Browse files Browse the repository at this point in the history
…ix of KILL and sequences

Continue support the hack of current select equal builtin select if
selects stack is empty even after subselects.
  • Loading branch information
sanja-byelkin committed Jul 28, 2020
1 parent fd9ca2a commit c6eb21c
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 44 deletions.
8 changes: 8 additions & 0 deletions mysql-test/main/parser.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions mysql-test/main/parser.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions mysql-test/main/signal.result
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/main/signal.test
Original file line number Diff line number Diff line change
Expand Up @@ -2546,15 +2546,15 @@ 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';
SIGNAL foo SET MYSQL_ERRNO = `65`; /* illegal */
end $$


-- error ER_BAD_FIELD_ERROR
-- error ER_SP_UNDECLARED_VAR
create procedure test_signal()
begin
DECLARE foo CONDITION FOR SQLSTATE '12345';
Expand Down Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/sp-error.result
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/sp-error.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions mysql-test/main/sp.result
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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)|
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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|
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions mysql-test/main/sp.test
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/compat/oracle/r/sp-cursor-rowtype.result
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/compat/oracle/r/sp.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1028,15 +1028,15 @@ 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
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
Expand All @@ -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
#
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/compat/oracle/t/sp-cursor-rowtype.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/compat/oracle/t/sp.test
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ DROP FUNCTION f1;
--echo #

DELIMITER $$;
--error ER_BAD_FIELD_ERROR
--error ER_SP_UNDECLARED_VAR
CREATE PROCEDURE p1
AS
BEGIN
Expand All @@ -1106,7 +1106,7 @@ DELIMITER ;$$


DELIMITER $$;
--error ER_BAD_FIELD_ERROR
--error ER_SP_UNDECLARED_VAR
CREATE PROCEDURE p1
AS
BEGIN
Expand All @@ -1119,7 +1119,7 @@ DELIMITER ;$$


DELIMITER $$;
--error ER_BAD_FIELD_ERROR
--error ER_SP_UNDECLARED_VAR
CREATE PROCEDURE p1
AS
BEGIN
Expand All @@ -1131,7 +1131,7 @@ DELIMITER ;$$


DELIMITER $$;
--error ER_BAD_FIELD_ERROR
--error ER_SP_UNDECLARED_VAR
CREATE PROCEDURE p1
AS
BEGIN
Expand Down
Loading

0 comments on commit c6eb21c

Please sign in to comment.