diff options
author | Bruce Momjian <bruce@momjian.us> | 1998-01-17 04:53:46 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1998-01-17 04:53:46 +0000 |
commit | b37bc65f44eb16e98212fc61b565bb86502812fd (patch) | |
tree | 0058866f3e0dcc08a98a534eee73cea7bd53bc3e /src/backend/nodes | |
parent | c65ea0e040f08b59407cd74f8f0f0dd190169d46 (diff) | |
download | postgresql-b37bc65f44eb16e98212fc61b565bb86502812fd.tar.gz postgresql-b37bc65f44eb16e98212fc61b565bb86502812fd.zip |
Creates the SubLink structure, and the Query->hasSubLink field,
with supporting code.
Creates SubLink node in gram.y.
psql.c patch for newatttypmod field.
Diffstat (limited to 'src/backend/nodes')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 28 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 28 | ||||
-rw-r--r-- | src/backend/nodes/readfuncs.c | 45 |
3 files changed, 98 insertions, 3 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index fe045539223..834cc8c2571 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.31 1998/01/16 23:19:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.32 1998/01/17 04:53:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -892,6 +892,28 @@ _copyAggreg(Aggreg *from) return newnode; } +/* ---------------- + * _copySubLink + * ---------------- + */ +static SubLink * +_copySubLink(SubLink *from) +{ + SubLink *newnode = makeNode(SubLink); + + /* ---------------- + * copy remainder of node + * ---------------- + */ + newnode->subLinkType = from->subLinkType; + newnode->useor = from->useor; + Node_Copy(from, newnode, lefthand); + Node_Copy(from, newnode, oper); + Node_Copy(from, newnode, subselect); + + return newnode; +} + static Array * _copyArray(Array *from) { @@ -1517,6 +1539,7 @@ _copyQuery(Query *from) Node_Copy(from, newnode, havingQual); newnode->hasAggs = from->hasAggs; + newnode->hasSubLinks = from->hasSubLinks; if (from->unionClause) { @@ -1673,6 +1696,9 @@ copyObject(void *from) case T_Aggreg: retval = _copyAggreg(from); break; + case T_SubLink: + retval = _copySubLink(from); + break; /* * RELATION NODES diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 41f3022c135..63c2ffef434 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.22 1998/01/16 23:19:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.23 1998/01/17 04:53:09 momjian Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -230,6 +230,8 @@ _outQuery(StringInfo str, Query *node) _outNode(str, node->havingQual); appendStringInfo(str, " :hasAggs "); appendStringInfo(str, (node->hasAggs ? "true" : "false")); + appendStringInfo(str, " :hasSubLinks "); + appendStringInfo(str, (node->hasSubLinks ? "true" : "false")); appendStringInfo(str, " :unionClause "); _outNode(str, node->unionClause); } @@ -754,6 +756,27 @@ _outAggreg(StringInfo str, Aggreg *node) } /* + * SubLink + */ +static void +_outSubLink(StringInfo str, SubLink *node) +{ + char buf[500]; + + appendStringInfo(str, "SUBLINK"); + sprintf(buf, " :subLinkType %d ", node->subLinkType); + appendStringInfo(str, buf); + appendStringInfo(str, " :useor "); + appendStringInfo(str, node->useor ? "true" : "false"); + appendStringInfo(str, " :lefthand "); + _outNode(str, node->lefthand); + appendStringInfo(str, " :oper "); + _outNode(str, node->oper); + appendStringInfo(str, " :subselect "); + _outNode(str, node->subselect); +} + +/* * Array is a subclass of Expr */ static void @@ -1648,6 +1671,9 @@ _outNode(StringInfo str, void *obj) case T_Aggreg: _outAggreg(str, obj); break; + case T_SubLink: + _outSubLink(str, obj); + break; case T_Array: _outArray(str, obj); break; diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 574d5c69e2c..e2c458e2933 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.18 1998/01/15 18:59:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.19 1998/01/17 04:53:11 momjian Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -156,6 +156,10 @@ _readQuery() token = lsptok(NULL, &length); /* get hasAggs */ local_node->hasAggs = (token[0] == 't') ? true : false; + token = lsptok(NULL, &length); /* skip the :hasSubLinks */ + token = lsptok(NULL, &length); /* get hasSubLinks */ + local_node->hasSubLinks = (token[0] == 't') ? true : false; + token = lsptok(NULL, &length); /* skip :unionClause */ local_node->unionClause = nodeRead(true); @@ -1151,6 +1155,41 @@ _readAggreg() return (local_node); } +/* ---------------- + * _readSubLink + * + * SubLink is a subclass of Node + * ---------------- + */ +static SubLink * +_readSubLink() +{ + SubLink *local_node; + char *token; + int length; + + local_node = makeNode(SubLink); + + token = lsptok(NULL, &length); /* eat :subLinkType */ + token = lsptok(NULL, &length); /* get subLinkType */ + local_node->subLinkType = atoi(token); + + token = lsptok(NULL, &length); /* eat :useor */ + token = lsptok(NULL, &length); /* get useor */ + local_node->useor = (token[0] == 't') ? true : false; + + token = lsptok(NULL, &length); /* eat :lefthand */ + local_node->lefthand = nodeRead(true); /* now read it */ + + token = lsptok(NULL, &length); /* eat :oper */ + local_node->oper = nodeRead(true); /* now read it */ + + token = lsptok(NULL, &length); /* eat :subselect */ + local_node->subselect = nodeRead(true); /* now read it */ + + return (local_node); +} + /* * Stuff from execnodes.h */ @@ -1971,6 +2010,10 @@ parsePlanString(void) { return_value = _readAggreg(); } + else if (!strncmp(token, "SUBLINK", 6)) + { + return_value = _readSubLink(); + } else if (!strncmp(token, "AGG", 3)) { return_value = _readAgg(); |