Re: Making empty Bitmapsets always be NULL

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Yuya Watari <watari(dot)yuya(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Making empty Bitmapsets always be NULL
Date: 2023-06-20 04:16:56
Message-ID: CAApHDvoBXTxsi6Peo48_geUa6=BM9fo6FCv93DqYFob0uE1ZKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 15 Jun 2023 at 20:57, Yuya Watari <watari(dot)yuya(at)gmail(dot)com> wrote:
>
> On Tue, Jun 13, 2023 at 8:07 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> > For the fix in the 0004 patch, I think we can do what you did more
> > simply. I don't think there's any need to perform the loop to find
> > the last non-zero word. We're only deleting a member from a single
> > word here, so we only need to check if that word is the last word and
> > remove it if it's become zero. If it's not the last word then we
> > can't remove it as there must be some other non-zero word after it.
>
> If my thinking is correct, the do-while loop I added is still
> necessary. Consider the following code. The Assertion in this code
> passes in the master but fails in the new patch.
>
> =====
> Bitmapset *x = bms_make_singleton(1000);
>
> x = bms_del_member(x, 1000);
> Assert(x == NULL);
> =====

I'm not sure what I was thinking there. Yeah, you're right, we do
need to do the backwards loop over the set to trim off the trailing
zero words.

I've adjusted the attached patch to do that.

David

Attachment Content-Type Size
remove_zero_trailing_words_from_bitmapsets_v4.patch text/plain 17.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-06-20 04:18:36 Re: Deleting prepared statements from libpq.
Previous Message Michael Paquier 2023-06-20 03:46:19 Re: Fix regression tests to work with REGRESS_OPTS=--no-locale