]> granicus.if.org Git - postgresql/commitdiff
New SubPlan node for subselects.
authorVadim B. Mikheev <vadim4o@yahoo.com>
Fri, 13 Feb 1998 03:45:29 +0000 (03:45 +0000)
committerVadim B. Mikheev <vadim4o@yahoo.com>
Fri, 13 Feb 1998 03:45:29 +0000 (03:45 +0000)
New PARAM_EXEC type.

src/include/nodes/execnodes.h
src/include/nodes/nodes.h
src/include/nodes/params.h
src/include/nodes/plannodes.h
src/include/nodes/primnodes.h

index 7a6fdcab94eaaa90b465b9da696144602cd10bf1..bc40d3e96a3ad6362e0c94a844802dc31b213a4d 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: execnodes.h,v 1.12 1997/09/08 21:52:40 momjian Exp $
+ * $Id: execnodes.h,v 1.13 1998/02/13 03:45:22 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -80,16 +80,17 @@ typedef struct RelationInfo
  */
 typedef struct ExprContext
 {
-       NodeTag         type;
-       TupleTableSlot *ecxt_scantuple;
-       TupleTableSlot *ecxt_innertuple;
-       TupleTableSlot *ecxt_outertuple;
-       Relation        ecxt_relation;
-       Index           ecxt_relid;
-       ParamListInfo ecxt_param_list_info;
-       List       *ecxt_range_table;
-       Datum      *ecxt_values;        /* precomputed values for aggreg */
-       char       *ecxt_nulls;         /* null flags for aggreg  values */
+       NodeTag                         type;
+       TupleTableSlot     *ecxt_scantuple;
+       TupleTableSlot     *ecxt_innertuple;
+       TupleTableSlot     *ecxt_outertuple;
+       Relation                        ecxt_relation;
+       Index                           ecxt_relid;
+       ParamListInfo           ecxt_param_list_info;
+       ParamExecData      *ecxt_param_exec_vals;       /* this is for subselects */
+       List                       *ecxt_range_table;
+       Datum                      *ecxt_values;        /* precomputed values for aggreg */
+       char                       *ecxt_nulls;         /* null flags for aggreg  values */
 } ExprContext;
 
 /* ----------------
@@ -193,18 +194,19 @@ typedef struct JunkFilter
  */
 typedef struct EState
 {
-       NodeTag         type;
-       ScanDirection es_direction;
-       List       *es_range_table;
-       RelationInfo *es_result_relation_info;
-       Relation        es_into_relation_descriptor;
-       ParamListInfo es_param_list_info;
-       int                     es_BaseId;
-       TupleTable      es_tupleTable;
-       JunkFilter *es_junkFilter;
-       int                *es_refcount;
-       uint32          es_processed;   /* # of tuples processed */
-       Oid                     es_lastoid;             /* last oid processed (by INSERT) */
+       NodeTag                         type;
+       ScanDirection           es_direction;
+       List                       *es_range_table;
+       RelationInfo       *es_result_relation_info;
+       Relation                        es_into_relation_descriptor;
+       ParamListInfo           es_param_list_info;
+       ParamExecData      *es_param_exec_vals; /* this is for subselects */
+       int                                     es_BaseId;
+       TupleTable                      es_tupleTable;
+       JunkFilter                 *es_junkFilter;
+       int                                *es_refcount;
+       uint32                          es_processed;   /* # of tuples processed */
+       Oid                                     es_lastoid;             /* last oid processed (by INSERT) */
 } EState;
 
 /* ----------------
@@ -292,7 +294,8 @@ typedef struct CommonState
 typedef struct ResultState
 {
        CommonState cstate;                     /* its first field is NodeTag */
-       int                     rs_done;
+       bool            rs_done;
+       bool            rs_checkqual;
 } ResultState;
 
 /* ----------------
index 9c913797dd4b01a01106585049468906978ba5df..d205f4236a3ad75b1786eeb28875ed325855e18a 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodes.h,v 1.23 1998/01/17 04:53:38 momjian Exp $
+ * $Id: nodes.h,v 1.24 1998/02/13 03:45:23 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -47,6 +47,7 @@ typedef enum NodeTag
        T_Choose,
        T_Tee,
        T_Group,
+       T_SubPlan,
 
        /*---------------------
         * TAGS FOR PRIMITIVE NODES (primnodes.h)
index 083c5faed41fae5897b392d81be18814cf0ce1c4..7a70a888b4530c303b4904365c22fdc0e250e161 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: params.h,v 1.6 1997/09/08 21:52:48 momjian Exp $
+ * $Id: params.h,v 1.7 1998/02/13 03:45:24 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
  *
  * PARAM_OLD:  Same as PARAM_NEW, but in this case we refer to
  *                             the "OLD" tuple.
+ *
+ * PARAM_EXEC: Evaluated by executor. Used for subselect...
+ *
  */
 
 #define PARAM_NAMED            11
 #define PARAM_NUM              12
 #define PARAM_NEW              13
 #define PARAM_OLD              14
