Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 849FF8820F8 for ; Tue, 7 Aug 2012 14:35:18 -0300 (ADT) Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Syngb-0002HB-GI for pgsql-bugs@postgresql.org; Tue, 07 Aug 2012 17:35:18 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1SyngM-00027b-Uh; Tue, 07 Aug 2012 13:35:02 -0400 Date: Tue, 7 Aug 2012 13:35:02 -0400 From: Bruce Momjian To: Artem Andreev Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6126: CC parameter in to_char() behaves incorrectly Message-ID: <20120807173502.GN29773@momjian.us> References: <201107210840.p6L8eBeA041492@wwwmaster.postgresql.org> <20120803225145.GK3463@momjian.us> <20120804143414.GA29773@momjian.us> <20120806192018.GI29773@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120806192018.GI29773@momjian.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201208/22 X-Sequence-Number: 33746 On Mon, Aug 6, 2012 at 03:20:18PM -0400, Bruce Momjian wrote: > 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. Applied. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +