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

Re: BUG #6126: CC parameter in to_char() behaves incorrectly

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Artem Andreev <artem(at)oktetlabs(dot)ru>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6126: CC parameter in to_char() behaves incorrectly
Date: 2012-08-06 19:20:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On Sat, Aug  4, 2012 at 10:34:14AM -0400, Bruce Momjian wrote:
> > I am thinking it is too late to apply this for 9.2 because users might
> > have already tested their applications, though I doubt many are using BC
> > dates.  Feedback?
> There is never just one bug in formatting.c --- the input side was also
> broken for BC/negative centuries.  The attached patch fixes the input
> side as well, and shows the old/fixed output for BC centuries.  The test
> queries were:
> 	SELECT to_date('-6  4', 'CC YY');
> 	SELECT to_date(' 6  4', 'CC YY');
> 	SELECT to_date('-6 00', 'CC YY');
> 	SELECT to_date(' 6 00', 'CC YY');
> 	SELECT to_date('-6', 'CC');
> 	SELECT to_date(' 6', 'CC');
> I believe this is all for 9.3-only.

OK, I found another bug in our code;  the output of:

  SELECT to_date(' 6 BC', 'CC BC');

returned 501BC, instead of the start of the century, 600BC, like SELECT
to_date('-6', 'CC') does.

I also allowed negative BC dates to map to AD dates, just like negative
AD dates map to BC dates.

Attached is an updated patch and output diff.

  Bruce Momjian  <bruce(at)momjian(dot)us>

  + It's impossible for everything to be true. +

Attachment: century.diff
Description: text/x-diff (6.6 KB)
Attachment: output.diff
Description: text/x-diff (2.3 KB)

In response to


pgsql-bugs by date

Next:From: junho1.kimDate: 2012-08-07 00:32:02
Subject: BUG #7481: DB installer Not progress
Previous:From: Eric ThomasDate: 2012-08-04 15:43:58
Subject: Small bug in psqlodbc-09.01 prevents interoperability with LISTSERV

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