Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1944 05/09/13 12:50:21 pem@stripped +6 -0
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.
sql/sql_yacc.yy
1.421 05/09/13 12:50:11 pem@stripped +32 -37
Initialize local variables in the block to null, or the default value, given.
(Untabifed block too.)
sql/sp_pcontext.h
1.21 05/09/13 12:50:11 pem@stripped +0 -10
Removed isset flag, since it's not used.
sql/sp_pcontext.cc
1.24 05/09/13 12:50:11 pem@stripped +0 -1
Removed isset flag, since it's not used.
sql/sp_head.cc
1.183 05/09/13 12:50:11 pem@stripped +9 -26
Just init. local variable slots in the fram to NULL. (Real init. will be done
in each block.)
mysql-test/t/sp.test
1.146 05/09/13 12:50:11 pem@stripped +45 -0
New test case for BUG#13133.
mysql-test/r/sp.result
1.151 05/09/13 12:50:11 pem@stripped +39 -0
New test case for BUG#13133.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pem
# Host: mysql.comhem.se
# Root: /usr/home/pem/mysql-5.0
--- 1.420/sql/sql_yacc.yy 2005-09-10 14:01:51 +02:00
+++ 1.421/sql/sql_yacc.yy 2005-09-13 12:50:11 +02:00
@@ -1657,42 +1657,41 @@
;
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;
-
- 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);
- }
- }
+ {
+ 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++)
+ {
+ 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_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction();
i->add_to_varlist(spv);
- spv->isset= TRUE;
}
}
|
@@ -2290,7 +2288,6 @@
sp_instr_cfetch *i= (sp_instr_cfetch *)sp->last_instruction();
i->add_to_varlist(spv);
- spv->isset= TRUE;
}
}
;
@@ -5894,7 +5891,6 @@
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 @@
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
--- 1.150/mysql-test/r/sp.result 2005-09-09 08:08:44 +02:00
+++ 1.151/mysql-test/r/sp.result 2005-09-13 12:50:11 +02:00
@@ -3225,4 +3225,43 @@
@var
abcdabcd
drop procedure bug12849_2|
+drop procedure if exists bug131333|
+drop function if exists bug131333|
+create procedure bug131333()
+begin
+begin
+declare a int;
+select a;
+set a = 1;
+select a;
+end;
+begin
+declare b int;
+select b;
+end;
+end|
+create function bug131333()
+returns int
+begin
+begin
+declare a int;
+set a = 1;
+end;
+begin
+declare b int;
+return b;
+end;
+end|
+call bug131333()|
+a
+NULL
+a
+1
+b
+NULL
+select bug131333()|
+bug131333()
+NULL
+drop procedure bug131333|
+drop function bug131333|
drop table t1,t2;
--- 1.145/mysql-test/t/sp.test 2005-09-09 08:08:44 +02:00
+++ 1.146/mysql-test/t/sp.test 2005-09-13 12:50:11 +02:00
@@ -4064,6 +4064,51 @@
drop procedure bug12849_2|
#
+# BUG#13133: Local variables in stored procedures are not initialized correctly.
+#
+--disable_warnings
+drop procedure if exists bug131333|
+drop function if exists bug131333|
+--enable_warnings
+create procedure bug131333()
+begin
+ begin
+ declare a int;
+
+ select a;
+ set a = 1;
+ select a;
+ end;
+ begin
+ declare b int;
+
+ select b;
+ end;
+end|
+
+create function bug131333()
+ returns int
+begin
+ begin
+ declare a int;
+
+ set a = 1;
+ end;
+ begin
+ declare b int;
+
+ return b;
+ end;
+end|
+
+call bug131333()|
+select bug131333()|
+
+drop procedure bug131333|
+drop function bug131333|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
--- 1.182/sql/sp_head.cc 2005-09-09 18:09:33 +02:00
+++ 1.183/sql/sp_head.cc 2005-09-13 12:50:11 +02:00
@@ -1078,7 +1078,6 @@
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 @@
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 @@
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;
--- 1.23/sql/sp_pcontext.cc 2005-06-05 16:19:13 +02:00
+++ 1.24/sql/sp_pcontext.cc 2005-09-13 12:50:11 +02:00
@@ -184,7 +184,6 @@
p->type= type;
p->mode= mode;
p->offset= current_pvars();
- p->isset= (mode == sp_param_out ? FALSE : TRUE);
p->dflt= NULL;
insert_dynamic(&m_pvar, (gptr)&p);
}
--- 1.20/sql/sp_pcontext.h 2005-08-25 15:34:13 +02:00
+++ 1.21/sql/sp_pcontext.h 2005-09-13 12:50:11 +02:00
@@ -35,7 +35,6 @@
enum enum_field_types type;
sp_param_mode_t mode;
uint offset; // Offset in current frame
- my_bool isset;
Item *dflt;
} sp_pvar_t;
@@ -145,15 +144,6 @@
if (p)
p->type= type;
- }
-
- inline void
- set_isset(uint i, my_bool val)
- {
- sp_pvar_t *p= find_pvar(i);
-
- if (p)
- p->isset= val;
}
inline void
| Thread |
|---|
| • bk commit into 5.0 tree (pem:1.1944) BUG#13133 | pem | 13 Sep |