From 5d7923dd1cd8fb8804a905a8b61c78c36ed512e6 Mon Sep 17 00:00:00 2001
From: "Vadim B. Mikheev" <vadim4o@yahoo.com>
Date: Fri, 13 Feb 1998 03:46:56 +0000
Subject: [PATCH] Subselects...

---
 src/include/executor/executor.h     |  3 ++-
 src/include/executor/nodeAgg.h      |  3 ++-
 src/include/executor/nodeHash.h     |  3 ++-
 src/include/executor/nodeHashjoin.h |  3 ++-
 src/include/executor/nodeMaterial.h |  6 ++++--
 src/include/executor/nodeNestloop.h |  3 ++-
 src/include/executor/nodeResult.h   |  3 ++-
 src/include/executor/nodeSubplan.h  | 20 ++++++++++++++++++++
 src/include/optimizer/clauses.h     |  6 +++++-
 src/include/optimizer/planner.h     |  3 ++-
 src/include/optimizer/subselect.h   | 20 ++++++++++++++++++++
 11 files changed, 63 insertions(+), 10 deletions(-)
 create mode 100644 src/include/executor/nodeSubplan.h
 create mode 100644 src/include/optimizer/subselect.h

diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index e5251886bc5..6769c5df76c 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: executor.h,v 1.19 1998/02/10 04:02:19 momjian Exp $
+ * $Id: executor.h,v 1.20 1998/02/13 03:43:33 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -108,6 +108,7 @@ extern void ExecInitOuterTupleSlot(EState *estate, HashJoinState *hashstate);
 
 extern TupleDesc ExecGetTupType(Plan *node);
 extern TupleDesc ExecTypeFromTL(List *targetList);
+extern void SetChangedParamList (Plan *node, List *newchg);
 
 /*
  * prototypes from functions in execTuples.c
diff --git a/src/include/executor/nodeAgg.h b/src/include/executor/nodeAgg.h
index 69f791b9c9a..ca8de787d17 100644
--- a/src/include/executor/nodeAgg.h
+++ b/src/include/executor/nodeAgg.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeAgg.h,v 1.6 1997/11/26 01:12:40 momjian Exp $
+ * $Id: nodeAgg.h,v 1.7 1998/02/13 03:43:34 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,5 +21,6 @@ extern TupleTableSlot *ExecAgg(Agg *node);
 extern bool ExecInitAgg(Agg *node, EState *estate, Plan *parent);
 extern int	ExecCountSlotsAgg(Agg *node);
 extern void ExecEndAgg(Agg *node);
+extern void ExecReScanAgg(Agg *node, ExprContext *exprCtxt, Plan *parent);
 
 #endif							/* NODEAGG_H */
diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h
index 6071eeb874a..a814c61ed6f 100644
--- a/src/include/executor/nodeHash.h
+++ b/src/include/executor/nodeHash.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeHash.h,v 1.7 1998/01/24 22:49:01 momjian Exp $
+ * $Id: nodeHash.h,v 1.8 1998/02/13 03:43:35 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -35,5 +35,6 @@ extern HeapTuple ExecScanHashBucket(HashJoinState *hjstate, HashBucket bucket,
 				   HeapTuple curtuple, List *hjclauses,
 				   ExprContext *econtext);
 extern void ExecHashTableReset(HashJoinTable hashtable, int ntuples);
+extern void ExecReScanHash(Hash *node, ExprContext *exprCtxt, Plan *parent);
 
 #endif							/* NODEHASH_H */
diff --git a/src/include/executor/nodeHashjoin.h b/src/include/executor/nodeHashjoin.h
index 2acbddf0384..e88e1a67cf4 100644
--- a/src/include/executor/nodeHashjoin.h
+++ b/src/include/executor/nodeHashjoin.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeHashjoin.h,v 1.7 1998/01/24 22:49:04 momjian Exp $
+ * $Id: nodeHashjoin.h,v 1.8 1998/02/13 03:43:36 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -23,6 +23,7 @@ extern int	ExecCountSlotsHashJoin(HashJoin *node);
 extern void ExecEndHashJoin(HashJoin *node);
 extern char * ExecHashJoinSaveTuple(HeapTuple heapTuple, char *buffer,
 					  File file, char *position);
+extern void ExecReScanHashJoin(HashJoin *node, ExprContext *exprCtxt, Plan *parent);
 
 
 #endif							/* NODEHASHJOIN_H */
diff --git a/src/include/executor/nodeMaterial.h b/src/include/executor/nodeMaterial.h
index de010d3ab21..1c612ea4fa4 100644
--- a/src/include/executor/nodeMaterial.h
+++ b/src/include/executor/nodeMaterial.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeMaterial.h,v 1.5 1997/11/26 01:12:53 momjian Exp $
+ * $Id: nodeMaterial.h,v 1.6 1998/02/13 03:43:37 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,7 +21,9 @@ extern TupleTableSlot *ExecMaterial(Material *node);
 extern bool ExecInitMaterial(Material *node, EState *estate, Plan *parent);
 extern int	ExecCountSlotsMaterial(Material *node);
 extern void ExecEndMaterial(Material *node);
+extern void ExecMaterialReScan(Material *node, ExprContext *exprCtxt, Plan *parent);
+#if 0
 extern List ExecMaterialMarkPos(Material *node);
 extern void ExecMaterialRestrPos(Material *node);
