diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 789c78dc109..cec4f7a9935 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -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) diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 29b9b9285ef..230a76721a4 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -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 diff --git a/sql/item.h b/sql/item.h index 9cd68e91273..a2ee8e4ec7f 100644 --- a/sql/item.h +++ b/sql/item.h @@ -266,6 +266,16 @@ public: this_item()->make_field(field); } + inline Item_result result_type() const + { + return this_const_item()->result_type(); + } + + inline bool const_item() const + { + return FALSE; + } + };