Re: Making empty Bitmapsets always be NULL - Mailing list pgsql-hackers

From Yuya Watari
Subject Re: Making empty Bitmapsets always be NULL
Date
Msg-id CAJ2pMkZ5F7c_ddQpqT-89ZuE8sVV-zHsXWHcVuf=uwsGaPu-bw@mail.gmail.com
Whole thread Raw
In response to Re: Making empty Bitmapsets always be NULL  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: Making empty Bitmapsets always be NULL
List pgsql-hackers
Hello,

On Thu, Jun 22, 2023 at 1:43 PM David Rowley <dgrowleyml@gmail.com> wrote:
> > 3. Avoid enlargement when nwords is equal wordnum.
> >     Can save cycles when in corner cases?
>
> No, you're just introducing a bug here.  Arrays in C are zero-based,
> so "wordnum >=  a->nwords" is exactly the correct way to check if
> wordnum falls outside the bounds of the existing allocated memory. By
> changing that to "wordnum > a->nwords" we'll fail to enlarge the words
> array when it needs to be enlarged by 1 element.

I agree with David. Unfortunately, some of the regression tests failed
with the v5 patch. These failures are due to the bug introduced by the
#3 change.

--
Best regards,
Yuya Watari



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Remove deprecation warnings when compiling PG ~13 with OpenSSL 3.0~
Next
From: Yuya Watari
Date:
Subject: Re: Making empty Bitmapsets always be NULL