pgsql: Fix minmax-multi distance for extreme interval values

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix minmax-multi distance for extreme interval values
Date: 2023-10-27 16:58:09
Message-ID: E1qwQ9x-002dIm-34@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix minmax-multi distance for extreme interval values

When calculating distance for interval values, the code mostly mimicked
interval_mi, i.e. it built a new interval value for the difference.
That however does not work for sufficiently distant interval values,
when the difference overflows the interval range.

Instead, we can calculate the distance directly, without constructing
the intermediate (and unnecessary) interval value.

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

Reported-by: Dean Rasheed
Reviewed-by: Ashutosh Bapat, Dean Rasheed
Backpatch-through: 14
Discussion: https://postgr.es/m/eef0ea8c-4aaa-8d0d-027f-58b1f35dd170@enterprisedb.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/924e0e2ee058d8dfeae6218dba9419a3ddf1c755

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 33 ++++-------------------------
src/test/regress/expected/brin_multi.out | 29 +++++++++++++++++++++++++
src/test/regress/sql/brin_multi.sql | 21 ++++++++++++++++++
3 files changed, 54 insertions(+), 29 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2023-10-27 16:59:40 pgsql: Fix minmax-multi on infinite date/timestamp values
Previous Message Tomas Vondra 2023-10-27 16:57:46 pgsql: Fix calculation in brin_minmax_multi_distance_date