pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Be more careful about out-of-range dates and timestamps.
Date: Wed, 16 Mar 2016 23:09:46 +0000
Message-ID: <E1agKZW-0006nG-69@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

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(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1agKZW-0006nG-69@gemulon.postgresql.org>
Permalink:  ../E1agKZW-0006nG-69@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1agKZW-0006nG-69@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Be more careful about out-of-range dates and timestamps.
  In-Reply-To: <E1agKZW-0006nG-69@gemulon.postgresql.org>
  References: <E1agKZW-0006nG-69@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox