pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix 'negative bitmapset member' error
Date: Mon, 15 Jan 2024 15:45:32 +0000
Message-ID: <E1rPP9Y-001YnJ-1M@gemulon.postgresql.org> (raw)

Fix 'negative bitmapset member' error

When removing a useless join, we'd remove PHVs that are not used at join
partner rels or above the join.  A PHV that references the join's relid
in ph_eval_at is logically "above" the join and thus should not be
removed.  We have the following check for that:

    !bms_is_member(ojrelid, phinfo->ph_eval_at)

However, in the case of SJE removing a useless inner join, 'ojrelid' is
set to -1, which would trigger the "negative bitmapset member not
allowed" error in bms_is_member().

Fix it by skipping examining ojrelid for inner joins in this check.

Reported-by: Zuming Jiang
Bug: #18260
Discussion: https://postgr.es/m/18260-1b6a0c4ae311b837%40postgresql.org
Author: Richard Guo
Reviewed-by: Andrei Lepikhov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/fe093994db4dc5dcc239f8839b094c0b75de00cf

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c |  2 +-
src/test/regress/expected/join.out        | 20 ++++++++++++++++++++
src/test/regress/sql/join.sql             |  8 ++++++++
3 files changed, 29 insertions(+), 1 deletion(-)



Message-ID: <E1rPP9Y-001YnJ-1M@gemulon.postgresql.org>
Permalink:  ../E1rPP9Y-001YnJ-1M@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rPP9Y-001YnJ-1M@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix 'negative bitmapset member' error
  In-Reply-To: <E1rPP9Y-001YnJ-1M@gemulon.postgresql.org>

* 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