Skip to content

Commit bc9f1af

Browse files
committed
Add upper boundary tests for timestamp and timestamptz types
The existing regression tests only tested the lower boundary of the range supported by the timestamp and timestamptz types because "The upper boundary differs between integer and float timestamps, so no check". Since this is obsolete, add similar tests for the upper boundary.
1 parent f64ea6d commit bc9f1af

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

src/test/regress/expected/timestamp.out

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ SELECT d1 FROM TIMESTAMP_TBL;
234234
Mon Jan 01 17:32:01 2001
235235
(65 rows)
236236

237-
-- Check behavior at the lower boundary of the timestamp range
237+
-- Check behavior at the boundaries of the timestamp range
238238
SELECT '4714-11-24 00:00:00 BC'::timestamp;
239239
timestamp
240240
-----------------------------
@@ -245,7 +245,16 @@ SELECT '4714-11-23 23:59:59 BC'::timestamp; -- out of range
245245
ERROR: timestamp out of range: "4714-11-23 23:59:59 BC"
246246
LINE 1: SELECT '4714-11-23 23:59:59 BC'::timestamp;
247247
^
248-
-- The upper boundary differs between integer and float timestamps, so no check
248+
SELECT '294276-12-31 23:59:59'::timestamp;
249+
timestamp
250+
----------------------------
251+
Sun Dec 31 23:59:59 294276
252+
(1 row)
253+
254+
SELECT '294277-01-01 00:00:00'::timestamp; -- out of range
255+
ERROR: timestamp out of range: "294277-01-01 00:00:00"
256+
LINE 1: SELECT '294277-01-01 00:00:00'::timestamp;
257+
^
249258
-- Demonstrate functions and operators
250259
SELECT d1 FROM TIMESTAMP_TBL
251260
WHERE d1 > timestamp without time zone '1997-01-02';

src/test/regress/expected/timestamptz.out

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ SELECT d1 FROM TIMESTAMPTZ_TBL;
318318
Mon Jan 01 17:32:01 2001 PST
319319
(66 rows)
320320

321-
-- Check behavior at the lower boundary of the timestamp range
321+
-- Check behavior at the boundaries of the timestamp range
322322
SELECT '4714-11-24 00:00:00+00 BC'::timestamptz;
323323
timestamptz
324324
---------------------------------
@@ -341,7 +341,26 @@ SELECT '4714-11-23 23:59:59+00 BC'::timestamptz; -- out of range
341341
ERROR: timestamp out of range: "4714-11-23 23:59:59+00 BC"
342342
LINE 1: SELECT '4714-11-23 23:59:59+00 BC'::timestamptz;
343343
^
344-
-- The upper boundary differs between integer and float timestamps, so no check
344+
SELECT '294276-12-31 23:59:59+00'::timestamptz;
345+
timestamptz
346+
--------------------------------
347+
Sun Dec 31 15:59:59 294276 PST
348+
(1 row)
349+
350+
SELECT '294276-12-31 15:59:59-08'::timestamptz;
351+
timestamptz
352+
--------------------------------
353+
Sun Dec 31 15:59:59 294276 PST
354+
(1 row)
355+
356+
SELECT '294277-01-01 00:00:00+00'::timestamptz; -- out of range
357+
ERROR: timestamp out of range: "294277-01-01 00:00:00+00"
358+
LINE 1: SELECT '294277-01-01 00:00:00+00'::timestamptz;
359+
^
360+
SELECT '294277-12-31 16:00:00-08'::timestamptz; -- out of range
361+
ERROR: timestamp out of range: "294277-12-31 16:00:00-08"
362+
LINE 1: SELECT '294277-12-31 16:00:00-08'::timestamptz;
363+
^
345364
-- Demonstrate functions and operators
346365
SELECT d1 FROM TIMESTAMPTZ_TBL
347366
WHERE d1 > timestamp with time zone '1997-01-02';

src/test/regress/sql/timestamp.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
137137

138138
SELECT d1 FROM TIMESTAMP_TBL;
139139

140-
-- Check behavior at the lower boundary of the timestamp range
140+
-- Check behavior at the boundaries of the timestamp range
141141
SELECT '4714-11-24 00:00:00 BC'::timestamp;
142142
SELECT '4714-11-23 23:59:59 BC'::timestamp; -- out of range
143-
-- The upper boundary differs between integer and float timestamps, so no check
143+
SELECT '294276-12-31 23:59:59'::timestamp;
144+
SELECT '294277-01-01 00:00:00'::timestamp; -- out of range
144145

145146
-- Demonstrate functions and operators
146147
SELECT d1 FROM TIMESTAMP_TBL

src/test/regress/sql/timestamptz.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,15 @@ SELECT 'Wed Jul 11 10:51:14 PST+03:00 2001'::timestamptz;
158158

159159
SELECT d1 FROM TIMESTAMPTZ_TBL;
160160

161-
-- Check behavior at the lower boundary of the timestamp range
161+
-- Check behavior at the boundaries of the timestamp range
162162
SELECT '4714-11-24 00:00:00+00 BC'::timestamptz;
163163
SELECT '4714-11-23 16:00:00-08 BC'::timestamptz;
164164
SELECT 'Sun Nov 23 16:00:00 4714 PST BC'::timestamptz;
165165
SELECT '4714-11-23 23:59:59+00 BC'::timestamptz; -- out of range
166-
-- The upper boundary differs between integer and float timestamps, so no check
166+
SELECT '294276-12-31 23:59:59+00'::timestamptz;
167+
SELECT '294276-12-31 15:59:59-08'::timestamptz;
168+
SELECT '294277-01-01 00:00:00+00'::timestamptz; -- out of range
169+
SELECT '294277-12-31 16:00:00-08'::timestamptz; -- out of range
167170

168171
-- Demonstrate functions and operators
169172
SELECT d1 FROM TIMESTAMPTZ_TBL

0 commit comments

Comments
 (0)