Commit 98397562 authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

Bugfix. Local variables are now initialized to null.

parent 1f1a8531
......@@ -514,6 +514,22 @@ id data
hndlr3 13
delete from t1;
drop procedure hndlr3;
create procedure hndlr4()
begin
declare x int default 0;
declare val int; # No default
declare continue handler for sqlexception set x=1;
select data into val from test.t1 where id='z' limit 1; # No hits
if val < 10 then
insert into test.t1 values ('z', 10);
end if;
end;
call hndlr4();
select * from t1;
id data
z 10
delete from t1;
drop procedure hndlr4;
create procedure cur1()
begin
declare done int default 0;
......
......@@ -604,6 +604,29 @@ select * from t1|
delete from t1|
drop procedure hndlr3|
# Variables might be uninitialized when using handlers
# (Otherwise the compiler can detect if a variable is not set, but
# not in this case.)
create procedure hndlr4()
begin
declare x int default 0;
declare val int; # No default
declare continue handler for sqlexception set x=1;
select data into val from test.t1 where id='z' limit 1; # No hits
if val < 10 then
insert into test.t1 values ('z', 10);
end if;
end|
call hndlr4()|
select * from t1|
delete from t1|
drop procedure hndlr4|
#
# Cursors
#
......
......@@ -229,7 +229,9 @@ public:
Item_splocal(uint offset)
: m_offset(offset)
{}
{
Item::maybe_null= TRUE;
}
Item *this_item();
Item *this_const_item() const;
......
......@@ -401,11 +401,17 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
close_thread_tables(thd);
// The rest of the frame are local variables which are all IN.
// QQ We haven't found any hint of what the value is when unassigned,
// so we set it to NULL for now. It's an error to refer to an
// unassigned variable anyway (which should be detected by the parser).
// Default all variables to null (those with default clauses will
// be set by an set instruction).
{
Item_null *nit= NULL; // Re-use this, and only create if needed
for (; i < csize ; i++)
nctx->push_item(NULL);
{
if (! nit)
nit= new Item_null();
nctx->push_item(nit);
}
}
thd->spcont= nctx;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment