| From: | Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix BRIN minmax-multi distance calculation for OID |
| Date: | 2026-11-02 22:41:52 |
| Message-ID: | E1xO0iu-00000001r1E-1tGg@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix BRIN minmax-multi distance calculation for OID
The oid_minmax_multi_ops opclass simply calculated the distance using
brin_minmax_multi_distance_int4. That however interprets the values as
int32, so OIDs above PG_INT32_MAX were treated as negative values, and
ranges crossing the boundary ended with a negative distance.
With assert-enabled guild, this tripped the (a1 <= a2) check. Without
asserts, the index was less efficient.
Fix by introducing brin_minmax_multi_distance_oid, correctly treating
the OID values as unsigned.
This required a catalog change (and catversion bump), so it can't be
backpatched. It'd be possible to adjust brin_minmax_multi_distance_int4
to handle the (a1 > a2) case differently. But that'd lose the assert,
and it does not seem worth it (indexes on OIDs don't seem very common).
Author: Tomas Vondra <tomas(at)vondra(dot)me>
Reviewed-by: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Reviewed-by: shihao zhong <zhong950419(at)gmail(dot)com>
Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/4b6735c21fa4c43be041c6c610d7be6463c2c1f9
Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c | 21 +++++++++++++++++++++
src/include/catalog/pg_amproc.dat | 2 +-
src/include/catalog/pg_proc.dat | 4 ++++
src/test/regress/expected/brin_multi.out | 5 +++++
src/test/regress/sql/brin_multi.sql | 8 ++++++++
5 files changed, 39 insertions(+), 1 deletion(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Masahiko Sawada | 2026-11-02 23:01:26 | pgsql: Add REPACK progress phases for logical decoding setup. |
| Previous Message | Masahiko Sawada | 2026-11-02 21:23:26 | pgsql: Make parallel vacuum processes share the cost limit. |