+#define        PARAM_EXEC              15
 #define PARAM_INVALID  100
 
 
@@ -87,4 +91,11 @@ typedef struct ParamListInfoData
 
 typedef ParamListInfoData *ParamListInfo;
 
+typedef struct ParamExecData
+{
+       void       *execPlan;           /* plan must be executed to get param value */
+       Datum           value;
+       bool            isnull;
+} ParamExecData;
+
 #endif                                                 /* PARAMS_H */
index 871afacbc4b71a91a4c7791c21e4a107df5553b0..0091891aaeaf2adfe16dcc02093ff78ccb8627cc 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: plannodes.h,v 1.13 1998/01/15 19:00:13 momjian Exp $
+ * $Id: plannodes.h,v 1.14 1998/02/13 03:45:25 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -74,6 +74,24 @@ typedef struct Plan
        List       *qual;                       /* Node* or List* ?? */
        struct Plan *lefttree;
        struct Plan *righttree;
+       List       *extParam;           /* indices of _all_ _external_ PARAM_EXEC for 
+                                                                * this plan in global es_param_exec_vals.
+                                                                * Params from setParam from initPlan-s
+                                                                * are not included, but their execParam-s 
+                                                                * are here!!! */
+       List       *locParam;           /* someones from setParam-s */
+       List       *chgParam;           /* list of changed ones from the above */
+       List       *initPlan;           /* Init Plan nodes (un-correlated expr subselects) */
+       List       *subPlan;            /* Other SubPlan nodes */
+       
+       /* 
+        * We really need in some TopPlan node to store range table and
+        * resultRelation from Query there and get rid of Query itself
+        * from Executor. Some other stuff like below could be put there, too.
+        */
+       int                     nParamExec;             /* Number of them in entire query. This is
+                                                                * to get Executor know about how many
+                                                                * param_exec there are in query plan. */
 } Plan;
 
 /* ----------------
@@ -335,4 +353,24 @@ typedef struct Tee
                                                                 * plans */
 } Tee;
 
+/* ---------------------
+ *             SubPlan node
+ * ---------------------
+ */
+typedef struct SubPlan
+{
+       NodeTag                 type;
+       Plan               *plan;               /* subselect plan itself */
+       int                             plan_id;        /* dummy thing because of we haven't
+                                                                * equal funcs for plan nodes... actually,
+                                                                * we could put *plan itself somewhere else
+                                                                * (TopPlan node ?)... */
+       List               *rtable;             /* range table */
+       List               *setParam;   /* non-correlated EXPR & EXISTS subqueries
+                                                                * have to set some Params for paren Plan */
+       List               *parParam;   /* indices of corr. Vars from parent plan */
+       SubLink            *sublink;    /* SubLink node for subselects in WHERE and HAVING */
+       bool                    shutdown;       /* shutdown plan if TRUE */
+} SubPlan;
+
 #endif                                                 /* PLANNODES_H */
index 6a37bc1b204bb07358637d72d4011fd180be42c2..a16e2ee4c08b01d3a51486619b3a64ae50f898c7 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: primnodes.h,v 1.18 1998/02/10 16:04:27 momjian Exp $
+ * $Id: primnodes.h,v 1.19 1998/02/13 03:45:29 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -86,7 +86,7 @@ typedef struct Fjoin
  */
 typedef enum OpType
 {
-       OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR
+       OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR, SUBPLAN_EXPR
 } OpType;
 
 typedef struct Expr
@@ -94,7 +94,7 @@ typedef struct Expr
        NodeTag         type;
        Oid                     typeOid;                /* oid of the type of this expr */
        OpType          opType;                 /* type of the op */
-       Node       *oper;                       /* could be Oper or Func */
+       Node       *oper;                       /* could be Oper or Func or SubPlan */
        List       *args;                       /* list of argument nodes */
 } Expr;