mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
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%40mail.gmail.com
This commit is contained in:
@ -519,23 +519,19 @@ typedef struct EState
|
||||
CommandId es_output_cid;
|
||||
|
||||
/* Info about target table(s) for insert/update/delete queries: */
|
||||
ResultRelInfo *es_result_relations; /* array of ResultRelInfos */
|
||||
int es_num_result_relations; /* length of array */
|
||||
ResultRelInfo **es_result_relations; /* Array of per-range-table-entry
|
||||
* ResultRelInfo pointers, or NULL
|
||||
* if not a target table */
|
||||
List *es_opened_result_relations; /* List of non-NULL entries in
|
||||
* es_result_relations in no
|
||||
* specific order */
|
||||
ResultRelInfo *es_result_relation_info; /* currently active array elt */
|
||||
|
||||
/*
|
||||
* Info about the partition root table(s) for insert/update/delete queries
|
||||
* targeting partitioned tables. Only leaf partitions are mentioned in
|
||||
* es_result_relations, but we need access to the roots for firing
|
||||
* triggers and for runtime tuple routing.
|
||||
*/
|
||||
ResultRelInfo *es_root_result_relations; /* array of ResultRelInfos */
|
||||
int es_num_root_result_relations; /* length of the array */
|
||||
PartitionDirectory es_partition_directory; /* for PartitionDesc lookup */
|
||||
|
||||
/*
|
||||
* The following list contains ResultRelInfos created by the tuple routing
|
||||
* code for partitions that don't already have one.
|
||||
* code for partitions that aren't found in the es_result_relations array.
|
||||
*/
|
||||
List *es_tuple_routing_result_relations;
|
||||
|
||||
|
Reference in New Issue
Block a user