pgsql: Fix datetime input to behave correctly for Feb 29 in years BC.

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix datetime input to behave correctly for Feb 29 in years BC.
Date: 2008-02-25 23:21:22
Message-ID: 20080225232122.42955754108@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Fix datetime input to behave correctly for Feb 29 in years BC.

Formerly, DecodeDate attempted to verify the day-of-the-month exactly, but
it was under the misapprehension that it would know whether we were looking
at a BC year or not. In reality this check can't be made until the calling
function (eg DecodeDateTime) has processed all the fields. So, split the
BC adjustment and validity checks out into a new function ValidateDate that
is called only after processing all the fields. In passing, this patch
makes DecodeTimeOnly work for BC inputs, which it never did before.

(The historical veracity of all this is nonexistent, of course, but if
we're going to say we support proleptic Gregorian calendar then we should
do it correctly. In any case the unpatched code is broken because it could
emit dates that it would then reject on re-inputting.)

Per report from Bernd Helmle. Back-patch as far as 8.0; in 7.x we were
not using our own calendar support and so this seems a bit too risky
to put into 7.4.

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
pgsql/src/backend/utils/adt:
datetime.c (r1.160.2.4 -> r1.160.2.5)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/datetime.c?r1=1.160.2.4&r2=1.160.2.5)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2008-02-25 23:21:29 pgsql: Fix datetime input to behave correctly for Feb 29 in years BC.
Previous Message Tom Lane 2008-02-25 23:21:15 pgsql: Fix datetime input to behave correctly for Feb 29 in years BC.