A change in IF behaviour that several users asked for ...

parent edf3929c
......@@ -46924,6 +46924,14 @@ not yet 100% confident in this code.
* News-3.23.0:: Changes in release 3.23.0
@end menu
@node News-3.23.53, News-3.23.52, News-3.23.x, News-3.23.x
@appendixsubsec Changes in release 3.23.53
@itemize @bullet
@item
Changed behaviour that IF(condition,column,NULL) returns column type
@end itemize
@node News-3.23.52, News-3.23.51, News-3.23.x, News-3.23.x
@appendixsubsec Changes in release 3.23.52
@itemize @bullet
......@@ -33,3 +33,5 @@ aa
aaa
sum(if(num is null,0.00,num))
144.54
min(if(y -x > 5,y,NULL)) max(if(y - x > 5,y,NULL))
6 56
......@@ -28,3 +28,7 @@ create table t1 (num double(12,2));
insert into t1 values (144.54);
select sum(if(num is null,0.00,num)) from t1;
drop table t1;
create table t1 (x int, y int);
insert into t1 values (0,6),(10,16),(20,26),(30,10),(40,46),(50,56);
select min(if(y -x > 5,y,NULL)), max(if(y - x > 5,y,NULL)) from t1;
drop table t1;
......@@ -494,6 +494,12 @@ Item_func_if::fix_length_and_dec()
decimals=max(args[1]->decimals,args[2]->decimals);
enum Item_result arg1_type=args[1]->result_type();
enum Item_result arg2_type=args[2]->result_type();
bool null1=args[1]->null_value;
bool null2=args[2]->null_value;
if (null1 && !null2)
arg1_type=arg2_type;
else if (!null1 && null2)
arg2_type=arg1_type;
binary=1;
if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT)
{
......
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