Re: Fix BRIN numeric_minmax_multi_ops out of range value range merging

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix BRIN numeric_minmax_multi_ops out of range value range merging
Date: 2026-11-05 14:57:50
Message-ID: 462c8b7d-2685-4ee7-9046-29482e51c76c@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/2/26 23:49, Tomas Vondra wrote:
> On 10/31/26 05:11, shihao zhong wrote:
>> Hi Tomas,
>>
>> Thanks for your patch.. 
>>
>> I think your code is right, the subtraction only fails when the result
>> is too
>> big for numeric.  
>>
>> Two small things.
>>
>> 1. A NaN boundary gives a NaN distance. The
>> brin_minmax_multi_distance_numeric
>> return infinity there.
>>
>> 2. In 0004, GiST can call numrange_subdiff with v1 < v2. Overflow
>> there should give -infinity, not +infinity.
>>
>
> Thanks. I've pushed the three BRIN fixes. Here's an updated fix for the
> multirange issue, with the -infinity for (v1 < v2).
>

I've pushed the remaining part, with some minor tweaks (mostly wording,
stale comments, and so on). I realized this may actually affect more
places, including inserts into GiST indexes, selectivity estimation,
etc. Hence the minor tweaks in the commit message.

I have tried to construct a test exercising the -infinity case, but that
turned out a bit ugly. It either depended on platform (formatting of
"infinity"), or triggered it through GiST page splits etc. I decided
it's not worth it, so we test just the +infinity case.

Thanks for the investigation and patches!

--
Tomas Vondra
may the buildfarm be merciful

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-05 15:10:43 Re: Remove obsolete locking comment from AddBufferToRing()
Previous Message Ayoub Kazar 2026-11-05 14:52:23 Re: Fix exclude generated columns in COPY TO with RLS