Re: BUG #15141: Faulty ISO 8601 parsing - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #15141: Faulty ISO 8601 parsing
Date
Msg-id 32337.1522714669@sss.pgh.pa.us
Whole thread Raw
In response to BUG #15141: Faulty ISO 8601 parsing  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #15141: Faulty ISO 8601 parsing
Re: BUG #15141: Faulty ISO 8601 parsing
Re: BUG #15141: Faulty ISO 8601 parsing
List pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.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


pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #15141: Faulty ISO 8601 parsing
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #15141: Faulty ISO 8601 parsing