Commit dc892fd3 authored by Vadim B. Mikheev's avatar Vadim B. Mikheev

Support for subselects.

(Have to re-visit readfuncs.c)
parent 1a105cef
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.37 1998/02/10 04:00:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.38 1998/02/13 03:27:42 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -79,6 +79,8 @@ listCopy(List *list) ...@@ -79,6 +79,8 @@ listCopy(List *list)
static void static void
CopyPlanFields(Plan *from, Plan *newnode) CopyPlanFields(Plan *from, Plan *newnode)
{ {
extern List *SS_pull_subplan (void *expr);
newnode->cost = from->cost; newnode->cost = from->cost;
newnode->plan_size = from->plan_size; newnode->plan_size = from->plan_size;
newnode->plan_width = from->plan_width; newnode->plan_width = from->plan_width;
...@@ -88,6 +90,15 @@ CopyPlanFields(Plan *from, Plan *newnode) ...@@ -88,6 +90,15 @@ CopyPlanFields(Plan *from, Plan *newnode)
newnode->qual = copyObject(from->qual); newnode->qual = copyObject(from->qual);
newnode->lefttree = copyObject(from->lefttree); newnode->lefttree = copyObject(from->lefttree);
newnode->righttree = copyObject(from->righttree); newnode->righttree = copyObject(from->righttree);
newnode->extParam = listCopy (from->extParam);
newnode->locParam = listCopy (from->locParam);
newnode->chgParam = listCopy (from->chgParam);
Node_Copy(from, newnode, initPlan);
if ( from->subPlan != NULL )
newnode->subPlan = SS_pull_subplan (newnode->qual);
else
newnode->subPlan = NULL;
newnode->nParamExec = from->nParamExec;
} }
/* ---------------- /* ----------------
...@@ -575,6 +586,22 @@ _copyHash(Hash *from) ...@@ -575,6 +586,22 @@ _copyHash(Hash *from)
return newnode; return newnode;
} }
static SubPlan *
_copySubPlan(SubPlan *from)
{
SubPlan *newnode = makeNode(SubPlan);
Node_Copy(from, newnode, plan);
newnode->plan_id = from->plan_id;
Node_Copy(from, newnode, rtable);
newnode->setParam = listCopy (from->setParam);
newnode->parParam = listCopy (from->parParam);
Node_Copy(from, newnode, sublink);
newnode->shutdown = from->shutdown;
return newnode;
}
/* **************************************************************** /* ****************************************************************
* primnodes.h copy functions * primnodes.h copy functions
* **************************************************************** * ****************************************************************
...@@ -1661,6 +1688,9 @@ copyObject(void *from) ...@@ -1661,6 +1688,9 @@ copyObject(void *from)
case T_Hash: case T_Hash:
retval = _copyHash(from); retval = _copyHash(from);
break; break;
case T_SubPlan:
retval = _copySubPlan(from);
break;
/* /*
* PRIMITIVE NODES * PRIMITIVE NODES
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.14 1998/02/10 04:00:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.15 1998/02/13 03:27:44 vadim Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -236,6 +236,7 @@ _equalParam(Param *a, Param *b) ...@@ -236,6 +236,7 @@ _equalParam(Param *a, Param *b)
return (false); return (false);
break; break;
case PARAM_NUM: case PARAM_NUM:
case PARAM_EXEC:
if (a->paramid != b->paramid) if (a->paramid != b->paramid)
return (false); return (false);
break; break;
...@@ -503,6 +504,18 @@ _equalIndexScan(IndexScan *a, IndexScan *b) ...@@ -503,6 +504,18 @@ _equalIndexScan(IndexScan *a, IndexScan *b)
return (true); return (true);
} }
static bool
_equalSubPlan(SubPlan *a, SubPlan *b)
{
if (a->plan_id != b->plan_id)
return (false);
if (!equal((a->sublink->oper), (b->sublink->oper)))
return (false);
return (true);
}
static bool static bool
_equalJInfo(JInfo *a, JInfo *b) _equalJInfo(JInfo *a, JInfo *b)
{ {
...@@ -680,6 +693,9 @@ equal(void *a, void *b) ...@@ -680,6 +693,9 @@ equal(void *a, void *b)
case T_IndexScan: case T_IndexScan:
retval = _equalIndexScan(a, b); retval = _equalIndexScan(a, b);
break; break;
case T_SubPlan:
retval = _equalSubPlan(a, b);
break;
case T_JInfo: case T_JInfo:
retval = _equalJInfo(a, b); retval = _equalJInfo(a, b);
break; break;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.29 1998/02/10 16:03:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.30 1998/02/13 03:27:45 vadim Exp $
* *
* NOTES * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
...@@ -288,7 +288,14 @@ _outPlanInfo(StringInfo str, Plan *node) ...@@ -288,7 +288,14 @@ _outPlanInfo(StringInfo str, Plan *node)
_outNode(str, node->lefttree); _outNode(str, node->lefttree);
appendStringInfo(str, " :righttree "); appendStringInfo(str, " :righttree ");
_outNode(str, node->righttree); _outNode(str, node->righttree);
appendStringInfo(str, " :extprm ");
_outIntList(str, node->extParam);
appendStringInfo(str, " :locprm ");
_outIntList(str, node->locParam);
appendStringInfo(str, " :initplan ");
_outNode(str, node->initPlan);
sprintf(buf, " :nprm %d ", node->nParamExec);
appendStringInfo(str, buf);
} }
/* /*
...@@ -408,6 +415,26 @@ _outHashJoin(StringInfo str, HashJoin *node) ...@@ -408,6 +415,26 @@ _outHashJoin(StringInfo str, HashJoin *node)
appendStringInfo(str, buf); appendStringInfo(str, buf);
} }
static void
_outSubPlan(StringInfo str, SubPlan *node)
{
char buf[500];
appendStringInfo(str, "SUBPLAN");
appendStringInfo(str, " :plan ");
_outNode(str, node->plan);
sprintf(buf, " :planid %u ", node->plan_id);
appendStringInfo(str, buf);
appendStringInfo(str, " :rtable ");
_outNode(str, node->rtable);
appendStringInfo(str, " :setprm ");
_outIntList (str, node->setParam);
appendStringInfo(str, " :parprm ");
_outIntList (str, node->parParam);
appendStringInfo(str, " :slink ");
_outNode(str, node->sublink);
}
/* /*
* Scan is a subclass of Node * Scan is a subclass of Node
*/ */
...@@ -674,6 +701,9 @@ _outExpr(StringInfo str, Expr *node) ...@@ -674,6 +701,9 @@ _outExpr(StringInfo str, Expr *node)
case NOT_EXPR: case NOT_EXPR:
opstr = "not"; opstr = "not";
break; break;
case SUBPLAN_EXPR:
opstr = "subp";
break;
} }
appendStringInfo(str, " :opType "); appendStringInfo(str, " :opType ");
appendStringInfo(str, opstr); appendStringInfo(str, opstr);
...@@ -1654,6 +1684,9 @@ _outNode(StringInfo str, void *obj) ...@@ -1654,6 +1684,9 @@ _outNode(StringInfo str, void *obj)
case T_Hash: case T_Hash:
_outHash(str, obj); _outHash(str, obj);
break; break;
case T_SubPlan:
_outSubPlan(str, obj);
break;
case T_Tee: case T_Tee:
_outTee(str, obj); _outTee(str, obj);
break; break;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.24 1998/02/10 16:03:23 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.25 1998/02/13 03:27:47 vadim Exp $
* *
* NOTES * NOTES
* Most of the read functions for plan nodes are tested. (In fact, they * Most of the read functions for plan nodes are tested. (In fact, they
...@@ -777,6 +777,10 @@ _readExpr() ...@@ -777,6 +777,10 @@ _readExpr()
{ {
local_node->opType = NOT_EXPR; local_node->opType = NOT_EXPR;
} }
else if (!strncmp(token, "subp", 4))
{
local_node->opType = SUBPLAN_EXPR;
}
token = lsptok(NULL, &length); /* eat :oper */ token = lsptok(NULL, &length); /* eat :oper */
local_node->oper = nodeRead(true); local_node->oper = nodeRead(true);
......
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