Skip site navigation (1) Skip section navigation (2)

Re: Strange behavior with leap dates and centuries BC

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bernd Helmle <mailings(at)oopsware(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange behavior with leap dates and centuries BC
Date: 2008-02-25 17:00:05
Message-ID: 28390.1203958805@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Bernd Helmle <mailings(at)oopsware(dot)de> writes:
> CREATE TABLE foo(datum date);
> INSERT INTO foo VALUES('0000-02-29');

Since there is no year zero according to Gregorian reckoning, this
should have been rejected to start with.

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

Yeah, something broken there too.  It does know (correctly) that 1BC
is a leap year:

regression=# select '0001-02-28 BC'::date + 1;
   ?column?    
---------------
 0001-02-29 BC
(1 row)

regression=# select '0002-02-28 BC'::date + 1;
   ?column?    
---------------
 0002-03-01 BC
(1 row)

So I'd say there are two separate bugs in datetime input processing
exposed here.

> 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.

I see the same behaviors in 7.4.x, so it's a longstanding problem...

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Gregory StarkDate: 2008-02-25 17:10:41
Subject: Re: Questions about indexes with text_pattern_ops
Previous:From: Tom LaneDate: 2008-02-25 16:29:39
Subject: Re: Questions about indexes with text_pattern_ops

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group