]> granicus.if.org Git - postgresql/commit
Fix datetime input to behave correctly for Feb 29 in years BC.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 25 Feb 2008 23:21:15 +0000 (23:21 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 25 Feb 2008 23:21:15 +0000 (23:21 +0000)
commite8543ab2c84551294d98c89bdea6f67d871fba6f
tree7cc1919a05b20c7b58c2f3c06f81c701331ca07e
parent7988f948c925e0a015bde35c9db78e24447b6174
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.
src/backend/utils/adt/datetime.c