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 | b5f9e7ec20bd9a779ffcee7d19032a1db679c341 (patch) | |
tree | e9be1a621c9e211cb4daf7e3f100a113c29249fd /sql/sp_head.cc | |
parent | 17d63d133ba29e4296c287daea9f26333b95c85c (diff) | |
download | mariadb-git-b5f9e7ec20bd9a779ffcee7d19032a1db679c341.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/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 0444499de48..a11907373cd 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1078,7 +1078,6 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp) sp_rcontext *octx = thd->spcont; sp_rcontext *nctx = NULL; uint i; - Item_null *nit; int ret= -1; // Assume error if (argcount != params) @@ -1109,22 +1108,15 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp) nctx->push_item(it); } + /* The rest of the frame are local variables which are all IN. - Default all variables to null (those with default clauses will - be set by an set instruction). + Push NULLs to get the right size (and make the reuse mechanism work) - + the will be initialized by set instructions in each frame. */ - - nit= NULL; // Re-use this, and only create if needed for (; i < csize ; i++) - { - if (! nit) - { - if (!(nit= new Item_null())) - DBUG_RETURN(-1); - } - nctx->push_item(nit); - } + nctx->push_item(NULL); + thd->spcont= nctx; binlog_save_options= thd->options; @@ -1321,23 +1313,14 @@ int sp_head::execute_procedure(THD *thd, List<Item> *args) close_thread_tables(thd, 0, 0); DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str)); + /* The rest of the frame are local variables which are all IN. - Default all variables to null (those with default clauses will - be set by an set instruction). + Push NULLs to get the right size (and make the reuse mechanism work) - + the will be initialized by set instructions in each frame. */ for (; i < csize ; i++) - { - if (! nit) - { - if (!(nit= new Item_null())) - { - ret= -1; - break; - } - } - nctx->push_item(nit); - } + nctx->push_item(NULL); } thd->spcont= nctx; |