Skip to content

Commit

Permalink
HAWQ-1532. test cases on 'Asia' timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuien Liu authored and radarwave committed Dec 1, 2017
1 parent 7d522a8 commit 5e15295
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/test/feature/catalog/ans/time.ans
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,79 @@ psql:/tmp/TestType_time.sql:44: ERROR: operator is not unique: time without tim
LINE 1: SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
^
HINT: Could not choose a best candidate operator. You may need to add explicit type casts.
--
-- Support timezone_abbreviations = 'Asia'
--
-- For some reason this seems to have been missed to support
-- CST (China Standard Time). On some platforms, for example,
-- Linux, CST is used as time string suffix of GMT+8, especially
-- for users in China. In such case, the timestamp of log is
-- '14 hours' ahead of the actual China time (GMT+8).
SHOW timezone_abbreviations; -- info for debug, should always be 'Default'
timezone_abbreviations
------------------------
Default
(1 row)

SET timezone_abbreviations TO 'Asia';
SET
SELECT abbrev, utc_offset FROM pg_timezone_abbrevs WHERE abbrev = 'CST';
abbrev | utc_offset
--------+------------
CST | 08:00:00
(1 row)

SELECT '2002-09-24 10:10 CST'::TIMESTAMP WITH TIME ZONE;
timestamptz
------------------------------
Mon Sep 23 19:10:00 2002 PDT
(1 row)

SELECT '2002-09-24 10:10 Asia/Shanghai'::TIMESTAMP WITH TIME ZONE; -- won't change
timestamptz
------------------------------
Mon Sep 23 19:10:00 2002 PDT
(1 row)

SELECT '2002-09-24 10:10 GST'::TIMESTAMP WITH TIME ZONE; -- Gulf Standard Time, Asia/Dubai
timestamptz
------------------------------
Mon Sep 23 23:10:00 2002 PDT
(1 row)

SELECT '2002-09-24 10:10 IST'::TIMESTAMP WITH TIME ZONE; -- Indian Standard Time
timestamptz
------------------------------
Mon Sep 23 21:40:00 2002 PDT
(1 row)

SET timezone_abbreviations TO 'Default';
SET
SELECT abbrev, utc_offset FROM pg_timezone_abbrevs WHERE abbrev = 'CST';
abbrev | utc_offset
--------+------------
CST | -06:00:00
(1 row)

SELECT '2002-09-24 10:10 CST'::TIMESTAMP WITH TIME ZONE;
timestamptz
------------------------------
Tue Sep 24 09:10:00 2002 PDT
(1 row)

SELECT '2002-09-24 10:10 Asia/Shanghai'::TIMESTAMP WITH TIME ZONE; -- won't change
timestamptz
------------------------------
Mon Sep 23 19:10:00 2002 PDT
(1 row)

SELECT '2002-09-24 10:10 GST'::TIMESTAMP WITH TIME ZONE; -- 'GST' is invalid in Default
psql:/tmp/TestType_time.sql:68: ERROR: invalid input syntax for type timestamp with time zone: "2002-09-24 10:10 GST"
LINE 1: SELECT '2002-09-24 10:10 GST'::TIMESTAMP WITH TIME ZONE;
^
SELECT '2002-09-24 10:10 IST'::TIMESTAMP WITH TIME ZONE; -- Israel Standard Time
timestamptz
------------------------------
Tue Sep 24 01:10:00 2002 PDT
(1 row)

25 changes: 25 additions & 0 deletions src/test/feature/catalog/sql/time.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,28 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00' ORDER BY 1;
-- where we do mixed-type arithmetic. - thomas 2000-12-02

SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;

--
-- Support timezone_abbreviations = 'Asia'
--
-- For some reason this seems to have been missed to support
-- CST (China Standard Time). On some platforms, for example,
-- Linux, CST is used as time string suffix of GMT+8, especially
-- for users in China. In such case, the timestamp of log is
-- '14 hours' ahead of the actual China time (GMT+8).

SHOW timezone_abbreviations; -- info for debug, should always be 'Default'

SET timezone_abbreviations TO 'Asia';
SELECT abbrev, utc_offset FROM pg_timezone_abbrevs WHERE abbrev = 'CST';
SELECT '2002-09-24 10:10 CST'::TIMESTAMP WITH TIME ZONE;
SELECT '2002-09-24 10:10 Asia/Shanghai'::TIMESTAMP WITH TIME ZONE; -- won't change
SELECT '2002-09-24 10:10 GST'::TIMESTAMP WITH TIME ZONE; -- Gulf Standard Time, Asia/Dubai
SELECT '2002-09-24 10:10 IST'::TIMESTAMP WITH TIME ZONE; -- Indian Standard Time

SET timezone_abbreviations TO 'Default';
SELECT abbrev, utc_offset FROM pg_timezone_abbrevs WHERE abbrev = 'CST';
SELECT '2002-09-24 10:10 CST'::TIMESTAMP WITH TIME ZONE;
SELECT '2002-09-24 10:10 Asia/Shanghai'::TIMESTAMP WITH TIME ZONE; -- won't change
SELECT '2002-09-24 10:10 GST'::TIMESTAMP WITH TIME ZONE; -- 'GST' is invalid in Default
SELECT '2002-09-24 10:10 IST'::TIMESTAMP WITH TIME ZONE; -- Israel Standard Time

0 comments on commit 5e15295

Please sign in to comment.