OSDN Git Service

Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias.
[pg-rex/syncrep.git] / src / include / nodes / plannodes.h
index 1cab6e0..ca5727f 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: plannodes.h,v 1.39 2000/04/12 17:16:40 momjian Exp $
+ * $Id: plannodes.h,v 1.43 2000/09/29 18:21:39 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,6 +31,7 @@
  *
  *             Scan ***                                CommonScanState                 scanstate;
  *             IndexScan                               IndexScanState                  indxstate;
+ *             SubqueryScan                    SubqueryScanState               subquerystate;
  *
  *               (*** nodes which inherit Scan also inherit scanstate)
  *
@@ -82,7 +83,7 @@ typedef struct Plan
                                                                 * individual nodes point to one EState
                                                                 * for the whole top-level plan */
        List       *targetlist;
-       List       *qual;                       /* Node* or List* ?? */
+       List       *qual;                       /* implicitly-ANDed qual conditions */
        struct Plan *lefttree;
        struct Plan *righttree;
        List       *extParam;           /* indices of _all_ _external_ PARAM_EXEC
@@ -202,6 +203,26 @@ typedef struct TidScan
        TidScanState *tidstate;
 } TidScan;
 
+/* ----------------
+ *             subquery scan node
+ *
+ * SubqueryScan is for scanning the output of a sub-query in the range table.
+ * We need a special plan node above the sub-query's plan as a place to switch
+ * execution contexts.  Although we are not scanning a physical relation,
+ * we make this a descendant of Scan anyway for code-sharing purposes.
+ *
+ * Note: we store the sub-plan in the type-specific subplan field, not in
+ * the generic lefttree field as you might expect.  This is because we do
+ * not want plan-tree-traversal routines to recurse into the subplan without
+ * knowing that they are changing Query contexts.
+ * ----------------
+ */
+typedef struct SubqueryScan
+{
+       Scan            scan;
+       Plan       *subplan;
+} SubqueryScan;
+
 /*
  * ==========
  * Join nodes
@@ -210,9 +231,26 @@ typedef struct TidScan
 
 /* ----------------
  *             Join node
+ *
+ * jointype:   rule for joining tuples from left and right subtrees
+ * joinqual:   qual conditions that came from JOIN/ON or JOIN/USING
+ *                             (plan.qual contains conditions that came from WHERE)
+ *
+ * When jointype is INNER, joinqual and plan.qual are semantically
+ * interchangeable.  For OUTER jointypes, the two are *not* interchangeable;
+ * only joinqual is used to determine whether a match has been found for
+ * the purpose of deciding whether to generate null-extended tuples.
+ * (But plan.qual is still applied before actually returning a tuple.)
+ * For an outer join, only joinquals are allowed to be used as the merge
+ * or hash condition of a merge or hash join.
  * ----------------
  */
-typedef Plan Join;
+typedef struct Join
+{
+       Plan            plan;
+       JoinType        jointype;
+       List       *joinqual;           /* JOIN quals (in addition to plan.qual) */
+} Join;
 
 /* ----------------
  *             nest loop join node
@@ -245,7 +283,6 @@ typedef struct HashJoin
        List       *hashclauses;
        Oid                     hashjoinop;
        HashJoinState *hashjoinstate;
-       bool            hashdone;
 } HashJoin;
 
 /* ---------------
@@ -277,27 +314,13 @@ typedef struct Group
        GroupState *grpstate;
 } Group;
 
-/*
- * ==========
- * Noname nodes
- * ==========
- */
-typedef struct Noname
-{
-       Plan            plan;
-       Oid                     nonameid;
-       int                     keycount;
-} Noname;
-
 /* ----------------
  *             materialization node
  * ----------------
  */
 typedef struct Material
 {
-       Plan            plan;                   /* noname node flattened out */
-       Oid                     nonameid;
-       int                     keycount;
+       Plan            plan;
        MaterialState *matstate;
 } Material;
 
@@ -307,8 +330,7 @@ typedef struct Material
  */
 typedef struct Sort
 {
-       Plan            plan;                   /* noname node flattened out */
-       Oid                     nonameid;
+       Plan            plan;
        int                     keycount;
        SortState  *sortstate;
 } Sort;
@@ -319,9 +341,7 @@ typedef struct Sort
  */
 typedef struct Unique
 {
-       Plan            plan;                   /* noname node flattened out */
-       Oid                     nonameid;
-       int                     keycount;
+       Plan            plan;
        int                     numCols;                /* number of columns to check for
                                                                 * uniqueness */
        AttrNumber *uniqColIdx;         /* indexes into the target list */
@@ -335,7 +355,7 @@ typedef struct Unique
 typedef struct Hash
 {
        Plan            plan;
-       Var                *hashkey;
+       Node       *hashkey;
        HashState  *hashstate;
 } Hash;
 
@@ -387,7 +407,7 @@ typedef struct SubPlan
         * Remaining fields are working state for executor; not used in
         * planning
         */
-       bool            shutdown;               /* TRUE = need to shutdown plan */
+       bool            needShutdown;   /* TRUE = need to shutdown subplan */
        HeapTuple       curTuple;               /* copy of most recent tuple from subplan */
 } SubPlan;