Re: BUG #15141: Faulty ISO 8601 parsing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: defanor(at)uberspace(dot)net
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15141: Faulty ISO 8601 parsing
Date: 2018-04-03 00:17:49
Message-ID: 32337.1522714669@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
> The time parsing fails on some valid ISO times, with some locales, e.g.:

> # select to_timestamp('2018-04-03T01:45:00,728456785+0000')::timestamp with
> time zone;
> ERROR: invalid input syntax for type double precision:
> "2018-04-03T01:45:00,728456785+0000"

This is confused: the single-argument form of to_timestamp() takes a
float8 argument, not a timestamp, which is why the error message is
phrased the way it is.

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.

(Also, this is not the only aspect of 8601 that we don't support;
for instance the option to specify fractional minutes or hours
instead of fractional seconds. There again, I think the potential
for confusion and error outweighs any benefit from being nominally
more standards-compliant.)

You probably could read data formatted this way using the two-argument
form of to_timestamp() with a suitable format string.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2018-04-03 00:46:21 Re: BUG #15141: Faulty ISO 8601 parsing
Previous Message David G. Johnston 2018-04-02 23:58:15 Re: BUG #15141: Faulty ISO 8601 parsing