]> granicus.if.org Git - postgresql/blobdiff - src/include/nodes/execnodes.h
Spell 'precedes', 'preceding' correctly in various places.
[postgresql] / src / include / nodes / execnodes.h
index 4ba3a70c1b558ce454cbb1ed14e034710097590e..97e76ccdfd5b8b929560fbbbcfd1ab8b257e168a 100644 (file)
@@ -4,10 +4,10 @@
  *       definitions for executor state nodes
  *
  *
- * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: execnodes.h,v 1.53 2000/11/12 00:37:01 tgl Exp $
+ * $Id: execnodes.h,v 1.67 2001/11/21 22:57:01 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -34,7 +34,7 @@
  *             NumKeyAttrs                     number of key attributes for this index
  *                                                     (ie, number of attrs from underlying relation)
  *             KeyAttrNumbers          underlying-rel attribute numbers used as keys
- *             Predicate                       partial-index predicate, or NULL if none
+ *             Predicate                       partial-index predicate, or NIL if none
  *             FuncOid                         OID of function, or InvalidOid if not f. index
  *             FuncInfo                        fmgr lookup data for function, if FuncOid valid
  *             Unique                          is it a unique index?
@@ -46,7 +46,7 @@ typedef struct IndexInfo
        int                     ii_NumIndexAttrs;
        int                     ii_NumKeyAttrs;
        AttrNumber      ii_KeyAttrNumbers[INDEX_MAX_KEYS];
-       Node       *ii_Predicate;
+       List       *ii_Predicate;
        Oid                     ii_FuncOid;
        FmgrInfo        ii_FuncInfo;
        bool            ii_Unique;
@@ -65,7 +65,7 @@ typedef struct IndexInfo
  *     There are two memory contexts associated with an ExprContext:
  *     * ecxt_per_query_memory is a relatively long-lived context (such as
  *       TransactionCommandContext); typically it's the same context the
- *       ExprContext node itself is allocated in.  This context can be
+ *       ExprContext node itself is allocated in.      This context can be
  *       used for purposes such as storing operator/function fcache nodes.
  *     * ecxt_per_tuple_memory is a short-term context for expression results.
  *       As the name suggests, it will typically be reset once per tuple,
@@ -86,8 +86,8 @@ typedef struct ExprContext
        MemoryContext ecxt_per_query_memory;
        MemoryContext ecxt_per_tuple_memory;
        /* Values to substitute for Param nodes in expression */
-       ParamExecData *ecxt_param_exec_vals;    /* for PARAM_EXEC params */
-       ParamListInfo ecxt_param_list_info;             /* for other param types */
+       ParamExecData *ecxt_param_exec_vals;            /* for PARAM_EXEC params */
+       ParamListInfo ecxt_param_list_info; /* for other param types */
        /* Values to substitute for Aggref nodes in expression */
        Datum      *ecxt_aggvalues; /* precomputed values for Aggref nodes */
        bool       *ecxt_aggnulls;      /* null flags for Aggref nodes */
@@ -153,7 +153,7 @@ typedef struct ProjectionInfo
  *       in emitted tuples.    For example, when we do an UPDATE query,
  *       the planner adds a "junk" entry to the targetlist so that the tuples
  *       returned to ExecutePlan() contain an extra attribute: the ctid of
- *       the tuple to be updated.  This is needed to do the update, but we
+ *       the tuple to be updated.      This is needed to do the update, but we
  *       don't want the ctid to be part of the stored new tuple!  So, we
  *       apply a "junk filter" to remove the junk attributes and form the
  *       real output tuple.
@@ -164,11 +164,21 @@ typedef struct ProjectionInfo
  *                                             (including the junk attributes).
  *       cleanTargetList:      the "clean" target list (junk attributes removed).
  *       cleanLength:          the length of 'cleanTargetList'
