Commit 89906482 authored by unknown's avatar unknown
Browse files

func_if.result, func_if.test:

  Added a test case for bug #11142.
item_cmpfunc.cc:
  Fixed bug #11142.
  Implementation of Item_func_nullif::is_null was corrected.


sql/item_cmpfunc.cc:
  Fixed bug #11142.
  Implementation of Item_func_nullif::is_null was corrected.
mysql-test/t/func_if.test:
  Added a test case for bug #11142.
mysql-test/r/func_if.result:
  Added a test case for bug #11142.
parent e802cd3b
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -86,3 +86,30 @@ 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
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb');
SELECT a, NULLIF(a,'') FROM t1;
a	NULLIF(a,'')
aaa	aaa
NULL	NULL
	NULL
bbb	bbb
SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL;
a	NULLIF(a,'')
NULL	NULL
	NULL
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb');
SELECT a, NULLIF(a,'') FROM t1;
a	NULLIF(a,'')
aaa	aaa
NULL	NULL
	NULL
bbb	bbb
SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL;
a	NULLIF(a,'')
NULL	NULL
	NULL
DROP TABLE t1;
+27 −0
Original line number Diff line number Diff line
@@ -60,3 +60,30 @@ 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;
#
# Test to check evaluation of MULLIF when the first argument is NULL
# (motivated by the Bug 11142)
#

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb');
SELECT a, NULLIF(a,'') FROM t1;
SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL;

DROP TABLE t1;

#
# Test for bug #11142: evaluation of NULLIF when the first argument is NULL
#

CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES ('aaa'), (NULL), (''), ('bbb');

SELECT a, NULLIF(a,'') FROM t1;
SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL;

DROP TABLE t1;
+1 −3
Original line number Diff line number Diff line
@@ -1161,9 +1161,7 @@ Item_func_nullif::val_str(String *str)
bool
Item_func_nullif::is_null()
{
  if (!cmp.compare())
    return (null_value=1);
  return 0;
  return (null_value= (!cmp.compare() ? 1 : args[0]->null_value)); 
}

/*