-
+#endif
 #endif							/* NODEMATERIAL_H */
diff --git a/src/include/executor/nodeNestloop.h b/src/include/executor/nodeNestloop.h
index ec08d3a9ed8..50d2f49820f 100644
--- a/src/include/executor/nodeNestloop.h
+++ b/src/include/executor/nodeNestloop.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeNestloop.h,v 1.5 1997/11/26 01:12:57 momjian Exp $
+ * $Id: nodeNestloop.h,v 1.6 1998/02/13 03:43:38 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,5 +21,6 @@ extern TupleTableSlot *ExecNestLoop(NestLoop *node, Plan *parent);
 extern bool ExecInitNestLoop(NestLoop *node, EState *estate, Plan *parent);
 extern int	ExecCountSlotsNestLoop(NestLoop *node);
 extern void ExecEndNestLoop(NestLoop *node);
+extern void ExecReScanNestLoop(NestLoop *node, ExprContext *exprCtxt, Plan *parent);
 
 #endif							/* NODENESTLOOP_H */
diff --git a/src/include/executor/nodeResult.h b/src/include/executor/nodeResult.h
index e3ebe2241e6..fffdf52e6ab 100644
--- a/src/include/executor/nodeResult.h
+++ b/src/include/executor/nodeResult.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nodeResult.h,v 1.5 1997/11/26 01:12:58 momjian Exp $
+ * $Id: nodeResult.h,v 1.6 1998/02/13 03:43:39 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,5 +21,6 @@ extern TupleTableSlot *ExecResult(Result *node);
 extern bool ExecInitResult(Result *node, EState *estate, Plan *parent);
 extern int	ExecCountSlotsResult(Result *node);
 extern void ExecEndResult(Result *node);
+extern void ExecReScanResult(Result *node, ExprContext *exprCtxt, Plan *parent);
 
 #endif							/* NODERESULT_H */
diff --git a/src/include/executor/nodeSubplan.h b/src/include/executor/nodeSubplan.h
new file mode 100644
index 00000000000..6fa8945482e
--- /dev/null
+++ b/src/include/executor/nodeSubplan.h
@@ -0,0 +1,20 @@
+/*-------------------------------------------------------------------------
+ *
+ * nodeSubplan.h--
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef NODESUBPLAN_H
+#define NODESUBPLAN_H
+
+#include "executor/tuptable.h"
+#include "nodes/execnodes.h"
+#include "nodes/plannodes.h"
+
+extern Datum ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext);
+extern bool ExecInitSubPlan(SubPlan *node, EState *estate, Plan *parent);
+extern void ExecReScanSetParamPlan (SubPlan *node, Plan *parent);
+extern void ExecSetParamPlan (SubPlan *node);
+extern void ExecEndSubPlan(SubPlan *node);
+
+#endif							/* NODESUBPLAN_H */
diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h
index 8df238e8ea4..60ca943fb51 100644
--- a/src/include/optimizer/clauses.h
+++ b/src/include/optimizer/clauses.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: clauses.h,v 1.8 1998/01/24 22:49:39 momjian Exp $
+ * $Id: clauses.h,v 1.9 1998/02/13 03:46:54 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -48,4 +48,8 @@ extern void get_rels_atts(Node *clause, int *relid1,
 			  AttrNumber *attno1, int *relid2, AttrNumber *attno2);
 extern void CommuteClause(Node *clause);
 
+#define	is_subplan(clause)	((Node*) clause != NULL && \
+						nodeTag((Node*) clause) == T_Expr && \
+						((Expr *) clause)->opType == SUBPLAN_EXPR)
+
 #endif							/* CLAUSES_H */
diff --git a/src/include/optimizer/planner.h b/src/include/optimizer/planner.h
index 86b3023aa01..38782d3a2c2 100644
--- a/src/include/optimizer/planner.h
+++ b/src/include/optimizer/planner.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: planner.h,v 1.7 1997/11/26 01:13:49 momjian Exp $
+ * $Id: planner.h,v 1.8 1998/02/13 03:46:56 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,6 +21,7 @@
 #include "parser/parse_node.h"
 
 extern Plan *planner(Query *parse);
+extern Plan *union_planner(Query *parse);
 extern void pg_checkretval(Oid rettype, QueryTreeList *querytree_list);
 
 #endif							/* PLANNER_H */
diff --git a/src/include/optimizer/subselect.h b/src/include/optimizer/subselect.h
new file mode 100644
index 00000000000..64f9851909e
--- /dev/null
+++ b/src/include/optimizer/subselect.h
@@ -0,0 +1,20 @@
+/*-------------------------------------------------------------------------
+ *
+ * subselect.h--
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef SUBSELECT_H
+#define SUBSELECT_H
+
+extern int		PlannerQueryLevel;		/* level of current query */
+extern List	   *PlannerVarParam;		/* correlation Vars to Param mapper */
+extern List	   *PlannerParamVar;		/* to get Var from Param->paramid */
+extern List	   *PlannerInitPlan;		/* init subplans for current query */
+extern int		PlannerPlanId;			/* to assigne unique ID to subquery plans */
+
+extern List	   *SS_finalize_plan (Plan *plan);
+extern Node	   *SS_replace_correlation_vars (Node *expr);
+extern Node	   *SS_process_sublinks (Node *expr);
+
+#endif							/* SUBSELECT_H */
-- 
GitLab