- *       cleanTupTyp         the tuple descriptor of the "clean" tuple (with
+ *       cleanTupType:         the tuple descriptor of the "clean" tuple (with
  *                                             junk attributes removed).
- *       cleanMap:                     A map with the correspondance between the non junk
- *                                             attributes of the "original" tuple and the
- *                                             attributes of the "clean" tuple.
+ *       cleanMap:                     A map with the correspondence between the non-junk
+ *                                             attribute numbers of the "original" tuple and the
+ *                                             attribute numbers of the "clean" tuple.
+ *       junkContext:          memory context holding the JunkFilter node and all
+ *                                             its subsidiary data structures.
+ *       resultSlot:           tuple slot that can be used to hold cleaned tuple.
+ *
+ * NOTE: the original targetList and tupType are passed to ExecInitJunkFilter,
+ * as is the resultSlot.  These items do not belong to the JunkFilter. All
+ * the other subsidiary structures are created during ExecInitJunkFilter,
+ * and all of them can be freed by deleting the memory context junkContext.
+ * This would not be needed if we had a cleaner approach to managing
+ * query-lifetime data structures...
  * ----------------
  */
 typedef struct JunkFilter
@@ -181,21 +191,25 @@ typedef struct JunkFilter
        int                     jf_cleanLength;
        TupleDesc       jf_cleanTupType;
        AttrNumber *jf_cleanMap;
+       MemoryContext jf_junkContext;
+       TupleTableSlot *jf_resultSlot;
 } JunkFilter;
 
 /* ----------------
  *       ResultRelInfo information
  *
- *             whenever we update an existing relation, we have to
- *             update indices on the relation.  The ResultRelInfo class
- *             is used to hold all the information on result relations,
- *             including indices.. -cim 10/15/89
+ *             Whenever we update an existing relation, we have to
+ *             update indices on the relation, and perhaps also fire triggers.
+ *             The ResultRelInfo class is used to hold all the information needed
+ *             about a result relation, including indices.. -cim 10/15/89
  *
  *             RangeTableIndex                 result relation's range table index
  *             RelationDesc                    relation descriptor for result relation
  *             NumIndices                              # of indices existing on result relation
  *             IndexRelationDescs              array of relation descriptors for indices
  *             IndexRelationInfo               array of key/attr info for indices
+ *             TrigDesc                                triggers to be fired, if any
+ *             TrigFunctions                   cached lookup info for trigger functions
  *             ConstraintExprs                 array of constraint-checking expressions
  *             junkFilter                              for removing junk attributes from tuples
  * ----------------
@@ -208,6 +222,8 @@ typedef struct ResultRelInfo
        int                     ri_NumIndices;
        RelationPtr ri_IndexRelationDescs;
        IndexInfo **ri_IndexRelationInfo;
+       TriggerDesc *ri_TrigDesc;
+       FmgrInfo   *ri_TrigFunctions;
        List      **ri_ConstraintExprs;
        JunkFilter *ri_junkFilter;
 } ResultRelInfo;
@@ -237,10 +253,11 @@ typedef struct EState
        ScanDirection es_direction;
        Snapshot        es_snapshot;
        List       *es_range_table;
-       ResultRelInfo *es_result_relations;             /* array of ResultRelInfos */
-       int                     es_num_result_relations;        /* length of array */
-       ResultRelInfo *es_result_relation_info; /* currently active array elt */
-       JunkFilter *es_junkFilter;                              /* currently active junk filter */
+       ResultRelInfo *es_result_relations; /* array of ResultRelInfos */
+       int                     es_num_result_relations;                /* length of array */
+       ResultRelInfo *es_result_relation_info;         /* currently active array
+                                                                                                * elt */
+       JunkFilter *es_junkFilter;      /* currently active junk filter */
        Relation        es_into_relation_descriptor;
        ParamListInfo es_param_list_info;
        ParamExecData *es_param_exec_vals;      /* this is for subselects */
@@ -248,11 +265,13 @@ typedef struct EState
        uint32          es_processed;   /* # of tuples processed */
        Oid                     es_lastoid;             /* last oid processed (by INSERT) */
        List       *es_rowMark;         /* not good place, but there is no other */
-       MemoryContext es_query_cxt;     /* per-query context in which EState lives */
+       MemoryContext es_query_cxt; /* per-query context in which EState lives */
+
        /*
         * this ExprContext is for per-output-tuple operations, such as
-        * constraint checks and index-value computations.  It can be reset
-        * for each output tuple.  Note that it will be created only if needed.
+        * constraint checks and index-value computations.      It will be reset
+        * for each output tuple.  Note that it will be created only if
+        * needed.
         */
        ExprContext *es_per_tuple_exprcontext;
        /* Below is to re-evaluate plan qual in READ COMMITTED mode */
@@ -283,7 +302,7 @@ typedef struct EState
  *|
  *|                      As a result, many classes have extra slots which they
  *|                      don't use.  These slots are denoted (unused) in the
- *|                      comment preceeding the class definition.      If you
+ *|                      comment preceding the class definition.       If you
  *|                      comes up with a better idea of a way of doing things
  *|                      along these lines, then feel free to make your idea
  *|                      known to me.. -cim 10/15/89
@@ -341,6 +360,8 @@ typedef struct ResultState
  *      AppendState information
  *
  *             whichplan               which plan is being executed (0 .. n-1)
+ *             firstplan               first plan to execute (usually 0)
+ *             lastplan                last plan to execute (usually n-1)
  *             nplans                  how many plans are in the list
  *             initialized             array of ExecInitNode() results
  * ----------------
@@ -349,6 +370,8 @@ typedef struct AppendState
 {
        CommonState cstate;                     /* its first field is NodeTag */
        int                     as_whichplan;
+       int                     as_firstplan;
+       int                     as_lastplan;
        int                     as_nplans;
        bool       *as_initialized;
 } AppendState;
@@ -438,7 +461,7 @@ typedef struct TidScanState
        int                     tss_NumTids;
        int                     tss_TidPtr;
        int                     tss_MarkTidPtr;
