Commit 9aa680a0 authored by unknown's avatar unknown

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

Two missing methods added to Item_splocal + test case.


mysql-test/r/sp.result:
  Test case for BUG#1547
mysql-test/t/sp.test:
  Test case for BUG#1547
sql/item.h:
  Fix for BUG#1547: "SELECT ... WHERE field = var" sometimes give the wrong result in SPs
  
  Added missing methods to Item_splocal to get the correct compare function
  and make the optimizer do the right thing.
parent 776784b8
......@@ -601,6 +601,27 @@ less 2
more 17
delete from t1;
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;
create table fac (n int unsigned not null primary key, f bigint unsigned);
create procedure ifac(n int unsigned)
......
......@@ -697,6 +697,28 @@ select * from t1|
delete from t1|
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
......
......@@ -266,6 +266,16 @@ class Item_splocal : public Item
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