Fixed BUG#2227: Server crash with stored procedure call.
(Meaning "... with SELECT v", where v is a local variable.) mysql-test/r/sp.result: Test case for BUG#2227 mysql-test/t/sp.test: Test case for BUG#2227 sql/item.h: Item_splocal::send() needed for "SELEC v", where "v" is a local variable. Also set the field name. sql/sp_head.cc: Have to get decimals and max_length right for reals, when SELECT of local variables.
This commit is contained in:
parent
3fefe780ff
commit
219f51b475
@ -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)
|
||||
|
@ -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
|
||||
|
10
sql/item.h
10
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user