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

Bugfix; added another method to Item_splocal, updated tests, and added previous

fix to functions as well.
parent 98397562
......@@ -514,21 +514,21 @@ id data
hndlr3 13
delete from t1;
drop procedure hndlr3;
drop table if exists t3;
create table t3 ( id char(16), data int );
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;
select data into val from test.t3 where id='z' limit 1; # No hits
insert into test.t3 values ('z', val);
end;
call hndlr4();
select * from t1;
select * from t3;
id data
z 10
delete from t1;
z NULL
drop table t3;
drop procedure hndlr4;
create procedure cur1()
begin
......@@ -555,6 +555,7 @@ foo 40
bar 15
zap 663
drop procedure cur1;
drop table if exists t3;
create table t3 ( s char(16), i int );
create procedure cur2()
begin
......
......@@ -608,22 +608,25 @@ 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.)
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( id char(16), data int )|
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
select data into val from test.t3 where id='z' limit 1; # No hits
if val < 10 then
insert into test.t1 values ('z', 10);
end if;
insert into test.t3 values ('z', val);
end|
call hndlr4()|
select * from t1|
delete from t1|
select * from t3|
drop table t3|
drop procedure hndlr4|
......@@ -654,6 +657,9 @@ call cur1()|
select * from t1|
drop procedure cur1|
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( s char(16), i int )|
create procedure cur2()
......
......@@ -278,6 +278,10 @@ public:
return FALSE;
}
inline int save_in_field(Field *field, bool no_conversions)
{
return this_item()->save_in_field(field, no_conversions);
}
};
......
......@@ -316,9 +316,17 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
close_thread_tables(thd);
// The rest of the frame are local variables which are all IN.
// QQ See comment in execute_procedure below.
for (; i < csize ; i++)
nctx->push_item(NULL);
// 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++)
{
if (! nit)
nit= new Item_null();
nctx->push_item(nit);
}
}
thd->spcont= nctx;
ret= execute(thd);
......
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