Re: BUG #17795: Erroneous parsing of floating-poing components in DecodeISO8601Interval() - Mailing list pgsql-bugs

From Alexander Lakhin
Subject Re: BUG #17795: Erroneous parsing of floating-poing components in DecodeISO8601Interval()
Date
Msg-id 18486f0e-cdfa-49b3-c863-bb83bdd8a097@gmail.com
Whole thread Raw
In response to Re: BUG #17795: Erroneous parsing of floating-poing components in DecodeISO8601Interval()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #17795: Erroneous parsing of floating-poing components in DecodeISO8601Interval()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
20.02.2023 02:40, Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
>> I've encountered a pair of relatively new anomalies when using ISO-8601
>> intervals.
>>
>>
>> On the whole I think the right fix is to go back to using strtod()
>> to parse the whole input string, as we did before e39f99046.  This
>> results in some inaccuracy if there's more than 15 digits in the
>> input, but I don't care enough about that scenario to work harder.
This approach seems less fragile to me. All my examples shown before
work as expected now.
Thanks!
>> There are a couple of other places where datetime.c is using strtod()
>> to parse what it expects to be a fractional value.  I'm inclined to
>> just barf if the result is out of range.  Maybe we shouldn't back-patch
>> that aspect into v15, not sure.
I could not find a way to pass the e-notation there.
Looking at the callers of the ParseFraction() and DecodeNumberField()
I see only DecodeDate(), DecodeDateTime(), DecodeTimeOnly(),
and DecodeInterval(). All these functions pass to ParseFraction()
and DecodeNumberField() not full "fractional" strings, but fields, that
were extracted before. For example, with "SELECT time 'J0.5e1';"
there are three fields  "j", "0.5", "e1" passed to DecodeTimeOnly(),
or with "SELECT interval '1.5e1';" I see fields "1.5" and "e1".
(Maybe I miss something.)

Also, the comment added makes me wonder, whether ".1e-10"
(e.g., in "1.1e-10") can be considered bogus too. I would say so
(if we are going to just add a fraction produced by ParseFraction()
to some integer part later, we still get the wrong result
(for the scientific notation)), and if we want to have
a consistent syntax, maybe it's worth to check an input string for 'e'/'E',
but if not, then maybe leave it alone. I would prefer the latter for now.

Best regards,
Alexander



pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #17789: process_pgfdw_appname() fails for autovacuum workers
Next
From: PG Bug reporting form
Date:
Subject: BUG #17802: PGLogical getting Terminated