From: | Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Greg Stark <stark(at)mit(dot)edu>, Zhihong Yu <zyu(at)yugabyte(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: PATCH: Using BRIN indexes for sorted output |
Date: | 2023-02-24 10:25:55 |
Message-ID: | b8a4e04c-c091-056c-a379-11d35c7b2d8d@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2/24/23 09:39, Alvaro Herrera wrote:
> On 2023-Feb-23, Matthias van de Meent wrote:
>
>>> + for (heapBlk = 0; heapBlk < nblocks; heapBlk += pagesPerRange)
>>
>> I am not familiar with the frequency of max-sized relations, but this
>> would go into an infinite loop for pagesPerRange values >1 for
>> max-sized relations due to BlockNumber wraparound. I think there
>> should be some additional overflow checks here.
>
> They are definitely not very common -- BlockNumber wraps around at 32 TB
> IIUC. But yeah, I guess it is a possibility, and perhaps we should find
> a way to write these loops in a more robust manner.
>
I guess the easiest fix would be to do the arithmetic in 64 bits. That'd
eliminate the overflow.
Alternatively, we could do something like
prevHeapBlk = 0;
for (heapBlk = 0; (heapBlk < nblocks) && (prevHeapBlk <= heapBlk);
heapBlk += pagesPerRange)
{
...
prevHeapBlk = heapBlk;
}
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Nazir Bilal Yavuz | 2023-02-24 10:43:26 | Re: allow meson to find ICU in non-standard localtion |
Previous Message | Anton A. Melnikov | 2023-02-24 10:12:47 | Re: odd buildfarm failure - "pg_ctl: control file appears to be corrupt" |