Skip to content

Commit 6131ffc

Browse files
committed
Add tests for date_part of epoch near upper bound of timestamp range
This exercises a special case in the implementations of date_part('epoch', timestamp[tz]) that was previously not tested.
1 parent 4753ef3 commit 6131ffc

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/test/regress/expected/timestamp.out

+7
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,13 @@ SELECT d1 as "timestamp",
10121012
Mon Jan 01 17:32:01 2001 | 200 | 21 | 3 | 2451912 | 978370321
10131013
(65 rows)
10141014

1015+
-- value near upper bound uses special case in code
1016+
SELECT date_part('epoch', '294270-01-01 00:00:00'::timestamp);
1017+
date_part
1018+
---------------
1019+
9224097091200
1020+
(1 row)
1021+
10151022
-- TO_CHAR()
10161023
SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
10171024
FROM TIMESTAMP_TBL;

src/test/regress/expected/timestamptz.out

+7
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,13 @@ SELECT d1 as timestamptz,
11891189
Mon Jan 01 17:32:01 2001 PST | -28800 | -8 | 0
11901190
(66 rows)
11911191

1192+
-- value near upper bound uses special case in code
1193+
SELECT date_part('epoch', '294270-01-01 00:00:00+00'::timestamptz);
1194+
date_part
1195+
---------------
1196+
9224097091200
1197+
(1 row)
1198+
11921199
-- TO_CHAR()
11931200
SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
11941201
FROM TIMESTAMPTZ_TBL;

src/test/regress/sql/timestamp.sql

+3
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ SELECT d1 as "timestamp",
261261
date_part( 'epoch', d1) AS epoch
262262
FROM TIMESTAMP_TBL;
263263

264+
-- value near upper bound uses special case in code
265+
SELECT date_part('epoch', '294270-01-01 00:00:00'::timestamp);
266+
264267
-- TO_CHAR()
265268
SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
266269
FROM TIMESTAMP_TBL;

src/test/regress/sql/timestamptz.sql

+3
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ SELECT d1 as timestamptz,
275275
date_part( 'timezone_minute', d1) AS timezone_minute
276276
FROM TIMESTAMPTZ_TBL;
277277

278+
-- value near upper bound uses special case in code
279+
SELECT date_part('epoch', '294270-01-01 00:00:00+00'::timestamptz);
280+
278281
-- TO_CHAR()
279282
SELECT to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
280283
FROM TIMESTAMPTZ_TBL;

0 commit comments

Comments
 (0)