New SubPlan node for subselects.

New PARAM_EXEC type.
This commit is contained in:
Vadim B. Mikheev 1998-02-13 03:45:29 +00:00
parent eab1471b2b
commit 6fcf2d7cb3
5 changed files with 83 additions and 30 deletions

View 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;
/* ----------------

View 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)

View 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 $
*
*-------------------------------------------------------------------------
*/
@ -36,12 +36,16 @@
*
* 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 */

View 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 */

View 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;