PostgreSQL Source Code: src/include/executor/execPartition.h File Reference (original) (raw)
Go to the source code of this file.
Data Structures | |
---|---|
struct | PartitionedRelPruningData |
struct | PartitionPruningData |
struct | PartitionPruneState |
Typedefs | |
---|---|
typedef struct PartitionDispatchData * | PartitionDispatch |
typedef struct PartitionTupleRouting | PartitionTupleRouting |
typedef struct PartitionedRelPruningData | PartitionedRelPruningData |
typedef struct PartitionPruningData | PartitionPruningData |
typedef struct PartitionPruneState | PartitionPruneState |
Functions | |
---|---|
PartitionTupleRouting * | ExecSetupPartitionTupleRouting (EState *estate, Relation rel) |
ResultRelInfo * | ExecFindPartition (ModifyTableState *mtstate, ResultRelInfo *rootResultRelInfo, PartitionTupleRouting *proute, TupleTableSlot *slot, EState *estate) |
void | ExecCleanupTupleRouting (ModifyTableState *mtstate, PartitionTupleRouting *proute) |
void | ExecDoInitialPruning (EState *estate) |
PartitionPruneState * | ExecInitPartitionExecPruning (PlanState *planstate, int n_total_subplans, int part_prune_index, Bitmapset *relids, Bitmapset **initially_valid_subplans) |
Bitmapset * | ExecFindMatchingSubPlans (PartitionPruneState *prunestate, bool initial_prune, Bitmapset **validsubplan_rtis) |
◆ PartitionDispatch
◆ PartitionedRelPruningData
◆ PartitionPruneState
◆ PartitionPruningData
◆ PartitionTupleRouting
◆ ExecCleanupTupleRouting()
Definition at line 1236 of file execPartition.c.
1238{
1239 int i;
1240
1241
1242
1243
1244
1245
1246
1247
1249 {
1251
1253
1256 }
1257
1259 {
1261
1262
1266 resultRelInfo);
1267
1268
1269
1270
1271
1273 continue;
1274
1277 }
1278}
void ExecCloseIndices(ResultRelInfo *resultRelInfo)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
EndForeignInsert_function EndForeignInsert
PartitionDispatch * partition_dispatch_info
ResultRelInfo ** partitions
struct FdwRoutine * ri_FdwRoutine
void table_close(Relation relation, LOCKMODE lockmode)
References FdwRoutine::EndForeignInsert, ExecCloseIndices(), ExecDropSingleTupleTableSlot(), i, PartitionTupleRouting::is_borrowed_rel, NoLock, PartitionTupleRouting::num_dispatch, PartitionTupleRouting::num_partitions, PartitionTupleRouting::partition_dispatch_info, PartitionTupleRouting::partitions, ModifyTableState::ps, PartitionDispatchData::reldesc, ResultRelInfo::ri_FdwRoutine, ResultRelInfo::ri_RelationDesc, PlanState::state, table_close(), and PartitionDispatchData::tupslot.
Referenced by CopyFrom(), ExecEndModifyTable(), and finish_edata().
◆ ExecDoInitialPruning()
void ExecDoInitialPruning | ( | EState * | estate | ) |
---|
Definition at line 1819 of file execPartition.c.
1820{
1822
1824 {
1827 Bitmapset *validsubplans = NULL;
1828 Bitmapset *all_leafpart_rtis = NULL;
1829 Bitmapset *validsubplan_rtis = NULL;
1830
1831
1833 &all_leafpart_rtis);
1835 prunestate);
1836
1837
1838
1839
1840
1843 &validsubplan_rtis);
1844 else
1845 validsubplan_rtis = all_leafpart_rtis;
1846
1848 validsubplan_rtis);
1850 validsubplans);
1851 }
1852}
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * ExecFindMatchingSubPlans(PartitionPruneState *prunestate, bool initial_prune, Bitmapset **validsubplan_rtis)
static PartitionPruneState * CreatePartitionPruneState(EState *estate, PartitionPruneInfo *pruneinfo, Bitmapset **all_leafpart_rtis)
List * lappend(List *list, void *datum)
#define lfirst_node(type, lc)
List * es_part_prune_infos
Bitmapset * es_unpruned_relids
List * es_part_prune_states
List * es_part_prune_results
References bms_add_members(), CreatePartitionPruneState(), PartitionPruneState::do_initial_prune, EState::es_part_prune_infos, EState::es_part_prune_results, EState::es_part_prune_states, EState::es_unpruned_relids, ExecFindMatchingSubPlans(), lappend(), and lfirst_node.
Referenced by InitPlan().
◆ ExecFindMatchingSubPlans()
Definition at line 2493 of file execPartition.c.
2496{
2499 int i;
2500
2501
2502
2503
2504
2505
2507 Assert(validsubplan_rtis != NULL || !initial_prune);
2508
2509
2510
2511
2512
2514
2515
2516
2517
2518
2520 {
2523
2524
2525
2526
2527
2528
2531 &result, validsubplan_rtis);
2532
2533
2534
2535
2536
2537
2540 }
2541
2542
2544
2546
2547
2549 if (validsubplan_rtis)
2550 *validsubplan_rtis = bms_copy(*validsubplan_rtis);
2551
2553
2554 return result;
2555}
Bitmapset * bms_copy(const Bitmapset *a)
static void find_matching_subplans_recurse(PartitionPruningData *prunedata, PartitionedRelPruningData *pprune, bool initial_prune, Bitmapset **validsubplans, Bitmapset **validsubplan_rtis)
#define ResetExprContext(econtext)
Assert(PointerIsAligned(start, uint64))
void MemoryContextReset(MemoryContext context)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
ExprContext * exprcontext
PartitionPruningData * partprunedata[FLEXIBLE_ARRAY_MEMBER]
Bitmapset * other_subplans
MemoryContext prune_context
PartitionedRelPruningData partrelprunedata[FLEXIBLE_ARRAY_MEMBER]
List * exec_pruning_steps
PartitionPruneContext exec_context
References Assert(), bms_add_members(), bms_copy(), PartitionPruneState::do_exec_prune, PartitionedRelPruningData::exec_context, PartitionedRelPruningData::exec_pruning_steps, PartitionPruneContext::exprcontext, find_matching_subplans_recurse(), i, MemoryContextReset(), MemoryContextSwitchTo(), PartitionPruneState::num_partprunedata, PartitionPruneState::other_subplans, PartitionPruneState::partprunedata, PartitionPruningData::partrelprunedata, PartitionPruneState::prune_context, and ResetExprContext.
Referenced by choose_next_subplan_for_leader(), choose_next_subplan_for_worker(), choose_next_subplan_locally(), ExecAppendAsyncBegin(), ExecDoInitialPruning(), and ExecMergeAppend().
◆ ExecFindPartition()
Definition at line 265 of file execPartition.c.
269{
282
283
285
286
287
288
289
292
293
294 dispatch = pd[0];
295 while (dispatch != NULL)
296 {
297 int partidx = -1;
298 bool is_leaf;
299
301
303 partdesc = dispatch->partdesc;
304
305
306
307
308
309
310
311
312
315
316
317
318
319
320 if (partdesc->nparts == 0 ||
322 {
323 char *val_desc;
324
329 (errcode(ERRCODE_CHECK_VIOLATION),
330 errmsg("no partition of relation \"%s\" found for row",
332 val_desc ?
333 errdetail("Partition key of the failing row contains %s.",
334 val_desc) : 0,
336 }
337
338 is_leaf = partdesc->is_leaf[partidx];
339 if (is_leaf)
340 {
341
342
343
344
346 {
347
350 }
351 else
352 {
353
354
355
356
357
359 partdesc->oids[partidx],
360 true, false);
361 if (rri)
362 {
363
365
366
367
368
369
371 rri, partidx, true);
372 }
373 else
374 {
375
377 dispatch,
378 rootResultRelInfo, partidx);
379 }
380 }
382
383
384 dispatch = NULL;
385 }
386 else
387 {
388
389
390
392 {
393
395
397
398
399
400
401
402 dispatch = pd[dispatch->indexes[partidx]];
403 }
404 else
405 {
406
408
409
410
411
412
414 proute,
415 partdesc->oids[partidx],
416 dispatch, partidx,
420
422 dispatch = subdispatch;
423 }
424
425
426
427
428
430 {
433
434 myslot = dispatch->tupslot;
436
437 if (tempslot != NULL)
439 }
440 }
441
442
443
444
445
446
447
448
449
451 {
452
453
454
455
456
457
458
459
460
461
462
463
464 if (is_leaf)
465 {
467
468 if (map)
471 else
472 slot = rootslot;
473 }
474
476 }
477 }
478
479
480 if (myslot != NULL)
482
485
486 return rri;
487}
static Datum values[MAXATTR]
#define OidIsValid(objectId)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, List *mergeActions)
bool ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
static PartitionDispatch ExecInitPartitionDispatchInfo(EState *estate, PartitionTupleRouting *proute, Oid partoid, PartitionDispatch parent_pd, int partidx, ResultRelInfo *rootResultRelInfo)
static ResultRelInfo * ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, PartitionTupleRouting *proute, PartitionDispatch dispatch, ResultRelInfo *rootResultRelInfo, int partidx)
static void ExecInitRoutingInfo(ModifyTableState *mtstate, EState *estate, PartitionTupleRouting *proute, PartitionDispatch dispatch, ResultRelInfo *partRelInfo, int partidx, bool is_borrowed_rel)
static char * ExecBuildSlotPartitionKeyDescription(Relation rel, Datum *values, bool *isnull, int maxfieldlen)
static void FormPartitionKeyDatum(PartitionDispatch pd, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
static int get_partition_for_tuple(PartitionDispatch pd, Datum *values, bool *isnull)
TupleConversionMap * ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate)
#define GetPerTupleExprContext(estate)
#define GetPerTupleMemoryContext(estate)
#define CHECK_FOR_INTERRUPTS()
ResultRelInfo * ExecLookupResultRelByOid(ModifyTableState *node, Oid resultoid, bool missing_ok, bool update_cache)
#define PARTITION_MAX_KEYS
#define RelationGetRelid(relation)
#define RelationGetRelationName(relation)
int errtable(Relation rel)
TupleTableSlot * ecxt_scantuple
ResultRelInfo * rootResultRelInfo
PartitionBoundInfo boundinfo
int indexes[FLEXIBLE_ARRAY_MEMBER]
ResultRelInfo ** nonleaf_partitions
TupleTableSlot * ri_PartitionTupleSlot
TupleTableSlot * execute_attr_map_slot(AttrMap *attrMap, TupleTableSlot *in_slot, TupleTableSlot *out_slot)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
References Assert(), TupleConversionMap::attrMap, PartitionDescData::boundinfo, CHECK_FOR_INTERRUPTS, CheckValidResultRel(), CMD_INSERT, PartitionBoundInfoData::default_index, ExprContext::ecxt_scantuple, ereport, errcode(), errdetail(), errmsg(), ERROR, errtable(), ExecBuildSlotPartitionKeyDescription(), ExecClearTuple(), ExecGetRootToChildMap(), ExecInitPartitionDispatchInfo(), ExecInitPartitionInfo(), ExecInitRoutingInfo(), ExecLookupResultRelByOid(), ExecPartitionCheck(), execute_attr_map_slot(), FormPartitionKeyDatum(), get_partition_for_tuple(), GetPerTupleExprContext, GetPerTupleMemoryContext, PartitionDispatchData::indexes, PartitionDescData::is_leaf, likely, MemoryContextSwitchTo(), NIL, PartitionTupleRouting::nonleaf_partitions, PartitionDescData::nparts, PartitionTupleRouting::num_dispatch, PartitionTupleRouting::num_partitions, OidIsValid, PartitionDescData::oids, PartitionDispatchData::partdesc, PartitionTupleRouting::partition_dispatch_info, PARTITION_MAX_KEYS, PartitionTupleRouting::partitions, RelationData::rd_rel, RelationGetRelationName, RelationGetRelid, PartitionDispatchData::reldesc, ResultRelInfo::ri_PartitionTupleSlot, ResultRelInfo::ri_RelationDesc, ModifyTableState::rootResultRelInfo, PartitionDispatchData::tupmap, PartitionDispatchData::tupslot, and values.
Referenced by apply_handle_tuple_routing(), CopyFrom(), and ExecPrepareTupleRouting().
◆ ExecInitPartitionExecPruning()
Definition at line 1875 of file execPartition.c.
1880{
1884
1885
1887 part_prune_index);
1888
1889
1891 elog(ERROR, "wrong pruneinfo with relids=%s found at part_prune_index=%d contained in plan node with relids=%s",
1894
1895
1896
1897
1898
1899
1901 Assert(prunestate != NULL);
1902
1903
1907 part_prune_index);
1908 else
1909 {
1910
1911 Assert(n_total_subplans > 0);
1912 *initially_valid_subplans = bms_add_range(NULL, 0,
1913 n_total_subplans - 1);
1914 }
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1930 *initially_valid_subplans,
1931 n_total_subplans);
1932
1933 return prunestate;
1934}
bool bms_equal(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_add_range(Bitmapset *a, int lower, int upper)
static void InitExecPartitionPruneContexts(PartitionPruneState *prunestate, PlanState *parent_plan, Bitmapset *initially_valid_subplans, int n_total_subplans)
char * bmsToString(const Bitmapset *bms)
static void * list_nth(const List *list, int n)
#define list_nth_node(type, list, n)
References Assert(), bms_add_range(), bms_equal(), bmsToString(), PartitionPruneState::do_exec_prune, PartitionPruneState::do_initial_prune, elog, ERROR, EState::es_part_prune_infos, EState::es_part_prune_results, EState::es_part_prune_states, InitExecPartitionPruneContexts(), list_nth(), list_nth_node, PartitionPruneInfo::relids, and PlanState::state.
Referenced by ExecInitAppend(), and ExecInitMergeAppend().
◆ ExecSetupPartitionTupleRouting()
Definition at line 218 of file execPartition.c.
219{
221
222
223
224
225
226
227
228
232
233
234
235
236
237
238
240 NULL, 0, NULL);
241
242 return proute;
243}
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
References CurrentMemoryContext, ExecInitPartitionDispatchInfo(), PartitionTupleRouting::memcxt, palloc0(), PartitionTupleRouting::partition_root, and RelationGetRelid.
Referenced by apply_handle_tuple_routing(), CopyFrom(), ExecCrossPartitionUpdate(), ExecInitMerge(), and ExecInitModifyTable().