Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

execProcnode.c File Reference

#include "postgres.h"
#include "executor/executor.h"
#include "executor/nodeAgg.h"
#include "executor/nodeAppend.h"
#include "executor/nodeBitmapAnd.h"
#include "executor/nodeBitmapHeapscan.h"
#include "executor/nodeBitmapIndexscan.h"
#include "executor/nodeBitmapOr.h"
#include "executor/nodeCtescan.h"
#include "executor/nodeForeignscan.h"
#include "executor/nodeFunctionscan.h"
#include "executor/nodeGroup.h"
#include "executor/nodeHash.h"
#include "executor/nodeHashjoin.h"
#include "executor/nodeIndexonlyscan.h"
#include "executor/nodeIndexscan.h"
#include "executor/nodeLimit.h"
#include "executor/nodeLockRows.h"
#include "executor/nodeMaterial.h"
#include "executor/nodeMergeAppend.h"
#include "executor/nodeMergejoin.h"
#include "executor/nodeModifyTable.h"
#include "executor/nodeNestloop.h"
#include "executor/nodeRecursiveunion.h"
#include "executor/nodeResult.h"
#include "executor/nodeSeqscan.h"
#include "executor/nodeSetOp.h"
#include "executor/nodeSort.h"
#include "executor/nodeSubplan.h"
#include "executor/nodeSubqueryscan.h"
#include "executor/nodeTidscan.h"
#include "executor/nodeUnique.h"
#include "executor/nodeValuesscan.h"
#include "executor/nodeWindowAgg.h"
#include "executor/nodeWorktablescan.h"
#include "miscadmin.h"
Include dependency graph for execProcnode.c:

Go to the source code of this file.

Functions

PlanStateExecInitNode (Plan *node, EState *estate, int eflags)
TupleTableSlotExecProcNode (PlanState *node)
NodeMultiExecProcNode (PlanState *node)
void ExecEndNode (PlanState *node)

Function Documentation

void ExecEndNode ( PlanState node  ) 

Definition at line 583 of file execProcnode.c.

References bms_free(), PlanState::chgParam, elog, ERROR, ExecEndAgg(), ExecEndAppend(), ExecEndBitmapAnd(), ExecEndBitmapHeapScan(), ExecEndBitmapIndexScan(), ExecEndBitmapOr(), ExecEndCteScan(), ExecEndForeignScan(), ExecEndFunctionScan(), ExecEndGroup(), ExecEndHash(), ExecEndHashJoin(), ExecEndIndexOnlyScan(), ExecEndIndexScan(), ExecEndLimit(), ExecEndLockRows(), ExecEndMaterial(), ExecEndMergeAppend(), ExecEndMergeJoin(), ExecEndModifyTable(), ExecEndNestLoop(), ExecEndRecursiveUnion(), ExecEndResult(), ExecEndSeqScan(), ExecEndSetOp(), ExecEndSort(), ExecEndSubqueryScan(), ExecEndTidScan(), ExecEndUnique(), ExecEndValuesScan(), ExecEndWindowAgg(), ExecEndWorkTableScan(), nodeTag, NULL, T_AggState, T_AppendState, T_BitmapAndState, T_BitmapHeapScanState, T_BitmapIndexScanState, T_BitmapOrState, T_CteScanState, T_ForeignScanState, T_FunctionScanState, T_GroupState, T_HashJoinState, T_HashState, T_IndexOnlyScanState, T_IndexScanState, T_LimitState, T_LockRowsState, T_MaterialState, T_MergeAppendState, T_MergeJoinState, T_ModifyTableState, T_NestLoopState, T_RecursiveUnionState, T_ResultState, T_SeqScanState, T_SetOpState, T_SortState, T_SubqueryScanState, T_TidScanState, T_UniqueState, T_ValuesScanState, T_WindowAggState, and T_WorkTableScanState.

