From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | James Hunter <james(dot)hunter(dot)pg(at)gmail(dot)com> |
Cc: | Evgeniy Gorbanyov <gorbanyoves(at)basealt(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Possible integer overflow in bringetbitmap() |
Date: | 2024-12-10 03:33:08 |
Message-ID: | Z1e2dNa_AXAbGiVj@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Dec 05, 2024 at 08:46:45AM -0800, James Hunter wrote:
> On Wed, Dec 4, 2024 at 10:13 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> >
> > totalpages is signed, and BlockNumber is unsigned. Hence in theory
> > you could always fall into a trap once totalpages gets higher than
> > (2^31 - 1), no? This is not going to be a problem in practice even if
> > the number of pages per range assigned to brin can be 1, still..
>
> Good point -- so the fix should be something like: (a) make totalpages
> a BlockNumber or uint32; (b) cast either "totalpages" or "10" to
> int64, before returning the result?
Sure, you could do (a) and (b) together. It also seems to me that it
is just simpler to make totalpages a int64 to map automatically with
the result expected by the caller of bringetbitmap(), and we know that
based on MaxBlockNumber we'll never run out of bits.
--
Michael
From | Date | Subject | |
---|---|---|---|
Next Message | Evgeny | 2024-12-10 03:38:06 | Re: Add 64-bit XIDs into PostgreSQL 15 |
Previous Message | jian he | 2024-12-10 03:32:37 | Re: proposal: schema variables |