Re: Fix overflow in DecodeInterval - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Fix overflow in DecodeInterval
Date
Msg-id 1642579.1649001803@sss.pgh.pa.us
Whole thread Raw
In response to Re: Fix overflow in DecodeInterval  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Fix overflow in DecodeInterval  (Joseph Koshakow <koshy44@gmail.com>)
List pgsql-hackers
I wrote:
> Joseph Koshakow <koshy44@gmail.com> writes:
>> I think I know that the issue is. It's with `ParseISO8601Number` and
>> the minutes field "1.".
>> Previously that function parsed the entire field into a single double,
>> so "1." would
>> be parsed into 1.0. Now we try to parse the integer and decimal parts
>> separately. So
>> we first parse "1" into 1 and then fail to "." into anything because
>> it's not a valid decimal.

> Interesting point, but then why doesn't it fail everywhere?

Oh ... a bit of testing says that strtod() on an empty string
succeeds (returning zero) on Linux, but fails with EINVAL on
AIX.  The latter is a lot less surprising than the former,
so we'd better cope.

(Reading POSIX with an eagle eye, it looks like both behaviors
are allowed per spec: this is why you have to check that endptr
was advanced to be sure everything is kosher.)

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Fix overflow in DecodeInterval
Next
From: Andres Freund
Date:
Subject: Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints