PostgreSQL Source Code: src/backend/executor/execPartition.c File Reference (original) (raw)
Go to the source code of this file.
◆ PARTITION_CACHED_FIND_THRESHOLD
#define PARTITION_CACHED_FIND_THRESHOLD 16
◆ PartitionDispatchData
◆ adjust_partition_colnos()
◆ adjust_partition_colnos_using_map()
static List * adjust_partition_colnos_using_map ( List * colnos, AttrMap * attrMap ) | static |
---|
Definition at line 1720 of file execPartition.c.
1721{
1724
1725 Assert(attrMap != NULL);
1726
1727 foreach(lc, colnos)
1728 {
1730
1731 if (parentattrno <= 0 ||
1732 parentattrno > attrMap->maplen ||
1733 attrMap->attnums[parentattrno - 1] == 0)
1734 elog(ERROR, "unexpected attno %d in target column list",
1735 parentattrno);
1737 attrMap->attnums[parentattrno - 1]);
1738 }
1739
1740 return new_colnos;
1741}
List * lappend_int(List *list, int datum)
References Assert(), AttrMap::attnums, elog, ERROR, lappend_int(), lfirst_int, AttrMap::maplen, and NIL.
Referenced by adjust_partition_colnos(), and ExecInitPartitionInfo().
◆ CreatePartitionPruneState()
Definition at line 2031 of file execPartition.c.
2033{
2035 int n_part_hierarchies;
2037 int i;
2038
2039
2040
2041
2042
2044
2045
2049
2051 Assert(n_part_hierarchies > 0);
2052
2053
2054
2055
2059
2060
2061 prunestate->econtext = econtext;
2063
2065 prunestate->do_initial_prune = false;
2066 prunestate->do_exec_prune = false;
2068
2069
2070
2071
2072
2073
2074
2077 "Partition Prune",
2079
2080 i = 0;
2082 {
2084 int npartrelpruneinfos = list_length(partrelpruneinfos);
2087 int j;
2088
2094
2095 j = 0;
2096 foreach(lc2, partrelpruneinfos)
2097 {
2103
2104
2105
2106
2107
2108
2109
2111
2112
2113 pprune->partrel = partrel;
2114
2117 partrel);
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2139
2141 memcmp(partdesc->oids, pinfo->relid_map,
2142 sizeof(int) * partdesc->nparts) == 0)
2143 {
2144 pprune->subpart_map = pinfo->subpart_map;
2146 memcpy(pprune->subplan_map, pinfo->subplan_map,
2147 sizeof(int) * pinfo->nparts);
2148 }
2149 else
2150 {
2151 int pd_idx = 0;
2152 int pp_idx;
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2167
2168 for (pp_idx = 0; pp_idx < partdesc->nparts; pp_idx++)
2169 {
2170
2171 while (pd_idx < pinfo->nparts &&
2172 (pinfo->relid_map[pd_idx]))
2173 pd_idx++;
2174
2175 recheck:
2176 if (pd_idx < pinfo->nparts &&
2177 pinfo->relid_map[pd_idx] == partdesc->oids[pp_idx])
2178 {
2179
2181 pinfo->subplan_map[pd_idx];
2183 pinfo->subpart_map[pd_idx];
2185 pinfo->leafpart_rti_map[pd_idx];
2186 pd_idx++;
2187 continue;
2188 }
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210 for (int pd_idx2 = pd_idx + 1; pd_idx2 < pinfo->nparts; pd_idx2++)
2211 {
2212 if (pd_idx2 >= pinfo->nparts)
2213 break;
2214 if (pinfo->relid_map[pd_idx2] == partdesc->oids[pp_idx])
2215 {
2216 pd_idx = pd_idx2;
2217 goto recheck;
2218 }
2219 }
2220
2224 }
2225 }
2226
2227
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2242 {
2245 partdesc, partkey, NULL,
2246 econtext);
2247
2249 }
2253 {
2254
2256 }
2257
2258
2259
2260
2261
2264
2265
2266
2267
2268
2270 {
2271 int part_index = -1;
2272
2274 part_index)) >= 0)
2275 {
2277
2278 if (rtindex)
2279 *all_leafpart_rtis = bms_add_member(*all_leafpart_rtis,
2280 rtindex);
2281 }
2282 }
2283
2284 j++;
2285 }
2286 i++;
2287 }
2288
2289 return prunestate;
2290}
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
#define OidIsValid(objectId)
static void InitPartitionPruneContext(PartitionPruneContext *context, List *pruning_steps, PartitionDesc partdesc, PartitionKey partkey, PlanState *planstate, ExprContext *econtext)
struct PartitionedRelPruningData PartitionedRelPruningData
Relation ExecGetRangeTableRelation(EState *estate, Index rti, bool isResultRel)
ExprContext * CreateExprContext(EState *estate)
#define EXEC_FLAG_EXPLAIN_GENERIC
MemoryContext CurrentMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
PartitionKey RelationGetPartitionKey(Relation rel)
PartitionDirectory CreatePartitionDirectory(MemoryContext mcxt, bool omit_detached)
PartitionDesc PartitionDirectoryLookup(PartitionDirectory pdir, Relation rel)
#define lfirst_node(type, lc)
static int list_length(const List *l)
MemoryContext es_query_cxt
PartitionDirectory es_partition_directory
struct EState * ecxt_estate
Bitmapset * other_subplans
PartitionPruningData * partprunedata[FLEXIBLE_ARRAY_MEMBER]
Bitmapset * other_subplans
MemoryContext prune_context
PartitionedRelPruningData partrelprunedata[FLEXIBLE_ARRAY_MEMBER]
Bitmapset * present_parts
List * initial_pruning_steps
List * exec_pruning_steps
List * exec_pruning_steps
PartitionPruneContext initial_context
Bitmapset * present_parts
List * initial_pruning_steps
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), bms_add_member(), bms_add_members(), bms_copy(), bms_next_member(), CreateExprContext(), CreatePartitionDirectory(), CurrentMemoryContext, PartitionPruneState::do_exec_prune, PartitionPruneState::do_initial_prune, PartitionPruneState::econtext, ExprContext::ecxt_estate, EState::es_partition_directory, EState::es_query_cxt, EState::es_top_eflags, EXEC_FLAG_EXPLAIN_GENERIC, PartitionedRelPruningData::exec_pruning_steps, PartitionedRelPruneInfo::exec_pruning_steps, ExecGetRangeTableRelation(), PartitionPruneState::execparamids, PartitionedRelPruneInfo::execparamids, i, PartitionedRelPruningData::initial_context, PartitionedRelPruningData::initial_pruning_steps, PartitionedRelPruneInfo::initial_pruning_steps, InitPartitionPruneContext(), j, PartitionedRelPruningData::leafpart_rti_map, lfirst_node, list_length(), PartitionedRelPruningData::nparts, PartitionedRelPruneInfo::nparts, PartitionDescData::nparts, PartitionPruneState::num_partprunedata, PartitionPruningData::num_partrelprunedata, OidIsValid, PartitionDescData::oids, PartitionPruneState::other_subplans, PartitionPruneInfo::other_subplans, palloc(), PartitionDirectoryLookup(), PartitionPruneState::partprunedata, PartitionedRelPruningData::partrel, PartitionPruningData::partrelprunedata, PartitionedRelPruningData::present_parts, PartitionedRelPruneInfo::present_parts, PartitionPruneState::prune_context, PartitionPruneInfo::prune_infos, RelationGetPartitionKey(), PartitionedRelPruneInfo::rtindex, PartitionedRelPruningData::subpart_map, and PartitionedRelPruningData::subplan_map.
Referenced by ExecDoInitialPruning().
◆ ExecBuildSlotPartitionKeyDescription()
static char * ExecBuildSlotPartitionKeyDescription ( Relation rel, Datum * values, bool * isnull, int maxfieldlen ) | static |
---|
Definition at line 1615 of file execPartition.c.
1619{
1623 int i;
1626
1628 return NULL;
1629
1630
1633 {
1634
1635
1636
1637
1638 for (i = 0; i < partnatts; i++)
1639 {
1641
1642
1643
1644
1645
1646
1650 return NULL;
1651 }
1652 }
1653
1657
1658 for (i = 0; i < partnatts; i++)
1659 {
1660 char *val;
1661 int vallen;
1662
1663 if (isnull[i])
1664 val = "null";
1665 else
1666 {
1667 Oid foutoid;
1668 bool typisvarlena;
1669
1671 &foutoid, &typisvarlena);
1673 }
1674
1675 if (i > 0)
1677
1678
1679 vallen = strlen(val);
1680 if (vallen <= maxfieldlen)
1682 else
1683 {
1687 }
1688 }
1689
1691
1692 return buf.data;
1693}
AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum, Oid roleid, AclMode mode)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
#define InvalidAttrNumber
static Datum values[MAXATTR]
char * OidOutputFunctionCall(Oid functionId, Datum val)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
int pg_mbcliplen(const char *mbstr, int len, int limit)
static int16 get_partition_col_attnum(PartitionKey key, int col)
static int get_partition_natts(PartitionKey key)
static Oid get_partition_col_typid(PartitionKey key, int col)
#define RelationGetRelid(relation)
int check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
char * pg_get_partkeydef_columns(Oid relid, bool pretty)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
References ACL_SELECT, ACLCHECK_OK, appendBinaryStringInfo(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), attnum, buf, check_enable_rls(), get_partition_col_attnum(), get_partition_col_typid(), get_partition_natts(), getTypeOutputInfo(), GetUserId(), i, initStringInfo(), InvalidAttrNumber, InvalidOid, sort-test::key, OidOutputFunctionCall(), pg_attribute_aclcheck(), pg_class_aclcheck(), pg_get_partkeydef_columns(), pg_mbcliplen(), RelationGetPartitionKey(), RelationGetRelid, RLS_ENABLED, val, and values.
Referenced by ExecFindPartition().
◆ ExecCleanupTupleRouting()
Definition at line 1237 of file execPartition.c.
1239{
1240 int i;
1241
1242
1243
1244
1245
1246
1247
1248
1250 {
1252
1254
1257 }
1258
1260 {
1262
1263
1267 resultRelInfo);
1268
1269
1270
1271
1272
1274 continue;
1275
1278 }
1279}
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 1822 of file execPartition.c.
1823{
1826 List *locked_relids = NIL;
1827
1829 {
1832 Bitmapset *validsubplans = NULL;
1833 Bitmapset *all_leafpart_rtis = NULL;
1834 Bitmapset *validsubplan_rtis = NULL;
1835
1836
1838 &all_leafpart_rtis);
1840 prunestate);
1841
1842
1843
1844
1845
1848 &validsubplan_rtis);
1849 else
1850 validsubplan_rtis = all_leafpart_rtis;
1851
1853 {
1854 int rtindex = -1;
1855
1857 rtindex)) >= 0)
1858 {
1860
1862 rte->rellockmode != NoLock);
1864 locked_relids = lappend_int(locked_relids, rtindex);
1865 }
1866 }
1868 validsubplan_rtis);
1870 validsubplans);
1871 }
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1885 {
1886 foreach(lc, stmt->firstResultRels)
1887 {
1889
1891 {
1893
1896 locked_relids = lappend_int(locked_relids, firstResultRel);
1897 }
1898 }
1899 }
1900
1901
1902
1903
1904
1906 {
1907 foreach(lc, locked_relids)
1908 {
1910
1912 }
1913 }
1914}
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * ExecFindMatchingSubPlans(PartitionPruneState *prunestate, bool initial_prune, Bitmapset **validsubplan_rtis)
static PartitionPruneState * CreatePartitionPruneState(EState *estate, PartitionPruneInfo *pruneinfo, Bitmapset **all_leafpart_rtis)
static bool ExecShouldLockRelations(EState *estate)
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
static bool ExecPlanStillValid(EState *estate)
List * lappend(List *list, void *datum)
void UnlockRelationOid(Oid relid, LOCKMODE lockmode)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
List * es_part_prune_infos
PlannedStmt * es_plannedstmt
Bitmapset * es_unpruned_relids
List * es_part_prune_states
List * es_part_prune_results
References Assert(), bms_add_members(), bms_is_member(), bms_next_member(), CreatePartitionPruneState(), PartitionPruneState::do_initial_prune, EState::es_part_prune_infos, EState::es_part_prune_results, EState::es_part_prune_states, EState::es_plannedstmt, EState::es_unpruned_relids, exec_rt_fetch(), ExecFindMatchingSubPlans(), ExecPlanStillValid(), ExecShouldLockRelations(), lappend(), lappend_int(), lfirst_int, lfirst_node, LockRelationOid(), NIL, NoLock, RTE_RELATION, RangeTblEntry::rtekind, stmt, and UnlockRelationOid().
Referenced by InitPlan().
◆ ExecFindMatchingSubPlans()
Definition at line 2555 of file execPartition.c.
2558{
2561 int i;
2562
2563
2564
2565
2566
2567
2569 Assert(validsubplan_rtis != NULL || !initial_prune);
2570
2571
2572
2573
2574
2576
2577
2578
2579
2580
2582 {
2585
2586
2587
2588
2589
2590
2593 &result, validsubplan_rtis);
2594
2595
2596
2597
2598
2599
2602 }
2603
2604
2606
2608
2609
2611 if (validsubplan_rtis)
2612 *validsubplan_rtis = bms_copy(*validsubplan_rtis);
2613
2615
2616 return result;
2617}
static void find_matching_subplans_recurse(PartitionPruningData *prunedata, PartitionedRelPruningData *pprune, bool initial_prune, Bitmapset **validsubplans, Bitmapset **validsubplan_rtis)
#define ResetExprContext(econtext)
void MemoryContextReset(MemoryContext context)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
ExprContext * exprcontext
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 266 of file execPartition.c.
270{
283
284
286
287
288
289
290
293
294
295 dispatch = pd[0];
296 while (dispatch != NULL)
297 {
298 int partidx = -1;
299 bool is_leaf;
300
302
304 partdesc = dispatch->partdesc;
305
306
307
308
309
310
311
312
313
316
317
318
319
320
321 if (partdesc->nparts == 0 ||
323 {
324 char *val_desc;
325
330 (errcode(ERRCODE_CHECK_VIOLATION),
331 errmsg("no partition of relation \"%s\" found for row",
333 val_desc ?
334 errdetail("Partition key of the failing row contains %s.",
335 val_desc) : 0,
337 }
338
339 is_leaf = partdesc->is_leaf[partidx];
340 if (is_leaf)
341 {
342
343
344
345
347 {
348
351 }
352 else
353 {
354
355
356
357
358
360 partdesc->oids[partidx],
361 true, false);
362 if (rri)
363 {
364
366
367
368
369
370
372 rri, partidx, true);
373 }
374 else
375 {
376
378 dispatch,
379 rootResultRelInfo, partidx);
380 }
381 }
383
384
385 dispatch = NULL;
386 }
387 else
388 {
389
390
391
393 {
394
396
398
399
400
401
402
403 dispatch = pd[dispatch->indexes[partidx]];
404 }
405 else
406 {
407
409
410
411
412
413
415 proute,
416 partdesc->oids[partidx],
417 dispatch, partidx,
421
423 dispatch = subdispatch;
424 }
425
426
427
428
429
431 {
434
435 myslot = dispatch->tupslot;
437
438 if (tempslot != NULL)
440 }
441 }
442
443
444
445
446
447
448
449
450
452 {
453
454
455
456
457
458
459
460
461
462
463
464
465 if (is_leaf)
466 {
468
469 if (map)
472 else
473 slot = rootslot;
474 }
475
477 }
478 }
479
480
481 if (myslot != NULL)
483
486
487 return rri;
488}
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 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().
◆ ExecInitPartitionDispatchInfo()
Definition at line 1098 of file execPartition.c.
1102{
1106 int dispatchidx;
1108
1109
1110
1111
1112
1113
1114
1115
1116
1121
1123
1124
1125
1126
1127
1128
1131 else
1134
1136 partdesc->nparts * sizeof(int));
1141 if (parent_pd != NULL)
1142 {
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1155 tupdesc,
1156 false);
1159 }
1160 else
1161 {
1162
1165 }
1166
1167
1168
1169
1170
1171 memset(pd->indexes, -1, sizeof(int) * partdesc->nparts);
1172
1173
1175
1176
1178 {
1180 {
1186 }
1187 else
1188 {
1196 }
1197 }
1199
1200
1201
1202
1203
1204
1205 if (parent_pd)
1206 {
1208
1211 }
1212 else
1214
1215
1216
1217
1218
1219 if (parent_pd)
1220 {
1222 parent_pd->indexes[partidx] = dispatchidx;
1223 }
1224
1226
1227 return pd;
1228}
AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, ResultRelInfo *partition_root_rri, int instrument_options)
struct PartitionDispatchData * PartitionDispatch
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
const TupleTableSlotOps TTSOpsVirtual
void * repalloc(void *pointer, Size size)
#define RelationGetDescr(relation)
Relation table_open(Oid relationId, LOCKMODE lockmode)
#define IsolationUsesXactSnapshot()
References Assert(), build_attrmap_by_name_if_req(), CreatePartitionDirectory(), EState::es_partition_directory, EState::es_query_cxt, PartitionDispatchData::indexes, InitResultRelInfo(), IsolationUsesXactSnapshot, PartitionDispatchData::key, PartitionDispatchData::keystate, makeNode, MakeSingleTupleTableSlot(), PartitionTupleRouting::max_dispatch, PartitionTupleRouting::memcxt, MemoryContextSwitchTo(), NIL, PartitionTupleRouting::nonleaf_partitions, PartitionDescData::nparts, PartitionTupleRouting::num_dispatch, palloc(), PartitionDispatchData::partdesc, PartitionTupleRouting::partition_dispatch_info, PartitionTupleRouting::partition_root, PartitionDirectoryLookup(), RelationGetDescr, RelationGetPartitionKey(), RelationGetRelid, PartitionDispatchData::reldesc, repalloc(), RowExclusiveLock, table_open(), TTSOpsVirtual, PartitionDispatchData::tupmap, and PartitionDispatchData::tupslot.
Referenced by ExecFindPartition(), and ExecSetupPartitionTupleRouting().
◆ ExecInitPartitionExecPruning()
Definition at line 1937 of file execPartition.c.
1942{
1946
1947
1949 part_prune_index);
1950
1951
1953 elog(ERROR, "wrong pruneinfo with relids=%s found at part_prune_index=%d contained in plan node with relids=%s",
1956
1957
1958
1959
1960
1961
1963 Assert(prunestate != NULL);
1964
1965
1969 part_prune_index);
1970 else
1971 {
1972
1973 Assert(n_total_subplans > 0);
1974 *initially_valid_subplans = bms_add_range(NULL, 0,
1975 n_total_subplans - 1);
1976 }
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1992 *initially_valid_subplans,
1993 n_total_subplans);
1994
1995 return prunestate;
1996}
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().
◆ ExecInitPartitionInfo()
Definition at line 499 of file execPartition.c.
504{
512 AttrMap *part_attmap = NULL;
513 bool found_whole_row;
514
516
518
521 partrel,
522 0,
523 rootResultRelInfo,
525
526
527
528
529
530
532
533
534
535
536
537
538
539 if (partrel->rd_rel->relhasindex &&
540 leaf_part_rri->ri_IndexRelationDescs == NULL)
542 (node != NULL &&
544
545
546
547
548
549
550
551
553 {
554 List *wcoList;
557
558
559
560
561
562
572
573
574
575
576
577
578
579
580
581
583
584
585
586
587 part_attmap =
590 false);
591 wcoList = (List *)
593 firstVarno, 0,
594 part_attmap,
596 &found_whole_row);
597
598
599 foreach(ll, wcoList)
600 {
603 &mtstate->ps);
604
605 wcoExprs = lappend(wcoExprs, wcoExpr);
606 }
607
608 leaf_part_rri->ri_WithCheckOptions = wcoList;
609 leaf_part_rri->ri_WithCheckOptionExprs = wcoExprs;
610 }
611
612
613
614
615
616
617
618
620 {
623 List *returningList;
624
625
635
636
637
638
639
640
641
643
644
645
646
647 if (part_attmap == NULL)
648 part_attmap =
651 false);
652 returningList = (List *)
654 firstVarno, 0,
655 part_attmap,
657 &found_whole_row);
658
659
660 leaf_part_rri->ri_returningList = returningList;
661
662
663
664
665
666
667
672 leaf_part_rri->ri_projectReturning =
675 }
676
677
679 leaf_part_rri, partidx, false);
680
681
682
683
685 {
689 List *arbiterIndexes = NIL;
690
691
692
693
694
695
696
698 {
699 List *childIdxs;
700
702
703 foreach(lc, childIdxs)
704 {
706 List *ancestors;
708
711 {
713 arbiterIndexes = lappend_oid(arbiterIndexes, childIdx);
714 }
716 }
717 }
718
719
720
721
722
723
726 elog(ERROR, "invalid arbiter index list");
727 leaf_part_rri->ri_onConflictArbiterIndexes = arbiterIndexes;
728
729
730
731
733 {
736
738
741
742 leaf_part_rri->ri_onConflict = onconfl;
743
744
745
746
747
748
752
753
754
755
756
757
758
759 if (map == NULL)
760 {
761
762
763
764
765
766
767
768
775 }
776 else
777 {
778 List *onconflset;
779 List *onconflcols;
780
781
782
783
784
785
786
787
789 if (part_attmap == NULL)
790 part_attmap =
793 false);
794 onconflset = (List *)
797 part_attmap,
799 &found_whole_row);
800
801 onconflset = (List *)
803 firstVarno, 0,
804 part_attmap,
806 &found_whole_row);
807
808
809
811 leaf_part_rri);
812
813
817
818
821 true,
822 onconflcols,
823 partrelDesc,
824 econtext,
826 &mtstate->ps);
827
828
829
830
831
832
833
835 {
836 List *clause;
837
839 clause = (List *)
842 part_attmap,
844 &found_whole_row);
845
846 clause = (List *)
848 firstVarno, 0,
849 part_attmap,
851 &found_whole_row);
852
855 }
856 }
857 }
858 }
859
860
861
862
863
864
865
866
867
871 leaf_part_rri);
872
873
874
875
876
877
878
879
880
881
883 {
887 Node *joinCondition;
888
889 if (part_attmap == NULL)
890 part_attmap =
893 false);
894
895 if (unlikely(!leaf_part_rri->ri_projectNewInfoValid))
897
898
899 joinCondition =
901 firstVarno, 0,
902 part_attmap,
904 &found_whole_row);
905
906 leaf_part_rri->ri_MergeJoinCondition =
908
909 foreach(lc, firstMergeActionList)
910 {
911
914
915
918
919
920 leaf_part_rri->ri_MergeActions[action->matchKind] =
921 lappend(leaf_part_rri->ri_MergeActions[action->matchKind],
922 action_state);
923
924 switch (action->commandType)
925 {
927
928
929
930
931
932
935 leaf_part_rri->ri_newTupleSlot,
936 &mtstate->ps,
938 break;
940
941
942
943
944
945 if (part_attmap)
946 action->updateColnos =
948 part_attmap);
951 true,
952 action->updateColnos,
954 econtext,
955 leaf_part_rri->ri_newTupleSlot,
956 NULL);
957 break;
960
961 break;
962
963 default:
964 elog(ERROR, "unknown action in MERGE WHEN clause");
965 }
966
967
970 firstVarno, 0,
971 part_attmap,
973 &found_whole_row);
976 }
977 }
979
980 return leaf_part_rri;
981}
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
ExprState * ExecInitQual(List *qual, PlanState *parent)
ProjectionInfo * ExecBuildUpdateProjection(List *targetList, bool evalTargetList, List *targetColnos, TupleDesc relDesc, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent)
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
static List * adjust_partition_colnos(List *colnos, ResultRelInfo *leaf_part_rri)
List * lappend_oid(List *list, Oid datum)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
void ExecInitMergeTupleSlots(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo)
#define castNode(_type_, nodeptr)
List * get_partition_ancestors(Oid relid)
#define RelationGetForm(relation)
List * RelationGetIndexList(Relation relation)
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
List * es_tuple_routing_result_relations
ProjectionInfo * mas_proj
ResultRelInfo * resultRelInfo
List * mergeJoinConditions
List * withCheckOptionLists
OnConflictAction onConflictAction
TupleTableSlot * oc_ProjSlot
TupleTableSlot * oc_Existing
ExprState * oc_WhereClause
ProjectionInfo * oc_ProjInfo
ExprContext * ps_ExprContext
TupleTableSlot * ps_ResultTupleSlot
OnConflictSetState * ri_onConflict
List * ri_onConflictArbiterIndexes
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
References generate_unaccent_rules::action, adjust_partition_colnos(), adjust_partition_colnos_using_map(), Assert(), build_attrmap_by_name(), castNode, CheckValidResultRel(), CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_NOTHING, CMD_UPDATE, copyObject, elog, ERROR, EState::es_instrument, EState::es_query_cxt, EState::es_tuple_routing_result_relations, EState::es_tupleTable, ExecBuildProjectionInfo(), ExecBuildUpdateProjection(), ExecGetRootToChildMap(), ExecInitMergeTupleSlots(), ExecInitQual(), ExecInitRoutingInfo(), ExecOpenIndices(), get_partition_ancestors(), InitResultRelInfo(), INNER_VAR, lappend(), lappend_oid(), lfirst, lfirst_node, lfirst_oid, linitial, list_free(), list_length(), list_member_oid(), makeNode, map_variable_attnos(), MergeActionState::mas_action, MergeActionState::mas_proj, MergeActionState::mas_whenqual, PartitionTupleRouting::memcxt, MemoryContextSwitchTo(), ModifyTable::mergeActionLists, ModifyTable::mergeJoinConditions, NIL, OnConflictSetState::oc_Existing, OnConflictSetState::oc_ProjInfo, OnConflictSetState::oc_ProjSlot, OnConflictSetState::oc_WhereClause, PartitionDescData::oids, ONCONFLICT_NONE, ONCONFLICT_UPDATE, ModifyTable::onConflictAction, ModifyTable::onConflictCols, ModifyTable::onConflictSet, ModifyTable::onConflictWhere, ModifyTable::operation, PartitionDispatchData::partdesc, PlanState::plan, ModifyTableState::ps, PlanState::ps_ExprContext, PlanState::ps_ResultTupleSlot, WithCheckOption::qual, RelationGetDescr, RelationGetForm, RelationGetIndexList(), ModifyTable::resultRelations, ModifyTableState::resultRelInfo, ModifyTable::returningLists, ResultRelInfo::ri_onConflict, ResultRelInfo::ri_onConflictArbiterIndexes, ResultRelInfo::ri_RangeTableIndex, ResultRelInfo::ri_RelationDesc, RowExclusiveLock, PlanState::state, table_open(), table_slot_create(), unlikely, and ModifyTable::withCheckOptionLists.
Referenced by ExecFindPartition().
◆ ExecInitRoutingInfo()
Definition at line 990 of file execPartition.c.
997{
999 int rri_index;
1000
1002
1003
1004
1005
1006
1007
1008
1009
1011 {
1013
1014
1015
1016
1017
1020 }
1021 else
1023
1024
1025
1026
1027
1031
1032
1033
1034
1035
1036
1037
1038
1044 else
1046
1048
1050
1051
1052
1053
1055
1057
1058
1060 {
1062 {
1068 }
1069 else
1070 {
1078 }
1079 }
1080
1081 proute->partitions[rri_index] = partRelInfo;
1083 dispatch->indexes[partidx] = rri_index;
1084
1086}
BeginForeignInsert_function BeginForeignInsert
ExecForeignBatchInsert_function ExecForeignBatchInsert
GetForeignModifyBatchSize_function GetForeignModifyBatchSize
struct CopyMultiInsertBuffer * ri_CopyMultiInsertBuffer
References Assert(), FdwRoutine::BeginForeignInsert, EState::es_tupleTable, FdwRoutine::ExecForeignBatchInsert, ExecGetRootToChildMap(), FdwRoutine::GetForeignModifyBatchSize, PartitionDispatchData::indexes, PartitionTupleRouting::is_borrowed_rel, PartitionTupleRouting::max_partitions, PartitionTupleRouting::memcxt, MemoryContextSwitchTo(), PartitionTupleRouting::num_partitions, palloc(), PartitionTupleRouting::partitions, repalloc(), ResultRelInfo::ri_BatchSize, ResultRelInfo::ri_CopyMultiInsertBuffer, ResultRelInfo::ri_FdwRoutine, ResultRelInfo::ri_PartitionTupleSlot, ResultRelInfo::ri_RelationDesc, and table_slot_create().
Referenced by ExecFindPartition(), and ExecInitPartitionInfo().
◆ ExecSetupPartitionTupleRouting()
Definition at line 219 of file execPartition.c.
220{
222
223
224
225
226
227
228
229
233
234
235
236
237
238
239
241 NULL, 0, NULL);
242
243 return proute;
244}
void * palloc0(Size size)
References CurrentMemoryContext, ExecInitPartitionDispatchInfo(), PartitionTupleRouting::memcxt, palloc0(), PartitionTupleRouting::partition_root, and RelationGetRelid.
Referenced by apply_handle_tuple_routing(), CopyFrom(), ExecCrossPartitionUpdate(), ExecInitMerge(), and ExecInitModifyTable().
◆ find_matching_subplans_recurse()
Definition at line 2628 of file execPartition.c.
2633{
2635 int i;
2636
2637
2639
2640
2641
2642
2643
2644
2651 else
2653
2654
2655 i = -1;
2657 {
2659 {
2662
2663
2664
2665
2666
2668 *validsubplan_rtis = bms_add_member(*validsubplan_rtis,
2670 }
2671 else
2672 {
2674
2675 if (partidx >= 0)
2678 initial_prune, validsubplans,
2679 validsubplan_rtis);
2680 else
2681 {
2682
2683
2684
2685
2686
2687
2688
2689 }
2690 }
2691 }
2692}
Bitmapset * get_matching_partitions(PartitionPruneContext *context, List *pruning_steps)
void check_stack_depth(void)
References bms_add_member(), bms_next_member(), check_stack_depth(), PartitionedRelPruningData::exec_context, PartitionedRelPruningData::exec_pruning_steps, find_matching_subplans_recurse(), get_matching_partitions(), i, PartitionedRelPruningData::initial_context, PartitionedRelPruningData::initial_pruning_steps, PartitionedRelPruningData::leafpart_rti_map, PartitionPruningData::partrelprunedata, PartitionedRelPruningData::present_parts, PartitionedRelPruningData::subpart_map, and PartitionedRelPruningData::subplan_map.
Referenced by ExecFindMatchingSubPlans(), and find_matching_subplans_recurse().
◆ FormPartitionKeyDatum()
Definition at line 1298 of file execPartition.c.
1303{
1305 int i;
1306
1308 {
1309
1310 Assert(estate != NULL &&
1312
1313
1315 }
1316
1319 {
1322 bool isNull;
1323
1324 if (keycol != 0)
1325 {
1326
1327 datum = slot_getattr(slot, keycol, &isNull);
1328 }
1329 else
1330 {
1331
1332 if (partexpr_item == NULL)
1333 elog(ERROR, "wrong number of partition key expressions");
1336 &isNull);
1337 partexpr_item = lnext(pd->keystate, partexpr_item);
1338 }
1340 isnull[i] = isNull;
1341 }
1342
1343 if (partexpr_item != NULL)
1344 elog(ERROR, "wrong number of partition key expressions");
1345}
List * ExecPrepareExprList(List *nodes, EState *estate)
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
References Assert(), elog, ERROR, ExecEvalExprSwitchContext(), ExecPrepareExprList(), GetPerTupleExprContext, i, PartitionDispatchData::key, PartitionDispatchData::keystate, lfirst, list_head(), lnext(), NIL, PartitionKeyData::partattrs, PartitionKeyData::partexprs, PartitionKeyData::partnatts, slot_getattr(), and values.
Referenced by ExecFindPartition().
◆ get_partition_for_tuple()
Definition at line 1395 of file execPartition.c.
1396{
1397 int bound_offset = -1;
1398 int part_index = -1;
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416 switch (key->strategy)
1417 {
1419 {
1421
1422
1424 key->partsupfunc,
1425 key->partcollation,
1427
1428
1429
1430
1431
1432 return boundinfo->indexes[rowHash % boundinfo->nindexes];
1433 }
1434
1436 if (isnull[0])
1437 {
1438
1440 {
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1452 }
1453 }
1454 else
1455 {
1457
1459 {
1461 Datum lastDatum = boundinfo->datums[last_datum_offset][0];
1463
1464
1466 key->partcollation[0],
1467 lastDatum,
1469
1470 if (cmpval == 0)
1471 return boundinfo->indexes[last_datum_offset];
1472
1473
1474 }
1475
1477 key->partcollation,
1478 boundinfo,
1480 if (bound_offset >= 0 && equal)
1481 part_index = boundinfo->indexes[bound_offset];
1482 }
1483 break;
1484
1486 {
1487 bool equal = false,
1488 range_partkey_has_null = false;
1489 int i;
1490
1491
1492
1493
1494
1495 for (i = 0; i < key->partnatts; i++)
1496 {
1497 if (isnull[i])
1498 {
1499 range_partkey_has_null = true;
1500 break;
1501 }
1502 }
1503
1504
1505 if (range_partkey_has_null)
1506 break;
1507
1509 {
1511 Datum *lastDatums = boundinfo->datums[last_datum_offset];
1514
1515
1517 key->partcollation,
1518 lastDatums,
1519 kind,
1521 key->partnatts);
1522
1523
1524
1525
1526
1527 if (cmpval == 0)
1528 return boundinfo->indexes[last_datum_offset + 1];
1529
1530 if (cmpval < 0 && last_datum_offset + 1 < boundinfo->ndatums)
1531 {
1532
1533 lastDatums = boundinfo->datums[last_datum_offset + 1];
1534 kind = boundinfo->kind[last_datum_offset + 1];
1536 key->partcollation,
1537 lastDatums,
1538 kind,
1540 key->partnatts);
1541
1542 if (cmpval > 0)
1543 return boundinfo->indexes[last_datum_offset + 1];
1544 }
1545
1546 }
1547
1549 key->partcollation,
1550 boundinfo,
1551 key->partnatts,
1554
1555
1556
1557
1558
1559
1560
1561 part_index = boundinfo->indexes[bound_offset + 1];
1562 }
1563 break;
1564
1565 default:
1566 elog(ERROR, "unexpected partition strategy: %d",
1567 (int) key->strategy);
1568 }
1569
1570
1571
1572
1573
1574 if (part_index < 0)
1575 {
1576
1577
1578
1579
1580
1582 }
1583
1584
1585 Assert(bound_offset >= 0);
1586
1587
1588
1589
1590
1591
1592
1593
1594
1597 else
1598 {
1602 }
1603
1604 return part_index;
1605}
bool equal(const void *a, const void *b)
#define PARTITION_CACHED_FIND_THRESHOLD
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
@ PARTITION_STRATEGY_HASH
@ PARTITION_STRATEGY_LIST
@ PARTITION_STRATEGY_RANGE
int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc, Oid *partcollation, Datum *rb_datums, PartitionRangeDatumKind *rb_kind, Datum *tuple_datums, int n_tuple_datums)
uint64 compute_partition_hash_value(int partnatts, FmgrInfo *partsupfunc, const Oid *partcollation, const Datum *values, const bool *isnull)
int partition_range_datum_bsearch(FmgrInfo *partsupfunc, Oid *partcollation, PartitionBoundInfo boundinfo, int nvalues, Datum *values, bool *is_equal)
int partition_list_bsearch(FmgrInfo *partsupfunc, Oid *partcollation, PartitionBoundInfo boundinfo, Datum value, bool *is_equal)
#define partition_bound_accepts_nulls(bi)
static int32 DatumGetInt32(Datum X)
PartitionRangeDatumKind ** kind
int last_found_datum_index
int last_found_part_index
References Assert(), PartitionDescData::boundinfo, compute_partition_hash_value(), DatumGetInt32(), PartitionBoundInfoData::datums, PartitionBoundInfoData::default_index, elog, equal(), ERROR, FunctionCall2Coll(), i, PartitionBoundInfoData::indexes, PartitionDispatchData::key, sort-test::key, PartitionBoundInfoData::kind, PartitionDescData::last_found_count, PartitionDescData::last_found_datum_index, PartitionDescData::last_found_part_index, PartitionBoundInfoData::ndatums, PartitionBoundInfoData::nindexes, PartitionBoundInfoData::null_index, PartitionDispatchData::partdesc, partition_bound_accepts_nulls, PARTITION_CACHED_FIND_THRESHOLD, partition_list_bsearch(), partition_range_datum_bsearch(), partition_rbound_datum_cmp(), PARTITION_STRATEGY_HASH, PARTITION_STRATEGY_LIST, PARTITION_STRATEGY_RANGE, and values.
Referenced by ExecFindPartition().
◆ InitExecPartitionPruneContexts()
Definition at line 2398 of file execPartition.c.
2402{
2404 int *new_subplan_indexes = NULL;
2406 int i;
2407 int newidx;
2408 bool fix_subplan_map = false;
2409
2411 Assert(parent_plan != NULL);
2412 estate = parent_plan->state;
2413
2414
2415
2416
2417
2418 if (bms_num_members(initially_valid_subplans) < n_total_subplans)
2419 {
2420 fix_subplan_map = true;
2421
2422
2423
2424
2425
2426
2427 new_subplan_indexes = (int *) palloc0(sizeof(int) * n_total_subplans);
2428 newidx = 1;
2429 i = -1;
2431 {
2432 Assert(i < n_total_subplans);
2433 new_subplan_indexes[i] = newidx++;
2434 }
2435 }
2436
2437
2438
2439
2440
2442 {
2444 int j;
2445
2446
2447
2448
2449
2450
2451
2452
2454 {
2456 int nparts = pprune->nparts;
2457 int k;
2458
2459
2461 {
2464
2465
2466
2467
2468
2472
2475 partdesc, partkey, parent_plan,
2477 }
2478
2479 if (!fix_subplan_map)
2480 continue;
2481
2482
2485
2486 for (k = 0; k < nparts; k++)
2487 {
2489 int subidx;
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499 if (oldidx >= 0)
2500 {
2501 Assert(oldidx < n_total_subplans);
2502 pprune->subplan_map[k] = new_subplan_indexes[oldidx] - 1;
2503
2504 if (new_subplan_indexes[oldidx] > 0)
2507 }
2508 else if ((subidx = pprune->subpart_map[k]) >= 0)
2509 {
2511
2513
2517 }
2518 }
2519 }
2520 }
2521
2522
2523
2524
2525
2526 if (fix_subplan_map)
2527 {
2528 new_other_subplans = NULL;
2529 i = -1;
2531 new_other_subplans = bms_add_member(new_other_subplans,
2532 new_subplan_indexes[i] - 1);
2533
2536
2537 pfree(new_subplan_indexes);
2538 }
2539}
void bms_free(Bitmapset *a)
int bms_num_members(const Bitmapset *a)
void pfree(void *pointer)
References Assert(), bms_add_member(), bms_free(), bms_is_empty, bms_next_member(), bms_num_members(), PartitionPruneState::do_exec_prune, PartitionPruneState::econtext, EState::es_partition_directory, PartitionedRelPruningData::exec_context, PartitionedRelPruningData::exec_pruning_steps, i, InitPartitionPruneContext(), j, NIL, PartitionedRelPruningData::nparts, PartitionPruneState::num_partprunedata, PartitionPruningData::num_partrelprunedata, PartitionPruneState::other_subplans, palloc0(), PartitionDirectoryLookup(), PartitionPruneState::partprunedata, PartitionedRelPruningData::partrel, PartitionPruningData::partrelprunedata, pfree(), PartitionedRelPruningData::present_parts, RelationGetPartitionKey(), PlanState::state, PartitionedRelPruningData::subpart_map, and PartitionedRelPruningData::subplan_map.
Referenced by ExecInitPartitionExecPruning().
◆ InitPartitionPruneContext()
Definition at line 2296 of file execPartition.c.
2302{
2303 int n_steps;
2304 int partnatts;
2306
2308
2315
2316
2319
2323
2324
2327 foreach(lc, pruning_steps)
2328 {
2331 int keyno;
2332
2333
2335 continue;
2336
2338
2339 for (keyno = 0; keyno < partnatts; keyno++)
2340 {
2342 continue;
2343
2344 if (lc2 != NULL)
2345 {
2347
2348
2350 {
2353 keyno);
2354
2355
2356
2357
2358
2359
2360
2361
2362 if (planstate == NULL)
2366 else
2369 }
2371 }
2372 }
2373 }
2374}
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
ExprState * ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
#define IsA(nodeptr, _type_)
#define PruneCxtStateIdx(partnatts, step_id, keyno)
ParamListInfo ecxt_param_list_info
PartitionStrategy strategy
PartitionBoundInfo boundinfo
References Assert(), bms_is_member(), PartitionDescData::boundinfo, PartitionPruneContext::boundinfo, CurrentMemoryContext, ExprContext::ecxt_param_list_info, ExecInitExpr(), ExecInitExprWithParams(), PartitionPruneContext::exprcontext, PartitionPruneStepOp::exprs, PartitionPruneContext::exprstates, IsA, lfirst, list_head(), list_length(), lnext(), PartitionDescData::nparts, PartitionPruneContext::nparts, PartitionPruneStepOp::nullkeys, palloc0(), PartitionPruneContext::partcollation, PartitionKeyData::partcollation, PartitionPruneContext::partnatts, PartitionKeyData::partnatts, PartitionPruneContext::partsupfunc, PartitionKeyData::partsupfunc, PartitionPruneContext::planstate, PartitionPruneContext::ppccontext, PruneCxtStateIdx, PartitionPruneStepOp::step, PartitionPruneStep::step_id, PartitionPruneContext::stepcmpfuncs, PartitionPruneContext::strategy, and PartitionKeyData::strategy.
Referenced by CreatePartitionPruneState(), and InitExecPartitionPruneContexts().