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

small bug on 3-digit years in 9.2-dev

From: Marc Cousin <cousinmarc(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: small bug on 3-digit years in 9.2-dev
Date: 2012-07-02 09:32:50
Message-ID: 201207021132.50285.cousinmarc@gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi,

While working on the "What's new in 9.2", I think I found a small bug:

SELECT to_date('519-07-02','YYY-MM-DD');
  to_date   
------------
 0519-07-02
(1 row)

It comes, I think, from the year 519 case not being handled in the following 
code. Patch attached

+	if (year < 70)
+		return year + 2000;
+	/* Force 70-99 into the 1900's */
+	else if (year >= 70 && year < 100)
+		return year + 1900;
+	/* Force 100-519 into the 2000's */
+	else if (year >= 100 && year < 519)
+		return year + 2000;
+	/* Force 520-999 into the 1000's */
+	else if (year >= 520 && year < 1000)
+		return year + 1000;
+	else
+		return year;

Regards

Attachment: correct_dates.patch
Description: text/x-patch (532 bytes)

Responses

pgsql-hackers by date

Next:From: Amit KapilaDate: 2012-07-02 12:08:22
Subject: [WIP] Patch : Change pg_ident.conf parsing to be the same as pg_hba.conf
Previous:From: Kyotaro HORIGUCHIDate: 2012-07-02 09:08:13
Subject: Re: Checkpointer on hot standby runs without looking checkpoint_segments

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