[MDEV-17335] COALESCE() respects NO_ZERO_DATE, NO_ZERO_IN_DATE but ignores unset ALLOW_INVALID_DATES Created: 2018-10-01  Updated: 2019-11-18

Status: Open
Project: MariaDB Server
Component/s: Data types, Temporal Types
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-17329 Inconsistency of NULL date value conv... Open
Epic Link: Data type cleanups

 Description   

SET sql_mode=ALLOW_INVALID_DATES;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DATE);
INSERT INTO t1 VALUES ('0000-00-00'),('2001-00-01'),('2001-02-30');
SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
SELECT *, COALESCE(a) FROM t1;

Versions 10.0, 10.1, 10.2, 10.3, 10.4 return these results:

+------------+-------------+
| a          | COALESCE(a) |
+------------+-------------+
| 0000-00-00 | NULL        |
| 2001-00-01 | NULL        |
| 2001-02-30 | 2001-02-30  |
+------------+-------------+

COALESCE() respects NO_ZERO_DATE and NO_ZERO_IN_DATE, but ignores unset ALLOW_INVALID_DATE.

(Note, table fields ignore sql_mode. But this is by design, it's hard to fix, and it's out of scope of this MDEV)

5.5 returns these results

+------------+-------------+
| a          | COALESCE(a) |
+------------+-------------+
| 0000-00-00 | 0000-00-00  |
| 2001-00-01 | 2001-00-01  |
| 2001-02-30 | 2001-02-30  |
+------------+-------------+

So in 5.5 COALESCE() ignores sql_mode completely.


Generated at Thu Feb 08 08:35:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.