summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2004-01-08 09:27:29 +0100
committerunknown <pem@mysql.comhem.se>2004-01-08 09:27:29 +0100
commit952e2cd42af99102c74d16abc61b37e2c42055b0 (patch)
treee33db53c3a4c2445a62dfedb86c6a2598018fa0a /sql
parentd4898d174c7e728a66831a299b8dddfd5ca6e802 (diff)
downloadmariadb-git-952e2cd42af99102c74d16abc61b37e2c42055b0.tar.gz
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.)
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_yacc.yy30
1 files changed, 21 insertions, 9 deletions
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;