Commit 6fcf2d7c authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

New SubPlan node for subselects.

New PARAM_EXEC type.
parent eab1471b
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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 ...@@ -80,16 +80,17 @@ typedef struct RelationInfo
*/ */
typedef struct ExprContext typedef struct ExprContext
{ {
NodeTag type; NodeTag type;
TupleTableSlot *ecxt_scantuple; TupleTableSlot *ecxt_scantuple;
TupleTableSlot *ecxt_innertuple; TupleTableSlot *ecxt_innertuple;
TupleTableSlot *ecxt_outertuple; TupleTableSlot *ecxt_outertuple;
Relation ecxt_relation; Relation ecxt_relation;
Index ecxt_relid; Index ecxt_relid;
ParamListInfo ecxt_param_list_info; ParamListInfo ecxt_param_list_info;
List *ecxt_range_table; ParamExecData *ecxt_param_exec_vals; /* this is for subselects */
Datum *ecxt_values; /* precomputed values for aggreg */ List *ecxt_range_table;
char *ecxt_nulls; /* null flags for aggreg values */ Datum *ecxt_values; /* precomputed values for aggreg */
char *ecxt_nulls; /* null flags for aggreg values */
} ExprContext; } ExprContext;
/* ---------------- /* ----------------
...@@ -193,18 +194,19 @@ typedef struct JunkFilter ...@@ -193,18 +194,19 @@ typedef struct JunkFilter
*/ */
typedef struct EState typedef struct EState
{ {
NodeTag type; NodeTag type;
ScanDirection es_direction; ScanDirection es_direction;
List *es_range_table; List *es_range_table;
RelationInfo *es_result_relation_info; RelationInfo *es_result_relation_info;
Relation es_into_relation_descriptor; Relation es_into_relation_descriptor;
ParamListInfo es_param_list_info; ParamListInfo es_param_list_info;
int es_BaseId; ParamExecData *es_param_exec_vals; /* this is for subselects */
TupleTable es_tupleTable; int es_BaseId;
JunkFilter *es_junkFilter; TupleTable es_tupleTable;
int *es_refcount; JunkFilter *es_junkFilter;
uint32 es_processed; /* # of tuples processed */ int *es_refcount;
Oid es_lastoid; /* last oid processed (by INSERT) */ uint32 es_processed; /* # of tuples processed */
Oid es_lastoid; /* last oid processed (by INSERT) */
} EState; } EState;
/* ---------------- /* ----------------
...@@ -292,7 +294,8 @@ typedef struct CommonState ...@@ -292,7 +294,8 @@ typedef struct CommonState
typedef struct ResultState typedef struct ResultState
{ {
CommonState cstate; /* its first field is NodeTag */ CommonState cstate; /* its first field is NodeTag */
int rs_done; bool rs_done;
bool rs_checkqual;
} ResultState; } ResultState;
/* ---------------- /* ----------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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 ...@@ -47,6 +47,7 @@ typedef enum NodeTag
T_Choose, T_Choose,
T_Tee, T_Tee,
T_Group, T_Group,
T_SubPlan,
/*--------------------- /*---------------------
* TAGS FOR PRIMITIVE NODES (primnodes.h) * TAGS FOR PRIMITIVE NODES (primnodes.h)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -36,12 +36,16 @@ ...@@ -36,12 +36,16 @@
* *
* PARAM_OLD: Same as PARAM_NEW, but in this case we refer to * PARAM_OLD: Same as PARAM_NEW, but in this case we refer to
* the "OLD" tuple. * the "OLD" tuple.
*
* PARAM_EXEC: Evaluated by executor. Used for subselect...
*
*/ */
#define PARAM_NAMED 11 #define PARAM_NAMED 11
#define PARAM_NUM 12 #define PARAM_NUM 12
#define PARAM_NEW 13 #define PARAM_NEW 13
#define PARAM_OLD 14 #define PARAM_OLD 14
#define PARAM_EXEC 15
#define PARAM_INVALID 100 #define PARAM_INVALID 100
...@@ -87,4 +91,11 @@ typedef struct ParamListInfoData ...@@ -87,4 +91,11 @@ typedef struct ParamListInfoData
typedef ParamListInfoData *ParamListInfo; typedef ParamListInfoData *ParamListInfo;
typedef struct ParamExecData
{
void *execPlan; /* plan must be executed to get param value */
Datum value;
bool isnull;
} ParamExecData;
#endif /* PARAMS_H */ #endif /* PARAMS_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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 ...@@ -74,6 +74,24 @@ typedef struct Plan
List *qual; /* Node* or List* ?? */ List *qual; /* Node* or List* ?? */
struct Plan *lefttree; struct Plan *lefttree;
struct Plan *righttree; 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; } Plan;
/* ---------------- /* ----------------
...@@ -335,4 +353,24 @@ typedef struct Tee ...@@ -335,4 +353,24 @@ typedef struct Tee
* plans */ * plans */
} Tee; } 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 */ #endif /* PLANNODES_H */
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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 ...@@ -86,7 +86,7 @@ typedef struct Fjoin
*/ */
typedef enum OpType 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; } OpType;
typedef struct Expr typedef struct Expr
...@@ -94,7 +94,7 @@ typedef struct Expr ...@@ -94,7 +94,7 @@ typedef struct Expr
NodeTag type; NodeTag type;
Oid typeOid; /* oid of the type of this expr */ Oid typeOid; /* oid of the type of this expr */
OpType opType; /* type of the op */ 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 */ List *args; /* list of argument nodes */
} Expr; } Expr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment