Skip to content

Commit 6fcf2d7

Browse files
committed
New SubPlan node for subselects.
New PARAM_EXEC type.
1 parent eab1471 commit 6fcf2d7

File tree

5 files changed

+83
-30
lines changed

5 files changed

+83
-30
lines changed

src/include/nodes/execnodes.h

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: execnodes.h,v 1.12 1997/09/08 21:52:40 momjian Exp $
9+
* $Id: execnodes.h,v 1.13 1998/02/13 03:45:22 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -80,16 +80,17 @@ typedef struct RelationInfo
8080
*/
8181
typedef struct ExprContext
8282
{
83-
NodeTag type;
84-
TupleTableSlot *ecxt_scantuple;
85-
TupleTableSlot *ecxt_innertuple;
86-
TupleTableSlot *ecxt_outertuple;
87-
Relation ecxt_relation;
88-
Index ecxt_relid;
89-
ParamListInfo ecxt_param_list_info;
90-
List *ecxt_range_table;
91-
Datum *ecxt_values; /* precomputed values for aggreg */
92-
char *ecxt_nulls; /* null flags for aggreg values */
83+
NodeTag type;
84+
TupleTableSlot *ecxt_scantuple;
85+
TupleTableSlot *ecxt_innertuple;
86+
TupleTableSlot *ecxt_outertuple;
87+
Relation ecxt_relation;
88+
Index ecxt_relid;
89+
ParamListInfo ecxt_param_list_info;
90+
ParamExecData *ecxt_param_exec_vals; /* this is for subselects */
91+
List *ecxt_range_table;
92+
Datum *ecxt_values; /* precomputed values for aggreg */
93+
char *ecxt_nulls; /* null flags for aggreg values */
9394
} ExprContext;
9495

9596
/* ----------------
@@ -193,18 +194,19 @@ typedef struct JunkFilter
193194
*/
194195
typedef struct EState
195196
{
196-
NodeTag type;
197-
ScanDirection es_direction;
198-
List *es_range_table;
199-
RelationInfo *es_result_relation_info;
200-
Relation es_into_relation_descriptor;
201-
ParamListInfo es_param_list_info;
202-
int es_BaseId;
203-
TupleTable es_tupleTable;
204-
JunkFilter *es_junkFilter;
205-
int *es_refcount;
206-
uint32 es_processed; /* # of tuples processed */
207-
Oid es_lastoid; /* last oid processed (by INSERT) */
197+
NodeTag type;
198+
ScanDirection es_direction;
199+
List *es_range_table;
200+
RelationInfo *es_result_relation_info;
201+
Relation es_into_relation_descriptor;
202+
ParamListInfo es_param_list_info;
203+
ParamExecData *es_param_exec_vals; /* this is for subselects */
204+
int es_BaseId;
205+
TupleTable es_tupleTable;
206+
JunkFilter *es_junkFilter;
207+
int *es_refcount;
208+
uint32 es_processed; /* # of tuples processed */
209+
Oid es_lastoid; /* last oid processed (by INSERT) */
208210
} EState;
209211

210212
/* ----------------
@@ -292,7 +294,8 @@ typedef struct CommonState
292294
typedef struct ResultState
293295
{
294296
CommonState cstate; /* its first field is NodeTag */
295-
int rs_done;
297+
bool rs_done;
298+
bool rs_checkqual;
296299
} ResultState;
297300

298301
/* ----------------

src/include/nodes/nodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nodes.h,v 1.23 1998/01/17 04:53:38 momjian Exp $
9+
* $Id: nodes.h,v 1.24 1998/02/13 03:45:23 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -47,6 +47,7 @@ typedef enum NodeTag
4747
T_Choose,
4848
T_Tee,
4949
T_Group,
50+
T_SubPlan,
5051

5152
/*---------------------
5253
* TAGS FOR PRIMITIVE NODES (primnodes.h)

src/include/nodes/params.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: params.h,v 1.6 1997/09/08 21:52:48 momjian Exp $
9+
* $Id: params.h,v 1.7 1998/02/13 03:45:24 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -36,12 +36,16 @@
3636
*
3737
* PARAM_OLD: Same as PARAM_NEW, but in this case we refer to
3838
* the "OLD" tuple.
39+
*
40+
* PARAM_EXEC: Evaluated by executor. Used for subselect...
41+
*
3942
*/
4043

