Skip to content

Commit dc892fd

Browse files
committed
Support for subselects.
(Have to re-visit readfuncs.c)
1 parent 1a105ce commit dc892fd

File tree

4 files changed

+88
-5
lines changed

4 files changed

+88
-5
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.37 1998/02/10 04:00:44 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.38 1998/02/13 03:27:42 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -79,6 +79,8 @@ listCopy(List *list)
7979
static void
8080
CopyPlanFields(Plan *from, Plan *newnode)
8181
{
82+
extern List *SS_pull_subplan (void *expr);
83+
8284
newnode->cost = from->cost;
8385
newnode->plan_size = from->plan_size;
8486
newnode->plan_width = from->plan_width;
@@ -88,6 +90,15 @@ CopyPlanFields(Plan *from, Plan *newnode)
8890
newnode->qual = copyObject(from->qual);
8991
newnode->lefttree = copyObject(from->lefttree);
9092
newnode->righttree = copyObject(from->righttree);
93+
newnode->extParam = listCopy (from->extParam);
94+
newnode->locParam = listCopy (from->locParam);
95+
newnode->chgParam = listCopy (from->chgParam);
96+
Node_Copy(from, newnode, initPlan);
97+
if ( from->subPlan != NULL )
98+
newnode->subPlan = SS_pull_subplan (newnode->qual);
99+
else
100+
newnode->subPlan = NULL;
101+
newnode->nParamExec = from->nParamExec;
91102
}
92103

93104
/* ----------------
@@ -575,6 +586,22 @@ _copyHash(Hash *from)
575586
return newnode;
576587
}
577588

589+
static SubPlan *
590+
_copySubPlan(SubPlan *from)
591+
{
592+
SubPlan *newnode = makeNode(SubPlan);
593+
594+
Node_Copy(from, newnode, plan);
595+
newnode->plan_id = from->plan_id;
596+
Node_Copy(from, newnode, rtable);
597+
newnode->setParam = listCopy (from->setParam);
598+
newnode->parParam = listCopy (from->parParam);
599+
Node_Copy(from, newnode, sublink);
600+
newnode->shutdown = from->shutdown;
601+
602+
return newnode;
603+
}
604+
578605
/* ****************************************************************
579606
* primnodes.h copy functions
580607
* ****************************************************************
@@ -1661,6 +1688,9 @@ copyObject(void *from)
16611688
case T_Hash:
16621689
retval = _copyHash(from);
16631690
break;
1691+
case T_SubPlan:
1692+
retval = _copySubPlan(from);
1693+
break;
16641694

16651695
/*
16661696
* PRIMITIVE NODES

src/backend/nodes/equalfuncs.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.14 1998/02/10 04:00:47 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.15 1998/02/13 03:27:44 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -236,6 +236,7 @@ _equalParam(Param *a, Param *b)
236236
return (false);
237237
break;
238238
case PARAM_NUM:
239+
case PARAM_EXEC:
239240
if (a->paramid != b->paramid)
240241
return (false);
241242
break;
@@ -503,6 +504,18 @@ _equalIndexScan(IndexScan *a, IndexScan *b)
503504
return (true);
504505
}
505506

507+
static bool
508+
_equalSubPlan(SubPlan *a, SubPlan *b)
509+
{
510+
if (a->plan_id != b->plan_id)
511+
return (false);
512+
513+
if (!equal((a->sublink->oper), (b->sublink->oper)))
514+
return (false);
515+
516+
return (true);
517+
}
518+
506519
static bool
507520
_equalJInfo(JInfo *a, JInfo *b)
508521
{
@@ -680,6 +693,9 @@ equal(void *a, void *b)
680693
case T_IndexScan:
681694
retval = _equalIndexScan(a, b);
682695
break;
696+
case T_SubPlan:
697+
retval = _equalSubPlan(a, b);
698+
break;
683699
case T_JInfo:
684700
retval = _equalJInfo(a, b);
685701
break;

src/backend/nodes/outfuncs.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.29 1998/02/10 16:03:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.30 1998/02/13 03:27:45 vadim Exp $
1111
*
1212
* NOTES
1313
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -288,7 +288,14 @@ _outPlanInfo(StringInfo str, Plan *node)
288288
_outNode(str, node->lefttree);
289289
appendStringInfo(str, " :righttree ");
290290
_outNode(str, node->righttree);
291-
291+
appendStringInfo(str, " :extprm ");
292+
_outIntList(str, node->extParam);
293+
appendStringInfo(str, " :locprm ");
294+
_outIntList(str, node->locParam);
295+
appendStringInfo(str, " :initplan ");
296+
_outNode(str, node->initPlan);
297+
sprintf(buf, " :nprm %d ", node->nParamExec);
298+
appendStringInfo(str, buf);
292299
}
293300

294301
/*
@@ -408,6 +415,26 @@ _outHashJoin(StringInfo str, HashJoin *node)
408415
appendStringInfo(str, buf);
409416
}
410417

418+
static void
419+
_outSubPlan(StringInfo str, SubPlan *node)
420+
{
421+
char buf[500];
422+
423+
appendStringInfo(str, "SUBPLAN");
424+
appendStringInfo(str, " :plan ");
425+
_outNode(str, node->plan);
426+
sprintf(buf, " :planid %u ", node->plan_id);
427+
appendStringInfo(str, buf);
428+
appendStringInfo(str, " :rtable ");
429+
_outNode(str, node->rtable);
430+
appendStringInfo(str, " :setprm ");
431+
_outIntList (str, node->setParam);
432+
appendStringInfo(str, " :parprm ");
433+
_outIntList (str, node->parParam);
434+
appendStringInfo(str, " :slink ");
435+
_outNode(str, node->sublink);
436+
}
437+
411438
/*
412439
* Scan is a subclass of Node
413440
*/
@@ -674,6 +701,9 @@ _outExpr(StringInfo str, Expr *node)
674701
case NOT_EXPR:
675702
opstr = "not";
676703
break;
704+
case SUBPLAN_EXPR:
705+
opstr = "subp";
706+
break;
677707
}
678708
appendStringInfo(str, " :opType ");
679709
appendStringInfo(str, opstr);
@@ -1654,6 +1684,9 @@ _outNode(StringInfo str, void *obj)
16541684
case T_Hash:
16551685
_outHash(str, obj);
16561686
break;
1687+
case T_SubPlan:
1688+
_outSubPlan(str, obj);
1689+
break;
16571690
case T_Tee:
16581691
_outTee(str, obj);
16591692
break;

src/backend/nodes/readfuncs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.24 1998/02/10 16:03:23 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.25 1998/02/13 03:27:47 vadim Exp $
1111
*
1212
* NOTES
1313
* Most of the read functions for plan nodes are tested. (In fact, they
@@ -777,6 +777,10 @@ _readExpr()
777777
{
778778
local_node->opType = NOT_EXPR;
779779
}
780+
else if (!strncmp(token, "subp", 4))
781+
{
782+
local_node->opType = SUBPLAN_EXPR;
783+
}
780784

781785
token = lsptok(NULL, &length); /* eat :oper */
782786
local_node->oper = nodeRead(true);

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