*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.15 1998/01/06 18:52:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.16 1998/01/06 23:19:47 momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
_outNode(str, node->inhRelnames);
appendStringInfo(str, " :constraints");
_outNode(str, node->constraints);
-} /* _outCreateStmt() */
+}
static void
_outIndexStmt(StringInfo str, IndexStmt *node)
appendStringInfo(str, " :rangetable ");
_outNode(str, node->rangetable);
appendStringInfo(str, " :lossy ");
- appendStringInfo(str, (*node->lossy ? "y": "n"));
+ appendStringInfo(str, (*node->lossy ? "true": "false"));
appendStringInfo(str, " :unique ");
- appendStringInfo(str, (node->unique ? "y": "n"));
-} /* _outIndexStmt() */
+ appendStringInfo(str, (node->unique ? "true": "false"));
+}
static void
_outColumnDef(StringInfo str, ColumnDef *node)
appendStringInfo(str, " :typename ");
_outNode(str, node->typename);
appendStringInfo(str, " :is_not_null ");
- appendStringInfo(str, (node->is_not_null ? "y": "n"));
+ appendStringInfo(str, (node->is_not_null ? "true": "false"));
appendStringInfo(str, " :defval ");
appendStringInfo(str, node->defval);
appendStringInfo(str, " :constraints");
_outNode(str, node->constraints);
-} /* _outColumnDef() */
+}
+
+static void
+_outTypeName(StringInfo str, TypeName *node)
+{
+ char buf[500];
+
+ appendStringInfo(str, "TYPENAME");
+
+ appendStringInfo(str, " :name ");
+ appendStringInfo(str, node->name);
+ appendStringInfo(str, " :timezone ");
+ appendStringInfo(str, (node->timezone ? "true" : "false"));
+ appendStringInfo(str, " :setof ");
+ appendStringInfo(str, (node->setof ? "true" : "false"));
+ appendStringInfo(str, " :arrayBounds ");
+ _outNode(str, node->arrayBounds);
+ appendStringInfo(str, " :typlen ");
+ sprintf(buf," %d ", node->typlen);
+ appendStringInfo(str, buf);
+}
static void
_outIndexElem(StringInfo str, IndexElem *node)
appendStringInfo(str, node->class);
appendStringInfo(str, " :tname");
_outNode(str, node->tname);
-} /* _outIndexElem() */
+}
static void
_outQuery(StringInfo str, Query *node)
appendStringInfo(str, " :into ");
appendStringInfo(str, node->into);
appendStringInfo(str, " :isPortal ");
- appendStringInfo(str, (node->isPortal ? "y": "n"));
+ appendStringInfo(str, (node->isPortal ? "true" : "false"));
appendStringInfo(str, " :isBinary ");
- appendStringInfo(str, (node->isBinary ? "y": "n"));
+ appendStringInfo(str, (node->isBinary ? "true" : "false"));
appendStringInfo(str, " :unionall ");
- appendStringInfo(str, (node->unionall ? "y": "n"));
+ appendStringInfo(str, (node->unionall ? "true" : "false"));
appendStringInfo(str, " :unique ");
appendStringInfo(str, node->uniqueFlag);
appendStringInfo(str, " :sortClause ");
}
static void
-_outSortGroupBy(StringInfo str, SortGroupBy *node)
+_outSortClause(StringInfo str, SortClause *node)
{
char buf[500];
- int i;
- appendStringInfo(str, "SORTGROUPBY");
+ appendStringInfo(str, "SORTCLAUSE");
- appendStringInfo(str, " :resno ");
- sprintf(buf," %d ", node->resno);
- appendStringInfo(str, " :range ");
- appendStringInfo(str, node->range);
- appendStringInfo(str, " :name ");
- appendStringInfo(str, node->name);
- appendStringInfo(str, " :useOp ");
- appendStringInfo(str, node->useOp);
+ appendStringInfo(str, " :resdom ");
+ _outNode(str, node->resdom);
+ appendStringInfo(str, " :opoid ");
+ sprintf(buf," %u ", node->opoid);
+ appendStringInfo(str, buf);
+}
+
+static void
+_outGroupClause(StringInfo str, GroupClause *node)
+{
+ char buf[500];
+
+ appendStringInfo(str, "GROUPCLAUSE");
+
+ appendStringInfo(str, " :entry ");
+ _outNode(str, node->entry);
+ appendStringInfo(str, " :grpOpoid ");
+ sprintf(buf," %u ", node->grpOpoid);
+ appendStringInfo(str, buf);
}
/*
sprintf(buf, " :width %d", node->plan_width);
appendStringInfo(str, buf);
appendStringInfo(str, " :state ");
- appendStringInfo(str, (node->state == (EState *) NULL? "nil" : "non-NIL"));
+ appendStringInfo(str, node->state ? "not-NULL" : "\"\"");
appendStringInfo(str, " :qptargetlist ");
_outNode(str, node->targetlist);
appendStringInfo(str, " :qpqual ");
case T_ColumnDef:
_outColumnDef(str, obj);
break;
+ case T_TypeName:
+ _outTypeName(str, obj);
+ break;
case T_IndexElem:
_outIndexElem(str, obj);
break;
case T_Query:
_outQuery(str, obj);
break;
- case T_SortGroupBy:
- _outSortGroupBy(str, obj);
+ case T_SortClause:
+ _outSortClause(str, obj);
+ break;
+ case T_GroupClause:
+ _outGroupClause(str, obj);
break;
case T_Plan:
_outPlan(str, obj);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.14 1998/01/06 18:52:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.15 1998/01/06 23:19:49 momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
}
/* ----------------
- * _readSortGroupBy
+ * _readSortClause
* ----------------
*/
-static SortGroupBy *
-_readSortGroupBy()
+static SortClause *
+_readSortClause()
{
- SortGroupBy *local_node;
+ SortClause *local_node;
char *token;
int length;
- local_node = makeNode(SortGroupBy);
+ local_node = makeNode(SortClause);
- token = lsptok(NULL, &length); /* skip the :resno */
- token = lsptok(NULL, &length); /* get resno */
- local_node->resno = atoi(token);
+ token = lsptok(NULL, &length); /* skip the :resdom */
+ token = lsptok(NULL, &length); /* get resdom */
+ local_node->resdom = nodeRead(true);
- token = lsptok(NULL, &length); /* skip :range */
- token = lsptok(NULL, &length); /* get range */
- if (length == 0)
- local_node->range = NULL;
- else
- {
- local_node->range = palloc(length + 1);
- StrNCpy(local_node->range, token, length+1);
- }
+ token = lsptok(NULL, &length); /* skip :opoid */
+ token = lsptok(NULL, &length); /* get opoid */
+ local_node->opoid = strtoul(token,NULL,10);
- token = lsptok(NULL, &length); /* skip :name */
- token = lsptok(NULL, &length); /* get name */
- if (length == 0)
- local_node->name = NULL;
- else
- {
- local_node->name = palloc(length + 1);
- StrNCpy(local_node->name, token, length+1);
- }
+ return (local_node);
+}
- token = lsptok(NULL, &length); /* skip :useOp */
- token = lsptok(NULL, &length); /* get useOp */
- if (length == 0)
- local_node->useOp = NULL;
- else
- {
- local_node->useOp = palloc(length + 1);
- StrNCpy(local_node->useOp, token, length+1);
- }
+/* ----------------
+ * _readGroupClause
+ * ----------------
+ */
+static GroupClause *
+_readGroupClause()
+{
+ GroupClause *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(GroupClause);
+
+ token = lsptok(NULL, &length); /* skip the :entry */
+ token = lsptok(NULL, &length); /* get entry */
+ local_node->entry = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* skip :grpOpoid */
+ token = lsptok(NULL, &length); /* get grpOpoid */
+ local_node->grpOpoid = strtoul(token,NULL,10);
return (local_node);
}
token = lsptok(NULL, &length); /* eat the :state stuff */
token = lsptok(NULL, &length); /* now get the state */
- if (!strncmp(token, "nil", 3))
+ if (length == 0)
{
node->state = (EState *) NULL;
}
token = lsptok(NULL, &length); /* eat :unionrelid */
token = lsptok(NULL, &length); /* get unionrelid */
- local_node->unionrelid = atoi(token);
+ local_node->unionrelid = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* eat :unionrtentries */
local_node->unionrtentries = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :hashjoinop */
token = lsptok(NULL, &length); /* get hashjoinop */
- local_node->hashjoinop = atoi(token);
+ local_node->hashjoinop = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* eat :hashjointable */
token = lsptok(NULL, &length); /* eat hashjointable */
token = lsptok(NULL, &length); /* eat :scanrelid */
token = lsptok(NULL, &length); /* get scanrelid */
- node->scanrelid = atoi(token);
+ node->scanrelid = strtoul(token,NULL,10);
}
/* ----------------
token = lsptok(NULL, &length); /* eat :reskey */
token = lsptok(NULL, &length); /* get reskey */
- local_node->reskey = atoi(token);
+ local_node->reskey = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* eat :reskeyop */
token = lsptok(NULL, &length); /* get reskeyop */
token = lsptok(NULL, &length); /* eat :varno */
token = lsptok(NULL, &length); /* get varno */
- local_node->varno = atoi(token);
+ local_node->varno = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* eat :varattno */
token = lsptok(NULL, &length); /* get varattno */
token = lsptok(NULL, &length); /* eat :arrayelemtype */
token = lsptok(NULL, &length); /* get arrayelemtype */
- local_node->arrayelemtype = (Oid) atoi(token);
+ local_node->arrayelemtype = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* eat :arrayelemlength */
token = lsptok(NULL, &length); /* get arrayelemlength */
token = lsptok(NULL, &length); /* eat :refelemtype */
token = lsptok(NULL, &length); /* get refelemtype */
- local_node->refelemtype = (Oid) atoi(token);
+ local_node->refelemtype = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* eat :refattrlength */
token = lsptok(NULL, &length); /* get refattrlength */
token = lsptok(NULL, &length); /* get :constlen */
token = lsptok(NULL, &length); /* now read it */
- local_node->constlen = atoi(token);
+ local_node->constlen = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* get :constisnull */
token = lsptok(NULL, &length); /* now read it */
token = lsptok(NULL, &length); /* eat :inh */
token = lsptok(NULL, &length); /* get :inh */
- local_node->inh = atoi(token);
+ local_node->inh = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :refname */
token = lsptok(NULL, &length); /* get :refname */
token = lsptok(NULL, &length); /* eat :relid */
token = lsptok(NULL, &length); /* get :relid */
- local_node->relid = atoi(token);
+ local_node->relid = strtoul(token,NULL,10);
return (local_node);
}
token = lsptok(NULL, &length); /* get :array_index */
token = lsptok(NULL, &length); /* now read it */
- local_node->array_index = atoi(token);
+ local_node->array_index = strtoul(token,NULL,10);
return (local_node);
}
token = lsptok(NULL, &length); /* get :hashop */
token = lsptok(NULL, &length); /* now read it */
- local_node->hashop = atoi(token);
+ local_node->hashop = strtoul(token,NULL,10);
token = lsptok(NULL, &length); /* get :jmkeys */
local_node->jmethod.jmkeys = nodeRead(true); /* now read it */
{
return_value = _readQuery();
}
- else if (!strncmp(token, "SORTGROUPBY", 11))
+ else if (!strncmp(token, "SORTCLAUSE", 10))
+ {
+ return_value = _readSortClause();
+ }
+ else if (!strncmp(token, "GROUPCLAUSE", 10))
{
- return_value = _readSortGroupBy();
+ return_value = _readGroupClause();
}
else
{