diff options
author | unknown <gluh@gluh.mysql.r18.ru> | 2004-09-18 13:06:44 +0400 |
---|---|---|
committer | unknown <gluh@gluh.mysql.r18.ru> | 2004-09-18 13:06:44 +0400 |
commit | d7281b331a79d1e2e3f026bbf71660006ee6df0b (patch) | |
tree | 93fd06c086dffc2635a6570d6c71cc5bb22174c9 | |
parent | e84eb55a0778ca62490c79136b9a09379b02773a (diff) | |
download | mariadb-git-d7281b331a79d1e2e3f026bbf71660006ee6df0b.tar.gz |
Fix for bug #5595: NULLIF() IS NULL returns false if NULLIF() returns NULL
-rw-r--r-- | mysql-test/r/func_if.result | 3 | ||||
-rw-r--r-- | mysql-test/t/func_if.test | 4 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 9 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 1 |
4 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result index aee54ede324..72226588de3 100644 --- a/mysql-test/r/func_if.result +++ b/mysql-test/r/func_if.result @@ -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 diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 5e605dbe97b..f78cb5ade55 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -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; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 013304d9df5..fbc1ad97e76 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -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 diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 236ebb8d28b..8f1aa525190 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -240,6 +240,7 @@ public: void fix_length_and_dec(); const char *func_name() const { return "nullif"; } table_map not_null_tables() const { return 0; } + bool is_null(); }; |