pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: defanor@uberspace.net
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15141: Faulty ISO 8601 parsing
Date: Mon, 02 Apr 2018 23:39:20 -0400
Message-ID: <8933.1522726760@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbhU_mXqxXWBxog0s2Lwqj=U2=WWBBdSb5zbwUaFz-S5A@mail.gmail.com>
References: <152271186941.1442.12179299369295226185@wrigleys.postgresql.org>
	<32337.1522714669@sss.pgh.pa.us>
	<CAKFQuwbhU_mXqxXWBxog0s2Lwqj=U2=WWBBdSb5zbwUaFz-S5A@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Apr 2, 2018 at 5:17 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I think you meant that this fails:
>> # select '2018-04-03T01:45:00,728456785+0000'::timestamp with time zone;
>> ERROR:  invalid input syntax for type timestamp with time zone:
>> "2018-04-03T01:45:00,728456785+0000"
>> which it does, but I don't think we should do anything about it.
>> There is not and never has been any dependency on LC_TIME properties in
>> PG's timestamp I/O.  Considering that we also have DateStyle to cope with,
>> as well as a lot more flexibility in the input parser than ISO 8601
>> contemplates, I think allowing a comma instead of decimal point here
>> would probably create more confusion than benefit.

> ​Ideally it would be as simple as:

> - /* Leading decimal point? Then fractional seconds... */
> - else if (*cp == '.')
> + /* Leading decimal point or comma? Then fractional seconds... */
> + else if (*cp == '.' || *cp  == ',')

Well, it's not.

The core problem here is that the datetime input parser treats commas as
ignorable punctuation, equivalent to whitespace.  For instance, we accept

# select 'sunday, april 1, 2018'::timestamp;
      timestamp      
---------------------
 2018-04-01 00:00:00
(1 row)

but not

# select 'sunday. april 1, 2018'::timestamp;
ERROR:  invalid input syntax for type timestamp: "sunday. april 1, 2018"

But surely it would not be a good idea to consider "T01:45:00,728456785"
the same as "T01:45:00 728456785".

Changing this would entail all sorts of side-effects on non-ISO
data formats.  Considering that this code is about old enough to
vote, and this is the first complaint on this specific issue
that I can recall hearing, I don't even think it's worth the
time to investigate just what the side-effects would be ...
there's no way that any proposed change would get past the
backwards-compatibility hurdles.

			regards, tom lane




view thread (7+ messages)

Message-ID: <8933.1522726760@sss.pgh.pa.us>
Permalink:  ../8933.1522726760@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8933.1522726760@sss.pgh.pa.us

 · 

reply

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, david.g.johnston@gmail.com, defanor@uberspace.net
  Subject: Re: BUG #15141: Faulty ISO 8601 parsing
  In-Reply-To: <8933.1522726760@sss.pgh.pa.us>
  References: <152271186941.1442.12179299369295226185@wrigleys.postgresql.org> <32337.1522714669@sss.pgh.pa.us> <CAKFQuwbhU_mXqxXWBxog0s2Lwqj=U2=WWBBdSb5zbwUaFz-S5A@mail.gmail.com> <8933.1522726760@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