summaryrefslogtreecommitdiff
path: root/src/test/regress/sql/timestamptz.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-03-16 19:09:04 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-03-16 19:09:28 -0400
commita70e13a39eccf5fc944c66e0029004b6abcb3cae (patch)
treeffc2d894a16b329f5968e1ff1a6c4a89e5bca889 /src/test/regress/sql/timestamptz.sql
parentf2b74b01d4a18241bd7560e74d527f3ba42d4738 (diff)
downloadpostgresql-a70e13a39eccf5fc944c66e0029004b6abcb3cae.tar.gz
Be more careful about out-of-range dates and timestamps.
Tighten the semantics of boundary-case timestamptz so that we allow timestamps >= '4714-11-24 00:00+00 BC' and < 'ENDYEAR-01-01 00:00+00 AD' exactly, no more and no less, but it is allowed to enter timestamps within that range using non-GMT timezone offsets (which could make the nominal date 4714-11-23 BC or ENDYEAR-01-01 AD). This eliminates dump/reload failure conditions for timestamps near the endpoints. To do this, separate checking of the inputs for date2j() from the final range check, and allow the Julian date code to handle a range slightly wider than the nominal range of the datatypes. Also add a bunch of checks to detect out-of-range dates and timestamps that formerly could be returned by operations such as date-plus-integer. All C-level functions that return date, timestamp, or timestamptz should now be proof against returning a value that doesn't pass IS_VALID_DATE() or IS_VALID_TIMESTAMP(). Vitaly Burovoy, reviewed by Anastasia Lubennikova, and substantially whacked around by me
Diffstat (limited to 'src/test/regress/sql/timestamptz.sql')
-rw-r--r--src/test/regress/sql/timestamptz.sql7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/regress/sql/timestamptz.sql b/src/test/regress/sql/timestamptz.sql
index f4b455e703..03dbc05aab 100644
--- a/src/test/regress/sql/timestamptz.sql
+++ b/src/test/regress/sql/timestamptz.sql
@@ -162,6 +162,13 @@ SELECT 'Wed Jul 11 10:51:14 PST+03:00 2001'::timestamptz;
SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
+-- Check behavior at the lower boundary 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
+
-- Demonstrate functions and operators
SELECT '' AS "48", d1 FROM TIMESTAMPTZ_TBL
WHERE d1 > timestamp with time zone '1997-01-02';