4144
#define PARAM_NAMED 11
4245
#define PARAM_NUM 12
4346
#define PARAM_NEW 13
4447
#define PARAM_OLD 14
48+
#define PARAM_EXEC 15
4549
#define PARAM_INVALID 100
4650

4751

@@ -87,4 +91,11 @@ typedef struct ParamListInfoData
8791

8892
typedef ParamListInfoData *ParamListInfo;
8993

94+
typedef struct ParamExecData
95+
{
96+
void *execPlan; /* plan must be executed to get param value */
97+
Datum value;
98+
bool isnull;
99+
} ParamExecData;
100+
90101
#endif /* PARAMS_H */

src/include/nodes/plannodes.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: plannodes.h,v 1.13 1998/01/15 19:00:13 momjian Exp $
9+
* $Id: plannodes.h,v 1.14 1998/02/13 03:45:25 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -74,6 +74,24 @@ typedef struct Plan
7474
List *qual; /* Node* or List* ?? */
7575
struct Plan *lefttree;
7676
struct Plan *righttree;
77+
List *extParam; /* indices of _all_ _external_ PARAM_EXEC for
78+
* this plan in global es_param_exec_vals.
79+
* Params from setParam from initPlan-s
80+
* are not included, but their execParam-s
81+
* are here!!! */
82+
List *locParam; /* someones from setParam-s */
83+
List *chgParam; /* list of changed ones from the above */
84+
List *initPlan; /* Init Plan nodes (un-correlated expr subselects) */
85+
List *subPlan; /* Other SubPlan nodes */
86+
87+
/*
88+
* We really need in some TopPlan node to store range table and
89+
* resultRelation from Query there and get rid of Query itself
90+
* from Executor. Some other stuff like below could be put there, too.
91+
*/
92+
int nParamExec; /* Number of them in entire query. This is
93+
* to get Executor know about how many
94+
* param_exec there are in query plan. */
7795
} Plan;
7896

7997
/* ----------------
@@ -335,4 +353,24 @@ typedef struct Tee
335353
* plans */
336354
} Tee;
337355

356+
/* ---------------------
357+
* SubPlan node
358+
* ---------------------
359+
*/
360+
typedef struct SubPlan
361+
{
362+
NodeTag type;
363+
Plan *plan; /* subselect plan itself */
364+
int plan_id; /* dummy thing because of we haven't
365+
* equal funcs for plan nodes... actually,
366+
* we could put *plan itself somewhere else
367+
* (TopPlan node ?)... */
368+
List *rtable; /* range table */
369+
List *setParam; /* non-correlated EXPR & EXISTS subqueries
370+
* have to set some Params for paren Plan */
371+
List *parParam; /* indices of corr. Vars from parent plan */
372+
SubLink *sublink; /* SubLink node for subselects in WHERE and HAVING */
373+
bool shutdown; /* shutdown plan if TRUE */
374+
} SubPlan;
375+
338376
#endif /* PLANNODES_H */

src/include/nodes/primnodes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: primnodes.h,v 1.18 1998/02/10 16:04:27 momjian Exp $
9+
* $Id: primnodes.h,v 1.19 1998/02/13 03:45:29 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -86,15 +86,15 @@ typedef struct Fjoin
8686
*/
8787
typedef enum OpType
8888
{
89-
OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR
89+
OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR, SUBPLAN_EXPR
9090
} OpType;
9191

9292
typedef struct Expr
9393
{
9494
NodeTag type;
9595
Oid typeOid; /* oid of the type of this expr */
9696
OpType opType; /* type of the op */
97-
Node *oper; /* could be Oper or Func */
97+
Node *oper; /* could be Oper or Func or SubPlan */
9898
List *args; /* list of argument nodes */
9999
} Expr;
100100

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy