pgsql: Fix netmask handling in inet_minmax_multi_ops

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix netmask handling in inet_minmax_multi_ops
Date: 2023-03-20 09:28:35
Message-ID: E1peBoh-004SQd-AM@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix netmask handling in inet_minmax_multi_ops

When calculating distance in brin_minmax_multi_distance_inet(), the
netmask was applied incorrectly. This results in (seemingly) incorrect
ordering of values, triggering an assert.

For builds without asserts this is mostly harmless - we may merge other
ranges, possibly resulting in slightly less efficient index. But it's
still correct and the greedy algorithm doesn't guarantee optimality
anyway.

Backpatch to 14, where minmax-multi indexes were introduced.

Reported by Dmitry Dolgov, investigation and fix by me.

Reported-by: Dmitry Dolgov
Backpatch-through: 14
Discussion: https://postgr.es/m/17774-c6f3e36dd4471e67@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e8583126833a53f4eebe28a8de45d128f01ff664

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 4 ++--
src/test/regress/expected/brin_multi.out | 6 ++++++
src/test/regress/sql/brin_multi.sql | 7 +++++++
3 files changed, 15 insertions(+), 2 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2023-03-20 09:28:54 pgsql: Fix netmask handling in inet_minmax_multi_ops
Previous Message Peter Eisentraut 2023-03-20 08:05:23 pgsql: doc: Additional information about timeline ID hexadecimal format