You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WL#12535: Retrieve the stored timestamp as UTC datetime
Implement SQL standard clause AT TIME ZONE for values of type
TIMESTAMP, combined with a CAST to DATETIME.
The purpose of this is to convert the UTC part of a TIMESTAMP
to a DATETIME, without also converting the value to the local
time zone. It can be used to obtain the UTC value in the client.
For this reason, the time zone part of the AT TIME ZONE clause must
be specified as '+00:00' or UTC (which is equivalent to the former).
For completeness, we also convert DATETIME values, such as
literals, in the same manner.
Reviewed by: Roy Lyseng <roy.lyseng@oracle.com>
Change-Id: I805cd4722add368acc4ced383ae3c9cb786db4c3
Copy file name to clipboardExpand all lines: mysql-test/r/parser.result
+46
Original file line number
Diff line number
Diff line change
@@ -2686,3 +2686,49 @@ SELECT @var;
2686
2686
SELECT @var;
2687
2687
@var
2688
2688
4
2689
+
#
2690
+
# <time zone> syntax.
2691
+
#
2692
+
SET time_zone = '+01:00';
2693
+
SELECT cast( DATE'2019-10-10' AT LOCAL AS DATETIME );
2694
+
ERROR 42000: This version of MySQL doesn't yet support 'AT LOCAL'
2695
+
SELECT cast( DATE'2019-10-10' AT TIME ZONE 'UTC' AS DATETIME );
2696
+
ERROR HY000: Cannot cast value to TIMESTAMP WITH TIME ZONE.
2697
+
SELECT cast( TIME'10:10' AT LOCAL AS DATETIME );
2698
+
ERROR 42000: This version of MySQL doesn't yet support 'AT LOCAL'
2699
+
SELECT cast( TIME'10:10' AT TIME ZONE '+01:00' AS DATETIME );
2700
+
ERROR HY000: Cannot cast value to TIMESTAMP WITH TIME ZONE.
2701
+
SELECT cast( TIME'10:10' AT TIME ZONE INTERVAL 'UTC' AS DATETIME );
2702
+
ERROR HY000: Cannot cast value to TIMESTAMP WITH TIME ZONE.
2703
+
SELECT cast( TIME'10:10' AT TIME ZONE '' AS DATETIME );
2704
+
ERROR HY000: Cannot cast value to TIMESTAMP WITH TIME ZONE.
2705
+
SELECT cast( TIME'10:10' AT TIME ZONE INTERVAL '' AS DATETIME );
2706
+
ERROR HY000: Cannot cast value to TIMESTAMP WITH TIME ZONE.
2707
+
SELECT cast( TIMESTAMP'2019-10-10 10:11:12' AT LOCAL AS DATETIME );
2708
+
ERROR 42000: This version of MySQL doesn't yet support 'AT LOCAL'
2709
+
SELECT cast( NULL AT TIME ZONE 'UTC' AS DATETIME );
2710
+
cast( NULL AT TIME ZONE 'UTC' AS DATETIME )
2711
+
NULL
2712
+
# Casting to prohibited types
2713
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS BINARY );
2714
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BINARY )' at line 1
2715
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS CHAR );
2716
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CHAR )' at line 1
2717
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS DATE );
2718
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATE )' at line 1
2719
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS DECIMAL );
2720
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECIMAL )' at line 1
2721
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS DOUBLE );
2722
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DOUBLE )' at line 1
2723
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS FLOAT );
2724
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FLOAT )' at line 1
2725
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS SIGNED INTEGER );
2726
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SIGNED INTEGER )' at line 1
2727
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS TIME );
2728
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TIME )' at line 1
2729
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS UNSIGNED INTEGER );
2730
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNSIGNED INTEGER )' at line 1
2731
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS JSON );
2732
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JSON )' at line 1
2733
+
SELECT cast( TIMESTAMP'2019-10-10 10:40:00' AT TIME ZONE 'UTC' AS REAL );
2734
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REAL )' at line 1
0 commit comments