Strange behavior with leap dates and centuries BC - Mailing list pgsql-hackers

From Bernd Helmle
Subject Strange behavior with leap dates and centuries BC
Date
Msg-id 2F0F5BDC74EB050246A4DB48@imhotep.credativ.de
Whole thread Raw
Responses Re: Strange behavior with leap dates and centuries BC  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I saw this strange behavior due to a customer problem who managed to get 
dumps which aren't restorable anymore:

CREATE TABLE foo(datum date);

INSERT INTO foo VALUES('0000-02-29');
INSERT 0 1

SELECT * FROM foo;    datum
---------------0001-02-29 BC
(1 row)

COPY foo TO STDOUT;
0001-02-29 BC

INSERT INTO foo VALUES('0001-02-29 BC');
ERROR:  date/time field value out of range: "0001-02-29 BC"


Huh? It seems the calculation for leap dates with negative year values is 
broken. This example was taken from a current HEAD checkout today, the 
original version i've seen this behavior first was 8.2.4.



--  Thanks
                   Bernd


pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Questions about indexes with text_pattern_ops
Next
From: David BOURIAUD
Date:
Subject: Re: One more option for pg_dump...