[MDEV-5678] Wrong result from ADDDATE(IFNULL(baddate)) Created: 2014-02-14  Updated: 2022-10-31  Resolved: 2022-10-31

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Affects Version/s: 10.0.7
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

mysql> SELECT ADDDATE(TIMESTAMP'0000-00-00 00:20:12',0) as add1, ADDDATE(IFNULL(TIMESTAMP(NULL),TIME'00:20:12'),0) as indirect,IFNULL(TIMESTAMP(NULL),TIME'00:20:12') as add2;
+------+---------------------+---------------------+
| add1 | indirect            | add2                |
+------+---------------------+---------------------+
| NULL | 0000-00-00 00:20:12 | 0000-00-00 00:20:12 |
+------+---------------------+---------------------+
1 row in set, 1 warning (0.00 sec)
 

ADDDATE(TIMESTAMP'0000-00-00 00:20:12',0) correctly returns NULL,
because it requires a value date.

However, ADDDATE() erroneously returns a non-NULL if the value
comes indirectly, e.g. from the IFNULL function.
The expected result of "add2" should also be NULL.



 Comments   
Comment by Sergei Golubchik [ 2022-10-31 ]

ifnull() returns the second argument, if the first is NULL. Looks like the result of the above is correct.

Generated at Thu Feb 08 07:06:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.