Skip to content

Commit 4a427b8

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 ee06199 commit 4a427b8

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
@@ -262,3 +262,63 @@ SELECT date_part('epoch', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-
262262
63025.575401
263263
(1 row)
264264

265+
--
266+
-- Test timetz_zone, timetz_izone
267+
--
268+
BEGIN;
269+
SET LOCAL TimeZone TO 'UTC';
270+
CREATE VIEW timetz_local_view AS
271+
SELECT f1 AS dat,
272+
f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_tz,
273+
f1 AT TIME ZONE INTERVAL '00:00' AS dat_at_int
274+
FROM TIMETZ_TBL
275+
ORDER BY f1;
276+
SELECT pg_get_viewdef('timetz_local_view', true);
277+
pg_get_viewdef
278+
-----------------------------------------------------------------------
279+
SELECT f1 AS dat, +
280+
(f1 AT TIME ZONE current_setting('TimeZone'::text)) AS dat_at_tz,+
281+
(f1 AT TIME ZONE '@ 0'::interval) AS dat_at_int +
282+
FROM timetz_tbl +
283+
ORDER BY f1;
284+
(1 row)
285+
286+
TABLE timetz_local_view;
287+
dat | dat_at_tz | dat_at_int
288+
----------------+----------------+----------------
289+
00:01:00-07 | 07:01:00+00 | 07:01:00+00
290+
01:00:00-07 | 08:00:00+00 | 08:00:00+00
291+
02:03:00-07 | 09:03:00+00 | 09:03:00+00
292+
08:08:00-04 | 12:08:00+00 | 12:08:00+00
293+
07:07:00-08 | 15:07:00+00 | 15:07:00+00
294+
11:59:00-07 | 18:59:00+00 | 18:59:00+00
295+
12:00:00-07 | 19:00:00+00 | 19:00:00+00
296+
12:01:00-07 | 19:01:00+00 | 19:01:00+00
297+
15:36:39-04 | 19:36:39+00 | 19:36:39+00
298+
15:36:39-05 | 20:36:39+00 | 20:36:39+00
299+
23:59:00-07 | 06:59:00+00 | 06:59:00+00
300+
23:59:59.99-07 | 06:59:59.99+00 | 06:59:59.99+00
301+
(12 rows)
302+
303+
SELECT f1 AS dat,
304+
f1 AT TIME ZONE 'UTC+10' AS dat_at_tz,
305+
f1 AT TIME ZONE INTERVAL '-10:00' AS dat_at_int
306+
FROM TIMETZ_TBL
307+
ORDER BY f1;
308+
dat | dat_at_tz | dat_at_int
309+
----------------+----------------+----------------
310+
00:01:00-07 | 21:01:00-10 | 21:01:00-10
311+
01:00:00-07 | 22:00:00-10 | 22:00:00-10
312+
02:03:00-07 | 23:03:00-10 | 23:03:00-10
313+
08:08:00-04 | 02:08:00-10 | 02:08:00-10
314+
07:07:00-08 | 05:07:00-10 | 05:07:00-10
315+
11:59:00-07 | 08:59:00-10 | 08:59:00-10
316+
12:00:00-07 | 09:00:00-10 | 09:00:00-10
317+
12:01:00-07 | 09:01:00-10 | 09:01:00-10
318+
15:36:39-04 | 09:36:39-10 | 09:36:39-10
319+
15:36:39-05 | 10:36:39-10 | 10:36:39-10
320+
23:59:00-07 | 20:59:00-10 | 20:59:00-10
321+
23:59:59.99-07 | 20:59:59.99-10 | 20:59:59.99-10
322+
(12 rows)
323+
324+
ROLLBACK;

src/test/regress/sql/timetz.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,23 @@ SELECT date_part('microsecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-
8484
SELECT date_part('millisecond', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');
8585
SELECT date_part('second', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');
8686
SELECT date_part('epoch', TIME WITH TIME ZONE '2020-05-26 13:30:25.575401-04');
87+
88+
--
89+
-- Test timetz_zone, timetz_izone
90+
--
91+
BEGIN;
92+
SET LOCAL TimeZone TO 'UTC';
93+
CREATE VIEW timetz_local_view AS
94+
SELECT f1 AS dat,
95+
f1 AT TIME ZONE current_setting('TimeZone') AS dat_at_tz,
96+
f1 AT TIME ZONE INTERVAL '00:00' AS dat_at_int
97+
FROM TIMETZ_TBL
98+
ORDER BY f1;
99+
SELECT pg_get_viewdef('timetz_local_view', true);
100+
TABLE timetz_local_view;
101+
SELECT f1 AS dat,
102+
f1 AT TIME ZONE 'UTC+10' AS dat_at_tz,
103+
f1 AT TIME ZONE INTERVAL '-10:00' AS dat_at_int
104+
FROM TIMETZ_TBL
105+
ORDER BY f1;
106+
ROLLBACK;

0 commit comments

Comments
 (0)