Bug #60385 LAST_DAY is null
Submitted: 8 Mar 2011 8:22 Modified: 11 Mar 2011 23:35
Reporter: Sergei Golubchik Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.57 OS:Any
Assigned to: CPU Architecture:Any

[8 Mar 2011 8:22] Sergei Golubchik
Description:
Item_func_last_day sets maybe_null incorrectly.
It does not reflect the fact that LAST_DAY can be null for a not null argument.

How to repeat:
CREATE TABLE t1 ( f2 int NOT NULL) ;
INSERT INTO t1 VALUES (0),(0);
SELECT last_day(f2) from t1;
SELECT last_day(f2) from t1 where last_day(f2) is null;
[8 Mar 2011 12:23] Valeriy Kravchuk
Verified with current mysql-5.1 from bzr:

macbook-pro:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.57-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop table t1;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE t1 ( f2 int NOT NULL) ;
Query OK, 0 rows affected (0.11 sec)

mysql> INSERT INTO t1 VALUES (0),(0);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> SELECT last_day(f2) from t1;
+--------------+
| last_day(f2) |
+--------------+
| NULL         |
| NULL         |
+--------------+
2 rows in set, 2 warnings (0.00 sec)

mysql> SELECT last_day(f2) from t1 where last_day(f2) is null;
Empty set (0.00 sec)

Recent MySQL-5.5 does not have this problem.
[11 Mar 2011 23:35] Omer Barnir
Issue is fixed in 5.5 and fix will not be back ported to 5.1