Commit c258c861 authored by pem@mysql.telia.com's avatar pem@mysql.telia.com

Fix for BUG#1547: "SELECT ... WHERE field = var" sometimes give the wrong result in SPs

Two missing methods added to Item_splocal + test case.
parent 225aada6
...@@ -601,6 +601,27 @@ less 2 ...@@ -601,6 +601,27 @@ less 2
more 17 more 17
delete from t1; delete from t1;
drop procedure bug1495; drop procedure bug1495;
create procedure bug1547(s char(16))
begin
declare x int;
select data into x from t1 where s = id limit 1;
if x > 10 then
insert into t1 values ("less", x-10);
else
insert into t1 values ("more", x+10);
end if;
end;
insert into t1 values ("foo", 12), ("bar", 7);
call bug1547("foo");
call bug1547("bar");
select * from t1;
id data
foo 12
bar 7
less 2
more 17
delete from t1;
drop procedure bug1547;
drop table if exists fac; drop table if exists fac;
create table fac (n int unsigned not null primary key, f bigint unsigned); create table fac (n int unsigned not null primary key, f bigint unsigned);
create procedure ifac(n int unsigned) create procedure ifac(n int unsigned)
......
...@@ -697,6 +697,28 @@ select * from t1| ...@@ -697,6 +697,28 @@ select * from t1|
delete from t1| delete from t1|
drop procedure bug1495| drop procedure bug1495|
#
# BUG#1547
#
create procedure bug1547(s char(16))
begin
declare x int;
select data into x from t1 where s = id limit 1;
if x > 10 then
insert into t1 values ("less", x-10);
else
insert into t1 values ("more", x+10);
end if;
end|
insert into t1 values ("foo", 12), ("bar", 7)|
call bug1547("foo")|
call bug1547("bar")|
select * from t1|
delete from t1|
drop procedure bug1547|
# #
# Some "real" examples # Some "real" examples
......
...@@ -266,6 +266,16 @@ public: ...@@ -266,6 +266,16 @@ public:
this_item()->make_field(field); this_item()->make_field(field);
} }
inline Item_result result_type() const
{
return this_const_item()->result_type();
}
inline bool const_item() const
{
return FALSE;
}
}; };
......
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