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
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/a70e13a39eccf5fc944c66e0029004b6abcb3cae
Modified Files
--------------
src/backend/utils/adt/date.c | 118 +++++++++++++++++++++++++----
src/backend/utils/adt/datetime.c | 8 +-
src/backend/utils/adt/formatting.c | 8 ++
src/backend/utils/adt/timestamp.c | 95 +++++++++++++++++++----
src/include/datatype/timestamp.h | 79 ++++++++++++++++---
src/interfaces/ecpg/pgtypeslib/dt.h | 28 ++++---
src/interfaces/ecpg/pgtypeslib/timestamp.c | 6 +-
src/test/regress/expected/date.out | 21 +++++
src/test/regress/expected/timestamp.out | 12 +++
src/test/regress/expected/timestamptz.out | 24 ++++++
src/test/regress/sql/date.sql | 6 ++
src/test/regress/sql/timestamp.sql | 5 ++
src/test/regress/sql/timestamptz.sql | 7 ++
13 files changed, 364 insertions(+), 53 deletions(-)