Commit 26fcc550 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

LP993103: Wrong result with LAST_DAY('0000-00-00 00:00:00')IS NULL in WHERE condition

Fix is to set  maybe_null  flag for Item_func_last_day.
parent feb4776e
......@@ -21,6 +21,12 @@ name cdate note
name1 1998-01-01 note01
name2 1998-01-01 note01
drop table t1,t2;
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(1);
SELECT * FROM t1 WHERE LAST_DAY('0000-00-00 00:00:00') IS NULL;
a
1
DROP TABLE t1;
CREATE TABLE t1 ( datum DATE );
INSERT INTO t1 VALUES ( "2000-1-1" );
INSERT INTO t1 VALUES ( "2000-1-2" );
......
......@@ -26,6 +26,13 @@ INSERT INTO t2 VALUES ('1998-01-02','note02');
select name,t1.cdate,note from t1,t2 where t1.cdate=t2.cdate and t1.cdate='1998-01-01';
drop table t1,t2;
# MariaDB lp:993103. WHERE LAST_DAY(zero_date) IS NULL does not evaluate to TRUE.
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES(1);
SELECT * FROM t1 WHERE LAST_DAY('0000-00-00 00:00:00') IS NULL;
DROP TABLE t1;
#
# Date and BETWEEN
#
......
......@@ -1169,6 +1169,11 @@ class Item_func_last_day :public Item_date
{
public:
Item_func_last_day(Item *a) :Item_date(a) {}
void fix_length_and_dec()
{
Item_date::fix_length_and_dec();
maybe_null= 1;
}
const char *func_name() const { return "last_day"; }
bool get_date(MYSQL_TIME *res, uint fuzzy_date);
};
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