From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Create ResultRelInfos later in InitPlan, index them by RT index.
Date: Tue, 13 Oct 2020 10:08:27 +0000
Message-ID: <E1kSHEJ-0008UU-Sd@gemulon.postgresql.org> (raw)
Create ResultRelInfos later in InitPlan, index them by RT index.
Instead of allocating all the ResultRelInfos upfront in one big array,
allocate them in ExecInitModifyTable(). es_result_relations is now an
array of ResultRelInfo pointers, rather than an array of structs, and it
is indexed by the RT index.
This simplifies things: we get rid of the separate concept of a "result
rel index", and don't need to set it in setrefs.c anymore. This also
allows follow-up optimizations (not included in this commit yet) to skip
initializing ResultRelInfos for target relations that were not needed at
runtime, and removal of the es_result_relation_info pointer.
The EState arrays of regular result rels and root result rels are merged
into one array. Similarly, the resultRelations and rootResultRelations
lists in PlannedStmt are merged into one. It's not actually clear to me
why they were kept separate in the first place, but now that the
es_result_relations array is indexed by RT index, it certainly seems
pointless.
The PlannedStmt->resultRelations list is now only needed for
ExecRelationIsTargetRelation(). One visible effect of this change is that
ExecRelationIsTargetRelation() will now return 'true' also for the
partition root, if a partitioned table is updated. That seems like a good
thing, although the function isn't used in core code, and I don't see any
reason for an FDW to call it on a partition root.
Author: Amit Langote
Discussion: https://www.postgresql.org/message-id/CA%2BHiwqGEmiib8FLiHMhKB%2BCH5dRgHSLc5N5wnvc4kym%2BZYpQEQ%40ma...
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1375422c7826a2bf387be29895e961614f69de4b
Modified Files
--------------
src/backend/commands/copy.c | 24 +--
src/backend/commands/explain.c | 17 +-
src/backend/commands/tablecmds.c | 9 +-
src/backend/commands/trigger.c | 2 +-
src/backend/executor/execMain.c | 256 +++++++++----------------------
src/backend/executor/execParallel.c | 1 -
src/backend/executor/execUtils.c | 57 ++++---
src/backend/executor/nodeModifyTable.c | 24 ++-
src/backend/nodes/copyfuncs.c | 3 -
src/backend/nodes/outfuncs.c | 4 -
src/backend/nodes/readfuncs.c | 3 -
src/backend/optimizer/plan/createplan.c | 2 -
src/backend/optimizer/plan/planner.c | 3 -
src/backend/optimizer/plan/setrefs.c | 17 +-
src/backend/replication/logical/worker.c | 32 ++--
src/include/executor/executor.h | 5 +-
src/include/nodes/execnodes.h | 18 +--
src/include/nodes/pathnodes.h | 2 -
src/include/nodes/plannodes.h | 8 -
19 files changed, 184 insertions(+), 303 deletions(-)
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: heikki.linnakangas@iki.fi
Subject: Re: pgsql: Create ResultRelInfos later in InitPlan, index them by RT index.
In-Reply-To: <E1kSHEJ-0008UU-Sd@gemulon.postgresql.org>
References: <E1kSHEJ-0008UU-Sd@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