Re: Making empty Bitmapsets always be NULL

From: Yuya Watari <watari(dot)yuya(at)gmail(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Making empty Bitmapsets always be NULL
Date: 2023-06-22 08:49:34
Message-ID: CAJ2pMkZ5F7c_ddQpqT-89ZuE8sVV-zHsXWHcVuf=uwsGaPu-bw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

On Thu, Jun 22, 2023 at 1:43 PM David Rowley <dgrowleyml(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yuya Watari 2023-06-22 08:59:13 Re: Making empty Bitmapsets always be NULL
Previous Message Michael Paquier 2023-06-22 08:39:33 Re: Remove deprecation warnings when compiling PG ~13 with OpenSSL 3.0~