aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2021-03-30 08:46:34 +0200
committerPeter Eisentraut <peter@eisentraut.org>2021-03-30 08:46:34 +0200
commitbc9f1afdebc98b490d0a00468d75e8e4d080afb0 (patch)
treea790e9c8ecb536e28e6fba58be50d87b3fc1620c
parentf64ea6dc5c8ccaec9a3d3d39695ca261febb6883 (diff)
downloadpostgresql-bc9f1afdebc98b490d0a00468d75e8e4d080afb0.tar.gz
postgresql-bc9f1afdebc98b490d0a00468d75e8e4d080afb0.zip
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.
-rw-r--r--src/test/regress/expected/timestamp.out13
-rw-r--r--src/test/regress/expected/timestamptz.out23
-rw-r--r--src/test/regress/sql/timestamp.sql5
-rw-r--r--src/test/regress/sql/timestamptz.sql7
4 files changed, 40 insertions, 8 deletions
diff --git a/src/test/regress/expected/timestamp.out b/src/test/regress/expected/timestamp.out
index 233ac50d7e6..bde6d786ae6 100644
--- a/src/test/regress/expected/timestamp.out
+++ b/src/test/regress/expected/timestamp.out
@@ -234,7 +234,7 @@ SELECT d1 FROM TIMESTAMP_TBL;
Mon Jan 01 17:32:01 2001
(65 rows)
--- Check behavior at the lower boundary of the timestamp range
+-- Check behavior at the boundaries of the timestamp range
SELECT '4714-11-24 00:00:00 BC'::timestamp;
timestamp
-----------------------------
@@ -245,7 +245,16 @@ SELECT '4714-11-23 23:59:59 BC'::timestamp; -- out of range
ERROR: timestamp out of range: "4714-11-23 23:59:59 BC"
LINE 1: SELECT '4714-11-23 23:59:59 BC'::timestamp;
^
--- The upper boundary differs between integer and float timestamps, so no check
+SELECT '294276-12-31 23:59:59'::timestamp;
+ timestamp
+----------------------------
+ Sun Dec 31 23:59:59 294276
+(1 row)
+
+SELECT '294277-01-01 00:00:00'::timestamp; -- out of range
+ERROR: timestamp out of range: "294277-01-01 00:00:00"
+LINE 1: SELECT '294277-01-01 00:00:00'::timestamp;
+ ^
-- Demonstrate functions and operators
SELECT d1 FROM TIMESTAMP_TBL
WHERE d1 > timestamp without time zone '1997-01-02';
diff --git a/src/test/regress/expected/timestamptz.out b/src/test/regress/expected/timestamptz.out
index abd8a645a0a..752333f0b00 100644
--- a/src/test/regress/expected/timestamptz.out
+++ b/src/test/regress/expected/timestamptz.out
@@ -318,7 +318,7 @@ SELECT d1 FROM TIMESTAMPTZ_TBL;
Mon Jan 01 17:32:01 2001 PST
(66 rows)
--- Check behavior at the lower boundary of the timestamp range
+-- Check behavior at the boundaries of the timestamp range
SELECT '4714-11-24 00:00:00+00 BC'::timestamptz;
timestamptz
---------------------------------
@@ -341,7 +341,26 @@ SELECT '4714-11-23 23:59:59+00 BC'::timestamptz; -- out of range
ERROR: timestamp out of range: "4714-11-23 23:59:59+00 BC"
LINE 1: SELECT '4714-11-23 23:59:59+00 BC'::timestamptz;
^
--- The upper boundary differs between integer and float timestamps, so no check
+SELECT '294276-12-31 23:59:59+00'::timestamptz;
+ timestamptz
+--------------------------------
+ Sun Dec 31 15:59:59 294276 PST
+(1 row)
+
+SELECT '294276-12-31 15:59:59-08'::timestamptz;
+ timestamptz
+--------------------------------
+ Sun Dec 31 15:59:59 294276 PST
+(1 row)
+
+SELECT '294277-01-01 00:00:00+00'::timestamptz; -- out of range
+ERROR: timestamp out of range: "294277-01-01 00:00:00+00"
+LINE 1: SELECT '294277-01-01 00:00:00+00'::timestamptz;
+ ^
+SELECT '294277-12-31 16:00:00-08'::timestamptz; -- out of range
+ERROR: timestamp out of range: "294277-12-31 16:00:00-08"
+LINE 1: SELECT '294277-12-31 16:00:00-08'::timestamptz;
+ ^
-- Demonstrate functions and operators
SELECT d1 FROM TIMESTAMPTZ_TBL
WHERE d1 > timestamp with time zone '1997-01-02';
diff --git a/src/test/regress/sql/timestamp.sql b/src/test/regress/sql/timestamp.sql
index 78116a38e83..458a16b5c61 100644
--- a/src/test/regress/sql/timestamp.sql
+++ b/src/test/regress/sql/timestamp.sql
@@ -137,10 +137,11 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
SELECT d1 FROM TIMESTAMP_TBL;
--- Check behavior at the lower boundary of the timestamp range
+-- Check behavior at the boundaries of the timestamp range
SELECT '4714-11-24 00:00:00 BC'::timestamp;
SELECT '4714-11-23 23:59:59 BC'::timestamp; -- out of range
--- The upper boundary differs between integer and float timestamps, so no check
+SELECT '294276-12-31 23:59:59'::timestamp;
+SELECT '294277-01-01 00:00:00'::timestamp; -- out of range
-- Demonstrate functions and operators
SELECT d1 FROM TIMESTAMP_TBL
diff --git a/src/test/regress/sql/timestamptz.sql b/src/test/regress/sql/timestamptz.sql
index 7ad6edcd61c..d21a8a4dff0 100644
--- a/src/test/regress/sql/timestamptz.sql
+++ b/src/test/regress/sql/timestamptz.sql
@@ -158,12 +158,15 @@ SELECT 'Wed Jul 11 10:51:14 PST+03:00 2001'::timestamptz;
SELECT d1 FROM TIMESTAMPTZ_TBL;
--- Check behavior at the lower boundary of the timestamp range
+-- Check behavior at the boundaries of the timestamp range
SELECT '4714-11-24 00:00:00+00 BC'::timestamptz;
SELECT '4714-11-23 16:00:00-08 BC'::timestamptz;
SELECT 'Sun Nov 23 16:00:00 4714 PST BC'::timestamptz;
SELECT '4714-11-23 23:59:59+00 BC'::timestamptz; -- out of range
--- The upper boundary differs between integer and float timestamps, so no check
+SELECT '294276-12-31 23:59:59+00'::timestamptz;
+SELECT '294276-12-31 15:59:59-08'::timestamptz;
+SELECT '294277-01-01 00:00:00+00'::timestamptz; -- out of range
+SELECT '294277-12-31 16:00:00-08'::timestamptz; -- out of range
-- Demonstrate functions and operators
SELECT d1 FROM TIMESTAMPTZ_TBL