diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/main/func_extract.result | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/main/func_extract.result')
-rw-r--r-- | mysql-test/main/func_extract.result | 592 |
1 files changed, 592 insertions, 0 deletions
diff --git a/mysql-test/main/func_extract.result b/mysql-test/main/func_extract.result new file mode 100644 index 00000000..bebb8c71 --- /dev/null +++ b/mysql-test/main/func_extract.result @@ -0,0 +1,592 @@ +# +# MDEV-17385 MICROSECOND() returns confusing results with an out-of-range TIME-alike argument +# +CREATE TABLE t1 (v VARCHAR(64), ll BIGINT, t TIME, dt DATETIME, d DATE); +CREATE TABLE t2 AS SELECT +EXTRACT(DAY FROM t), +EXTRACT(DAY_HOUR FROM t), +EXTRACT(DAY_MINUTE FROM t), +EXTRACT(DAY_SECOND FROM t), +EXTRACT(DAY_MICROSECOND FROM t), +EXTRACT(DAY FROM d), +EXTRACT(DAY_HOUR FROM d), +EXTRACT(DAY_MINUTE FROM d), +EXTRACT(DAY_SECOND FROM d), +EXTRACT(DAY_MICROSECOND FROM d), +EXTRACT(DAY FROM v), +EXTRACT(DAY_HOUR FROM v), +EXTRACT(DAY_MINUTE FROM v), +EXTRACT(DAY_SECOND FROM v), +EXTRACT(DAY_MICROSECOND FROM v), +EXTRACT(DAY FROM ll), +EXTRACT(DAY_HOUR FROM ll), +EXTRACT(DAY_MINUTE FROM ll), +EXTRACT(DAY_SECOND FROM ll), +EXTRACT(DAY_MICROSECOND FROM ll) +FROM t1; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `EXTRACT(DAY FROM t)` int(3) DEFAULT NULL, + `EXTRACT(DAY_HOUR FROM t)` int(5) DEFAULT NULL, + `EXTRACT(DAY_MINUTE FROM t)` int(7) DEFAULT NULL, + `EXTRACT(DAY_SECOND FROM t)` int(9) DEFAULT NULL, + `EXTRACT(DAY_MICROSECOND FROM t)` bigint(15) DEFAULT NULL, + `EXTRACT(DAY FROM d)` int(3) DEFAULT NULL, + `EXTRACT(DAY_HOUR FROM d)` int(5) DEFAULT NULL, + `EXTRACT(DAY_MINUTE FROM d)` int(7) DEFAULT NULL, + `EXTRACT(DAY_SECOND FROM d)` int(9) DEFAULT NULL, + `EXTRACT(DAY_MICROSECOND FROM d)` bigint(15) DEFAULT NULL, + `EXTRACT(DAY FROM v)` int(8) DEFAULT NULL, + `EXTRACT(DAY_HOUR FROM v)` int(10) DEFAULT NULL, + `EXTRACT(DAY_MINUTE FROM v)` bigint(12) DEFAULT NULL, + `EXTRACT(DAY_SECOND FROM v)` bigint(14) DEFAULT NULL, + `EXTRACT(DAY_MICROSECOND FROM v)` bigint(20) DEFAULT NULL, + `EXTRACT(DAY FROM ll)` int(8) DEFAULT NULL, + `EXTRACT(DAY_HOUR FROM ll)` int(10) DEFAULT NULL, + `EXTRACT(DAY_MINUTE FROM ll)` bigint(12) DEFAULT NULL, + `EXTRACT(DAY_SECOND FROM ll)` bigint(14) DEFAULT NULL, + `EXTRACT(DAY_MICROSECOND FROM ll)` bigint(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(64), b DECIMAL(32,9)); +INSERT INTO t1 VALUES +('9999-12-31 23:59:59.123456', 99991231235959.123456), +('2001-01-01 10:20:30.123456', 20010101102030.123456), +('4294967296:59:59.123456', 42949672965959.123456), +('4294967295:59:59.123456', 42949672955959.123456), +('87649416:59:59.123456', 876494165959.123456), +('87649415:59:59.123456', 876494155959.123456), +('87649414:59:59.123456', 876494145959.123456), +('9999:59:59.123456', 99995959.123456), +('9999:01:01.123456', 99990101.123456), +('9999:01:01', 99990101), +('0.999999', 0.999999), +('0.99999', 0.99999), +('0.9999', 0.9999), +('0.999', 0.999), +('0.99', 0.99), +('0.9', 0.9), +('000000',0); +# Summary: +# Check that FUNC(varchar) and FUNC(decimal) give equal results +# Expect empty sets +SELECT a, b, EXTRACT(DAY_HOUR FROM a), EXTRACT(DAY_HOUR FROM b) FROM t1 WHERE NOT (EXTRACT(DAY_HOUR FROM a)<=>EXTRACT(DAY_HOUR FROM b)); +a b EXTRACT(DAY_HOUR FROM a) EXTRACT(DAY_HOUR FROM b) +SELECT a, b, EXTRACT(DAY FROM a), EXTRACT(DAY FROM b) FROM t1 WHERE NOT (EXTRACT(DAY FROM a)<=>EXTRACT(DAY FROM b)); +a b EXTRACT(DAY FROM a) EXTRACT(DAY FROM b) +SELECT a, b, EXTRACT(HOUR FROM a), EXTRACT(HOUR FROM b) FROM t1 WHERE NOT (EXTRACT(HOUR FROM a)<=>EXTRACT(HOUR FROM b)); +a b EXTRACT(HOUR FROM a) EXTRACT(HOUR FROM b) +SELECT a, b, EXTRACT(MINUTE FROM a), EXTRACT(MINUTE FROM b) FROM t1 WHERE NOT (EXTRACT(MINUTE FROM a)<=>EXTRACT(MINUTE FROM b)); +a b EXTRACT(MINUTE FROM a) EXTRACT(MINUTE FROM b) +SELECT a, b, EXTRACT(SECOND FROM a), EXTRACT(SECOND FROM b) FROM t1 WHERE NOT (EXTRACT(SECOND FROM a)<=>EXTRACT(SECOND FROM b)); +a b EXTRACT(SECOND FROM a) EXTRACT(SECOND FROM b) +SELECT a, b, EXTRACT(MICROSECOND FROM a), EXTRACT(MICROSECOND FROM b) FROM t1 WHERE NOT (EXTRACT(MICROSECOND FROM a)<=>EXTRACT(MICROSECOND FROM b)); +a b EXTRACT(MICROSECOND FROM a) EXTRACT(MICROSECOND FROM b) +# Detailed results +SELECT +a, +CAST(a AS INTERVAL DAY_SECOND(6)) AS cidm, +EXTRACT(DAY FROM a) * 24 + EXTRACT(HOUR FROM a) AS dh, +EXTRACT(DAY_HOUR FROM a), +EXTRACT(DAY FROM a), +EXTRACT(HOUR FROM a), +EXTRACT(MINUTE FROM a), +EXTRACT(SECOND FROM a), +EXTRACT(MICROSECOND FROM a) +FROM t1; +a cidm dh EXTRACT(DAY_HOUR FROM a) EXTRACT(DAY FROM a) EXTRACT(HOUR FROM a) EXTRACT(MINUTE FROM a) EXTRACT(SECOND FROM a) EXTRACT(MICROSECOND FROM a) +9999-12-31 23:59:59.123456 NULL 767 3123 31 23 59 59 123456 +2001-01-01 10:20:30.123456 NULL 34 110 1 10 20 30 123456 +4294967296:59:59.123456 NULL NULL NULL NULL NULL NULL NULL NULL +4294967295:59:59.123456 NULL NULL NULL NULL NULL NULL NULL NULL +87649416:59:59.123456 NULL NULL NULL NULL NULL NULL NULL NULL +87649415:59:59.123456 3652058 23:59:59.123456 87649415 365205823 3652058 23 59 59 123456 +87649414:59:59.123456 3652058 22:59:59.123456 87649414 365205822 3652058 22 59 59 123456 +9999:59:59.123456 416 15:59:59.123456 9999 41615 416 15 59 59 123456 +9999:01:01.123456 416 15:01:01.123456 9999 41615 416 15 1 1 123456 +9999:01:01 416 15:01:01.000000 9999 41615 416 15 1 1 0 +0.999999 00:00:00.999999 0 0 0 0 0 0 999999 +0.99999 00:00:00.999990 0 0 0 0 0 0 999990 +0.9999 00:00:00.999900 0 0 0 0 0 0 999900 +0.999 00:00:00.999000 0 0 0 0 0 0 999000 +0.99 00:00:00.990000 0 0 0 0 0 0 990000 +0.9 00:00:00.900000 0 0 0 0 0 0 900000 +000000 00:00:00.000000 0 0 0 0 0 0 0 +Warnings: +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '9999-12-31 23:59:59.123456' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 10:20:30.123456' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect interval value: '4294967296:59:59.123456' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect interval value: '4294967295:59:59.123456' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +Warning 1292 Incorrect interval value: '87649416:59:59.123456' +SELECT +b, +CAST(b AS INTERVAL DAY_SECOND(6)) AS cidm, +EXTRACT(DAY FROM b) * 24 + EXTRACT(HOUR FROM b) AS dh, +EXTRACT(DAY_HOUR FROM b), +EXTRACT(DAY FROM b), +EXTRACT(HOUR FROM b), +EXTRACT(MINUTE FROM b), +EXTRACT(SECOND FROM b), +EXTRACT(MICROSECOND FROM b) +FROM t1; +b cidm dh EXTRACT(DAY_HOUR FROM b) EXTRACT(DAY FROM b) EXTRACT(HOUR FROM b) EXTRACT(MINUTE FROM b) EXTRACT(SECOND FROM b) EXTRACT(MICROSECOND FROM b) +99991231235959.123456000 NULL 767 3123 31 23 59 59 123456 +20010101102030.123456000 NULL 34 110 1 10 20 30 123456 +42949672965959.123456000 NULL NULL NULL NULL NULL NULL NULL NULL +42949672955959.123456000 NULL NULL NULL NULL NULL NULL NULL NULL +876494165959.123456000 NULL NULL NULL NULL NULL NULL NULL NULL +876494155959.123456000 3652058 23:59:59.123456 87649415 365205823 3652058 23 59 59 123456 +876494145959.123456000 3652058 22:59:59.123456 87649414 365205822 3652058 22 59 59 123456 +99995959.123456000 416 15:59:59.123456 9999 41615 416 15 59 59 123456 +99990101.123456000 416 15:01:01.123456 9999 41615 416 15 1 1 123456 +99990101.000000000 416 15:01:01.000000 9999 41615 416 15 1 1 0 +0.999999000 00:00:00.999999 0 0 0 0 0 0 999999 +0.999990000 00:00:00.999990 0 0 0 0 0 0 999990 +0.999900000 00:00:00.999900 0 0 0 0 0 0 999900 +0.999000000 00:00:00.999000 0 0 0 0 0 0 999000 +0.990000000 00:00:00.990000 0 0 0 0 0 0 990000 +0.900000000 00:00:00.900000 0 0 0 0 0 0 900000 +0.000000000 00:00:00.000000 0 0 0 0 0 0 0 +Warnings: +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '99991231235959.123456000' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '20010101102030.123456000' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '42949672965959.123456000' +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect interval value: '42949672965959.123456000' for column `test`.`t1`.`b` at row 3 +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '42949672955959.123456000' +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect interval value: '42949672955959.123456000' for column `test`.`t1`.`b` at row 4 +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '876494165959.123456000' +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Warning 1292 Incorrect interval value: '876494165959.123456000' for column `test`.`t1`.`b` at row 5 +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '876494155959.123456000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '876494145959.123456000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '99995959.123456000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '99990101.123456000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '99990101.000000000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '0.999999000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '0.999990000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '0.999900000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '0.999000000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '0.990000000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '0.900000000' +Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '0.000000000' +DROP TABLE t1; +# Special case: DAY + TIME +CREATE TABLE t1 (a VARCHAR(64)); +INSERT INTO t1 VALUES ('9999-01-01'); +SELECT a, +EXTRACT(DAY_HOUR FROM a), +EXTRACT(DAY_MINUTE FROM a), +EXTRACT(DAY_SECOND FROM a), +EXTRACT(DAY_MICROSECOND FROM a), +EXTRACT(DAY FROM a), +EXTRACT(HOUR FROM a), +EXTRACT(MINUTE FROM a), +EXTRACT(SECOND FROM a), +EXTRACT(MICROSECOND FROM a) +FROM t1; +a EXTRACT(DAY_HOUR FROM a) EXTRACT(DAY_MINUTE FROM a) EXTRACT(DAY_SECOND FROM a) EXTRACT(DAY_MICROSECOND FROM a) EXTRACT(DAY FROM a) EXTRACT(HOUR FROM a) EXTRACT(MINUTE FROM a) EXTRACT(SECOND FROM a) EXTRACT(MICROSECOND FROM a) +9999-01-01 100 10000 1000000 1000000000000 1 0 0 0 0 +DROP TABLE t1; +# Bad values +CREATE TABLE t1 (a VARCHAR(64)); +INSERT INTO t1 VALUES (''); +SELECT a, +CAST(a AS INTERVAL DAY_SECOND(6)) AS cidm, +EXTRACT(DAY_HOUR FROM a), +EXTRACT(DAY_MINUTE FROM a), +EXTRACT(DAY_SECOND FROM a), +EXTRACT(DAY_MICROSECOND FROM a), +EXTRACT(DAY FROM a), +EXTRACT(HOUR FROM a), +EXTRACT(MINUTE FROM a), +EXTRACT(SECOND FROM a), +EXTRACT(MICROSECOND FROM a) +FROM t1; +a cidm EXTRACT(DAY_HOUR FROM a) EXTRACT(DAY_MINUTE FROM a) EXTRACT(DAY_SECOND FROM a) EXTRACT(DAY_MICROSECOND FROM a) EXTRACT(DAY FROM a) EXTRACT(HOUR FROM a) EXTRACT(MINUTE FROM a) EXTRACT(SECOND FROM a) EXTRACT(MICROSECOND FROM a) + NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +Warnings: +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +Warning 1292 Incorrect interval value: '' +DROP TABLE t1; +# Backward compatibility +# This still parses as DATETIME +SELECT EXTRACT(YEAR FROM '2001/02/03 10:20:30'); +EXTRACT(YEAR FROM '2001/02/03 10:20:30') +2001 +SELECT EXTRACT(MONTH FROM '2001/02/03 10:20:30'); +EXTRACT(MONTH FROM '2001/02/03 10:20:30') +2 +SELECT EXTRACT(DAY FROM '2001/02/03 10:20:30'); +EXTRACT(DAY FROM '2001/02/03 10:20:30') +3 +SELECT EXTRACT(YEAR FROM '01/02/03 10:20:30'); +EXTRACT(YEAR FROM '01/02/03 10:20:30') +2001 +SELECT EXTRACT(MONTH FROM '01/02/03 10:20:30'); +EXTRACT(MONTH FROM '01/02/03 10:20:30') +2 +SELECT EXTRACT(DAY FROM '01/02/03 10:20:30'); +EXTRACT(DAY FROM '01/02/03 10:20:30') +3 +SELECT EXTRACT(YEAR FROM '01:02:03 10:20:30'); +EXTRACT(YEAR FROM '01:02:03 10:20:30') +2001 +SELECT EXTRACT(MONTH FROM '01:02:03 10:20:30'); +EXTRACT(MONTH FROM '01:02:03 10:20:30') +2 +SELECT EXTRACT(DAY FROM '01:02:03 10:20:30'); +EXTRACT(DAY FROM '01:02:03 10:20:30') +3 +# This still parses as DATETIME and returns NULL +SELECT EXTRACT(YEAR FROM "2011-02-32 8:46:06.23434"); +EXTRACT(YEAR FROM "2011-02-32 8:46:06.23434") +NULL +Warnings: +Warning 1292 Incorrect datetime value: '2011-02-32 8:46:06.23434' +SELECT EXTRACT(MONTH FROM "2011-02-32 8:46:06.23434"); +EXTRACT(MONTH FROM "2011-02-32 8:46:06.23434") +NULL +Warnings: +Warning 1292 Incorrect datetime value: '2011-02-32 8:46:06.23434' +SELECT EXTRACT(DAY FROM "2011-02-32 8:46:06.23434"); +EXTRACT(DAY FROM "2011-02-32 8:46:06.23434") +NULL +Warnings: +Warning 1292 Incorrect interval value: '2011-02-32 8:46:06.23434' +SELECT EXTRACT(HOUR FROM "2011-02-32 8:46:06.23434"); +EXTRACT(HOUR FROM "2011-02-32 8:46:06.23434") +NULL +Warnings: +Warning 1292 Incorrect interval value: '2011-02-32 8:46:06.23434' +# This still parses as DATE +SELECT EXTRACT(YEAR FROM '2001/02/03'); +EXTRACT(YEAR FROM '2001/02/03') +2001 +SELECT EXTRACT(MONTH FROM '2001/02/03'); +EXTRACT(MONTH FROM '2001/02/03') +2 +SELECT EXTRACT(DAY FROM '2001/02/03'); +EXTRACT(DAY FROM '2001/02/03') +3 +SELECT EXTRACT(YEAR FROM '01/02/03'); +EXTRACT(YEAR FROM '01/02/03') +2001 +SELECT EXTRACT(MONTH FROM '01/02/03'); +EXTRACT(MONTH FROM '01/02/03') +2 +SELECT EXTRACT(DAY FROM '01/02/03'); +EXTRACT(DAY FROM '01/02/03') +3 +SELECT EXTRACT(YEAR FROM '01-02-03'); +EXTRACT(YEAR FROM '01-02-03') +2001 +SELECT EXTRACT(MONTH FROM '01-02-03'); +EXTRACT(MONTH FROM '01-02-03') +2 +SELECT EXTRACT(DAY FROM '01-02-03'); +EXTRACT(DAY FROM '01-02-03') +3 +SELECT EXTRACT(YEAR FROM '1-2-3'); +EXTRACT(YEAR FROM '1-2-3') +1 +SELECT EXTRACT(MONTH FROM '1-2-3'); +EXTRACT(MONTH FROM '1-2-3') +2 +SELECT EXTRACT(DAY FROM '1-2-3'); +EXTRACT(DAY FROM '1-2-3') +3 +SELECT EXTRACT(HOUR FROM '1-2-3'); +EXTRACT(HOUR FROM '1-2-3') +0 +SELECT EXTRACT(DAY FROM '2024-01-03 garbage /////'); +EXTRACT(DAY FROM '2024-01-03 garbage /////') +3 +Warnings: +Warning 1292 Truncated incorrect date value: '2024-01-03 garbage /////' +SELECT EXTRACT(DAY FROM '24-01-03 garbage /////'); +EXTRACT(DAY FROM '24-01-03 garbage /////') +3 +Warnings: +Warning 1292 Truncated incorrect date value: '24-01-03 garbage /////' +SELECT EXTRACT(DAY FROM '01-02-03'); +EXTRACT(DAY FROM '01-02-03') +3 +SELECT EXTRACT(DAY FROM '24:02:03T'); +EXTRACT(DAY FROM '24:02:03T') +3 +SELECT EXTRACT(DAY FROM '24-02-03'); +EXTRACT(DAY FROM '24-02-03') +3 +SELECT EXTRACT(DAY FROM '24/02/03'); +EXTRACT(DAY FROM '24/02/03') +3 +SELECT EXTRACT(DAY FROM '11111'); +EXTRACT(DAY FROM '11111') +1 +SELECT TIME('2001-01-01T'), TIME('2001-01-01T '); +TIME('2001-01-01T') TIME('2001-01-01T ') +00:00:00 00:00:00 +SELECT TIME('2001/01/01T'), TIME('2001/01/01T '); +TIME('2001/01/01T') TIME('2001/01/01T ') +00:00:00 00:00:00 +SELECT TIME('2001:01:01T'), TIME('2001:01:01T '); +TIME('2001:01:01T') TIME('2001:01:01T ') +00:00:00 00:00:00 +SELECT EXTRACT(DAY FROM '2001-01-01T'), EXTRACT(DAY FROM '2001-01-01T '); +EXTRACT(DAY FROM '2001-01-01T') EXTRACT(DAY FROM '2001-01-01T ') +1 1 +SELECT EXTRACT(DAY FROM '2001/01/01T'), EXTRACT(DAY FROM '2001/01/01T '); +EXTRACT(DAY FROM '2001/01/01T') EXTRACT(DAY FROM '2001/01/01T ') +1 1 +SELECT EXTRACT(DAY FROM '2001:01:01T'), EXTRACT(DAY FROM '2001:01:01T '); +EXTRACT(DAY FROM '2001:01:01T') EXTRACT(DAY FROM '2001:01:01T ') +1 1 +SELECT TIME('2001:01:01T'), TIME('2001:01:01T '); +TIME('2001:01:01T') TIME('2001:01:01T ') +00:00:00 00:00:00 +SELECT EXTRACT(HOUR FROM '2001-01-01T'), EXTRACT(HOUR FROM '2001-01-01T '); +EXTRACT(HOUR FROM '2001-01-01T') EXTRACT(HOUR FROM '2001-01-01T ') +0 0 +SELECT EXTRACT(HOUR FROM '2001/01/01T'), EXTRACT(HOUR FROM '2001/01/01T '); +EXTRACT(HOUR FROM '2001/01/01T') EXTRACT(HOUR FROM '2001/01/01T ') +0 0 +SELECT EXTRACT(HOUR FROM '2001:01:01T'), EXTRACT(HOUR FROM '2001:01:01T '); +EXTRACT(HOUR FROM '2001:01:01T') EXTRACT(HOUR FROM '2001:01:01T ') +0 0 +# This still parses as DATE and returns NULL (without trying TIME) +SELECT EXTRACT(DAY FROM '100000:02:03T'); +EXTRACT(DAY FROM '100000:02:03T') +NULL +Warnings: +Warning 1292 Incorrect interval value: '100000:02:03T' +SELECT EXTRACT(DAY FROM '100000/02/03'); +EXTRACT(DAY FROM '100000/02/03') +NULL +Warnings: +Warning 1292 Incorrect interval value: '100000/02/03' +SELECT EXTRACT(DAY FROM '100000-02-03'); +EXTRACT(DAY FROM '100000-02-03') +NULL +Warnings: +Warning 1292 Incorrect interval value: '100000-02-03' +SELECT EXTRACT(DAY FROM '1111'); +EXTRACT(DAY FROM '1111') +NULL +Warnings: +Warning 1292 Incorrect interval value: '1111' +SELECT EXTRACT(DAY FROM '111'); +EXTRACT(DAY FROM '111') +NULL +Warnings: +Warning 1292 Incorrect interval value: '111' +SELECT EXTRACT(DAY FROM '11'); +EXTRACT(DAY FROM '11') +NULL +Warnings: +Warning 1292 Incorrect interval value: '11' +SELECT EXTRACT(DAY FROM '1'); +EXTRACT(DAY FROM '1') +NULL +Warnings: +Warning 1292 Incorrect interval value: '1' +# This still parses as TIME +SELECT EXTRACT(HOUR FROM '11111'); +EXTRACT(HOUR FROM '11111') +1 +SELECT EXTRACT(HOUR FROM '1111'); +EXTRACT(HOUR FROM '1111') +0 +SELECT EXTRACT(HOUR FROM '111'); +EXTRACT(HOUR FROM '111') +0 +SELECT EXTRACT(HOUR FROM '11'); +EXTRACT(HOUR FROM '11') +0 +SELECT EXTRACT(HOUR FROM '1'); +EXTRACT(HOUR FROM '1') +0 +SELECT TIME('01:02:03:'); +TIME('01:02:03:') +01:02:03 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03:' +SELECT TIME('01:02:03-'); +TIME('01:02:03-') +01:02:03 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03-' +SELECT TIME('01:02:03;'); +TIME('01:02:03;') +01:02:03 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03;' +SELECT TIME('01:02:03/'); +TIME('01:02:03/') +01:02:03 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03/' +SELECT EXTRACT(HOUR FROM '01:02:03:'); +EXTRACT(HOUR FROM '01:02:03:') +1 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03:' +SELECT EXTRACT(HOUR FROM '01:02:03-'); +EXTRACT(HOUR FROM '01:02:03-') +1 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03-' +SELECT EXTRACT(HOUR FROM '01:02:03;'); +EXTRACT(HOUR FROM '01:02:03;') +1 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03;' +SELECT EXTRACT(HOUR FROM '01:02:03/'); +EXTRACT(HOUR FROM '01:02:03/') +1 +Warnings: +Warning 1292 Truncated incorrect time value: '01:02:03/' +# Backward compatibility preserved for YEAR and MONTH only +# (behavior has changed for DAY, see below) +SELECT EXTRACT(YEAR FROM '01:02:03'); +EXTRACT(YEAR FROM '01:02:03') +2001 +SELECT EXTRACT(MONTH FROM '01:02:03'); +EXTRACT(MONTH FROM '01:02:03') +2 +SELECT EXTRACT(YEAR FROM '24:01:03 garbage /////'); +EXTRACT(YEAR FROM '24:01:03 garbage /////') +2024 +Warnings: +Warning 1292 Truncated incorrect date value: '24:01:03 garbage /////' +SELECT EXTRACT(MONTH FROM '24:01:03 garbage /////'); +EXTRACT(MONTH FROM '24:01:03 garbage /////') +1 +Warnings: +Warning 1292 Truncated incorrect date value: '24:01:03 garbage /////' +# This still parses as TIME 00:20:01 +SELECT TIME('2001/01/01'); +TIME('2001/01/01') +00:20:01 +Warnings: +Warning 1292 Truncated incorrect time value: '2001/01/01' +SELECT TIME('2001-01-01'); +TIME('2001-01-01') +00:20:01 +Warnings: +Warning 1292 Truncated incorrect time value: '2001-01-01' +# This still parses as TIME and overflows to '838:59:59' +SELECT TIME('2001:01:01'); +TIME('2001:01:01') +838:59:59 +Warnings: +Warning 1292 Truncated incorrect time value: '2001:01:01' +# This used to parse as DATE, now parses as TIME interval +CREATE TABLE t1 (a VARCHAR(64)); +INSERT INTO t1 VALUES +('2024:01:03 garbage /////'), +('24:01:03 garbage /////'), +('01:01:03 garbage /////'), +('2024:02:03'), +('100000:02:03'), +('24:02:03'), +('01:02:03'), +('01:02:03:'), +('01:02:03-'), +('01:02:03;'), +('01:02:03/'), +('20 10:20:30'); +SELECT +EXTRACT(DAY FROM a), +EXTRACT(DAY_SECOND FROM a), a, +CAST(a AS INTERVAL DAY_SECOND(6)) AS cidm +FROM t1; +EXTRACT(DAY FROM a) EXTRACT(DAY_SECOND FROM a) a cidm +84 84080103 2024:01:03 garbage ///// NULL +1 1000103 24:01:03 garbage ///// NULL +0 10103 01:01:03 garbage ///// NULL +84 84080203 2024:02:03 84 08:02:03.000000 +4166 4166160203 100000:02:03 4166 16:02:03.000000 +1 1000203 24:02:03 1 00:02:03.000000 +0 10203 01:02:03 01:02:03.000000 +0 10203 01:02:03: 01:02:03.000000 +0 10203 01:02:03- NULL +0 10203 01:02:03; 01:02:03.000000 +0 10203 01:02:03/ 01:02:03.000000 +20 20102030 20 10:20:30 20 10:20:30.000000 +Warnings: +Warning 1292 Truncated incorrect time value: '2024:01:03 garbage /////' +Warning 1292 Truncated incorrect time value: '2024:01:03 garbage /////' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2024:01:03 garbage /////' +Warning 1292 Truncated incorrect time value: '24:01:03 garbage /////' +Warning 1292 Truncated incorrect time value: '24:01:03 garbage /////' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '24:01:03 garbage /////' +Warning 1292 Truncated incorrect time value: '01:01:03 garbage /////' +Warning 1292 Truncated incorrect time value: '01:01:03 garbage /////' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '01:01:03 garbage /////' +Warning 1292 Truncated incorrect time value: '01:02:03:' +Warning 1292 Truncated incorrect time value: '01:02:03:' +Warning 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '01:02:03:' +Warning 1292 Truncated incorrect time value: '01:02:03-' +Warning 1292 Truncated incorrect time value: '01:02:03-' +Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '01:02:03-' +Warning 1292 Truncated incorrect time value: '01:02:03;' +Warning 1292 Truncated incorrect time value: '01:02:03;' +Warning 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '01:02:03;' +Warning 1292 Truncated incorrect time value: '01:02:03/' +Warning 1292 Truncated incorrect time value: '01:02:03/' +Warning 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '01:02:03/' +DROP TABLE t1; |