-       ItemPointer *tss_TidList;
+       ItemPointerData *tss_TidList;
        HeapTupleData tss_htup;
 } TidScanState;
 
@@ -475,8 +498,8 @@ typedef CommonState JoinState;
 /* ----------------
  *      NestLoopState information
  *
- *             NeedNewOuter       true if need new outer tuple on next call
- *             MatchedOuter       true if found a join match for current outer tuple
+ *             NeedNewOuter       true if need new outer tuple on next call
+ *             MatchedOuter       true if found a join match for current outer tuple
  *             NullInnerTupleSlot prepared null tuple for left outer joins
  * ----------------
  */
@@ -494,10 +517,10 @@ typedef struct NestLoopState
  *             OuterSkipQual      outerKey1 < innerKey1 ...
  *             InnerSkipQual      outerKey1 > innerKey1 ...
  *             JoinState                  current "state" of join. see executor.h
- *             MatchedOuter       true if found a join match for current outer tuple
- *             MatchedInner       true if found a join match for current inner tuple
- *             OuterTupleSlot     pointer to slot in tuple table for cur outer tuple
- *             InnerTupleSlot     pointer to slot in tuple table for cur inner tuple
+ *             MatchedOuter       true if found a join match for current outer tuple
+ *             MatchedInner       true if found a join match for current inner tuple
+ *             OuterTupleSlot     pointer to slot in tuple table for cur outer tuple
+ *             InnerTupleSlot     pointer to slot in tuple table for cur inner tuple
  *             MarkedTupleSlot    pointer to slot in tuple table for marked tuple
  *             NullOuterTupleSlot prepared null tuple for right outer joins
  *             NullInnerTupleSlot prepared null tuple for left outer joins
@@ -530,9 +553,9 @@ typedef struct MergeJoinState
  *             hj_InnerHashKey                 the inner hash key in the hashjoin condition
  *             hj_OuterTupleSlot               tuple slot for outer tuples
  *             hj_HashTupleSlot                tuple slot for hashed tuples
- *             hj_NullInnerTupleSlot   prepared null tuple for left outer joins
- *             hj_NeedNewOuter         true if need new outer tuple on next call
- *             hj_MatchedOuter         true if found a join match for current outer
+ *             hj_NullInnerTupleSlot   prepared null tuple for left outer joins
+ *             hj_NeedNewOuter                 true if need new outer tuple on next call
+ *             hj_MatchedOuter                 true if found a join match for current outer
  *             hj_hashdone                             true if hash-table-build phase is done
  * ----------------
  */
@@ -584,7 +607,7 @@ typedef struct MaterialState
  *     during evaluation of an Agg node's output tuple(s).
  * -------------------------
  */
-typedef struct AggStatePerAggData *AggStatePerAgg;     /* private in nodeAgg.c */
+typedef struct AggStatePerAggData *AggStatePerAgg;             /* private in nodeAgg.c */
 
 typedef struct AggState
 {
@@ -592,7 +615,8 @@ typedef struct AggState
        List       *aggs;                       /* all Aggref nodes in targetlist & quals */
        int                     numaggs;                /* length of list (could be zero!) */
        AggStatePerAgg peragg;          /* per-Aggref working state */
-       MemoryContext tup_cxt;          /* context for per-output-tuple expressions */
+       MemoryContext tup_cxt;          /* context for per-output-tuple
+                                                                * expressions */
        MemoryContext agg_cxt[2];       /* pair of expression eval memory contexts */
        int                     which_cxt;              /* 0 or 1, indicates current agg_cxt */
        bool            agg_done;               /* indicates completion of Agg scan */
@@ -615,7 +639,6 @@ typedef struct GroupState
  *      SortState information
  *
  *             sort_Done               indicates whether sort has been performed yet
- *             sort_Keys               scan key structures describing the sort keys
  *             tuplesortstate  private state of tuplesort.c
  * ----------------
  */
@@ -623,7 +646,6 @@ typedef struct SortState
 {
        CommonScanState csstate;        /* its first field is NodeTag */
        bool            sort_Done;
-       ScanKey         sort_Keys;
        void       *tuplesortstate;
 } SortState;
 
@@ -650,7 +672,7 @@ typedef struct UniqueState
  *      SetOpState information
  *
  *             SetOp nodes are used "on top of" sort nodes to discard
- *             duplicate tuples returned from the sort phase.  These are
+ *             duplicate tuples returned from the sort phase.  These are
  *             more complex than a simple Unique since we have to count
  *             how many duplicates to return.
  * ----------------
@@ -727,8 +749,7 @@ typedef struct TeeState
        MemoryContext tee_mcxt;
        HeapScanDesc tee_leftScanDesc,
                                tee_rightScanDesc;
-}                      TeeState;
-
+}      TeeState;
 #endif
 
-#endif  /* EXECNODES_H */
+#endif   /* EXECNODES_H */