Referenced by EvalPlanQualEnd(), ExecEndAgg(), ExecEndAppend(), ExecEndBitmapAnd(), ExecEndBitmapHeapScan(), ExecEndBitmapOr(), ExecEndGroup(), ExecEndHash(), ExecEndHashJoin(), ExecEndLimit(), ExecEndLockRows(), ExecEndMaterial(), ExecEndMergeAppend(), ExecEndMergeJoin(), ExecEndModifyTable(), ExecEndNestLoop(), ExecEndPlan(), ExecEndRecursiveUnion(), ExecEndResult(), ExecEndSetOp(), ExecEndSort(), ExecEndSubqueryScan(), ExecEndUnique(), and ExecEndWindowAgg().

{
    /*
     * do nothing when we get to the end of a leaf on tree.
     */
    if (node == NULL)
        return;

    if (node->chgParam != NULL)
    {
        bms_free(node->chgParam);
        node->chgParam = NULL;
    }

    switch (nodeTag(node))
    {
            /*
             * control nodes
             */
        case T_ResultState:
            ExecEndResult((ResultState *) node);
            break;

        case T_ModifyTableState:
            ExecEndModifyTable((ModifyTableState *) node);
            break;

        case T_AppendState:
            ExecEndAppend((AppendState *) node);
            break;

        case T_MergeAppendState:
            ExecEndMergeAppend((MergeAppendState *) node);
            break;

        case T_RecursiveUnionState:
            ExecEndRecursiveUnion((RecursiveUnionState *) node);
            break;

        case T_BitmapAndState:
            ExecEndBitmapAnd((BitmapAndState *) node);
            break;

        case T_BitmapOrState:
            ExecEndBitmapOr((BitmapOrState *) node);
            break;

            /*
             * scan nodes
             */
        case T_SeqScanState:
            ExecEndSeqScan((SeqScanState *) node);
            break;

        case T_IndexScanState:
            ExecEndIndexScan((IndexScanState *) node);
            break;

        case T_IndexOnlyScanState:
            ExecEndIndexOnlyScan((IndexOnlyScanState *) node);
            break;

        case T_BitmapIndexScanState:
            ExecEndBitmapIndexScan((BitmapIndexScanState *) node);
            break;

        case T_BitmapHeapScanState:
            ExecEndBitmapHeapScan((BitmapHeapScanState *) node);
            break;

        case T_TidScanState:
            ExecEndTidScan((TidScanState *) node);
            break;

        case T_SubqueryScanState:
            ExecEndSubqueryScan((SubqueryScanState *) node);
            break;

        case T_FunctionScanState:
            ExecEndFunctionScan((FunctionScanState *) node);
            break;

        case T_ValuesScanState:
            ExecEndValuesScan((ValuesScanState *) node);
            break;

        case T_CteScanState:
            ExecEndCteScan((CteScanState *) node);
            break;

        case T_WorkTableScanState:
            ExecEndWorkTableScan((WorkTableScanState *) node);
            break;

        case T_ForeignScanState:
            ExecEndForeignScan((ForeignScanState *) node);
            break;

            /*
             * join nodes
             */
        case T_NestLoopState:
            ExecEndNestLoop((NestLoopState *) node);
            break;

        case T_MergeJoinState:
            ExecEndMergeJoin((MergeJoinState *) node);
            break;

        case T_HashJoinState:
            ExecEndHashJoin((HashJoinState *) node);
            break;

            /*
             * materialization nodes
             */
        case T_MaterialState:
            ExecEndMaterial((MaterialState *) node);
            break;

        case T_SortState:
            ExecEndSort((SortState *) node);
            break;

        case T_GroupState:
            ExecEndGroup((GroupState *) node);
            break;

        case T_AggState:
            ExecEndAgg((AggState *) node);
            break;

        case T_WindowAggState:
            ExecEndWindowAgg((WindowAggState *) node);
            break;

        case T_UniqueState:
            ExecEndUnique((UniqueState *) node);
            break;

        case T_HashState:
            ExecEndHash((HashState *) node);
            break;

        case T_SetOpState:
            ExecEndSetOp((SetOpState *) node);
            break;

        case T_LockRowsState:
            ExecEndLockRows((LockRowsState *) node);
            break;

        case T_LimitState:
            ExecEndLimit((LimitState *) node);
            break;

        default:
            elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
            break;
    }
}

