MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecSetupPartitionTupleRouting

Function ExecSetupPartitionTupleRouting

src/backend/executor/execPartition.c:218–244  ·  view source on GitHub ↗

* ExecSetupPartitionTupleRouting - sets up information needed during * tuple routing for partitioned tables, encapsulates it in * PartitionTupleRouting, and returns it. * * Callers must use the returned PartitionTupleRouting during calls to * ExecFindPartition(). The actual ResultRelInfo for a partition is only * allocated when the partition is found for the first time. * * The current me

Source from the content-addressed store, hash-verified

216 * it should be estate->es_query_cxt.
217 */
218PartitionTupleRouting *
219ExecSetupPartitionTupleRouting(EState *estate, Relation rel)
220{
221 PartitionTupleRouting *proute;
222
223 /*
224 * Here we attempt to expend as little effort as possible in setting up
225 * the PartitionTupleRouting. Each partition's ResultRelInfo is built on
226 * demand, only when we actually need to route a tuple to that partition.
227 * The reason for this is that a common case is for INSERT to insert a
228 * single tuple into a partitioned table and this must be fast.
229 */
230 proute = (PartitionTupleRouting *) palloc0(sizeof(PartitionTupleRouting));
231 proute->partition_root = rel;
232 proute->memcxt = CurrentMemoryContext;
233 /* Rest of members initialized by zeroing */
234
235 /*
236 * Initialize this table's PartitionDispatch object. Here we pass in the
237 * parent as NULL as we don't need to care about any parent of the target
238 * partitioned table.
239 */
240 ExecInitPartitionDispatchInfo(estate, proute, RelationGetRelid(rel),
241 NULL, 0, NULL);
242
243 return proute;
244}
245
246/*
247 * ExecFindPartition -- Return the ResultRelInfo for the leaf partition that

Callers 4

CopyFromFunction · 0.85
ExecCrossPartitionUpdateFunction · 0.85
ExecInitModifyTableFunction · 0.85

Calls 2

palloc0Function · 0.50

Tested by

no test coverage detected