Commit d7281b33 authored by unknown's avatar unknown
Browse files

Fix for bug #5595: NULLIF() IS NULL returns false if NULLIF() returns NULL

parent e84eb55a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -64,3 +64,6 @@ select if(1>2,a,avg(a)) from t1;
if(1>2,a,avg(a))
1.5000
drop table t1;
SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL;
NULLIF(5,5) IS NULL	NULLIF(5,5) IS NOT NULL
1	0
+4 −0
Original line number Diff line number Diff line
@@ -47,3 +47,7 @@ insert t1 values (1),(2);
select if(1>2,a,avg(a)) from t1;
drop table t1;

#
# Bug #5595  NULLIF() IS NULL returns false if NULLIF() returns NULL
#
SELECT NULLIF(5,5) IS NULL, NULLIF(5,5) IS NOT NULL;
+9 −0
Original line number Diff line number Diff line
@@ -654,6 +654,15 @@ Item_func_nullif::val_str(String *str)
  return res;
}


bool
Item_func_nullif::is_null()
{
  if (!(this->*cmp_func)())
    return null_value=1;
  return 0;
}

/*
  CASE expression 
  Return the matching ITEM or NULL if all compares (including else) failed
+1 −0
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ class Item_func_nullif :public Item_bool_func2
  void fix_length_and_dec();
  const char *func_name() const { return "nullif"; }
  table_map not_null_tables() const { return 0; }
  bool is_null();
};