pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use an explicit state flag to control PlaceHolderInfo creation.
Date: Wed, 17 Aug 2022 20:12:46 +0000
Message-ID: <E1oOPPA-0000Zu-TX@gemulon.postgresql.org> (raw)

Use an explicit state flag to control PlaceHolderInfo creation.

Up to now, callers of find_placeholder_info() were required to pass
a flag indicating if it's OK to make a new PlaceHolderInfo.  That'd
be fine if the callers had free choice, but they do not.  Once we
begin deconstruct_jointree() it's no longer OK to make more PHIs;
while callers before that always want to create a PHI if it's not
there already.  So there's no freedom of action, only the opportunity
to cause bugs by creating PHIs too late.  Let's get rid of that in
favor of adding a state flag PlannerInfo.placeholdersFrozen, which
we can set at the point where it's no longer OK to make more PHIs.

This patch also simplifies a couple of call sites that were using
complicated logic to avoid calling find_placeholder_info() as much
as possible.  Now that that lookup is O(1) thanks to the previous
commit, the extra bitmap manipulations are probably a net negative.

Discussion: https://postgr.es/m/1405792.1660677844@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/path/costsize.c     |  2 +-
src/backend/optimizer/path/equivclass.c   |  2 +-
src/backend/optimizer/plan/createplan.c   |  9 ++-------
src/backend/optimizer/plan/initsplan.c    | 32 +++++++++++++++++--------------
src/backend/optimizer/plan/planner.c      |  1 +
src/backend/optimizer/prep/prepjointree.c |  1 +
src/backend/optimizer/util/inherit.c      |  2 +-
src/backend/optimizer/util/paramassign.c  | 10 +++-------
src/backend/optimizer/util/placeholder.c  | 26 ++++++++++---------------
src/include/nodes/pathnodes.h             |  2 ++
src/include/optimizer/placeholder.h       |  2 +-
src/include/optimizer/planmain.h          |  2 +-
12 files changed, 42 insertions(+), 49 deletions(-)



Message-ID: <E1oOPPA-0000Zu-TX@gemulon.postgresql.org>
Permalink:  ../E1oOPPA-0000Zu-TX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oOPPA-0000Zu-TX@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Use an explicit state flag to control PlaceHolderInfo creation.
  In-Reply-To: <E1oOPPA-0000Zu-TX@gemulon.postgresql.org>
  References: <E1oOPPA-0000Zu-TX@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