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 ...@@ -514,21 +514,21 @@ id data
hndlr3 13 hndlr3 13
delete from t1; delete from t1;
drop procedure hndlr3; drop procedure hndlr3;
drop table if exists t3;
create table t3 ( id char(16), data int );
create procedure hndlr4() create procedure hndlr4()
begin begin
declare x int default 0; declare x int default 0;
declare val int; # No default declare val int; # No default
declare continue handler for sqlexception set x=1; 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.t3 values ('z', val);
insert into test.t1 values ('z', 10);
end if;
end; end;
call hndlr4(); call hndlr4();
select * from t1; select * from t3;
id data id data
z 10 z NULL
delete from t1; drop table t3;
drop procedure hndlr4; drop procedure hndlr4;
create procedure cur1() create procedure cur1()
begin begin
...@@ -555,6 +555,7 @@ foo 40 ...@@ -555,6 +555,7 @@ foo 40
bar 15 bar 15
zap 663 zap 663
drop procedure cur1; drop procedure cur1;
drop table if exists t3;
create table t3 ( s char(16), i int ); create table t3 ( s char(16), i int );
create procedure cur2() create procedure cur2()
begin begin
......
...@@ -608,22 +608,25 @@ drop procedure hndlr3| ...@@ -608,22 +608,25 @@ drop procedure hndlr3|
# Variables might be uninitialized when using handlers # Variables might be uninitialized when using handlers
# (Otherwise the compiler can detect if a variable is not set, but # (Otherwise the compiler can detect if a variable is not set, but
# not in this case.) # not in this case.)
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( id char(16), data int )|
create procedure hndlr4() create procedure hndlr4()
begin begin
declare x int default 0; declare x int default 0;
declare val int; # No default declare val int; # No default
declare continue handler for sqlexception set x=1; 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.t3 values ('z', val);
insert into test.t1 values ('z', 10);
end if;
end| end|
call hndlr4()| call hndlr4()|
select * from t1| select * from t3|
delete from t1| drop table t3|
drop procedure hndlr4| drop procedure hndlr4|
...@@ -654,6 +657,9 @@ call cur1()| ...@@ -654,6 +657,9 @@ call cur1()|
select * from t1| select * from t1|
drop procedure cur1| drop procedure cur1|
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( s char(16), i int )| create table t3 ( s char(16), i int )|
create procedure cur2() create procedure cur2()
......
...@@ -278,6 +278,10 @@ public: ...@@ -278,6 +278,10 @@ public:
return FALSE; 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) ...@@ -316,9 +316,17 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
close_thread_tables(thd); close_thread_tables(thd);
// The rest of the frame are local variables which are all IN. // The rest of the frame are local variables which are all IN.
// QQ See comment in execute_procedure below. // 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++) for (; i < csize ; i++)
nctx->push_item(NULL); {
if (! nit)
nit= new Item_null();
nctx->push_item(nit);
}
}
thd->spcont= nctx; thd->spcont= nctx;
ret= execute(thd); 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