Handle null values correctly in SP local variables.
mysql-test/r/sp.result: Test for handling of null values. mysql-test/t/sp.test: Test for handling of null values. sql/item.h: Update null_value correctly in Item_splocal.
This commit is contained in:
parent
700ae43d71
commit
8bd2c19af8
@ -85,11 +85,23 @@ declare lf double;
|
||||
declare ls varchar(32);
|
||||
set ld = null, li = null, lf = null, ls = null;
|
||||
insert into t3 values (ld, li, lf, ls);
|
||||
insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"),
|
||||
((li is null), 1, "li is null"),
|
||||
((li = 0), null, "li = 0"),
|
||||
((lf is null), 1, "lf is null"),
|
||||
((lf = 0), null, "lf = 0"),
|
||||
((ls is null), 1, "ls is null");
|
||||
end;
|
||||
call nullset();
|
||||
select * from t3;
|
||||
d i f s
|
||||
NULL NULL NULL NULL
|
||||
NULL 1 1 ld is null
|
||||
NULL 1 1 li is null
|
||||
NULL NULL NULL li = 0
|
||||
NULL 1 1 lf is null
|
||||
NULL NULL NULL lf = 0
|
||||
NULL 1 1 ls is null
|
||||
drop table t3;
|
||||
drop procedure nullset;
|
||||
create procedure mixset(x char(16), y int)
|
||||
|
@ -124,6 +124,13 @@ begin
|
||||
|
||||
set ld = null, li = null, lf = null, ls = null;
|
||||
insert into t3 values (ld, li, lf, ls);
|
||||
|
||||
insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"),
|
||||
((li is null), 1, "li is null"),
|
||||
((li = 0), null, "li = 0"),
|
||||
((lf is null), 1, "lf is null"),
|
||||
((lf = 0), null, "lf = 0"),
|
||||
((ls is null), 1, "ls is null");
|
||||
end|
|
||||
|
||||
call nullset()|
|
||||
|
23
sql/item.h
23
sql/item.h
@ -256,17 +256,34 @@ public:
|
||||
|
||||
inline double val()
|
||||
{
|
||||
return this_item()->val();
|
||||
Item *it= this_item();
|
||||
double ret= it->val();
|
||||
Item::null_value= it->null_value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline longlong val_int()
|
||||
{
|
||||
return this_item()->val_int();
|
||||
Item *it= this_item();
|
||||
longlong ret= it->val_int();
|
||||
Item::null_value= it->null_value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline String *val_str(String *sp)
|
||||
{
|
||||
return this_item()->val_str(sp);
|
||||
Item *it= this_item();
|
||||
String *ret= it->val_str(sp);
|
||||
Item::null_value= it->null_value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline bool is_null()
|
||||
{
|
||||
Item *it= this_item();
|
||||
bool ret= it->is_null();
|
||||
Item::null_value= it->null_value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline void make_field(Send_field *field)
|
||||
|
Loading…
x
Reference in New Issue
Block a user