Re: Crash in BRIN minmax-multi indexes

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: Zhihong Yu <zyu(at)yugabyte(dot)com>
Cc: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Crash in BRIN minmax-multi indexes
Date: 2021-04-01 01:39:30
Message-ID: 4c972b7f-3223-93c1-2b14-b2c7f4061ce8@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2021-04-01 01:43:41 Re: New IndexAM API controlling index vacuum strategies
Previous Message Zhihong Yu 2021-04-01 01:22:03 Re: Crash in BRIN minmax-multi indexes