Re: Infinite Interval
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
To: Joseph Koshakow <koshy44@gmail.com>
Cc: 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-03-31T12:46:12Z
Lists: pgsql-hackers
Attachments
- interval_mul_fixes.patch (text/x-patch) patch
I hurried too much on the previous patch. It introduced other problems. Attached is a better patch and also fixes problem below #select 'infinity'::interval * 0; ?column? ---------- infinity (1 row) with the patch we see #select 'infinity'::interval * 0; 2023-03-31 18:00:43.131 IST [240892] ERROR: interval out of range 2023-03-31 18:00:43.131 IST [240892] STATEMENT: select 'infinity'::interval * 0; ERROR: interval out of range which looks more appropriate given 0 * inf = Nan for float. There's some way to avoid separate checks for infinite-ness of interval and factor and use a single block using some integer arithmetic. But I think this is more readable. So I avoided doing that. Let me know if this works for you. Also added some test cases. -- Best Wishes, Ashutosh Bapat On Fri, Mar 31, 2023 at 3:46 PM Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> wrote: > > On Tue, Mar 28, 2023 at 7:17 PM Ashutosh Bapat > <ashutosh.bapat.oss@gmail.com> wrote: > > make sure that every > > operator that interval as one of its operands or the result has been > > covered in the code. > > time_mi_time - do we want to add an Assert to make sure that this > function does not produce an Interval structure which looks like > non-finite interval? > > multiplying an interval by infinity throws an error > #select '5 days'::interval * 'infinity'::float8; > 2023-03-29 19:40:15.797 IST [136240] ERROR: interval out of range > 2023-03-29 19:40:15.797 IST [136240] STATEMENT: select '5 > days'::interval * 'infinity'::float8; > ERROR: interval out of range > > I think this should produce an infinite interval now. Attached patch > to fix this, to be applied on top of your patch. With the patch > #select '5 days'::interval * 'infinity'::float8; > ?column? > ---------- > infinity > (1 row) > > Going through the tests now. > > -- > Best Wishes, > Ashutosh Bapat
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