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: Avoid passing query tlist around separately from root->processed
Date: Wed, 27 Mar 2019 16:58:27 +0000
Message-ID: <E1h9Bsh-0001k6-KZ@gemulon.postgresql.org> (raw)

Avoid passing query tlist around separately from root->processed_tlist.

In the dim past, the planner kept the fully-processed version of the query
targetlist (the result of preprocess_targetlist) in grouping_planner's
local variable "tlist", and only grudgingly passed it to individual other
routines as needed.  Later we discovered a need to still have it available
after grouping_planner finishes, and invented the root->processed_tlist
field for that purpose, but it wasn't used internally to grouping_planner;
the tlist was still being passed around separately in the same places as
before.

Now comes a proposed patch to allow appendrel expansion to add entries
to the processed tlist, well after preprocess_targetlist has finished
its work.  To avoid having to pass around the tlist explicitly, it's
proposed to allow appendrel expansion to modify root->processed_tlist.
That makes aliasing the tlist with assorted parameters and local
variables really scary.  It would accidentally work as long as the
tlist is initially nonempty, because then the List header won't move
around, but it's not exactly hard to think of ways for that to break.
Aliased values are poor programming practice anyway.

Hence, get rid of local variables and parameters that can be identified
with root->processed_tlist, in favor of just using that field directly.
And adjust comments to match.  (Some of the new comments speak as though
it's already possible for appendrel expansion to modify the tlist; that's
not true yet, but will happen in a later patch.)

Discussion: https://postgr.es/m/9d7c5112-cb99-6a47-d3be-cf1ee6862a1d@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/333ed246c6f351c4e8fe22c764b97793c4101b00

Modified Files
--------------
src/backend/optimizer/plan/planagg.c  | 19 +++++-----
src/backend/optimizer/plan/planmain.c |  6 ++--
src/backend/optimizer/plan/planner.c  | 65 +++++++++++++----------------------
src/include/nodes/pathnodes.h         |  9 +++--
src/include/optimizer/planmain.h      |  4 +--
5 files changed, 45 insertions(+), 58 deletions(-)



Message-ID: <E1h9Bsh-0001k6-KZ@gemulon.postgresql.org>
Permalink:  ../E1h9Bsh-0001k6-KZ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1h9Bsh-0001k6-KZ@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: Avoid passing query tlist around separately from root->processed
  In-Reply-To: <E1h9Bsh-0001k6-KZ@gemulon.postgresql.org>
  References: <E1h9Bsh-0001k6-KZ@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