1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-5372 Make "CAST(time_expr AS DATETIME)" compatible with MySQL-5.6 (and the SQL Standard)

This commit is contained in:
Alexander Barkov
2014-03-07 00:21:25 +04:00
parent b95c8ce530
commit 89e1715355
33 changed files with 604 additions and 209 deletions

View File

@ -1,3 +1,4 @@
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
DROP TABLE IF EXISTS t1_selects, t1_modes, t1_values;
DROP VIEW IF EXISTS v1;
CREATE TABLE t1_values
@ -3936,12 +3937,10 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
NULL -838:59:59 2
0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '-838:59:59'
2000-12-30 01:00:01 -838:59:59 2
2001-03-09 22:59:59 838:59:59 3
2001-02-03 13:00:00 13:00:00 4
2001-02-03 10:00:00 10:00:00 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3950,12 +3949,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
NULL -838:59:59 2
0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '-838:59:59'
2000-12-30 01:00:01 -838:59:59 2
2001-03-09 22:59:59 838:59:59 3
2001-02-03 13:00:00 13:00:00 4
2001-02-03 10:00:00 10:00:00 5
DROP VIEW v1;
@ -4302,10 +4299,10 @@ my_time, id FROM t1_values
WHERE select_id = 35 OR select_id IS NULL order by id;
CAST(my_time AS DATE) my_time id
NULL NULL 1
0000-00-00 -838:59:59 2
0000-00-00 838:59:59 3
0000-00-00 13:00:00 4
0000-00-00 10:00:00 5
2000-12-30 -838:59:59 2
2001-03-09 838:59:59 3
2001-02-03 13:00:00 4
2001-02-03 10:00:00 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as date) AS `CAST(my_time AS DATE)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -4314,10 +4311,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 35 OR select_id IS NULL) order by id;
CAST(my_time AS DATE) my_time id
NULL NULL 1
0000-00-00 -838:59:59 2
0000-00-00 838:59:59 3
0000-00-00 13:00:00 4
0000-00-00 10:00:00 5
2000-12-30 -838:59:59 2
2001-03-09 838:59:59 3
2001-02-03 13:00:00 4
2001-02-03 10:00:00 5
DROP VIEW v1;
@ -5280,3 +5277,4 @@ DROP VIEW v1;
DROP TABLE t1_selects, t1_modes, t1_values;
SET timestamp=DEFAULT;

View File

@ -1,4 +1,5 @@
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
DROP TABLE IF EXISTS t1_selects, t1_modes, t1_values;
DROP VIEW IF EXISTS v1;
CREATE TABLE t1_values
@ -3937,12 +3938,10 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
NULL -838:59:59 2
0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '-838:59:59'
2000-12-30 01:00:01 -838:59:59 2
2001-03-09 22:59:59 838:59:59 3
2001-02-03 13:00:00 13:00:00 4
2001-02-03 10:00:00 10:00:00 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3951,12 +3950,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
NULL -838:59:59 2
0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '-838:59:59'
2000-12-30 01:00:01 -838:59:59 2
2001-03-09 22:59:59 838:59:59 3
2001-02-03 13:00:00 13:00:00 4
2001-02-03 10:00:00 10:00:00 5
DROP VIEW v1;
@ -4303,10 +4300,10 @@ my_time, id FROM t1_values
WHERE select_id = 35 OR select_id IS NULL order by id;
CAST(my_time AS DATE) my_time id
NULL NULL 1
0000-00-00 -838:59:59 2
0000-00-00 838:59:59 3
0000-00-00 13:00:00 4
0000-00-00 10:00:00 5
2000-12-30 -838:59:59 2
2001-03-09 838:59:59 3
2001-02-03 13:00:00 4
2001-02-03 10:00:00 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as date) AS `CAST(my_time AS DATE)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -4315,10 +4312,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 35 OR select_id IS NULL) order by id;
CAST(my_time AS DATE) my_time id
NULL NULL 1
0000-00-00 -838:59:59 2
0000-00-00 838:59:59 3
0000-00-00 13:00:00 4
0000-00-00 10:00:00 5
2000-12-30 -838:59:59 2
2001-03-09 838:59:59 3
2001-02-03 13:00:00 4
2001-02-03 10:00:00 5
DROP VIEW v1;
@ -5281,3 +5278,4 @@ DROP VIEW v1;
DROP TABLE t1_selects, t1_modes, t1_values;
SET timestamp=DEFAULT;

View File

@ -1,4 +1,5 @@
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET timestamp=unix_timestamp('2001-02-03 10:20:30');
DROP TABLE IF EXISTS t1_selects, t1_modes, t1_values;
DROP VIEW IF EXISTS v1;
CREATE TABLE t1_values
@ -3937,12 +3938,10 @@ my_time, id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
NULL -838:59:59 2
0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '-838:59:59'
2000-12-30 01:00:01 -838:59:59 2
2001-03-09 22:59:59 838:59:59 3
2001-02-03 13:00:00 13:00:00 4
2001-02-03 10:00:00 10:00:00 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as datetime) AS `CAST(my_time AS DATETIME)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -3951,12 +3950,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 46 OR select_id IS NULL) order by id;
CAST(my_time AS DATETIME) my_time id
NULL NULL 1
NULL -838:59:59 2
0000-01-03 22:59:59 838:59:59 3
0000-00-00 13:00:00 13:00:00 4
0000-00-00 10:00:00 10:00:00 5
Warnings:
Warning 1292 Truncated incorrect datetime value: '-838:59:59'
2000-12-30 01:00:01 -838:59:59 2
2001-03-09 22:59:59 838:59:59 3
2001-02-03 13:00:00 13:00:00 4
2001-02-03 10:00:00 10:00:00 5
DROP VIEW v1;
@ -4303,10 +4300,10 @@ my_time, id FROM t1_values
WHERE select_id = 35 OR select_id IS NULL order by id;
CAST(my_time AS DATE) my_time id
NULL NULL 1
0000-00-00 -838:59:59 2
0000-00-00 838:59:59 3
0000-00-00 13:00:00 4
0000-00-00 10:00:00 5
2000-12-30 -838:59:59 2
2001-03-09 838:59:59 3
2001-02-03 13:00:00 4
2001-02-03 10:00:00 5
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select cast(`t1_values`.`my_time` as date) AS `CAST(my_time AS DATE)`,`t1_values`.`my_time` AS `my_time`,`t1_values`.`id` AS `id` from `t1_values` latin1 latin1_swedish_ci
@ -4315,10 +4312,10 @@ WHERE v1.id IN (SELECT id FROM t1_values
WHERE select_id = 35 OR select_id IS NULL) order by id;
CAST(my_time AS DATE) my_time id
NULL NULL 1
0000-00-00 -838:59:59 2
0000-00-00 838:59:59 3
0000-00-00 13:00:00 4
0000-00-00 10:00:00 5
2000-12-30 -838:59:59 2
2001-03-09 838:59:59 3
2001-02-03 13:00:00 4
2001-02-03 10:00:00 5
DROP VIEW v1;
@ -5281,3 +5278,4 @@ DROP VIEW v1;
DROP TABLE t1_selects, t1_modes, t1_values;
SET timestamp=DEFAULT;