PlanState* ExecInitNode ( Plan node,
EState estate,
int  eflags 
)

Definition at line 132 of file execProcnode.c.

References Assert, elog, ERROR, EState::es_instrument, ExecInitAgg(), ExecInitAppend(), ExecInitBitmapAnd(), ExecInitBitmapHeapScan(), ExecInitBitmapIndexScan(), ExecInitBitmapOr(), ExecInitCteScan(), ExecInitForeignScan(), ExecInitFunctionScan(), ExecInitGroup(), ExecInitHash(), ExecInitHashJoin(), ExecInitIndexOnlyScan(), ExecInitIndexScan(), ExecInitLimit(), ExecInitLockRows(), ExecInitMaterial(), ExecInitMergeAppend(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNestLoop(), ExecInitRecursiveUnion(), ExecInitResult(), ExecInitSeqScan(), ExecInitSetOp(), ExecInitSort(), ExecInitSubPlan(), ExecInitSubqueryScan(), ExecInitTidScan(), ExecInitUnique(), ExecInitValuesScan(), ExecInitWindowAgg(), ExecInitWorkTableScan(), PlanState::initPlan, Plan::initPlan, InstrAlloc(), PlanState::instrument, IsA, lappend(), lfirst, nodeTag, NULL, T_Agg, T_Append, T_BitmapAnd, T_BitmapHeapScan, T_BitmapIndexScan, T_BitmapOr, T_CteScan, T_ForeignScan, T_FunctionScan, T_Group, T_Hash, T_HashJoin, T_IndexOnlyScan, T_IndexScan, T_Limit, T_LockRows, T_Material, T_MergeAppend, T_MergeJoin, T_ModifyTable, T_NestLoop, T_RecursiveUnion, T_Result, T_SeqScan, T_SetOp, T_Sort, T_SubqueryScan, T_TidScan, T_Unique, T_ValuesScan, T_WindowAgg, and T_WorkTableScan.

Referenced by EvalPlanQualStart(), ExecInitAgg(), ExecInitAppend(), ExecInitBitmapAnd(), ExecInitBitmapHeapScan(), ExecInitBitmapOr(), ExecInitGroup(), ExecInitHash(), ExecInitHashJoin(), ExecInitLimit(), ExecInitLockRows(), ExecInitMaterial(), ExecInitMergeAppend(), ExecInitMergeJoin(), ExecInitModifyTable(), ExecInitNestLoop(), ExecInitRecursiveUnion(), ExecInitResult(), ExecInitSetOp(), ExecInitSort(), ExecInitSubqueryScan(), ExecInitUnique(), ExecInitWindowAgg(), and InitPlan().

{
    PlanState  *result;
    List       *subps;
    ListCell   *l;

    /*
     * do nothing when we get to the end of a leaf on tree.
     */
    if (node == NULL)
        return NULL;

    switch (nodeTag(node))
    {
            /*
             * control nodes
             */
        case T_Result:
            result = (PlanState *) ExecInitResult((Result *) node,
                                                  estate, eflags);
            break;

        case T_ModifyTable:
            result = (PlanState *) ExecInitModifyTable((ModifyTable *) node,
                                                       estate, eflags);
            break;

        case T_Append:
            result = (PlanState *) ExecInitAppend((Append *) node,
                                                  estate, eflags);
            break;

        case T_MergeAppend:
            result = (PlanState *) ExecInitMergeAppend((MergeAppend *) node,
                                                       estate, eflags);
            break;

        case T_RecursiveUnion:
            result = (PlanState *) ExecInitRecursiveUnion((RecursiveUnion *) node,
                                                          estate, eflags);
            break;

        case T_BitmapAnd:
            result = (PlanState *) ExecInitBitmapAnd((BitmapAnd *) node,
                                                     estate, eflags);
            break;

        case T_BitmapOr:
            result = (PlanState *) ExecInitBitmapOr((BitmapOr *) node,
                                                    estate, eflags);
            break;

            /*
             * scan nodes
             */
        case T_SeqScan:
            result = (PlanState *) ExecInitSeqScan((SeqScan *) node,
                                                   estate, eflags);
            break;

        case T_IndexScan:
            result = (PlanState *) ExecInitIndexScan((IndexScan *) node,
                                                     estate, eflags);
            break;

        case T_IndexOnlyScan:
            result = (PlanState *) ExecInitIndexOnlyScan((IndexOnlyScan *) node,
                                                         estate, eflags);
            break;

        case T_BitmapIndexScan:
            result = (PlanState *) ExecInitBitmapIndexScan((BitmapIndexScan *) node,
                                                           estate, eflags);
            break;

        case T_BitmapHeapScan:
            result = (PlanState *) ExecInitBitmapHeapScan((BitmapHeapScan *) node,
                                                          estate, eflags);
            break;

        case T_TidScan:
            result = (PlanState *) ExecInitTidScan((TidScan *) node,
                                                   estate, eflags);
            break;

        case T_SubqueryScan:
            result = (PlanState *) ExecInitSubqueryScan((SubqueryScan *) node,
                                                        estate, eflags);
            break;

        case T_FunctionScan:
            result = (PlanState *) ExecInitFunctionScan((FunctionScan *) node,
                                                        estate, eflags);
            break;

        case T_ValuesScan:
            result = (PlanState *) ExecInitValuesScan((ValuesScan *) node,
                                                      estate, eflags);
            break;

        case T_CteScan:
            result = (PlanState *) ExecInitCteScan((CteScan *) node,
                                                   estate, eflags);
            break;

        case T_WorkTableScan:
            result = (PlanState *) ExecInitWorkTableScan((WorkTableScan *) node,
                                                         estate, eflags);
            break;

        case T_ForeignScan:
            result = (PlanState *) ExecInitForeignScan((ForeignScan *) node,
                                                       estate, eflags);
            break;

            /*
             * join nodes
             */
        case T_NestLoop:
            result = (PlanState *) ExecInitNestLoop((NestLoop *) node,
                                                    estate, eflags);
            break;

        case T_MergeJoin:
            result = (PlanState *) ExecInitMergeJoin((MergeJoin *) node,
                                                     estate, eflags);
            break;

        case T_HashJoin:
            result = (PlanState *) ExecInitHashJoin((HashJoin *) node,
                                                    estate, eflags);
            break;

            /*
             * materialization nodes
             */
        case T_Material:
            result = (PlanState *) ExecInitMaterial((Material *) node,
                                                    estate, eflags);
            break;

        case T_Sort:
            result = (PlanState *) ExecInitSort((Sort *) node,
                                                estate, eflags);
            break;

        case T_Group:
            result = (PlanState *) ExecInitGroup((Group *) node,
                                                 estate, eflags);
            break;

        case T_Agg:
            result = (PlanState *) ExecInitAgg((Agg *) node,
                                               estate, eflags);
            break;

        case T_WindowAgg:
            result = (PlanState *) ExecInitWindowAgg((WindowAgg *) node,
                                                     estate, eflags);
            break;

        case T_Unique:
            result = (PlanState *) ExecInitUnique((Unique *) node,
                                                  estate, eflags);
            break;

        case T_Hash:
            result = (PlanState *) ExecInitHash((Hash *) node,
                                                estate, eflags);
            break;

        case T_SetOp:
            result = (PlanState *) ExecInitSetOp((SetOp *) node,
                                                 estate, eflags);
            break;

        case T_LockRows:
            result = (PlanState *) ExecInitLockRows((LockRows *) node,
                                                    estate, eflags);
            break;

        case T_Limit:
            result = (PlanState *) ExecInitLimit((Limit *) node,
                                                 estate, eflags);
            break;

        default:
            elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
            result = NULL;      /* keep compiler quiet */
            break;
    }

    /*
     * Initialize any initPlans present in this node.  The planner put them in
     * a separate list for us.
     */
    subps = NIL;
    foreach(l, node->initPlan)
    {
        SubPlan    *subplan = (SubPlan *) lfirst(l);
        SubPlanState *sstate;

        Assert(IsA(subplan, SubPlan));
        sstate = ExecInitSubPlan(subplan, result);
        subps = lappend(subps, sstate);
    }
    result->initPlan = subps;

    /* Set up instrumentation for this node if requested */
    if (estate->es_instrument)
        result->instrument = InstrAlloc(1, estate->es_instrument);

    return result;
}

TupleTableSlot* ExecProcNode ( PlanState node  ) 

Definition at line 355 of file execProcnode.c.

References CHECK_FOR_INTERRUPTS, PlanState::chgParam, elog, ERROR, ExecAgg(), ExecAppend(), ExecBitmapHeapScan(), ExecCteScan(), ExecForeignScan(), ExecFunctionScan(), ExecGroup(), ExecHash(), ExecHashJoin(), ExecIndexOnlyScan(), ExecIndexScan(), ExecLimit(), ExecLockRows(), ExecMaterial(), ExecMergeAppend(), ExecMergeJoin(), ExecModifyTable(), ExecNestLoop(), ExecRecursiveUnion(), ExecReScan(), ExecResult(), ExecSeqScan(), ExecSetOp(), ExecSort(), ExecSubqueryScan(), ExecTidScan(), ExecUnique(), ExecValuesScan(), ExecWindowAgg(), ExecWorkTableScan(), InstrStartNode(), InstrStopNode(), PlanState::instrument, nodeTag, NULL, T_AggState, T_AppendState, T_BitmapHeapScanState, T_CteScanState, T_ForeignScanState, T_FunctionScanState, T_GroupState, T_HashJoinState, T_HashState, T_IndexOnlyScanState, T_IndexScanState, T_LimitState, T_LockRowsState, T_MaterialState, T_MergeAppendState, T_MergeJoinState, T_ModifyTableState, T_NestLoopState, T_RecursiveUnionState, T_ResultState, T_SeqScanState, T_SetOpState, T_SortState, T_SubqueryScanState, T_TidScanState, T_UniqueState, T_ValuesScanState, T_WindowAggState, T_WorkTableScanState, and TupIsNull.

Referenced by agg_fill_hash_table(), agg_retrieve_direct(), begin_partition(), buildSubPlanHash(), CteScanNext(), EvalPlanQualNext(), ExecAppend(), ExecGroup(), ExecHashJoin(), ExecHashJoinOuterGetTuple(), ExecLimit(), ExecLockRows(), ExecMaterial(), ExecMergeAppend(), ExecMergeJoin(), ExecModifyTable(), ExecNestLoop(), ExecPostprocessPlan(), ExecRecursiveUnion(), ExecResult(), ExecScanSubPlan(), ExecSetParamPlan(), ExecSort(), ExecUnique(), ExecutePlan(), MultiExecHash(), setop_fill_hash_table(), setop_retrieve_direct(), spool_tuples(), and SubqueryNext().

{
    TupleTableSlot *result;

    CHECK_FOR_INTERRUPTS();

    if (node->chgParam != NULL) /* something changed */
        ExecReScan(node);       /* let ReScan handle this */

    if (node->instrument)
        InstrStartNode(node->instrument);

    switch (nodeTag(node))
    {
            /*
             * control nodes
             */
        case T_ResultState:
            result = ExecResult((ResultState *) node);
            break;

        case T_ModifyTableState:
            result = ExecModifyTable((ModifyTableState *) node);
            break;

        case T_AppendState:
            result = ExecAppend((AppendState *) node);
            break;

        case T_MergeAppendState:
            result = ExecMergeAppend((MergeAppendState *) node);
            break;

        case T_RecursiveUnionState:
            result = ExecRecursiveUnion((RecursiveUnionState *) node);
            break;

            /* BitmapAndState does not yield tuples */

            /* BitmapOrState does not yield tuples */

            /*
             * scan nodes
             */
        case T_SeqScanState:
            result = ExecSeqScan((SeqScanState *) node);
            break;

        case T_IndexScanState:
            result = ExecIndexScan((IndexScanState *) node);
            break;

        case T_IndexOnlyScanState:
            result = ExecIndexOnlyScan((IndexOnlyScanState *) node);
            break;

            /* BitmapIndexScanState does not yield tuples */

        case T_BitmapHeapScanState:
            result = ExecBitmapHeapScan((BitmapHeapScanState *) node);
            break;

        case T_TidScanState:
            result = ExecTidScan((TidScanState *) node);
            break;

        case T_SubqueryScanState:
            result = ExecSubqueryScan((SubqueryScanState *) node);
            break;

        case T_FunctionScanState:
            result = ExecFunctionScan((FunctionScanState *) node);
            break;

        case T_ValuesScanState:
            result = ExecValuesScan((ValuesScanState *) node);
            break;

        case T_CteScanState:
            result = ExecCteScan((CteScanState *) node);
            break;

        case T_WorkTableScanState:
            result = ExecWorkTableScan((WorkTableScanState *) node);
            break;

        case T_ForeignScanState:
            result = ExecForeignScan((ForeignScanState *) node);
            break;

            /*
             * join nodes
             */
        case T_NestLoopState:
            result = ExecNestLoop((NestLoopState *) node);
            break;

        case T_MergeJoinState:
            result = ExecMergeJoin((MergeJoinState *) node);
            break;

        case T_HashJoinState:
            result = ExecHashJoin((HashJoinState *) node);
            break;

            /*
             * materialization nodes
             */
        case T_MaterialState:
            result = ExecMaterial((MaterialState *) node);
            break;

        case T_SortState:
            result = ExecSort((SortState *) node);
            break;

        case T_GroupState:
            result = ExecGroup((GroupState *) node);
            break;

        case T_AggState:
            result = ExecAgg((AggState *) node);
            break;

        case T_WindowAggState:
            result = ExecWindowAgg((WindowAggState *) node);
            break;

        case T_UniqueState:
            result = ExecUnique((UniqueState *) node);
            break;

        case T_HashState:
            result = ExecHash((HashState *) node);
            break;

        case T_SetOpState:
            result = ExecSetOp((SetOpState *) node);
            break;

        case T_LockRowsState:
            result = ExecLockRows((LockRowsState *) node);
            break;

        case T_LimitState:
            result = ExecLimit((LimitState *) node);
            break;

        default:
            elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
            result = NULL;
            break;
    }

    if (node->instrument)
        InstrStopNode(node->instrument, TupIsNull(result) ? 0.0 : 1.0);

    return result;
}

Node* MultiExecProcNode ( PlanState node  ) 

Definition at line 530 of file execProcnode.c.

References CHECK_FOR_INTERRUPTS, PlanState::chgParam, elog, ERROR, ExecReScan(), MultiExecBitmapAnd(), MultiExecBitmapIndexScan(), MultiExecBitmapOr(), MultiExecHash(), nodeTag, NULL, T_BitmapAndState, T_BitmapIndexScanState, T_BitmapOrState, and T_HashState.

Referenced by BitmapHeapNext(), ExecHashJoin(), MultiExecBitmapAnd(), and MultiExecBitmapOr().

{
    Node       *result;

    CHECK_FOR_INTERRUPTS();

    if (node->chgParam != NULL) /* something changed */
        ExecReScan(node);       /* let ReScan handle this */

    switch (nodeTag(node))
    {
            /*
             * Only node types that actually support multiexec will be listed
             */

        case T_HashState:
            result = MultiExecHash((HashState *) node);
            break;

        case T_BitmapIndexScanState:
            result = MultiExecBitmapIndexScan((BitmapIndexScanState *) node);
            break;

        case T_BitmapAndState:
            result = MultiExecBitmapAnd((BitmapAndState *) node);
            break;

        case T_BitmapOrState:
            result = MultiExecBitmapOr((BitmapOrState *) node);
            break;

        default:
            elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
            result = NULL;
            break;
    }

    return result;
}