Commit 28f589db authored by unknown's avatar unknown

Fix BUG#2272: Crash if update with variable name in stored procedure.

Parse column names (and not variables) only in UPDATE ... SET ...


mysql-test/r/sp-error.result:
  New test case for BUG#2272
mysql-test/t/sp-error.test:
  New test case for BUG#2272
sql/sql_yacc.yy:
  "UPDATE table SET id = val" should only recognize column names, and not
  local SP variables for 'id'.
  (Also removed "as locator" syntax which is not supported.)
parent 00406c99
......@@ -283,4 +283,13 @@ create table t3 (column_1 int)|
call bug1653()|
drop procedure bug1653|
drop table t3|
create procedure bug2272()
begin
declare v int;
update t1 set v = 42;
end|
insert into t1 values (666, 51.3)|
call bug2272()|
ERROR 42S22: Unknown column 'v' in 'field list'
delete from t1|
drop table t1|
......@@ -388,6 +388,20 @@ call bug1653()|
drop procedure bug1653|
drop table t3|
#
# BUG#2272
#
create procedure bug2272()
begin
declare v int;
update t1 set v = 42;
end|
insert into t1 values (666, 51.3)|
--error 1054
call bug2272()|
delete from t1|
drop table t1|
......
......@@ -679,6 +679,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
param_marker singlerow_subselect singlerow_subselect_init
signed_literal NUM_literal
exists_subselect exists_subselect_init sp_opt_default
simple_ident_nospvar simple_ident_q
%type <item_list>
expr_list sp_expr_list udf_expr_list udf_expr_list2 when_list
......@@ -1257,7 +1258,7 @@ sp_fdparams:
;
sp_fdparam:
ident type sp_opt_locator
ident type
{
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
......@@ -1283,7 +1284,7 @@ sp_pdparams:
;
sp_pdparam:
sp_opt_inout ident type sp_opt_locator
sp_opt_inout ident type
{
LEX *lex= Lex;
sp_pcontext *spc= lex->spcont;
......@@ -1305,11 +1306,6 @@ sp_opt_inout:
| INOUT_SYM { $$= sp_param_inout; }
;
sp_opt_locator:
/* Empty */
| AS LOCATOR_SYM
;
sp_proc_stmts:
/* Empty */ {}
| sp_proc_stmts sp_proc_stmt ';'
......@@ -4999,7 +4995,7 @@ update_list:
if (add_item_to_list(YYTHD, $3) || add_value_to_list(YYTHD, $5))
YYABORT;
}
| simple_ident equal expr_or_default
| simple_ident_nospvar equal expr_or_default
{
if (add_item_to_list(YYTHD, $1) || add_value_to_list(YYTHD, $3))
YYABORT;
......@@ -5680,7 +5676,23 @@ simple_ident:
(Item*) new Item_ref(NullS,NullS,$1.str);
}
}
| ident '.' ident
| simple_ident_q { $$= $1; }
;
simple_ident_nospvar:
ident
{
SELECT_LEX *sel=Select;
$$= (sel->parsing_place != SELECT_LEX_NODE::IN_HAVING ||
sel->get_in_sum_expr() > 0) ?
(Item*) new Item_field(NullS,NullS,$1.str) :
(Item*) new Item_ref(NullS,NullS,$1.str);
}
| simple_ident_q { $$= $1; }
;
simple_ident_q:
ident '.' ident
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
......
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