Re: Crash in BRIN minmax-multi indexes
Tomas Vondra <tomas.vondra@enterprisedb.com>
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Zhihong Yu <zyu@yugabyte.com>
Cc: Jaime Casanova <jcasanov@systemguards.com.ec>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-04-01T01:39:30Z
Lists: pgsql-hackers
On 4/1/21 3:22 AM, Zhihong Yu wrote:
> Hi,
> - delta += (float8) addrb[i] - (float8) addra[i];
> - delta /= 256;
> ...
> + delta /= 255;
>
> May I know why the divisor was changed ?
>
Yeah, that's a mistake, it should remain 256. Consider two subtractions
1.1.2.255 - 1.1.1.0 = [0, 0, 1, 255]
1.1.2.255 - 1.1.0.255 = [0, 0, 2, 0]
With the divisor being 255 those would be the same (2 * 256), but we
want the first one to be a bit smaller. It's also consistent with how
inet does subtractions:
test=# select '1.1.2.255'::inet - '1.1.0.255'::inet;
?column?
----------
512
(1 row)
test=# select '1.1.2.255'::inet - '1.1.1.0'::inet;
?column?
----------
511
(1 row)
So I'll keep the 256.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Commits
-
Fix assert in BRIN build_distances
- 02699bc1fd3b 16.0 landed
- c4f64cfab9fe 15.2 landed
- 883dc0214a64 14.7 landed
-
Fix bug in brin_minmax_multi_union
- d9c5b9a9eeb9 14.0 landed
-
Fix order of parameters in BRIN minmax-multi calls
- 1dad2a5ea3d1 14.0 landed
-
Fix BRIN minmax-multi distance for inet type
- e1fbe1181c86 14.0 landed
-
Fix BRIN minmax-multi distance for timetz type
- 7262f2421a1e 14.0 landed
-
Fix BRIN minmax-multi distance for interval type
- 2b10e0e3c2ca 14.0 landed