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

Function InitSliceTable

src/backend/executor/execUtils.c:1662–1763  ·  view source on GitHub ↗

* Create the executor slice table. * * The planner constructed a slice table, in plannedstmt->slices. Turn that * into an "executor slice table", with slightly more information. The gangs * to execute the slices will be set up later. */

Source from the content-addressed store, hash-verified

1660 * to execute the slices will be set up later.
1661 */
1662SliceTable *
1663InitSliceTable(EState *estate, PlannedStmt *plannedstmt)
1664{
1665 SliceTable *table;
1666 int i;
1667 int numSlices;
1668 MemoryContext oldcontext;
1669
1670 numSlices = plannedstmt->numSlices;
1671 Assert(numSlices > 0);
1672
1673 if (gp_max_slices > 0 && numSlices > gp_max_slices)
1674 ereport(ERROR,
1675 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1676 errmsg("at most %d slices are allowed in a query, current number: %d",
1677 gp_max_slices, numSlices),
1678 errhint("rewrite your query or adjust GUC gp_max_slices")));
1679
1680 oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
1681
1682 table = makeNode(SliceTable);
1683 table->instrument_options = INSTRUMENT_NONE;
1684 table->hasMotions = false;
1685
1686 /*
1687 * Initialize the executor slice table.
1688 *
1689 * We have most of the information in the planner slice table. In addition to that,
1690 * we set up the parent-child relationships.
1691 */
1692 table->slices = palloc0(sizeof(ExecSlice) * numSlices);
1693 for (i = 0; i < numSlices; i++)
1694 {
1695 ExecSlice *currExecSlice = &table->slices[i];
1696 PlanSlice *currPlanSlice = &plannedstmt->slices[i];
1697 int parentIndex;
1698 int rootIndex;
1699
1700 currExecSlice->sliceIndex = i;
1701 currExecSlice->planNumSegments = currPlanSlice->numsegments;
1702 currExecSlice->segments = NIL;
1703 currExecSlice->primaryGang = NULL;
1704 currExecSlice->primaryProcesses = NIL;
1705
1706 parentIndex = currPlanSlice->parentIndex;
1707 if (parentIndex < -1 || parentIndex >= numSlices)
1708 elog(ERROR, "invalid parent slice index %d", currPlanSlice->parentIndex);
1709
1710 if (parentIndex >= 0)
1711 {
1712 ExecSlice *parentExecSlice = &table->slices[parentIndex];
1713 int counter;
1714
1715 /* Sending slice is a child of recv slice */
1716 parentExecSlice->children = lappend_int(parentExecSlice->children, currPlanSlice->sliceIndex);
1717
1718 /* Find the root slice */
1719 rootIndex = i;

Calls 8

MemoryContextSwitchToFunction · 0.85
lappend_intFunction · 0.85
FillSliceGangInfoFunction · 0.85
getgpsegmentCountFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errhintFunction · 0.50
palloc0Function · 0.50

Tested by 1