From: Tom Lane <tgl@sss.pgh.pa.us>
To: infinite77derger@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15351: to_date() function bug
Date: Fri, 24 Aug 2018 12:08:30 -0400
Message-ID: <15477.1535126910@sss.pgh.pa.us> (raw)
In-Reply-To: <153512536372.1489.18196536375179237149@wrigleys.postgresql.org>
References: <153512536372.1489.18196536375179237149@wrigleys.postgresql.org>
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> All dates, that are less then '04.01.0001', returns in Before Christ (!)
> format.
Can't reproduce that here ...
> Examples:
> SELECT to_date('01.12.0000', 'DD.MM.YYYY'); - - converts to 0001-12-01 BC
> (Before Christ)
> SELECT to_date('01.01.0000', 'DD.MM.YYYY'); - - converts to 0001-01-01
> BC
Neither of the above are surprising. There's no year zero in the
Gregorian calendar. We could throw an error for that input, perhaps,
but what the code chooses to do is interpret it as 1BC.
> SELECT to_date('01.01.0001', 'DD.MM.YYYY'); - - converts to 0001-01-01
> BC
That would be a bug, I agree, but I can't reproduce it here. I get
regression=# SELECT to_date('01.01.0001', 'DD.MM.YYYY');
to_date
------------
0001-01-01
(1 row)
and likewise for your other funny cases. I wonder whether you're
using a stock build of Postgres --- or maybe you're running into
compiler bugs? Where did you get PG from?
> SELECT to_date('', 'DD.MM.YYYY'); - - empty text also converts to
> 0001-01-01 BC
That seems all right given the interpretation of zeroes. There's probably
a market for a version of to_date that's more willing to throw errors for
questionable input ... but that's not how to_date itself has traditionally
worked.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, infinite77derger@gmail.com
Subject: Re: BUG #15351: to_date() function bug
In-Reply-To: <15477.1535126910@sss.pgh.pa.us>
References: <153512536372.1489.18196536375179237149@wrigleys.postgresql.org> <15477.1535126910@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox