Commit 9a669196 authored by unknown's avatar unknown

Fix for ISNULL()


Docs/manual.texi:
  Chagnelog
mysql-test/r/join.result:
  New tests for IS NULL
mysql-test/t/join.test:
  New tests for IS NULL
parent 804a9307
......@@ -46916,6 +46916,10 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.51
@itemize @bullet
@item
Removed BDB documentation.
@item
Fixed mit-pthreads to compile with glibc 2.2 (needed for @code{make dist}).
@item
Fixed the @code{FLOAT(X+1,X)} is not converted to @code{FLOAT(X+2,X)}.
(This also affected @code{DECIMAL}, @code{DOUBLE} and @code{REAL} types)
@item
......@@ -46929,7 +46933,8 @@ Fixed that underflowed decimal fields is not zero filled.
If we get an overflow when inserting @code{'+11111'} for
@code{decimal(5,0) unsigned} columns, we will just drop the sign.
@item
Fixed bug with @code{ISNULL(expression_which_cannot_be_null)}.
Fixed optimization bug with @code{ISNULL(expression_which_cannot_be_null)} and
@code{ISNULL(constant_expression)}.
@item
Fixed host lookup bug in the glibc library that we used with the 3.23.50
Linux-x86 binaries.
......@@ -27,6 +27,9 @@ d d
0000-00-00 NULL
d
0000-00-00
d
2001-08-01
0000-00-00
COUNT(t1.Title)
1
COUNT(t1.Title)
......
......@@ -120,6 +120,7 @@ CREATE TABLE t2 (d DATE NOT NULL);
INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00');
SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL;
SELECT * from t1 WHERE t1.d IS NULL;
SELECT * FROM t1 WHERE 1/0 IS NULL;
DROP TABLE t1,t2;
#
......
......@@ -1211,7 +1211,7 @@ longlong Item_func_isnull::val_int()
This has to be here because of the test in update_used_tables().
*/
if (!used_tables_cache)
return 0;
return cached_value;
(void) args[0]->val();
return (args[0]->null_value) ? 1 : 0;
}
......
......@@ -429,6 +429,7 @@ class Item_func_in :public Item_int_func
class Item_func_isnull :public Item_bool_func
{
longlong cached_value;
public:
Item_func_isnull(Item *a) :Item_bool_func(a) {}
longlong val_int();
......@@ -449,6 +450,12 @@ class Item_func_isnull :public Item_bool_func
args[0]->update_used_tables();
used_tables_cache=args[0]->used_tables();
}
if (!used_tables_cache)
{
/* Remember if the value is always NULL or never NULL */
args[0]->val();
cached_value= args[0]->null_value ? (longlong) 1 : (longlong) 0;
}
}
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
};
......
......@@ -47,7 +47,7 @@ class Item_func_to_days :public Item_int_func
Item_func_to_days(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "to_days"; }
void fix_length_and_dec() { decimals=0; max_length=6; }
void fix_length_and_dec() { decimals=0; max_length=6; maybe_null=1; }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment