Re: Infinite Interval
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: Joseph Koshakow <koshy44@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, "Gregory Stark (as CFM)" <stark.cfm@gmail.com>,
jian he <jian.universality@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-09-18T11:39:35Z
Lists: pgsql-hackers
On Wed, 13 Sept 2023 at 11:13, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> wrote: > > On Tue, Sep 12, 2023 at 2:39 PM Dean Rasheed <dean.a.rasheed@gmail.com> wrote: > > > > and it looks like the infinite interval > > input code is broken. > > The code required to handle 'infinity' as an input value was removed by > d6d1430f404386162831bc32906ad174b2007776. I have added a separate > commit which reverts that commit as 0004, which should be merged into > 0003. > I think that simply reverting d6d1430f404386162831bc32906ad174b2007776 is not sufficient. This does not make it clear what the point is of the code in the "case RESERV" block. That code really should check the value returned by DecodeSpecial(), otherwise invalid inputs are not caught until later, and the error reported is not ideal. For example: select interval 'now'; ERROR: unexpected dtype 12 while parsing interval "now" So DecodeInterval() should return DTERR_BAD_FORMAT in such cases (see similar code in DecodeTimeOnly(), for example). I'd also suggest a comment to indicate why itm_in isn't updated in this case (see similar case in DecodeDateTime(), for example). Another point to consider is what should happen if "ago" is specified with infinite inputs. As it stands, it is accepted, but does nothing: select interval 'infinity ago'; interval ---------- infinity (1 row) select interval '-infinity ago'; interval ----------- -infinity (1 row) This could be made to invert the sign, as it does for finite inputs, but I think perhaps it would be better to simply reject such inputs. Regards, Dean
Commits
-
Support +/- infinity in the interval data type.
- 519fc1bd9e9d 17.0 landed
-
Avoid integer overflow hazard in interval_time().
- 3850d4dec1d9 17.0 landed
-
Guard against overflow in make_interval().
- b2d55447a563 17.0 landed
-
Fix minmax-multi on infinite date/timestamp values
- 8da86d62a112 17.0 cited
-
Optimize various aggregate deserialization functions, take 2
- 0c882a298881 17.0 cited
-
Remove dead code in DecodeInterval()
- d6d1430f4043 17.0 cited
-
Accept "+infinity" in date and timestamp[tz] input.
- 2ceea5adb026 16.0 cited
-
Fix overflow hazards in interval input and output conversions.
- e39f99046710 15.0 cited