Re: BUG #16419: wrong parsing BC year in to_date() function
David G. Johnston <david.g.johnston@gmail.com>
From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-07-15T16:26:53Z
Lists: pgsql-bugs, pgsql-hackers
Attachments
- v1-001-to-date-behavior-in-bc-bug16419.patch (application/octet-stream) patch v1
On Tue, May 12, 2020 at 8:56 PM Laurenz Albe <laurenz.albe@cybertec.at>
wrote:
> On Tue, 2020-05-12 at 18:09 -0700, David G. Johnston wrote:
> > Redirecting to -hackers for visibility. I feel there needs to be
> something done here, even if just documentation (a bullet in the usage
> notes section - and a code comment update for the macro)
> > pointing this out and not changing any behavior.
>
> Since "to_date" is an Oracle compatibility function, here is what Oracle
> 18.4 has to say to that:
>
> SQL> SELECT to_date('0000', 'YYYY') FROM dual;
> SELECT to_date('0000', 'YYYY') FROM dual
> *
> ERROR at line 1:
> ORA-01841: (full) year must be between -4713 and +9999, and not be 0
>
>
Attached is a concrete patch (back-patchable hopefully) documenting the
current reality.
As noted in the patch commit message (commentary really):
make_timestamp not agreeing with make_date on how to handle negative years
should probably just be fixed - but that is for someone else to handle.
Whether to actually change the behavior of to_date is up for debate though
I would presume it would not be back-patched.
David J.
Commits
-
Fix handling of BC years in to_date/to_timestamp.
- db96be24ce32 10.15 landed
- c5232dca8d1b 12.5 landed
- b0fe0b022f80 11.10 landed
- 99fd38c02299 13.1 landed
- 489c9c3407cb 14.0 landed
- 4857e6fe16c2 9.5.24 landed
- 19e7982681df 9.6.20 landed
-
Fix make_timestamp[tz] to accept negative years as meaning BC.
- a094c8ff5352 14.0 landed
-
doc: PG 13 relnotes, update TOAST item to mention decompression
- fb544735f114 13.0 cited