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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: exclusion(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17795: Erroneous parsing of floating-poing components in DecodeISO8601Interval()
Date: 2023-02-19 23:40:59
Message-ID: 3449142.1676850059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> I've encountered a pair of relatively new anomalies when using ISO-8601
> intervals.

Thanks for the report! All of these seem to trace to the fact that
ParseISO8601Number isn't considering the possibility that the input
string ends with "eNN". This allows the reported "fraction" output
to have values greater than 1, which breaks some calling code as you
show, and it also fails to apply that scale factor to the integer
part of the output, which accounts for some of the other cases.

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.

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.

Anyway I propose the attached.

regards, tom lane

Attachment Content-Type Size
fix-E-notation-in-datetime-fields.patch text/x-diff 4.8 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2023-02-19 23:46:03 Re: Inconsistent 'at time zone' conversion
Previous Message Umut TEKİN 2023-02-19 22:36:37 Inconsistent 'at time zone' conversion