From 20eba06d9b6ed88a02b425f1716ada15ffd745ba Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 25 Nov 2024 16:13:16 +0400 Subject: [PATCH] MDEV-35489 Assertion `!ldate->neg' or unexpected result upon extracting unit from invalid value The patch for MDEV-23687 easlier fixed this problem. Adding tests only. --- mysql-test/main/func_extract.result | 23 +++++++++++++++++++++++ mysql-test/main/func_extract.test | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/mysql-test/main/func_extract.result b/mysql-test/main/func_extract.result index 5c651d713ea..86b6f13a0ed 100644 --- a/mysql-test/main/func_extract.result +++ b/mysql-test/main/func_extract.result @@ -1503,5 +1503,28 @@ Warnings: Warning 1292 Incorrect datetime value: '100000:00:00' SET SESSION old_mode=DEFAULT; # +# MDEV-35489 Assertion `!ldate->neg' or unexpected result upon extracting unit from invalid value +# +SELECT EXTRACT(DAY FROM TIMESTAMP(-177498480000)); +EXTRACT(DAY FROM TIMESTAMP(-177498480000)) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '-177498480000' +SELECT EXTRACT(DAY FROM TIMESTAMP(-177498480001)); +EXTRACT(DAY FROM TIMESTAMP(-177498480001)) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '-177498480001' +SELECT EXTRACT(DAY FROM TIMESTAMP(-200000000000)); +EXTRACT(DAY FROM TIMESTAMP(-200000000000)) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '-200000000000' +SELECT EXTRACT(DAY FROM TIMESTAMP(-221938034527)); +EXTRACT(DAY FROM TIMESTAMP(-221938034527)) +NULL +Warnings: +Warning 1292 Incorrect datetime value: '-221938034527' +# # End of 10.5 tests # diff --git a/mysql-test/main/func_extract.test b/mysql-test/main/func_extract.test index 05c5529659b..234a65547f1 100644 --- a/mysql-test/main/func_extract.test +++ b/mysql-test/main/func_extract.test @@ -528,6 +528,16 @@ SELECT CAST('100000:00:00' AS DATE); SELECT EXTRACT(DAY FROM CAST('100000:00:00' AS DATE)); SET SESSION old_mode=DEFAULT; +--echo # +--echo # MDEV-35489 Assertion `!ldate->neg' or unexpected result upon extracting unit from invalid value +--echo # + +SELECT EXTRACT(DAY FROM TIMESTAMP(-177498480000)); +SELECT EXTRACT(DAY FROM TIMESTAMP(-177498480001)); +SELECT EXTRACT(DAY FROM TIMESTAMP(-200000000000)); +SELECT EXTRACT(DAY FROM TIMESTAMP(-221938034527)); + + --echo # --echo # End of 10.5 tests --echo #