Commit 370a43a3 authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

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.
parent 1ef17f0a
...@@ -302,4 +302,20 @@ call bug2272()| ...@@ -302,4 +302,20 @@ call bug2272()|
ERROR 42S22: Unknown column 'v' in 'field list' ERROR 42S22: Unknown column 'v' in 'field list'
delete from t1| delete from t1|
drop procedure bug2272| 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| drop table t1|
...@@ -75,6 +75,20 @@ id data ...@@ -75,6 +75,20 @@ id data
locset 21 locset 21
delete from t1| delete from t1|
drop procedure locset| 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| drop table if exists t3|
create table t3 ( d date, i int, f double, s varchar(32) )| create table t3 ( d date, i int, f double, s varchar(32) )|
create procedure nullset() create procedure nullset()
......
...@@ -421,6 +421,30 @@ call bug2272()| ...@@ -421,6 +421,30 @@ call bug2272()|
delete from t1| delete from t1|
drop procedure bug2272| 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| drop table t1|
delimiter ;| delimiter ;|
...@@ -109,6 +109,23 @@ delete from t1| ...@@ -109,6 +109,23 @@ delete from t1|
drop procedure locset| 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 # Set things to null
--disable_warnings --disable_warnings
drop table if exists t3| drop table if exists t3|
......
...@@ -4903,7 +4903,7 @@ ident_eq_list: ...@@ -4903,7 +4903,7 @@ ident_eq_list:
ident_eq_value; ident_eq_value;
ident_eq_value: ident_eq_value:
simple_ident equal expr_or_default simple_ident_nospvar equal expr_or_default
{ {
LEX *lex=Lex; LEX *lex=Lex;
if (lex->field_list.push_back($1) || if (lex->field_list.push_back($1) ||
...@@ -4990,7 +4990,7 @@ update: ...@@ -4990,7 +4990,7 @@ update:
; ;
update_list: 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)) if (add_item_to_list(YYTHD, $3) || add_value_to_list(YYTHD, $5))
YYABORT; YYABORT;
...@@ -5629,7 +5629,7 @@ NUM_literal: ...@@ -5629,7 +5629,7 @@ NUM_literal:
**********************************************************************/ **********************************************************************/
insert_ident: insert_ident:
simple_ident { $$=$1; } simple_ident_nospvar { $$=$1; }
| table_wild { $$=$1; }; | table_wild { $$=$1; };
table_wild: table_wild:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment