summaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/copyfuncs.c2634
-rw-r--r--src/backend/nodes/equalfuncs.c1149
-rw-r--r--src/backend/nodes/list.c685
-rw-r--r--src/backend/nodes/makefuncs.c139
-rw-r--r--src/backend/nodes/nodeFuncs.c119
-rw-r--r--src/backend/nodes/nodes.c36
-rw-r--r--src/backend/nodes/outfuncs.c2640
-rw-r--r--src/backend/nodes/print.c582
-rw-r--r--src/backend/nodes/read.c421
-rw-r--r--src/backend/nodes/readfuncs.c3199
10 files changed, 5983 insertions, 5621 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index e763b9cd7ce..caf9e176ef3 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* copyfuncs.c--
- * Copy functions for Postgres tree nodes.
+ * Copy functions for Postgres tree nodes.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.6 1997/09/04 13:24:01 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.7 1997/09/07 04:42:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,7 +25,7 @@
#include "parser/parse_query.h"
#include "utils/syscache.h"
-#include "utils/builtins.h" /* for namecpy */
+#include "utils/builtins.h" /* for namecpy */
#include "utils/elog.h"
#include "utils/palloc.h"
#include "catalog/pg_type.h"
@@ -33,1716 +33,1774 @@
/*
* listCopy--
- * this copy function only copies the "lcons-cells" of the list but not
- * its contents. (good for list of pointers as well as list of integers).
+ * this copy function only copies the "lcons-cells" of the list but not
+ * its contents. (good for list of pointers as well as list of integers).
*/
-List *
-listCopy(List *list)
+List *
+listCopy(List * list)
{
- List *newlist=NIL;
- List *l, *nl=NIL;
-
- foreach(l, list) {
- if (newlist==NIL) {
- newlist = nl = lcons(lfirst(l),NIL);
- }else {
- lnext(nl) = lcons(lfirst(l),NIL);
- nl = lnext(nl);
+ List *newlist = NIL;
+ List *l,
+ *nl = NIL;
+
+ foreach(l, list)
+ {
+ if (newlist == NIL)
+ {
+ newlist = nl = lcons(lfirst(l), NIL);
+ }
+ else
+ {
+ lnext(nl) = lcons(lfirst(l), NIL);
+ nl = lnext(nl);
+ }
}
- }
- return newlist;
+ return newlist;
}
-
+
/*
* Node_Copy--
- * a macro to simplify calling of copyObject on the specified field
+ * a macro to simplify calling of copyObject on the specified field
*/
#define Node_Copy(from, newnode, field) \
- newnode->field = copyObject(from->field)
+ newnode->field = copyObject(from->field)
/* ****************************************************************
- * plannodes.h copy functions
+ * plannodes.h copy functions
* ****************************************************************
*/
/* ----------------
- * CopyPlanFields
+ * CopyPlanFields
*
- * This function copies the fields of the Plan node. It is used by
- * all the copy functions for classes which inherit from Plan.
+ * This function copies the fields of the Plan node. It is used by
+ * all the copy functions for classes which inherit from Plan.
* ----------------
*/
static void
-CopyPlanFields(Plan *from, Plan *newnode)
+CopyPlanFields(Plan * from, Plan * newnode)
{
- newnode->cost = from->cost;
- newnode->plan_size = from->plan_size;
- newnode->plan_width = from->plan_width;
- newnode->state = from->state;
- newnode->targetlist = copyObject(from->targetlist);
- newnode->qual = copyObject(from->qual);
- newnode->lefttree = copyObject(from->lefttree);
- newnode->righttree = copyObject(from->righttree);
+ newnode->cost = from->cost;
+ newnode->plan_size = from->plan_size;
+ newnode->plan_width = from->plan_width;
+ newnode->state = from->state;
+ newnode->targetlist = copyObject(from->targetlist);
+ newnode->qual = copyObject(from->qual);
+ newnode->lefttree = copyObject(from->lefttree);
+ newnode->righttree = copyObject(from->righttree);
}
/* ----------------
- * _copyPlan
+ * _copyPlan
* ----------------
*/
-static Plan *
-_copyPlan(Plan *from)
+static Plan *
+_copyPlan(Plan * from)
{
- Plan *newnode = makeNode(Plan);
-
- /* ----------------
- * copy the node superclass fields
- * ----------------
- */
- CopyPlanFields(from, newnode);
-
- return newnode;
+ Plan *newnode = makeNode(Plan);
+
+ /* ----------------
+ * copy the node superclass fields
+ * ----------------
+ */
+ CopyPlanFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copyExistential
+ * _copyExistential
* ----------------
*/
static Existential *
-_copyExistential(Existential *from)
+_copyExistential(Existential * from)
{
- Existential *newnode = makeNode(Existential);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields(from, newnode);
-
- return newnode;
+ Existential *newnode = makeNode(Existential);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copyResult
+ * _copyResult
* ----------------
*/
-static Result *
-_copyResult(Result *from)
+static Result *
+_copyResult(Result * from)
{
- Result *newnode = makeNode(Result);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, resconstantqual);
- Node_Copy(from, newnode, resstate);
-
- return newnode;
+ Result *newnode = makeNode(Result);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, resconstantqual);
+ Node_Copy(from, newnode, resstate);
+
+ return newnode;
}
/* ----------------
- * _copyAppend
+ * _copyAppend
* ----------------
*/
-static Append *
-_copyAppend(Append *from)
+static Append *
+_copyAppend(Append * from)
{
- Append *newnode = makeNode(Append);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, unionplans);
- newnode->unionrelid = from->unionrelid;
- Node_Copy(from, newnode, unionrtentries);
- Node_Copy(from, newnode, unionstate);
-
- return newnode;
+ Append *newnode = makeNode(Append);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, unionplans);
+ newnode->unionrelid = from->unionrelid;
+ Node_Copy(from, newnode, unionrtentries);
+ Node_Copy(from, newnode, unionstate);
+
+ return newnode;
}
/* ----------------
- * CopyScanFields
+ * CopyScanFields
*
- * This function copies the fields of the Scan node. It is used by
- * all the copy functions for classes which inherit from Scan.
+ * This function copies the fields of the Scan node. It is used by
+ * all the copy functions for classes which inherit from Scan.
* ----------------
*/
static void
-CopyScanFields(Scan *from, Scan *newnode)
+CopyScanFields(Scan * from, Scan * newnode)
{
- newnode->scanrelid = from->scanrelid;
- Node_Copy(from, newnode, scanstate);
- return;
+ newnode->scanrelid = from->scanrelid;
+ Node_Copy(from, newnode, scanstate);
+ return;
}
/* ----------------
- * _copyScan
+ * _copyScan
* ----------------
*/
-static Scan *
-_copyScan(Scan *from)
+static Scan *
+_copyScan(Scan * from)
{
- Scan *newnode = makeNode(Scan);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyScanFields(from, newnode);
-
- return newnode;
+ Scan *newnode = makeNode(Scan);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyScanFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copySeqScan
+ * _copySeqScan
* ----------------
*/
static SeqScan *
-_copySeqScan(SeqScan *from)
+_copySeqScan(SeqScan * from)
{
- SeqScan *newnode = makeNode(SeqScan);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyScanFields((Scan*)from, (Scan*)newnode);
-
- return newnode;
+ SeqScan *newnode = makeNode(SeqScan);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyScanFields((Scan *) from, (Scan *) newnode);
+
+ return newnode;
}
/* ----------------
- * _copyIndexScan
+ * _copyIndexScan
* ----------------
*/
static IndexScan *
-_copyIndexScan(IndexScan *from)
+_copyIndexScan(IndexScan * from)
{
- IndexScan *newnode = makeNode(IndexScan);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyScanFields((Scan*)from, (Scan*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->indxid = listCopy(from->indxid);
- Node_Copy(from, newnode, indxqual);
- Node_Copy(from, newnode, indxstate);
-
- return newnode;
+ IndexScan *newnode = makeNode(IndexScan);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyScanFields((Scan *) from, (Scan *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->indxid = listCopy(from->indxid);
+ Node_Copy(from, newnode, indxqual);
+ Node_Copy(from, newnode, indxstate);
+
+ return newnode;
}
/* ----------------
- * CopyJoinFields
+ * CopyJoinFields
*
- * This function copies the fields of the Join node. It is used by
- * all the copy functions for classes which inherit from Join.
+ * This function copies the fields of the Join node. It is used by
+ * all the copy functions for classes which inherit from Join.
* ----------------
*/
static void
-CopyJoinFields(Join *from, Join *newnode)
+CopyJoinFields(Join * from, Join * newnode)
{
- /* nothing extra */
- return;
+ /* nothing extra */
+ return;
}
/* ----------------
- * _copyJoin
+ * _copyJoin
* ----------------
*/
-static Join *
-_copyJoin(Join *from)
+static Join *
+_copyJoin(Join * from)
{
- Join *newnode = makeNode(Join);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyJoinFields(from, newnode);
-
- return newnode;
+ Join *newnode = makeNode(Join);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyJoinFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copyNestLoop
+ * _copyNestLoop
* ----------------
*/
static NestLoop *
-_copyNestLoop(NestLoop *from)
+_copyNestLoop(NestLoop * from)
{
- NestLoop *newnode = makeNode(NestLoop);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyJoinFields((Join*)from, (Join*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, nlstate);
-
- return newnode;
+ NestLoop *newnode = makeNode(NestLoop);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyJoinFields((Join *) from, (Join *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, nlstate);
+
+ return newnode;
}
/* ----------------
- * _copyMergeJoin
+ * _copyMergeJoin
* ----------------
*/
static MergeJoin *
-_copyMergeJoin(MergeJoin *from)
+_copyMergeJoin(MergeJoin * from)
{
- MergeJoin *newnode = makeNode(MergeJoin);
- List *newlist;
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyJoinFields((Join*)from, (Join*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, mergeclauses);
-
- newnode->mergesortop = from->mergesortop;
- newlist = NIL;
-
- newnode->mergerightorder = (Oid *)palloc(sizeof(Oid)*2);
- newnode->mergerightorder[0] = from->mergerightorder[0];
- newnode->mergerightorder[1] = 0;
-
- newnode->mergeleftorder = (Oid *)palloc(sizeof(Oid)*2);
- newnode->mergeleftorder[0] = from->mergeleftorder[0];
- newnode->mergeleftorder[1] = 0;
-
- Node_Copy(from, newnode, mergestate);
-
- return newnode;
+ MergeJoin *newnode = makeNode(MergeJoin);
+ List *newlist;
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyJoinFields((Join *) from, (Join *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, mergeclauses);
+
+ newnode->mergesortop = from->mergesortop;
+ newlist = NIL;
+
+ newnode->mergerightorder = (Oid *) palloc(sizeof(Oid) * 2);
+ newnode->mergerightorder[0] = from->mergerightorder[0];
+ newnode->mergerightorder[1] = 0;
+
+ newnode->mergeleftorder = (Oid *) palloc(sizeof(Oid) * 2);
+ newnode->mergeleftorder[0] = from->mergeleftorder[0];
+ newnode->mergeleftorder[1] = 0;
+
+ Node_Copy(from, newnode, mergestate);
+
+ return newnode;
}
/* ----------------
- * _copyHashJoin
+ * _copyHashJoin
* ----------------
*/
static HashJoin *
-_copyHashJoin(HashJoin *from)
+_copyHashJoin(HashJoin * from)
{
- HashJoin *newnode = makeNode(HashJoin);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyJoinFields((Join*)from, (Join*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, hashclauses);
-
- newnode->hashjoinop = from->hashjoinop;
-
- Node_Copy(from, newnode, hashjoinstate);
-
- newnode->hashjointable = from->hashjointable;
- newnode->hashjointablekey = from->hashjointablekey;
- newnode->hashjointablesize = from->hashjointablesize;
- newnode->hashdone = from->hashdone;
-
- return newnode;
+ HashJoin *newnode = makeNode(HashJoin);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyJoinFields((Join *) from, (Join *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, hashclauses);
+
+ newnode->hashjoinop = from->hashjoinop;
+
+ Node_Copy(from, newnode, hashjoinstate);
+
+ newnode->hashjointable = from->hashjointable;
+ newnode->hashjointablekey = from->hashjointablekey;
+ newnode->hashjointablesize = from->hashjointablesize;
+ newnode->hashdone = from->hashdone;
+
+ return newnode;
}
/* ----------------
- * CopyTempFields
+ * CopyTempFields
*
- * This function copies the fields of the Temp node. It is used by
- * all the copy functions for classes which inherit from Temp.
+ * This function copies the fields of the Temp node. It is used by
+ * all the copy functions for classes which inherit from Temp.
* ----------------
*/
static void
-CopyTempFields(Temp *from, Temp *newnode)
+CopyTempFields(Temp * from, Temp * newnode)
{
- newnode->tempid = from->tempid;
- newnode->keycount = from->keycount;
- return;
+ newnode->tempid = from->tempid;
+ newnode->keycount = from->keycount;
+ return;
}
/* ----------------
- * _copyTemp
+ * _copyTemp
* ----------------
*/
-static Temp *
-_copyTemp(Temp *from)
+static Temp *
+_copyTemp(Temp * from)
{
- Temp *newnode = makeNode(Temp);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyTempFields(from, newnode);
-
- return newnode;
+ Temp *newnode = makeNode(Temp);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyTempFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copyMaterial
+ * _copyMaterial
* ----------------
*/
static Material *
-_copyMaterial(Material *from)
+_copyMaterial(Material * from)
{
- Material *newnode = makeNode(Material);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyTempFields((Temp*)from, (Temp*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, matstate);
-
- return newnode;
+ Material *newnode = makeNode(Material);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyTempFields((Temp *) from, (Temp *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, matstate);
+
+ return newnode;
}
/* ----------------
- * _copySort
+ * _copySort
* ----------------
*/
-static Sort *
-_copySort(Sort *from)
+static Sort *
+_copySort(Sort * from)
{
- Sort *newnode = makeNode(Sort);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyTempFields((Temp*)from, (Temp*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, sortstate);
-
- return newnode;
+ Sort *newnode = makeNode(Sort);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyTempFields((Temp *) from, (Temp *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, sortstate);
+
+ return newnode;
}
/* ---------------
- * _copyAgg
+ * _copyAgg
* --------------
*/
-static Agg *
-_copyAgg(Agg *from)
+static Agg *
+_copyAgg(Agg * from)
{
- Agg *newnode = makeNode(Agg);
- int i;
-
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyTempFields((Temp*)from, (Temp*)newnode);
-
- newnode->numAgg = from->numAgg;
- newnode->aggs = malloc(sizeof(Aggreg *));
- for(i=0; i < from->numAgg; i++) {
- newnode->aggs[i] = copyObject(from->aggs[i]);
- }
-
- Node_Copy(from, newnode, aggstate);
-
- return newnode;
+ Agg *newnode = makeNode(Agg);
+ int i;
+
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyTempFields((Temp *) from, (Temp *) newnode);
+
+ newnode->numAgg = from->numAgg;
+ newnode->aggs = malloc(sizeof(Aggreg *));
+ for (i = 0; i < from->numAgg; i++)
+ {
+ newnode->aggs[i] = copyObject(from->aggs[i]);
+ }
+
+ Node_Copy(from, newnode, aggstate);
+
+ return newnode;
}
/* ----------------
- * _copyUnique
+ * _copyUnique
* ----------------
*/
-static Unique *
-_copyUnique(Unique *from)
+static Unique *
+_copyUnique(Unique * from)
{
- Unique *newnode = makeNode(Unique);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
- CopyTempFields((Temp*)from, (Temp*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, uniquestate);
-
- return newnode;
+ Unique *newnode = makeNode(Unique);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+ CopyTempFields((Temp *) from, (Temp *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, uniquestate);
+
+ return newnode;
}
/* ----------------
- * _copyHash
+ * _copyHash
* ----------------
*/
-static Hash *
-_copyHash(Hash *from)
+static Hash *
+_copyHash(Hash * from)
{
- Hash *newnode = makeNode(Hash);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- CopyPlanFields((Plan*)from, (Plan*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, hashkey);
- Node_Copy(from, newnode, hashstate);
-
- newnode->hashtable = from->hashtable;
- newnode->hashtablekey = from->hashtablekey;
- newnode->hashtablesize = from->hashtablesize;
-
- return newnode;
+ Hash *newnode = makeNode(Hash);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ CopyPlanFields((Plan *) from, (Plan *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, hashkey);
+ Node_Copy(from, newnode, hashstate);
+
+ newnode->hashtable = from->hashtable;
+ newnode->hashtablekey = from->hashtablekey;
+ newnode->hashtablesize = from->hashtablesize;
+
+ return newnode;
}
/* ****************************************************************
- * primnodes.h copy functions
+ * primnodes.h copy functions
* ****************************************************************
*/
/* ----------------
- * _copyResdom
+ * _copyResdom
* ----------------
*/
-static Resdom *
-_copyResdom(Resdom *from)
+static Resdom *
+_copyResdom(Resdom * from)
{
- Resdom *newnode = makeNode(Resdom);
-
- newnode->resno = from->resno;
- newnode->restype = from->restype;
- newnode->reslen = from->reslen;
-
- if (from->resname != NULL) {
- newnode->resname = palloc(strlen(from->resname)+1);
- strcpy(newnode->resname, from->resname);
- } else
- newnode->resname = (char*) NULL;
-
- newnode->reskey = from->reskey;
- newnode->reskeyop = from->reskeyop;
- newnode->resjunk = from->resjunk;
-
- return newnode;
+ Resdom *newnode = makeNode(Resdom);
+
+ newnode->resno = from->resno;
+ newnode->restype = from->restype;
+ newnode->reslen = from->reslen;
+
+ if (from->resname != NULL)
+ {
+ newnode->resname = palloc(strlen(from->resname) + 1);
+ strcpy(newnode->resname, from->resname);
+ }
+ else
+ newnode->resname = (char *) NULL;
+
+ newnode->reskey = from->reskey;
+ newnode->reskeyop = from->reskeyop;
+ newnode->resjunk = from->resjunk;
+
+ return newnode;
}
-static Fjoin *
-_copyFjoin(Fjoin *from)
+static Fjoin *
+_copyFjoin(Fjoin * from)
{
- Fjoin *newnode = makeNode(Fjoin);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
-
- newnode->fj_initialized = from->fj_initialized;
- newnode->fj_nNodes = from->fj_nNodes;
-
- Node_Copy(from, newnode, fj_innerNode);
-
- newnode->fj_results = (DatumPtr)
- palloc((from->fj_nNodes)*sizeof(Datum));
-
- newnode->fj_alwaysDone = (BoolPtr)
- palloc((from->fj_nNodes)*sizeof(bool));
-
- memmove(from->fj_results,
- newnode->fj_results,
- (from->fj_nNodes)*sizeof(Datum));
-
- memmove(from->fj_alwaysDone,
- newnode->fj_alwaysDone,
- (from->fj_nNodes)*sizeof(bool));
-
-
- return newnode;
+ Fjoin *newnode = makeNode(Fjoin);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+
+ newnode->fj_initialized = from->fj_initialized;
+ newnode->fj_nNodes = from->fj_nNodes;
+
+ Node_Copy(from, newnode, fj_innerNode);
+
+ newnode->fj_results = (DatumPtr)
+ palloc((from->fj_nNodes) * sizeof(Datum));
+
+ newnode->fj_alwaysDone = (BoolPtr)
+ palloc((from->fj_nNodes) * sizeof(bool));
+
+ memmove(from->fj_results,
+ newnode->fj_results,
+ (from->fj_nNodes) * sizeof(Datum));
+
+ memmove(from->fj_alwaysDone,
+ newnode->fj_alwaysDone,
+ (from->fj_nNodes) * sizeof(bool));
+
+
+ return newnode;
}
/* ----------------
- * _copyExpr
+ * _copyExpr
* ----------------
*/
-static Expr *
-_copyExpr(Expr *from)
+static Expr *
+_copyExpr(Expr * from)
{
- Expr *newnode = makeNode(Expr);
-
- /* ----------------
- * copy node superclass fields
- * ----------------
- */
- newnode->typeOid = from->typeOid;
- newnode->opType = from->opType;
-
- Node_Copy(from, newnode, oper);
- Node_Copy(from, newnode, args);
-
- return newnode;
+ Expr *newnode = makeNode(Expr);
+
+ /* ----------------
+ * copy node superclass fields
+ * ----------------
+ */
+ newnode->typeOid = from->typeOid;
+ newnode->opType = from->opType;
+
+ Node_Copy(from, newnode, oper);
+ Node_Copy(from, newnode, args);
+
+ return newnode;
}
/* ----------------
- * _copyVar
+ * _copyVar
* ----------------
*/
-static Var *
-_copyVar(Var *from)
+static Var *
+_copyVar(Var * from)
{
- Var *newnode = makeNode(Var);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->varno = from->varno;
- newnode->varattno = from->varattno;
- newnode->vartype = from->vartype;
-
- newnode->varnoold = from->varnoold;
- newnode->varoattno = from->varoattno;
-
- return newnode;
+ Var *newnode = makeNode(Var);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->varno = from->varno;
+ newnode->varattno = from->varattno;
+ newnode->vartype = from->vartype;
+
+ newnode->varnoold = from->varnoold;
+ newnode->varoattno = from->varoattno;
+
+ return newnode;
}
/* ----------------
- * _copyOper
+ * _copyOper
* ----------------
*/
-static Oper *
-_copyOper(Oper *from)
+static Oper *
+_copyOper(Oper * from)
{
- Oper *newnode = makeNode(Oper);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->opno = from->opno;
- newnode->opid = from->opid;
- newnode->opresulttype = from->opresulttype;
- newnode->opsize = from->opsize;
-
- /*
- * NOTE: shall we copy the cache structure or just the pointer ?
- * Alternatively we can set 'op_fcache' to NULL, in which
- * case the executor will initialize it when it needs it...
- */
- newnode->op_fcache = from->op_fcache;
-
- return newnode;
+ Oper *newnode = makeNode(Oper);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->opno = from->opno;
+ newnode->opid = from->opid;
+ newnode->opresulttype = from->opresulttype;
+ newnode->opsize = from->opsize;
+
+ /*
+ * NOTE: shall we copy the cache structure or just the pointer ?
+ * Alternatively we can set 'op_fcache' to NULL, in which case the
+ * executor will initialize it when it needs it...
+ */
+ newnode->op_fcache = from->op_fcache;
+
+ return newnode;
}
/* ----------------
- * _copyConst
+ * _copyConst
* ----------------
*/
-static Const *
-_copyConst(Const *from)
+static Const *
+_copyConst(Const * from)
{
- static Oid cached_type;
- static bool cached_typbyval;
-
- Const *newnode = makeNode(Const);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->consttype = from->consttype;
- newnode->constlen = from->constlen;
-
- /* ----------------
- * XXX super cheesy hack until parser/planner
- * puts in the right values here.
- * ----------------
- */
- if (cached_type != from->consttype) {
- HeapTuple typeTuple;
- TypeTupleForm typeStruct;
-
- /* ----------------
- * get the type tuple corresponding to the paramList->type,
- * If this fails, returnValue has been pre-initialized
- * to "null" so we just return it.
- * ----------------
- */
- typeTuple = SearchSysCacheTuple(TYPOID,
- ObjectIdGetDatum(from->consttype),
- 0,0,0);
-
+ static Oid cached_type;
+ static bool cached_typbyval;
+
+ Const *newnode = makeNode(Const);
+
/* ----------------
- * get the type length and by-value from the type tuple and
- * save the information in our one element cache.
+ * copy remainder of node
* ----------------
*/
- Assert(PointerIsValid(typeTuple));
-
- typeStruct = (TypeTupleForm) GETSTRUCT(typeTuple);
- cached_typbyval = (typeStruct)->typbyval ? true : false ;
- cached_type = from->consttype;
- }
-
- from->constbyval = cached_typbyval;
-
- if (!from->constisnull) {
+ newnode->consttype = from->consttype;
+ newnode->constlen = from->constlen;
+
/* ----------------
- * copying the Datum in a const node is a bit trickier
- * because it might be a pointer and it might also be of
- * variable length...
+ * XXX super cheesy hack until parser/planner
+ * puts in the right values here.
* ----------------
*/
- if (from->constbyval == true) {
- /* ----------------
- * passed by value so just copy the datum.
- * ----------------
- */
- newnode->constvalue = from->constvalue;
- } else {
- /* ----------------
- * not passed by value. datum contains a pointer.
- * ----------------
- */
- if (from->constlen != -1) {
+ if (cached_type != from->consttype)
+ {
+ HeapTuple typeTuple;
+ TypeTupleForm typeStruct;
+
+ /* ----------------
+ * get the type tuple corresponding to the paramList->type,
+ * If this fails, returnValue has been pre-initialized
+ * to "null" so we just return it.
+ * ----------------
+ */
+ typeTuple = SearchSysCacheTuple(TYPOID,
+ ObjectIdGetDatum(from->consttype),
+ 0, 0, 0);
+
/* ----------------
- * fixed length structure
+ * get the type length and by-value from the type tuple and
+ * save the information in our one element cache.
* ----------------
*/
- newnode->constvalue = PointerGetDatum(palloc(from->constlen));
- memmove((char*)newnode->constvalue,
- (char*)from->constvalue, from->constlen);
- } else {
+ Assert(PointerIsValid(typeTuple));
+
+ typeStruct = (TypeTupleForm) GETSTRUCT(typeTuple);
+ cached_typbyval = (typeStruct)->typbyval ? true : false;
+ cached_type = from->consttype;
+ }
+
+ from->constbyval = cached_typbyval;
+
+ if (!from->constisnull)
+ {
/* ----------------
- * variable length structure. here the length is stored
- * in the first int pointed to by the constval.
+ * copying the Datum in a const node is a bit trickier
+ * because it might be a pointer and it might also be of
+ * variable length...
* ----------------
*/
- int length;
- length = *((int *) from->constvalue);
- newnode->constvalue = PointerGetDatum(palloc(length));
- memmove((char*)newnode->constvalue,
- (char*)from->constvalue, length);
- }
+ if (from->constbyval == true)
+ {
+ /* ----------------
+ * passed by value so just copy the datum.
+ * ----------------
+ */
+ newnode->constvalue = from->constvalue;
+ }
+ else
+ {
+ /* ----------------
+ * not passed by value. datum contains a pointer.
+ * ----------------
+ */
+ if (from->constlen != -1)
+ {
+ /* ----------------
+ * fixed length structure
+ * ----------------
+ */
+ newnode->constvalue = PointerGetDatum(palloc(from->constlen));
+ memmove((char *) newnode->constvalue,
+ (char *) from->constvalue, from->constlen);
+ }
+ else
+ {
+ /* ----------------
+ * variable length structure. here the length is stored
+ * in the first int pointed to by the constval.
+ * ----------------
+ */
+ int length;
+
+ length = *((int *) from->constvalue);
+ newnode->constvalue = PointerGetDatum(palloc(length));
+ memmove((char *) newnode->constvalue,
+ (char *) from->constvalue, length);
+ }
+ }
+ }
+ else
+ {
+ newnode->constvalue = from->constvalue;
}
- }
- else {
- newnode->constvalue = from->constvalue;
- }
- newnode->constisnull = from->constisnull;
- newnode->constbyval = from->constbyval;
-
- return newnode;
+ newnode->constisnull = from->constisnull;
+ newnode->constbyval = from->constbyval;
+
+ return newnode;
}
/* ----------------
- * _copyParam
+ * _copyParam
* ----------------
*/
-static Param *
-_copyParam(Param *from)
+static Param *
+_copyParam(Param * from)
{
- Param *newnode = makeNode(Param);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->paramkind = from->paramkind;
- newnode->paramid = from->paramid;
-
- if (from->paramname != NULL) {
- newnode->paramname = pstrdup(from->paramname);
- } else
- newnode->paramname = (char*)NULL;
-
- newnode->paramtype = from->paramtype;
- Node_Copy(from, newnode, param_tlist);
-
- return newnode;
+ Param *newnode = makeNode(Param);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->paramkind = from->paramkind;
+ newnode->paramid = from->paramid;
+
+ if (from->paramname != NULL)
+ {
+ newnode->paramname = pstrdup(from->paramname);
+ }
+ else
+ newnode->paramname = (char *) NULL;
+
+ newnode->paramtype = from->paramtype;
+ Node_Copy(from, newnode, param_tlist);
+
+ return newnode;
}
/* ----------------
- * _copyFunc
+ * _copyFunc
* ----------------
*/
-static Func *
-_copyFunc(Func *from)
+static Func *
+_copyFunc(Func * from)
{
- Func *newnode = makeNode(Func);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->funcid = from->funcid;
- newnode->functype = from->functype;
- newnode->funcisindex = from->funcisindex;
- newnode->funcsize = from->funcsize;
- newnode->func_fcache = from->func_fcache;
- Node_Copy(from, newnode, func_tlist);
- Node_Copy(from, newnode, func_planlist);
-
- return newnode;
+ Func *newnode = makeNode(Func);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->funcid = from->funcid;
+ newnode->functype = from->functype;
+ newnode->funcisindex = from->funcisindex;
+ newnode->funcsize = from->funcsize;
+ newnode->func_fcache = from->func_fcache;
+ Node_Copy(from, newnode, func_tlist);
+ Node_Copy(from, newnode, func_planlist);
+
+ return newnode;
}
/* ----------------
- * _copyAggreg
+ * _copyAggreg
* ----------------
*/
-static Aggreg *
-_copyAggreg(Aggreg *from)
+static Aggreg *
+_copyAggreg(Aggreg * from)
{
- Aggreg *newnode = makeNode(Aggreg);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->aggname = pstrdup(from->aggname);
- newnode->basetype = from->basetype;
- newnode->aggtype = from->aggtype;
-
- Node_Copy(from, newnode, target);
-
- newnode->aggno = from->aggno;
-
- return newnode;
+ Aggreg *newnode = makeNode(Aggreg);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->aggname = pstrdup(from->aggname);
+ newnode->basetype = from->basetype;
+ newnode->aggtype = from->aggtype;
+
+ Node_Copy(from, newnode, target);
+
+ newnode->aggno = from->aggno;
+
+ return newnode;
}
-static Array *
-_copyArray(Array *from)
+static Array *
+_copyArray(Array * from)
{
- Array *newnode = makeNode(Array);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->arrayelemtype = from->arrayelemtype;
- newnode->arrayelemlength = from->arrayelemlength;
- newnode->arrayelembyval = from->arrayelembyval;
- newnode->arrayndim = from->arrayndim;
- newnode->arraylow = from->arraylow;
- newnode->arrayhigh = from->arrayhigh;
- newnode->arraylen = from->arraylen;
-
- return newnode;
+ Array *newnode = makeNode(Array);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->arrayelemtype = from->arrayelemtype;
+ newnode->arrayelemlength = from->arrayelemlength;
+ newnode->arrayelembyval = from->arrayelembyval;
+ newnode->arrayndim = from->arrayndim;
+ newnode->arraylow = from->arraylow;
+ newnode->arrayhigh = from->arrayhigh;
+ newnode->arraylen = from->arraylen;
+
+ return newnode;
}
static ArrayRef *
-_copyArrayRef(ArrayRef *from)
+_copyArrayRef(ArrayRef * from)
{
- ArrayRef *newnode = makeNode(ArrayRef);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->refelemtype = from->refelemtype;
- newnode->refattrlength = from->refattrlength;
- newnode->refelemlength = from->refelemlength;
- newnode->refelembyval = from->refelembyval;
-
- Node_Copy(from,newnode,refupperindexpr);
- Node_Copy(from,newnode,reflowerindexpr);
- Node_Copy(from,newnode,refexpr);
- Node_Copy(from,newnode,refassgnexpr);
-
- return newnode;
+ ArrayRef *newnode = makeNode(ArrayRef);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->refelemtype = from->refelemtype;
+ newnode->refattrlength = from->refattrlength;
+ newnode->refelemlength = from->refelemlength;
+ newnode->refelembyval = from->refelembyval;
+
+ Node_Copy(from, newnode, refupperindexpr);
+ Node_Copy(from, newnode, reflowerindexpr);
+ Node_Copy(from, newnode, refexpr);
+ Node_Copy(from, newnode, refassgnexpr);
+
+ return newnode;
}
/* ****************************************************************
- * relation.h copy functions
+ * relation.h copy functions
* ****************************************************************
*/
/* ----------------
- * _copyRel
+ * _copyRel
* ----------------
*/
/*
- ** when you change this, also make sure to fix up xfunc_copyRel in
+ ** when you change this, also make sure to fix up xfunc_copyRel in
** planner/path/xfunc.c accordingly!!!
- ** -- JMH, 8/2/93
+ ** -- JMH, 8/2/93
*/
-static Rel *
-_copyRel(Rel *from)
+static Rel *
+_copyRel(Rel * from)
{
- Rel *newnode = makeNode(Rel);
- int i, len;
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->relids = listCopy(from->relids);
-
- newnode->indexed = from->indexed;
- newnode->pages = from->pages;
- newnode->tuples = from->tuples;
- newnode->size = from->size;
- newnode->width = from->width;
- newnode->indproc = from->indproc;
-
- Node_Copy(from, newnode, targetlist);
- Node_Copy(from, newnode, pathlist);
- Node_Copy(from, newnode, unorderedpath);
- Node_Copy(from, newnode, cheapestpath);
- newnode->pruneable = from->pruneable;
- newnode->relam = from->relam;
-
- if (from->classlist) {
- for(len=0; from->classlist[len]!=0; len++)
- ;
- newnode->classlist = (Oid *)palloc(sizeof(Oid) * (len+1));
- for(i=0; i < len; i++) {
- newnode->classlist[i] = from->classlist[i];
+ Rel *newnode = makeNode(Rel);
+ int i,
+ len;
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->relids = listCopy(from->relids);
+
+ newnode->indexed = from->indexed;
+ newnode->pages = from->pages;
+ newnode->tuples = from->tuples;
+ newnode->size = from->size;
+ newnode->width = from->width;
+ newnode->indproc = from->indproc;
+
+ Node_Copy(from, newnode, targetlist);
+ Node_Copy(from, newnode, pathlist);
+ Node_Copy(from, newnode, unorderedpath);
+ Node_Copy(from, newnode, cheapestpath);
+ newnode->pruneable = from->pruneable;
+ newnode->relam = from->relam;
+
+ if (from->classlist)
+ {
+ for (len = 0; from->classlist[len] != 0; len++)
+ ;
+ newnode->classlist = (Oid *) palloc(sizeof(Oid) * (len + 1));
+ for (i = 0; i < len; i++)
+ {
+ newnode->classlist[i] = from->classlist[i];
+ }
+ newnode->classlist[len] = 0;
}
- newnode->classlist[len] = 0;
- }
-
- if (from->indexkeys) {
- for(len=0; from->indexkeys[len]!=0; len++)
- ;
- newnode->indexkeys = (int *)palloc(sizeof(int) * (len+1));
- for(i=0; i < len; i++) {
- newnode->indexkeys[i] = from->indexkeys[i];
+
+ if (from->indexkeys)
+ {
+ for (len = 0; from->indexkeys[len] != 0; len++)
+ ;
+ newnode->indexkeys = (int *) palloc(sizeof(int) * (len + 1));
+ for (i = 0; i < len; i++)
+ {
+ newnode->indexkeys[i] = from->indexkeys[i];
+ }
+ newnode->indexkeys[len] = 0;
}
- newnode->indexkeys[len] = 0;
- }
-
- if (from->ordering) {
- for(len=0; from->ordering[len]!=0; len++)
- ;
- newnode->ordering = (Oid *)palloc(sizeof(Oid) * (len+1));
- for(i=0; i < len; i++) {
- newnode->ordering[i] = from->ordering[i];
+
+ if (from->ordering)
+ {
+ for (len = 0; from->ordering[len] != 0; len++)
+ ;
+ newnode->ordering = (Oid *) palloc(sizeof(Oid) * (len + 1));
+ for (i = 0; i < len; i++)
+ {
+ newnode->ordering[i] = from->ordering[i];
+ }
+ newnode->ordering[len] = 0;
}
- newnode->ordering[len] = 0;
- }
-
- Node_Copy(from, newnode, clauseinfo);
- Node_Copy(from, newnode, joininfo);
- Node_Copy(from, newnode, innerjoin);
- Node_Copy(from, newnode, superrels);
-
- return newnode;
+
+ Node_Copy(from, newnode, clauseinfo);
+ Node_Copy(from, newnode, joininfo);
+ Node_Copy(from, newnode, innerjoin);
+ Node_Copy(from, newnode, superrels);
+
+ return newnode;
}
/* ----------------
- * CopyPathFields
+ * CopyPathFields
*
- * This function copies the fields of the Path node. It is used by
- * all the copy functions for classes which inherit from Path.
+ * This function copies the fields of the Path node. It is used by
+ * all the copy functions for classes which inherit from Path.
* ----------------
*/
static void
-CopyPathFields(Path *from, Path *newnode)
+CopyPathFields(Path * from, Path * newnode)
{
- newnode->pathtype = from->pathtype;
- /* Modify the next line, since it causes the copying to cycle
- (i.e. the parent points right back here!
- -- JMH, 7/7/92.
- Old version:
- Node_Copy(from, newnode, parent);
- */
- newnode->parent = from->parent;
-
- newnode->path_cost = from->path_cost;
-
- newnode->p_ordering.ordtype = from->p_ordering.ordtype;
- if (from->p_ordering.ordtype == SORTOP_ORDER) {
- int len, i;
- Oid *ordering = from->p_ordering.ord.sortop;
-
- if (ordering) {
- for(len=0; ordering[len]!=0; len++)
- ;
- newnode->p_ordering.ord.sortop =
- (Oid *)palloc(sizeof(Oid) * (len+1));
- for(i=0; i < len; i++) {
- newnode->p_ordering.ord.sortop[i] = ordering[i];
- }
- newnode->p_ordering.ord.sortop[len] = 0;
- } else {
- newnode->p_ordering.ord.sortop = NULL;
+ newnode->pathtype = from->pathtype;
+
+ /*
+ * Modify the next line, since it causes the copying to cycle (i.e.
+ * the parent points right back here! -- JMH, 7/7/92. Old version:
+ * Node_Copy(from, newnode, parent);
+ */
+ newnode->parent = from->parent;
+
+ newnode->path_cost = from->path_cost;
+
+ newnode->p_ordering.ordtype = from->p_ordering.ordtype;
+ if (from->p_ordering.ordtype == SORTOP_ORDER)
+ {
+ int len,
+ i;
+ Oid *ordering = from->p_ordering.ord.sortop;
+
+ if (ordering)
+ {
+ for (len = 0; ordering[len] != 0; len++)
+ ;
+ newnode->p_ordering.ord.sortop =
+ (Oid *) palloc(sizeof(Oid) * (len + 1));
+ for (i = 0; i < len; i++)
+ {
+ newnode->p_ordering.ord.sortop[i] = ordering[i];
+ }
+ newnode->p_ordering.ord.sortop[len] = 0;
+ }
+ else
+ {
+ newnode->p_ordering.ord.sortop = NULL;
+ }
+ }
+ else
+ {
+ Node_Copy(from, newnode, p_ordering.ord.merge);
}
- } else {
- Node_Copy(from, newnode, p_ordering.ord.merge);
- }
-
- Node_Copy(from, newnode, keys);
-
- newnode->outerjoincost = from->outerjoincost;
-
- newnode->joinid = listCopy(from->joinid);
- Node_Copy(from, newnode, locclauseinfo);
+
+ Node_Copy(from, newnode, keys);
+
+ newnode->outerjoincost = from->outerjoincost;
+
+ newnode->joinid = listCopy(from->joinid);
+ Node_Copy(from, newnode, locclauseinfo);
}
/* ----------------
- * _copyPath
+ * _copyPath
* ----------------
*/
-static Path *
-_copyPath(Path *from)
+static Path *
+_copyPath(Path * from)
{
- Path *newnode = makeNode(Path);
-
- CopyPathFields(from, newnode);
-
- return newnode;
+ Path *newnode = makeNode(Path);
+
+ CopyPathFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copyIndexPath
+ * _copyIndexPath
* ----------------
*/
static IndexPath *
-_copyIndexPath(IndexPath *from)
+_copyIndexPath(IndexPath * from)
{
- IndexPath *newnode = makeNode(IndexPath);
-
- /* ----------------
- * copy the node superclass fields
- * ----------------
- */
- CopyPathFields((Path*)from, (Path*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->indexid = listCopy(from->indexid);
- Node_Copy(from, newnode, indexqual);
-
- if (from->indexkeys)
- {
- int i, len;
-
- for(len=0; from->indexkeys[len]!=0; len++)
- ;
- newnode->indexkeys = (int *)palloc(sizeof(int) * (len+1));
- for(i=0; i < len; i++) {
- newnode->indexkeys[i] = from->indexkeys[i];
+ IndexPath *newnode = makeNode(IndexPath);
+
+ /* ----------------
+ * copy the node superclass fields
+ * ----------------
+ */
+ CopyPathFields((Path *) from, (Path *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->indexid = listCopy(from->indexid);
+ Node_Copy(from, newnode, indexqual);
+
+ if (from->indexkeys)
+ {
+ int i,
+ len;
+
+ for (len = 0; from->indexkeys[len] != 0; len++)
+ ;
+ newnode->indexkeys = (int *) palloc(sizeof(int) * (len + 1));
+ for (i = 0; i < len; i++)
+ {
+ newnode->indexkeys[i] = from->indexkeys[i];
+ }
+ newnode->indexkeys[len] = 0;
}
- newnode->indexkeys[len] = 0;
- }
-
- return newnode;
+
+ return newnode;
}
/* ----------------
- * CopyJoinPathFields
+ * CopyJoinPathFields
*
- * This function copies the fields of the JoinPath node. It is used by
- * all the copy functions for classes which inherit from JoinPath.
+ * This function copies the fields of the JoinPath node. It is used by
+ * all the copy functions for classes which inherit from JoinPath.
* ----------------
*/
static void
-CopyJoinPathFields(JoinPath *from, JoinPath *newnode)
+CopyJoinPathFields(JoinPath * from, JoinPath * newnode)
{
- Node_Copy(from, newnode, pathclauseinfo);
- Node_Copy(from, newnode, outerjoinpath);
- Node_Copy(from, newnode, innerjoinpath);
+ Node_Copy(from, newnode, pathclauseinfo);
+ Node_Copy(from, newnode, outerjoinpath);
+ Node_Copy(from, newnode, innerjoinpath);
}
/* ----------------
- * _copyJoinPath
+ * _copyJoinPath
* ----------------
*/
static JoinPath *
-_copyJoinPath(JoinPath *from)
+_copyJoinPath(JoinPath * from)
{
- JoinPath *newnode = makeNode(JoinPath);
-
- /* ----------------
- * copy the node superclass fields
- * ----------------
- */
- CopyPathFields((Path*)from, (Path*)newnode);
- CopyJoinPathFields(from, newnode);
-
- return newnode;
+ JoinPath *newnode = makeNode(JoinPath);
+
+ /* ----------------
+ * copy the node superclass fields
+ * ----------------
+ */
+ CopyPathFields((Path *) from, (Path *) newnode);
+ CopyJoinPathFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copyMergePath
+ * _copyMergePath
* ----------------
*/
static MergePath *
-_copyMergePath(MergePath *from)
+_copyMergePath(MergePath * from)
{
- MergePath *newnode = makeNode(MergePath);
-
- /* ----------------
- * copy the node superclass fields
- * ----------------
- */
- CopyPathFields((Path*)from, (Path*)newnode);
- CopyJoinPathFields((JoinPath*)from, (JoinPath*)newnode);
-
- /* ----------------
- * copy the remainder of the node
- * ----------------
- */
- Node_Copy(from, newnode, path_mergeclauses);
- Node_Copy(from, newnode, outersortkeys);
- Node_Copy(from, newnode, innersortkeys);
-
- return newnode;
+ MergePath *newnode = makeNode(MergePath);
+
+ /* ----------------
+ * copy the node superclass fields
+ * ----------------
+ */
+ CopyPathFields((Path *) from, (Path *) newnode);
+ CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
+
+ /* ----------------
+ * copy the remainder of the node
+ * ----------------
+ */
+ Node_Copy(from, newnode, path_mergeclauses);
+ Node_Copy(from, newnode, outersortkeys);
+ Node_Copy(from, newnode, innersortkeys);
+
+ return newnode;
}
/* ----------------
- * _copyHashPath
+ * _copyHashPath
* ----------------
*/
static HashPath *
-_copyHashPath(HashPath *from)
+_copyHashPath(HashPath * from)
{
- HashPath *newnode = makeNode(HashPath);
-
- /* ----------------
- * copy the node superclass fields
- * ----------------
- */
- CopyPathFields((Path*)from, (Path*)newnode);
- CopyJoinPathFields((JoinPath*)from, (JoinPath*)newnode);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, path_hashclauses);
- Node_Copy(from, newnode, outerhashkeys);
- Node_Copy(from, newnode, innerhashkeys);
-
- return newnode;
+ HashPath *newnode = makeNode(HashPath);
+
+ /* ----------------
+ * copy the node superclass fields
+ * ----------------
+ */
+ CopyPathFields((Path *) from, (Path *) newnode);
+ CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, path_hashclauses);
+ Node_Copy(from, newnode, outerhashkeys);
+ Node_Copy(from, newnode, innerhashkeys);
+
+ return newnode;
}
/* ----------------
- * _copyOrderKey
+ * _copyOrderKey
* ----------------
*/
static OrderKey *
-_copyOrderKey(OrderKey *from)
+_copyOrderKey(OrderKey * from)
{
- OrderKey *newnode = makeNode(OrderKey);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->attribute_number = from->attribute_number;
- newnode->array_index = from->array_index;
-
- return newnode;
+ OrderKey *newnode = makeNode(OrderKey);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->attribute_number = from->attribute_number;
+ newnode->array_index = from->array_index;
+
+ return newnode;
}
/* ----------------
- * _copyJoinKey
+ * _copyJoinKey
* ----------------
*/
static JoinKey *
-_copyJoinKey(JoinKey *from)
+_copyJoinKey(JoinKey * from)
{
- JoinKey *newnode = makeNode(JoinKey);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, outer);
- Node_Copy(from, newnode, inner);
-
- return newnode;
+ JoinKey *newnode = makeNode(JoinKey);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, outer);
+ Node_Copy(from, newnode, inner);
+
+ return newnode;
}
/* ----------------
- * _copyMergeOrder
+ * _copyMergeOrder
* ----------------
*/
static MergeOrder *
-_copyMergeOrder(MergeOrder *from)
+_copyMergeOrder(MergeOrder * from)
{
- MergeOrder *newnode = makeNode(MergeOrder);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->join_operator = from->join_operator;
- newnode->left_operator = from->left_operator;
- newnode->right_operator = from->right_operator;
- newnode->left_type = from->left_type;
- newnode->right_type = from->right_type;
-
- return newnode;
+ MergeOrder *newnode = makeNode(MergeOrder);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->join_operator = from->join_operator;
+ newnode->left_operator = from->left_operator;
+ newnode->right_operator = from->right_operator;
+ newnode->left_type = from->left_type;
+ newnode->right_type = from->right_type;
+
+ return newnode;
}
/* ----------------
- * _copyCInfo
+ * _copyCInfo
* ----------------
*/
-static CInfo *
-_copyCInfo(CInfo *from)
+static CInfo *
+_copyCInfo(CInfo * from)
{
- CInfo *newnode = makeNode(CInfo);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, clause);
-
- newnode->selectivity = from->selectivity;
- newnode->notclause = from->notclause;
-
- Node_Copy(from, newnode, indexids);
- Node_Copy(from, newnode, mergesortorder);
- newnode->hashjoinoperator = from->hashjoinoperator;
- newnode->cinfojoinid = listCopy(from->cinfojoinid);
-
- return newnode;
+ CInfo *newnode = makeNode(CInfo);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, clause);
+
+ newnode->selectivity = from->selectivity;
+ newnode->notclause = from->notclause;
+
+ Node_Copy(from, newnode, indexids);
+ Node_Copy(from, newnode, mergesortorder);
+ newnode->hashjoinoperator = from->hashjoinoperator;
+ newnode->cinfojoinid = listCopy(from->cinfojoinid);
+
+ return newnode;
}
/* ----------------
- * CopyJoinMethodFields
+ * CopyJoinMethodFields
*
- * This function copies the fields of the JoinMethod node. It is used by
- * all the copy functions for classes which inherit from JoinMethod.
+ * This function copies the fields of the JoinMethod node. It is used by
+ * all the copy functions for classes which inherit from JoinMethod.
* ----------------
*/
static void
-CopyJoinMethodFields(JoinMethod *from, JoinMethod *newnode)
+CopyJoinMethodFields(JoinMethod * from, JoinMethod * newnode)
{
- Node_Copy(from, newnode, jmkeys);
- Node_Copy(from, newnode, clauses);
- return;
+ Node_Copy(from, newnode, jmkeys);
+ Node_Copy(from, newnode, clauses);
+ return;
}
/* ----------------
- * _copyJoinMethod
+ * _copyJoinMethod
* ----------------
*/
static JoinMethod *
-_copyJoinMethod(JoinMethod *from)
+_copyJoinMethod(JoinMethod * from)
{
- JoinMethod *newnode = makeNode(JoinMethod);
-
- CopyJoinMethodFields(from, newnode);
-
- return newnode;
+ JoinMethod *newnode = makeNode(JoinMethod);
+
+ CopyJoinMethodFields(from, newnode);
+
+ return newnode;
}
/* ----------------
- * _copyHInfo
+ * _copyHInfo
* ----------------
*/
-static HInfo *
-_copyHInfo(HInfo *from)
+static HInfo *
+_copyHInfo(HInfo * from)
{
- HInfo *newnode = makeNode(HInfo);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->hashop = from->hashop;
-
- return newnode;
+ HInfo *newnode = makeNode(HInfo);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->hashop = from->hashop;
+
+ return newnode;
}
/* ----------------
- * _copyMInfo
+ * _copyMInfo
* ----------------
*/
-static MInfo *
-_copyMInfo(MInfo *from)
+static MInfo *
+_copyMInfo(MInfo * from)
{
- MInfo *newnode = makeNode(MInfo);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- Node_Copy(from, newnode, m_ordering);
-
- return newnode;
+ MInfo *newnode = makeNode(MInfo);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ Node_Copy(from, newnode, m_ordering);
+
+ return newnode;
}
/* ----------------
- * _copyJInfo
+ * _copyJInfo
* ----------------
*/
-static JInfo *
-_copyJInfo(JInfo *from)
+static JInfo *
+_copyJInfo(JInfo * from)
{
- JInfo *newnode = makeNode(JInfo);
-
- /* ----------------
- * copy remainder of node
- * ----------------
- */
- newnode->otherrels = listCopy(from->otherrels);
- Node_Copy(from, newnode, jinfoclauseinfo);
-
- newnode->mergesortable = from->mergesortable;
- newnode->hashjoinable = from->hashjoinable;
- newnode->inactive = from->inactive;
-
- return newnode;
+ JInfo *newnode = makeNode(JInfo);
+
+ /* ----------------
+ * copy remainder of node
+ * ----------------
+ */
+ newnode->otherrels = listCopy(from->otherrels);
+ Node_Copy(from, newnode, jinfoclauseinfo);
+
+ newnode->mergesortable = from->mergesortable;
+ newnode->hashjoinable = from->hashjoinable;
+ newnode->inactive = from->inactive;
+
+ return newnode;
}
-static Iter *
-_copyIter(Iter *from)
+static Iter *
+_copyIter(Iter * from)
{
- Iter *newnode = makeNode(Iter);
+ Iter *newnode = makeNode(Iter);
+
+ Node_Copy(from, newnode, iterexpr);
+ newnode->itertype = from->itertype;
- Node_Copy(from, newnode, iterexpr);
- newnode->itertype = from->itertype;
-
- return newnode;
+ return newnode;
}
-static Stream *
-_copyStream(Stream *from)
+static Stream *
+_copyStream(Stream * from)
{
- Stream *newnode = makeNode(Stream);
-
- newnode->pathptr = from->pathptr;
- newnode->cinfo = from->cinfo;
- newnode->clausetype = from->clausetype;
- newnode->groupup = from->groupup;
- newnode->groupcost = from->groupcost;
- newnode->groupsel = from->groupsel;
- newnode->upstream = (StreamPtr)NULL; /* only copy nodes downwards! */
- Node_Copy(from, newnode, downstream);
- if (newnode->downstream)
- ((Stream*)newnode->downstream)->upstream = (Stream*)newnode;
-
- return newnode;
+ Stream *newnode = makeNode(Stream);
+
+ newnode->pathptr = from->pathptr;
+ newnode->cinfo = from->cinfo;
+ newnode->clausetype = from->clausetype;
+ newnode->groupup = from->groupup;
+ newnode->groupcost = from->groupcost;
+ newnode->groupsel = from->groupsel;
+ newnode->upstream = (StreamPtr) NULL; /* only copy nodes
+ * downwards! */
+ Node_Copy(from, newnode, downstream);
+ if (newnode->downstream)
+ ((Stream *) newnode->downstream)->upstream = (Stream *) newnode;
+
+ return newnode;
}
/* ****************
- * parsenodes.h routines have no copy functions
+ * parsenodes.h routines have no copy functions
* ****************
*/
static TargetEntry *
-_copyTargetEntry(TargetEntry *from)
+_copyTargetEntry(TargetEntry * from)
{
- TargetEntry *newnode = makeNode(TargetEntry);
+ TargetEntry *newnode = makeNode(TargetEntry);
- Node_Copy(from, newnode, resdom);
- Node_Copy(from, newnode, fjoin);
- Node_Copy(from, newnode, expr);
- return newnode;
+ Node_Copy(from, newnode, resdom);
+ Node_Copy(from, newnode, fjoin);
+ Node_Copy(from, newnode, expr);
+ return newnode;
}
static RangeTblEntry *
-_copyRangeTblEntry(RangeTblEntry *from)
+_copyRangeTblEntry(RangeTblEntry * from)
{
- RangeTblEntry *newnode = makeNode(RangeTblEntry);
-
- memcpy (newnode, from, sizeof (RangeTblEntry));
- if ( from->relname )
- newnode->relname = pstrdup (from->relname);
- if ( from->refname )
- newnode->refname = pstrdup (from->refname);
- if ( from->timeRange )
- {
- newnode->timeRange = makeNode (TimeRange);
- if ( from->timeRange->startDate )
- newnode->timeRange->startDate = pstrdup (from->timeRange->startDate);
- else
- newnode->timeRange->startDate = NULL;
- if ( from->timeRange->endDate )
- newnode->timeRange->endDate = pstrdup (from->timeRange->endDate);
- else
- newnode->timeRange->endDate = NULL;
- newnode->timeQual = makeTimeRange (newnode->timeRange->startDate,
- newnode->timeRange->endDate,
- ((newnode->timeRange->endDate == NULL) ? 0 : 1));
- }
-
- return newnode;
+ RangeTblEntry *newnode = makeNode(RangeTblEntry);
+
+ memcpy(newnode, from, sizeof(RangeTblEntry));
+ if (from->relname)
+ newnode->relname = pstrdup(from->relname);
+ if (from->refname)
+ newnode->refname = pstrdup(from->refname);
+ if (from->timeRange)
+ {
+ newnode->timeRange = makeNode(TimeRange);
+ if (from->timeRange->startDate)
+ newnode->timeRange->startDate = pstrdup(from->timeRange->startDate);
+ else
+ newnode->timeRange->startDate = NULL;
+ if (from->timeRange->endDate)
+ newnode->timeRange->endDate = pstrdup(from->timeRange->endDate);
+ else
+ newnode->timeRange->endDate = NULL;
+ newnode->timeQual = makeTimeRange(newnode->timeRange->startDate,
+ newnode->timeRange->endDate,
+ ((newnode->timeRange->endDate == NULL) ? 0 : 1));
+ }
+
+ return newnode;
}
static SortClause *
-_copySortClause(SortClause *from)
+_copySortClause(SortClause * from)
{
- SortClause *newnode = makeNode(SortClause);
+ SortClause *newnode = makeNode(SortClause);
+
+ Node_Copy(from, newnode, resdom);
+ newnode->opoid = from->opoid;
- Node_Copy(from, newnode, resdom);
- newnode->opoid = from->opoid;
-
- return newnode;
+ return newnode;
}
static A_Const *
-_copyAConst(A_Const *from)
+_copyAConst(A_Const * from)
{
- A_Const *newnode = makeNode(A_Const);
+ A_Const *newnode = makeNode(A_Const);
- newnode->val = *((Value *)(copyObject(&(from->val))));
- Node_Copy(from, newnode, typename);
+ newnode->val = *((Value *) (copyObject(&(from->val))));
+ Node_Copy(from, newnode, typename);
- return newnode;
+ return newnode;
}
static TypeName *
-_copyTypeName(TypeName *from)
+_copyTypeName(TypeName * from)
{
- TypeName *newnode = makeNode(TypeName);
-
- if(from->name) {
- newnode->name = pstrdup(from->name);
- } else {
- from->name = (char *)0;
- }
- newnode->setof = from->setof;
- Node_Copy(from, newnode, arrayBounds);
- newnode->typlen = from->typlen;
-
- return newnode;
+ TypeName *newnode = makeNode(TypeName);
+
+ if (from->name)
+ {
+ newnode->name = pstrdup(from->name);
+ }
+ else
+ {
+ from->name = (char *) 0;
+ }
+ newnode->setof = from->setof;
+ Node_Copy(from, newnode, arrayBounds);
+ newnode->typlen = from->typlen;
+
+ return newnode;
}
-static Query *
-_copyQuery(Query *from)
+static Query *
+_copyQuery(Query * from)
{
- Query *newnode = makeNode(Query);
-
- newnode->commandType = from->commandType;
- newnode->resultRelation = from->resultRelation;
- /* probably should dup this string instead of just pointing */
- /* to the old one --djm */
- if(from->into) {
- newnode->into = pstrdup(from->into);
- } else {
- newnode->into = (char *)0;
- }
- newnode->isPortal = from->isPortal;
- Node_Copy(from, newnode, rtable);
- if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt) {
- NotifyStmt *from_notify = (NotifyStmt*)from->utilityStmt;
- NotifyStmt *n = makeNode(NotifyStmt);
- int length = strlen(from_notify->relname);
-
- n->relname = palloc(length + 1);
- strcpy(n->relname,from_notify->relname);
- newnode->utilityStmt = (Node*)n;
- }
- if (from->uniqueFlag) {
- newnode->uniqueFlag = (char*)palloc(strlen(from->uniqueFlag)+1);
- strcpy(newnode->uniqueFlag, from->uniqueFlag);
- }
- else
- newnode->uniqueFlag = NULL;
- Node_Copy(from, newnode, sortClause);
- Node_Copy(from, newnode, targetList);
- Node_Copy(from, newnode, qual);
-
- return newnode;
+ Query *newnode = makeNode(Query);
+
+ newnode->commandType = from->commandType;
+ newnode->resultRelation = from->resultRelation;
+ /* probably should dup this string instead of just pointing */
+ /* to the old one --djm */
+ if (from->into)
+ {
+ newnode->into = pstrdup(from->into);
+ }
+ else
+ {
+ newnode->into = (char *) 0;
+ }
+ newnode->isPortal = from->isPortal;
+ Node_Copy(from, newnode, rtable);
+ if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt)
+ {
+ NotifyStmt *from_notify = (NotifyStmt *) from->utilityStmt;
+ NotifyStmt *n = makeNode(NotifyStmt);
+ int length = strlen(from_notify->relname);
+
+ n->relname = palloc(length + 1);
+ strcpy(n->relname, from_notify->relname);
+ newnode->utilityStmt = (Node *) n;
+ }
+ if (from->uniqueFlag)
+ {
+ newnode->uniqueFlag = (char *) palloc(strlen(from->uniqueFlag) + 1);
+ strcpy(newnode->uniqueFlag, from->uniqueFlag);
+ }
+ else
+ newnode->uniqueFlag = NULL;
+ Node_Copy(from, newnode, sortClause);
+ Node_Copy(from, newnode, targetList);
+ Node_Copy(from, newnode, qual);
+
+ return newnode;
}
/* ****************
- * mnodes.h routines have no copy functions
+ * mnodes.h routines have no copy functions
* ****************
*/
/* ****************************************************************
- * pg_list.h copy functions
+ * pg_list.h copy functions
* ****************************************************************
*/
-static Value *
-_copyValue(Value *from)
+static Value *
+_copyValue(Value * from)
{
- Value *newnode = makeNode(Value);
-
- newnode->type = from->type;
- switch(from->type) {
- case T_String:
- newnode->val.str = pstrdup(from->val.str);
- break;
- case T_Integer:
- newnode->val.ival = from->val.ival;
- break;
- case T_Float:
- newnode->val.dval = from->val.dval;
- break;
- default:
- break;
- }
- return newnode;
+ Value *newnode = makeNode(Value);
+
+ newnode->type = from->type;
+ switch (from->type)
+ {
+ case T_String:
+ newnode->val.str = pstrdup(from->val.str);
+ break;
+ case T_Integer:
+ newnode->val.ival = from->val.ival;
+ break;
+ case T_Float:
+ newnode->val.dval = from->val.dval;
+ break;
+ default:
+ break;
+ }
+ return newnode;
}
/* ----------------
- * copyObject returns a copy of the node or list. If it is a list, it
- * recursively copies its items.
+ * copyObject returns a copy of the node or list. If it is a list, it
+ * recursively copies its items.
* ----------------
*/
-void *
+void *
copyObject(void *from)
{
- void *retval;
-
- if (from==NULL)
- return NULL;
- switch(nodeTag(from)) {
- /*
- * PLAN NODES
- */
- case T_Plan:
- retval = _copyPlan(from);
- break;
- case T_Existential:
- retval = _copyExistential(from);
- break;
- case T_Result:
- retval = _copyResult(from);
- break;
- case T_Append:
- retval = _copyAppend(from);
- break;
- case T_Scan:
- retval = _copyScan(from);
- break;
- case T_SeqScan:
- retval = _copySeqScan(from);
- break;
- case T_IndexScan:
- retval = _copyIndexScan(from);
- break;
- case T_Join:
- retval = _copyJoin(from);
- break;
- case T_NestLoop:
- retval = _copyNestLoop(from);
- break;
- case T_MergeJoin:
- retval = _copyMergeJoin(from);
- break;
- case T_HashJoin:
- retval = _copyHashJoin(from);
- break;
- case T_Temp:
- retval = _copyTemp(from);
- break;
- case T_Material:
- retval = _copyMaterial(from);
- break;
- case T_Sort:
- retval = _copySort(from);
- break;
- case T_Agg:
- retval = _copyAgg(from);
- break;
- case T_Unique:
- retval = _copyUnique(from);
- break;
- case T_Hash:
- retval = _copyHash(from);
- break;
-
- /*
- * PRIMITIVE NODES
- */
- case T_Resdom:
- retval = _copyResdom(from);
- break;
- case T_Fjoin:
- retval = _copyFjoin(from);
- break;
- case T_Expr:
- retval = _copyExpr(from);
- break;
- case T_Var:
- retval = _copyVar(from);
- break;
- case T_Oper:
- retval = _copyOper(from);
- break;
- case T_Const:
- retval = _copyConst(from);
- break;
- case T_Param:
- retval = _copyParam(from);
- break;
- case T_Func:
- retval = _copyFunc(from);
- break;
- case T_Array:
- retval = _copyArray(from);
- break;
- case T_ArrayRef:
- retval = _copyArrayRef(from);
- break;
- case T_Aggreg:
- retval = _copyAggreg(from);
- break;
- /*
- * RELATION NODES
- */
- case T_Rel:
- retval = _copyRel(from);
- break;
- case T_Path:
- retval = _copyPath(from);
- break;
- case T_IndexPath:
- retval = _copyIndexPath(from);
- break;
- case T_JoinPath:
- retval = _copyJoinPath(from);
- break;
- case T_MergePath:
- retval = _copyMergePath(from);
- break;
- case T_HashPath:
- retval = _copyHashPath(from);
- break;
- case T_OrderKey:
- retval = _copyOrderKey(from);
- break;
- case T_JoinKey:
- retval = _copyJoinKey(from);
- break;
- case T_MergeOrder:
- retval = _copyMergeOrder(from);
- break;
- case T_CInfo:
- retval = _copyCInfo(from);
- break;
- case T_JoinMethod:
- retval = _copyJoinMethod(from);
- break;
- case T_HInfo:
- retval = _copyHInfo(from);
- break;
- case T_MInfo:
- retval = _copyMInfo(from);
- break;
- case T_JInfo:
- retval = _copyJInfo(from);
- break;
- case T_Iter:
- retval = _copyIter(from);
- break;
- case T_Stream:
- retval = _copyStream(from);
- break;
+ void *retval;
- /*
- * PARSE NODES
- */
- case T_Query:
- retval = _copyQuery(from);
- break;
- case T_TargetEntry:
- retval = _copyTargetEntry(from);
- break;
- case T_RangeTblEntry:
- retval = _copyRangeTblEntry(from);
- break;
- case T_SortClause:
- retval = _copySortClause(from);
- break;
- case T_A_Const:
- retval = _copyAConst(from);
- break;
- case T_TypeName:
- retval = _copyTypeName(from);
- break;
-
- /*
- * VALUE NODES
- */
- case T_Integer: case T_String: case T_Float:
- retval = _copyValue(from);
- break;
- case T_List:
+ if (from == NULL)
+ return NULL;
+ switch (nodeTag(from))
{
- List *list=from, *l;
- List *newlist = NIL, *nl=NIL;
- foreach(l, list) {
- if (newlist==NIL) {
- newlist = nl = lcons(copyObject(lfirst(l)),NIL);
- }else {
- lnext(nl) = lcons(copyObject(lfirst(l)),NIL);
- nl = lnext(nl);
+
+ /*
+ * PLAN NODES
+ */
+ case T_Plan:
+ retval = _copyPlan(from);
+ break;
+ case T_Existential:
+ retval = _copyExistential(from);
+ break;
+ case T_Result:
+ retval = _copyResult(from);
+ break;
+ case T_Append:
+ retval = _copyAppend(from);
+ break;
+ case T_Scan:
+ retval = _copyScan(from);
+ break;
+ case T_SeqScan:
+ retval = _copySeqScan(from);
+ break;
+ case T_IndexScan:
+ retval = _copyIndexScan(from);
+ break;
+ case T_Join:
+ retval = _copyJoin(from);
+ break;
+ case T_NestLoop:
+ retval = _copyNestLoop(from);
+ break;
+ case T_MergeJoin:
+ retval = _copyMergeJoin(from);
+ break;
+ case T_HashJoin:
+ retval = _copyHashJoin(from);
+ break;
+ case T_Temp:
+ retval = _copyTemp(from);
+ break;
+ case T_Material:
+ retval = _copyMaterial(from);
+ break;
+ case T_Sort:
+ retval = _copySort(from);
+ break;
+ case T_Agg:
+ retval = _copyAgg(from);
+ break;
+ case T_Unique:
+ retval = _copyUnique(from);
+ break;
+ case T_Hash:
+ retval = _copyHash(from);
+ break;
+
+ /*
+ * PRIMITIVE NODES
+ */
+ case T_Resdom:
+ retval = _copyResdom(from);
+ break;
+ case T_Fjoin:
+ retval = _copyFjoin(from);
+ break;
+ case T_Expr:
+ retval = _copyExpr(from);
+ break;
+ case T_Var:
+ retval = _copyVar(from);
+ break;
+ case T_Oper:
+ retval = _copyOper(from);
+ break;
+ case T_Const:
+ retval = _copyConst(from);
+ break;
+ case T_Param:
+ retval = _copyParam(from);
+ break;
+ case T_Func:
+ retval = _copyFunc(from);
+ break;
+ case T_Array:
+ retval = _copyArray(from);
+ break;
+ case T_ArrayRef:
+ retval = _copyArrayRef(from);
+ break;
+ case T_Aggreg:
+ retval = _copyAggreg(from);
+ break;
+
+ /*
+ * RELATION NODES
+ */
+ case T_Rel:
+ retval = _copyRel(from);
+ break;
+ case T_Path:
+ retval = _copyPath(from);
+ break;
+ case T_IndexPath:
+ retval = _copyIndexPath(from);
+ break;
+ case T_JoinPath:
+ retval = _copyJoinPath(from);
+ break;
+ case T_MergePath:
+ retval = _copyMergePath(from);
+ break;
+ case T_HashPath:
+ retval = _copyHashPath(from);
+ break;
+ case T_OrderKey:
+ retval = _copyOrderKey(from);
+ break;
+ case T_JoinKey:
+ retval = _copyJoinKey(from);
+ break;
+ case T_MergeOrder:
+ retval = _copyMergeOrder(from);
+ break;
+ case T_CInfo:
+ retval = _copyCInfo(from);
+ break;
+ case T_JoinMethod:
+ retval = _copyJoinMethod(from);
+ break;
+ case T_HInfo:
+ retval = _copyHInfo(from);
+ break;
+ case T_MInfo:
+ retval = _copyMInfo(from);
+ break;
+ case T_JInfo:
+ retval = _copyJInfo(from);
+ break;
+ case T_Iter:
+ retval = _copyIter(from);
+ break;
+ case T_Stream:
+ retval = _copyStream(from);
+ break;
+
+ /*
+ * PARSE NODES
+ */
+ case T_Query:
+ retval = _copyQuery(from);
+ break;
+ case T_TargetEntry:
+ retval = _copyTargetEntry(from);
+ break;
+ case T_RangeTblEntry:
+ retval = _copyRangeTblEntry(from);
+ break;
+ case T_SortClause:
+ retval = _copySortClause(from);
+ break;
+ case T_A_Const:
+ retval = _copyAConst(from);
+ break;
+ case T_TypeName:
+ retval = _copyTypeName(from);
+ break;
+
+ /*
+ * VALUE NODES
+ */
+ case T_Integer:
+ case T_String:
+ case T_Float:
+ retval = _copyValue(from);
+ break;
+ case T_List:
+ {
+ List *list = from,
+ *l;
+ List *newlist = NIL,
+ *nl = NIL;
+
+ foreach(l, list)
+ {
+ if (newlist == NIL)
+ {
+ newlist = nl = lcons(copyObject(lfirst(l)), NIL);
+ }
+ else
+ {
+ lnext(nl) = lcons(copyObject(lfirst(l)), NIL);
+ nl = lnext(nl);
+ }
+ }
+ retval = newlist;
}
- }
- retval = newlist;
+ break;
+ default:
+ elog(NOTICE, "copyObject: don't know how to copy %d", nodeTag(from));
+ retval = from;
+ break;
}
- break;
- default:
- elog(NOTICE, "copyObject: don't know how to copy %d", nodeTag(from));
- retval = from;
- break;
- }
- return retval;
+ return retval;
}
-
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 4a8a072d33f..792c8783f99 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* equalfuncs.c--
- * equal functions to compare the nodes
+ * equal functions to compare the nodes
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.6 1997/08/19 21:31:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.7 1997/09/07 04:42:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,700 +26,717 @@
#include "utils/elog.h"
#include "storage/itemptr.h"
-static bool equali(List *a, List *b);
+static bool equali(List * a, List * b);
/*
- * Stuff from primnodes.h
+ * Stuff from primnodes.h
*/
/*
- * Resdom is a subclass of Node.
+ * Resdom is a subclass of Node.
*/
-static bool
-_equalResdom(Resdom *a, Resdom *b)
+static bool
+_equalResdom(Resdom * a, Resdom * b)
{
- if (a->resno != b->resno)
- return (false);
- if (a->restype != b->restype)
- return (false);
- if (a->reslen != b->reslen)
- return (false);
- if (strcmp(a->resname, b->resname) != 0)
- return (false);
- if (a->reskey != b->reskey)
- return (false);
- if (a->reskeyop != b->reskeyop)
- return (false);
-
- return (true);
+ if (a->resno != b->resno)
+ return (false);
+ if (a->restype != b->restype)
+ return (false);
+ if (a->reslen != b->reslen)
+ return (false);
+ if (strcmp(a->resname, b->resname) != 0)
+ return (false);
+ if (a->reskey != b->reskey)
+ return (false);
+ if (a->reskeyop != b->reskeyop)
+ return (false);
+
+ return (true);
}
-static bool
-_equalFjoin(Fjoin *a, Fjoin *b)
+static bool
+_equalFjoin(Fjoin * a, Fjoin * b)
{
- int nNodes;
-
- if (a->fj_initialized != b->fj_initialized)
- return (false);
- if (a->fj_nNodes != b->fj_nNodes)
- return (false);
- if (!equal(a->fj_innerNode, b->fj_innerNode))
- return (false);
-
- nNodes = a->fj_nNodes;
- if (memcmp(a->fj_results, b->fj_results, nNodes*sizeof(Datum)) != 0)
- return (false);
- if (memcmp(a->fj_alwaysDone, b->fj_alwaysDone, nNodes*sizeof(bool)) != 0)
- return (false);
-
- return(true);
+ int nNodes;
+
+ if (a->fj_initialized != b->fj_initialized)
+ return (false);
+ if (a->fj_nNodes != b->fj_nNodes)
+ return (false);
+ if (!equal(a->fj_innerNode, b->fj_innerNode))
+ return (false);
+
+ nNodes = a->fj_nNodes;
+ if (memcmp(a->fj_results, b->fj_results, nNodes * sizeof(Datum)) != 0)
+ return (false);
+ if (memcmp(a->fj_alwaysDone, b->fj_alwaysDone, nNodes * sizeof(bool)) != 0)
+ return (false);
+
+ return (true);
}
/*
- * Expr is a subclass of Node.
+ * Expr is a subclass of Node.
*/
-static bool
-_equalExpr(Expr *a, Expr *b)
+static bool
+_equalExpr(Expr * a, Expr * b)
{
- if (a->opType != b->opType)
- return (false);
- if (!equal(a->oper, b->oper))
- return (false);
- if (!equal(a->args, b->args))
- return (false);
-
- return (true);
+ if (a->opType != b->opType)
+ return (false);
+ if (!equal(a->oper, b->oper))
+ return (false);
+ if (!equal(a->args, b->args))
+ return (false);
+
+ return (true);
}
-static bool
-_equalIter(Iter *a, Iter *b)
+static bool
+_equalIter(Iter * a, Iter * b)
{
- return (equal(a->iterexpr, b->iterexpr));
+ return (equal(a->iterexpr, b->iterexpr));
}
-static bool
-_equalStream(Stream *a, Stream *b)
+static bool
+_equalStream(Stream * a, Stream * b)
{
- if (a->clausetype != b->clausetype)
- return(false);
- if (a->groupup != b->groupup)
- return(false);
- if (a->groupcost != b->groupcost)
- return(false);
- if (a->groupsel != b->groupsel)
- return(false);
- if (!equal(a->pathptr, b->pathptr))
- return(false);
- if (!equal(a->cinfo, b->cinfo))
- return(false);
- if (!equal(a->upstream, b->upstream))
- return(false);
- return(equal(a->downstream, b->downstream));
+ if (a->clausetype != b->clausetype)
+ return (false);
+ if (a->groupup != b->groupup)
+ return (false);
+ if (a->groupcost != b->groupcost)
+ return (false);
+ if (a->groupsel != b->groupsel)
+ return (false);
+ if (!equal(a->pathptr, b->pathptr))
+ return (false);
+ if (!equal(a->cinfo, b->cinfo))
+ return (false);
+ if (!equal(a->upstream, b->upstream))
+ return (false);
+ return (equal(a->downstream, b->downstream));
}
/*
- * Var is a subclass of Expr.
+ * Var is a subclass of Expr.
*/
-static bool
-_equalVar(Var *a, Var *b)
+static bool
+_equalVar(Var * a, Var * b)
{
- if (a->varno != b->varno)
- return (false);
- if (a->varattno != b->varattno)
- return (false);
- if (a->vartype != b->vartype)
- return (false);
- if (a->varnoold != b->varnoold)
- return (false);
- if (a->varoattno != b->varoattno)
- return (false);
-
- return (true);
+ if (a->varno != b->varno)
+ return (false);
+ if (a->varattno != b->varattno)
+ return (false);
+ if (a->vartype != b->vartype)
+ return (false);
+ if (a->varnoold != b->varnoold)
+ return (false);
+ if (a->varoattno != b->varoattno)
+ return (false);
+
+ return (true);
}
-static bool
-_equalArray(Array *a, Array *b)
+static bool
+_equalArray(Array * a, Array * b)
{
- if (a->arrayelemtype != b->arrayelemtype)
- return (false);
- if (a->arrayndim != b->arrayndim)
- return (false);
- if (a->arraylow.indx[0] != b->arraylow.indx[0])
- return (false);
- if (a->arrayhigh.indx[0] != b->arrayhigh.indx[0])
- return (false);
- if (a->arraylen != b->arraylen)
- return (false);
- return(TRUE);
+ if (a->arrayelemtype != b->arrayelemtype)
+ return (false);
+ if (a->arrayndim != b->arrayndim)
+ return (false);
+ if (a->arraylow.indx[0] != b->arraylow.indx[0])
+ return (false);
+ if (a->arrayhigh.indx[0] != b->arrayhigh.indx[0])
+ return (false);
+ if (a->arraylen != b->arraylen)
+ return (false);
+ return (TRUE);
}
-static bool
-_equalArrayRef(ArrayRef *a, ArrayRef *b)
+static bool
+_equalArrayRef(ArrayRef * a, ArrayRef * b)
{
- if (a->refelemtype != b->refelemtype)
- return (false);
- if (a->refattrlength != b->refattrlength)
- return (false);
- if (a->refelemlength != b->refelemlength)
- return (false);
- if (a->refelembyval != b->refelembyval)
- return (false);
- if (!equal(a->refupperindexpr, b->refupperindexpr))
- return (false);
- if (!equal(a->reflowerindexpr, b->reflowerindexpr))
- return (false);
- if (!equal(a->refexpr, b->refexpr))
- return (false);
- return (equal(a->refassgnexpr, b->refassgnexpr));
+ if (a->refelemtype != b->refelemtype)
+ return (false);
+ if (a->refattrlength != b->refattrlength)
+ return (false);
+ if (a->refelemlength != b->refelemlength)
+ return (false);
+ if (a->refelembyval != b->refelembyval)
+ return (false);
+ if (!equal(a->refupperindexpr, b->refupperindexpr))
+ return (false);
+ if (!equal(a->reflowerindexpr, b->reflowerindexpr))
+ return (false);
+ if (!equal(a->refexpr, b->refexpr))
+ return (false);
+ return (equal(a->refassgnexpr, b->refassgnexpr));
}
/*
- * Oper is a subclass of Expr.
+ * Oper is a subclass of Expr.
*/
-static bool
-_equalOper(Oper *a, Oper *b)
+static bool
+_equalOper(Oper * a, Oper * b)
{
- if (a->opno != b->opno)
- return (false);
- if (a->opresulttype != b->opresulttype)
- return (false);
-
- return (true);
+ if (a->opno != b->opno)
+ return (false);
+ if (a->opresulttype != b->opresulttype)
+ return (false);
+
+ return (true);
}
/*
- * Const is a subclass of Expr.
+ * Const is a subclass of Expr.
*/
-static bool
-_equalConst(Const *a, Const *b)
+static bool
+_equalConst(Const * a, Const * b)
{
- /*
- ** this function used to do a pointer compare on a and b. That's
- ** ridiculous. -- JMH, 7/11/92
- */
- if (a->consttype != b->consttype)
- return(false);
- if (a->constlen != b->constlen)
- return(false);
- if (a->constisnull != b->constisnull)
- return(false);
- if (a->constbyval != b->constbyval)
- return(false);
- return(datumIsEqual(a->constvalue, b->constvalue,
- a->consttype, a->constbyval, a->constlen));
+
+ /*
+ * * this function used to do a pointer compare on a and b. That's *
+ * ridiculous. -- JMH, 7/11/92
+ */
+ if (a->consttype != b->consttype)
+ return (false);
+ if (a->constlen != b->constlen)
+ return (false);
+ if (a->constisnull != b->constisnull)
+ return (false);
+ if (a->constbyval != b->constbyval)
+ return (false);
+ return (datumIsEqual(a->constvalue, b->constvalue,
+ a->consttype, a->constbyval, a->constlen));
}
/*
- * Param is a subclass of Expr.
+ * Param is a subclass of Expr.
*/
-static bool
-_equalParam(Param *a, Param *b)
+static bool
+_equalParam(Param * a, Param * b)
{
- if (a->paramkind != b->paramkind)
- return (false);
- if (a->paramtype != b->paramtype)
- return (false);
- if (!equal(a->param_tlist, b->param_tlist))
- return (false);
-
- switch (a->paramkind) {
- case PARAM_NAMED:
- case PARAM_NEW:
- case PARAM_OLD:
- if (strcmp(a->paramname, b->paramname) != 0)
- return (false);
- break;
- case PARAM_NUM:
- if (a->paramid != b->paramid)
- return (false);
- break;
- case PARAM_INVALID:
- /*
- * XXX: Hmmm... What are we supposed to return
- * in this case ??
- */
- return(true);
- break;
- default:
- elog(WARN, "_equalParam: Invalid paramkind value: %d",
- a->paramkind);
- }
-
- return (true);
+ if (a->paramkind != b->paramkind)
+ return (false);
+ if (a->paramtype != b->paramtype)
+ return (false);
+ if (!equal(a->param_tlist, b->param_tlist))
+ return (false);
+
+ switch (a->paramkind)
+ {
+ case PARAM_NAMED:
+ case PARAM_NEW:
+ case PARAM_OLD:
+ if (strcmp(a->paramname, b->paramname) != 0)
+ return (false);
+ break;
+ case PARAM_NUM:
+ if (a->paramid != b->paramid)
+ return (false);
+ break;
+ case PARAM_INVALID:
+
+ /*
+ * XXX: Hmmm... What are we supposed to return in this case ??
+ */
+ return (true);
+ break;
+ default:
+ elog(WARN, "_equalParam: Invalid paramkind value: %d",
+ a->paramkind);
+ }
+
+ return (true);
}
/*
- * Func is a subclass of Expr.
+ * Func is a subclass of Expr.
*/
-static bool
-_equalFunc(Func *a, Func *b)
+static bool
+_equalFunc(Func * a, Func * b)
{
- if (a->funcid != b->funcid)
- return (false);
- if (a->functype != b->functype)
- return (false);
- if (a->funcisindex != b->funcisindex)
- return (false);
- if (a->funcsize != b->funcsize)
- return (false);
- if (!equal(a->func_tlist, b->func_tlist))
- return (false);
- if (!equal(a->func_planlist, b->func_planlist))
- return (false);
-
- return (true);
+ if (a->funcid != b->funcid)
+ return (false);
+ if (a->functype != b->functype)
+ return (false);
+ if (a->funcisindex != b->funcisindex)
+ return (false);
+ if (a->funcsize != b->funcsize)
+ return (false);
+ if (!equal(a->func_tlist, b->func_tlist))
+ return (false);
+ if (!equal(a->func_planlist, b->func_planlist))
+ return (false);
+
+ return (true);
}
/*
* CInfo is a subclass of Node.
*/
-static bool
-_equalCInfo(CInfo *a, CInfo *b)
+static bool
+_equalCInfo(CInfo * a, CInfo * b)
{
- Assert(IsA(a,CInfo));
- Assert(IsA(b,CInfo));
-
- if (!equal(a->clause, b->clause))
- return(false);
- if (a->selectivity != b->selectivity)
- return(false);
- if (a->notclause != b->notclause)
- return(false);
+ Assert(IsA(a, CInfo));
+ Assert(IsA(b, CInfo));
+
+ if (!equal(a->clause, b->clause))
+ return (false);
+ if (a->selectivity != b->selectivity)
+ return (false);
+ if (a->notclause != b->notclause)
+ return (false);
#ifdef EqualMergeOrderExists
- if (!EqualMergeOrder(a->mergesortorder,b->mergesortorder))
- return(false);
+ if (!EqualMergeOrder(a->mergesortorder, b->mergesortorder))
+ return (false);
#endif
- if(a->hashjoinoperator != b->hashjoinoperator)
- return(false);
- return(equal((a->indexids),
- (b->indexids)));
+ if (a->hashjoinoperator != b->hashjoinoperator)
+ return (false);
+ return (equal((a->indexids),
+ (b->indexids)));
}
-static bool
-_equalJoinMethod(JoinMethod *a, JoinMethod *b)
+static bool
+_equalJoinMethod(JoinMethod * a, JoinMethod * b)
{
- Assert(IsA(a,JoinMethod));
- Assert(IsA(b,JoinMethod));
-
- if (!equal((a->jmkeys),
- (b->jmkeys)))
- return(false);
- if (!equal((a->clauses),
- (b->clauses)))
- return(false);
- return(true);
+ Assert(IsA(a, JoinMethod));
+ Assert(IsA(b, JoinMethod));
+
+ if (!equal((a->jmkeys),
+ (b->jmkeys)))
+ return (false);
+ if (!equal((a->clauses),
+ (b->clauses)))
+ return (false);
+ return (true);
}
-static bool
-_equalPath(Path *a, Path *b)
+static bool
+_equalPath(Path * a, Path * b)
{
- if (a->pathtype != b->pathtype)
- return(false);
- if (a->parent != b->parent)
- return(false);
- /*
- if (a->path_cost != b->path_cost)
- return(false);
- */
- if (a->p_ordering.ordtype == SORTOP_ORDER) {
- int i = 0;
- if (a->p_ordering.ord.sortop==NULL ||
- b->p_ordering.ord.sortop==NULL) {
-
- if (a->p_ordering.ord.sortop != b->p_ordering.ord.sortop)
- return false;
- } else {
- while(a->p_ordering.ord.sortop[i]!=0 &&
- b->p_ordering.ord.sortop[i]!=0) {
- if (a->p_ordering.ord.sortop[i] != b->p_ordering.ord.sortop[i])
- return false;
- i++;
- }
- if (a->p_ordering.ord.sortop[i]!=0 ||
- b->p_ordering.ord.sortop[i]!=0)
- return false;
+ if (a->pathtype != b->pathtype)
+ return (false);
+ if (a->parent != b->parent)
+ return (false);
+
+ /*
+ * if (a->path_cost != b->path_cost) return(false);
+ */
+ if (a->p_ordering.ordtype == SORTOP_ORDER)
+ {
+ int i = 0;
+
+ if (a->p_ordering.ord.sortop == NULL ||
+ b->p_ordering.ord.sortop == NULL)
+ {
+
+ if (a->p_ordering.ord.sortop != b->p_ordering.ord.sortop)
+ return false;
+ }
+ else
+ {
+ while (a->p_ordering.ord.sortop[i] != 0 &&
+ b->p_ordering.ord.sortop[i] != 0)
+ {
+ if (a->p_ordering.ord.sortop[i] != b->p_ordering.ord.sortop[i])
+ return false;
+ i++;
+ }
+ if (a->p_ordering.ord.sortop[i] != 0 ||
+ b->p_ordering.ord.sortop[i] != 0)
+ return false;
+ }
+ }
+ else
+ {
+ if (!equal((a->p_ordering.ord.merge),
+ (b->p_ordering.ord.merge)))
+ return (false);
}
- } else {
- if (!equal((a->p_ordering.ord.merge),
- (b->p_ordering.ord.merge)))
- return(false);
- }
- if (!equal((a->keys),
- (b->keys)))
- return(false);
- /*
- if (a->outerjoincost != b->outerjoincost)
- return(false);
- */
- if (!equali((a->joinid),
- (b->joinid)))
- return(false);
- return(true);
+ if (!equal((a->keys),
+ (b->keys)))
+ return (false);
+
+ /*
+ * if (a->outerjoincost != b->outerjoincost) return(false);
+ */
+ if (!equali((a->joinid),
+ (b->joinid)))
+ return (false);
+ return (true);
}
-static bool
-_equalIndexPath(IndexPath *a, IndexPath *b)
+static bool
+_equalIndexPath(IndexPath * a, IndexPath * b)
{
- if (!_equalPath((Path*)a,(Path*)b))
- return(false);
- if (!equali((a->indexid), (b->indexid)))
- return(false);
- if (!equal((a->indexqual), (b->indexqual)))
- return(false);
- return(true);
+ if (!_equalPath((Path *) a, (Path *) b))
+ return (false);
+ if (!equali((a->indexid), (b->indexid)))
+ return (false);
+ if (!equal((a->indexqual), (b->indexqual)))
+ return (false);
+ return (true);
}
-static bool
-_equalJoinPath(JoinPath *a,JoinPath *b)
+static bool
+_equalJoinPath(JoinPath * a, JoinPath * b)
{
- Assert(IsA_JoinPath(a));
- Assert(IsA_JoinPath(b));
-
- if (!_equalPath((Path*)a,(Path*)b))
- return(false);
- if (!equal((a->pathclauseinfo), (b->pathclauseinfo)))
- return(false);
- if (!equal((a->outerjoinpath), (b->outerjoinpath)))
- return(false);
- if (!equal((a->innerjoinpath), (b->innerjoinpath)))
- return(false);
- return(true);
+ Assert(IsA_JoinPath(a));
+ Assert(IsA_JoinPath(b));
+
+ if (!_equalPath((Path *) a, (Path *) b))
+ return (false);
+ if (!equal((a->pathclauseinfo), (b->pathclauseinfo)))
+ return (false);
+ if (!equal((a->outerjoinpath), (b->outerjoinpath)))
+ return (false);
+ if (!equal((a->innerjoinpath), (b->innerjoinpath)))
+ return (false);
+ return (true);
}
-static bool
-_equalMergePath(MergePath *a, MergePath *b)
+static bool
+_equalMergePath(MergePath * a, MergePath * b)
{
- Assert(IsA(a,MergePath));
- Assert(IsA(b,MergePath));
-
- if (!_equalJoinPath((JoinPath*)a,(JoinPath*)b))
- return(false);
- if (!equal((a->path_mergeclauses), (b->path_mergeclauses)))
- return(false);
- if (!equal((a->outersortkeys), (b->outersortkeys)))
- return(false);
- if (!equal((a->innersortkeys), (b->innersortkeys)))
- return(false);
- return(true);
+ Assert(IsA(a, MergePath));
+ Assert(IsA(b, MergePath));
+
+ if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
+ return (false);
+ if (!equal((a->path_mergeclauses), (b->path_mergeclauses)))
+ return (false);
+ if (!equal((a->outersortkeys), (b->outersortkeys)))
+ return (false);
+ if (!equal((a->innersortkeys), (b->innersortkeys)))
+ return (false);
+ return (true);
}
-static bool
-_equalHashPath(HashPath *a, HashPath *b)
+static bool
+_equalHashPath(HashPath * a, HashPath * b)
{
- Assert(IsA(a,HashPath));
- Assert(IsA(b,HashPath));
-
- if (!_equalJoinPath((JoinPath*)a,(JoinPath*)b))
- return(false);
- if (!equal((a->path_hashclauses), (b->path_hashclauses)))
- return(false);
- if (!equal((a->outerhashkeys), (b->outerhashkeys)))
- return(false);
- if (!equal((a->innerhashkeys), (b->innerhashkeys)))
- return(false);
- return(true);
+ Assert(IsA(a, HashPath));
+ Assert(IsA(b, HashPath));
+
+ if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
+ return (false);
+ if (!equal((a->path_hashclauses), (b->path_hashclauses)))
+ return (false);
+ if (!equal((a->outerhashkeys), (b->outerhashkeys)))
+ return (false);
+ if (!equal((a->innerhashkeys), (b->innerhashkeys)))
+ return (false);
+ return (true);
}
-static bool
-_equalJoinKey(JoinKey *a, JoinKey *b)
+static bool
+_equalJoinKey(JoinKey * a, JoinKey * b)
{
- Assert(IsA(a,JoinKey));
- Assert(IsA(b,JoinKey));
-
- if (!equal((a->outer),(b->outer)))
- return(false);
- if (!equal((a->inner),(b->inner)))
- return(false);
- return(true);
+ Assert(IsA(a, JoinKey));
+ Assert(IsA(b, JoinKey));
+
+ if (!equal((a->outer), (b->outer)))
+ return (false);
+ if (!equal((a->inner), (b->inner)))
+ return (false);
+ return (true);
}
-static bool
-_equalMergeOrder(MergeOrder *a, MergeOrder *b)
+static bool
+_equalMergeOrder(MergeOrder * a, MergeOrder * b)
{
- if (a == (MergeOrder*)NULL && b == (MergeOrder*)NULL)
- return(true);
- Assert(IsA(a,MergeOrder));
- Assert(IsA(b,MergeOrder));
-
- if (a->join_operator != b->join_operator)
- return(false);
- if (a->left_operator != b->left_operator)
- return(false);
- if (a->right_operator != b->right_operator)
- return(false);
- if (a->left_type != b->left_type)
- return(false);
- if (a->right_type != b->right_type)
- return(false);
- return(true);
+ if (a == (MergeOrder *) NULL && b == (MergeOrder *) NULL)
+ return (true);
+ Assert(IsA(a, MergeOrder));
+ Assert(IsA(b, MergeOrder));
+
+ if (a->join_operator != b->join_operator)
+ return (false);
+ if (a->left_operator != b->left_operator)
+ return (false);
+ if (a->right_operator != b->right_operator)
+ return (false);
+ if (a->left_type != b->left_type)
+ return (false);
+ if (a->right_type != b->right_type)
+ return (false);
+ return (true);
}
-static bool
-_equalHInfo(HInfo *a, HInfo *b)
+static bool
+_equalHInfo(HInfo * a, HInfo * b)
{
- Assert(IsA(a,HInfo));
- Assert(IsA(b,HInfo));
-
- if (a->hashop != b->hashop)
- return(false);
- return(true);
+ Assert(IsA(a, HInfo));
+ Assert(IsA(b, HInfo));
+
+ if (a->hashop != b->hashop)
+ return (false);
+ return (true);
}
-/* XXX This equality function is a quick hack, should be
- * fixed to compare all fields.
+/* XXX This equality function is a quick hack, should be
+ * fixed to compare all fields.
*/
-static bool
-_equalIndexScan(IndexScan *a, IndexScan *b)
+static bool
+_equalIndexScan(IndexScan * a, IndexScan * b)
{
- Assert(IsA(a,IndexScan));
- Assert(IsA(b,IndexScan));
-
- /*
- if(a->scan.plan.cost != b->scan.plan.cost)
- return(false);
- */
-
- if (!equal((a->indxqual),(b->indxqual)))
- return(false);
-
- if (a->scan.scanrelid != b->scan.scanrelid)
- return(false);
-
- if (!equali((a->indxid),(b->indxid)))
- return(false);
- return(true);
+ Assert(IsA(a, IndexScan));
+ Assert(IsA(b, IndexScan));
+
+ /*
+ * if(a->scan.plan.cost != b->scan.plan.cost) return(false);
+ */
+
+ if (!equal((a->indxqual), (b->indxqual)))
+ return (false);
+
+ if (a->scan.scanrelid != b->scan.scanrelid)
+ return (false);
+
+ if (!equali((a->indxid), (b->indxid)))
+ return (false);
+ return (true);
}
-static bool
-_equalJInfo(JInfo *a, JInfo *b)
+static bool
+_equalJInfo(JInfo * a, JInfo * b)
{
- Assert(IsA(a,JInfo));
- Assert(IsA(b,JInfo));
- if (!equal((a->otherrels),(b->otherrels)))
- return(false);
- if (!equal((a->jinfoclauseinfo),(b->jinfoclauseinfo)))
- return(false);
- if (a->mergesortable != b->mergesortable)
- return(false);
- if (a->hashjoinable != b->hashjoinable)
- return(false);
- return(true);
+ Assert(IsA(a, JInfo));
+ Assert(IsA(b, JInfo));
+ if (!equal((a->otherrels), (b->otherrels)))
+ return (false);
+ if (!equal((a->jinfoclauseinfo), (b->jinfoclauseinfo)))
+ return (false);
+ if (a->mergesortable != b->mergesortable)
+ return (false);
+ if (a->hashjoinable != b->hashjoinable)
+ return (false);
+ return (true);
}
/*
- * Stuff from execnodes.h
+ * Stuff from execnodes.h
*/
/*
- * EState is a subclass of Node.
+ * EState is a subclass of Node.
*/
-static bool
-_equalEState(EState *a, EState *b)
+static bool
+_equalEState(EState * a, EState * b)
{
- if (a->es_direction != b->es_direction)
- return (false);
-
- if (!equal(a->es_range_table, b->es_range_table))
- return (false);
-
- if (a->es_result_relation_info != b->es_result_relation_info)
- return (false);
-
- return (true);
+ if (a->es_direction != b->es_direction)
+ return (false);
+
+ if (!equal(a->es_range_table, b->es_range_table))
+ return (false);
+
+ if (a->es_result_relation_info != b->es_result_relation_info)
+ return (false);
+
+ return (true);
}
-static bool
-_equalTargetEntry(TargetEntry *a, TargetEntry *b)
+static bool
+_equalTargetEntry(TargetEntry * a, TargetEntry * b)
{
- if (!equal(a->resdom,b->resdom))
- return(false);
- if (!equal(a->fjoin,b->fjoin))
- return(false);
- if (!equal(a->expr,b->expr))
- return(false);
-
- return(true);
+ if (!equal(a->resdom, b->resdom))
+ return (false);
+ if (!equal(a->fjoin, b->fjoin))
+ return (false);
+ if (!equal(a->expr, b->expr))
+ return (false);
+
+ return (true);
}
/*
- * equal -- are two lists equal?
+ * equal -- are two lists equal?
*
- * This is a comparison by value. It would be simpler to write it
- * to be recursive, but it should run faster if we iterate.
+ * This is a comparison by value. It would be simpler to write it
+ * to be recursive, but it should run faster if we iterate.
*/
-static bool
-_equalValue(Value *a, Value *b)
+static bool
+_equalValue(Value * a, Value * b)
{
- if (a->type != b->type)
- return (false);
-
- switch(a->type) {
- case T_String:
- return strcmp(a->val.str, b->val.str);
- case T_Integer:
- return (a->val.ival==b->val.ival);
- case T_Float:
- return (a->val.dval==b->val.dval);
- default:
- break;
- }
-
- return (true);
+ if (a->type != b->type)
+ return (false);
+
+ switch (a->type)
+ {
+ case T_String:
+ return strcmp(a->val.str, b->val.str);
+ case T_Integer:
+ return (a->val.ival == b->val.ival);
+ case T_Float:
+ return (a->val.dval == b->val.dval);
+ default:
+ break;
+ }
+
+ return (true);
}
/*
* equal--
- * returns whether two nodes are equal
+ * returns whether two nodes are equal
*/
bool
equal(void *a, void *b)
{
- bool retval=false;
-
- if (a == b)
- return(true);
- /*
- * note that a!=b, so only one of them can be NULL
- */
- if (a==NULL || b==NULL)
- return (false);
- /*
- * are they the same type of nodes?
- */
- if (nodeTag(a)!=nodeTag(b))
- return (false);
-
- switch(nodeTag(a)) {
- case T_Resdom:
- retval = _equalResdom(a, b);
- break;
- case T_Fjoin:
- retval = _equalFjoin(a, b);
- break;
- case T_Expr:
- retval = _equalExpr(a, b);
- break;
- case T_TargetEntry:
- retval = _equalTargetEntry(a,b);
- break;
- case T_Iter:
- retval = _equalIter(a, b);
- break;
- case T_Stream:
- retval = _equalStream(a, b);
- break;
- case T_Var:
- retval = _equalVar(a, b);
- break;
- case T_Array:
- retval = _equalArray(a, b);
- break;
- case T_ArrayRef:
- retval = _equalArrayRef(a, b);
- break;
- case T_Oper:
- retval = _equalOper(a, b);
- break;
- case T_Const:
- retval = _equalConst(a, b);
- break;
- case T_Param:
- retval = _equalParam(a, b);
- break;
- case T_Func:
- retval = _equalFunc(a, b);
- break;
- case T_CInfo:
- retval = _equalCInfo(a, b);
- break;
- case T_JoinMethod:
- retval = _equalJoinMethod(a, b);
- break;
- case T_Path:
- retval = _equalPath(a, b);
- break;
- case T_IndexPath:
- retval = _equalIndexPath(a, b);
- break;
- case T_JoinPath:
- retval = _equalJoinPath(a, b);
- break;
- case T_MergePath:
- retval = _equalMergePath(a, b);
- break;
- case T_HashPath:
- retval = _equalHashPath(a, b);
- break;
- case T_JoinKey:
- retval = _equalJoinKey(a, b);
- break;
- case T_MergeOrder:
- retval = _equalMergeOrder(a, b);
- break;
- case T_HInfo:
- retval = _equalHInfo(a, b);
- break;
- case T_IndexScan:
- retval = _equalIndexScan(a, b);
- break;
- case T_JInfo:
- retval = _equalJInfo(a, b);
- break;
- case T_EState:
- retval = _equalEState(a, b);
- break;
- case T_Integer: case T_String: case T_Float:
- retval = _equalValue(a, b);
- break;
- case T_List:
- {
- List *la = (List*)a;
- List *lb = (List*)b;
- List *l;
+ bool retval = false;
- if (a==NULL && b==NULL)
+ if (a == b)
return (true);
- if (length(a)!=length(b))
+
+ /*
+ * note that a!=b, so only one of them can be NULL
+ */
+ if (a == NULL || b == NULL)
return (false);
- foreach(l, la) {
- if (!equal(lfirst(l), lfirst(lb)))
- return (false);
- lb = lnext(lb);
- }
- retval = true;
+
+ /*
+ * are they the same type of nodes?
+ */
+ if (nodeTag(a) != nodeTag(b))
+ return (false);
+
+ switch (nodeTag(a))
+ {
+ case T_Resdom:
+ retval = _equalResdom(a, b);
+ break;
+ case T_Fjoin:
+ retval = _equalFjoin(a, b);
+ break;
+ case T_Expr:
+ retval = _equalExpr(a, b);
+ break;
+ case T_TargetEntry:
+ retval = _equalTargetEntry(a, b);
+ break;
+ case T_Iter:
+ retval = _equalIter(a, b);
+ break;
+ case T_Stream:
+ retval = _equalStream(a, b);
+ break;
+ case T_Var:
+ retval = _equalVar(a, b);
+ break;
+ case T_Array:
+ retval = _equalArray(a, b);
+ break;
+ case T_ArrayRef:
+ retval = _equalArrayRef(a, b);
+ break;
+ case T_Oper:
+ retval = _equalOper(a, b);
+ break;
+ case T_Const:
+ retval = _equalConst(a, b);
+ break;
+ case T_Param:
+ retval = _equalParam(a, b);
+ break;
+ case T_Func:
+ retval = _equalFunc(a, b);
+ break;
+ case T_CInfo:
+ retval = _equalCInfo(a, b);
+ break;
+ case T_JoinMethod:
+ retval = _equalJoinMethod(a, b);
+ break;
+ case T_Path:
+ retval = _equalPath(a, b);
+ break;
+ case T_IndexPath:
+ retval = _equalIndexPath(a, b);
+ break;
+ case T_JoinPath:
+ retval = _equalJoinPath(a, b);
+ break;
+ case T_MergePath:
+ retval = _equalMergePath(a, b);
+ break;
+ case T_HashPath:
+ retval = _equalHashPath(a, b);
+ break;
+ case T_JoinKey:
+ retval = _equalJoinKey(a, b);
+ break;
+ case T_MergeOrder:
+ retval = _equalMergeOrder(a, b);
+ break;
+ case T_HInfo:
+ retval = _equalHInfo(a, b);
+ break;
+ case T_IndexScan:
+ retval = _equalIndexScan(a, b);
+ break;
+ case T_JInfo:
+ retval = _equalJInfo(a, b);
+ break;
+ case T_EState:
+ retval = _equalEState(a, b);
+ break;
+ case T_Integer:
+ case T_String:
+ case T_Float:
+ retval = _equalValue(a, b);
+ break;
+ case T_List:
+ {
+ List *la = (List *) a;
+ List *lb = (List *) b;
+ List *l;
+
+ if (a == NULL && b == NULL)
+ return (true);
+ if (length(a) != length(b))
+ return (false);
+ foreach(l, la)
+ {
+ if (!equal(lfirst(l), lfirst(lb)))
+ return (false);
+ lb = lnext(lb);
+ }
+ retval = true;
+ }
+ break;
+ default:
+ elog(NOTICE, "equal: don't know whether nodes of type %d are equal",
+ nodeTag(a));
+ break;
}
- break;
- default:
- elog(NOTICE, "equal: don't know whether nodes of type %d are equal",
- nodeTag(a));
- break;
- }
-
- return retval;
+
+ return retval;
}
/*
* equali--
- * compares two lists of integers
+ * compares two lists of integers
*
* XXX temp hack. needs something like T_IntList
*/
-static bool
-equali(List *a, List *b)
-{
- List *la = (List*)a;
- List *lb = (List*)b;
- List *l;
-
- if (a==NULL && b==NULL)
- return (true);
- if (length(a)!=length(b))
- return (false);
- foreach(l, la) {
- if (lfirsti(l) != lfirsti(lb))
- return (false);
- lb = lnext(lb);
- }
- return true;
+static bool
+equali(List * a, List * b)
+{
+ List *la = (List *) a;
+ List *lb = (List *) b;
+ List *l;
+
+ if (a == NULL && b == NULL)
+ return (true);
+ if (length(a) != length(b))
+ return (false);
+ foreach(l, la)
+ {
+ if (lfirsti(l) != lfirsti(lb))
+ return (false);
+ lb = lnext(lb);
+ }
+ return true;
}
diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c
index 6dc010eff65..334030822f7 100644
--- a/src/backend/nodes/list.c
+++ b/src/backend/nodes/list.c
@@ -1,23 +1,23 @@
/*-------------------------------------------------------------------------
*
* list.c--
- * various list handling routines
+ * various list handling routines
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.4 1997/08/19 21:31:39 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.5 1997/09/07 04:42:46 momjian Exp $
*
* NOTES
- * XXX a few of the following functions are duplicated to handle
- * List of pointers and List of integers separately. Some day,
- * someone should unify them. - ay 11/2/94
- * This file needs cleanup.
+ * XXX a few of the following functions are duplicated to handle
+ * List of pointers and List of integers separately. Some day,
+ * someone should unify them. - ay 11/2/94
+ * This file needs cleanup.
*
* HISTORY
- * AUTHOR DATE MAJOR EVENT
- * Andrew Yu Oct, 1994 file creation
+ * AUTHOR DATE MAJOR EVENT
+ * Andrew Yu Oct, 1994 file creation
*
*-------------------------------------------------------------------------
*/
@@ -25,442 +25,483 @@
#include "postgres.h"
#include "nodes/pg_list.h"
#include "nodes/parsenodes.h"
-#include "utils/builtins.h" /* for namecpy */
+#include "utils/builtins.h" /* for namecpy */
#include "utils/elog.h"
#include "utils/palloc.h"
-List *
-makeList(void *elem, ...)
+List *
+makeList(void *elem,...)
{
- va_list args;
- List *retval = NIL;
- List *temp = NIL;
- List *tempcons = NIL;
-
- va_start(args, elem);
-
- temp = elem;
- while (temp != (void *) -1) {
- temp = lcons(temp, NIL);
- if (tempcons == NIL)
- retval = temp;
- else
- lnext(tempcons) = temp;
- tempcons = temp;
-
- temp = va_arg(args, void *);
- }
+ va_list args;
+ List *retval = NIL;
+ List *temp = NIL;
+ List *tempcons = NIL;
+
+ va_start(args, elem);
+
+ temp = elem;
+ while (temp != (void *) -1)
+ {
+ temp = lcons(temp, NIL);
+ if (tempcons == NIL)
+ retval = temp;
+ else
+ lnext(tempcons) = temp;
+ tempcons = temp;
+
+ temp = va_arg(args, void *);
+ }
- va_end(args);
+ va_end(args);
- return (retval);
+ return (retval);
}
-List *
-lcons(void *obj, List *list)
+List *
+lcons(void *obj, List * list)
{
- List *l = makeNode(List);
- lfirst(l) = obj;
- lnext(l) = list;
- return l;
+ List *l = makeNode(List);
+
+ lfirst(l) = obj;
+ lnext(l) = list;
+ return l;
}
-List *
-lconsi(int datum, List *list)
+List *
+lconsi(int datum, List * list)
{
- List *l = makeNode(List);
- lfirsti(l) = datum;
- lnext(l) = list;
- return l;
+ List *l = makeNode(List);
+
+ lfirsti(l) = datum;
+ lnext(l) = list;
+ return l;
}
-List *
-lappend(List *list, void *obj)
+List *
+lappend(List * list, void *obj)
{
- return nconc(list, lcons(obj, NIL));
+ return nconc(list, lcons(obj, NIL));
}
-List *
-lappendi(List *list, int datum)
+List *
+lappendi(List * list, int datum)
{
- return nconc(list, lconsi(datum, NIL));
+ return nconc(list, lconsi(datum, NIL));
}
-Value *
+Value *
makeInteger(long i)
{
- Value *v = makeNode(Value);
- v->type = T_Integer;
- v->val.ival = i;
- return v;
+ Value *v = makeNode(Value);
+
+ v->type = T_Integer;
+ v->val.ival = i;
+ return v;
}
-Value *
+Value *
makeFloat(double d)
{
- Value *v = makeNode(Value);
- v->type = T_Float;
- v->val.dval = d;
- return v;
+ Value *v = makeNode(Value);
+
+ v->type = T_Float;
+ v->val.dval = d;
+ return v;
}
-Value *
+Value *
makeString(char *str)
{
- Value *v = makeNode(Value);
- v->type = T_String;
- v->val.str = str;
- return v;
+ Value *v = makeNode(Value);
+
+ v->type = T_String;
+ v->val.str = str;
+ return v;
}
/* n starts with 0 */
-void *
-nth(int n, List *l)
+void *
+nth(int n, List * l)
{
- /* XXX assume list is long enough */
- while(n > 0) {
- l = lnext(l);
- n--;
- }
- return lfirst(l);
+ /* XXX assume list is long enough */
+ while (n > 0)
+ {
+ l = lnext(l);
+ n--;
+ }
+ return lfirst(l);
}
int
-nthi(int n, List *l)
+nthi(int n, List * l)
{
- /* XXX assume list is long enough */
- while(n > 0) {
- l = lnext(l);
- n--;
- }
- return lfirsti(l);
+ /* XXX assume list is long enough */
+ while (n > 0)
+ {
+ l = lnext(l);
+ n--;
+ }
+ return lfirsti(l);
}
/* this is here solely for rt_store. Get rid of me some day! */
void
-set_nth(List *l, int n, void *elem)
+set_nth(List * l, int n, void *elem)
{
- /* XXX assume list is long enough */
- while(n > 0) {
- l = lnext(l);
- n--;
- }
- lfirst(l) = elem;
- return;
+ /* XXX assume list is long enough */
+ while (n > 0)
+ {
+ l = lnext(l);
+ n--;
+ }
+ lfirst(l) = elem;
+ return;
}
int
-length(List *l)
+length(List * l)
{
- int i=0;
- while(l!=NIL) {
- l = lnext(l);
- i++;
- }
- return i;
+ int i = 0;
+
+ while (l != NIL)
+ {
+ l = lnext(l);
+ i++;
+ }
+ return i;
}
void
-freeList(List *list)
+freeList(List * list)
{
- while(list!=NIL) {
- List *l = list;
- list = lnext(list);
- pfree(l);
- }
+ while (list != NIL)
+ {
+ List *l = list;
+
+ list = lnext(list);
+ pfree(l);
+ }
}
/*
* below are for backwards compatibility
*/
-List *
-append(List *l1, List *l2)
+List *
+append(List * l1, List * l2)
{
- List *newlist, *newlist2, *p;
+ List *newlist,
+ *newlist2,
+ *p;
- if (l1==NIL)
- return copyObject(l2);
+ if (l1 == NIL)
+ return copyObject(l2);
- newlist = copyObject(l1);
- newlist2 = copyObject(l2);
+ newlist = copyObject(l1);
+ newlist2 = copyObject(l2);
- for (p=newlist; lnext(p)!=NIL; p=lnext(p))
- ;
- lnext(p) = newlist2;
- return newlist;
+ for (p = newlist; lnext(p) != NIL; p = lnext(p))
+ ;
+ lnext(p) = newlist2;
+ return newlist;
}
/*
* below are for backwards compatibility
*/
-List *
-intAppend(List *l1, List *l2)
+List *
+intAppend(List * l1, List * l2)
{
- List *newlist, *newlist2, *p;
+ List *newlist,
+ *newlist2,
+ *p;
- if (l1==NIL)
- return listCopy(l2);
+ if (l1 == NIL)
+ return listCopy(l2);
- newlist = listCopy(l1);
- newlist2 = listCopy(l2);
+ newlist = listCopy(l1);
+ newlist2 = listCopy(l2);
- for (p=newlist; lnext(p)!=NIL; p=lnext(p))
- ;
- lnext(p) = newlist2;
- return newlist;
+ for (p = newlist; lnext(p) != NIL; p = lnext(p))
+ ;
+ lnext(p) = newlist2;
+ return newlist;
}
-List *
-nconc(List *l1, List *l2)
+List *
+nconc(List * l1, List * l2)
{
- List *temp;
-
- if (l1 == NIL)
- return l2;
- if (l2 == NIL)
- return l1;
- if (l1 == l2)
- elog(WARN, "tryout to nconc a list to itself");
-
- for (temp = l1; lnext(temp)!=NULL; temp = lnext(temp))
- ;
-
- lnext(temp) = l2;
- return(l1); /* list1 is now list1[]list2 */
+ List *temp;
+
+ if (l1 == NIL)
+ return l2;
+ if (l2 == NIL)
+ return l1;
+ if (l1 == l2)
+ elog(WARN, "tryout to nconc a list to itself");
+
+ for (temp = l1; lnext(temp) != NULL; temp = lnext(temp))
+ ;
+
+ lnext(temp) = l2;
+ return (l1); /* list1 is now list1[]list2 */
}
-List *
-nreverse(List *list)
+List *
+nreverse(List * list)
{
- List *rlist = NIL;
- List *p = NIL;
-
- if(list==NULL)
- return(NIL);
-
- if (length(list) == 1)
- return(list);
-
- for (p = list; p!=NULL; p = lnext(p)) {
- rlist = lcons(lfirst(p),rlist);
- }
-
- lfirst(list) = lfirst(rlist);
- lnext(list) = lnext(rlist);
- return(list);
+ List *rlist = NIL;
+ List *p = NIL;
+
+ if (list == NULL)
+ return (NIL);
+
+ if (length(list) == 1)
+ return (list);
+
+ for (p = list; p != NULL; p = lnext(p))
+ {
+ rlist = lcons(lfirst(p), rlist);
+ }
+
+ lfirst(list) = lfirst(rlist);
+ lnext(list) = lnext(rlist);
+ return (list);
}
-/*
- * same
- *
- * Returns t if two lists contain the same elements.
- * now defined in lispdep.c
+/*
+ * same
+ *
+ * Returns t if two lists contain the same elements.
+ * now defined in lispdep.c
*
* XXX only good for IntList -ay
*/
bool
-same(List *foo, List *bar)
+same(List * foo, List * bar)
{
- List *temp = NIL;
-
- if (foo == NULL)
- return (bar==NULL);
- if (bar == NULL)
- return (foo==NULL);
- if (length(foo) == length(bar)) {
- foreach (temp,foo) {
- if (!intMember(lfirsti(temp),bar))
- return(false);
+ List *temp = NIL;
+
+ if (foo == NULL)
+ return (bar == NULL);
+ if (bar == NULL)
+ return (foo == NULL);
+ if (length(foo) == length(bar))
+ {
+ foreach(temp, foo)
+ {
+ if (!intMember(lfirsti(temp), bar))
+ return (false);
+ }
+ return (true);
}
- return(true);
- }
- return(false);
-
-}
-
-List *
-LispUnion(List *foo, List *bar)
+ return (false);
+
+}
+
+List *
+LispUnion(List * foo, List * bar)
{
- List *retval = NIL;
- List *i = NIL;
- List *j = NIL;
-
- if (foo==NIL)
- return(bar); /* XXX - should be copy of bar */
-
- if (bar==NIL)
- return(foo); /* XXX - should be copy of foo */
-
- foreach (i,foo) {
- foreach (j,bar) {
- if (! equal(lfirst(i), lfirst(j))) {
- retval = lappend(retval,lfirst(i));
- break;
- }
+ List *retval = NIL;
+ List *i = NIL;
+ List *j = NIL;
+
+ if (foo == NIL)
+ return (bar); /* XXX - should be copy of bar */
+
+ if (bar == NIL)
+ return (foo); /* XXX - should be copy of foo */
+
+ foreach(i, foo)
+ {
+ foreach(j, bar)
+ {
+ if (!equal(lfirst(i), lfirst(j)))
+ {
+ retval = lappend(retval, lfirst(i));
+ break;
+ }
+ }
}
- }
- foreach(i,bar) {
- retval = lappend(retval,lfirst(i));
- }
-
- return(retval);
+ foreach(i, bar)
+ {
+ retval = lappend(retval, lfirst(i));
+ }
+
+ return (retval);
}
-List *
-LispUnioni(List *foo, List *bar)
+List *
+LispUnioni(List * foo, List * bar)
{
- List *retval = NIL;
- List *i = NIL;
- List *j = NIL;
-
- if (foo==NIL)
- return(bar); /* XXX - should be copy of bar */
-
- if (bar==NIL)
- return(foo); /* XXX - should be copy of foo */
-
- foreach (i,foo) {
- foreach (j,bar) {
- if (lfirsti(i) != lfirsti(j)) {
- retval = lappendi(retval,lfirsti(i));
- break;
- }
+ List *retval = NIL;
+ List *i = NIL;
+ List *j = NIL;
+
+ if (foo == NIL)
+ return (bar); /* XXX - should be copy of bar */
+
+ if (bar == NIL)
+ return (foo); /* XXX - should be copy of foo */
+
+ foreach(i, foo)
+ {
+ foreach(j, bar)
+ {
+ if (lfirsti(i) != lfirsti(j))
+ {
+ retval = lappendi(retval, lfirsti(i));
+ break;
+ }
+ }
+ }
+ foreach(i, bar)
+ {
+ retval = lappendi(retval, lfirsti(i));
}
- }
- foreach(i,bar) {
- retval = lappendi(retval, lfirsti(i));
- }
-
- return(retval);
+
+ return (retval);
}
/*
* member()
* - nondestructive, returns t iff foo is a member of the list
- * bar
+ * bar
*/
bool
-member(void *foo, List *bar)
+member(void *foo, List * bar)
{
- List *i;
- foreach (i,bar)
- if (equal((Node*)(lfirst(i)),(Node*)foo))
- return(true);
- return(false);
+ List *i;
+
+ foreach(i, bar)
+ if (equal((Node *) (lfirst(i)), (Node *) foo))
+ return (true);
+ return (false);
}
bool
-intMember(int foo, List *bar)
+intMember(int foo, List * bar)
{
- List *i;
- foreach (i,bar)
- if (foo == lfirsti(i))
- return(true);
- return(false);
+ List *i;
+
+ foreach(i, bar)
+ if (foo == lfirsti(i))
+ return (true);
+ return (false);
}
/*
* lremove -
- * only does pointer comparisons. Removes 'elem' from the the linked list.
+ * only does pointer comparisons. Removes 'elem' from the the linked list.
*/
-List *
-lremove(void *elem, List *list)
+List *
+lremove(void *elem, List * list)
{
- List *l;
- List *prev = NIL;
- List *result = list;
-
- foreach(l, list) {
- if (elem == lfirst(l))
- break;
- prev = l;
- }
- if (l!=NULL) {
- if (prev == NIL) {
- result = lnext(list);
- } else {
- lnext(prev) = lnext(l);
+ List *l;
+ List *prev = NIL;
+ List *result = list;
+
+ foreach(l, list)
+ {
+ if (elem == lfirst(l))
+ break;
+ prev = l;
+ }
+ if (l != NULL)
+ {
+ if (prev == NIL)
+ {
+ result = lnext(list);
+ }
+ else
+ {
+ lnext(prev) = lnext(l);
+ }
}
- }
- return result;
+ return result;
}
-
-List *
-LispRemove(void *elem, List *list)
+
+List *
+LispRemove(void *elem, List * list)
{
- List *temp = NIL;
- List *prev = NIL;
-
- if (equal(elem, lfirst(list)))
- return lnext(list);
-
- temp = lnext(list);
- prev = list;
- while(temp!=NIL) {
- if (equal(elem, lfirst(temp))) {
- lnext(prev) = lnext(temp);
- break;
+ List *temp = NIL;
+ List *prev = NIL;
+
+ if (equal(elem, lfirst(list)))
+ return lnext(list);
+
+ temp = lnext(list);
+ prev = list;
+ while (temp != NIL)
+ {
+ if (equal(elem, lfirst(temp)))
+ {
+ lnext(prev) = lnext(temp);
+ break;
+ }
+ temp = lnext(temp);
+ prev = lnext(prev);
}
- temp = lnext(temp);
- prev = lnext(prev);
- }
- return(list);
+ return (list);
}
#ifdef NOT_USED
-List *
-intLispRemove(int elem, List *list)
+List *
+intLispRemove(int elem, List * list)
{
- List *temp = NIL;
- List *prev = NIL;
-
- if (elem == lfirsti(list))
- return lnext(list);
-
- temp = lnext(list);
- prev = list;
- while(temp!=NIL) {
- if (elem == lfirsti(temp)) {
- lnext(prev) = lnext(temp);
- break;
+ List *temp = NIL;
+ List *prev = NIL;
+
+ if (elem == lfirsti(list))
+ return lnext(list);
+
+ temp = lnext(list);
+ prev = list;
+ while (temp != NIL)
+ {
+ if (elem == lfirsti(temp))
+ {
+ lnext(prev) = lnext(temp);
+ break;
+ }
+ temp = lnext(temp);
+ prev = lnext(prev);
}
- temp = lnext(temp);
- prev = lnext(prev);
- }
- return(list);
+ return (list);
}
+
#endif
-List *
-set_difference(List *list1, List *list2)
+List *
+set_difference(List * list1, List * list2)
{
- List *temp1 = NIL;
- List *result = NIL;
-
- if (list2==NIL)
- return(list1);
-
- foreach (temp1, list1) {
- if (!member(lfirst(temp1), list2))
- result = lappend(result, lfirst(temp1));
- }
- return(result);
+ List *temp1 = NIL;
+ List *result = NIL;
+
+ if (list2 == NIL)
+ return (list1);
+
+ foreach(temp1, list1)
+ {
+ if (!member(lfirst(temp1), list2))
+ result = lappend(result, lfirst(temp1));
+ }
+ return (result);
}
-List *
-set_differencei(List *list1, List *list2)
+List *
+set_differencei(List * list1, List * list2)
{
- List *temp1 = NIL;
- List *result = NIL;
-
- if (list2==NIL)
- return(list1);
-
- foreach (temp1, list1) {
- if (!intMember(lfirsti(temp1), list2))
- result = lappendi(result, lfirsti(temp1));
- }
- return(result);
-}
+ List *temp1 = NIL;
+ List *result = NIL;
+
+ if (list2 == NIL)
+ return (list1);
+ foreach(temp1, list1)
+ {
+ if (!intMember(lfirsti(temp1), list2))
+ result = lappendi(result, lfirsti(temp1));
+ }
+ return (result);
+}
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index 18894e8a41c..7c5a9efc1fb 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -1,22 +1,22 @@
/*
* makefuncs.c--
- * creator functions for primitive nodes. The functions here are for
- * the most frequently created nodes.
+ * creator functions for primitive nodes. The functions here are for
+ * the most frequently created nodes.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.2 1997/01/22 01:42:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.3 1997/09/07 04:42:48 momjian Exp $
*
* NOTES
- * Creator functions in POSTGRES 4.2 are generated automatically. Most of
- * them are rarely used. Now we don't generate them any more. If you want
- * one, you have to write it yourself.
+ * Creator functions in POSTGRES 4.2 are generated automatically. Most of
+ * them are rarely used. Now we don't generate them any more. If you want
+ * one, you have to write it yourself.
*
* HISTORY
- * AUTHOR DATE MAJOR EVENT
- * Andrew Yu Oct 20, 1994 file creation
+ * AUTHOR DATE MAJOR EVENT
+ * Andrew Yu Oct 20, 1994 file creation
*/
#include "postgres.h"
#include "nodes/pg_list.h"
@@ -25,95 +25,94 @@
/*
* makeOper -
- * creates an Oper node
+ * creates an Oper node
*/
-Oper *
+Oper *
makeOper(Oid opno,
- Oid opid,
- Oid opresulttype,
- int opsize,
- FunctionCachePtr op_fcache)
+ Oid opid,
+ Oid opresulttype,
+ int opsize,
+ FunctionCachePtr op_fcache)
{
- Oper *oper = makeNode(Oper);
+ Oper *oper = makeNode(Oper);
- oper->opno = opno;
- oper->opid = opid;
- oper->opresulttype = opresulttype;
- oper->opsize = opsize;
- oper->op_fcache = op_fcache;
- return oper;
+ oper->opno = opno;
+ oper->opid = opid;
+ oper->opresulttype = opresulttype;
+ oper->opsize = opsize;
+ oper->op_fcache = op_fcache;
+ return oper;
}
/*
* makeVar -
- * creates a Var node
+ * creates a Var node
*
*/
-Var *
-makeVar(Index varno,
- AttrNumber varattno,
- Oid vartype,
- Index varnoold,
- AttrNumber varoattno)
+Var *
+makeVar(Index varno,
+ AttrNumber varattno,
+ Oid vartype,
+ Index varnoold,
+ AttrNumber varoattno)
{
- Var *var = makeNode(Var);
+ Var *var = makeNode(Var);
- var->varno = varno;
- var->varattno = varattno;
- var->vartype = vartype;
- var->varnoold = varnoold;
- var->varoattno = varoattno;
+ var->varno = varno;
+ var->varattno = varattno;
+ var->vartype = vartype;
+ var->varnoold = varnoold;
+ var->varoattno = varoattno;
- return var;
+ return var;
}
/*
* makeResdom -
- * creates a Resdom (Result Domain) node
+ * creates a Resdom (Result Domain) node
*/
-Resdom *
+Resdom *
makeResdom(AttrNumber resno,
- Oid restype,
- int reslen,
- char *resname,
- Index reskey,
- Oid reskeyop,
- int resjunk)
+ Oid restype,
+ int reslen,
+ char *resname,
+ Index reskey,
+ Oid reskeyop,
+ int resjunk)
{
- Resdom *resdom = makeNode(Resdom);
+ Resdom *resdom = makeNode(Resdom);
- resdom->resno = resno;
- resdom->restype = restype;
- resdom->reslen = reslen;
- resdom->resname = resname;
- resdom->reskey = reskey;
- resdom->reskeyop = reskeyop;
- resdom->resjunk = resjunk;
- return resdom;
+ resdom->resno = resno;
+ resdom->restype = restype;
+ resdom->reslen = reslen;
+ resdom->resname = resname;
+ resdom->reskey = reskey;
+ resdom->reskeyop = reskeyop;
+ resdom->resjunk = resjunk;
+ return resdom;
}
/*
* makeConst -
- * creates a Const node
+ * creates a Const node
*/
-Const *
+Const *
makeConst(Oid consttype,
- Size constlen,
- Datum constvalue,
- bool constisnull,
- bool constbyval,
- bool constisset,
- bool constiscast)
+ Size constlen,
+ Datum constvalue,
+ bool constisnull,
+ bool constbyval,
+ bool constisset,
+ bool constiscast)
{
- Const *cnst = makeNode(Const);
+ Const *cnst = makeNode(Const);
- cnst->consttype = consttype;
- cnst->constlen = constlen;
- cnst->constvalue = constvalue;
- cnst->constisnull = constisnull;
- cnst->constbyval = constbyval;
- cnst->constisset = constisset;
- cnst->constiscast = constiscast;
- return cnst;
+ cnst->consttype = consttype;
+ cnst->constlen = constlen;
+ cnst->constvalue = constvalue;
+ cnst->constisnull = constisnull;
+ cnst->constbyval = constbyval;
+ cnst->constisset = constisset;
+ cnst->constiscast = constiscast;
+ return cnst;
}
-
diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c
index e1e6bc6f140..081760eaca2 100644
--- a/src/backend/nodes/nodeFuncs.c
+++ b/src/backend/nodes/nodeFuncs.c
@@ -1,18 +1,18 @@
/*-------------------------------------------------------------------------
*
* nodeFuncs.c--
- * All node routines more complicated than simple access/modification
+ * All node routines more complicated than simple access/modification
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.3 1997/08/19 21:31:41 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.4 1997/09/07 04:42:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
-#include <sys/types.h>
+#include <sys/types.h>
#include "postgres.h"
@@ -23,99 +23,96 @@
#include "nodes/nodeFuncs.h"
#include "utils/lsyscache.h"
-static bool var_is_inner(Var *var);
+static bool var_is_inner(Var * var);
-/*
+/*
* single_node -
- * Returns t if node corresponds to a single-noded expression
+ * Returns t if node corresponds to a single-noded expression
*/
bool
-single_node(Node *node)
+single_node(Node * node)
{
- if(IsA(node,Ident) || IsA(node,Const) || IsA(node,Var) || IsA(node,Param))
- return(true);
- else
- return(false);
+ if (IsA(node, Ident) || IsA(node, Const) || IsA(node, Var) || IsA(node, Param))
+ return (true);
+ else
+ return (false);
}
/*****************************************************************************
- * VAR nodes
+ * VAR nodes
*****************************************************************************/
-/*
- * var_is_outer
- * var_is_inner
- * var_is_mat
- * var_is_rel
- *
- * Returns t iff the var node corresponds to (respectively):
- * the outer relation in a join
- * the inner relation of a join
- * a materialized relation
- * a base relation (i.e., not an attribute reference, a variable from
- * some lower join level, or a sort result)
- * var node is an array reference
- *
+/*
+ * var_is_outer
+ * var_is_inner
+ * var_is_mat
+ * var_is_rel
+ *
+ * Returns t iff the var node corresponds to (respectively):
+ * the outer relation in a join
+ * the inner relation of a join
+ * a materialized relation
+ * a base relation (i.e., not an attribute reference, a variable from
+ * some lower join level, or a sort result)
+ * var node is an array reference
+ *
*/
bool
-var_is_outer (Var *var)
+var_is_outer(Var * var)
{
- return((bool)(var->varno == OUTER));
+ return ((bool) (var->varno == OUTER));
}
-static bool
-var_is_inner (Var *var)
+static bool
+var_is_inner(Var * var)
{
- return ( (bool) (var->varno == INNER));
+ return ((bool) (var->varno == INNER));
}
bool
-var_is_rel (Var *var)
+var_is_rel(Var * var)
{
- return (bool)
- ! (var_is_inner (var) || var_is_outer (var));
+ return (bool)
+ ! (var_is_inner(var) || var_is_outer(var));
}
/*****************************************************************************
- * OPER nodes
+ * OPER nodes
*****************************************************************************/
-/*
+/*
* replace_opid -
- *
- * Given a oper node, resets the opfid field with the
- * procedure OID (regproc id).
- *
- * Returns the modified oper node.
- *
+ *
+ * Given a oper node, resets the opfid field with the
+ * procedure OID (regproc id).
+ *
+ * Returns the modified oper node.
+ *
*/
-Oper *
-replace_opid (Oper *oper)
+Oper *
+replace_opid(Oper * oper)
{
- oper->opid = get_opcode(oper->opno);
- oper->op_fcache = NULL;
- return(oper);
+ oper->opid = get_opcode(oper->opno);
+ oper->op_fcache = NULL;
+ return (oper);
}
/*****************************************************************************
- * constant (CONST, PARAM) nodes
+ * constant (CONST, PARAM) nodes
*****************************************************************************/
-/*
+/*
* non_null -
- * Returns t if the node is a non-null constant, e.g., if the node has a
- * valid `constvalue' field.
- *
+ * Returns t if the node is a non-null constant, e.g., if the node has a
+ * valid `constvalue' field.
+ *
*/
bool
-non_null (Expr *c)
+non_null(Expr * c)
{
-
- if ( IsA(c,Const) && ! ((Const*)c)->constisnull )
- return(true);
- else
- return(false);
-}
-
-
+ if (IsA(c, Const) && !((Const *) c)->constisnull)
+ return (true);
+ else
+ return (false);
+}
diff --git a/src/backend/nodes/nodes.c b/src/backend/nodes/nodes.c
index 82845cca15c..2af057e5a4c 100644
--- a/src/backend/nodes/nodes.c
+++ b/src/backend/nodes/nodes.c
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
*
* nodes.c--
- * support code for nodes (now that we get rid of the home-brew
- * inheritance system, our support code for nodes get much simpler)
+ * support code for nodes (now that we get rid of the home-brew
+ * inheritance system, our support code for nodes get much simpler)
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.1.1.1 1996/07/09 06:21:33 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.2 1997/09/07 04:42:52 momjian Exp $
*
* HISTORY
- * Andrew Yu Oct 20, 1994 file creation
+ * Andrew Yu Oct 20, 1994 file creation
*
*-------------------------------------------------------------------------
*/
@@ -19,27 +19,27 @@
#include "postgres.h"
#include "utils/palloc.h"
#include "utils/elog.h"
-#include "nodes/nodes.h" /* where func declarations of this file goes */
+#include "nodes/nodes.h" /* where func declarations of this file
+ * goes */
/*
* newNode -
- * create a new node of the specified size and tag the node with the
- * specified tag.
+ * create a new node of the specified size and tag the node with the
+ * specified tag.
*
* !WARNING!: Avoid using newNode directly. You should be using the
- * macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
+ * macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
*
*/
-Node *
+Node *
newNode(Size size, NodeTag tag)
{
- Node *newNode;
-
- Assert(size >= 4); /* need the tag, at least */
-
- newNode = (Node *)palloc(size);
- memset((char *)newNode, 0, size);
- newNode->type = tag;
- return(newNode);
-}
+ Node *newNode;
+
+ Assert(size >= 4); /* need the tag, at least */
+ newNode = (Node *) palloc(size);
+ memset((char *) newNode, 0, size);
+ newNode->type = tag;
+ return (newNode);
+}
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index a41848c6188..a1574c8734f 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -1,24 +1,24 @@
/*-------------------------------------------------------------------------
*
* outfuncs.c--
- * routines to convert a node to ascii representation
+ * routines to convert a node to ascii representation
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.6 1997/08/18 20:52:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.7 1997/09/07 04:42:53 momjian Exp $
*
* NOTES
- * Every (plan) node in POSTGRES has an associated "out" routine which
- * knows how to create its ascii representation. These functions are
- * useful for debugging as well as for storing plans in the system
- * catalogs (eg. indexes). This is also the plan string sent out in
- * Mariposa.
+ * Every (plan) node in POSTGRES has an associated "out" routine which
+ * knows how to create its ascii representation. These functions are
+ * useful for debugging as well as for storing plans in the system
+ * catalogs (eg. indexes). This is also the plan string sent out in
+ * Mariposa.
*
- * These functions update the in/out argument of type StringInfo
- * passed to them. This argument contains the string holding the ASCII
- * representation plus some other information (string length, etc.)
+ * These functions update the in/out argument of type StringInfo
+ * passed to them. This argument contains the string holding the ASCII
+ * representation plus some other information (string length, etc.)
*
*-------------------------------------------------------------------------
*/
@@ -45,1305 +45,1322 @@
#include "catalog/pg_type.h"
#include "lib/stringinfo.h"
-static void _outDatum(StringInfo str, Datum value, Oid type);
-static void _outNode(StringInfo str, void *obj);
+static void _outDatum(StringInfo str, Datum value, Oid type);
+static void _outNode(StringInfo str, void *obj);
/*
* _outIntList -
- * converts a List of integers
+ * converts a List of integers
*/
static void
-_outIntList(StringInfo str, List *list)
+_outIntList(StringInfo str, List * list)
{
- List *l;
- char buf[500];
+ List *l;
+ char buf[500];
- appendStringInfo(str, "(");
- foreach(l, list) {
- sprintf(buf, "%d ", (int)lfirst(l));
- appendStringInfo(str, buf);
- }
- appendStringInfo(str, ")");
+ appendStringInfo(str, "(");
+ foreach(l, list)
+ {
+ sprintf(buf, "%d ", (int) lfirst(l));
+ appendStringInfo(str, buf);
+ }
+ appendStringInfo(str, ")");
}
static void
-_outQuery(StringInfo str, Query *node)
+_outQuery(StringInfo str, Query * node)
{
- char buf[500];
-
- sprintf(buf, "QUERY");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :command %d", node->commandType);
- appendStringInfo(str,buf);
- if (node->utilityStmt &&
- nodeTag(node->utilityStmt) == T_NotifyStmt)
- sprintf(buf," :utility %s",
- ((NotifyStmt*)(node->utilityStmt))->relname);
- else /* use "" to designate */
- sprintf(buf," :utility \"\"");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :resrel %d", node->resultRelation);
- appendStringInfo(str,buf);
- sprintf(buf, " :rtable ");
- appendStringInfo(str,buf);
- _outNode(str, node->rtable);
- if (node->uniqueFlag)
- sprintf(buf, " :unique %s", node->uniqueFlag);
- else /* use "" to designate non-unique */
- sprintf(buf, " :unique \"\"");
- appendStringInfo(str,buf);
- sprintf(buf, " :targetlist ");
- appendStringInfo(str,buf);
- _outNode(str, node->targetList);
- sprintf(buf, " :qual ");
- appendStringInfo(str,buf);
- _outNode(str, node->qual);
-
+ char buf[500];
+
+ sprintf(buf, "QUERY");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :command %d", node->commandType);
+ appendStringInfo(str, buf);
+ if (node->utilityStmt &&
+ nodeTag(node->utilityStmt) == T_NotifyStmt)
+ sprintf(buf, " :utility %s",
+ ((NotifyStmt *) (node->utilityStmt))->relname);
+ else
+/* use "" to designate */
+ sprintf(buf, " :utility \"\"");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :resrel %d", node->resultRelation);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :rtable ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->rtable);
+ if (node->uniqueFlag)
+ sprintf(buf, " :unique %s", node->uniqueFlag);
+ else
+/* use "" to designate non-unique */
+ sprintf(buf, " :unique \"\"");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :targetlist ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->targetList);
+ sprintf(buf, " :qual ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->qual);
+
}
/*
* print the basic stuff of all nodes that inherit from Plan
*/
static void
-_outPlanInfo(StringInfo str, Plan *node)
+_outPlanInfo(StringInfo str, Plan * node)
{
- char buf[500];
-
- sprintf(buf, " :cost %g", node->cost );
- appendStringInfo(str,buf);
- sprintf(buf, " :size %d", node->plan_size);
- appendStringInfo(str,buf);
- sprintf(buf, " :width %d", node->plan_width);
- appendStringInfo(str,buf);
- sprintf(buf, " :state %s", (node->state == (EState*) NULL ?
- "nil" : "non-NIL"));
- appendStringInfo(str,buf);
- sprintf(buf, " :qptargetlist ");
- appendStringInfo(str,buf);
- _outNode(str, node->targetlist);
- sprintf(buf, " :qpqual ");
- appendStringInfo(str,buf);
- _outNode(str, node->qual);
- sprintf(buf, " :lefttree ");
- appendStringInfo(str,buf);
- _outNode(str, node->lefttree);
- sprintf(buf, " :righttree ");
- appendStringInfo(str,buf);
- _outNode(str, node->righttree);
-
+ char buf[500];
+
+ sprintf(buf, " :cost %g", node->cost);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :size %d", node->plan_size);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :width %d", node->plan_width);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :state %s", (node->state == (EState *) NULL ?
+ "nil" : "non-NIL"));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :qptargetlist ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->targetlist);
+ sprintf(buf, " :qpqual ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->qual);
+ sprintf(buf, " :lefttree ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->lefttree);
+ sprintf(buf, " :righttree ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->righttree);
+
}
/*
- * Stuff from plannodes.h
+ * Stuff from plannodes.h
*/
static void
-_outPlan(StringInfo str, Plan *node)
+_outPlan(StringInfo str, Plan * node)
{
- char buf[500];
-
- sprintf(buf, "PLAN");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
+ char buf[500];
+
+ sprintf(buf, "PLAN");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
}
static void
-_outResult(StringInfo str, Result *node)
+_outResult(StringInfo str, Result * node)
{
- char buf[500];
-
- sprintf(buf, "RESULT");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :resconstantqual ");
- appendStringInfo(str,buf);
- _outNode(str, node->resconstantqual);
-
+ char buf[500];
+
+ sprintf(buf, "RESULT");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :resconstantqual ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->resconstantqual);
+
}
/*
- * Existential is a subclass of Plan.
+ * Existential is a subclass of Plan.
*/
static void
-_outExistential(StringInfo str, Existential *node)
+_outExistential(StringInfo str, Existential * node)
{
- char buf[500];
-
- sprintf(buf, "EXISTENTIAL");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
-
+ char buf[500];
+
+ sprintf(buf, "EXISTENTIAL");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+
}
/*
- * Append is a subclass of Plan.
+ * Append is a subclass of Plan.
*/
static void
-_outAppend(StringInfo str, Append *node)
+_outAppend(StringInfo str, Append * node)
{
- char buf[500];
-
- sprintf(buf, "APPEND");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :unionplans ");
- appendStringInfo(str,buf);
- _outNode(str, node->unionplans);
-
- sprintf(buf, " :unionrelid %d", node->unionrelid);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :unionrtentries ");
- appendStringInfo(str,buf);
- _outNode(str, node->unionrtentries);
-
+ char buf[500];
+
+ sprintf(buf, "APPEND");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :unionplans ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->unionplans);
+
+ sprintf(buf, " :unionrelid %d", node->unionrelid);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :unionrtentries ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->unionrtentries);
+
}
/*
- * Join is a subclass of Plan
+ * Join is a subclass of Plan
*/
static void
-_outJoin(StringInfo str, Join *node)
+_outJoin(StringInfo str, Join * node)
{
- char buf[500];
-
- sprintf(buf, "JOIN");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
+ char buf[500];
+
+ sprintf(buf, "JOIN");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
}
/*
- * NestLoop is a subclass of Join
+ * NestLoop is a subclass of Join
*/
static void
-_outNestLoop(StringInfo str, NestLoop *node)
+_outNestLoop(StringInfo str, NestLoop * node)
{
- char buf[500];
-
- sprintf(buf, "NESTLOOP");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
+ char buf[500];
+
+ sprintf(buf, "NESTLOOP");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
}
/*
- * MergeJoin is a subclass of Join
+ * MergeJoin is a subclass of Join
*/
static void
-_outMergeJoin(StringInfo str, MergeJoin *node)
+_outMergeJoin(StringInfo str, MergeJoin * node)
{
- char buf[500];
-
- sprintf(buf, "MERGEJOIN");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :mergeclauses ");
- appendStringInfo(str,buf);
- _outNode(str, node->mergeclauses);
-
- sprintf(buf, " :mergesortop %u", node->mergesortop);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :mergerightorder %u", node->mergerightorder[0]);
- appendStringInfo(str, buf);
-
- sprintf(buf, " :mergeleftorder %u", node->mergeleftorder[0]);
- appendStringInfo(str, buf);
+ char buf[500];
+
+ sprintf(buf, "MERGEJOIN");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :mergeclauses ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->mergeclauses);
+
+ sprintf(buf, " :mergesortop %u", node->mergesortop);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :mergerightorder %u", node->mergerightorder[0]);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :mergeleftorder %u", node->mergeleftorder[0]);
+ appendStringInfo(str, buf);
}
/*
- * HashJoin is a subclass of Join.
+ * HashJoin is a subclass of Join.
*/
static void
-_outHashJoin(StringInfo str, HashJoin *node)
+_outHashJoin(StringInfo str, HashJoin * node)
{
- char buf[500];
-
- sprintf(buf, "HASHJOIN");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :hashclauses ");
- appendStringInfo(str,buf);
- _outNode(str, node->hashclauses);
-
- sprintf(buf, " :hashjoinop %u",node->hashjoinop);
- appendStringInfo(str,buf);
- sprintf(buf, " :hashjointable 0x%x", (int) node->hashjointable);
- appendStringInfo(str,buf);
- sprintf(buf, " :hashjointablekey %d", node->hashjointablekey);
- appendStringInfo(str,buf);
- sprintf(buf, " :hashjointablesize %d", node->hashjointablesize);
- appendStringInfo(str,buf);
- sprintf(buf, " :hashdone %d", node->hashdone);
- appendStringInfo(str,buf);
+ char buf[500];
+
+ sprintf(buf, "HASHJOIN");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :hashclauses ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->hashclauses);
+
+ sprintf(buf, " :hashjoinop %u", node->hashjoinop);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :hashjointable 0x%x", (int) node->hashjointable);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :hashjointablekey %d", node->hashjointablekey);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :hashjointablesize %d", node->hashjointablesize);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :hashdone %d", node->hashdone);
+ appendStringInfo(str, buf);
}
/*
- * Scan is a subclass of Node
+ * Scan is a subclass of Node
*/
static void
-_outScan(StringInfo str, Scan *node)
+_outScan(StringInfo str, Scan * node)
{
- char buf[500];
-
- sprintf(buf, "SCAN");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :scanrelid %d", node->scanrelid);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "SCAN");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :scanrelid %d", node->scanrelid);
+ appendStringInfo(str, buf);
+
}
/*
- * SeqScan is a subclass of Scan
+ * SeqScan is a subclass of Scan
*/
static void
-_outSeqScan(StringInfo str, SeqScan *node)
+_outSeqScan(StringInfo str, SeqScan * node)
{
- char buf[500];
-
- sprintf(buf, "SEQSCAN");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :scanrelid %d", node->scanrelid);
- appendStringInfo(str,buf);
-
-
+ char buf[500];
+
+ sprintf(buf, "SEQSCAN");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :scanrelid %d", node->scanrelid);
+ appendStringInfo(str, buf);
+
+
}
/*
- * IndexScan is a subclass of Scan
+ * IndexScan is a subclass of Scan
*/
static void
-_outIndexScan(StringInfo str, IndexScan *node)
+_outIndexScan(StringInfo str, IndexScan * node)
{
- char buf[500];
-
- sprintf(buf, "INDEXSCAN");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :scanrelid %d", node->scan.scanrelid);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :indxid ");
- appendStringInfo(str,buf);
- _outIntList(str, node->indxid);
-
- sprintf(buf, " :indxqual ");
- appendStringInfo(str,buf);
- _outNode(str, node->indxqual);
-
+ char buf[500];
+
+ sprintf(buf, "INDEXSCAN");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :scanrelid %d", node->scan.scanrelid);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :indxid ");
+ appendStringInfo(str, buf);
+ _outIntList(str, node->indxid);
+
+ sprintf(buf, " :indxqual ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->indxqual);
+
}
/*
- * Temp is a subclass of Plan
+ * Temp is a subclass of Plan
*/
static void
-_outTemp(StringInfo str, Temp *node)
+_outTemp(StringInfo str, Temp * node)
{
- char buf[500];
-
- sprintf(buf, "TEMP");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :tempid %u", node->tempid);
- appendStringInfo(str,buf);
- sprintf(buf, " :keycount %d", node->keycount);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "TEMP");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :tempid %u", node->tempid);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :keycount %d", node->keycount);
+ appendStringInfo(str, buf);
+
}
/*
- * Sort is a subclass of Temp
+ * Sort is a subclass of Temp
*/
static void
-_outSort(StringInfo str, Sort *node)
+_outSort(StringInfo str, Sort * node)
{
- char buf[500];
-
- sprintf(buf, "SORT");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :tempid %u", node->tempid);
- appendStringInfo(str,buf);
- sprintf(buf, " :keycount %d", node->keycount);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "SORT");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :tempid %u", node->tempid);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :keycount %d", node->keycount);
+ appendStringInfo(str, buf);
+
}
static void
-_outAgg(StringInfo str, Agg *node)
+_outAgg(StringInfo str, Agg * node)
{
- char buf[500];
- sprintf(buf, "AGG");
- appendStringInfo(str,buf);
- _outPlanInfo(str,(Plan*)node);
-
- /* the actual Agg fields */
- sprintf(buf, " :numagg %d ", node->numAgg);
- appendStringInfo(str, buf);
+ char buf[500];
+
+ sprintf(buf, "AGG");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ /* the actual Agg fields */
+ sprintf(buf, " :numagg %d ", node->numAgg);
+ appendStringInfo(str, buf);
}
static void
-_outGroup(StringInfo str, Group *node)
+_outGroup(StringInfo str, Group * node)
{
- char buf[500];
- sprintf(buf, "GRP");
- appendStringInfo(str,buf);
- _outPlanInfo(str,(Plan*)node);
-
- /* the actual Group fields */
- sprintf(buf, " :numCols %d ", node->numCols);
- appendStringInfo(str, buf);
- sprintf(buf, " :tuplePerGroup %s", node->tuplePerGroup ? "true" : "nil");
- appendStringInfo(str, buf);
+ char buf[500];
+
+ sprintf(buf, "GRP");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ /* the actual Group fields */
+ sprintf(buf, " :numCols %d ", node->numCols);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :tuplePerGroup %s", node->tuplePerGroup ? "true" : "nil");
+ appendStringInfo(str, buf);
}
-
-
+
+
/*
- * For some reason, unique is a subclass of Temp.
+ * For some reason, unique is a subclass of Temp.
*/
static void
-_outUnique(StringInfo str, Unique *node)
+_outUnique(StringInfo str, Unique * node)
{
- char buf[500];
-
- sprintf(buf, "UNIQUE");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :tempid %u", node->tempid);
- appendStringInfo(str,buf);
- sprintf(buf, " :keycount %d", node->keycount);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "UNIQUE");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :tempid %u", node->tempid);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :keycount %d", node->keycount);
+ appendStringInfo(str, buf);
+
}
/*
- * Hash is a subclass of Temp
+ * Hash is a subclass of Temp
*/
static void
-_outHash(StringInfo str, Hash *node)
+_outHash(StringInfo str, Hash * node)
{
- char buf[500];
-
- sprintf(buf, "HASH");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :hashkey ");
- appendStringInfo(str,buf);
- _outNode(str, node->hashkey);
-
- sprintf(buf, " :hashtable 0x%x", (int) (node->hashtable));
- appendStringInfo(str,buf);
- sprintf(buf, " :hashtablekey %d", node->hashtablekey);
- appendStringInfo(str,buf);
- sprintf(buf, " :hashtablesize %d", node->hashtablesize);
- appendStringInfo(str,buf);
+ char buf[500];
+
+ sprintf(buf, "HASH");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :hashkey ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->hashkey);
+
+ sprintf(buf, " :hashtable 0x%x", (int) (node->hashtable));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :hashtablekey %d", node->hashtablekey);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :hashtablesize %d", node->hashtablesize);
+ appendStringInfo(str, buf);
}
static void
-_outTee(StringInfo str, Tee *node)
+_outTee(StringInfo str, Tee * node)
{
- char buf[500];
-
- sprintf(buf, "TEE");
- appendStringInfo(str,buf);
- _outPlanInfo(str, (Plan*) node);
-
- sprintf(buf, " :leftParent %X", (int) (node->leftParent));
- appendStringInfo(str,buf);
- sprintf(buf, " :rightParent %X", (int) (node->rightParent));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :rtentries ");
- appendStringInfo(str,buf);
- _outNode(str, node->rtentries);
+ char buf[500];
+
+ sprintf(buf, "TEE");
+ appendStringInfo(str, buf);
+ _outPlanInfo(str, (Plan *) node);
+
+ sprintf(buf, " :leftParent %X", (int) (node->leftParent));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :rightParent %X", (int) (node->rightParent));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :rtentries ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->rtentries);
}
/*****************************************************************************
*
- * Stuff from primnodes.h.
+ * Stuff from primnodes.h.
*
*****************************************************************************/
/*
- * Resdom is a subclass of Node
+ * Resdom is a subclass of Node
*/
static void
-_outResdom(StringInfo str, Resdom *node)
+_outResdom(StringInfo str, Resdom * node)
{
- char buf[500];
-
- sprintf(buf, "RESDOM");
- appendStringInfo(str,buf);
- sprintf(buf, " :resno %hd", node->resno);
- appendStringInfo(str,buf);
- sprintf(buf, " :restype %u", node->restype);
- appendStringInfo(str,buf);
- sprintf(buf, " :reslen %d", node->reslen);
- appendStringInfo(str,buf);
- sprintf(buf, " :resname \"%s\"",
- ((node->resname) ? ((char *) node->resname) : "null"));
- appendStringInfo(str,buf);
- sprintf(buf, " :reskey %d", node->reskey);
- appendStringInfo(str,buf);
- sprintf(buf, " :reskeyop %u", node->reskeyop);
- appendStringInfo(str,buf);
- sprintf(buf, " :resjunk %d", node->resjunk);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "RESDOM");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :resno %hd", node->resno);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :restype %u", node->restype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :reslen %d", node->reslen);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :resname \"%s\"",
+ ((node->resname) ? ((char *) node->resname) : "null"));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :reskey %d", node->reskey);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :reskeyop %u", node->reskeyop);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :resjunk %d", node->resjunk);
+ appendStringInfo(str, buf);
+
}
static void
-_outFjoin(StringInfo str, Fjoin *node)
+_outFjoin(StringInfo str, Fjoin * node)
{
- char buf[500];
- int i;
-
- sprintf(buf, "FJOIN");
- appendStringInfo(str,buf);
- sprintf(buf, " :initialized %s", node->fj_initialized ? "true":"nil");
- appendStringInfo(str,buf);
- sprintf(buf, " :nNodes %d", node->fj_nNodes);
- appendStringInfo(str,buf);
-
- appendStringInfo(str," :innerNode ");
- appendStringInfo(str,buf);
- _outNode(str, node->fj_innerNode);
-
- sprintf(buf, " :results @ 0x%x ", (int)(node->fj_results));
- appendStringInfo(str, buf);
-
- appendStringInfo( str, " :alwaysdone ");
- for (i = 0; i<node->fj_nNodes; i++)
+ char buf[500];
+ int i;
+
+ sprintf(buf, "FJOIN");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :initialized %s", node->fj_initialized ? "true" : "nil");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :nNodes %d", node->fj_nNodes);
+ appendStringInfo(str, buf);
+
+ appendStringInfo(str, " :innerNode ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->fj_innerNode);
+
+ sprintf(buf, " :results @ 0x%x ", (int) (node->fj_results));
+ appendStringInfo(str, buf);
+
+ appendStringInfo(str, " :alwaysdone ");
+ for (i = 0; i < node->fj_nNodes; i++)
{
- sprintf(buf, " %s ", ((node->fj_alwaysDone[i]) ? "true" : "nil"));
- appendStringInfo(str, buf);
+ sprintf(buf, " %s ", ((node->fj_alwaysDone[i]) ? "true" : "nil"));
+ appendStringInfo(str, buf);
}
}
/*
- * Expr is a subclass of Node
+ * Expr is a subclass of Node
*/
static void
-_outExpr(StringInfo str, Expr *node)
+_outExpr(StringInfo str, Expr * node)
{
- char buf[500];
- char *opstr = NULL;
-
- sprintf(buf, "EXPR");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :typeOid %u", node->typeOid);
- appendStringInfo(str,buf);
- switch(node->opType) {
- case OP_EXPR:
- opstr = "op";
- break;
- case FUNC_EXPR:
- opstr = "func";
- break;
- case OR_EXPR:
- opstr = "or";
- break;
- case AND_EXPR:
- opstr = "and";
- break;
- case NOT_EXPR:
- opstr = "not";
- break;
- }
- sprintf(buf, " :opType %s", opstr);
- appendStringInfo(str,buf);
- sprintf(buf, " :oper ");
- appendStringInfo(str,buf);
- _outNode(str, node->oper);
- sprintf(buf, " :args ");
- appendStringInfo(str,buf);
- _outNode(str, node->args);
+ char buf[500];
+ char *opstr = NULL;
+
+ sprintf(buf, "EXPR");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :typeOid %u", node->typeOid);
+ appendStringInfo(str, buf);
+ switch (node->opType)
+ {
+ case OP_EXPR:
+ opstr = "op";
+ break;
+ case FUNC_EXPR:
+ opstr = "func";
+ break;
+ case OR_EXPR:
+ opstr = "or";
+ break;
+ case AND_EXPR:
+ opstr = "and";
+ break;
+ case NOT_EXPR:
+ opstr = "not";
+ break;
+ }
+ sprintf(buf, " :opType %s", opstr);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :oper ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->oper);
+ sprintf(buf, " :args ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->args);
}
/*
- * Var is a subclass of Expr
+ * Var is a subclass of Expr
*/
static void
-_outVar(StringInfo str, Var *node)
+_outVar(StringInfo str, Var * node)
{
- char buf[500];
-
- sprintf(buf, "VAR");
- appendStringInfo(str,buf);
- sprintf(buf, " :varno %d", node->varno);
- appendStringInfo(str,buf);
- sprintf(buf, " :varattno %hd", node->varattno);
- appendStringInfo(str,buf);
- sprintf(buf, " :vartype %u", node->vartype);
- appendStringInfo(str,buf);
- sprintf(buf, " :varnoold %d", node->varnoold);
- appendStringInfo(str,buf);
- sprintf(buf, " :varoattno %d", node->varoattno);
- appendStringInfo(str,buf);
+ char buf[500];
+
+ sprintf(buf, "VAR");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :varno %d", node->varno);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :varattno %hd", node->varattno);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :vartype %u", node->vartype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :varnoold %d", node->varnoold);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :varoattno %d", node->varoattno);
+ appendStringInfo(str, buf);
}
/*
- * Const is a subclass of Expr
+ * Const is a subclass of Expr
*/
static void
-_outConst(StringInfo str, Const *node)
+_outConst(StringInfo str, Const * node)
{
- char buf[500];
-
- sprintf(buf, "CONST");
- appendStringInfo(str,buf);
- sprintf(buf, " :consttype %u", node->consttype);
- appendStringInfo(str,buf);
- sprintf(buf, " :constlen %hd", node->constlen);
- appendStringInfo(str,buf);
- sprintf(buf, " :constisnull %s", (node->constisnull ? "true" : "nil"));
- appendStringInfo(str,buf);
- sprintf(buf, " :constvalue ");
- appendStringInfo(str,buf);
- if (node->constisnull) {
- sprintf(buf, "NIL ");
- appendStringInfo(str,buf);
- } else {
- _outDatum(str, node->constvalue, node->consttype);
- }
- sprintf(buf, " :constbyval %s", (node->constbyval ? "true" : "nil"));
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "CONST");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :consttype %u", node->consttype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :constlen %hd", node->constlen);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :constisnull %s", (node->constisnull ? "true" : "nil"));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :constvalue ");
+ appendStringInfo(str, buf);
+ if (node->constisnull)
+ {
+ sprintf(buf, "NIL ");
+ appendStringInfo(str, buf);
+ }
+ else
+ {
+ _outDatum(str, node->constvalue, node->consttype);
+ }
+ sprintf(buf, " :constbyval %s", (node->constbyval ? "true" : "nil"));
+ appendStringInfo(str, buf);
+
}
/*
- * Aggreg
+ * Aggreg
*/
static void
-_outAggreg(StringInfo str, Aggreg *node)
+_outAggreg(StringInfo str, Aggreg * node)
{
- char buf[500];
-
- sprintf(buf, "AGGREG");
- appendStringInfo(str,buf);
- sprintf(buf, " :aggname \"%s\"", (char*)node->aggname);
- appendStringInfo(str,buf);
- sprintf(buf, " :basetype %u", node->basetype);
- appendStringInfo(str,buf);
- sprintf(buf, " :aggtype %u", node->aggtype);
- appendStringInfo(str,buf);
- sprintf(buf, " :aggno %d", node->aggno);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :target ");
- appendStringInfo(str,buf);
- _outNode(str, node->target);
+ char buf[500];
+
+ sprintf(buf, "AGGREG");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :aggname \"%s\"", (char *) node->aggname);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :basetype %u", node->basetype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :aggtype %u", node->aggtype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :aggno %d", node->aggno);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :target ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->target);
}
/*
- * Array is a subclass of Expr
+ * Array is a subclass of Expr
*/
static void
-_outArray(StringInfo str, Array *node)
+_outArray(StringInfo str, Array * node)
{
- char buf[500];
- int i;
- sprintf(buf, "ARRAY");
- appendStringInfo(str, buf);
- sprintf(buf, " :arrayelemtype %u", node->arrayelemtype);
- appendStringInfo(str, buf);
- sprintf(buf, " :arrayelemlength %d", node->arrayelemlength);
- appendStringInfo(str, buf);
- sprintf(buf, " :arrayelembyval %c", (node->arrayelembyval) ? 't' : 'f');
- appendStringInfo(str, buf);
- sprintf(buf, " :arrayndim %d", node->arrayndim);
- appendStringInfo(str, buf);
- sprintf(buf, " :arraylow ");
- appendStringInfo(str, buf);
- for (i = 0; i < node->arrayndim; i++){
- sprintf(buf, " %d", node->arraylow.indx[i]);
- appendStringInfo(str, buf);
- }
- sprintf(buf, " :arrayhigh ");
- appendStringInfo(str, buf);
- for (i = 0; i < node->arrayndim; i++){
- sprintf(buf, " %d", node->arrayhigh.indx[i]);
- appendStringInfo(str, buf);
- }
- sprintf(buf, " :arraylen %d", node->arraylen);
- appendStringInfo(str, buf);
+ char buf[500];
+ int i;
+
+ sprintf(buf, "ARRAY");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :arrayelemtype %u", node->arrayelemtype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :arrayelemlength %d", node->arrayelemlength);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :arrayelembyval %c", (node->arrayelembyval) ? 't' : 'f');
+ appendStringInfo(str, buf);
+ sprintf(buf, " :arrayndim %d", node->arrayndim);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :arraylow ");
+ appendStringInfo(str, buf);
+ for (i = 0; i < node->arrayndim; i++)
+ {
+ sprintf(buf, " %d", node->arraylow.indx[i]);
+ appendStringInfo(str, buf);
+ }
+ sprintf(buf, " :arrayhigh ");
+ appendStringInfo(str, buf);
+ for (i = 0; i < node->arrayndim; i++)
+ {
+ sprintf(buf, " %d", node->arrayhigh.indx[i]);
+ appendStringInfo(str, buf);
+ }
+ sprintf(buf, " :arraylen %d", node->arraylen);
+ appendStringInfo(str, buf);
}
/*
- * ArrayRef is a subclass of Expr
+ * ArrayRef is a subclass of Expr
*/
static void
-_outArrayRef(StringInfo str, ArrayRef *node)
+_outArrayRef(StringInfo str, ArrayRef * node)
{
- char buf[500];
-
- sprintf(buf, "ARRAYREF");
- appendStringInfo(str, buf);
- sprintf(buf, " :refelemtype %u", node->refelemtype);
- appendStringInfo(str, buf);
- sprintf(buf, " :refattrlength %d", node->refattrlength);
- appendStringInfo(str, buf);
- sprintf(buf, " :refelemlength %d", node->refelemlength);
- appendStringInfo(str, buf);
- sprintf(buf, " :refelembyval %c", (node->refelembyval) ? 't' : 'f');
- appendStringInfo(str, buf);
-
- sprintf(buf, " :refupperindex ");
- appendStringInfo(str, buf);
- _outNode(str, node->refupperindexpr);
-
- sprintf(buf, " :reflowerindex ");
- appendStringInfo(str, buf);
- _outNode(str, node->reflowerindexpr);
-
- sprintf(buf, " :refexpr ");
- appendStringInfo(str, buf);
- _outNode(str, node->refexpr);
-
- sprintf(buf, " :refassgnexpr ");
- appendStringInfo(str, buf);
- _outNode(str, node->refassgnexpr);
+ char buf[500];
+
+ sprintf(buf, "ARRAYREF");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :refelemtype %u", node->refelemtype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :refattrlength %d", node->refattrlength);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :refelemlength %d", node->refelemlength);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :refelembyval %c", (node->refelembyval) ? 't' : 'f');
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :refupperindex ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->refupperindexpr);
+
+ sprintf(buf, " :reflowerindex ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->reflowerindexpr);
+
+ sprintf(buf, " :refexpr ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->refexpr);
+
+ sprintf(buf, " :refassgnexpr ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->refassgnexpr);
}
/*
- * Func is a subclass of Expr
+ * Func is a subclass of Expr
*/
static void
-_outFunc(StringInfo str, Func *node)
+_outFunc(StringInfo str, Func * node)
{
- char buf[500];
-
- sprintf(buf, "FUNC");
- appendStringInfo(str,buf);
- sprintf(buf, " :funcid %u", node->funcid);
- appendStringInfo(str,buf);
- sprintf(buf, " :functype %u", node->functype);
- appendStringInfo(str,buf);
- sprintf(buf, " :funcisindex %s",
- (node->funcisindex ? "true" : "nil"));
- appendStringInfo(str,buf);
- sprintf(buf, " :funcsize %d", node->funcsize);
- appendStringInfo(str, buf);
- sprintf(buf, " :func_fcache @ 0x%x", (int)(node->func_fcache));
- appendStringInfo(str, buf);
-
- appendStringInfo(str, " :func_tlist ");
- _outNode(str, node->func_tlist);
-
- appendStringInfo(str, " :func_planlist ");
- _outNode(str, node->func_planlist);
+ char buf[500];
+
+ sprintf(buf, "FUNC");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :funcid %u", node->funcid);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :functype %u", node->functype);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :funcisindex %s",
+ (node->funcisindex ? "true" : "nil"));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :funcsize %d", node->funcsize);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :func_fcache @ 0x%x", (int) (node->func_fcache));
+ appendStringInfo(str, buf);
+
+ appendStringInfo(str, " :func_tlist ");
+ _outNode(str, node->func_tlist);
+
+ appendStringInfo(str, " :func_planlist ");
+ _outNode(str, node->func_planlist);
}
/*
- * Oper is a subclass of Expr
+ * Oper is a subclass of Expr
*/
static void
-_outOper(StringInfo str, Oper *node)
+_outOper(StringInfo str, Oper * node)
{
- char buf[500];
-
- sprintf(buf, "OPER");
- appendStringInfo(str,buf);
- sprintf(buf, " :opno %u", node->opno);
- appendStringInfo(str,buf);
- sprintf(buf, " :opid %u", node->opid);
- appendStringInfo(str,buf);
- sprintf(buf, " :opresulttype %u", node->opresulttype);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "OPER");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :opno %u", node->opno);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :opid %u", node->opid);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :opresulttype %u", node->opresulttype);
+ appendStringInfo(str, buf);
+
}
/*
- * Param is a subclass of Expr
+ * Param is a subclass of Expr
*/
static void
-_outParam(StringInfo str, Param *node)
+_outParam(StringInfo str, Param * node)
{
- char buf[500];
-
- sprintf(buf, "PARAM");
- appendStringInfo(str,buf);
- sprintf(buf, " :paramkind %d", node->paramkind);
- appendStringInfo(str,buf);
- sprintf(buf, " :paramid %hd", node->paramid);
- appendStringInfo(str,buf);
- sprintf(buf, " :paramname \"%s\"", node->paramname);
- appendStringInfo(str,buf);
- sprintf(buf, " :paramtype %u", node->paramtype);
- appendStringInfo(str,buf);
-
- appendStringInfo(str, " :param_tlist ");
- _outNode(str, node->param_tlist);
+ char buf[500];
+
+ sprintf(buf, "PARAM");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :paramkind %d", node->paramkind);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :paramid %hd", node->paramid);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :paramname \"%s\"", node->paramname);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :paramtype %u", node->paramtype);
+ appendStringInfo(str, buf);
+
+ appendStringInfo(str, " :param_tlist ");
+ _outNode(str, node->param_tlist);
}
/*
- * Stuff from execnodes.h
+ * Stuff from execnodes.h
*/
/*
- * EState is a subclass of Node.
+ * EState is a subclass of Node.
*/
static void
-_outEState(StringInfo str, EState *node)
+_outEState(StringInfo str, EState * node)
{
- char buf[500];
-
- sprintf(buf, "ESTATE");
- appendStringInfo(str,buf);
- sprintf(buf, " :direction %d", node->es_direction);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :range_table ");
- appendStringInfo(str,buf);
- _outNode(str, node->es_range_table);
-
- sprintf(buf, " :result_relation_info @ 0x%x",
- (int) (node->es_result_relation_info));
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "ESTATE");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :direction %d", node->es_direction);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :range_table ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->es_range_table);
+
+ sprintf(buf, " :result_relation_info @ 0x%x",
+ (int) (node->es_result_relation_info));
+ appendStringInfo(str, buf);
+
}
/*
- * Stuff from relation.h
+ * Stuff from relation.h
*/
static void
-_outRel(StringInfo str, Rel *node)
+_outRel(StringInfo str, Rel * node)
{
- char buf[500];
-
- sprintf(buf, "REL");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :relids ");
- appendStringInfo(str,buf);
- _outIntList(str, node->relids);
-
- sprintf(buf, " :indexed %s", (node->indexed ? "true" : "nil"));
- appendStringInfo(str,buf);
- sprintf(buf, " :pages %u", node->pages);
- appendStringInfo(str,buf);
- sprintf(buf, " :tuples %u", node->tuples);
- appendStringInfo(str,buf);
- sprintf(buf, " :size %u", node->size);
- appendStringInfo(str,buf);
- sprintf(buf, " :width %u", node->width);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :targetlist ");
- appendStringInfo(str,buf);
- _outNode(str, node->targetlist);
-
- sprintf(buf, " :pathlist ");
- appendStringInfo(str,buf);
- _outNode(str, node->pathlist);
-
- /*
- * Not sure if these are nodes or not. They're declared as
- * struct Path *. Since i don't know, i'll just print the
- * addresses for now. This can be changed later, if necessary.
- */
-
- sprintf(buf, " :unorderedpath @ 0x%x", (int)(node->unorderedpath));
- appendStringInfo(str,buf);
- sprintf(buf, " :cheapestpath @ 0x%x", (int)(node->cheapestpath));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :pruneable %s", (node->pruneable ? "true" : "nil"));
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "REL");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :relids ");
+ appendStringInfo(str, buf);
+ _outIntList(str, node->relids);
+
+ sprintf(buf, " :indexed %s", (node->indexed ? "true" : "nil"));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :pages %u", node->pages);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :tuples %u", node->tuples);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :size %u", node->size);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :width %u", node->width);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :targetlist ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->targetlist);
+
+ sprintf(buf, " :pathlist ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->pathlist);
+
+ /*
+ * Not sure if these are nodes or not. They're declared as struct
+ * Path *. Since i don't know, i'll just print the addresses for now.
+ * This can be changed later, if necessary.
+ */
+
+ sprintf(buf, " :unorderedpath @ 0x%x", (int) (node->unorderedpath));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :cheapestpath @ 0x%x", (int) (node->cheapestpath));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :pruneable %s", (node->pruneable ? "true" : "nil"));
+ appendStringInfo(str, buf);
+
#if 0
- sprintf(buf, " :classlist ");
- appendStringInfo(str,buf);
- _outNode(str, node->classlist);
-
- sprintf(buf, " :indexkeys ");
- appendStringInfo(str,buf);
- _outNode(str, node->indexkeys);
-
- sprintf(buf, " :ordering ");
- appendStringInfo(str,buf);
- _outNode(str, node->ordering);
-#endif
-
- sprintf(buf, " :clauseinfo ");
- appendStringInfo(str,buf);
- _outNode(str, node->clauseinfo);
-
- sprintf(buf, " :joininfo ");
- appendStringInfo(str,buf);
- _outNode(str, node->joininfo);
-
- sprintf(buf, " :innerjoin ");
- appendStringInfo(str,buf);
- _outNode(str, node->innerjoin);
-
+ sprintf(buf, " :classlist ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->classlist);
+
+ sprintf(buf, " :indexkeys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->indexkeys);
+
+ sprintf(buf, " :ordering ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->ordering);
+#endif
+
+ sprintf(buf, " :clauseinfo ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->clauseinfo);
+
+ sprintf(buf, " :joininfo ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->joininfo);
+
+ sprintf(buf, " :innerjoin ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->innerjoin);
+
}
/*
- * TargetEntry is a subclass of Node.
+ * TargetEntry is a subclass of Node.
*/
static void
-_outTargetEntry(StringInfo str, TargetEntry *node)
+_outTargetEntry(StringInfo str, TargetEntry * node)
{
- char buf[500];
-
- sprintf(buf, "TLE");
- appendStringInfo(str,buf);
- sprintf(buf, " :resdom ");
- appendStringInfo(str,buf);
- _outNode(str, node->resdom);
-
- sprintf(buf, " :expr ");
- appendStringInfo(str,buf);
- if (node->expr) {
- _outNode(str, node->expr);
- }else {
- appendStringInfo(str, "nil");
- }
-}
+ char buf[500];
+
+ sprintf(buf, "TLE");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :resdom ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->resdom);
+
+ sprintf(buf, " :expr ");
+ appendStringInfo(str, buf);
+ if (node->expr)
+ {
+ _outNode(str, node->expr);
+ }
+ else
+ {
+ appendStringInfo(str, "nil");
+ }
+}
static void
-_outRangeTblEntry(StringInfo str, RangeTblEntry *node)
+_outRangeTblEntry(StringInfo str, RangeTblEntry * node)
{
- char buf[500];
-
- sprintf(buf, "RTE");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :relname \"%s\"",
- ((node->relname) ? ((char *) node->relname) : "null"));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :inh %d ", node->inh);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :refname \"%s\"",
- ((node->refname) ? ((char *) node->refname) : "null"));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :relid %u ", node->relid);
- appendStringInfo(str,buf);
-}
+ char buf[500];
+
+ sprintf(buf, "RTE");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :relname \"%s\"",
+ ((node->relname) ? ((char *) node->relname) : "null"));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :inh %d ", node->inh);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :refname \"%s\"",
+ ((node->refname) ? ((char *) node->refname) : "null"));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :relid %u ", node->relid);
+ appendStringInfo(str, buf);
+}
/*
- * Path is a subclass of Node.
+ * Path is a subclass of Node.
*/
static void
-_outPath(StringInfo str, Path *node)
+_outPath(StringInfo str, Path * node)
{
- char buf[500];
-
- sprintf(buf, "PATH");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :pathtype %d", node->pathtype);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :cost %f", node->path_cost);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :keys ");
- appendStringInfo(str,buf);
- _outNode(str, node->keys);
-
+ char buf[500];
+
+ sprintf(buf, "PATH");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :pathtype %d", node->pathtype);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :cost %f", node->path_cost);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :keys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->keys);
+
}
/*
- * IndexPath is a subclass of Path.
+ * IndexPath is a subclass of Path.
*/
static void
-_outIndexPath(StringInfo str, IndexPath *node)
+_outIndexPath(StringInfo str, IndexPath * node)
{
- char buf[500];
-
- sprintf(buf, "INDEXPATH");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :pathtype %d", node->path.pathtype);
- appendStringInfo(str,buf);
-
- /* sprintf(buf, " :parent ");
- appendStringInfo(str,buf);
- _outNode(str, node->parent); */
-
- sprintf(buf, " :cost %f", node->path.path_cost);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "INDEXPATH");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :pathtype %d", node->path.pathtype);
+ appendStringInfo(str, buf);
+
+ /*
+ * sprintf(buf, " :parent "); appendStringInfo(str,buf); _outNode(str,
+ * node->parent);
+ */
+
+ sprintf(buf, " :cost %f", node->path.path_cost);
+ appendStringInfo(str, buf);
+
#if 0
- sprintf(buf, " :p_ordering ");
- appendStringInfo(str,buf);
- _outNode(str, node->path.p_ordering);
-#endif
- sprintf(buf, " :keys ");
- appendStringInfo(str,buf);
- _outNode(str, node->path.keys);
-
- sprintf(buf, " :indexid ");
- appendStringInfo(str,buf);
- _outIntList(str, node->indexid);
-
- sprintf(buf, " :indexqual ");
- appendStringInfo(str,buf);
- _outNode(str, node->indexqual);
-
+ sprintf(buf, " :p_ordering ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->path.p_ordering);
+#endif
+ sprintf(buf, " :keys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->path.keys);
+
+ sprintf(buf, " :indexid ");
+ appendStringInfo(str, buf);
+ _outIntList(str, node->indexid);
+
+ sprintf(buf, " :indexqual ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->indexqual);
+
}
/*
- * JoinPath is a subclass of Path
+ * JoinPath is a subclass of Path
*/
static void
-_outJoinPath(StringInfo str, JoinPath *node)
+_outJoinPath(StringInfo str, JoinPath * node)
{
- char buf[500];
-
- sprintf(buf, "JOINPATH");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :pathtype %d", node->path.pathtype);
- appendStringInfo(str,buf);
-
- /* sprintf(buf, " :parent ");
- appendStringInfo(str,buf);
- _outNode(str, node->parent); */
-
- sprintf(buf, " :cost %f", node->path.path_cost);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "JOINPATH");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :pathtype %d", node->path.pathtype);
+ appendStringInfo(str, buf);
+
+ /*
+ * sprintf(buf, " :parent "); appendStringInfo(str,buf); _outNode(str,
+ * node->parent);
+ */
+
+ sprintf(buf, " :cost %f", node->path.path_cost);
+ appendStringInfo(str, buf);
+
#if 0
- sprintf(buf, " :p_ordering ");
- appendStringInfo(str,buf);
- _outNode(str, node->path.p_ordering);
-#endif
- sprintf(buf, " :keys ");
- appendStringInfo(str,buf);
- _outNode(str, node->path.keys);
-
- sprintf(buf, " :pathclauseinfo ");
- appendStringInfo(str,buf);
- _outNode(str, node->pathclauseinfo);
-
- /*
- * Not sure if these are nodes; they're declared as "struct path *".
- * For now, i'll just print the addresses.
- */
-
- sprintf(buf, " :outerjoinpath @ 0x%x", (int)(node->outerjoinpath));
- appendStringInfo(str,buf);
- sprintf(buf, " :innerjoinpath @ 0x%x", (int)(node->innerjoinpath));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :outerjoincost %f", node->path.outerjoincost);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :joinid ");
- appendStringInfo(str,buf);
- _outIntList(str, node->path.joinid);
-
+ sprintf(buf, " :p_ordering ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->path.p_ordering);
+#endif
+ sprintf(buf, " :keys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->path.keys);
+
+ sprintf(buf, " :pathclauseinfo ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->pathclauseinfo);
+
+ /*
+ * Not sure if these are nodes; they're declared as "struct path *".
+ * For now, i'll just print the addresses.
+ */
+
+ sprintf(buf, " :outerjoinpath @ 0x%x", (int) (node->outerjoinpath));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :innerjoinpath @ 0x%x", (int) (node->innerjoinpath));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :outerjoincost %f", node->path.outerjoincost);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :joinid ");
+ appendStringInfo(str, buf);
+ _outIntList(str, node->path.joinid);
+
}
/*
- * MergePath is a subclass of JoinPath.
+ * MergePath is a subclass of JoinPath.
*/
static void
-_outMergePath(StringInfo str, MergePath *node)
+_outMergePath(StringInfo str, MergePath * node)
{
- char buf[500];
-
- sprintf(buf, "MERGEPATH");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :pathtype %d", node->jpath.path.pathtype);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :cost %f", node->jpath.path.path_cost);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :keys ");
- appendStringInfo(str,buf);
- _outNode(str, node->jpath.path.keys);
-
- sprintf(buf, " :pathclauseinfo ");
- appendStringInfo(str,buf);
- _outNode(str, node->jpath.pathclauseinfo);
-
- /*
- * Not sure if these are nodes; they're declared as "struct path *".
- * For now, i'll just print the addresses.
- */
-
- sprintf(buf, " :outerjoinpath @ 0x%x", (int)(node->jpath.outerjoinpath));
- appendStringInfo(str,buf);
- sprintf(buf, " :innerjoinpath @ 0x%x", (int)(node->jpath.innerjoinpath));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :joinid ");
- appendStringInfo(str,buf);
- _outIntList(str, node->jpath.path.joinid);
-
- sprintf(buf, " :path_mergeclauses ");
- appendStringInfo(str,buf);
- _outNode(str, node->path_mergeclauses);
-
- sprintf(buf, " :outersortkeys ");
- appendStringInfo(str,buf);
- _outNode(str, node->outersortkeys);
-
- sprintf(buf, " :innersortkeys ");
- appendStringInfo(str,buf);
- _outNode(str, node->innersortkeys);
-
+ char buf[500];
+
+ sprintf(buf, "MERGEPATH");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :pathtype %d", node->jpath.path.pathtype);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :cost %f", node->jpath.path.path_cost);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :keys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jpath.path.keys);
+
+ sprintf(buf, " :pathclauseinfo ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jpath.pathclauseinfo);
+
+ /*
+ * Not sure if these are nodes; they're declared as "struct path *".
+ * For now, i'll just print the addresses.
+ */
+
+ sprintf(buf, " :outerjoinpath @ 0x%x", (int) (node->jpath.outerjoinpath));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :innerjoinpath @ 0x%x", (int) (node->jpath.innerjoinpath));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :joinid ");
+ appendStringInfo(str, buf);
+ _outIntList(str, node->jpath.path.joinid);
+
+ sprintf(buf, " :path_mergeclauses ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->path_mergeclauses);
+
+ sprintf(buf, " :outersortkeys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->outersortkeys);
+
+ sprintf(buf, " :innersortkeys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->innersortkeys);
+
}
/*
- * HashPath is a subclass of JoinPath.
+ * HashPath is a subclass of JoinPath.
*/
static void
-_outHashPath(StringInfo str, HashPath *node)
+_outHashPath(StringInfo str, HashPath * node)
{
- char buf[500];
-
- sprintf(buf, "HASHPATH");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :pathtype %d", node->jpath.path.pathtype);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :cost %f", node->jpath.path.path_cost);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :keys ");
- appendStringInfo(str,buf);
- _outNode(str, node->jpath.path.keys);
-
- sprintf(buf, " :pathclauseinfo ");
- appendStringInfo(str,buf);
- _outNode(str, node->jpath.pathclauseinfo);
-
- /*
- * Not sure if these are nodes; they're declared as "struct path *".
- * For now, i'll just print the addresses.
- */
-
- sprintf(buf, " :outerjoinpath @ 0x%x", (int) (node->jpath.outerjoinpath));
- appendStringInfo(str,buf);
- sprintf(buf, " :innerjoinpath @ 0x%x", (int) (node->jpath.innerjoinpath));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :joinid ");
- appendStringInfo(str,buf);
- _outIntList(str, node->jpath.path.joinid);
-
- sprintf(buf, " :path_hashclauses ");
- appendStringInfo(str,buf);
- _outNode(str, node->path_hashclauses);
-
- sprintf(buf, " :outerhashkeys ");
- appendStringInfo(str,buf);
- _outNode(str, node->outerhashkeys);
-
- sprintf(buf, " :innerhashkeys ");
- appendStringInfo(str,buf);
- _outNode(str, node->innerhashkeys);
-
+ char buf[500];
+
+ sprintf(buf, "HASHPATH");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :pathtype %d", node->jpath.path.pathtype);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :cost %f", node->jpath.path.path_cost);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :keys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jpath.path.keys);
+
+ sprintf(buf, " :pathclauseinfo ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jpath.pathclauseinfo);
+
+ /*
+ * Not sure if these are nodes; they're declared as "struct path *".
+ * For now, i'll just print the addresses.
+ */
+
+ sprintf(buf, " :outerjoinpath @ 0x%x", (int) (node->jpath.outerjoinpath));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :innerjoinpath @ 0x%x", (int) (node->jpath.innerjoinpath));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :joinid ");
+ appendStringInfo(str, buf);
+ _outIntList(str, node->jpath.path.joinid);
+
+ sprintf(buf, " :path_hashclauses ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->path_hashclauses);
+
+ sprintf(buf, " :outerhashkeys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->outerhashkeys);
+
+ sprintf(buf, " :innerhashkeys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->innerhashkeys);
+
}
/*
- * OrderKey is a subclass of Node.
+ * OrderKey is a subclass of Node.
*/
static void
-_outOrderKey(StringInfo str, OrderKey *node)
+_outOrderKey(StringInfo str, OrderKey * node)
{
- char buf[500];
-
- sprintf(buf, "ORDERKEY");
- appendStringInfo(str,buf);
- sprintf(buf, " :attribute_number %d", node->attribute_number);
- appendStringInfo(str,buf);
- sprintf(buf, " :array_index %d", node->array_index);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "ORDERKEY");
+ appendStringInfo(str, buf);
+ sprintf(buf, " :attribute_number %d", node->attribute_number);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :array_index %d", node->array_index);
+ appendStringInfo(str, buf);
+
}
/*
- * JoinKey is a subclass of Node.
+ * JoinKey is a subclass of Node.
*/
static void
-_outJoinKey(StringInfo str, JoinKey *node)
+_outJoinKey(StringInfo str, JoinKey * node)
{
- char buf[500];
-
- sprintf(buf, "JOINKEY");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :outer ");
- appendStringInfo(str,buf);
- _outNode(str, node->outer);
-
- sprintf(buf, " :inner ");
- appendStringInfo(str,buf);
- _outNode(str, node->inner);
-
+ char buf[500];
+
+ sprintf(buf, "JOINKEY");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :outer ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->outer);
+
+ sprintf(buf, " :inner ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->inner);
+
}
/*
- * MergeOrder is a subclass of Node.
+ * MergeOrder is a subclass of Node.
*/
static void
-_outMergeOrder(StringInfo str, MergeOrder *node)
+_outMergeOrder(StringInfo str, MergeOrder * node)
{
- char buf[500];
-
- sprintf(buf, "MERGEORDER");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :join_operator %d", node->join_operator);
- appendStringInfo(str,buf);
- sprintf(buf, " :left_operator %d", node->left_operator);
- appendStringInfo(str,buf);
- sprintf(buf, " :right_operator %d", node->right_operator);
- appendStringInfo(str,buf);
- sprintf(buf, " :left_type %d", node->left_type);
- appendStringInfo(str,buf);
- sprintf(buf, " :right_type %d", node->right_type);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "MERGEORDER");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :join_operator %d", node->join_operator);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :left_operator %d", node->left_operator);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :right_operator %d", node->right_operator);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :left_type %d", node->left_type);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :right_type %d", node->right_type);
+ appendStringInfo(str, buf);
+
}
/*
- * CInfo is a subclass of Node.
+ * CInfo is a subclass of Node.
*/
static void
-_outCInfo(StringInfo str, CInfo *node)
+_outCInfo(StringInfo str, CInfo * node)
{
- char buf[500];
-
- sprintf(buf, "CINFO");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :clause ");
- appendStringInfo(str,buf);
- _outNode(str, node->clause);
-
- sprintf(buf, " :selectivity %f", node->selectivity);
- appendStringInfo(str,buf);
- sprintf(buf, " :notclause %s", (node->notclause ? "true" : "nil"));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :indexids ");
- appendStringInfo(str,buf);
- _outNode(str, node->indexids);
-
- sprintf(buf, " :mergesortorder ");
- appendStringInfo(str,buf);
- _outNode(str, node->mergesortorder);
-
- sprintf(buf, " :hashjoinoperator %u", node->hashjoinoperator);
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "CINFO");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :clause ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->clause);
+
+ sprintf(buf, " :selectivity %f", node->selectivity);
+ appendStringInfo(str, buf);
+ sprintf(buf, " :notclause %s", (node->notclause ? "true" : "nil"));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :indexids ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->indexids);
+
+ sprintf(buf, " :mergesortorder ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->mergesortorder);
+
+ sprintf(buf, " :hashjoinoperator %u", node->hashjoinoperator);
+ appendStringInfo(str, buf);
+
}
/*
- * JoinMethod is a subclass of Node.
+ * JoinMethod is a subclass of Node.
*/
static void
-_outJoinMethod(StringInfo str, JoinMethod *node)
+_outJoinMethod(StringInfo str, JoinMethod * node)
{
- char buf[500];
-
- sprintf(buf, "JOINMETHOD");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :jmkeys ");
- appendStringInfo(str,buf);
- _outNode(str, node->jmkeys);
-
- sprintf(buf, " :clauses ");
- appendStringInfo(str,buf);
- _outNode(str, node->clauses);
-
-
+ char buf[500];
+
+ sprintf(buf, "JOINMETHOD");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :jmkeys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jmkeys);
+
+ sprintf(buf, " :clauses ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->clauses);
+
+
}
/*
* HInfo is a subclass of JoinMethod.
*/
static void
-_outHInfo(StringInfo str, HInfo *node)
+_outHInfo(StringInfo str, HInfo * node)
{
- char buf[500];
-
- sprintf(buf, "HASHINFO");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :hashop ");
- appendStringInfo(str,buf);
- sprintf(buf, "%u",node->hashop);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :jmkeys ");
- appendStringInfo(str,buf);
- _outNode(str, node->jmethod.jmkeys);
-
- sprintf(buf, " :clauses ");
- appendStringInfo(str,buf);
- _outNode(str, node->jmethod.clauses);
-
+ char buf[500];
+
+ sprintf(buf, "HASHINFO");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :hashop ");
+ appendStringInfo(str, buf);
+ sprintf(buf, "%u", node->hashop);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :jmkeys ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jmethod.jmkeys);
+
+ sprintf(buf, " :clauses ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jmethod.clauses);
+
}
/*
- * JInfo is a subclass of Node.
+ * JInfo is a subclass of Node.
*/
static void
-_outJInfo(StringInfo str, JInfo *node)
+_outJInfo(StringInfo str, JInfo * node)
{
- char buf[500];
-
- sprintf(buf, "JINFO");
- appendStringInfo(str,buf);
-
- sprintf(buf, " :otherrels ");
- appendStringInfo(str,buf);
- _outIntList(str, node->otherrels);
-
- sprintf(buf, " :jinfoclauseinfo ");
- appendStringInfo(str,buf);
- _outNode(str, node->jinfoclauseinfo);
-
- sprintf(buf, " :mergesortable %s",
- (node->mergesortable ? "true" : "nil"));
- appendStringInfo(str,buf);
- sprintf(buf, " :hashjoinable %s",
- (node->hashjoinable ? "true" : "nil"));
- appendStringInfo(str,buf);
-
+ char buf[500];
+
+ sprintf(buf, "JINFO");
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :otherrels ");
+ appendStringInfo(str, buf);
+ _outIntList(str, node->otherrels);
+
+ sprintf(buf, " :jinfoclauseinfo ");
+ appendStringInfo(str, buf);
+ _outNode(str, node->jinfoclauseinfo);
+
+ sprintf(buf, " :mergesortable %s",
+ (node->mergesortable ? "true" : "nil"));
+ appendStringInfo(str, buf);
+ sprintf(buf, " :hashjoinable %s",
+ (node->hashjoinable ? "true" : "nil"));
+ appendStringInfo(str, buf);
+
}
/*
@@ -1352,319 +1369,340 @@ _outJInfo(StringInfo str, JInfo *node)
static void
_outDatum(StringInfo str, Datum value, Oid type)
{
- char buf[500];
- Size length, typeLength;
- bool byValue;
- int i;
- char *s;
-
- /*
- * find some information about the type and the "real" length
- * of the datum.
- */
- byValue = get_typbyval(type);
- typeLength = get_typlen(type);
- length = datumGetSize(value, type, byValue, typeLength);
-
- if (byValue) {
- s = (char *) (&value);
- sprintf(buf, " %d [ ", length);
- appendStringInfo(str,buf);
- for (i=0; i<sizeof(Datum); i++) {
- sprintf(buf, "%d ", (int) (s[i]) );
- appendStringInfo(str,buf);
+ char buf[500];
+ Size length,
+ typeLength;
+ bool byValue;
+ int i;
+ char *s;
+
+ /*
+ * find some information about the type and the "real" length of the
+ * datum.
+ */
+ byValue = get_typbyval(type);
+ typeLength = get_typlen(type);
+ length = datumGetSize(value, type, byValue, typeLength);
+
+ if (byValue)
+ {
+ s = (char *) (&value);
+ sprintf(buf, " %d [ ", length);
+ appendStringInfo(str, buf);
+ for (i = 0; i < sizeof(Datum); i++)
+ {
+ sprintf(buf, "%d ", (int) (s[i]));
+ appendStringInfo(str, buf);
+ }
+ sprintf(buf, "] ");
+ appendStringInfo(str, buf);
}
- sprintf(buf, "] ");
- appendStringInfo(str,buf);
- } else { /* !byValue */
- s = (char *) DatumGetPointer(value);
- if (!PointerIsValid(s)) {
- sprintf(buf, " 0 [ ] ");
- appendStringInfo(str,buf);
- } else {
- /*
- * length is unsigned - very bad to do < comparison to -1 without
- * casting it to int first!! -mer 8 Jan 1991
- */
- if (((int)length) <= -1) {
- length = VARSIZE(s);
- }
- sprintf(buf, " %d [ ", length);
- appendStringInfo(str,buf);
- for (i=0; i<length; i++) {
- sprintf(buf, "%d ", (int) (s[i]) );
- appendStringInfo(str,buf);
- }
- sprintf(buf, "] ");
- appendStringInfo(str,buf);
+ else
+ { /* !byValue */
+ s = (char *) DatumGetPointer(value);
+ if (!PointerIsValid(s))
+ {
+ sprintf(buf, " 0 [ ] ");
+ appendStringInfo(str, buf);
+ }
+ else
+ {
+
+ /*
+ * length is unsigned - very bad to do < comparison to -1
+ * without casting it to int first!! -mer 8 Jan 1991
+ */
+ if (((int) length) <= -1)
+ {
+ length = VARSIZE(s);
+ }
+ sprintf(buf, " %d [ ", length);
+ appendStringInfo(str, buf);
+ for (i = 0; i < length; i++)
+ {
+ sprintf(buf, "%d ", (int) (s[i]));
+ appendStringInfo(str, buf);
+ }
+ sprintf(buf, "] ");
+ appendStringInfo(str, buf);
+ }
}
- }
-
+
}
static void
-_outIter(StringInfo str, Iter *node)
+_outIter(StringInfo str, Iter * node)
{
- appendStringInfo(str,"ITER");
-
- appendStringInfo(str," :iterexpr ");
- _outNode(str, node->iterexpr);
+ appendStringInfo(str, "ITER");
+
+ appendStringInfo(str, " :iterexpr ");
+ _outNode(str, node->iterexpr);
}
static void
-_outStream(StringInfo str, Stream *node)
+_outStream(StringInfo str, Stream * node)
{
- char buf[500];
-
- appendStringInfo(str,"STREAM");
-
- sprintf(buf, " :pathptr @ 0x%x", (int)(node->pathptr));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :cinfo @ 0x%x", (int)(node->cinfo));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :clausetype %d", (int)(node->clausetype));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :upstream @ 0x%x", (int)(node->upstream));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :downstream @ 0x%x", (int)(node->downstream));
- appendStringInfo(str,buf);
-
- sprintf(buf, " :groupup %d", node->groupup);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :groupcost %f", node->groupcost);
- appendStringInfo(str,buf);
-
- sprintf(buf, " :groupsel %f", node->groupsel);
- appendStringInfo(str,buf);
-}
+ char buf[500];
+
+ appendStringInfo(str, "STREAM");
+
+ sprintf(buf, " :pathptr @ 0x%x", (int) (node->pathptr));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :cinfo @ 0x%x", (int) (node->cinfo));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :clausetype %d", (int) (node->clausetype));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :upstream @ 0x%x", (int) (node->upstream));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :downstream @ 0x%x", (int) (node->downstream));
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :groupup %d", node->groupup);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :groupcost %f", node->groupcost);
+ appendStringInfo(str, buf);
+
+ sprintf(buf, " :groupsel %f", node->groupsel);
+ appendStringInfo(str, buf);
+}
static void
-_outValue(StringInfo str, Value *value)
+_outValue(StringInfo str, Value * value)
{
- char buf[500];
-
- switch(value->type) {
- case T_String:
- sprintf(buf, "\"%s\"", value->val.str);
- appendStringInfo(str, buf);
- break;
- case T_Integer:
- sprintf(buf, "%ld", value->val.ival);
- appendStringInfo(str, buf);
- break;
- case T_Float:
- sprintf(buf, "%f", value->val.dval);
- appendStringInfo(str, buf);
- break;
- default:
- break;
- }
- return;
+ char buf[500];
+
+ switch (value->type)
+ {
+ case T_String:
+ sprintf(buf, "\"%s\"", value->val.str);
+ appendStringInfo(str, buf);
+ break;
+ case T_Integer:
+ sprintf(buf, "%ld", value->val.ival);
+ appendStringInfo(str, buf);
+ break;
+ case T_Float:
+ sprintf(buf, "%f", value->val.dval);
+ appendStringInfo(str, buf);
+ break;
+ default:
+ break;
+ }
+ return;
}
/*
* _outNode -
- * converts a Node into ascii string and append it to 'str'
+ * converts a Node into ascii string and append it to 'str'
*/
static void
_outNode(StringInfo str, void *obj)
{
- if (obj==NULL) {
- appendStringInfo(str, "nil");
- return;
- }
+ if (obj == NULL)
+ {
+ appendStringInfo(str, "nil");
+ return;
+ }
- if (nodeTag(obj)==T_List) {
- List *l;
- appendStringInfo(str, "(");
- foreach(l, (List*)obj) {
- _outNode(str, lfirst(l));
- if (lnext(l))
- appendStringInfo(str, " ");
+ if (nodeTag(obj) == T_List)
+ {
+ List *l;
+
+ appendStringInfo(str, "(");
+ foreach(l, (List *) obj)
+ {
+ _outNode(str, lfirst(l));
+ if (lnext(l))
+ appendStringInfo(str, " ");
+ }
+ appendStringInfo(str, ")");
}
- appendStringInfo(str, ")");
- }else {
- appendStringInfo(str, "{");
- switch(nodeTag(obj)) {
- case T_Query:
- _outQuery(str, obj);
- break;
- case T_Plan:
- _outPlan(str, obj);
- break;
- case T_Result:
- _outResult(str, obj);
- break;
- case T_Existential:
- _outExistential(str, obj);
- break;
- case T_Append:
- _outAppend(str, obj);
- break;
- case T_Join:
- _outJoin(str, obj);
- break;
- case T_NestLoop:
- _outNestLoop(str, obj);
- break;
- case T_MergeJoin:
- _outMergeJoin(str, obj);
- break;
- case T_HashJoin:
- _outHashJoin(str, obj);
- break;
- case T_Scan:
- _outScan(str, obj);
- break;
- case T_SeqScan:
- _outSeqScan(str, obj);
- break;
- case T_IndexScan:
- _outIndexScan(str, obj);
- break;
- case T_Temp:
- _outTemp(str, obj);
- break;
- case T_Sort:
- _outSort(str, obj);
- break;
- case T_Agg:
- _outAgg(str, obj);
- break;
- case T_Group:
- _outGroup(str, obj);
- break;
- case T_Unique:
- _outUnique(str, obj);
- break;
- case T_Hash:
- _outHash(str, obj);
- break;
- case T_Tee:
- _outTee(str, obj);
- break;
- case T_Resdom:
- _outResdom(str, obj);
- break;
- case T_Fjoin:
- _outFjoin(str, obj);
- break;
- case T_Expr:
- _outExpr(str, obj);
- break;
- case T_Var:
- _outVar(str, obj);
- break;
- case T_Const:
- _outConst(str, obj);
- break;
- case T_Aggreg:
- _outAggreg(str, obj);
- break;
- case T_Array:
- _outArray(str, obj);
- break;
- case T_ArrayRef:
- _outArrayRef(str, obj);
- break;
- case T_Func:
- _outFunc(str, obj);
- break;
- case T_Oper:
- _outOper(str, obj);
- break;
- case T_Param:
- _outParam(str, obj);
- break;
- case T_EState:
- _outEState(str, obj);
- break;
- case T_Rel:
- _outRel(str, obj);
- break;
- case T_TargetEntry:
- _outTargetEntry(str, obj);
- break;
- case T_RangeTblEntry:
- _outRangeTblEntry(str, obj);
- break;
- case T_Path:
- _outPath(str, obj);
- break;
- case T_IndexPath:
- _outIndexPath (str, obj);
- break;
- case T_JoinPath:
- _outJoinPath(str, obj);
- break;
- case T_MergePath:
- _outMergePath(str, obj);
- break;
- case T_HashPath:
- _outHashPath(str, obj);
- break;
- case T_OrderKey:
- _outOrderKey(str, obj);
- break;
- case T_JoinKey:
- _outJoinKey(str, obj);
- break;
- case T_MergeOrder:
- _outMergeOrder(str, obj);
- break;
- case T_CInfo:
- _outCInfo(str, obj);
- break;
- case T_JoinMethod:
- _outJoinMethod(str, obj);
- break;
- case T_HInfo:
- _outHInfo(str, obj);
- break;
- case T_JInfo:
- _outJInfo(str, obj);
- break;
- case T_Iter:
- _outIter(str, obj);
- break;
- case T_Stream:
- _outStream(str, obj);
- break;
- case T_Integer: case T_String: case T_Float:
- _outValue(str, obj);
- break;
- default:
- elog(NOTICE, "_outNode: don't know how to print type %d",
- nodeTag(obj));
- break;
+ else
+ {
+ appendStringInfo(str, "{");
+ switch (nodeTag(obj))
+ {
+ case T_Query:
+ _outQuery(str, obj);
+ break;
+ case T_Plan:
+ _outPlan(str, obj);
+ break;
+ case T_Result:
+ _outResult(str, obj);
+ break;
+ case T_Existential:
+ _outExistential(str, obj);
+ break;
+ case T_Append:
+ _outAppend(str, obj);
+ break;
+ case T_Join:
+ _outJoin(str, obj);
+ break;
+ case T_NestLoop:
+ _outNestLoop(str, obj);
+ break;
+ case T_MergeJoin:
+ _outMergeJoin(str, obj);
+ break;
+ case T_HashJoin:
+ _outHashJoin(str, obj);
+ break;
+ case T_Scan:
+ _outScan(str, obj);
+ break;
+ case T_SeqScan:
+ _outSeqScan(str, obj);
+ break;
+ case T_IndexScan:
+ _outIndexScan(str, obj);
+ break;
+ case T_Temp:
+ _outTemp(str, obj);
+ break;
+ case T_Sort:
+ _outSort(str, obj);
+ break;
+ case T_Agg:
+ _outAgg(str, obj);
+ break;
+ case T_Group:
+ _outGroup(str, obj);
+ break;
+ case T_Unique:
+ _outUnique(str, obj);
+ break;
+ case T_Hash:
+ _outHash(str, obj);
+ break;
+ case T_Tee:
+ _outTee(str, obj);
+ break;
+ case T_Resdom:
+ _outResdom(str, obj);
+ break;
+ case T_Fjoin:
+ _outFjoin(str, obj);
+ break;
+ case T_Expr:
+ _outExpr(str, obj);
+ break;
+ case T_Var:
+ _outVar(str, obj);
+ break;
+ case T_Const:
+ _outConst(str, obj);
+ break;
+ case T_Aggreg:
+ _outAggreg(str, obj);
+ break;
+ case T_Array:
+ _outArray(str, obj);
+ break;
+ case T_ArrayRef:
+ _outArrayRef(str, obj);
+ break;
+ case T_Func:
+ _outFunc(str, obj);
+ break;
+ case T_Oper:
+ _outOper(str, obj);
+ break;
+ case T_Param:
+ _outParam(str, obj);
+ break;
+ case T_EState:
+ _outEState(str, obj);
+ break;
+ case T_Rel:
+ _outRel(str, obj);
+ break;
+ case T_TargetEntry:
+ _outTargetEntry(str, obj);
+ break;
+ case T_RangeTblEntry:
+ _outRangeTblEntry(str, obj);
+ break;
+ case T_Path:
+ _outPath(str, obj);
+ break;
+ case T_IndexPath:
+ _outIndexPath(str, obj);
+ break;
+ case T_JoinPath:
+ _outJoinPath(str, obj);
+ break;
+ case T_MergePath:
+ _outMergePath(str, obj);
+ break;
+ case T_HashPath:
+ _outHashPath(str, obj);
+ break;
+ case T_OrderKey:
+ _outOrderKey(str, obj);
+ break;
+ case T_JoinKey:
+ _outJoinKey(str, obj);
+ break;
+ case T_MergeOrder:
+ _outMergeOrder(str, obj);
+ break;
+ case T_CInfo:
+ _outCInfo(str, obj);
+ break;
+ case T_JoinMethod:
+ _outJoinMethod(str, obj);
+ break;
+ case T_HInfo:
+ _outHInfo(str, obj);
+ break;
+ case T_JInfo:
+ _outJInfo(str, obj);
+ break;
+ case T_Iter:
+ _outIter(str, obj);
+ break;
+ case T_Stream:
+ _outStream(str, obj);
+ break;
+ case T_Integer:
+ case T_String:
+ case T_Float:
+ _outValue(str, obj);
+ break;
+ default:
+ elog(NOTICE, "_outNode: don't know how to print type %d",
+ nodeTag(obj));
+ break;
+ }
+ appendStringInfo(str, "}");
}
- appendStringInfo(str, "}");
- }
- return;
+ return;
}
/*
* nodeToString -
- * returns the ascii representation of the Node
+ * returns the ascii representation of the Node
*/
-char *
+char *
nodeToString(void *obj)
{
- StringInfo str;
- char *s;
-
- if (obj==NULL)
- return "";
- Assert(obj!=NULL);
- str = makeStringInfo();
- _outNode(str, obj);
- s = str->data;
- pfree(str);
-
- return s;
+ StringInfo str;
+ char *s;
+
+ if (obj == NULL)
+ return "";
+ Assert(obj != NULL);
+ str = makeStringInfo();
+ _outNode(str, obj);
+ s = str->data;
+ pfree(str);
+
+ return s;
}
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c
index 0f92c189e51..9fb61ed3ea7 100644
--- a/src/backend/nodes/print.c
+++ b/src/backend/nodes/print.c
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
*
* print.c--
- * various print routines (used mostly for debugging)
+ * various print routines (used mostly for debugging)
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.6 1997/08/19 21:31:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.7 1997/09/07 04:42:55 momjian Exp $
*
* HISTORY
- * AUTHOR DATE MAJOR EVENT
- * Andrew Yu Oct 26, 1994 file creation
+ * AUTHOR DATE MAJOR EVENT
+ * Andrew Yu Oct 26, 1994 file creation
*
*-------------------------------------------------------------------------
*/
@@ -33,21 +33,21 @@
#include "nodes/plannodes.h"
#include "optimizer/clauses.h"
-static char *plannode_type (Plan* p);
+static char *plannode_type(Plan * p);
/*
* print--
- * print contents of Node to stdout
+ * print contents of Node to stdout
*/
void
print(void *obj)
{
- char *s;
+ char *s;
- s = nodeToString(obj);
- printf("%s\n", s);
- fflush(stdout);
- return;
+ s = nodeToString(obj);
+ printf("%s\n", s);
+ fflush(stdout);
+ return;
}
/*
@@ -56,327 +56,365 @@ print(void *obj)
void
pprint(void *obj)
{
- char *s;
- int i;
- char line[80];
- int indentLev;
- int j;
-
- s = nodeToString(obj);
-
- indentLev = 0;
- i = 0;
- for(;;) {
- for(j=0; j<indentLev*3; j++) {
- line[j] = ' ';
- }
- for( ; j<75 && s[i]!='\0'; i++, j++) {
- line[j] = s[i];
- switch (line[j]) {
- case '}':
- if (j != indentLev*3) {
- line[j] = '\0';
- printf("%s\n",line);
- line[indentLev*3] = '\0';
- printf("%s}\n",line);
- }else {
- line[j] = '\0';
- printf("%s}\n",line);
- }
- indentLev--;
- j = indentLev*3-1; /* print the line before : and resets */
- break;
- case ')':
- line[j+1] = '\0';
- printf("%s\n", line);
- j = indentLev*3-1;
- break;
- case '{':
- indentLev++;
- /* !!! FALLS THROUGH */
- case ':':
- if (j != 0) {
- line[j] = '\0';
- printf("%s\n",line);
- /* print the line before : and resets */
- for(j=0; j<indentLev*3; j++) {
+ char *s;
+ int i;
+ char line[80];
+ int indentLev;
+ int j;
+
+ s = nodeToString(obj);
+
+ indentLev = 0;
+ i = 0;
+ for (;;)
+ {
+ for (j = 0; j < indentLev * 3; j++)
+ {
line[j] = ' ';
- }
}
- line[j] = s[i];
- break;
- }
+ for (; j < 75 && s[i] != '\0'; i++, j++)
+ {
+ line[j] = s[i];
+ switch (line[j])
+ {
+ case '}':
+ if (j != indentLev * 3)
+ {
+ line[j] = '\0';
+ printf("%s\n", line);
+ line[indentLev * 3] = '\0';
+ printf("%s}\n", line);
+ }
+ else
+ {
+ line[j] = '\0';
+ printf("%s}\n", line);
+ }
+ indentLev--;
+ j = indentLev * 3 - 1; /* print the line before : and
+ * resets */
+ break;
+ case ')':
+ line[j + 1] = '\0';
+ printf("%s\n", line);
+ j = indentLev * 3 - 1;
+ break;
+ case '{':
+ indentLev++;
+ /* !!! FALLS THROUGH */
+ case ':':
+ if (j != 0)
+ {
+ line[j] = '\0';
+ printf("%s\n", line);
+ /* print the line before : and resets */
+ for (j = 0; j < indentLev * 3; j++)
+ {
+ line[j] = ' ';
+ }
+ }
+ line[j] = s[i];
+ break;
+ }
+ }
+ line[j] = '\0';
+ if (s[i] == '\0')
+ break;
+ printf("%s\n", line);
}
- line[j] = '\0';
- if (s[i]=='\0')
- break;
- printf("%s\n", line);
- }
- if (j!=0) {
- printf("%s\n", line);
- }
- fflush(stdout);
- return;
+ if (j != 0)
+ {
+ printf("%s\n", line);
+ }
+ fflush(stdout);
+ return;
}
/*
* print_rt--
- * print contents of range table
+ * print contents of range table
*/
void
-print_rt(List *rtable)
+print_rt(List * rtable)
{
- List *l;
- int i=1;
-
- printf("resno\trelname(refname)\trelid\tinFromCl\n");
- printf("-----\t----------------\t-----\t--------\n");
- foreach(l, rtable) {
- RangeTblEntry *rte = lfirst(l);
- printf("%d\t%s(%s)\t%d\t%d\t%s\n",
- i,rte->relname,rte->refname,rte->relid,
- rte->inFromCl,
- (rte->inh?"inh":""));
- i++;
- }
+ List *l;
+ int i = 1;
+
+ printf("resno\trelname(refname)\trelid\tinFromCl\n");
+ printf("-----\t----------------\t-----\t--------\n");
+ foreach(l, rtable)
+ {
+ RangeTblEntry *rte = lfirst(l);
+
+ printf("%d\t%s(%s)\t%d\t%d\t%s\n",
+ i, rte->relname, rte->refname, rte->relid,
+ rte->inFromCl,
+ (rte->inh ? "inh" : ""));
+ i++;
+ }
}
/*
* print_expr--
- * print an expression
+ * print an expression
*/
void
-print_expr(Node *expr, List *rtable)
+print_expr(Node * expr, List * rtable)
{
- if (expr==NULL) {
- printf("nil");
- return;
- }
-
- if (IsA(expr,Var)) {
- Var *var = (Var*)expr;
- RangeTblEntry *rt;
- char *relname, *attname;
-
- switch (var->varno) {
- case INNER:
- relname = "INNER";
- attname = "?";
- break;
- case OUTER:
- relname = "OUTER";
- attname = "?";
- break;
- default:
- {
- Relation r;
- rt = rt_fetch(var->varno, rtable);
- relname = rt->relname;
- r = heap_openr(relname);
- if (rt->refname)
- relname = rt->refname; /* table renamed */
- attname = getAttrName(r, var->varattno);
- heap_close(r);
- }
- break;
+ if (expr == NULL)
+ {
+ printf("nil");
+ return;
}
- printf("%s.%s",relname,attname);
- } else if (IsA(expr,Expr)) {
- Expr *e = (Expr*)expr;
- if (is_opclause(expr)) {
- char *opname;
-
- print_expr((Node*)get_leftop(e), rtable);
- opname = get_opname(((Oper*)e->oper)->opno);
- printf(" %s ", opname);
- print_expr((Node*)get_rightop(e), rtable);
- } else {
- printf("an expr");
+
+ if (IsA(expr, Var))
+ {
+ Var *var = (Var *) expr;
+ RangeTblEntry *rt;
+ char *relname,
+ *attname;
+
+ switch (var->varno)
+ {
+ case INNER:
+ relname = "INNER";
+ attname = "?";
+ break;
+ case OUTER:
+ relname = "OUTER";
+ attname = "?";
+ break;
+ default:
+ {
+ Relation r;
+
+ rt = rt_fetch(var->varno, rtable);
+ relname = rt->relname;
+ r = heap_openr(relname);
+ if (rt->refname)
+ relname = rt->refname; /* table renamed */
+ attname = getAttrName(r, var->varattno);
+ heap_close(r);
+ }
+ break;
+ }
+ printf("%s.%s", relname, attname);
+ }
+ else if (IsA(expr, Expr))
+ {
+ Expr *e = (Expr *) expr;
+
+ if (is_opclause(expr))
+ {
+ char *opname;
+
+ print_expr((Node *) get_leftop(e), rtable);
+ opname = get_opname(((Oper *) e->oper)->opno);
+ printf(" %s ", opname);
+ print_expr((Node *) get_rightop(e), rtable);
+ }
+ else
+ {
+ printf("an expr");
+ }
+ }
+ else
+ {
+ printf("not an expr");
}
- } else {
- printf("not an expr");
- }
}
/*
* print_keys -
- * temporary here. where is keys list of list??
+ * temporary here. where is keys list of list??
*/
void
-print_keys(List *keys, List *rtable)
+print_keys(List * keys, List * rtable)
{
- List *k;
-
- printf("(");
- foreach(k, keys) {
- Node *var = lfirst((List*)lfirst(k));
- print_expr(var, rtable);
- if (lnext(k)) printf(", ");
- }
- printf(")\n");
+ List *k;
+
+ printf("(");
+ foreach(k, keys)
+ {
+ Node *var = lfirst((List *) lfirst(k));
+
+ print_expr(var, rtable);
+ if (lnext(k))
+ printf(", ");
+ }
+ printf(")\n");
}
/*
* print_tl --
- * print targetlist in a more legible way.
+ * print targetlist in a more legible way.
*/
-void
-print_tl(List *tlist, List *rtable)
+void
+print_tl(List * tlist, List * rtable)
{
- List *tl;
+ List *tl;
- printf("(\n");
- foreach(tl, tlist) {
- TargetEntry *tle = lfirst(tl);
+ printf("(\n");
+ foreach(tl, tlist)
+ {
+ TargetEntry *tle = lfirst(tl);
- printf("\t%d %s\t", tle->resdom->resno, tle->resdom->resname);
- if (tle->resdom->reskey!=0) {
- printf("(%d):\t", tle->resdom->reskey);
- } else {
- printf(" :\t");
+ printf("\t%d %s\t", tle->resdom->resno, tle->resdom->resname);
+ if (tle->resdom->reskey != 0)
+ {
+ printf("(%d):\t", tle->resdom->reskey);
+ }
+ else
+ {
+ printf(" :\t");
+ }
+ print_expr(tle->expr, rtable);
+ printf("\n");
}
- print_expr(tle->expr, rtable);
- printf("\n");
- }
- printf(")\n");
+ printf(")\n");
}
/*
* print_slot--
- * print out the tuple with the given TupleTableSlot
+ * print out the tuple with the given TupleTableSlot
*/
void
-print_slot(TupleTableSlot *slot)
+print_slot(TupleTableSlot * slot)
{
- if (!slot->val) {
- printf("tuple is null.\n");
- return;
- }
- if (!slot->ttc_tupleDescriptor) {
- printf("no tuple descriptor.\n");
- return;
- }
-
- debugtup(slot->val, slot->ttc_tupleDescriptor);
+ if (!slot->val)
+ {
+ printf("tuple is null.\n");
+ return;
+ }
+ if (!slot->ttc_tupleDescriptor)
+ {
+ printf("no tuple descriptor.\n");
+ return;
+ }
+
+ debugtup(slot->val, slot->ttc_tupleDescriptor);
}
-static char *
-plannode_type (Plan* p)
+static char *
+plannode_type(Plan * p)
{
- switch(nodeTag(p)) {
- case T_Plan:
- return "PLAN";
- break;
- case T_Existential:
- return "EXISTENTIAL";
- break;
- case T_Result:
- return "RESULT";
- break;
- case T_Append:
- return "APPEND";
- break;
- case T_Scan:
- return "SCAN";
- break;
- case T_SeqScan:
- return "SEQSCAN";
- break;
- case T_IndexScan:
- return "INDEXSCAN";
- break;
- case T_Join:
- return "JOIN";
- break;
- case T_NestLoop:
- return "NESTLOOP";
- break;
- case T_MergeJoin:
- return "MERGEJOIN";
- break;
- case T_HashJoin:
- return "HASHJOIN";
- break;
- case T_Temp:
- return "TEMP";
- break;
- case T_Material:
- return "MATERIAL";
- break;
- case T_Sort:
- return "SORT";
- break;
- case T_Agg:
- return "AGG";
- break;
- case T_Unique:
- return "UNIQUE";
- break;
- case T_Hash:
- return "HASH";
- break;
- case T_Tee:
- return "TEE";
- break;
- case T_Choose:
- return "CHOOSE";
- break;
- case T_Group:
- return "GROUP";
- break;
- default:
- return "UNKNOWN";
- break;
- }
+ switch (nodeTag(p))
+ {
+ case T_Plan:
+ return "PLAN";
+ break;
+ case T_Existential:
+ return "EXISTENTIAL";
+ break;
+ case T_Result:
+ return "RESULT";
+ break;
+ case T_Append:
+ return "APPEND";
+ break;
+ case T_Scan:
+ return "SCAN";
+ break;
+ case T_SeqScan:
+ return "SEQSCAN";
+ break;
+ case T_IndexScan:
+ return "INDEXSCAN";
+ break;
+ case T_Join:
+ return "JOIN";
+ break;
+ case T_NestLoop:
+ return "NESTLOOP";
+ break;
+ case T_MergeJoin:
+ return "MERGEJOIN";
+ break;
+ case T_HashJoin:
+ return "HASHJOIN";
+ break;
+ case T_Temp:
+ return "TEMP";
+ break;
+ case T_Material:
+ return "MATERIAL";
+ break;
+ case T_Sort:
+ return "SORT";
+ break;
+ case T_Agg:
+ return "AGG";
+ break;
+ case T_Unique:
+ return "UNIQUE";
+ break;
+ case T_Hash:
+ return "HASH";
+ break;
+ case T_Tee:
+ return "TEE";
+ break;
+ case T_Choose:
+ return "CHOOSE";
+ break;
+ case T_Group:
+ return "GROUP";
+ break;
+ default:
+ return "UNKNOWN";
+ break;
+ }
}
+
/*
prints the ascii description of the plan nodes
does this recursively by doing a depth-first traversal of the
plan tree. for SeqScan and IndexScan, the name of the table is also
- printed out
+ printed out
*/
void
-print_plan_recursive (Plan* p, Query *parsetree, int indentLevel, char* label)
+print_plan_recursive(Plan * p, Query * parsetree, int indentLevel, char *label)
{
- int i;
- char extraInfo[100];
+ int i;
+ char extraInfo[100];
- if (!p)
- return;
- for (i=0;i<indentLevel;i++)
- printf(" ");
- printf("%s%s :c=%.4f :s=%d :w=%d ",label, plannode_type(p),
- p->cost, p->plan_size, p->plan_width);
- if (IsA(p,Scan) || IsA(p,SeqScan)) {
- RangeTblEntry *rte;
- rte = rt_fetch(((Scan*)p)->scanrelid, parsetree->rtable);
- strNcpy(extraInfo, rte->relname, NAMEDATALEN-1);
- } else
- if (IsA(p,IndexScan)) {
- strNcpy(extraInfo,
- ((RangeTblEntry*)(nth(((IndexScan*)p)->scan.scanrelid - 1,
- parsetree->rtable)))->relname,
- NAMEDATALEN-1);
- } else
- extraInfo[0] = '\0';
- if (extraInfo[0] != '\0')
- printf(" ( %s )\n", extraInfo);
- else
- printf("\n");
- print_plan_recursive(p->lefttree, parsetree, indentLevel + 3, "l: ");
- print_plan_recursive(p->righttree, parsetree, indentLevel + 3, "r: ");
+ if (!p)
+ return;
+ for (i = 0; i < indentLevel; i++)
+ printf(" ");
+ printf("%s%s :c=%.4f :s=%d :w=%d ", label, plannode_type(p),
+ p->cost, p->plan_size, p->plan_width);
+ if (IsA(p, Scan) || IsA(p, SeqScan))
+ {
+ RangeTblEntry *rte;
+
+ rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable);
+ strNcpy(extraInfo, rte->relname, NAMEDATALEN - 1);
+ }
+ else if (IsA(p, IndexScan))
+ {
+ strNcpy(extraInfo,
+ ((RangeTblEntry *) (nth(((IndexScan *) p)->scan.scanrelid - 1,
+ parsetree->rtable)))->relname,
+ NAMEDATALEN - 1);
+ }
+ else
+ extraInfo[0] = '\0';
+ if (extraInfo[0] != '\0')
+ printf(" ( %s )\n", extraInfo);
+ else
+ printf("\n");
+ print_plan_recursive(p->lefttree, parsetree, indentLevel + 3, "l: ");
+ print_plan_recursive(p->righttree, parsetree, indentLevel + 3, "r: ");
}
-/* print_plan
+/* print_plan
prints just the plan node types */
void
-print_plan (Plan* p, Query* parsetree)
+print_plan(Plan * p, Query * parsetree)
{
- print_plan_recursive(p, parsetree, 0, "");
+ print_plan_recursive(p, parsetree, 0, "");
}
-
-
-
diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c
index 7e89f9d74d3..f0baa4f14d7 100644
--- a/src/backend/nodes/read.c
+++ b/src/backend/nodes/read.c
@@ -1,18 +1,18 @@
/*-------------------------------------------------------------------------
*
* read.c--
- * routines to convert a string (legal ascii representation of node) back
- * to nodes
+ * routines to convert a string (legal ascii representation of node) back
+ * to nodes
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.3 1997/08/12 22:53:04 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.4 1997/09/07 04:42:56 momjian Exp $
*
* HISTORY
- * AUTHOR DATE MAJOR EVENT
- * Andrew Yu Nov 2, 1994 file creation
+ * AUTHOR DATE MAJOR EVENT
+ * Andrew Yu Nov 2, 1994 file creation
*
*-------------------------------------------------------------------------
*/
@@ -26,17 +26,17 @@
/*
* stringToNode -
- * returns a Node with a given legal ascii representation
+ * returns a Node with a given legal ascii representation
*/
-void *
+void *
stringToNode(char *str)
{
- void *retval;
+ void *retval;
- lsptok(str, NULL); /* set the string used in lsptok */
- retval = nodeRead(true); /* start reading */
+ lsptok(str, NULL); /* set the string used in lsptok */
+ retval = nodeRead(true); /* start reading */
- return retval;
+ return retval;
}
/*****************************************************************************
@@ -46,115 +46,126 @@ stringToNode(char *str)
*****************************************************************************/
#define RIGHT_PAREN (1000000 + 1)
-#define LEFT_PAREN (1000000 + 2)
-#define PLAN_SYM (1000000 + 3)
-#define AT_SYMBOL (1000000 + 4)
-#define ATOM_TOKEN (1000000 + 5)
+#define LEFT_PAREN (1000000 + 2)
+#define PLAN_SYM (1000000 + 3)
+#define AT_SYMBOL (1000000 + 4)
+#define ATOM_TOKEN (1000000 + 5)
/*
* nodeTokenType -
- * returns the type of the node token contained in token.
- * It returns one of the following valid NodeTags:
- * T_Integer, T_Float, T_String
- * and some of its own:
- * RIGHT_PAREN, LEFT_PAREN, PLAN_SYM, AT_SYMBOL, ATOM_TOKEN
+ * returns the type of the node token contained in token.
+ * It returns one of the following valid NodeTags:
+ * T_Integer, T_Float, T_String
+ * and some of its own:
+ * RIGHT_PAREN, LEFT_PAREN, PLAN_SYM, AT_SYMBOL, ATOM_TOKEN
*
- * Assumption: the ascii representation is legal
+ * Assumption: the ascii representation is legal
*/
-static NodeTag
+static NodeTag
nodeTokenType(char *token, int length)
{
- NodeTag retval = 0;
-
- /*
- * Check if the token is a number (decimal or integer,
- * positive or negative
- */
- if (isdigit(*token) ||
- (length>=2 && *token=='-' && isdigit(*(token+1)) ))
+ NodeTag retval = 0;
+
+ /*
+ * Check if the token is a number (decimal or integer, positive or
+ * negative
+ */
+ if (isdigit(*token) ||
+ (length >= 2 && *token == '-' && isdigit(*(token + 1))))
{
- /*
- * skip the optional '-' (i.e. negative number)
- */
- if (*token == '-') {
- token++;
- }
-
- /*
- * See if there is a decimal point
- */
-
- for (; length && *token != '.'; token++, length--);
-
- /*
- * if there isn't, token's an int, otherwise it's a float.
- */
-
- retval = (*token != '.') ? T_Integer : T_Float;
+
+ /*
+ * skip the optional '-' (i.e. negative number)
+ */
+ if (*token == '-')
+ {
+ token++;
+ }
+
+ /*
+ * See if there is a decimal point
+ */
+
+ for (; length && *token != '.'; token++, length--);
+
+ /*
+ * if there isn't, token's an int, otherwise it's a float.
+ */
+
+ retval = (*token != '.') ? T_Integer : T_Float;
}
- else if (isalpha(*token))
- retval = ATOM_TOKEN;
- else if (*token == '(')
- retval = LEFT_PAREN;
- else if (*token == ')')
- retval = RIGHT_PAREN;
- else if (*token == '@')
- retval = AT_SYMBOL;
- else if (*token == '\"')
- retval = T_String;
- else if (*token == '{')
- retval = PLAN_SYM;
- return(retval);
+ else if (isalpha(*token))
+ retval = ATOM_TOKEN;
+ else if (*token == '(')
+ retval = LEFT_PAREN;
+ else if (*token == ')')
+ retval = RIGHT_PAREN;
+ else if (*token == '@')
+ retval = AT_SYMBOL;
+ else if (*token == '\"')
+ retval = T_String;
+ else if (*token == '{')
+ retval = PLAN_SYM;
+ return (retval);
}
/*
* Works kinda like strtok, except it doesn't put nulls into string.
- *
+ *
* Returns the length in length instead. The string can be set without
* returning a token by calling lsptok with length == NULL.
*
*/
-char *
+char *
lsptok(char *string, int *length)
{
- static char *local_str;
- char *ret_string;
-
- if (string != NULL) {
- local_str = string;
- if (length == NULL) {
- return(NULL);
+ static char *local_str;
+ char *ret_string;
+
+ if (string != NULL)
+ {
+ local_str = string;
+ if (length == NULL)
+ {
+ return (NULL);
+ }
+ }
+
+ for (; *local_str == ' '
+ || *local_str == '\n'
+ || *local_str == '\t'; local_str++);
+
+ /*
+ * Now pointing at next token.
+ */
+ ret_string = local_str;
+ if (*local_str == '\0')
+ return (NULL);
+ *length = 1;
+
+ if (*local_str == '\"')
+ {
+ for (local_str++; *local_str != '\"'; (*length)++, local_str++);
+ (*length)++;
+ local_str++;
+ }
+ else if (*local_str == ')' || *local_str == '(' ||
+ *local_str == '}' || *local_str == '{')
+ {
+ local_str++;
+ }
+ else
+ {
+ for (; *local_str != ' '
+ && *local_str != '\n'
+ && *local_str != '\t'
+ && *local_str != '{'
+ && *local_str != '}'
+ && *local_str != '('
+ && *local_str != ')'; local_str++, (*length)++);
+ (*length)--;
}
- }
-
- for (; *local_str == ' '
- || *local_str == '\n'
- || *local_str == '\t'; local_str++);
-
- /*
- * Now pointing at next token.
- */
- ret_string = local_str;
- if (*local_str == '\0') return(NULL);
- *length = 1;
-
- if (*local_str == '\"') {
- for (local_str++; *local_str != '\"'; (*length)++, local_str++);
- (*length)++; local_str++;
- }else if (*local_str == ')' || *local_str == '(' ||
- *local_str == '}' || *local_str == '{') {
- local_str++;
- }else {
- for (; *local_str != ' '
- && *local_str != '\n'
- && *local_str != '\t'
- && *local_str != '{'
- && *local_str != '}'
- && *local_str != '('
- && *local_str != ')'; local_str++, (*length)++);
- (*length)--;
- }
- return(ret_string);
+ return (ret_string);
}
/*
@@ -163,108 +174,128 @@ lsptok(char *string, int *length)
* Secrets: He assumes that lsptok already has the string (see below).
* Any callers should set read_car_only to true.
*/
-void *
+void *
nodeRead(bool read_car_only)
{
- char *token;
- NodeTag type;
- Node *this_value = NULL, *return_value = NULL;
- int tok_len;
- char tmp;
- bool make_dotted_pair_cell = false;
-
- token = lsptok(NULL, &tok_len);
-
- if (token == NULL) return(NULL);
-
- type = nodeTokenType(token, tok_len);
-
- switch(type) {
- case PLAN_SYM:
- this_value = parsePlanString();
+ char *token;
+ NodeTag type;
+ Node *this_value = NULL,
+ *return_value = NULL;
+ int tok_len;
+ char tmp;
+ bool make_dotted_pair_cell = false;
+
token = lsptok(NULL, &tok_len);
- if (token[0] != '}') return(NULL);
- if (!read_car_only)
- make_dotted_pair_cell = true;
- else
- make_dotted_pair_cell = false;
- break;
- case LEFT_PAREN:
- if (!read_car_only) {
- List *l = makeNode(List);
+ if (token == NULL)
+ return (NULL);
- lfirst(l) = nodeRead(false);
- lnext(l) = nodeRead(false);
- this_value = (Node*)l;
- }else {
- this_value = nodeRead(false);
- }
- break;
- case RIGHT_PAREN:
- this_value = NULL;
- break;
- case AT_SYMBOL:
- break;
- case ATOM_TOKEN:
- if (!strncmp(token, "nil", 3)) {
- this_value = NULL;
- /*
- * It might be "nil" but it is an atom!
- */
- if (read_car_only) {
- make_dotted_pair_cell = false;
- } else {
+ type = nodeTokenType(token, tok_len);
+
+ switch (type)
+ {
+ case PLAN_SYM:
+ this_value = parsePlanString();
+ token = lsptok(NULL, &tok_len);
+ if (token[0] != '}')
+ return (NULL);
+
+ if (!read_car_only)
+ make_dotted_pair_cell = true;
+ else
+ make_dotted_pair_cell = false;
+ break;
+ case LEFT_PAREN:
+ if (!read_car_only)
+ {
+ List *l = makeNode(List);
+
+ lfirst(l) = nodeRead(false);
+ lnext(l) = nodeRead(false);
+ this_value = (Node *) l;
+ }
+ else
+ {
+ this_value = nodeRead(false);
+ }
+ break;
+ case RIGHT_PAREN:
+ this_value = NULL;
+ break;
+ case AT_SYMBOL:
+ break;
+ case ATOM_TOKEN:
+ if (!strncmp(token, "nil", 3))
+ {
+ this_value = NULL;
+
+ /*
+ * It might be "nil" but it is an atom!
+ */
+ if (read_car_only)
+ {
+ make_dotted_pair_cell = false;
+ }
+ else
+ {
+ make_dotted_pair_cell = true;
+ }
+ }
+ else
+ {
+ tmp = token[tok_len];
+ token[tok_len] = '\0';
+ this_value = (Node *) pstrdup(token); /* !attention! not a
+ * Node. use with
+ * caution */
+ token[tok_len] = tmp;
+ make_dotted_pair_cell = true;
+ }
+ break;
+ case T_Float:
+ tmp = token[tok_len];
+ token[tok_len] = '\0';
+ this_value = (Node *) makeFloat(atof(token));
+ token[tok_len] = tmp;
+ make_dotted_pair_cell = true;
+ break;
+ case T_Integer:
+ tmp = token[tok_len];
+ token[tok_len] = '\0';
+ this_value = (Node *) makeInteger(atoi(token));
+ token[tok_len] = tmp;
make_dotted_pair_cell = true;
- }
- }else {
- tmp = token[tok_len];
- token[tok_len] = '\0';
- this_value = (Node*)pstrdup(token); /* !attention! not a Node.
- use with caution */
- token[tok_len] = tmp;
- make_dotted_pair_cell = true;
+ break;
+ case T_String:
+ tmp = token[tok_len - 1];
+ token[tok_len - 1] = '\0';
+ token++;
+ this_value = (Node *) makeString(token); /* !! not strdup'd */
+ token[tok_len - 2] = tmp;
+ make_dotted_pair_cell = true;
+ break;
+ default:
+ elog(WARN, "nodeRead: Bad type %d", type);
+ break;
}
- break;
- case T_Float:
- tmp = token[tok_len];
- token[tok_len] = '\0';
- this_value = (Node*)makeFloat(atof(token));
- token[tok_len] = tmp;
- make_dotted_pair_cell = true;
- break;
- case T_Integer:
- tmp = token[tok_len];
- token[tok_len] = '\0';
- this_value = (Node*)makeInteger(atoi(token));
- token[tok_len] = tmp;
- make_dotted_pair_cell = true;
- break;
- case T_String:
- tmp = token[tok_len - 1];
- token[tok_len - 1] = '\0';
- token++;
- this_value = (Node*)makeString(token); /* !! not strdup'd */
- token[tok_len - 2] = tmp;
- make_dotted_pair_cell = true;
- break;
- default:
- elog(WARN, "nodeRead: Bad type %d", type);
- break;
- }
- if (make_dotted_pair_cell) {
- List *l = makeNode(List);
+ if (make_dotted_pair_cell)
+ {
+ List *l = makeNode(List);
- lfirst(l) = this_value;
- if (!read_car_only) {
- lnext(l) = nodeRead(false);
- }else {
- lnext(l) = NULL;
+ lfirst(l) = this_value;
+ if (!read_car_only)
+ {
+ lnext(l) = nodeRead(false);
+ }
+ else
+ {
+ lnext(l) = NULL;
+ }
+ return_value = (Node *) l;
}
- return_value = (Node*)l;
- }else {
- return_value = this_value;
- }
- return(return_value);
+ else
+ {
+ return_value = this_value;
+ }
+ return (return_value);
}
-
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index 736873bcba2..f42d5d536ee 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -1,25 +1,25 @@
/*-------------------------------------------------------------------------
*
* readfuncs.c--
- * Reader functions for Postgres tree nodes.
+ * Reader functions for Postgres tree nodes.
*
* Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.6 1997/08/12 20:15:28 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.7 1997/09/07 04:42:57 momjian Exp $
*
* NOTES
- * Most of the read functions for plan nodes are tested. (In fact, they
- * pass the regression test as of 11/8/94.) The rest (for path selection)
- * are probably never used. No effort has been made to get them to work.
- * The simplest way to test these functions is by doing the following in
- * ProcessQuery (before executing the plan):
- * plan = stringToNode(nodeToString(plan));
- * Then, run the regression test. Let's just say you'll notice if either
- * of the above function are not properly done.
- * - ay 11/94
- *
+ * Most of the read functions for plan nodes are tested. (In fact, they
+ * pass the regression test as of 11/8/94.) The rest (for path selection)
+ * are probably never used. No effort has been made to get them to work.
+ * The simplest way to test these functions is by doing the following in
+ * ProcessQuery (before executing the plan):
+ * plan = stringToNode(nodeToString(plan));
+ * Then, run the regression test. Let's just say you'll notice if either
+ * of the above function are not properly done.
+ * - ay 11/94
+ *
*-------------------------------------------------------------------------
*/
#include <stdio.h>
@@ -47,697 +47,720 @@
#include "nodes/readfuncs.h"
/* ----------------
- * node creator declarations
+ * node creator declarations
* ----------------
*/
-static Datum readDatum(Oid type);
+static Datum readDatum(Oid type);
-static List *toIntList(List *list)
+static List *
+toIntList(List * list)
{
- List *l;
- foreach(l, list) {
- /* ugly manipulation, should probably free the Value node too */
- lfirst(l) = (void*)intVal(lfirst(l));
- }
- return list;
+ List *l;
+
+ foreach(l, list)
+ {
+ /* ugly manipulation, should probably free the Value node too */
+ lfirst(l) = (void *) intVal(lfirst(l));
+ }
+ return list;
}
/* ----------------
- * _readQuery
+ * _readQuery
* ----------------
*/
-static Query *
+static Query *
_readQuery()
{
- Query *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Query);
-
- token = lsptok(NULL, &length); /* skip the :command */
- token = lsptok(NULL, &length); /* get the commandType */
- local_node->commandType = atoi(token);
-
- token = lsptok(NULL, &length); /* skip the :utility */
- token = lsptok(NULL, &length); /* get the notify name if any*/
- if (token[0] == '"' && token[1] == '"')
- local_node->utilityStmt = NULL;
- else {
- NotifyStmt *n = makeNode(NotifyStmt);
- n->relname = palloc(length + 1);
- strNcpy(n->relname,token,length);
- local_node->utilityStmt = (Node*)n;
- }
-
- token = lsptok(NULL, &length); /* skip the :resrel */
- token = lsptok(NULL, &length); /* get the resultRelation */
- local_node->resultRelation = atoi(token);
-
- token = lsptok(NULL, &length); /* skip :rtable */
- local_node->rtable = nodeRead(true);
-
- token = lsptok(NULL, &length); /* skip the :unique */
- token = lsptok(NULL, &length); /* get the uniqueFlag */
-/* local_node->uniqueFlag = (bool)atoi(token); */
- if (token[0]=='"' && token[1] == '"') /* non-unique */
- local_node->uniqueFlag = NULL;
- else {
- local_node->uniqueFlag = palloc(length + 1);
- strNcpy(local_node->uniqueFlag,token,length);
- }
-
- token = lsptok(NULL, &length); /* skip :targetlist */
- local_node->targetList = nodeRead(true);
-
- token = lsptok(NULL, &length); /* skip :qual */
- local_node->qual = nodeRead(true);
-
- return (local_node);
+ Query *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Query);
+
+ token = lsptok(NULL, &length); /* skip the :command */
+ token = lsptok(NULL, &length); /* get the commandType */
+ local_node->commandType = atoi(token);
+
+ token = lsptok(NULL, &length); /* skip the :utility */
+ token = lsptok(NULL, &length); /* get the notify name if any */
+ if (token[0] == '"' && token[1] == '"')
+ local_node->utilityStmt = NULL;
+ else
+ {
+ NotifyStmt *n = makeNode(NotifyStmt);
+
+ n->relname = palloc(length + 1);
+ strNcpy(n->relname, token, length);
+ local_node->utilityStmt = (Node *) n;
+ }
+
+ token = lsptok(NULL, &length); /* skip the :resrel */
+ token = lsptok(NULL, &length); /* get the resultRelation */
+ local_node->resultRelation = atoi(token);
+
+ token = lsptok(NULL, &length); /* skip :rtable */
+ local_node->rtable = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* skip the :unique */
+ token = lsptok(NULL, &length); /* get the uniqueFlag */
+/* local_node->uniqueFlag = (bool)atoi(token); */
+ if (token[0] == '"' && token[1] == '"') /* non-unique */
+ local_node->uniqueFlag = NULL;
+ else
+ {
+ local_node->uniqueFlag = palloc(length + 1);
+ strNcpy(local_node->uniqueFlag, token, length);
+ }
+
+ token = lsptok(NULL, &length); /* skip :targetlist */
+ local_node->targetList = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* skip :qual */
+ local_node->qual = nodeRead(true);
+
+ return (local_node);
}
/* ----------------
- * _getPlan
+ * _getPlan
* ----------------
*/
static void
-_getPlan(Plan *node)
+_getPlan(Plan * node)
{
- char *token;
- int length;
-
- token = lsptok(NULL, &length); /* first token is :cost */
- token = lsptok(NULL, &length); /* next is the actual cost */
- node->cost = (Cost) atof(token);
-
- token = lsptok(NULL, &length); /* skip the :size */
- token = lsptok(NULL, &length); /* get the plan_size */
- node->plan_size = atoi(token);
-
- token = lsptok(NULL, &length); /* skip the :width */
- token = lsptok(NULL, &length); /* get the plan_width */
- node->plan_width = atoi(token);
-
- token = lsptok(NULL, &length); /* eat the :state stuff */
- token = lsptok(NULL, &length); /* now get the state */
-
- if (!strncmp(token, "nil", 3)) {
- node->state = (EState*) NULL;
- }else { /* Disgusting hack until I figure out what to do here */
- node->state = (EState*) ! NULL;
- }
-
- token = lsptok(NULL, &length); /* eat :qptargetlist */
- node->targetlist = nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :qpqual */
- node->qual = nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :lefttree */
- node->lefttree = (Plan*) nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :righttree */
- node->righttree = (Plan*) nodeRead(true);
-
- return;
+ char *token;
+ int length;
+
+ token = lsptok(NULL, &length); /* first token is :cost */
+ token = lsptok(NULL, &length); /* next is the actual cost */
+ node->cost = (Cost) atof(token);
+
+ token = lsptok(NULL, &length); /* skip the :size */
+ token = lsptok(NULL, &length); /* get the plan_size */
+ node->plan_size = atoi(token);
+
+ token = lsptok(NULL, &length); /* skip the :width */
+ token = lsptok(NULL, &length); /* get the plan_width */
+ node->plan_width = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat the :state stuff */
+ token = lsptok(NULL, &length); /* now get the state */
+
+ if (!strncmp(token, "nil", 3))
+ {
+ node->state = (EState *) NULL;
+ }
+ else
+ { /* Disgusting hack until I figure out what
+ * to do here */
+ node->state = (EState *) ! NULL;
+ }
+
+ token = lsptok(NULL, &length); /* eat :qptargetlist */
+ node->targetlist = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :qpqual */
+ node->qual = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :lefttree */
+ node->lefttree = (Plan *) nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :righttree */
+ node->righttree = (Plan *) nodeRead(true);
+
+ return;
}
/*
- * Stuff from plannodes.h
+ * Stuff from plannodes.h
*/
/* ----------------
- * _readPlan
+ * _readPlan
* ----------------
*/
-static Plan *
+static Plan *
_readPlan()
{
- Plan *local_node;
-
- local_node = makeNode(Plan);
-
- _getPlan(local_node);
-
- return (local_node);
+ Plan *local_node;
+
+ local_node = makeNode(Plan);
+
+ _getPlan(local_node);
+
+ return (local_node);
}
/* ----------------
- * _readResult
+ * _readResult
*
- * Does some obscene, possibly unportable, magic with
- * sizes of things.
+ * Does some obscene, possibly unportable, magic with
+ * sizes of things.
* ----------------
*/
-static Result *
+static Result *
_readResult()
{
- Result *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Result);
-
- _getPlan((Plan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :resconstantqual */
- local_node->resconstantqual = nodeRead(true); /* now read it */
-
- return( local_node );
+ Result *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Result);
+
+ _getPlan((Plan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :resconstantqual */
+ local_node->resconstantqual = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readExistential
+ * _readExistential
*
- * Existential nodes are only used by the planner.
+ * Existential nodes are only used by the planner.
* ----------------
*/
static Existential *
_readExistential()
{
- Existential *local_node;
-
- local_node = makeNode(Existential);
-
- _getPlan((Plan*)local_node);
-
- return( local_node );
+ Existential *local_node;
+
+ local_node = makeNode(Existential);
+
+ _getPlan((Plan *) local_node);
+
+ return (local_node);
}
/* ----------------
- * _readAppend
+ * _readAppend
*
- * Append is a subclass of Plan.
+ * Append is a subclass of Plan.
* ----------------
*/
-static Append *
+static Append *
_readAppend()
{
- Append *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Append);
-
- _getPlan((Plan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :unionplans */
- local_node->unionplans = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* eat :unionrelid */
- token = lsptok(NULL, &length); /* get unionrelid */
- local_node->unionrelid = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :unionrtentries */
- local_node->unionrtentries = nodeRead(true); /* now read it */
-
- return(local_node);
+ Append *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Append);
+
+ _getPlan((Plan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :unionplans */
+ local_node->unionplans = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* eat :unionrelid */
+ token = lsptok(NULL, &length); /* get unionrelid */
+ local_node->unionrelid = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :unionrtentries */
+ local_node->unionrtentries = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _getJoin
+ * _getJoin
*
* In case Join is not the same structure as Plan someday.
* ----------------
*/
static void
-_getJoin(Join *node)
+_getJoin(Join * node)
{
- _getPlan((Plan*)node);
+ _getPlan((Plan *) node);
}
/* ----------------
- * _readJoin
+ * _readJoin
*
- * Join is a subclass of Plan
+ * Join is a subclass of Plan
* ----------------
*/
-static Join *
+static Join *
_readJoin()
{
- Join *local_node;
-
- local_node = makeNode(Join);
-
- _getJoin(local_node);
-
- return( local_node );
+ Join *local_node;
+
+ local_node = makeNode(Join);
+
+ _getJoin(local_node);
+
+ return (local_node);
}
/* ----------------
- * _readNestLoop
- *
- * NestLoop is a subclass of Join
+ * _readNestLoop
+ *
+ * NestLoop is a subclass of Join
* ----------------
*/
static NestLoop *
_readNestLoop()
{
- NestLoop *local_node;
-
- local_node = makeNode(NestLoop);
-
- _getJoin((Join*)local_node);
-
- return( local_node );
+ NestLoop *local_node;
+
+ local_node = makeNode(NestLoop);
+
+ _getJoin((Join *) local_node);
+
+ return (local_node);
}
/* ----------------
- * _readMergeJoin
- *
- * MergeJoin is a subclass of Join
+ * _readMergeJoin
+ *
+ * MergeJoin is a subclass of Join
* ----------------
*/
static MergeJoin *
_readMergeJoin()
{
- MergeJoin *local_node;
- char *token;
- int length;
-
- local_node = makeNode(MergeJoin);
-
- _getJoin((Join*)local_node);
- token = lsptok(NULL, &length); /* eat :mergeclauses */
- local_node->mergeclauses = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* eat :mergesortop */
- token = lsptok(NULL, &length); /* get mergesortop */
- local_node->mergesortop = atol(token);
-
- return( local_node );
+ MergeJoin *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(MergeJoin);
+
+ _getJoin((Join *) local_node);
+ token = lsptok(NULL, &length); /* eat :mergeclauses */
+ local_node->mergeclauses = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* eat :mergesortop */
+ token = lsptok(NULL, &length); /* get mergesortop */
+ local_node->mergesortop = atol(token);
+
+ return (local_node);
}
/* ----------------
- * _readHashJoin
- *
- * HashJoin is a subclass of Join.
+ * _readHashJoin
+ *
+ * HashJoin is a subclass of Join.
* ----------------
*/
static HashJoin *
_readHashJoin()
{
- HashJoin *local_node;
- char *token;
- int length;
-
- local_node = makeNode(HashJoin);
-
- _getJoin((Join*)local_node);
-
- token = lsptok(NULL, &length); /* eat :hashclauses */
- local_node->hashclauses = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* eat :hashjoinop */
- token = lsptok(NULL, &length); /* get hashjoinop */
- local_node->hashjoinop = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :hashjointable */
- token = lsptok(NULL, &length); /* eat hashjointable */
- local_node->hashjointable = NULL;
-
- token = lsptok(NULL, &length); /* eat :hashjointablekey */
- token = lsptok(NULL, &length); /* eat hashjointablekey */
- local_node->hashjointablekey = 0;
-
- token = lsptok(NULL, &length); /* eat :hashjointablesize */
- token = lsptok(NULL, &length); /* eat hashjointablesize */
- local_node->hashjointablesize = 0;
-
- token = lsptok(NULL, &length); /* eat :hashdone */
- token = lsptok(NULL, &length); /* eat hashdone */
- local_node->hashdone = false;
-
- return( local_node );
+ HashJoin *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(HashJoin);
+
+ _getJoin((Join *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :hashclauses */
+ local_node->hashclauses = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* eat :hashjoinop */
+ token = lsptok(NULL, &length); /* get hashjoinop */
+ local_node->hashjoinop = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :hashjointable */
+ token = lsptok(NULL, &length); /* eat hashjointable */
+ local_node->hashjointable = NULL;
+
+ token = lsptok(NULL, &length); /* eat :hashjointablekey */
+ token = lsptok(NULL, &length); /* eat hashjointablekey */
+ local_node->hashjointablekey = 0;
+
+ token = lsptok(NULL, &length); /* eat :hashjointablesize */
+ token = lsptok(NULL, &length); /* eat hashjointablesize */
+ local_node->hashjointablesize = 0;
+
+ token = lsptok(NULL, &length); /* eat :hashdone */
+ token = lsptok(NULL, &length); /* eat hashdone */
+ local_node->hashdone = false;
+
+ return (local_node);
}
/* ----------------
- * _getScan
+ * _getScan
*
- * Scan is a subclass of Node
- * (Actually, according to the plannodes.h include file, it is a
- * subclass of Plan. This is why _getPlan is used here.)
+ * Scan is a subclass of Node
+ * (Actually, according to the plannodes.h include file, it is a
+ * subclass of Plan. This is why _getPlan is used here.)
*
- * Scan gets its own get function since stuff inherits it.
+ * Scan gets its own get function since stuff inherits it.
* ----------------
*/
-static void
-_getScan(Scan *node)
+static void
+_getScan(Scan * node)
{
- char *token;
- int length;
-
- _getPlan((Plan*)node);
-
- token = lsptok(NULL, &length); /* eat :scanrelid */
- token = lsptok(NULL, &length); /* get scanrelid */
- node->scanrelid = atoi(token);
+ char *token;
+ int length;
+
+ _getPlan((Plan *) node);
+
+ token = lsptok(NULL, &length); /* eat :scanrelid */
+ token = lsptok(NULL, &length); /* get scanrelid */
+ node->scanrelid = atoi(token);
}
/* ----------------
- * _readScan
- *
+ * _readScan
+ *
* Scan is a subclass of Plan (Not Node, see above).
* ----------------
*/
-static Scan *
+static Scan *
_readScan()
{
- Scan *local_node;
-
- local_node = makeNode(Scan);
-
- _getScan(local_node);
-
- return(local_node);
+ Scan *local_node;
+
+ local_node = makeNode(Scan);
+
+ _getScan(local_node);
+
+ return (local_node);
}
/* ----------------
- * _readSeqScan
- *
- * SeqScan is a subclass of Scan
+ * _readSeqScan
+ *
+ * SeqScan is a subclass of Scan
* ----------------
*/
static SeqScan *
_readSeqScan()
{
- SeqScan *local_node;
-
- local_node = makeNode(SeqScan);
-
- _getScan((Scan*)local_node);
-
- return(local_node);
+ SeqScan *local_node;
+
+ local_node = makeNode(SeqScan);
+
+ _getScan((Scan *) local_node);
+
+ return (local_node);
}
/* ----------------
- * _readIndexScan
- *
- * IndexScan is a subclass of Scan
+ * _readIndexScan
+ *
+ * IndexScan is a subclass of Scan
* ----------------
*/
static IndexScan *
_readIndexScan()
{
- IndexScan *local_node;
- char *token;
- int length;
-
- local_node = makeNode(IndexScan);
-
- _getScan((Scan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :indxid */
- local_node->indxid =
- toIntList(nodeRead(true)); /* now read it */
-
- token = lsptok(NULL, &length); /* eat :indxqual */
- local_node->indxqual = nodeRead(true); /* now read it */
-
- return(local_node);
+ IndexScan *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(IndexScan);
+
+ _getScan((Scan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :indxid */
+ local_node->indxid =
+ toIntList(nodeRead(true)); /* now read it */
+
+ token = lsptok(NULL, &length); /* eat :indxqual */
+ local_node->indxqual = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readTemp
- *
- * Temp is a subclass of Plan
+ * _readTemp
+ *
+ * Temp is a subclass of Plan
* ----------------
*/
-static Temp *
+static Temp *
_readTemp()
{
- Temp *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Temp);
-
- _getPlan((Plan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :tempid */
- token = lsptok(NULL, &length); /* get tempid */
- local_node->tempid = atol(token);
-
- token = lsptok(NULL, &length); /* eat :keycount */
- token = lsptok(NULL, &length); /* get keycount */
- local_node->keycount = atoi(token);
-
- return(local_node);
+ Temp *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Temp);
+
+ _getPlan((Plan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :tempid */
+ token = lsptok(NULL, &length); /* get tempid */
+ local_node->tempid = atol(token);
+
+ token = lsptok(NULL, &length); /* eat :keycount */
+ token = lsptok(NULL, &length); /* get keycount */
+ local_node->keycount = atoi(token);
+
+ return (local_node);
}
/* ----------------
- * _readSort
- *
- * Sort is a subclass of Temp
+ * _readSort
+ *
+ * Sort is a subclass of Temp
* ----------------
*/
-static Sort *
+static Sort *
_readSort()
{
- Sort *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Sort);
-
- _getPlan((Plan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :tempid */
- token = lsptok(NULL, &length); /* get tempid */
- local_node->tempid = atol(token);
-
- token = lsptok(NULL, &length); /* eat :keycount */
- token = lsptok(NULL, &length); /* get keycount */
- local_node->keycount = atoi(token);
-
- return(local_node);
+ Sort *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Sort);
+
+ _getPlan((Plan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :tempid */
+ token = lsptok(NULL, &length); /* get tempid */
+ local_node->tempid = atol(token);
+
+ token = lsptok(NULL, &length); /* eat :keycount */
+ token = lsptok(NULL, &length); /* get keycount */
+ local_node->keycount = atoi(token);
+
+ return (local_node);
}
-static Agg *
+static Agg *
_readAgg()
{
- Agg *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Agg);
- _getPlan((Plan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :numagg */
- token = lsptok(NULL, &length); /* get numagg */
- local_node->numAgg = atoi(token);
-
- return(local_node);
+ Agg *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Agg);
+ _getPlan((Plan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :numagg */
+ token = lsptok(NULL, &length); /* get numagg */
+ local_node->numAgg = atoi(token);
+
+ return (local_node);
}
/* ----------------
- * _readUnique
+ * _readUnique
*
* For some reason, unique is a subclass of Temp.
*/
-static Unique *
+static Unique *
_readUnique()
{
- Unique *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Unique);
-
- _getPlan((Plan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :tempid */
- token = lsptok(NULL, &length); /* get :tempid */
- local_node->tempid = atol(token);
-
- token = lsptok(NULL, &length); /* eat :keycount */
- token = lsptok(NULL, &length); /* get :keycount */
- local_node->keycount = atoi(token);
-
- return(local_node);
+ Unique *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Unique);
+
+ _getPlan((Plan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :tempid */
+ token = lsptok(NULL, &length); /* get :tempid */
+ local_node->tempid = atol(token);
+
+ token = lsptok(NULL, &length); /* eat :keycount */
+ token = lsptok(NULL, &length); /* get :keycount */
+ local_node->keycount = atoi(token);
+
+ return (local_node);
}
/* ----------------
- * _readHash
- *
- * Hash is a subclass of Temp
+ * _readHash
+ *
+ * Hash is a subclass of Temp
* ----------------
*/
-static Hash *
+static Hash *
_readHash()
{
- Hash *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Hash);
-
- _getPlan((Plan*)local_node);
-
- token = lsptok(NULL, &length); /* eat :hashkey */
- local_node->hashkey = (Var*) nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :hashtable */
- token = lsptok(NULL, &length); /* eat hashtable address*/
- local_node->hashtable = NULL;
-
- token = lsptok(NULL, &length); /* eat :hashtablekey*/
- token = lsptok(NULL, &length); /* get hashtablekey */
- local_node->hashtablekey = 0;
-
- token = lsptok(NULL, &length); /* eat :hashtablesize*/
- token = lsptok(NULL, &length); /* get hashtablesize */
- local_node->hashtablesize = 0;
-
- return(local_node);
+ Hash *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Hash);
+
+ _getPlan((Plan *) local_node);
+
+ token = lsptok(NULL, &length); /* eat :hashkey */
+ local_node->hashkey = (Var *) nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :hashtable */
+ token = lsptok(NULL, &length); /* eat hashtable address */
+ local_node->hashtable = NULL;
+
+ token = lsptok(NULL, &length); /* eat :hashtablekey */
+ token = lsptok(NULL, &length); /* get hashtablekey */
+ local_node->hashtablekey = 0;
+
+ token = lsptok(NULL, &length); /* eat :hashtablesize */
+ token = lsptok(NULL, &length); /* get hashtablesize */
+ local_node->hashtablesize = 0;
+
+ return (local_node);
}
/*
- * Stuff from primnodes.h.
+ * Stuff from primnodes.h.
*/
/* ----------------
- * _readResdom
- *
- * Resdom is a subclass of Node
+ * _readResdom
+ *
+ * Resdom is a subclass of Node
* ----------------
*/
-static Resdom *
+static Resdom *
_readResdom()
{
- Resdom *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Resdom);
-
- token = lsptok(NULL, &length); /* eat :resno */
- token = lsptok(NULL, &length); /* get resno */
- local_node->resno = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :restype */
- token = lsptok(NULL, &length); /* get restype */
- local_node->restype = atol(token);
-
- token = lsptok(NULL, &length); /* eat :reslen */
- token = lsptok(NULL, &length); /* get reslen */
- local_node->reslen = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :resname */
- token = lsptok(NULL, &length); /* get the name */
-
- if (!strncmp(token, "\"null\"", 5)) {
- local_node->resname = NULL;
- }else {
- /*
- * Peel off ""'s, then make a true copy.
- */
-
- token++;
- token[length - 2] = '\0';
-
- local_node->resname = palloc(length);
- strcpy(local_node->resname, token);
- token[length - 2] = '\"';
- }
-
- token = lsptok(NULL, &length); /* eat :reskey */
- token = lsptok(NULL, &length); /* get reskey */
- local_node->reskey = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :reskeyop */
- token = lsptok(NULL, &length); /* get reskeyop */
- local_node->reskeyop = (Oid) atol(token);
-
- token = lsptok(NULL, &length); /* eat :resjunk */
- token = lsptok(NULL, &length); /* get resjunk */
- local_node->resjunk = atoi(token);
-
- return(local_node);
+ Resdom *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Resdom);
+
+ token = lsptok(NULL, &length); /* eat :resno */
+ token = lsptok(NULL, &length); /* get resno */
+ local_node->resno = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :restype */
+ token = lsptok(NULL, &length); /* get restype */
+ local_node->restype = atol(token);
+
+ token = lsptok(NULL, &length); /* eat :reslen */
+ token = lsptok(NULL, &length); /* get reslen */
+ local_node->reslen = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :resname */
+ token = lsptok(NULL, &length); /* get the name */
+
+ if (!strncmp(token, "\"null\"", 5))
+ {
+ local_node->resname = NULL;
+ }
+ else
+ {
+
+ /*
+ * Peel off ""'s, then make a true copy.
+ */
+
+ token++;
+ token[length - 2] = '\0';
+
+ local_node->resname = palloc(length);
+ strcpy(local_node->resname, token);
+ token[length - 2] = '\"';
+ }
+
+ token = lsptok(NULL, &length); /* eat :reskey */
+ token = lsptok(NULL, &length); /* get reskey */
+ local_node->reskey = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :reskeyop */
+ token = lsptok(NULL, &length); /* get reskeyop */
+ local_node->reskeyop = (Oid) atol(token);
+
+ token = lsptok(NULL, &length); /* eat :resjunk */
+ token = lsptok(NULL, &length); /* get resjunk */
+ local_node->resjunk = atoi(token);
+
+ return (local_node);
}
/* ----------------
- * _readExpr
- *
- * Expr is a subclass of Node
+ * _readExpr
+ *
+ * Expr is a subclass of Node
* ----------------
*/
-static Expr *
+static Expr *
_readExpr()
{
- Expr *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Expr);
-
- token = lsptok(NULL, &length); /* eat :typeOid */
- token = lsptok(NULL, &length); /* get typeOid */
- local_node->typeOid = (Oid)atol(token);
-
- token = lsptok(NULL, &length); /* eat :opType */
- token = lsptok(NULL, &length); /* get opType */
- if (!strncmp(token, "op", 2)) {
- local_node->opType = OP_EXPR;
- } else if (!strncmp(token, "func", 4)) {
- local_node->opType = FUNC_EXPR;
- } else if (!strncmp(token, "or", 2)) {
- local_node->opType = OR_EXPR;
- } else if (!strncmp(token, "and", 3)) {
- local_node->opType = AND_EXPR;
- } else if (!strncmp(token, "not", 3)) {
- local_node->opType = NOT_EXPR;
- }
-
- token = lsptok(NULL, &length); /* eat :oper */
- local_node->oper = nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :args */
- local_node->args = nodeRead(true); /* now read it */
-
- return(local_node);
+ Expr *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Expr);
+
+ token = lsptok(NULL, &length); /* eat :typeOid */
+ token = lsptok(NULL, &length); /* get typeOid */
+ local_node->typeOid = (Oid) atol(token);
+
+ token = lsptok(NULL, &length); /* eat :opType */
+ token = lsptok(NULL, &length); /* get opType */
+ if (!strncmp(token, "op", 2))
+ {
+ local_node->opType = OP_EXPR;
+ }
+ else if (!strncmp(token, "func", 4))
+ {
+ local_node->opType = FUNC_EXPR;
+ }
+ else if (!strncmp(token, "or", 2))
+ {
+ local_node->opType = OR_EXPR;
+ }
+ else if (!strncmp(token, "and", 3))
+ {
+ local_node->opType = AND_EXPR;
+ }
+ else if (!strncmp(token, "not", 3))
+ {
+ local_node->opType = NOT_EXPR;
+ }
+
+ token = lsptok(NULL, &length); /* eat :oper */
+ local_node->oper = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :args */
+ local_node->args = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readVar
- *
- * Var is a subclass of Expr
+ * _readVar
+ *
+ * Var is a subclass of Expr
* ----------------
*/
-static Var *
+static Var *
_readVar()
{
- Var *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Var);
-
- token = lsptok(NULL, &length); /* eat :varno */
- token = lsptok(NULL, &length); /* get varno */
- local_node->varno = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :varattno */
- token = lsptok(NULL, &length); /* get varattno */
- local_node->varattno = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :vartype */
- token = lsptok(NULL, &length); /* get vartype */
- local_node->vartype = (Oid) atol(token);
-
- token = lsptok(NULL, &length); /* eat :varnoold */
- token = lsptok(NULL, &length); /* get varnoold */
- local_node->varnoold = (Oid) atol(token);
-
- token = lsptok(NULL, &length); /* eat :varoattno */
- token = lsptok(NULL, &length); /* eat :varoattno */
- local_node->varoattno = (int) atol(token);
-
- return(local_node);
+ Var *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Var);
+
+ token = lsptok(NULL, &length); /* eat :varno */
+ token = lsptok(NULL, &length); /* get varno */
+ local_node->varno = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :varattno */
+ token = lsptok(NULL, &length); /* get varattno */
+ local_node->varattno = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :vartype */
+ token = lsptok(NULL, &length); /* get vartype */
+ local_node->vartype = (Oid) atol(token);
+
+ token = lsptok(NULL, &length); /* eat :varnoold */
+ token = lsptok(NULL, &length); /* get varnoold */
+ local_node->varnoold = (Oid) atol(token);
+
+ token = lsptok(NULL, &length); /* eat :varoattno */
+ token = lsptok(NULL, &length); /* eat :varoattno */
+ local_node->varoattno = (int) atol(token);
+
+ return (local_node);
}
/* ----------------
@@ -746,40 +769,40 @@ _readVar()
* Array is a subclass of Expr
* ----------------
*/
-static Array *
+static Array *
_readArray()
{
- Array *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Array);
-
- token = lsptok(NULL, &length); /* eat :arrayelemtype */
- token = lsptok(NULL, &length); /* get arrayelemtype */
- local_node->arrayelemtype = (Oid) atoi(token);
-
- token = lsptok(NULL, &length); /* eat :arrayelemlength */
- token = lsptok(NULL, &length); /* get arrayelemlength */
- local_node->arrayelemlength = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :arrayelembyval */
- token = lsptok(NULL, &length); /* get arrayelembyval */
- local_node->arrayelembyval = (token[0] == 't') ? true : false;
-
- token = lsptok(NULL, &length); /* eat :arraylow */
- token = lsptok(NULL, &length); /* get arraylow */
- local_node->arraylow.indx[0] = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :arrayhigh */
- token = lsptok(NULL, &length); /* get arrayhigh */
- local_node->arrayhigh.indx[0] = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :arraylen */
- token = lsptok(NULL, &length); /* get arraylen */
- local_node->arraylen = atoi(token);
-
- return(local_node);
+ Array *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Array);
+
+ token = lsptok(NULL, &length); /* eat :arrayelemtype */
+ token = lsptok(NULL, &length); /* get arrayelemtype */
+ local_node->arrayelemtype = (Oid) atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :arrayelemlength */
+ token = lsptok(NULL, &length); /* get arrayelemlength */
+ local_node->arrayelemlength = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :arrayelembyval */
+ token = lsptok(NULL, &length); /* get arrayelembyval */
+ local_node->arrayelembyval = (token[0] == 't') ? true : false;
+
+ token = lsptok(NULL, &length); /* eat :arraylow */
+ token = lsptok(NULL, &length); /* get arraylow */
+ local_node->arraylow.indx[0] = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :arrayhigh */
+ token = lsptok(NULL, &length); /* get arrayhigh */
+ local_node->arrayhigh.indx[0] = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :arraylen */
+ token = lsptok(NULL, &length); /* get arraylen */
+ local_node->arraylen = atoi(token);
+
+ return (local_node);
}
/* ----------------
@@ -791,1031 +814,1052 @@ _readArray()
static ArrayRef *
_readArrayRef()
{
- ArrayRef *local_node;
- char *token;
- int length;
-
- local_node = makeNode(ArrayRef);
-
- token = lsptok(NULL, &length); /* eat :refelemtype */
- token = lsptok(NULL, &length); /* get refelemtype */
- local_node->refelemtype = (Oid) atoi(token);
-
- token = lsptok(NULL, &length); /* eat :refattrlength */
- token = lsptok(NULL, &length); /* get refattrlength */
- local_node->refattrlength = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :refelemlength */
- token = lsptok(NULL, &length); /* get refelemlength */
- local_node->refelemlength = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :refelembyval */
- token = lsptok(NULL, &length); /* get refelembyval */
- local_node->refelembyval = (token[0] == 't') ? true : false;
-
- token = lsptok(NULL, &length); /* eat :refupperindex */
- local_node->refupperindexpr = nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :reflowerindex */
- local_node->reflowerindexpr = nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :refexpr */
- local_node->refexpr = nodeRead(true);
-
- token = lsptok(NULL, &length); /* eat :refassgnexpr */
- local_node->refassgnexpr = nodeRead(true);
-
- return(local_node);
+ ArrayRef *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(ArrayRef);
+
+ token = lsptok(NULL, &length); /* eat :refelemtype */
+ token = lsptok(NULL, &length); /* get refelemtype */
+ local_node->refelemtype = (Oid) atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :refattrlength */
+ token = lsptok(NULL, &length); /* get refattrlength */
+ local_node->refattrlength = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :refelemlength */
+ token = lsptok(NULL, &length); /* get refelemlength */
+ local_node->refelemlength = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :refelembyval */
+ token = lsptok(NULL, &length); /* get refelembyval */
+ local_node->refelembyval = (token[0] == 't') ? true : false;
+
+ token = lsptok(NULL, &length); /* eat :refupperindex */
+ local_node->refupperindexpr = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :reflowerindex */
+ local_node->reflowerindexpr = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :refexpr */
+ local_node->refexpr = nodeRead(true);
+
+ token = lsptok(NULL, &length); /* eat :refassgnexpr */
+ local_node->refassgnexpr = nodeRead(true);
+
+ return (local_node);
}
/* ----------------
- * _readConst
- *
- * Const is a subclass of Expr
+ * _readConst
+ *
+ * Const is a subclass of Expr
* ----------------
*/
-static Const *
+static Const *
_readConst()
{
- Const *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Const);
-
- token = lsptok(NULL, &length); /* get :consttype */
- token = lsptok(NULL, &length); /* now read it */
- local_node->consttype = atol(token);
-
-
- token = lsptok(NULL, &length); /* get :constlen */
- token = lsptok(NULL, &length); /* now read it */
- local_node->constlen = atoi(token);
-
- token = lsptok(NULL, &length); /* get :constisnull */
- token = lsptok(NULL, &length); /* now read it */
-
- if (!strncmp(token, "true", 4)) {
- local_node->constisnull = true;
- }else {
- local_node->constisnull = false;
- }
-
-
- token = lsptok(NULL, &length); /* get :constvalue */
-
- if (local_node->constisnull) {
- token = lsptok(NULL, &length); /* skip "NIL" */
- }else {
- /*
- * read the value
- */
- local_node->constvalue = readDatum(local_node->consttype);
- }
-
- token = lsptok(NULL, &length); /* get :constbyval */
- token = lsptok(NULL, &length); /* now read it */
-
- if (!strncmp(token, "true", 4)) {
- local_node->constbyval = true;
- }else {
- local_node->constbyval = false;
- }
-
- return(local_node);
+ Const *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Const);
+
+ token = lsptok(NULL, &length); /* get :consttype */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->consttype = atol(token);
+
+
+ token = lsptok(NULL, &length); /* get :constlen */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->constlen = atoi(token);
+
+ token = lsptok(NULL, &length); /* get :constisnull */
+ token = lsptok(NULL, &length); /* now read it */
+
+ if (!strncmp(token, "true", 4))
+ {
+ local_node->constisnull = true;
+ }
+ else
+ {
+ local_node->constisnull = false;
+ }
+
+
+ token = lsptok(NULL, &length); /* get :constvalue */
+
+ if (local_node->constisnull)
+ {
+ token = lsptok(NULL, &length); /* skip "NIL" */
+ }
+ else
+ {
+
+ /*
+ * read the value
+ */
+ local_node->constvalue = readDatum(local_node->consttype);
+ }
+
+ token = lsptok(NULL, &length); /* get :constbyval */
+ token = lsptok(NULL, &length); /* now read it */
+
+ if (!strncmp(token, "true", 4))
+ {
+ local_node->constbyval = true;
+ }
+ else
+ {
+ local_node->constbyval = false;
+ }
+
+ return (local_node);
}
/* ----------------
- * _readFunc
- *
- * Func is a subclass of Expr
+ * _readFunc
+ *
+ * Func is a subclass of Expr
* ----------------
*/
-static Func *
+static Func *
_readFunc()
{
- Func *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Func);
-
- token = lsptok(NULL, &length); /* get :funcid */
- token = lsptok(NULL, &length); /* now read it */
- local_node->funcid = atol(token);
-
- token = lsptok(NULL, &length); /* get :functype */
- token = lsptok(NULL, &length); /* now read it */
- local_node->functype = atol(token);
-
- token = lsptok(NULL, &length); /* get :funcisindex */
- token = lsptok(NULL, &length); /* now read it */
-
- if (!strncmp(token, "true", 4)) {
- local_node->funcisindex = true;
- }else {
- local_node->funcisindex = false;
- }
-
- token = lsptok(NULL, &length); /* get :funcsize */
- token = lsptok(NULL, &length); /* now read it */
- local_node->funcsize = atol(token);
-
- token = lsptok(NULL, &length); /* get :func_fcache */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->func_fcache = (FunctionCache *) NULL;
-
- token = lsptok(NULL, &length); /* get :func_tlist */
- local_node->func_tlist = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :func_planlist */
- local_node->func_planlist = nodeRead(true); /* now read it */
-
- return(local_node);
+ Func *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Func);
+
+ token = lsptok(NULL, &length); /* get :funcid */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->funcid = atol(token);
+
+ token = lsptok(NULL, &length); /* get :functype */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->functype = atol(token);
+
+ token = lsptok(NULL, &length); /* get :funcisindex */
+ token = lsptok(NULL, &length); /* now read it */
+
+ if (!strncmp(token, "true", 4))
+ {
+ local_node->funcisindex = true;
+ }
+ else
+ {
+ local_node->funcisindex = false;
+ }
+
+ token = lsptok(NULL, &length); /* get :funcsize */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->funcsize = atol(token);
+
+ token = lsptok(NULL, &length); /* get :func_fcache */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->func_fcache = (FunctionCache *) NULL;
+
+ token = lsptok(NULL, &length); /* get :func_tlist */
+ local_node->func_tlist = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :func_planlist */
+ local_node->func_planlist = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readOper
- *
- * Oper is a subclass of Expr
+ * _readOper
+ *
+ * Oper is a subclass of Expr
* ----------------
*/
-static Oper *
+static Oper *
_readOper()
{
- Oper *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Oper);
-
- token = lsptok(NULL, &length); /* get :opno */
- token = lsptok(NULL, &length); /* now read it */
- local_node->opno = atol(token);
-
- token = lsptok(NULL, &length); /* get :opid */
- token = lsptok(NULL, &length); /* now read it */
- local_node->opid = atol(token);
-
- token = lsptok(NULL, &length); /* get :opresulttype */
- token = lsptok(NULL, &length); /* now read it */
- local_node->opresulttype = atol(token);
-
- /*
- * NOTE: Alternatively we can call 'replace_opid'
- * which initializes both 'opid' and 'op_fcache'.
- */
- local_node->op_fcache = (FunctionCache *) NULL;
-
- return(local_node);
+ Oper *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Oper);
+
+ token = lsptok(NULL, &length); /* get :opno */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->opno = atol(token);
+
+ token = lsptok(NULL, &length); /* get :opid */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->opid = atol(token);
+
+ token = lsptok(NULL, &length); /* get :opresulttype */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->opresulttype = atol(token);
+
+ /*
+ * NOTE: Alternatively we can call 'replace_opid' which initializes
+ * both 'opid' and 'op_fcache'.
+ */
+ local_node->op_fcache = (FunctionCache *) NULL;
+
+ return (local_node);
}
/* ----------------
- * _readParam
- *
- * Param is a subclass of Expr
+ * _readParam
+ *
+ * Param is a subclass of Expr
* ----------------
*/
-static Param *
+static Param *
_readParam()
{
- Param *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Param);
-
- token = lsptok(NULL, &length); /* get :paramkind */
- token = lsptok(NULL, &length); /* now read it */
- local_node->paramkind = atoi(token);
-
- token = lsptok(NULL, &length); /* get :paramid */
- token = lsptok(NULL, &length); /* now read it */
- local_node->paramid = atol(token);
-
- token = lsptok(NULL, &length); /* get :paramname */
- token = lsptok(NULL, &length); /* now read it */
- token++; /* skip the first `"' */
- token[length - 2] = '\0'; /* this is the 2nd `"' */
-
- local_node->paramname = pstrdup(token);
- token[length - 2] = '\"'; /* restore the 2nd `"' */
-
- token = lsptok(NULL, &length); /* get :paramtype */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->paramtype = atol(token);
- token = lsptok(NULL, &length); /* get :param_tlist */
- local_node->param_tlist = nodeRead(true); /* now read it */
-
- return(local_node);
+ Param *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Param);
+
+ token = lsptok(NULL, &length); /* get :paramkind */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->paramkind = atoi(token);
+
+ token = lsptok(NULL, &length); /* get :paramid */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->paramid = atol(token);
+
+ token = lsptok(NULL, &length); /* get :paramname */
+ token = lsptok(NULL, &length); /* now read it */
+ token++; /* skip the first `"' */
+ token[length - 2] = '\0'; /* this is the 2nd `"' */
+
+ local_node->paramname = pstrdup(token);
+ token[length - 2] = '\"'; /* restore the 2nd `"' */
+
+ token = lsptok(NULL, &length); /* get :paramtype */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->paramtype = atol(token);
+ token = lsptok(NULL, &length); /* get :param_tlist */
+ local_node->param_tlist = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readAggreg
- *
- * Aggreg is a subclass of Node
+ * _readAggreg
+ *
+ * Aggreg is a subclass of Node
* ----------------
*/
-static Aggreg *
+static Aggreg *
_readAggreg()
{
- Aggreg *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Aggreg);
-
- token = lsptok(NULL, &length); /* eat :aggname */
- token = lsptok(NULL, &length); /* get aggname */
- local_node->aggname = (char*) palloc (length + 1);
- strNcpy (local_node->aggname, token, length);
-
- token = lsptok(NULL, &length); /* eat :basetype */
- token = lsptok(NULL, &length); /* get basetype */
- local_node->basetype = (Oid)atol(token);
-
- token = lsptok(NULL, &length); /* eat :aggtype */
- token = lsptok(NULL, &length); /* get aggtype */
- local_node->aggtype = (Oid)atol(token);
-
- token = lsptok(NULL, &length); /* eat :aggno */
- token = lsptok(NULL, &length); /* get aggno */
- local_node->aggno = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :target */
- local_node->target = nodeRead(true); /* now read it */
-
- return(local_node);
+ Aggreg *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Aggreg);
+
+ token = lsptok(NULL, &length); /* eat :aggname */
+ token = lsptok(NULL, &length); /* get aggname */
+ local_node->aggname = (char *) palloc(length + 1);
+ strNcpy(local_node->aggname, token, length);
+
+ token = lsptok(NULL, &length); /* eat :basetype */
+ token = lsptok(NULL, &length); /* get basetype */
+ local_node->basetype = (Oid) atol(token);
+
+ token = lsptok(NULL, &length); /* eat :aggtype */
+ token = lsptok(NULL, &length); /* get aggtype */
+ local_node->aggtype = (Oid) atol(token);
+
+ token = lsptok(NULL, &length); /* eat :aggno */
+ token = lsptok(NULL, &length); /* get aggno */
+ local_node->aggno = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :target */
+ local_node->target = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/*
- * Stuff from execnodes.h
+ * Stuff from execnodes.h
*/
/* ----------------
- * _readEState
- *
- * EState is a subclass of Node.
+ * _readEState
+ *
+ * EState is a subclass of Node.
* ----------------
*/
-static EState *
+static EState *
_readEState()
{
- EState *local_node;
- char *token;
- int length;
-
- local_node = makeNode(EState);
-
- token = lsptok(NULL, &length); /* get :direction */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->es_direction = atoi(token);
-
- token = lsptok(NULL, &length); /* get :range_table */
-
- local_node->es_range_table = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :result_relation_info */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- sscanf(token, "%x",(unsigned int *)&local_node->es_result_relation_info);
-
- return(local_node);
+ EState *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(EState);
+
+ token = lsptok(NULL, &length); /* get :direction */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->es_direction = atoi(token);
+
+ token = lsptok(NULL, &length); /* get :range_table */
+
+ local_node->es_range_table = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :result_relation_info */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ sscanf(token, "%x", (unsigned int *) &local_node->es_result_relation_info);
+
+ return (local_node);
}
/*
- * Stuff from relation.h
+ * Stuff from relation.h
*/
/* ----------------
- * _readRel
+ * _readRel
* ----------------
*/
-static Rel *
+static Rel *
_readRel()
{
- Rel *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Rel);
-
- token = lsptok(NULL, &length); /* get :relids */
- local_node->relids =
- toIntList(nodeRead(true)); /* now read it */
-
- token = lsptok(NULL, &length); /* get :indexed */
- token = lsptok(NULL, &length); /* now read it */
-
- if (!strncmp(token, "true", 4))
- {
- local_node->indexed = true;
- }
- else
- {
- local_node->indexed = false;
- }
-
- token = lsptok(NULL, &length); /* get :pages */
- token = lsptok(NULL, &length); /* now read it */
- local_node->pages = (unsigned int) atoi(token);
-
- token = lsptok(NULL, &length); /* get :tuples */
- token = lsptok(NULL, &length); /* now read it */
- local_node->tuples = (unsigned int) atoi(token);
-
- token = lsptok(NULL, &length); /* get :size */
- token = lsptok(NULL, &length); /* now read it */
- local_node->size = (unsigned int) atoi(token);
-
- token = lsptok(NULL, &length); /* get :width */
- token = lsptok(NULL, &length); /* now read it */
- local_node->width = (unsigned int) atoi(token);
-
- token = lsptok(NULL, &length); /* get :targetlist */
- local_node->targetlist = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :pathlist */
- local_node->pathlist = nodeRead(true); /* now read it */
-
- /*
- * Not sure if these are nodes or not. They're declared as
- * struct Path *. Since i don't know, i'll just print the
- * addresses for now. This can be changed later, if necessary.
- */
-
- token = lsptok(NULL, &length); /* get :unorderpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- sscanf(token, "%x", (unsigned int *)&local_node->unorderedpath);
-
- token = lsptok(NULL, &length); /* get :cheapestpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- sscanf(token, "%x", (unsigned int *)&local_node->cheapestpath);
-
-
- token = lsptok(NULL, &length); /* get :clauseinfo */
- local_node->clauseinfo = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :joininfo */
- local_node->joininfo = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :innerjoin */
- local_node->innerjoin = nodeRead(true); /* now read it */
-
- return(local_node);
+ Rel *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Rel);
+
+ token = lsptok(NULL, &length); /* get :relids */
+ local_node->relids =
+ toIntList(nodeRead(true)); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :indexed */
+ token = lsptok(NULL, &length); /* now read it */
+
+ if (!strncmp(token, "true", 4))
+ {
+ local_node->indexed = true;
+ }
+ else
+ {
+ local_node->indexed = false;
+ }
+
+ token = lsptok(NULL, &length); /* get :pages */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->pages = (unsigned int) atoi(token);
+
+ token = lsptok(NULL, &length); /* get :tuples */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->tuples = (unsigned int) atoi(token);
+
+ token = lsptok(NULL, &length); /* get :size */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->size = (unsigned int) atoi(token);
+
+ token = lsptok(NULL, &length); /* get :width */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->width = (unsigned int) atoi(token);
+
+ token = lsptok(NULL, &length); /* get :targetlist */
+ local_node->targetlist = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :pathlist */
+ local_node->pathlist = nodeRead(true); /* now read it */
+
+ /*
+ * Not sure if these are nodes or not. They're declared as struct
+ * Path *. Since i don't know, i'll just print the addresses for now.
+ * This can be changed later, if necessary.
+ */
+
+ token = lsptok(NULL, &length); /* get :unorderpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ sscanf(token, "%x", (unsigned int *) &local_node->unorderedpath);
+
+ token = lsptok(NULL, &length); /* get :cheapestpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ sscanf(token, "%x", (unsigned int *) &local_node->cheapestpath);
+
+
+ token = lsptok(NULL, &length); /* get :clauseinfo */
+ local_node->clauseinfo = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :joininfo */
+ local_node->joininfo = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :innerjoin */
+ local_node->innerjoin = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readTargetEntry
+ * _readTargetEntry
* ----------------
*/
static TargetEntry *
_readTargetEntry()
{
- TargetEntry *local_node;
- char *token;
- int length;
+ TargetEntry *local_node;
+ char *token;
+ int length;
- local_node = makeNode(TargetEntry);
+ local_node = makeNode(TargetEntry);
- token = lsptok(NULL, &length); /* get :resdom */
- local_node->resdom = nodeRead(true); /* now read it */
+ token = lsptok(NULL, &length); /* get :resdom */
+ local_node->resdom = nodeRead(true); /* now read it */
- token = lsptok(NULL, &length); /* get :expr */
- local_node->expr = nodeRead(true); /* now read it */
+ token = lsptok(NULL, &length); /* get :expr */
+ local_node->expr = nodeRead(true); /* now read it */
- return (local_node);
+ return (local_node);
}
/* ----------------
- * _readTargetEntry
+ * _readTargetEntry
* ----------------
*/
static RangeTblEntry *
_readRangeTblEntry()
{
- RangeTblEntry *local_node;
- char *token;
- int length;
+ RangeTblEntry *local_node;
+ char *token;
+ int length;
- local_node = makeNode(RangeTblEntry);
+ local_node = makeNode(RangeTblEntry);
- token = lsptok(NULL, &length); /* eat :relname */
- token = lsptok(NULL, &length); /* get :relname */
- if (!strncmp(token, "\"null\"", 5)) {
- local_node->relname = NULL;
- }else {
- /*
- * Peel off ""'s, then make a true copy.
- */
-
- token++;
- token[length - 2] = '\0';
-
- local_node->relname = (char *) palloc(NAMEDATALEN);
- strcpy(local_node->relname, token);
- token[length - 2] = '\"';
- }
-
- token = lsptok(NULL, &length); /* eat :inh */
- token = lsptok(NULL, &length); /* get :inh */
- local_node->inh = atoi(token);
-
- token = lsptok(NULL, &length); /* eat :refname */
- token = lsptok(NULL, &length); /* get :refname */
- if (!strncmp(token, "\"null\"", 5)) {
- local_node->refname = NULL;
- }else {
- /*
- * Peel off ""'s, then make a true copy.
- */
-
- token++;
- token[length - 2] = '\0';
-
- local_node->refname = (char*)pstrdup(token);
- token[length - 2] = '\"';
- }
-
- token = lsptok(NULL, &length); /* eat :relid */
- token = lsptok(NULL, &length); /* get :relid */
- local_node->relid = atoi(token);
-
- return (local_node);
+ token = lsptok(NULL, &length); /* eat :relname */
+ token = lsptok(NULL, &length); /* get :relname */
+ if (!strncmp(token, "\"null\"", 5))
+ {
+ local_node->relname = NULL;
+ }
+ else
+ {
+
+ /*
+ * Peel off ""'s, then make a true copy.
+ */
+
+ token++;
+ token[length - 2] = '\0';
+
+ local_node->relname = (char *) palloc(NAMEDATALEN);
+ strcpy(local_node->relname, token);
+ token[length - 2] = '\"';
+ }
+
+ token = lsptok(NULL, &length); /* eat :inh */
+ token = lsptok(NULL, &length); /* get :inh */
+ local_node->inh = atoi(token);
+
+ token = lsptok(NULL, &length); /* eat :refname */
+ token = lsptok(NULL, &length); /* get :refname */
+ if (!strncmp(token, "\"null\"", 5))
+ {
+ local_node->refname = NULL;
+ }
+ else
+ {
+
+ /*
+ * Peel off ""'s, then make a true copy.
+ */
+
+ token++;
+ token[length - 2] = '\0';
+
+ local_node->refname = (char *) pstrdup(token);
+ token[length - 2] = '\"';
+ }
+
+ token = lsptok(NULL, &length); /* eat :relid */
+ token = lsptok(NULL, &length); /* get :relid */
+ local_node->relid = atoi(token);
+
+ return (local_node);
}
/* ----------------
- * _readPath
- *
- * Path is a subclass of Node.
+ * _readPath
+ *
+ * Path is a subclass of Node.
* ----------------
*/
-static Path *
+static Path *
_readPath()
{
- Path *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Path);
-
- token = lsptok(NULL, &length); /* get :pathtype */
- token = lsptok(NULL, &length); /* now read it */
- local_node->pathtype = atol(token);
-
- token = lsptok(NULL, &length); /* get :cost */
- token = lsptok(NULL, &length); /* now read it */
- local_node->path_cost = (Cost) atof(token);
-
+ Path *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Path);
+
+ token = lsptok(NULL, &length); /* get :pathtype */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->pathtype = atol(token);
+
+ token = lsptok(NULL, &length); /* get :cost */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->path_cost = (Cost) atof(token);
+
#if 0
- token = lsptok(NULL, &length); /* get :p_ordering */
- local_node->p_ordering =
- nodeRead(true); /* now read it */
+ token = lsptok(NULL, &length); /* get :p_ordering */
+ local_node->p_ordering =
+ nodeRead(true); /* now read it */
#endif
-
- token = lsptok(NULL, &length); /* get :keys */
- local_node->keys = nodeRead(true); /* now read it */
-
- return(local_node);
+
+ token = lsptok(NULL, &length); /* get :keys */
+ local_node->keys = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readIndexPath
- *
- * IndexPath is a subclass of Path.
+ * _readIndexPath
+ *
+ * IndexPath is a subclass of Path.
* ----------------
*/
static IndexPath *
_readIndexPath()
{
- IndexPath *local_node;
- char *token;
- int length;
-
- local_node = makeNode(IndexPath);
-
- token = lsptok(NULL, &length); /* get :pathtype */
- token = lsptok(NULL, &length); /* now read it */
- local_node->path.pathtype = atol(token);
-
- token = lsptok(NULL, &length); /* get :cost */
- token = lsptok(NULL, &length); /* now read it */
- local_node->path.path_cost = (Cost) atof(token);
-
+ IndexPath *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(IndexPath);
+
+ token = lsptok(NULL, &length); /* get :pathtype */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->path.pathtype = atol(token);
+
+ token = lsptok(NULL, &length); /* get :cost */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->path.path_cost = (Cost) atof(token);
+
#if 0
- token = lsptok(NULL, &length); /* get :p_ordering */
- local_node->path.p_ordering = nodeRead(true); /* now read it */
+ token = lsptok(NULL, &length); /* get :p_ordering */
+ local_node->path.p_ordering = nodeRead(true); /* now read it */
#endif
-
- token = lsptok(NULL, &length); /* get :keys */
- local_node->path.keys = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :indexid */
- local_node->indexid =
- toIntList(nodeRead(true));
-
- token = lsptok(NULL, &length); /* get :indexqual */
- local_node->indexqual = nodeRead(true); /* now read it */
-
- return(local_node);
+
+ token = lsptok(NULL, &length); /* get :keys */
+ local_node->path.keys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :indexid */
+ local_node->indexid =
+ toIntList(nodeRead(true));
+
+ token = lsptok(NULL, &length); /* get :indexqual */
+ local_node->indexqual = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readJoinPath
- *
- * JoinPath is a subclass of Path
+ * _readJoinPath
+ *
+ * JoinPath is a subclass of Path
* ----------------
*/
static JoinPath *
_readJoinPath()
{
- JoinPath *local_node;
- char *token;
- int length;
-
-
- local_node = makeNode(JoinPath);
-
- token = lsptok(NULL, &length); /* get :pathtype */
- token = lsptok(NULL, &length); /* now read it */
- local_node->path.pathtype = atol(token);
-
- token = lsptok(NULL, &length); /* get :cost */
- token = lsptok(NULL, &length); /* now read it */
- local_node->path.path_cost = (Cost) atof(token);
-
+ JoinPath *local_node;
+ char *token;
+ int length;
+
+
+ local_node = makeNode(JoinPath);
+
+ token = lsptok(NULL, &length); /* get :pathtype */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->path.pathtype = atol(token);
+
+ token = lsptok(NULL, &length); /* get :cost */
+ token = lsptok(NULL, &length); /* now read it */
+ local_node->path.path_cost = (Cost) atof(token);
+
#if 0
- token = lsptok(NULL, &length); /* get :p_ordering */
- local_node->path.p_ordering = nodeRead(true); /* now read it */
+ token = lsptok(NULL, &length); /* get :p_ordering */
+ local_node->path.p_ordering = nodeRead(true); /* now read it */
#endif
-
- token = lsptok(NULL, &length); /* get :keys */
- local_node->path.keys = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :pathclauseinfo */
- local_node->pathclauseinfo = nodeRead(true); /* now read it */
-
- /*
- * Not sure if these are nodes; they're declared as "struct path *".
- * For now, i'll just print the addresses.
- *
- * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
- * and initialize these pointers to NULL.
- */
-
- token = lsptok(NULL, &length); /* get :outerjoinpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->outerjoinpath = NULL;
-
- token = lsptok(NULL, &length); /* get :innerjoinpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->innerjoinpath = NULL;
-
- token = lsptok(NULL, &length); /* get :outerjoincost */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->path.outerjoincost = (Cost) atof(token);
-
- token = lsptok(NULL, &length); /* get :joinid */
- local_node->path.joinid =
- toIntList(nodeRead(true)); /* now read it */
-
- return(local_node);
+
+ token = lsptok(NULL, &length); /* get :keys */
+ local_node->path.keys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :pathclauseinfo */
+ local_node->pathclauseinfo = nodeRead(true); /* now read it */
+
+ /*
+ * Not sure if these are nodes; they're declared as "struct path *".
+ * For now, i'll just print the addresses.
+ *
+ * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
+ * and initialize these pointers to NULL.
+ */
+
+ token = lsptok(NULL, &length); /* get :outerjoinpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->outerjoinpath = NULL;
+
+ token = lsptok(NULL, &length); /* get :innerjoinpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->innerjoinpath = NULL;
+
+ token = lsptok(NULL, &length); /* get :outerjoincost */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->path.outerjoincost = (Cost) atof(token);
+
+ token = lsptok(NULL, &length); /* get :joinid */
+ local_node->path.joinid =
+ toIntList(nodeRead(true)); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readMergePath
- *
- * MergePath is a subclass of JoinPath.
+ * _readMergePath
+ *
+ * MergePath is a subclass of JoinPath.
* ----------------
*/
static MergePath *
_readMergePath()
{
- MergePath *local_node;
- char *token;
- int length;
-
- local_node = makeNode(MergePath);
-
- token = lsptok(NULL, &length); /* get :pathtype */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.path.pathtype = atol(token);
-
- token = lsptok(NULL, &length); /* get :cost */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.path.path_cost = (Cost) atof(token);
-
+ MergePath *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(MergePath);
+
+ token = lsptok(NULL, &length); /* get :pathtype */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.path.pathtype = atol(token);
+
+ token = lsptok(NULL, &length); /* get :cost */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.path.path_cost = (Cost) atof(token);
+
#if 0
- token = lsptok(NULL, &length); /* get :p_ordering */
- local_node->jpath.path.p_ordering = nodeRead(true); /* now read it */
+ token = lsptok(NULL, &length); /* get :p_ordering */
+ local_node->jpath.path.p_ordering = nodeRead(true); /* now read it */
#endif
-
- token = lsptok(NULL, &length); /* get :keys */
- local_node->jpath.path.keys = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :pathclauseinfo */
- local_node->jpath.pathclauseinfo = nodeRead(true); /* now read it */
-
- /*
- * Not sure if these are nodes; they're declared as "struct path *".
- * For now, i'll just print the addresses.
- *
- * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
- * and initialize these pointers to NULL.
- */
-
- token = lsptok(NULL, &length); /* get :outerjoinpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.outerjoinpath = NULL;
-
- token = lsptok(NULL, &length); /* get :innerjoinpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.innerjoinpath = NULL;
-
- token = lsptok(NULL, &length); /* get :outerjoincost */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.path.outerjoincost = (Cost) atof(token);
-
- token = lsptok(NULL, &length); /* get :joinid */
- local_node->jpath.path.joinid =
- toIntList(nodeRead(true)); /* now read it */
-
- token = lsptok(NULL, &length); /* get :path_mergeclauses */
- local_node->path_mergeclauses = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :outersortkeys */
- local_node->outersortkeys = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :innersortkeys */
- local_node->innersortkeys = nodeRead(true); /* now read it */
-
- return(local_node);
+
+ token = lsptok(NULL, &length); /* get :keys */
+ local_node->jpath.path.keys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :pathclauseinfo */
+ local_node->jpath.pathclauseinfo = nodeRead(true); /* now read it */
+
+ /*
+ * Not sure if these are nodes; they're declared as "struct path *".
+ * For now, i'll just print the addresses.
+ *
+ * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
+ * and initialize these pointers to NULL.
+ */
+
+ token = lsptok(NULL, &length); /* get :outerjoinpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.outerjoinpath = NULL;
+
+ token = lsptok(NULL, &length); /* get :innerjoinpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.innerjoinpath = NULL;
+
+ token = lsptok(NULL, &length); /* get :outerjoincost */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.path.outerjoincost = (Cost) atof(token);
+
+ token = lsptok(NULL, &length); /* get :joinid */
+ local_node->jpath.path.joinid =
+ toIntList(nodeRead(true)); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :path_mergeclauses */
+ local_node->path_mergeclauses = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :outersortkeys */
+ local_node->outersortkeys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :innersortkeys */
+ local_node->innersortkeys = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readHashPath
- *
- * HashPath is a subclass of JoinPath.
+ * _readHashPath
+ *
+ * HashPath is a subclass of JoinPath.
* ----------------
*/
static HashPath *
_readHashPath()
{
- HashPath *local_node;
- char *token;
- int length;
-
- local_node = makeNode(HashPath);
-
- token = lsptok(NULL, &length); /* get :pathtype */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.path.pathtype = atol(token);
-
- token = lsptok(NULL, &length); /* get :cost */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.path.path_cost = (Cost) atof(token);
-
+ HashPath *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(HashPath);
+
+ token = lsptok(NULL, &length); /* get :pathtype */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.path.pathtype = atol(token);
+
+ token = lsptok(NULL, &length); /* get :cost */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.path.path_cost = (Cost) atof(token);
+
#if 0
- token = lsptok(NULL, &length); /* get :p_ordering */
- local_node->jpath.path.p_ordering = nodeRead(true); /* now read it */
+ token = lsptok(NULL, &length); /* get :p_ordering */
+ local_node->jpath.path.p_ordering = nodeRead(true); /* now read it */
#endif
-
- token = lsptok(NULL, &length); /* get :keys */
- local_node->jpath.path.keys = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :pathclauseinfo */
- local_node->jpath.pathclauseinfo = nodeRead(true); /* now read it */
-
- /*
- * Not sure if these are nodes; they're declared as "struct path *".
- * For now, i'll just print the addresses.
- *
- * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
- * and initialize these pointers to NULL.
- */
-
- token = lsptok(NULL, &length); /* get :outerjoinpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.outerjoinpath = NULL;
-
- token = lsptok(NULL, &length); /* get :innerjoinpath */
- token = lsptok(NULL, &length); /* get @ */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.innerjoinpath = NULL;
-
- token = lsptok(NULL, &length); /* get :outerjoincost */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->jpath.path.outerjoincost = (Cost) atof(token);
-
- token = lsptok(NULL, &length); /* get :joinid */
- local_node->jpath.path.joinid =
- toIntList(nodeRead(true)); /* now read it */
-
- token = lsptok(NULL, &length); /* get :path_hashclauses */
- local_node->path_hashclauses = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :outerhashkeys */
- local_node->outerhashkeys = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :innerhashkeys */
- local_node->innerhashkeys = nodeRead(true); /* now read it */
-
- return(local_node);
+
+ token = lsptok(NULL, &length); /* get :keys */
+ local_node->jpath.path.keys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :pathclauseinfo */
+ local_node->jpath.pathclauseinfo = nodeRead(true); /* now read it */
+
+ /*
+ * Not sure if these are nodes; they're declared as "struct path *".
+ * For now, i'll just print the addresses.
+ *
+ * GJK: Since I am parsing this stuff, I'll just ignore the addresses,
+ * and initialize these pointers to NULL.
+ */
+
+ token = lsptok(NULL, &length); /* get :outerjoinpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.outerjoinpath = NULL;
+
+ token = lsptok(NULL, &length); /* get :innerjoinpath */
+ token = lsptok(NULL, &length); /* get @ */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.innerjoinpath = NULL;
+
+ token = lsptok(NULL, &length); /* get :outerjoincost */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->jpath.path.outerjoincost = (Cost) atof(token);
+
+ token = lsptok(NULL, &length); /* get :joinid */
+ local_node->jpath.path.joinid =
+ toIntList(nodeRead(true)); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :path_hashclauses */
+ local_node->path_hashclauses = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :outerhashkeys */
+ local_node->outerhashkeys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :innerhashkeys */
+ local_node->innerhashkeys = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readOrderKey
- *
- * OrderKey is a subclass of Node.
+ * _readOrderKey
+ *
+ * OrderKey is a subclass of Node.
* ----------------
*/
static OrderKey *
_readOrderKey()
{
- OrderKey *local_node;
- char *token;
- int length;
-
- local_node = makeNode(OrderKey);
-
- token = lsptok(NULL, &length); /* get :attribute_number */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->attribute_number = atoi(token);
-
- token = lsptok(NULL, &length); /* get :array_index */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->array_index = atoi(token);
-
- return(local_node);
+ OrderKey *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(OrderKey);
+
+ token = lsptok(NULL, &length); /* get :attribute_number */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->attribute_number = atoi(token);
+
+ token = lsptok(NULL, &length); /* get :array_index */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->array_index = atoi(token);
+
+ return (local_node);
}
/* ----------------
- * _readJoinKey
- *
- * JoinKey is a subclass of Node.
+ * _readJoinKey
+ *
+ * JoinKey is a subclass of Node.
* ----------------
*/
static JoinKey *
_readJoinKey()
{
- JoinKey *local_node;
- char *token;
- int length;
-
- local_node = makeNode(JoinKey);
-
- token = lsptok(NULL, &length); /* get :outer */
- local_node->outer = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :inner */
- local_node->inner = nodeRead(true); /* now read it */
-
- return(local_node);
+ JoinKey *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(JoinKey);
+
+ token = lsptok(NULL, &length); /* get :outer */
+ local_node->outer = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :inner */
+ local_node->inner = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readMergeOrder
- *
- * MergeOrder is a subclass of Node.
+ * _readMergeOrder
+ *
+ * MergeOrder is a subclass of Node.
* ----------------
*/
static MergeOrder *
_readMergeOrder()
{
- MergeOrder *local_node;
- char *token;
- int length;
-
- local_node = makeNode(MergeOrder);
- token = lsptok(NULL, &length); /* get :join_operator */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->join_operator = atol(token);
-
- token = lsptok(NULL, &length); /* get :left_operator */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->left_operator = atol(token);
-
- token = lsptok(NULL, &length); /* get :right_operator */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->right_operator = atol(token);
-
- token = lsptok(NULL, &length); /* get :left_type */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->left_type = atol(token);
-
- token = lsptok(NULL, &length); /* get :right_type */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->right_type = atol(token);
-
- return(local_node);
+ MergeOrder *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(MergeOrder);
+ token = lsptok(NULL, &length); /* get :join_operator */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->join_operator = atol(token);
+
+ token = lsptok(NULL, &length); /* get :left_operator */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->left_operator = atol(token);
+
+ token = lsptok(NULL, &length); /* get :right_operator */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->right_operator = atol(token);
+
+ token = lsptok(NULL, &length); /* get :left_type */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->left_type = atol(token);
+
+ token = lsptok(NULL, &length); /* get :right_type */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->right_type = atol(token);
+
+ return (local_node);
}
/* ----------------
- * _readCInfo
- *
- * CInfo is a subclass of Node.
+ * _readCInfo
+ *
+ * CInfo is a subclass of Node.
* ----------------
*/
-static CInfo *
+static CInfo *
_readCInfo()
{
- CInfo *local_node;
- char *token;
- int length;
-
- local_node = makeNode(CInfo);
-
- token = lsptok(NULL, &length); /* get :clause */
- local_node->clause = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :selectivity */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->selectivity = atof(token);
-
- token = lsptok(NULL, &length); /* get :notclause */
- token = lsptok(NULL, &length); /* now read it */
-
- if (!strncmp(token, "true", 4))
- {
- local_node->notclause = true;
- }
- else
- {
- local_node->notclause = false;
- }
-
- token = lsptok(NULL, &length); /* get :indexids */
- local_node->indexids = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :mergesortorder */
- local_node->mergesortorder = (MergeOrder*) nodeRead(true);
-
- token = lsptok(NULL, &length); /* get :hashjoinoperator */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->hashjoinoperator = atol(token);
-
- return(local_node);
+ CInfo *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(CInfo);
+
+ token = lsptok(NULL, &length); /* get :clause */
+ local_node->clause = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :selectivity */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->selectivity = atof(token);
+
+ token = lsptok(NULL, &length); /* get :notclause */
+ token = lsptok(NULL, &length); /* now read it */
+
+ if (!strncmp(token, "true", 4))
+ {
+ local_node->notclause = true;
+ }
+ else
+ {
+ local_node->notclause = false;
+ }
+
+ token = lsptok(NULL, &length); /* get :indexids */
+ local_node->indexids = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :mergesortorder */
+ local_node->mergesortorder = (MergeOrder *) nodeRead(true);
+
+ token = lsptok(NULL, &length); /* get :hashjoinoperator */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->hashjoinoperator = atol(token);
+
+ return (local_node);
}
/* ----------------
- * _readJoinMethod
- *
- * JoinMethod is a subclass of Node.
+ * _readJoinMethod
+ *
+ * JoinMethod is a subclass of Node.
* ----------------
*/
static JoinMethod *
_readJoinMethod()
{
- JoinMethod *local_node;
- char *token;
- int length;
-
- local_node = makeNode(JoinMethod);
-
- token = lsptok(NULL, &length); /* get :jmkeys */
- local_node->jmkeys = nodeRead(true);/* now read it */
-
- token = lsptok(NULL, &length); /* get :clauses */
- local_node->clauses = nodeRead(true); /* now read it */
-
- return(local_node);
+ JoinMethod *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(JoinMethod);
+
+ token = lsptok(NULL, &length); /* get :jmkeys */
+ local_node->jmkeys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :clauses */
+ local_node->clauses = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readHInfo
- *
+ * _readHInfo
+ *
* HInfo is a subclass of JoinMethod.
* ----------------
*/
-static HInfo *
+static HInfo *
_readHInfo()
{
- HInfo *local_node;
- char *token;
- int length;
-
- local_node = makeNode(HInfo);
-
- token = lsptok(NULL, &length); /* get :hashop */
- token = lsptok(NULL, &length); /* now read it */
-
- local_node->hashop = atoi(token);
-
- token = lsptok(NULL, &length); /* get :jmkeys */
- local_node->jmethod.jmkeys = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :clauses */
- local_node->jmethod.clauses = nodeRead(true); /* now read it */
-
- return(local_node);
+ HInfo *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(HInfo);
+
+ token = lsptok(NULL, &length); /* get :hashop */
+ token = lsptok(NULL, &length); /* now read it */
+
+ local_node->hashop = atoi(token);
+
+ token = lsptok(NULL, &length); /* get :jmkeys */
+ local_node->jmethod.jmkeys = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :clauses */
+ local_node->jmethod.clauses = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * _readJInfo()
- *
- * JInfo is a subclass of Node.
+ * _readJInfo()
+ *
+ * JInfo is a subclass of Node.
* ----------------
*/
-static JInfo *
+static JInfo *
_readJInfo()
{
- JInfo *local_node;
- char *token;
- int length;
-
- local_node = makeNode(JInfo);
-
- token = lsptok(NULL, &length); /* get :otherrels */
- local_node->otherrels =
- toIntList(nodeRead(true)); /* now read it */
-
- token = lsptok(NULL, &length); /* get :jinfoclauseinfo */
- local_node->jinfoclauseinfo = nodeRead(true); /* now read it */
-
- token = lsptok(NULL, &length); /* get :mergesortable */
-
- if (!strncmp(token, "true", 4))
- {
- local_node->mergesortable = true;
- }
- else
- {
- local_node->mergesortable = false;
- }
-
- token = lsptok(NULL, &length); /* get :hashjoinable */
-
- if (!strncmp(token, "true", 4))
- {
- local_node->hashjoinable = true;
- }
- else
- {
- local_node->hashjoinable = false;
- }
-
- return(local_node);
+ JInfo *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(JInfo);
+
+ token = lsptok(NULL, &length); /* get :otherrels */
+ local_node->otherrels =
+ toIntList(nodeRead(true)); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :jinfoclauseinfo */
+ local_node->jinfoclauseinfo = nodeRead(true); /* now read it */
+
+ token = lsptok(NULL, &length); /* get :mergesortable */
+
+ if (!strncmp(token, "true", 4))
+ {
+ local_node->mergesortable = true;
+ }
+ else
+ {
+ local_node->mergesortable = false;
+ }
+
+ token = lsptok(NULL, &length); /* get :hashjoinable */
+
+ if (!strncmp(token, "true", 4))
+ {
+ local_node->hashjoinable = true;
+ }
+ else
+ {
+ local_node->hashjoinable = false;
+ }
+
+ return (local_node);
}
/* ----------------
- * _readIter()
+ * _readIter()
*
* ----------------
*/
-static Iter *
+static Iter *
_readIter()
{
- Iter *local_node;
- char *token;
- int length;
-
- local_node = makeNode(Iter);
-
- token = lsptok(NULL, &length); /* eat :iterexpr */
- local_node->iterexpr = nodeRead(true); /* now read it */
-
- return(local_node);
+ Iter *local_node;
+ char *token;
+ int length;
+
+ local_node = makeNode(Iter);
+
+ token = lsptok(NULL, &length); /* eat :iterexpr */
+ local_node->iterexpr = nodeRead(true); /* now read it */
+
+ return (local_node);
}
/* ----------------
- * parsePlanString
+ * parsePlanString
*
* Given a character string containing a plan, parsePlanString sets up the
* plan structure representing that plan.
@@ -1823,164 +1867,263 @@ _readIter()
* The string passed to parsePlanString must be null-terminated.
* ----------------
*/
-Node *
+Node *
parsePlanString(void)
{
- char *token;
- int length;
- void *return_value = NULL;
-
- token = lsptok(NULL, &length);
-
- if (!strncmp(token, "PLAN", 4)) {
- return_value = _readPlan();
- }else if (!strncmp(token, "RESULT", 6)) {
- return_value = _readResult();
- }else if (!strncmp(token, "EXISTENTIAL", 11)) {
- return_value = _readExistential();
- }else if (!strncmp(token, "APPEND", 6)) {
- return_value = _readAppend();
- }else if (!strncmp(token, "JOIN", 4)) {
- return_value = _readJoin();
- }else if (!strncmp(token, "NESTLOOP", 8)) {
- return_value = _readNestLoop();
- }else if (!strncmp(token, "MERGEJOIN", 9)) {
- return_value = _readMergeJoin();
- }else if (!strncmp(token, "HASHJOIN", 8)) {
- return_value = _readHashJoin();
- }else if (!strncmp(token, "SCAN", 4)) {
- return_value = _readScan();
- }else if (!strncmp(token, "SEQSCAN", 7)) {
- return_value = _readSeqScan();
- }else if (!strncmp(token, "INDEXSCAN", 9)) {
- return_value = _readIndexScan();
- }else if (!strncmp(token, "TEMP", 4)) {
- return_value = _readTemp();
- }else if (!strncmp(token, "SORT", 4)) {
- return_value = _readSort();
- }else if (!strncmp(token, "AGGREG", 6)) {
- return_value = _readAggreg();
- }else if (!strncmp(token, "AGG", 3)) {
- return_value = _readAgg();
- }else if (!strncmp(token, "UNIQUE", 4)) {
- return_value = _readUnique();
- }else if (!strncmp(token, "HASH", 4)) {
- return_value = _readHash();
- }else if (!strncmp(token, "RESDOM", 6)) {
- return_value = _readResdom();
- }else if (!strncmp(token, "EXPR", 4)) {
- return_value = _readExpr();
- }else if (!strncmp(token, "ARRAYREF", 7)) {
- /* make sure this strncmp is done before that of ARRAY */
- return_value = _readArrayRef();
- }else if (!strncmp(token, "ARRAY", 5)) {
- return_value = _readArray();
- }else if (!strncmp(token, "VAR", 3)) {
- return_value = _readVar();
- }else if (!strncmp(token, "CONST", 5)) {
- return_value = _readConst();
- }else if (!strncmp(token, "FUNC", 4)) {
- return_value = _readFunc();
- }else if (!strncmp(token, "OPER", 4)) {
- return_value = _readOper();
- }else if (!strncmp(token, "PARAM", 5)) {
- return_value = _readParam();
- }else if (!strncmp(token, "ESTATE", 6)) {
- return_value = _readEState();
- }else if (!strncmp(token, "REL", 3)) {
- return_value = _readRel();
- }else if (!strncmp(token, "TLE", 3)) {
- return_value = _readTargetEntry();
- }else if (!strncmp(token, "RTE", 3)) {
- return_value = _readRangeTblEntry();
- }else if (!strncmp(token, "PATH", 4)) {
- return_value = _readPath();
- }else if (!strncmp(token, "INDEXPATH", 9)) {
- return_value = _readIndexPath();
- }else if (!strncmp(token, "JOINPATH", 8)) {
- return_value = _readJoinPath();
- }else if (!strncmp(token, "MERGEPATH", 9)) {
- return_value = _readMergePath();
- }else if (!strncmp(token, "HASHPATH", 8)) {
- return_value = _readHashPath();
- }else if (!strncmp(token, "ORDERKEY", 8)) {
- return_value = _readOrderKey();
- }else if (!strncmp(token, "JOINKEY", 7)) {
- return_value = _readJoinKey();
- }else if (!strncmp(token, "MERGEORDER", 10)) {
- return_value = _readMergeOrder();
- }else if (!strncmp(token, "CINFO", 5)) {
- return_value = _readCInfo();
- }else if (!strncmp(token, "JOINMETHOD", 10)) {
- return_value = _readJoinMethod();
- }else if (!strncmp(token, "JINFO", 5)) {
- return_value = _readJInfo();
- }else if (!strncmp(token, "HINFO", 5)) {
- return_value = _readHInfo();
- }else if (!strncmp(token, "ITER", 4)) {
- return_value = _readIter();
- }else if (!strncmp(token, "QUERY", 5)) {
- return_value = _readQuery();
- }else {
- elog(WARN, "badly formatted planstring \"%.10s\"...\n", token);
- }
-
- return ((Node*)return_value);
+ char *token;
+ int length;
+ void *return_value = NULL;
+
+ token = lsptok(NULL, &length);
+
+ if (!strncmp(token, "PLAN", 4))
+ {
+ return_value = _readPlan();
+ }
+ else if (!strncmp(token, "RESULT", 6))
+ {
+ return_value = _readResult();
+ }
+ else if (!strncmp(token, "EXISTENTIAL", 11))
+ {
+ return_value = _readExistential();
+ }
+ else if (!strncmp(token, "APPEND", 6))
+ {
+ return_value = _readAppend();
+ }
+ else if (!strncmp(token, "JOIN", 4))
+ {
+ return_value = _readJoin();
+ }
+ else if (!strncmp(token, "NESTLOOP", 8))
+ {
+ return_value = _readNestLoop();
+ }
+ else if (!strncmp(token, "MERGEJOIN", 9))
+ {
+ return_value = _readMergeJoin();
+ }
+ else if (!strncmp(token, "HASHJOIN", 8))
+ {
+ return_value = _readHashJoin();
+ }
+ else if (!strncmp(token, "SCAN", 4))
+ {
+ return_value = _readScan();
+ }
+ else if (!strncmp(token, "SEQSCAN", 7))
+ {
+ return_value = _readSeqScan();
+ }
+ else if (!strncmp(token, "INDEXSCAN", 9))
+ {
+ return_value = _readIndexScan();
+ }
+ else if (!strncmp(token, "TEMP", 4))
+ {
+ return_value = _readTemp();
+ }
+ else if (!strncmp(token, "SORT", 4))
+ {
+ return_value = _readSort();
+ }
+ else if (!strncmp(token, "AGGREG", 6))
+ {
+ return_value = _readAggreg();
+ }
+ else if (!strncmp(token, "AGG", 3))
+ {
+ return_value = _readAgg();
+ }
+ else if (!strncmp(token, "UNIQUE", 4))
+ {
+ return_value = _readUnique();
+ }
+ else if (!strncmp(token, "HASH", 4))
+ {
+ return_value = _readHash();
+ }
+ else if (!strncmp(token, "RESDOM", 6))
+ {
+ return_value = _readResdom();
+ }
+ else if (!strncmp(token, "EXPR", 4))
+ {
+ return_value = _readExpr();
+ }
+ else if (!strncmp(token, "ARRAYREF", 7))
+ {
+ /* make sure this strncmp is done before that of ARRAY */
+ return_value = _readArrayRef();
+ }
+ else if (!strncmp(token, "ARRAY", 5))
+ {
+ return_value = _readArray();
+ }
+ else if (!strncmp(token, "VAR", 3))
+ {
+ return_value = _readVar();
+ }
+ else if (!strncmp(token, "CONST", 5))
+ {
+ return_value = _readConst();
+ }
+ else if (!strncmp(token, "FUNC", 4))
+ {
+ return_value = _readFunc();
+ }
+ else if (!strncmp(token, "OPER", 4))
+ {
+ return_value = _readOper();
+ }
+ else if (!strncmp(token, "PARAM", 5))
+ {
+ return_value = _readParam();
+ }
+ else if (!strncmp(token, "ESTATE", 6))
+ {
+ return_value = _readEState();
+ }
+ else if (!strncmp(token, "REL", 3))
+ {
+ return_value = _readRel();
+ }
+ else if (!strncmp(token, "TLE", 3))
+ {
+ return_value = _readTargetEntry();
+ }
+ else if (!strncmp(token, "RTE", 3))
+ {
+ return_value = _readRangeTblEntry();
+ }
+ else if (!strncmp(token, "PATH", 4))
+ {
+ return_value = _readPath();
+ }
+ else if (!strncmp(token, "INDEXPATH", 9))
+ {
+ return_value = _readIndexPath();
+ }
+ else if (!strncmp(token, "JOINPATH", 8))
+ {
+ return_value = _readJoinPath();
+ }
+ else if (!strncmp(token, "MERGEPATH", 9))
+ {
+ return_value = _readMergePath();
+ }
+ else if (!strncmp(token, "HASHPATH", 8))
+ {
+ return_value = _readHashPath();
+ }
+ else if (!strncmp(token, "ORDERKEY", 8))
+ {
+ return_value = _readOrderKey();
+ }
+ else if (!strncmp(token, "JOINKEY", 7))
+ {
+ return_value = _readJoinKey();
+ }
+ else if (!strncmp(token, "MERGEORDER", 10))
+ {
+ return_value = _readMergeOrder();
+ }
+ else if (!strncmp(token, "CINFO", 5))
+ {
+ return_value = _readCInfo();
+ }
+ else if (!strncmp(token, "JOINMETHOD", 10))
+ {
+ return_value = _readJoinMethod();
+ }
+ else if (!strncmp(token, "JINFO", 5))
+ {
+ return_value = _readJInfo();
+ }
+ else if (!strncmp(token, "HINFO", 5))
+ {
+ return_value = _readHInfo();
+ }
+ else if (!strncmp(token, "ITER", 4))
+ {
+ return_value = _readIter();
+ }
+ else if (!strncmp(token, "QUERY", 5))
+ {
+ return_value = _readQuery();
+ }
+ else
+ {
+ elog(WARN, "badly formatted planstring \"%.10s\"...\n", token);
+ }
+
+ return ((Node *) return_value);
}
+
/*------------------------------------------------------------*/
/* ----------------
- * readDatum
+ * readDatum
*
* given a string representation of the value of the given type,
* create the appropriate Datum
* ----------------
*/
-static Datum
+static Datum
readDatum(Oid type)
{
- int length;
- int tokenLength;
- char *token;
- bool byValue;
- Datum res;
- char *s;
- int i;
-
- byValue = get_typbyval(type);
-
- /*
- * read the actual length of the value
- */
- token = lsptok(NULL, &tokenLength);
- length = atoi(token);
- token = lsptok(NULL, &tokenLength); /* skip the '[' */
-
- if (byValue) {
- if (length > sizeof(Datum)) {
- elog(WARN, "readValue: byval & length = %d", length);
- }
- s = (char *) (&res);
- for (i=0; i<sizeof(Datum); i++) {
- token = lsptok(NULL, &tokenLength);
- s[i] = (char) atoi(token);
- }
- } else if (length <= 0) {
- s = NULL;
- } else if (length >= 1) {
- s = (char*)palloc(length);
- Assert( s!=NULL );
- for (i=0; i<length; i++) {
- token = lsptok(NULL, &tokenLength);
- s[i] = (char) atoi(token);
- }
- res = PointerGetDatum(s);
- }
-
- token = lsptok(NULL, &tokenLength); /* skip the ']' */
- if (token[0] != ']') {
- elog(WARN, "readValue: ']' expected, length =%d", length);
- }
-
- return(res);
+ int length;
+ int tokenLength;
+ char *token;
+ bool byValue;
+ Datum res;
+ char *s;
+ int i;
+
+ byValue = get_typbyval(type);
+
+ /*
+ * read the actual length of the value
+ */
+ token = lsptok(NULL, &tokenLength);
+ length = atoi(token);
+ token = lsptok(NULL, &tokenLength); /* skip the '[' */
+
+ if (byValue)
+ {
+ if (length > sizeof(Datum))
+ {
+ elog(WARN, "readValue: byval & length = %d", length);
+ }
+ s = (char *) (&res);
+ for (i = 0; i < sizeof(Datum); i++)
+ {
+ token = lsptok(NULL, &tokenLength);
+ s[i] = (char) atoi(token);
+ }
+ }
+ else if (length <= 0)
+ {
+ s = NULL;
+ }
+ else if (length >= 1)
+ {
+ s = (char *) palloc(length);
+ Assert(s != NULL);
+ for (i = 0; i < length; i++)
+ {
+ token = lsptok(NULL, &tokenLength);
+ s[i] = (char) atoi(token);
+ }
+ res = PointerGetDatum(s);
+ }
+
+ token = lsptok(NULL, &tokenLength); /* skip the ']' */
+ if (token[0] != ']')
+ {
+ elog(WARN, "readValue: ']' expected, length =%d", length);
+ }
+
+ return (res);
}