Skip to content

Commit 05b4614

Browse files
committed
Back-patch test cases for timetz_zone/timetz_izone.
Per code coverage reports, we had zero regression test coverage of these functions. That came back to bite us, as apparently that's allowed us to miss discovering misbehavior of this code with AIX's xlc compiler. Install relevant portions of the test cases added in 97957fd, 2f04720, 19fa977. (Assuming the expected outcome that the xlc problem does appear in back branches, a code fix will follow.) Discussion: https://postgr.es/m/CA+hUKGK=DOC+hE-62FKfZy=Ybt5uLkrg3zCZD-jFykM-iPn8yw@mail.gmail.com
1 parent d0e7f95 commit 05b4614

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

src/test/regress/expected/timetz.out

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,63 @@ ERROR: operator does not exist: time with time zone + time with time zone
144144
LINE 1: SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TI...
145145
^
146146
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
147+
--
148+
-- Test timetz_zone, timetz_izone
149+
--
150+
BEGIN;
151+
SET LOCAL TimeZone TO 'UTC';
152+
CREATE VIEW timetz_local_view AS
153+
SELECT f1 AS dat,
154+
f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_tz,
155+
f1 AT TIME ZONE INTERVAL '00:00' AS dat_at_int
156+
FROM TIMETZ_TBL
157+
ORDER BY f1;
158+
SELECT pg_get_viewdef('timetz_local_view', true);
159+
pg_get_viewdef
160+
------------------------------------------------------------------------------
161+
SELECT timetz_tbl.f1 AS dat, +
162+
timezone(current_setting('TimeZone'::text), timetz_tbl.f1) AS dat_at_tz,+
163+
timezone('@ 0'::interval, timetz_tbl.f1) AS dat_at_int +
164+
FROM timetz_tbl +
165+
ORDER BY timetz_tbl.f1;
166+
(1 row)
167+
168+
TABLE timetz_local_view;
169+
dat | dat_at_tz | dat_at_int
170+
----------------+----------------+----------------
171+
00:01:00-07 | 07:01:00+00 | 07:01:00+00
172+
01:00:00-07 | 08:00:00+00 | 08:00:00+00
173+
02:03:00-07 | 09:03:00+00 | 09:03:00+00
174+
08:08:00-04 | 12:08:00+00 | 12:08:00+00
175+
07:07:00-08 | 15:07:00+00 | 15:07:00+00
176+
11:59:00-07 | 18:59:00+00 | 18:59:00+00
177+
12:00:00-07 | 19:00:00+00 | 19:00:00+00
178+
12:01:00-07 | 19:01:00+00 | 19:01:00+00
179+
15:36:39-04 | 19:36:39+00 | 19:36:39+00
180+
15:36:39-05 | 20:36:39+00 | 20:36:39+00
181+
23:59:00-07 | 06:59:00+00 | 06:59:00+00
182+
23:59:59.99-07 | 06:59:59.99+00 | 06:59:59.99+00
183+
(12 rows)
184+
185+
SELECT f1 AS dat,
186+
f1 AT TIME ZONE 'UTC+10' AS dat_at_tz,
187+
f1 AT TIME ZONE INTERVAL '-10:00' AS dat_at_int
188+
FROM TIMETZ_TBL
189+
ORDER BY f1;
190+
dat | dat_at_tz | dat_at_int
191+
----------------+----------------+----------------
192+
00:01:00-07 | 21:01:00-10 | 21:01:00-10
193+
01:00:00-07 | 22:00:00-10 | 22:00:00-10
194+
02:03:00-07 | 23:03:00-10 | 23:03:00-10
195+
08:08:00-04 | 02:08:00-10 | 02:08:00-10
196+
07:07:00-08 | 05:07:00-10 | 05:07:00-10
197+
11:59:00-07 | 08:59:00-10 | 08:59:00-10
198+
12:00:00-07 | 09:00:00-10 | 09:00:00-10
199+
12:01:00-07 | 09:01:00-10 | 09:01:00-10
200+
15:36:39-04 | 09:36:39-10 | 09:36:39-10
201+
15:36:39-05 | 10:36:39-10 | 10:36:39-10
202+
23:59:00-07 | 20:59:00-10 | 20:59:00-10
203+
23:59:59.99-07 | 20:59:59.99-10 | 20:59:59.99-10
204+
(12 rows)
205+
206+
ROLLBACK;

src/test/regress/sql/timetz.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,23 @@ SELECT '25:00:00 PDT'::timetz; -- not allowed
5555
-- where we do mixed-type arithmetic. - thomas 2000-12-02
5656

5757
SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL;
58+
59+
--
60+
-- Test timetz_zone, timetz_izone
61+
--
62+
BEGIN;
63+
SET LOCAL TimeZone TO 'UTC';
64+
CREATE VIEW timetz_local_view AS
65+
SELECT f1 AS dat,
66+
f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_tz,
67+
f1 AT TIME ZONE INTERVAL '00:00' AS dat_at_int
68+
FROM TIMETZ_TBL
69+
ORDER BY f1;
70+
SELECT pg_get_viewdef('timetz_local_view', true);
71+
TABLE timetz_local_view;
72+
SELECT f1 AS dat,
73+
f1 AT TIME ZONE 'UTC+10' AS dat_at_tz,
74+
f1 AT TIME ZONE INTERVAL '-10:00' AS dat_at_int
75+
FROM TIMETZ_TBL
76+
ORDER BY f1;
77+
ROLLBACK;

0 commit comments

Comments
 (0)