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

Function ExecCreatePartitionPruneState

src/backend/executor/execPartition.c:1764–1973  ·  view source on GitHub ↗

* ExecCreatePartitionPruneState * Build the data structure required for calling * ExecFindInitialMatchingSubPlans and ExecFindMatchingSubPlans. * * 'planstate' is the parent plan node's execution state. * * 'partitionpruneinfo' is a PartitionPruneInfo as generated by * make_partition_pruneinfo. Here we build a PartitionPruneState containing a * PartitionPruningData for each partitioning

Source from the content-addressed store, hash-verified

1762 * provided in each PartitionedRelPruneInfo.
1763 */
1764PartitionPruneState *
1765ExecCreatePartitionPruneState(PlanState *planstate,
1766 PartitionPruneInfo *partitionpruneinfo)
1767{
1768 EState *estate = planstate->state;
1769 PartitionPruneState *prunestate;
1770 int n_part_hierarchies;
1771 ListCell *lc;
1772 int i;
1773
1774 /* For data reading, executor always omits detached partitions */
1775 if (estate->es_partition_directory == NULL)
1776 estate->es_partition_directory =
1777 CreatePartitionDirectory(estate->es_query_cxt, false);
1778
1779 n_part_hierarchies = list_length(partitionpruneinfo->prune_infos);
1780 Assert(n_part_hierarchies > 0);
1781
1782 /*
1783 * Allocate the data structure
1784 */
1785 prunestate = (PartitionPruneState *)
1786 palloc(offsetof(PartitionPruneState, partprunedata) +
1787 sizeof(PartitionPruningData *) * n_part_hierarchies);
1788
1789 prunestate->execparamids = NULL;
1790 /* other_subplans can change at runtime, so we need our own copy */
1791 prunestate->other_subplans = bms_copy(partitionpruneinfo->other_subplans);
1792 prunestate->do_initial_prune = false; /* may be set below */
1793 prunestate->do_exec_prune = false; /* may be set below */
1794 prunestate->num_partprunedata = n_part_hierarchies;
1795
1796 /*
1797 * Create a short-term memory context which we'll use when making calls to
1798 * the partition pruning functions. This avoids possible memory leaks,
1799 * since the pruning functions call comparison functions that aren't under
1800 * our control.
1801 */
1802 prunestate->prune_context =
1803 AllocSetContextCreate(CurrentMemoryContext,
1804 "Partition Prune",
1805 ALLOCSET_DEFAULT_SIZES);
1806
1807 i = 0;
1808 foreach(lc, partitionpruneinfo->prune_infos)
1809 {
1810 List *partrelpruneinfos = lfirst_node(List, lc);
1811 int npartrelpruneinfos = list_length(partrelpruneinfos);
1812 PartitionPruningData *prunedata;
1813 ListCell *lc2;
1814 int j;
1815
1816 prunedata = (PartitionPruningData *)
1817 palloc(offsetof(PartitionPruningData, partrelprunedata) +
1818 npartrelpruneinfos * sizeof(PartitionedRelPruningData));
1819 prunestate->partprunedata[i] = prunedata;
1820 prunedata->num_partrelprunedata = npartrelpruneinfos;
1821

Callers 3

ExecInitMergeAppendFunction · 0.85
ExecInitAppendFunction · 0.85

Calls 10

CreatePartitionDirectoryFunction · 0.85
list_lengthFunction · 0.85
bms_copyFunction · 0.85
RelationGetPartitionKeyFunction · 0.85
PartitionDirectoryLookupFunction · 0.85
ExecInitPruningContextFunction · 0.85
bms_add_membersFunction · 0.85
pallocFunction · 0.50
foreachFunction · 0.50

Tested by

no test coverage detected