Re: BUG #16541: Timestamp allowing greater than max documented value?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: michael(dot)mclaughlin(at)cpsi(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16541: Timestamp allowing greater than max documented value?
Date: 2020-07-14 17:59:42
Message-ID: 2878294.1594749582@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> I discovered while copying data from a PostgreSQL 9.6.16 database to a
> PostgreSQL 12.2 database that some of my imports were failing because
> timestamps in my data are out of range. As it turns out, somehow we wrote
> erroneous future dates into timestamp columns in our PG 9.6.16 database
> (i.e. '1666771-01-01 00:00:00') and the 9.6.16 allowed this, but when
> attempting to copy the data to the 12.2 database I get the out of range
> error. Per the PG documentation, the max value for timestamp is the year
> 294276 AD and this has been the case since version 8.4, but obviously it is
> still being allowed in version 9.6.16.

I believe the actual story is that floating-point timestamps allow a much
wider date range than integer timestamps (with corresponding loss of
precision as you get further away from the epoch date). The default
for integer_datetimes changed to "on" in 8.4, but your 9.6 installation
must have been built with it turned off.

This is documented, if not too prominently. If you check

https://www.postgresql.org/docs/9.6/datatype-datetime.html

the second "Note" includes

Note that using floating-point datetimes allows a larger range of
timestamp values to be represented than shown above: from 4713 BC
up to 5874897 AD.

That note is gone in more recent branches because we removed the
floating-point timestamp support altogether.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-07-15 03:17:35 BUG #16542: High CPU Usage
Previous Message PG Bug reporting form 2020-07-14 17:17:57 BUG #16541: Timestamp allowing greater than max documented value?