]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Ditch ExecGetTupType() in favor of the much simpler ExecGetResultType(),
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 5 May 2003 17:57:47 +0000 (17:57 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 5 May 2003 17:57:47 +0000 (17:57 +0000)
which does the same thing.  Perhaps at one time there was a reason to
allow plan nodes to store their result types in different places, but
AFAICT that's been unnecessary for a good while.

src/backend/executor/execMain.c
src/backend/executor/execProcnode.c
src/backend/executor/execUtils.c
src/backend/executor/nodeHashjoin.c
src/backend/executor/nodeMergejoin.c
src/backend/executor/nodeNestloop.c
src/backend/executor/nodeSort.c
src/include/executor/executor.h

index 485f1e03fa0d924a585240aaa58701c80ac01f48..d70b3379217f29f0dda8e64a9453b4059a5b7f67 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.205 2003/03/27 16:51:27 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.206 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -634,7 +634,7 @@ InitPlan(QueryDesc *queryDesc)
         * (this is especially important if we are creating a relation with
         * "SELECT INTO")
         */
-       tupType = ExecGetTupType(planstate);
+       tupType = ExecGetResultType(planstate);
 
        /*
         * Initialize the junk filter if needed.  SELECT and INSERT queries need a
@@ -713,7 +713,7 @@ InitPlan(QueryDesc *queryDesc)
                                        JunkFilter *j;
 
                                        j = ExecInitJunkFilter(subplan->plan->targetlist,
-                                                                                  ExecGetTupType(subplan),
+                                                                                  ExecGetResultType(subplan),
                                                          ExecAllocTableSlot(estate->es_tupleTable));
                                        resultRelInfo->ri_junkFilter = j;
                                        resultRelInfo++;
index 8d2bc0f8bd93faff9125cc94f10b52bf81d7c3c5..f8dbb019c5db99ef312860358cbfccb94e2a375b 100644 (file)
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.35 2003/02/09 00:30:39 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.36 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -22,7 +22,6 @@
  *             ExecInitNode    -               initialize a plan node and its subplans
  *             ExecProcNode    -               get a tuple by executing the plan node
  *             ExecEndNode             -               shut down a plan node and its subplans
- *             ExecGetTupType  -               get result tuple type of a plan node
  *
  *      NOTES
  *             This used to be three files.  It is now all combined into
@@ -602,181 +601,3 @@ ExecEndNode(PlanState *node)
                        break;
        }
 }
-
-
-/* ----------------------------------------------------------------
- *             ExecGetTupType
- *
- *             this gives you the tuple descriptor for tuples returned
- *             by this node.  I really wish I could ditch this routine,
- *             but since not all nodes store their type info in the same
- *             place, we have to do something special for each node type.
- *
- * ----------------------------------------------------------------
- */
-TupleDesc
-ExecGetTupType(PlanState *node)
-{
-       TupleTableSlot *slot;
-
-       if (node == NULL)
-               return NULL;
-
-       switch (nodeTag(node))
-       {
-               case T_ResultState:
-                       {
-                               ResultState *resstate = (ResultState *) node;
-
-                               slot = resstate->ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_AppendState:
-                       {
-                               AppendState *appendstate = (AppendState *) node;
-
-                               slot = appendstate->ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_SeqScanState:
-                       {
-                               SeqScanState *scanstate = (SeqScanState *) node;
-
-                               slot = scanstate->ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_IndexScanState:
-                       {
-                               IndexScanState *scanstate = (IndexScanState *) node;
-
-                               slot = scanstate->ss.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_TidScanState:
-                       {
-                               TidScanState *scanstate = (TidScanState *) node;
-
-                               slot = scanstate->ss.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_SubqueryScanState:
-                       {
-                               SubqueryScanState *scanstate = (SubqueryScanState *) node;
-
-                               slot = scanstate->ss.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_FunctionScanState:
-                       {
-                               FunctionScanState *scanstate = (FunctionScanState *) node;
-
-                               slot = scanstate->ss.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_NestLoopState:
-                       {
-                               NestLoopState *nlstate = (NestLoopState *) node;
-
-                               slot = nlstate->js.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_MergeJoinState:
-                       {
-                               MergeJoinState *mergestate = (MergeJoinState *) node;
-
-                               slot = mergestate->js.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_HashJoinState:
-                       {
-                               HashJoinState *hashjoinstate = (HashJoinState *) node;
-
-                               slot = hashjoinstate->js.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_MaterialState:
-                       {
-                               MaterialState *matstate = (MaterialState *) node;
-
-                               slot = matstate->ss.ss_ScanTupleSlot;
-                       }
-                       break;
-
-               case T_SortState:
-                       {
-                               SortState  *sortstate = (SortState *) node;
-
-                               slot = sortstate->ss.ss_ScanTupleSlot;
-                       }
-                       break;
-
-               case T_GroupState:
-                       {
-                               GroupState *grpstate = (GroupState *) node;
-
-                               slot = grpstate->ss.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_AggState:
-                       {
-                               AggState   *aggstate = (AggState *) node;
-
-                               slot = aggstate->ss.ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_UniqueState:
-                       {
-                               UniqueState *uniquestate = (UniqueState *) node;
-
-                               slot = uniquestate->ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_HashState:
-                       {
-                               HashState  *hashstate = (HashState *) node;
-
-                               slot = hashstate->ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_SetOpState:
-                       {
-                               SetOpState *setopstate = (SetOpState *) node;
-
-                               slot = setopstate->ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               case T_LimitState:
-                       {
-                               LimitState *limitstate = (LimitState *) node;
-
-                               slot = limitstate->ps.ps_ResultTupleSlot;
-                       }
-                       break;
-
-               default:
-
-                       /*
-                        * should never get here
-                        */
-                       elog(ERROR, "ExecGetTupType: node type %d unsupported",
-                                (int) nodeTag(node));
-                       return NULL;
-       }
-
-       return slot->ttc_tupleDescriptor;
-}
index 5341dbd347c735044ca924f4b235cdce0aecf6a3..c06d951f91e6c11116069b264cb88929eca6f0d3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.98 2003/02/09 06:56:27 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.99 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -413,7 +413,7 @@ ExecAssignResultTypeFromOuterPlan(PlanState *planstate)
        TupleDesc       tupDesc;
 
        outerPlan = outerPlanState(planstate);
-       tupDesc = ExecGetTupType(outerPlan);
+       tupDesc = ExecGetResultType(outerPlan);
 
        ExecAssignResultType(planstate, tupDesc, false);
 }
@@ -606,7 +606,7 @@ ExecAssignScanTypeFromOuterPlan(ScanState *scanstate)
        TupleDesc       tupDesc;
 
        outerPlan = outerPlanState(scanstate);
-       tupDesc = ExecGetTupType(outerPlan);
+       tupDesc = ExecGetResultType(outerPlan);
 
        ExecAssignScanType(scanstate, tupDesc, false);
 }
index 4bc1671801f5cd84de9ffe4d32e107560e298f0f..000063a8b7f23e932f48528e4ea5e4c85b7a948f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.49 2003/03/27 16:51:27 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.50 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -374,7 +374,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
                case JOIN_LEFT:
                        hjstate->hj_NullInnerTupleSlot =
                                ExecInitNullTupleSlot(estate,
-                                                                         ExecGetTupType(innerPlanState(hjstate)));
+                                                                         ExecGetResultType(innerPlanState(hjstate)));
                        break;
                default:
                        elog(ERROR, "ExecInitHashJoin: unsupported join type %d",
@@ -402,7 +402,7 @@ ExecInitHashJoin(HashJoin *node, EState *estate)
        ExecAssignProjectionInfo(&hjstate->js.ps);
 
        ExecSetSlotDescriptor(hjstate->hj_OuterTupleSlot,
-                                                 ExecGetTupType(outerPlanState(hjstate)),
+                                                 ExecGetResultType(outerPlanState(hjstate)),
                                                  false);
 
        /*
index d5dc7f421aac888b4693e50386dad92f9f6b901a..864008dd17cc4a6a2ac99aedb7dfbe7b00796071 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.56 2003/01/20 18:54:45 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.57 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1453,7 +1453,7 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate)
 
        mergestate->mj_MarkedTupleSlot = ExecInitExtraTupleSlot(estate);
        ExecSetSlotDescriptor(mergestate->mj_MarkedTupleSlot,
-                                                 ExecGetTupType(innerPlanState(mergestate)),
+                                                 ExecGetResultType(innerPlanState(mergestate)),
                                                  false);
 
        switch (node->join.jointype)
@@ -1464,12 +1464,12 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate)
                case JOIN_LEFT:
                        mergestate->mj_NullInnerTupleSlot =
                                ExecInitNullTupleSlot(estate,
-                                                          ExecGetTupType(innerPlanState(mergestate)));
+                                                          ExecGetResultType(innerPlanState(mergestate)));
                        break;
                case JOIN_RIGHT:
                        mergestate->mj_NullOuterTupleSlot =
                                ExecInitNullTupleSlot(estate,
-                                                          ExecGetTupType(outerPlanState(mergestate)));
+                                                          ExecGetResultType(outerPlanState(mergestate)));
 
                        /*
                         * Can't handle right or full join with non-nil extra
@@ -1481,10 +1481,10 @@ ExecInitMergeJoin(MergeJoin *node, EState *estate)
                case JOIN_FULL:
                        mergestate->mj_NullOuterTupleSlot =
                                ExecInitNullTupleSlot(estate,
-                                                          ExecGetTupType(outerPlanState(mergestate)));
+                                                          ExecGetResultType(outerPlanState(mergestate)));
                        mergestate->mj_NullInnerTupleSlot =
                                ExecInitNullTupleSlot(estate,
-                                                          ExecGetTupType(innerPlanState(mergestate)));
+                                                          ExecGetResultType(innerPlanState(mergestate)));
 
                        /*
                         * Can't handle right or full join with non-nil extra
index 8ccc0392057dfbfe4f3c2665073a739378f67256..bddce76b4378c99eb170bec46700ef5d92ad2018 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.31 2003/01/27 20:51:48 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.32 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -330,7 +330,7 @@ ExecInitNestLoop(NestLoop *node, EState *estate)
                case JOIN_LEFT:
                        nlstate->nl_NullInnerTupleSlot =
                                ExecInitNullTupleSlot(estate,
-                                                          ExecGetTupType(innerPlanState(nlstate)));
+                                                          ExecGetResultType(innerPlanState(nlstate)));
                        break;
                default:
                        elog(ERROR, "ExecInitNestLoop: unsupported join type %d",
index a37583241fb878ce69631741de3f67f6546581de..2be31ce09e809ad9451cfda698a725495cbfcbc8 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.42 2002/12/15 16:17:46 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.43 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -137,7 +137,7 @@ ExecSort(SortState *node)
                                   "calling tuplesort_begin");
 
                outerNode = outerPlanState(node);
-               tupDesc = ExecGetTupType(outerNode);
+               tupDesc = ExecGetResultType(outerNode);
 
                ExtractSortKeys(plannode, &sortOperators, &attNums);
 
@@ -173,11 +173,6 @@ ExecSort(SortState *node)
                 */
                estate->es_direction = dir;
 
-               /*
-                * make sure the tuple descriptor is up to date (is this needed?)
-                */
-               ExecAssignResultType(&node->ss.ps, tupDesc, false);
-
                /*
                 * finally set the sorted flag to true
                 */
index 40a696e2976459a894de4164876caa25a5cf3d80..9693435977d15fef28c244d36531c32b9ed93613 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: executor.h,v 1.91 2003/03/11 19:40:23 tgl Exp $
+ * $Id: executor.h,v 1.92 2003/05/05 17:57:47 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -101,7 +101,6 @@ extern PlanState *ExecInitNode(Plan *node, EState *estate);
 extern TupleTableSlot *ExecProcNode(PlanState *node);
 extern int     ExecCountSlotsNode(Plan *node);
 extern void ExecEndNode(PlanState *node);
-extern TupleDesc ExecGetTupType(PlanState *node);
 
 /*
  * prototypes from functions in execQual.c