Re: BRIN minmax multi - incorrect distance for infinite timestamp/date
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-10-18T10:56:39Z
Lists: pgsql-hackers
On Wed, 18 Oct 2023 at 09:16, Tomas Vondra <tomas.vondra@enterprisedb.com> wrote: > > BTW when adding the tests with extreme values, I noticed this: > > test=# select '5874897-01-01'::date; > date > --------------- > 5874897-01-01 > (1 row) > > test=# select '5874897-01-01'::date + '1 second'::interval; > ERROR: date out of range for timestamp > That's correct because date + interval returns timestamp, and the value is out of range for a timestamp. This is equivalent to: select '5874897-01-01'::date::timestamp + '1 second'::interval; ERROR: date out of range for timestamp and I think it's good that it gives a different error from this: select '294276-01-01'::date::timestamp + '1 year'::interval; ERROR: timestamp out of range so you can tell that the overflow in the first case happens before the addition. Of course a side effect of internally casting first is that you can't do things like this: select '5874897-01-01'::date - '5872897 years'::interval; ERROR: date out of range for timestamp which arguably ought to return '2000-01-01 00:00:00'. In practice though, I think it would be far more trouble than it's worth trying to change that. Regards, Dean
Commits
-
Fix minmax-multi distance for extreme interval values
- 0fa73c5cd050 14.10 landed
- 2fbb2fcb0c63 15.5 landed
- 924e0e2ee058 16.1 landed
- c6cf6d353c28 17.0 landed
-
Fix minmax-multi on infinite date/timestamp values
- 52c934cc1f2e 14.10 landed
- d04a9283b707 15.5 landed
- 497fc92086f8 16.1 landed
- 8da86d62a112 17.0 landed
-
Fix calculation in brin_minmax_multi_distance_date
- d1740e169d95 14.10 landed
- 088233f8db6c 15.5 landed
- e7965226d551 16.1 landed
- 394d51731495 17.0 landed
-
Fix overflow when calculating timestamp distance in BRIN
- 90c4da6d4392 14.10 landed
- daa7b0d7ce14 15.5 landed
- 0635fe02b426 16.1 landed
- b5489b75c6ce 17.0 landed