diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index f77f0787f20fb591d6cc51a502e37feff9db1cb4..3b6755a271c1a46436a99b9af9bdda303e2f6a1c 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -968,6 +968,16 @@ drop procedure bug2267_1| drop procedure bug2267_2| drop procedure bug2267_3| drop procedure bug2267_4| +create procedure bug2227(x int) +begin +declare y float default 2.6; +declare z char(16) default "zzz"; +select 1.3, x, y, 42, z; +end| +call bug2227(9)| +1.3 x y 42 z +1.3 9 2.6 42 zzz +drop procedure bug2227| 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 298120bca2f690919cfb358500f2b993a1c321ec..eefc6d7120245b7e75620e7331f6e6d0f6ce823c 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -502,7 +502,6 @@ drop procedure sel2| delete from t1| delete from t2| - # SELECT INTO local variables create procedure into_test(x char(16), y int) begin @@ -1107,6 +1106,20 @@ drop procedure bug2267_2| drop procedure bug2267_3| drop procedure bug2267_4| +# +# BUG#2227 +# +create procedure bug2227(x int) +begin + declare y float default 2.6; + declare z char(16) default "zzz"; + + select 1.3, x, y, 42, z; +end| + +call bug2227(9)| +drop procedure bug2227| + # # Some "real" examples diff --git a/sql/item.h b/sql/item.h index 7de6a5bfef890d560f84ffbb029d6842cf2011eb..584fad9eede2a311c054d21f8c8415d7bab11301 100644 --- a/sql/item.h +++ b/sql/item.h @@ -296,7 +296,10 @@ public: inline void make_field(Send_field *field) { - this_item()->make_field(field); + Item *it= this_item(); + + it->set_name(m_name.str, m_name.length, system_charset_info); + it->make_field(field); } inline Item_result result_type() const @@ -318,6 +321,11 @@ public: { str->append(m_name.str, m_name.length); } + + inline bool send(Protocol *protocol, String *str) + { + return this_item()->send(protocol, str); + } }; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index b263fb22c0e133739858e829779a57af998d08a1..8ba8ea25684670d19181ba70c62b504cd120778c 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -94,8 +94,14 @@ sp_eval_func_item(THD *thd, Item *it, enum enum_field_types type) } else { + /* There's some difference between Item::new_item() and the + * constructor; the former crashes, the latter works... weird. */ + uint8 decimals= it->decimals; + uint32 max_length= it->max_length; DBUG_PRINT("info", ("REAL_RESULT: %g", d)); it= new Item_real(it->val()); + it->decimals= decimals; + it->max_length= max_length; } break; }