diff options
author | unknown <pem@mysql.com> | 2005-09-13 12:50:21 +0200 |
---|---|---|
committer | unknown <pem@mysql.com> | 2005-09-13 12:50:21 +0200 |
commit | 902932a1e86ea728a8cc62d2ab5b1e0544d797ae (patch) | |
tree | e9be1a621c9e211cb4daf7e3f100a113c29249fd /sql/sql_yacc.yy | |
parent | b50eb4cd42d2d5073afb2af5af8b19c825a9cca1 (diff) | |
download | mariadb-git-902932a1e86ea728a8cc62d2ab5b1e0544d797ae.tar.gz |
Fixed BUG#13133: Local variables in stored procedures are not initialized correctly.
Have to init. all local variables in their frames, not just once at the beginning
of invocation.
mysql-test/r/sp.result:
New test case for BUG#13133.
mysql-test/t/sp.test:
New test case for BUG#13133.
sql/sp_head.cc:
Just init. local variable slots in the fram to NULL. (Real init. will be done
in each block.)
sql/sp_pcontext.cc:
Removed isset flag, since it's not used.
sql/sp_pcontext.h:
Removed isset flag, since it's not used.
sql/sql_yacc.yy:
Initialize local variables in the block to null, or the default value, given.
(Untabifed block too.)
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 520b6190410..104f9ca8445 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1657,42 +1657,41 @@ sp_decls: ; sp_decl: - DECLARE_SYM sp_decl_idents type + DECLARE_SYM sp_decl_idents type { Lex->sphead->reset_lex(YYTHD); } sp_opt_default - { - LEX *lex= Lex; - sp_pcontext *ctx= lex->spcont; - uint max= ctx->context_pvars(); - enum enum_field_types type= (enum enum_field_types)$3; - Item *it= $5; + { + LEX *lex= Lex; + sp_pcontext *ctx= lex->spcont; + uint max= ctx->context_pvars(); + enum enum_field_types type= (enum enum_field_types)$3; + Item *it= $5; + bool has_default= (it != NULL); - for (uint i = max-$2 ; i < max ; i++) - { - ctx->set_type(i, type); - if (! it) - ctx->set_isset(i, FALSE); - else - { - sp_instr_set *in= new sp_instr_set(lex->sphead->instructions(), - ctx, - ctx->pvar_context2index(i), - it, type, lex, - (i == max - 1)); - - /* - The last instruction is assigned to be responsible for - freeing LEX. - */ - lex->sphead->add_instr(in); - ctx->set_isset(i, TRUE); - ctx->set_default(i, it); - } - } + for (uint i = max-$2 ; i < max ; i++) + { + sp_instr_set *in; + + ctx->set_type(i, type); + if (! has_default) + it= new Item_null(); /* QQ Set to the type with null_value? */ + in = new sp_instr_set(lex->sphead->instructions(), + ctx, + ctx->pvar_context2index(i), + it, type, lex, + (i == max - 1)); + + /* + The last instruction is assigned to be responsible for + freeing LEX. + */ + lex->sphead->add_instr(in); + ctx->set_default(i, it); + } lex->sphead->restore_lex(YYTHD); - $$.vars= $2; - $$.conds= $$.hndlrs= $$.curs= 0; - } + $$.vars= $2; + $$.conds= $$.hndlrs= $$.curs= 0; + } | DECLARE_SYM ident CONDITION_SYM FOR_SYM sp_cond { LEX *lex= Lex; @@ -2268,7 +2267,6 @@ sp_fetch_list: sp_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction(); i->add_to_varlist(spv); - spv->isset= TRUE; } } | @@ -2290,7 +2288,6 @@ sp_fetch_list: sp_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction(); i->add_to_varlist(spv); - spv->isset= TRUE; } } ; @@ -5894,7 +5891,6 @@ select_var_ident: else { ((select_dumpvar *)lex->result)->var_list.push_back( new my_var($1,1,t->offset,t->type)); - t->isset= TRUE; } } ; @@ -7925,7 +7921,6 @@ sys_option_value: sp_set= new sp_instr_set(lex->sphead->instructions(), ctx, spv->offset, it, spv->type, lex, TRUE); lex->sphead->add_instr(sp_set); - spv->isset= TRUE; } } | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types |