pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Lepikhov <a.lepikhov@postgrespro.ru>
To: Richard Guo <guofenglinux@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: zuming.jiang@inf.ethz.ch
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN
Date: Mon, 15 Jan 2024 07:20:37 +0700
Message-ID: <72b0913e-a2b1-444d-a2fa-fa154ae91034@postgrespro.ru> (raw)
In-Reply-To: <CAMbWs48k_meXFAH1qb9UiPS8Q_p-POWWW0DLpYtf2yiHht_ncA@mail.gmail.com>
References: <18260-1b6a0c4ae311b837@postgresql.org>
	<CAMbWs4-tpHZyE-aEqhYt_aLtKU0YbcXBgz_GXG0EVHQXhSrENA@mail.gmail.com>
	<CAMbWs4-7ZRRuaXpksRR2so3XW+gdRWPMiAuSGqdfgy9fFaUCDg@mail.gmail.com>
	<ac1454ad-dc4d-467c-9a5a-11709ba33195@postgrespro.ru>
	<CAMbWs48k_meXFAH1qb9UiPS8Q_p-POWWW0DLpYtf2yiHht_ncA@mail.gmail.com>

On 11/1/2024 16:08, Richard Guo wrote:
> 
> On Thu, Dec 28, 2023 at 12:30 PM Andrei Lepikhov 
> <a.lepikhov@postgrespro.ru <mailto:a.lepikhov@postgrespro.ru>> wrote:
> 
>     On 28/12/2023 10:03, Richard Guo wrote:
>      >          if (bms_is_subset(phinfo->ph_needed, joinrelids) &&
>      >              bms_is_member(relid, phinfo->ph_eval_at) &&
>      > -           !bms_is_member(ojrelid, phinfo->ph_eval_at))
>      > +           (sjinfo == NULL || !bms_is_member(ojrelid,
>     phinfo->ph_eval_at)))
> 
>      > Alternatively, we can modify bms_is_member() to return false for
>      > negative numbers instead of emitting an error, as suggested by the
>      > comment there.
>      > -   /* XXX better to just return false for x<0 ? */
>      > +   /* negative number cannot be a member of the bitmapset */
>      >      if (x < 0)
>      > -       elog(ERROR, "negative bitmapset member not allowed");
>      > +       return false;
>      >
>      > I prefer the second option, but I'm open to other thoughts.
>     I don't like this option. It could mask some blunders somewhere like a
>     current one.
> 
> 
> After a second thought, I agree that the first option is better.  It
> maintains consistency with the Assert a few lines ahead, and also
> minimizes the potential impact of code changes compared to the second
> option.
> 
>      > FWIW, here is a simplified repro for this error.
>      >
>      > create table t (a int primary key, b int);
>      >
>      > explain (verbose, costs off)
>      > select 1 from t t1 left join
>      >      (lateral (select 1 as x, * from t t2) s1 inner join
>      >          (select * from t t3) s2 on s1.a = s2.a)
>      >      on true
>      > where s1.x = 1;
>      > ERROR:  negative bitmapset member not allowed
>     It can be simplified even more (without LATERAL):
> 
> 
> Indeed.  I realized this shortly after v1 patch was sent out, and was
> thinking that it wasn't worth the effort to update the patch with a new
> version just for this issue.
I like it, thanks for your efforts.

-- 
regards,
Andrei Lepikhov
Postgres Professional






view thread (8+ messages)  latest in thread

Message-ID: <72b0913e-a2b1-444d-a2fa-fa154ae91034@postgrespro.ru>
Permalink:  ../72b0913e-a2b1-444d-a2fa-fa154ae91034@postgrespro.ru/
Also on:    postgresql.org/message-id/72b0913e-a2b1-444d-a2fa-fa154ae91034@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: a.lepikhov@postgrespro.ru, guofenglinux@gmail.com, aekorotkov@gmail.com, zuming.jiang@inf.ethz.ch, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN
  In-Reply-To: <72b0913e-a2b1-444d-a2fa-fa154ae91034@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox