1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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

This commit is contained in:
gluh@gluh.mysql.r18.ru
2004-09-18 13:06:44 +04:00
parent 0b6dc49388
commit 276622c92d
4 changed files with 17 additions and 0 deletions

View File

@ -64,3 +64,6 @@ select if(1>2,a,avg(a)) from t1;
if(1>2,a,avg(a)) if(1>2,a,avg(a))
1.5000 1.5000
drop table t1; 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

View File

@ -47,3 +47,7 @@ insert t1 values (1),(2);
select if(1>2,a,avg(a)) from t1; select if(1>2,a,avg(a)) from t1;
drop table 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;

View File

@ -654,6 +654,15 @@ Item_func_nullif::val_str(String *str)
return res; return res;
} }
bool
Item_func_nullif::is_null()
{
if (!(this->*cmp_func)())
return null_value=1;
return 0;
}
/* /*
CASE expression CASE expression
Return the matching ITEM or NULL if all compares (including else) failed Return the matching ITEM or NULL if all compares (including else) failed

View File

@ -240,6 +240,7 @@ public:
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "nullif"; } const char *func_name() const { return "nullif"; }
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
bool is_null();
}; };