Re: BUG #16419: wrong parsing BC year in to_date() function

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #16419: wrong parsing BC year in to_date() function
Date: 2020-09-04 21:05:28
Message-ID: 13c0992c-f15a-a0ca-d839-91d3efd965d9@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2020-09-04 21:45, David G. Johnston wrote:
> On Thu, Sep 3, 2020 at 6:21 PM Bruce Momjian <bruce(at)momjian(dot)us
> <mailto:bruce(at)momjian(dot)us>> wrote:
>
> On Wed, Jul 15, 2020 at 09:26:53AM -0700, David G. Johnston wrote:
>
> > Whether to actually change the behavior of to_date is up for
> debate though I
> > would presume it would not be back-patched.
>
> OK, so, looking at this thread, we have to_date() treating -1 as -2 BC,
> make_date() treating -1 as 1 BC, and we have Oracle, which to_date() is
> supposed to match, making -1 as 1 BC.
>
> Because we already have the to_date/make_date inconsistency, and the -1
> to -2 BC mapping is confusing, and doesn't match Oracle, I think the
> clean solution is to change PG 14 to treat -1 as 1 BC, and document the
> incompatibility in the release notes.
>
>
> I agree that someone else should write another patch to fix the behavior
> for v14.  Still suggest committing the proposed patch to master and all
> supported versions to document the existing behavior correctly.  The fix
> patch can work from that.

Adding support for negative years in make_timestamp seems pretty
straightforward; see attached patch.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Support-negative-years-in-make_timestamp.patch text/plain 3.8 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-09-06 23:46:32 Re: Since '2001-09-09 01:46:40'::timestamp microseconds are lost when extracting epoch
Previous Message Bruce Momjian 2020-09-04 20:12:24 Re: BUG #16419: wrong parsing BC year in to_date() function

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2020-09-04 21:20:01 Re: [PATCH] Redudant initilization
Previous Message Cary Huang 2020-09-04 20:54:46 Re: Any objections to implementing LogicalDecodeMessageCB for pgoutput?