diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-12-02 10:35:55 +0100 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-12-02 10:35:55 +0100 |
commit | fb958b5da86da69651f6fb9f540c2cfb1346cdc5 (patch) | |
tree | a059d6e4ceab797bc94f2212a5d748f5e1b3fa6d /src/include/nodes/execnodes.h | |
parent | 40b1491357a4a092ea054176944cf76e2fe3eff8 (diff) |
Generalize ri_RootToPartitionMap to use for non-partition children
ri_RootToPartitionMap is currently only initialized for tuple routing
target partitions, though a future commit will need the ability to use
it even for the non-partition child tables, so make adjustments to the
decouple it from the partitioning code.
Also, make it lazily initialized via ExecGetRootToChildMap(), making
that function its preferred access path. Existing third-party code
accessing it directly should no longer do so; consequently, it's been
renamed to ri_RootToChildMap, which also makes it consistent with
ri_ChildToRootMap.
ExecGetRootToChildMap() houses the logic of setting the map appropriately
depending on whether a given child relation is partition or not.
To support this, also add a separate entry point for TupleConversionMap
creation that receives an AttrMap. No new code here, just split an
existing function in two.
Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CA+HiwqEYUhDXSK5BTvG_xk=eaAEJCD4GS3C6uH7ybBvv+Z_Tmg@mail.gmail.com
Diffstat (limited to 'src/include/nodes/execnodes.h')
-rw-r--r-- | src/include/nodes/execnodes.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index a2008846c63..71248a94660 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -539,6 +539,21 @@ typedef struct ResultRelInfo ExprState *ri_PartitionCheckExpr; /* + * Map to convert child result relation tuples to the format of the table + * actually mentioned in the query (called "root"). Computed only if + * needed. A NULL map value indicates that no conversion is needed, so we + * must have a separate flag to show if the map has been computed. + */ + TupleConversionMap *ri_ChildToRootMap; + bool ri_ChildToRootMapValid; + + /* + * As above, but in the other direction. + */ + TupleConversionMap *ri_RootToChildMap; + bool ri_RootToChildMapValid; + + /* * Information needed by tuple routing target relations * * RootResultRelInfo gives the target relation mentioned in the query, if @@ -546,23 +561,12 @@ typedef struct ResultRelInfo * mentioned in the query is an inherited table, nor when tuple routing is * not needed. * - * RootToPartitionMap and PartitionTupleSlot, initialized by - * ExecInitRoutingInfo, are non-NULL if partition has a different tuple - * format than the root table. + * PartitionTupleSlot is non-NULL if RootToChild conversion is needed and + * the relation is a partition. */ struct ResultRelInfo *ri_RootResultRelInfo; - TupleConversionMap *ri_RootToPartitionMap; TupleTableSlot *ri_PartitionTupleSlot; - /* - * Map to convert child result relation tuples to the format of the table - * actually mentioned in the query (called "root"). Computed only if - * needed. A NULL map value indicates that no conversion is needed, so we - * must have a separate flag to show if the map has been computed. - */ - TupleConversionMap *ri_ChildToRootMap; - bool ri_ChildToRootMapValid; - /* for use by copyfrom.c when performing multi-inserts */ struct CopyMultiInsertBuffer *ri_CopyMultiInsertBuffer; |