mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fixed BUG#2329: Crash if insert with variable name in stored procedure.
Found a few more places in the parser (insert, replace and update) where local stored procedure variables should not be recognized. mysql-test/r/sp-error.result: Test cases for BUG#2329 mysql-test/r/sp.result: New test case for certain context dependencies for symbols. mysql-test/t/sp-error.test: Test cases for BUG#2329 mysql-test/t/sp.test: New test case for certain context dependencies for symbols. sql/sql_yacc.yy: Found a few more places where local SP variables should not be recognized.
This commit is contained in:
@@ -302,4 +302,20 @@ call bug2272()|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
delete from t1|
|
||||
drop procedure bug2272|
|
||||
create procedure bug2329_1()
|
||||
begin
|
||||
declare v int;
|
||||
insert into t1 (v) values (5);
|
||||
end|
|
||||
create procedure bug2329_2()
|
||||
begin
|
||||
declare v int;
|
||||
replace t1 set v = 5;
|
||||
end|
|
||||
call bug2329_1()|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
call bug2329_2()|
|
||||
ERROR 42S22: Unknown column 'v' in 'field list'
|
||||
drop procedure bug2329_1|
|
||||
drop procedure bug2329_2|
|
||||
drop table t1|
|
||||
|
@@ -75,6 +75,20 @@ id data
|
||||
locset 21
|
||||
delete from t1|
|
||||
drop procedure locset|
|
||||
create procedure setcontext()
|
||||
begin
|
||||
declare data int default 2;
|
||||
insert into t1 (id, data) values ("foo", 1);
|
||||
replace t1 set data = data, id = "bar";
|
||||
update t1 set id = "kaka", data = 3 where t1.data = data;
|
||||
end|
|
||||
call setcontext()|
|
||||
select * from t1|
|
||||
id data
|
||||
foo 1
|
||||
kaka 3
|
||||
delete from t1|
|
||||
drop procedure setcontext|
|
||||
drop table if exists t3|
|
||||
create table t3 ( d date, i int, f double, s varchar(32) )|
|
||||
create procedure nullset()
|
||||
|
@@ -421,6 +421,30 @@ call bug2272()|
|
||||
delete from t1|
|
||||
drop procedure bug2272|
|
||||
|
||||
#
|
||||
# BUG#2329
|
||||
#
|
||||
create procedure bug2329_1()
|
||||
begin
|
||||
declare v int;
|
||||
|
||||
insert into t1 (v) values (5);
|
||||
end|
|
||||
|
||||
create procedure bug2329_2()
|
||||
begin
|
||||
declare v int;
|
||||
|
||||
replace t1 set v = 5;
|
||||
end|
|
||||
|
||||
--error 1054
|
||||
call bug2329_1()|
|
||||
--error 1054
|
||||
call bug2329_2()|
|
||||
drop procedure bug2329_1|
|
||||
drop procedure bug2329_2|
|
||||
|
||||
drop table t1|
|
||||
|
||||
delimiter ;|
|
||||
|
@@ -109,6 +109,23 @@ delete from t1|
|
||||
drop procedure locset|
|
||||
|
||||
|
||||
# In some contexts local variables are not recognized
|
||||
# (and in some, you have to qualify the identifier).
|
||||
create procedure setcontext()
|
||||
begin
|
||||
declare data int default 2;
|
||||
|
||||
insert into t1 (id, data) values ("foo", 1);
|
||||
replace t1 set data = data, id = "bar";
|
||||
update t1 set id = "kaka", data = 3 where t1.data = data;
|
||||
end|
|
||||
|
||||
call setcontext()|
|
||||
select * from t1|
|
||||
delete from t1|
|
||||
drop procedure setcontext|
|
||||
|
||||
|
||||
# Set things to null
|
||||
--disable_warnings
|
||||
drop table if exists t3|
|
||||
|
@@ -4903,7 +4903,7 @@ ident_eq_list:
|
||||
ident_eq_value;
|
||||
|
||||
ident_eq_value:
|
||||
simple_ident equal expr_or_default
|
||||
simple_ident_nospvar equal expr_or_default
|
||||
{
|
||||
LEX *lex=Lex;
|
||||
if (lex->field_list.push_back($1) ||
|
||||
@@ -4990,7 +4990,7 @@ update:
|
||||
;
|
||||
|
||||
update_list:
|
||||
update_list ',' simple_ident equal expr_or_default
|
||||
update_list ',' simple_ident_nospvar equal expr_or_default
|
||||
{
|
||||
if (add_item_to_list(YYTHD, $3) || add_value_to_list(YYTHD, $5))
|
||||
YYABORT;
|
||||
@@ -5629,7 +5629,7 @@ NUM_literal:
|
||||
**********************************************************************/
|
||||
|
||||
insert_ident:
|
||||
simple_ident { $$=$1; }
|
||||
simple_ident_nospvar { $$=$1; }
|
||||
| table_wild { $$=$1; };
|
||||
|
||||
table_wild:
|
||||
|
Reference in New Issue
Block a user