diff options
-rw-r--r-- | Docs/manual.texi | 8 | ||||
-rw-r--r-- | mysql-test/r/func_if.result | 2 | ||||
-rw-r--r-- | mysql-test/t/func_if.test | 4 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 6 |
4 files changed, 20 insertions, 0 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index 806c5d34fe0..d91738bf953 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -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 diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index 85c4007f63c..f93f8028496 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -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 diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index c5cc73ecd1f..85553d1a2fd 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -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; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index ae50090fea1..86e2ef29564 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -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) { |