Fix minmax-multi distance for extreme interval values
authorTomas Vondra <tomas.vondra@postgresql.org>
Fri, 27 Oct 2023 15:57:44 +0000 (17:57 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Fri, 27 Oct 2023 16:46:56 +0000 (18:46 +0200)
commit0fa73c5cd05093236cd6d5ff56e0bd5693d2645f
treebdc717756b75256e8d85ea9da2eddad982998efd
parent52c934cc1f2ee947a76dfc395403b07c24bb6712
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
src/backend/access/brin/brin_minmax_multi.c
src/test/regress/expected/brin_multi.out
src/test/regress/sql/brin_multi.sql