diff options
author | pem@mysql.comhem.se <> | 2004-01-08 09:27:29 +0100 |
---|---|---|
committer | pem@mysql.comhem.se <> | 2004-01-08 09:27:29 +0100 |
commit | 4975595660ce132a7b81a2fa39fc83c81a25fcea (patch) | |
tree | e33db53c3a4c2445a62dfedb86c6a2598018fa0a | |
parent | f9e2c6cd27268e72198bde3c1a71eb1273df335a (diff) | |
download | mariadb-git-4975595660ce132a7b81a2fa39fc83c81a25fcea.tar.gz |
Fix BUG#2272: Crash if update with variable name in stored procedure.
Parse column names (and not variables) only in UPDATE ... SET ...
-rw-r--r-- | mysql-test/r/sp-error.result | 9 | ||||
-rw-r--r-- | mysql-test/t/sp-error.test | 14 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 30 |
3 files changed, 44 insertions, 9 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 748fda6c4ec..c2b8460d615 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -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| diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index b8b60ac8dde..e33d4d36be7 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -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| diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a5ec1a20959..cec85db8ca6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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; |