Support for subselects.
(Have to re-visit readfuncs.c)
This commit is contained in:
parent
1a105cefbd
commit
dc892fd390
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
static void
|
||||
CopyPlanFields(Plan *from, Plan *newnode)
|
||||
{
|
||||
extern List *SS_pull_subplan (void *expr);
|
||||
|
||||
newnode->cost = from->cost;
|
||||
newnode->plan_size = from->plan_size;
|
||||
newnode->plan_width = from->plan_width;
|
||||
@ -88,6 +90,15 @@ CopyPlanFields(Plan *from, Plan *newnode)
|
||||
newnode->qual = copyObject(from->qual);
|
||||
newnode->lefttree = copyObject(from->lefttree);
|
||||
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)
|
||||
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
|
||||
* ****************************************************************
|
||||
@ -1661,6 +1688,9 @@ copyObject(void *from)
|
||||
case T_Hash:
|
||||
retval = _copyHash(from);
|
||||
break;
|
||||
case T_SubPlan:
|
||||
retval = _copySubPlan(from);
|
||||
break;
|
||||
|
||||
/*
|
||||
* PRIMITIVE NODES
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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)
|
||||
return (false);
|
||||
break;
|
||||
case PARAM_NUM:
|
||||
case PARAM_EXEC:
|
||||
if (a->paramid != b->paramid)
|
||||
return (false);
|
||||
break;
|
||||
@ -503,6 +504,18 @@ _equalIndexScan(IndexScan *a, IndexScan *b)
|
||||
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
|
||||
_equalJInfo(JInfo *a, JInfo *b)
|
||||
{
|
||||
@ -680,6 +693,9 @@ equal(void *a, void *b)
|
||||
case T_IndexScan:
|
||||
retval = _equalIndexScan(a, b);
|
||||
break;
|
||||
case T_SubPlan:
|
||||
retval = _equalSubPlan(a, b);
|
||||
break;
|
||||
case T_JInfo:
|
||||
retval = _equalJInfo(a, b);
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||
@ -288,7 +288,14 @@ _outPlanInfo(StringInfo str, Plan *node)
|
||||
_outNode(str, node->lefttree);
|
||||
appendStringInfo(str, " :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)
|
||||
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
|
||||
*/
|
||||
@ -674,6 +701,9 @@ _outExpr(StringInfo str, Expr *node)
|
||||
case NOT_EXPR:
|
||||
opstr = "not";
|
||||
break;
|
||||
case SUBPLAN_EXPR:
|
||||
opstr = "subp";
|
||||
break;
|
||||
}
|
||||
appendStringInfo(str, " :opType ");
|
||||
appendStringInfo(str, opstr);
|
||||
@ -1654,6 +1684,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_Hash:
|
||||
_outHash(str, obj);
|
||||
break;
|
||||
case T_SubPlan:
|
||||
_outSubPlan(str, obj);
|
||||
break;
|
||||
case T_Tee:
|
||||
_outTee(str, obj);
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* Most of the read functions for plan nodes are tested. (In fact, they
|
||||
@ -777,6 +777,10 @@ _readExpr()
|
||||
{
|
||||
local_node->opType = NOT_EXPR;
|
||||
}
|
||||
else if (!strncmp(token, "subp", 4))
|
||||
{
|
||||
local_node->opType = SUBPLAN_EXPR;
|
||||
}
|
||||
|
||||
token = lsptok(NULL, &length); /* eat :oper */
|
||||
local_node->oper = nodeRead(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user