Commit 2eafcf68 authored by Tom Lane's avatar Tom Lane

Restructure the code in copyfuncs and equalfuncs to put much heavier

reliance on macros, in hopes of eliminating silly typos (like copying
to the wrong field) and just generally making it easier to see the forest
instead of the trees.  As an example, here is the new code for A_Indices:

static A_Indices *
_copyAIndices(A_Indices *from)
{
	A_Indices  *newnode = makeNode(A_Indices);

	COPY_NODE_FIELD(lidx);
	COPY_NODE_FIELD(uidx);

	return newnode;
}

static bool
_equalAIndices(A_Indices *a, A_Indices *b)
{
	COMPARE_NODE_FIELD(lidx);
	COMPARE_NODE_FIELD(uidx);

	return true;
}

I plan to redo outfuncs/readfuncs in a similar style, but am committing
what I've got.
parent 200dd8e3
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.221 2002/11/24 21:52:13 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.222 2002/11/25 03:33:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -28,11 +28,44 @@ ...@@ -28,11 +28,44 @@
/* /*
* Node_Copy * Macros to simplify copying of different kinds of fields. Use these
* a macro to simplify calling of copyObject on the specified field * wherever possible to reduce the chance for silly typos. Note that these
* hard-wire the convention that the local variables in a Copy routine are
* named 'newnode' and 'from'.
*/ */
#define Node_Copy(from, newnode, field) \
((newnode)->field = copyObject((from)->field)) /* Copy a simple scalar field (int, float, bool, enum, etc) */
#define COPY_SCALAR_FIELD(fldname) \
(newnode->fldname = from->fldname)
/* Copy a field that is a pointer to some kind of Node or Node tree */
#define COPY_NODE_FIELD(fldname) \
(newnode->fldname = copyObject(from->fldname))
/* Copy a field that is a pointer to a list of integers */
#define COPY_INTLIST_FIELD(fldname) \
(newnode->fldname = listCopy(from->fldname))
/* Copy a field that is a pointer to a C string, or perhaps NULL */
#define COPY_STRING_FIELD(fldname) \
(newnode->fldname = from->fldname ? pstrdup(from->fldname) : (char *) NULL)
/* Copy a field that is a pointer to a simple palloc'd object of size sz */
#define COPY_POINTER_FIELD(fldname, sz) \
do { \
Size _size = (sz); \
newnode->fldname = palloc(_size); \
memcpy(newnode->fldname, from->fldname, _size); \
} while (0)
/* Special hack for fixing subplan lists of Plan nodes (ick) */
#define FIX_SUBPLAN_LINKS(subplanfldname, fldname) \
do { \
if (from->subplanfldname != NIL) \
newnode->subplanfldname = \
nconc(newnode->subplanfldname, \
pull_subplans((Node *) (newnode->fldname))); \
} while (0)
/* /*
...@@ -73,41 +106,37 @@ listCopy(List *list) ...@@ -73,41 +106,37 @@ listCopy(List *list)
* **************************************************************** * ****************************************************************
*/ */
/* ---------------- /*
* CopyPlanFields * CopyPlanFields
* *
* This function copies the fields of the Plan node. It is used by * This function copies the fields of the Plan node. It is used by
* all the copy functions for classes which inherit from Plan. * all the copy functions for classes which inherit from Plan.
* ----------------
*/ */
static void static void
CopyPlanFields(Plan *from, Plan *newnode) CopyPlanFields(Plan *from, Plan *newnode)
{ {
newnode->startup_cost = from->startup_cost; COPY_SCALAR_FIELD(startup_cost);
newnode->total_cost = from->total_cost; COPY_SCALAR_FIELD(total_cost);
newnode->plan_rows = from->plan_rows; COPY_SCALAR_FIELD(plan_rows);
newnode->plan_width = from->plan_width; COPY_SCALAR_FIELD(plan_width);
/* state is NOT copied */ /* execution state is NOT copied */
Node_Copy(from, newnode, targetlist); COPY_NODE_FIELD(targetlist);
Node_Copy(from, newnode, qual); COPY_NODE_FIELD(qual);
Node_Copy(from, newnode, lefttree); COPY_NODE_FIELD(lefttree);
Node_Copy(from, newnode, righttree); COPY_NODE_FIELD(righttree);
newnode->extParam = listCopy(from->extParam); COPY_INTLIST_FIELD(extParam);
newnode->locParam = listCopy(from->locParam); COPY_INTLIST_FIELD(locParam);
newnode->chgParam = listCopy(from->chgParam); COPY_INTLIST_FIELD(chgParam);
Node_Copy(from, newnode, initPlan); COPY_NODE_FIELD(initPlan);
/* subPlan list must point to subplans in the new subtree, not the old */ /* subPlan list must point to subplans in the new subtree, not the old */
if (from->subPlan != NIL) newnode->subPlan = NIL;
newnode->subPlan = nconc(pull_subplans((Node *) newnode->targetlist), FIX_SUBPLAN_LINKS(subPlan, targetlist);
pull_subplans((Node *) newnode->qual)); FIX_SUBPLAN_LINKS(subPlan, qual);
else COPY_SCALAR_FIELD(nParamExec);
newnode->subPlan = NIL;
newnode->nParamExec = from->nParamExec;
} }
/* ---------------- /*
* _copyPlan * _copyPlan
* ----------------
*/ */
static Plan * static Plan *
_copyPlan(Plan *from) _copyPlan(Plan *from)
...@@ -115,7 +144,7 @@ _copyPlan(Plan *from) ...@@ -115,7 +144,7 @@ _copyPlan(Plan *from)
Plan *newnode = makeNode(Plan); Plan *newnode = makeNode(Plan);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPlanFields(from, newnode); CopyPlanFields(from, newnode);
...@@ -123,9 +152,8 @@ _copyPlan(Plan *from) ...@@ -123,9 +152,8 @@ _copyPlan(Plan *from)
} }
/* ---------------- /*
* _copyResult * _copyResult
* ----------------
*/ */
static Result * static Result *
_copyResult(Result *from) _copyResult(Result *from)
...@@ -140,22 +168,16 @@ _copyResult(Result *from) ...@@ -140,22 +168,16 @@ _copyResult(Result *from)
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, resconstantqual); COPY_NODE_FIELD(resconstantqual);
/* /* subPlan list must point to subplans in the new subtree, not the old */
* We must add subplans in resconstantqual to the new plan's subPlan FIX_SUBPLAN_LINKS(plan.subPlan, resconstantqual);
* list
*/
if (from->plan.subPlan != NIL)
newnode->plan.subPlan = nconc(newnode->plan.subPlan,
pull_subplans(newnode->resconstantqual));
return newnode; return newnode;
} }
/* ---------------- /*
* _copyAppend * _copyAppend
* ----------------
*/ */
static Append * static Append *
_copyAppend(Append *from) _copyAppend(Append *from)
...@@ -170,30 +192,29 @@ _copyAppend(Append *from) ...@@ -170,30 +192,29 @@ _copyAppend(Append *from)
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, appendplans); COPY_NODE_FIELD(appendplans);
newnode->isTarget = from->isTarget; COPY_SCALAR_FIELD(isTarget);
return newnode; return newnode;
} }
/* ---------------- /*
* CopyScanFields * CopyScanFields
* *
* This function copies the fields of the Scan node. It is used by * This function copies the fields of the Scan node. It is used by
* all the copy functions for classes which inherit from Scan. * all the copy functions for classes which inherit from Scan.
* ----------------
*/ */
static void static void
CopyScanFields(Scan *from, Scan *newnode) CopyScanFields(Scan *from, Scan *newnode)
{ {
newnode->scanrelid = from->scanrelid; CopyPlanFields((Plan *) from, (Plan *) newnode);
return;
COPY_SCALAR_FIELD(scanrelid);
} }
/* ---------------- /*
* _copyScan * _copyScan
* ----------------
*/ */
static Scan * static Scan *
_copyScan(Scan *from) _copyScan(Scan *from)
...@@ -203,15 +224,13 @@ _copyScan(Scan *from) ...@@ -203,15 +224,13 @@ _copyScan(Scan *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyScanFields((Scan *) from, (Scan *) newnode); CopyScanFields((Scan *) from, (Scan *) newnode);
return newnode; return newnode;
} }
/* ---------------- /*
* _copySeqScan * _copySeqScan
* ----------------
*/ */
static SeqScan * static SeqScan *
_copySeqScan(SeqScan *from) _copySeqScan(SeqScan *from)
...@@ -221,15 +240,13 @@ _copySeqScan(SeqScan *from) ...@@ -221,15 +240,13 @@ _copySeqScan(SeqScan *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyScanFields((Scan *) from, (Scan *) newnode); CopyScanFields((Scan *) from, (Scan *) newnode);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyIndexScan * _copyIndexScan
* ----------------
*/ */
static IndexScan * static IndexScan *
_copyIndexScan(IndexScan *from) _copyIndexScan(IndexScan *from)
...@@ -239,34 +256,25 @@ _copyIndexScan(IndexScan *from) ...@@ -239,34 +256,25 @@ _copyIndexScan(IndexScan *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyScanFields((Scan *) from, (Scan *) newnode); CopyScanFields((Scan *) from, (Scan *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
newnode->indxid = listCopy(from->indxid); COPY_INTLIST_FIELD(indxid);
Node_Copy(from, newnode, indxqual); COPY_NODE_FIELD(indxqual);
Node_Copy(from, newnode, indxqualorig); COPY_NODE_FIELD(indxqualorig);
newnode->indxorderdir = from->indxorderdir; COPY_SCALAR_FIELD(indxorderdir);
/* /* subPlan list must point to subplans in the new subtree, not the old */
* We must add subplans in index quals to the new plan's subPlan list FIX_SUBPLAN_LINKS(scan.plan.subPlan, indxqual);
*/ FIX_SUBPLAN_LINKS(scan.plan.subPlan, indxqualorig);
if (from->scan.plan.subPlan != NIL)
{
newnode->scan.plan.subPlan = nconc(newnode->scan.plan.subPlan,
pull_subplans((Node *) newnode->indxqual));
newnode->scan.plan.subPlan = nconc(newnode->scan.plan.subPlan,
pull_subplans((Node *) newnode->indxqualorig));
}
return newnode; return newnode;
} }
/* ---------------- /*
* _copyTidScan * _copyTidScan
* ----------------
*/ */
static TidScan * static TidScan *
_copyTidScan(TidScan *from) _copyTidScan(TidScan *from)
...@@ -276,21 +284,22 @@ _copyTidScan(TidScan *from) ...@@ -276,21 +284,22 @@ _copyTidScan(TidScan *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyScanFields((Scan *) from, (Scan *) newnode); CopyScanFields((Scan *) from, (Scan *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
newnode->needRescan = from->needRescan; COPY_SCALAR_FIELD(needRescan);
Node_Copy(from, newnode, tideval); COPY_NODE_FIELD(tideval);
/* subPlan list must point to subplans in the new subtree, not the old */
FIX_SUBPLAN_LINKS(scan.plan.subPlan, tideval);
return newnode; return newnode;
} }
/* ---------------- /*
* _copySubqueryScan * _copySubqueryScan
* ----------------
*/ */
static SubqueryScan * static SubqueryScan *
_copySubqueryScan(SubqueryScan *from) _copySubqueryScan(SubqueryScan *from)
...@@ -300,20 +309,18 @@ _copySubqueryScan(SubqueryScan *from) ...@@ -300,20 +309,18 @@ _copySubqueryScan(SubqueryScan *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyScanFields((Scan *) from, (Scan *) newnode); CopyScanFields((Scan *) from, (Scan *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, subplan); COPY_NODE_FIELD(subplan);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyFunctionScan * _copyFunctionScan
* ----------------
*/ */
static FunctionScan * static FunctionScan *
_copyFunctionScan(FunctionScan *from) _copyFunctionScan(FunctionScan *from)
...@@ -323,34 +330,32 @@ _copyFunctionScan(FunctionScan *from) ...@@ -323,34 +330,32 @@ _copyFunctionScan(FunctionScan *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyScanFields((Scan *) from, (Scan *) newnode); CopyScanFields((Scan *) from, (Scan *) newnode);
return newnode; return newnode;
} }
/* ---------------- /*
* CopyJoinFields * CopyJoinFields
* *
* This function copies the fields of the Join node. It is used by * This function copies the fields of the Join node. It is used by
* all the copy functions for classes which inherit from Join. * all the copy functions for classes which inherit from Join.
* ----------------
*/ */
static void static void
CopyJoinFields(Join *from, Join *newnode) CopyJoinFields(Join *from, Join *newnode)
{ {
newnode->jointype = from->jointype; CopyPlanFields((Plan *) from, (Plan *) newnode);
Node_Copy(from, newnode, joinqual);
COPY_SCALAR_FIELD(jointype);
COPY_NODE_FIELD(joinqual);
/* subPlan list must point to subplans in the new subtree, not the old */ /* subPlan list must point to subplans in the new subtree, not the old */
if (from->plan.subPlan != NIL) FIX_SUBPLAN_LINKS(plan.subPlan, joinqual);
newnode->plan.subPlan = nconc(newnode->plan.subPlan,
pull_subplans((Node *) newnode->joinqual));
} }
/* ---------------- /*
* _copyJoin * _copyJoin
* ----------------
*/ */
static Join * static Join *
_copyJoin(Join *from) _copyJoin(Join *from)
...@@ -360,16 +365,14 @@ _copyJoin(Join *from) ...@@ -360,16 +365,14 @@ _copyJoin(Join *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyJoinFields(from, newnode); CopyJoinFields(from, newnode);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyNestLoop * _copyNestLoop
* ----------------
*/ */
static NestLoop * static NestLoop *
_copyNestLoop(NestLoop *from) _copyNestLoop(NestLoop *from)
...@@ -379,16 +382,14 @@ _copyNestLoop(NestLoop *from) ...@@ -379,16 +382,14 @@ _copyNestLoop(NestLoop *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyJoinFields((Join *) from, (Join *) newnode); CopyJoinFields((Join *) from, (Join *) newnode);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyMergeJoin * _copyMergeJoin
* ----------------
*/ */
static MergeJoin * static MergeJoin *
_copyMergeJoin(MergeJoin *from) _copyMergeJoin(MergeJoin *from)
...@@ -398,27 +399,21 @@ _copyMergeJoin(MergeJoin *from) ...@@ -398,27 +399,21 @@ _copyMergeJoin(MergeJoin *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyJoinFields((Join *) from, (Join *) newnode); CopyJoinFields((Join *) from, (Join *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, mergeclauses); COPY_NODE_FIELD(mergeclauses);
/* /* subPlan list must point to subplans in the new subtree, not the old */
* We must add subplans in mergeclauses to the new plan's subPlan list FIX_SUBPLAN_LINKS(join.plan.subPlan, mergeclauses);
*/
if (from->join.plan.subPlan != NIL)
newnode->join.plan.subPlan = nconc(newnode->join.plan.subPlan,
pull_subplans((Node *) newnode->mergeclauses));
return newnode; return newnode;
} }
/* ---------------- /*
* _copyHashJoin * _copyHashJoin
* ----------------
*/ */
static HashJoin * static HashJoin *
_copyHashJoin(HashJoin *from) _copyHashJoin(HashJoin *from)
...@@ -428,29 +423,23 @@ _copyHashJoin(HashJoin *from) ...@@ -428,29 +423,23 @@ _copyHashJoin(HashJoin *from)
/* /*
* copy node superclass fields * copy node superclass fields
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode);
CopyJoinFields((Join *) from, (Join *) newnode); CopyJoinFields((Join *) from, (Join *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, hashclauses); COPY_NODE_FIELD(hashclauses);
newnode->hashjoinop = from->hashjoinop; COPY_SCALAR_FIELD(hashjoinop);
/* /* subPlan list must point to subplans in the new subtree, not the old */
* We must add subplans in hashclauses to the new plan's subPlan list FIX_SUBPLAN_LINKS(join.plan.subPlan, hashclauses);
*/
if (from->join.plan.subPlan != NIL)
newnode->join.plan.subPlan = nconc(newnode->join.plan.subPlan,
pull_subplans((Node *) newnode->hashclauses));
return newnode; return newnode;
} }
/* ---------------- /*
* _copyMaterial * _copyMaterial
* ----------------
*/ */
static Material * static Material *
_copyMaterial(Material *from) _copyMaterial(Material *from)
...@@ -466,9 +455,8 @@ _copyMaterial(Material *from) ...@@ -466,9 +455,8 @@ _copyMaterial(Material *from)
} }
/* ---------------- /*
* _copySort * _copySort
* ----------------
*/ */
static Sort * static Sort *
_copySort(Sort *from) _copySort(Sort *from)
...@@ -480,15 +468,14 @@ _copySort(Sort *from) ...@@ -480,15 +468,14 @@ _copySort(Sort *from)
*/ */
CopyPlanFields((Plan *) from, (Plan *) newnode); CopyPlanFields((Plan *) from, (Plan *) newnode);
newnode->keycount = from->keycount; COPY_SCALAR_FIELD(keycount);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyGroup * _copyGroup
* ----------------
*/ */
static Group * static Group *
_copyGroup(Group *from) _copyGroup(Group *from)
...@@ -497,17 +484,14 @@ _copyGroup(Group *from) ...@@ -497,17 +484,14 @@ _copyGroup(Group *from)
CopyPlanFields((Plan *) from, (Plan *) newnode); CopyPlanFields((Plan *) from, (Plan *) newnode);
newnode->numCols = from->numCols; COPY_SCALAR_FIELD(numCols);
newnode->grpColIdx = palloc(from->numCols * sizeof(AttrNumber)); COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
memcpy(newnode->grpColIdx, from->grpColIdx,
from->numCols * sizeof(AttrNumber));
return newnode; return newnode;
} }
/* --------------- /*
* _copyAgg * _copyAgg
* --------------
*/ */
static Agg * static Agg *
_copyAgg(Agg *from) _copyAgg(Agg *from)
...@@ -516,37 +500,17 @@ _copyAgg(Agg *from) ...@@ -516,37 +500,17 @@ _copyAgg(Agg *from)
CopyPlanFields((Plan *) from, (Plan *) newnode); CopyPlanFields((Plan *) from, (Plan *) newnode);
newnode->aggstrategy = from->aggstrategy; COPY_SCALAR_FIELD(aggstrategy);
newnode->numCols = from->numCols; COPY_SCALAR_FIELD(numCols);
if (from->numCols > 0) if (from->numCols > 0)
{ COPY_POINTER_FIELD(grpColIdx, from->numCols * sizeof(AttrNumber));
newnode->grpColIdx = palloc(from->numCols * sizeof(AttrNumber)); COPY_SCALAR_FIELD(numGroups);
memcpy(newnode->grpColIdx, from->grpColIdx,
from->numCols * sizeof(AttrNumber));
}
newnode->numGroups = from->numGroups;
return newnode;
}
/* ---------------
* _copyGroupClause
* --------------
*/
static GroupClause *
_copyGroupClause(GroupClause *from)
{
GroupClause *newnode = makeNode(GroupClause);
newnode->tleSortGroupRef = from->tleSortGroupRef;
newnode->sortop = from->sortop;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyUnique * _copyUnique
* ----------------
*/ */
static Unique * static Unique *
_copyUnique(Unique *from) _copyUnique(Unique *from)
...@@ -561,16 +525,14 @@ _copyUnique(Unique *from) ...@@ -561,16 +525,14 @@ _copyUnique(Unique *from)
/* /*
* copy remainder of node * copy remainder of node
*/ */
newnode->numCols = from->numCols; COPY_SCALAR_FIELD(numCols);
newnode->uniqColIdx = palloc(from->numCols * sizeof(AttrNumber)); COPY_POINTER_FIELD(uniqColIdx, from->numCols * sizeof(AttrNumber));
memcpy(newnode->uniqColIdx, from->uniqColIdx, from->numCols * sizeof(AttrNumber));
return newnode; return newnode;
} }
/* ---------------- /*
* _copySetOp * _copySetOp
* ----------------
*/ */
static SetOp * static SetOp *
_copySetOp(SetOp *from) _copySetOp(SetOp *from)
...@@ -585,18 +547,16 @@ _copySetOp(SetOp *from) ...@@ -585,18 +547,16 @@ _copySetOp(SetOp *from)
/* /*
* copy remainder of node * copy remainder of node
*/ */
newnode->cmd = from->cmd; COPY_SCALAR_FIELD(cmd);
newnode->numCols = from->numCols; COPY_SCALAR_FIELD(numCols);
newnode->dupColIdx = palloc(from->numCols * sizeof(AttrNumber)); COPY_POINTER_FIELD(dupColIdx, from->numCols * sizeof(AttrNumber));
memcpy(newnode->dupColIdx, from->dupColIdx, from->numCols * sizeof(AttrNumber)); COPY_SCALAR_FIELD(flagColIdx);
newnode->flagColIdx = from->flagColIdx;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyLimit * _copyLimit
* ----------------
*/ */
static Limit * static Limit *
_copyLimit(Limit *from) _copyLimit(Limit *from)
...@@ -611,15 +571,14 @@ _copyLimit(Limit *from) ...@@ -611,15 +571,14 @@ _copyLimit(Limit *from)
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, limitOffset); COPY_NODE_FIELD(limitOffset);
Node_Copy(from, newnode, limitCount); COPY_NODE_FIELD(limitCount);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyHash * _copyHash
* ----------------
*/ */
static Hash * static Hash *
_copyHash(Hash *from) _copyHash(Hash *from)
...@@ -634,7 +593,9 @@ _copyHash(Hash *from) ...@@ -634,7 +593,9 @@ _copyHash(Hash *from)
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, hashkey); COPY_NODE_FIELD(hashkey);
/* XXX could the hashkey contain subplans? Not at present... */
return newnode; return newnode;
} }
...@@ -644,12 +605,12 @@ _copySubPlan(SubPlan *from) ...@@ -644,12 +605,12 @@ _copySubPlan(SubPlan *from)
{ {
SubPlan *newnode = makeNode(SubPlan); SubPlan *newnode = makeNode(SubPlan);
Node_Copy(from, newnode, plan); COPY_NODE_FIELD(plan);
newnode->plan_id = from->plan_id; COPY_SCALAR_FIELD(plan_id);
Node_Copy(from, newnode, rtable); COPY_NODE_FIELD(rtable);
newnode->setParam = listCopy(from->setParam); COPY_INTLIST_FIELD(setParam);
newnode->parParam = listCopy(from->parParam); COPY_INTLIST_FIELD(parParam);
Node_Copy(from, newnode, sublink); COPY_NODE_FIELD(sublink);
/* do not copy execution state */ /* do not copy execution state */
newnode->needShutdown = false; newnode->needShutdown = false;
...@@ -663,24 +624,22 @@ _copySubPlan(SubPlan *from) ...@@ -663,24 +624,22 @@ _copySubPlan(SubPlan *from)
* **************************************************************** * ****************************************************************
*/ */
/* ---------------- /*
* _copyResdom * _copyResdom
* ----------------
*/ */
static Resdom * static Resdom *
_copyResdom(Resdom *from) _copyResdom(Resdom *from)
{ {
Resdom *newnode = makeNode(Resdom); Resdom *newnode = makeNode(Resdom);
newnode->resno = from->resno; COPY_SCALAR_FIELD(resno);
newnode->restype = from->restype; COPY_SCALAR_FIELD(restype);
newnode->restypmod = from->restypmod; COPY_SCALAR_FIELD(restypmod);
if (from->resname != NULL) COPY_STRING_FIELD(resname);
newnode->resname = pstrdup(from->resname); COPY_SCALAR_FIELD(ressortgroupref);
newnode->ressortgroupref = from->ressortgroupref; COPY_SCALAR_FIELD(reskey);
newnode->reskey = from->reskey; COPY_SCALAR_FIELD(reskeyop);
newnode->reskeyop = from->reskeyop; COPY_SCALAR_FIELD(resjunk);
newnode->resjunk = from->resjunk;
return newnode; return newnode;
} }
...@@ -690,112 +649,105 @@ _copyFjoin(Fjoin *from) ...@@ -690,112 +649,105 @@ _copyFjoin(Fjoin *from)
{ {
Fjoin *newnode = makeNode(Fjoin); Fjoin *newnode = makeNode(Fjoin);
/* COPY_SCALAR_FIELD(fj_initialized);
* copy node superclass fields COPY_SCALAR_FIELD(fj_nNodes);
*/ COPY_NODE_FIELD(fj_innerNode);
COPY_POINTER_FIELD(fj_results, from->fj_nNodes * sizeof(Datum));
COPY_POINTER_FIELD(fj_alwaysDone, from->fj_nNodes * sizeof(bool));
newnode->fj_initialized = from->fj_initialized; return newnode;
newnode->fj_nNodes = from->fj_nNodes; }
Node_Copy(from, newnode, fj_innerNode); static Alias *
_copyAlias(Alias *from)
{
Alias *newnode = makeNode(Alias);
newnode->fj_results = (DatumPtr) COPY_STRING_FIELD(aliasname);
palloc((from->fj_nNodes) * sizeof(Datum)); COPY_NODE_FIELD(colnames);
memmove(from->fj_results,
newnode->fj_results,
(from->fj_nNodes) * sizeof(Datum));
newnode->fj_alwaysDone = (BoolPtr) return newnode;
palloc((from->fj_nNodes) * sizeof(bool)); }
memmove(from->fj_alwaysDone,
newnode->fj_alwaysDone,
(from->fj_nNodes) * sizeof(bool));
static RangeVar *
_copyRangeVar(RangeVar *from)
{
RangeVar *newnode = makeNode(RangeVar);
COPY_STRING_FIELD(catalogname);
COPY_STRING_FIELD(schemaname);
COPY_STRING_FIELD(relname);
COPY_SCALAR_FIELD(inhOpt);
COPY_SCALAR_FIELD(istemp);
COPY_NODE_FIELD(alias);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyExpr * _copyExpr
* ----------------
*/ */
static Expr * static Expr *
_copyExpr(Expr *from) _copyExpr(Expr *from)
{ {
Expr *newnode = makeNode(Expr); Expr *newnode = makeNode(Expr);
/* COPY_SCALAR_FIELD(typeOid);
* copy node superclass fields COPY_SCALAR_FIELD(opType);
*/ COPY_NODE_FIELD(oper);
newnode->typeOid = from->typeOid; COPY_NODE_FIELD(args);
newnode->opType = from->opType;
Node_Copy(from, newnode, oper);
Node_Copy(from, newnode, args);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyVar * _copyVar
* ----------------
*/ */
static Var * static Var *
_copyVar(Var *from) _copyVar(Var *from)
{ {
Var *newnode = makeNode(Var); Var *newnode = makeNode(Var);
/* COPY_SCALAR_FIELD(varno);
* copy remainder of node COPY_SCALAR_FIELD(varattno);
*/ COPY_SCALAR_FIELD(vartype);
newnode->varno = from->varno; COPY_SCALAR_FIELD(vartypmod);
newnode->varattno = from->varattno; COPY_SCALAR_FIELD(varlevelsup);
newnode->vartype = from->vartype; COPY_SCALAR_FIELD(varnoold);
newnode->vartypmod = from->vartypmod; COPY_SCALAR_FIELD(varoattno);
newnode->varlevelsup = from->varlevelsup;
newnode->varnoold = from->varnoold;
newnode->varoattno = from->varoattno;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyOper * _copyOper
* ----------------
*/ */
static Oper * static Oper *
_copyOper(Oper *from) _copyOper(Oper *from)
{ {
Oper *newnode = makeNode(Oper); Oper *newnode = makeNode(Oper);
/* COPY_SCALAR_FIELD(opno);
* copy remainder of node COPY_SCALAR_FIELD(opid);
*/ COPY_SCALAR_FIELD(opresulttype);
newnode->opno = from->opno; COPY_SCALAR_FIELD(opretset);
newnode->opid = from->opid;
newnode->opresulttype = from->opresulttype;
newnode->opretset = from->opretset;
/* Do not copy the run-time state, if any */ /* Do not copy the run-time state, if any */
newnode->op_fcache = NULL; newnode->op_fcache = NULL;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyConst * _copyConst
* ----------------
*/ */
static Const * static Const *
_copyConst(Const *from) _copyConst(Const *from)
{ {
Const *newnode = makeNode(Const); Const *newnode = makeNode(Const);
/* COPY_SCALAR_FIELD(consttype);
* copy remainder of node COPY_SCALAR_FIELD(constlen);
*/
newnode->consttype = from->consttype;
newnode->constlen = from->constlen;
if (from->constbyval || from->constisnull) if (from->constbyval || from->constisnull)
{ {
...@@ -808,141 +760,119 @@ _copyConst(Const *from) ...@@ -808,141 +760,119 @@ _copyConst(Const *from)
else else
{ {
/* /*
* not passed by value. We need a palloc'd copy. * passed by reference. We need a palloc'd copy.
*/ */
newnode->constvalue = datumCopy(from->constvalue, newnode->constvalue = datumCopy(from->constvalue,
from->constbyval, from->constbyval,
from->constlen); from->constlen);
} }
newnode->constisnull = from->constisnull; COPY_SCALAR_FIELD(constisnull);
newnode->constbyval = from->constbyval; COPY_SCALAR_FIELD(constbyval);
newnode->constisset = from->constisset; COPY_SCALAR_FIELD(constisset);
newnode->constiscast = from->constiscast; COPY_SCALAR_FIELD(constiscast);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyParam * _copyParam
* ----------------
*/ */
static Param * static Param *
_copyParam(Param *from) _copyParam(Param *from)
{ {
Param *newnode = makeNode(Param); Param *newnode = makeNode(Param);
/* COPY_SCALAR_FIELD(paramkind);
* copy remainder of node COPY_SCALAR_FIELD(paramid);
*/ COPY_STRING_FIELD(paramname);
newnode->paramkind = from->paramkind; COPY_SCALAR_FIELD(paramtype);
newnode->paramid = from->paramid;
if (from->paramname != NULL)
newnode->paramname = pstrdup(from->paramname);
newnode->paramtype = from->paramtype;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyFunc * _copyFunc
* ----------------
*/ */
static Func * static Func *
_copyFunc(Func *from) _copyFunc(Func *from)
{ {
Func *newnode = makeNode(Func); Func *newnode = makeNode(Func);
/* COPY_SCALAR_FIELD(funcid);
* copy remainder of node COPY_SCALAR_FIELD(funcresulttype);
*/ COPY_SCALAR_FIELD(funcretset);
newnode->funcid = from->funcid; COPY_SCALAR_FIELD(funcformat);
newnode->funcresulttype = from->funcresulttype;
newnode->funcretset = from->funcretset;
newnode->funcformat = from->funcformat;
/* Do not copy the run-time state, if any */ /* Do not copy the run-time state, if any */
newnode->func_fcache = NULL; newnode->func_fcache = NULL;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyAggref * _copyAggref
* ----------------
*/ */
static Aggref * static Aggref *
_copyAggref(Aggref *from) _copyAggref(Aggref *from)
{ {
Aggref *newnode = makeNode(Aggref); Aggref *newnode = makeNode(Aggref);
newnode->aggfnoid = from->aggfnoid; COPY_SCALAR_FIELD(aggfnoid);
newnode->aggtype = from->aggtype; COPY_SCALAR_FIELD(aggtype);
Node_Copy(from, newnode, target); COPY_NODE_FIELD(target);
newnode->aggstar = from->aggstar; COPY_SCALAR_FIELD(aggstar);
newnode->aggdistinct = from->aggdistinct; COPY_SCALAR_FIELD(aggdistinct);
newnode->aggno = from->aggno; /* probably not needed */ COPY_SCALAR_FIELD(aggno); /* probably not necessary */
return newnode; return newnode;
} }
/* ---------------- /*
* _copySubLink * _copySubLink
* ----------------
*/ */
static SubLink * static SubLink *
_copySubLink(SubLink *from) _copySubLink(SubLink *from)
{ {
SubLink *newnode = makeNode(SubLink); SubLink *newnode = makeNode(SubLink);
/* COPY_SCALAR_FIELD(subLinkType);
* copy remainder of node COPY_SCALAR_FIELD(useor);
*/ COPY_NODE_FIELD(lefthand);
newnode->subLinkType = from->subLinkType; COPY_NODE_FIELD(oper);
newnode->useor = from->useor; COPY_NODE_FIELD(subselect);
Node_Copy(from, newnode, lefthand);
Node_Copy(from, newnode, oper);
Node_Copy(from, newnode, subselect);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyFieldSelect * _copyFieldSelect
* ----------------
*/ */
static FieldSelect * static FieldSelect *
_copyFieldSelect(FieldSelect *from) _copyFieldSelect(FieldSelect *from)
{ {
FieldSelect *newnode = makeNode(FieldSelect); FieldSelect *newnode = makeNode(FieldSelect);
/* COPY_NODE_FIELD(arg);
* copy remainder of node COPY_SCALAR_FIELD(fieldnum);
*/ COPY_SCALAR_FIELD(resulttype);
Node_Copy(from, newnode, arg); COPY_SCALAR_FIELD(resulttypmod);
newnode->fieldnum = from->fieldnum;
newnode->resulttype = from->resulttype;
newnode->resulttypmod = from->resulttypmod;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyRelabelType * _copyRelabelType
* ----------------
*/ */
static RelabelType * static RelabelType *
_copyRelabelType(RelabelType *from) _copyRelabelType(RelabelType *from)
{ {
RelabelType *newnode = makeNode(RelabelType); RelabelType *newnode = makeNode(RelabelType);
/* COPY_NODE_FIELD(arg);
* copy remainder of node COPY_SCALAR_FIELD(resulttype);
*/ COPY_SCALAR_FIELD(resulttypmod);
Node_Copy(from, newnode, arg); COPY_SCALAR_FIELD(relabelformat);
newnode->resulttype = from->resulttype;
newnode->resulttypmod = from->resulttypmod;
newnode->relabelformat = from->relabelformat;
return newnode; return newnode;
} }
...@@ -952,18 +882,7 @@ _copyRangeTblRef(RangeTblRef *from) ...@@ -952,18 +882,7 @@ _copyRangeTblRef(RangeTblRef *from)
{ {
RangeTblRef *newnode = makeNode(RangeTblRef); RangeTblRef *newnode = makeNode(RangeTblRef);
newnode->rtindex = from->rtindex; COPY_SCALAR_FIELD(rtindex);
return newnode;
}
static FromExpr *
_copyFromExpr(FromExpr *from)
{
FromExpr *newnode = makeNode(FromExpr);
Node_Copy(from, newnode, fromlist);
Node_Copy(from, newnode, quals);
return newnode; return newnode;
} }
...@@ -973,114 +892,25 @@ _copyJoinExpr(JoinExpr *from) ...@@ -973,114 +892,25 @@ _copyJoinExpr(JoinExpr *from)
{ {
JoinExpr *newnode = makeNode(JoinExpr); JoinExpr *newnode = makeNode(JoinExpr);
newnode->jointype = from->jointype; COPY_SCALAR_FIELD(jointype);
newnode->isNatural = from->isNatural; COPY_SCALAR_FIELD(isNatural);
Node_Copy(from, newnode, larg); COPY_NODE_FIELD(larg);
Node_Copy(from, newnode, rarg); COPY_NODE_FIELD(rarg);
Node_Copy(from, newnode, using); COPY_NODE_FIELD(using);
Node_Copy(from, newnode, quals); COPY_NODE_FIELD(quals);
Node_Copy(from, newnode, alias); COPY_NODE_FIELD(alias);
newnode->rtindex = from->rtindex; COPY_SCALAR_FIELD(rtindex);
return newnode;
}
static CaseExpr *
_copyCaseExpr(CaseExpr *from)
{
CaseExpr *newnode = makeNode(CaseExpr);
/*
* copy remainder of node
*/
newnode->casetype = from->casetype;
Node_Copy(from, newnode, arg);
Node_Copy(from, newnode, args);
Node_Copy(from, newnode, defresult);
return newnode;
}
static CaseWhen *
_copyCaseWhen(CaseWhen *from)
{
CaseWhen *newnode = makeNode(CaseWhen);
/*
* copy remainder of node
*/
Node_Copy(from, newnode, expr);
Node_Copy(from, newnode, result);
return newnode; return newnode;
} }
static NullTest * static FromExpr *
_copyNullTest(NullTest *from) _copyFromExpr(FromExpr *from)
{
NullTest *newnode = makeNode(NullTest);
/*
* copy remainder of node
*/
Node_Copy(from, newnode, arg);
newnode->nulltesttype = from->nulltesttype;
return newnode;
}
static BooleanTest *
_copyBooleanTest(BooleanTest *from)
{
BooleanTest *newnode = makeNode(BooleanTest);
/*
* copy remainder of node
*/
Node_Copy(from, newnode, arg);
newnode->booltesttype = from->booltesttype;
return newnode;
}
static ConstraintTest *
_copyConstraintTest(ConstraintTest *from)
{
ConstraintTest *newnode = makeNode(ConstraintTest);
/*
* copy remainder of node
*/
Node_Copy(from, newnode, arg);
newnode->testtype = from->testtype;
if (from->name)
newnode->name = pstrdup(from->name);
if (from->domname)
newnode->domname = pstrdup(from->domname);
Node_Copy(from, newnode, check_expr);
return newnode;
}
static ConstraintTestValue *
_copyConstraintTestValue(ConstraintTestValue *from)
{ {
ConstraintTestValue *newnode = makeNode(ConstraintTestValue); FromExpr *newnode = makeNode(FromExpr);
/*
* copy remainder of node
*/
newnode->typeId = from->typeId;
newnode->typeMod = from->typeMod;
return newnode;
}
static DomainConstraintValue * COPY_NODE_FIELD(fromlist);
_copyDomainConstraintValue(DomainConstraintValue *from) COPY_NODE_FIELD(quals);
{
DomainConstraintValue *newnode = makeNode(DomainConstraintValue);
return newnode; return newnode;
} }
...@@ -1090,130 +920,112 @@ _copyArrayRef(ArrayRef *from) ...@@ -1090,130 +920,112 @@ _copyArrayRef(ArrayRef *from)
{ {
ArrayRef *newnode = makeNode(ArrayRef); ArrayRef *newnode = makeNode(ArrayRef);
/* COPY_SCALAR_FIELD(refrestype);
* copy remainder of node COPY_SCALAR_FIELD(refattrlength);
*/ COPY_SCALAR_FIELD(refelemlength);
newnode->refrestype = from->refrestype; COPY_SCALAR_FIELD(refelembyval);
newnode->refattrlength = from->refattrlength; COPY_SCALAR_FIELD(refelemalign);
newnode->refelemlength = from->refelemlength; COPY_NODE_FIELD(refupperindexpr);
newnode->refelembyval = from->refelembyval; COPY_NODE_FIELD(reflowerindexpr);
newnode->refelemalign = from->refelemalign; COPY_NODE_FIELD(refexpr);
COPY_NODE_FIELD(refassgnexpr);
Node_Copy(from, newnode, refupperindexpr);
Node_Copy(from, newnode, reflowerindexpr);
Node_Copy(from, newnode, refexpr);
Node_Copy(from, newnode, refassgnexpr);
return newnode; return newnode;
} }
/* **************************************************************** /* ****************************************************************
* relation.h copy functions * relation.h copy functions
*
* XXX the code to copy RelOptInfo and Path nodes is really completely bogus,
* because it makes no attempt to deal with multiple links from RelOptInfo
* to Paths, nor with back-links from Paths to their parent RelOptInfo.
* Currently, since we never actually try to copy a RelOptInfo, this is okay.
* **************************************************************** * ****************************************************************
*/ */
/* ---------------- /*
* _copyRelOptInfo * _copyRelOptInfo
* ----------------
*/ */
static RelOptInfo * static RelOptInfo *
_copyRelOptInfo(RelOptInfo *from) _copyRelOptInfo(RelOptInfo *from)
{ {
RelOptInfo *newnode = makeNode(RelOptInfo); RelOptInfo *newnode = makeNode(RelOptInfo);
newnode->reloptkind = from->reloptkind; COPY_SCALAR_FIELD(reloptkind);
COPY_INTLIST_FIELD(relids);
newnode->relids = listCopy(from->relids); COPY_SCALAR_FIELD(rows);
COPY_SCALAR_FIELD(width);
newnode->rows = from->rows; COPY_NODE_FIELD(targetlist);
newnode->width = from->width; COPY_NODE_FIELD(pathlist);
Node_Copy(from, newnode, targetlist);
Node_Copy(from, newnode, pathlist);
/* XXX cheapest-path fields should point to members of pathlist? */ /* XXX cheapest-path fields should point to members of pathlist? */
Node_Copy(from, newnode, cheapest_startup_path); COPY_NODE_FIELD(cheapest_startup_path);
Node_Copy(from, newnode, cheapest_total_path); COPY_NODE_FIELD(cheapest_total_path);
newnode->pruneable = from->pruneable; COPY_SCALAR_FIELD(pruneable);
COPY_SCALAR_FIELD(rtekind);
newnode->rtekind = from->rtekind; COPY_NODE_FIELD(indexlist);
Node_Copy(from, newnode, indexlist); COPY_SCALAR_FIELD(pages);
newnode->pages = from->pages; COPY_SCALAR_FIELD(tuples);
newnode->tuples = from->tuples; COPY_NODE_FIELD(subplan);
Node_Copy(from, newnode, subplan); COPY_SCALAR_FIELD(joinrti);
COPY_INTLIST_FIELD(joinrteids);
newnode->joinrti = from->joinrti; COPY_NODE_FIELD(baserestrictinfo);
newnode->joinrteids = listCopy(from->joinrteids); COPY_SCALAR_FIELD(baserestrictcost);
COPY_INTLIST_FIELD(outerjoinset);
Node_Copy(from, newnode, baserestrictinfo); COPY_NODE_FIELD(joininfo);
newnode->baserestrictcost = from->baserestrictcost; COPY_INTLIST_FIELD(index_outer_relids);
newnode->outerjoinset = listCopy(from->outerjoinset); COPY_NODE_FIELD(index_inner_paths);
Node_Copy(from, newnode, joininfo);
newnode->index_outer_relids = listCopy(from->index_outer_relids);
Node_Copy(from, newnode, index_inner_paths);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyIndexOptInfo * _copyIndexOptInfo
* ----------------
*/ */
static IndexOptInfo * static IndexOptInfo *
_copyIndexOptInfo(IndexOptInfo *from) _copyIndexOptInfo(IndexOptInfo *from)
{ {
IndexOptInfo *newnode = makeNode(IndexOptInfo); IndexOptInfo *newnode = makeNode(IndexOptInfo);
Size len;
newnode->indexoid = from->indexoid;
newnode->pages = from->pages;
newnode->tuples = from->tuples;
newnode->ncolumns = from->ncolumns; COPY_SCALAR_FIELD(indexoid);
newnode->nkeys = from->nkeys; COPY_SCALAR_FIELD(pages);
COPY_SCALAR_FIELD(tuples);
COPY_SCALAR_FIELD(ncolumns);
COPY_SCALAR_FIELD(nkeys);
if (from->classlist) if (from->classlist)
{ {
/* copy the trailing zero too */ /* copy the trailing zero too */
len = (from->ncolumns + 1) * sizeof(Oid); COPY_POINTER_FIELD(classlist, (from->ncolumns + 1) * sizeof(Oid));
newnode->classlist = (Oid *) palloc(len);
memcpy(newnode->classlist, from->classlist, len);
} }
if (from->indexkeys) if (from->indexkeys)
{ {
/* copy the trailing zero too */ /* copy the trailing zero too */
len = (from->nkeys + 1) * sizeof(int); COPY_POINTER_FIELD(indexkeys, (from->nkeys + 1) * sizeof(int));
newnode->indexkeys = (int *) palloc(len);
memcpy(newnode->indexkeys, from->indexkeys, len);
} }
if (from->ordering) if (from->ordering)
{ {
/* copy the trailing zero too */ /* copy the trailing zero too */
len = (from->ncolumns + 1) * sizeof(Oid); COPY_POINTER_FIELD(ordering, (from->ncolumns + 1) * sizeof(Oid));
newnode->ordering = (Oid *) palloc(len);
memcpy(newnode->ordering, from->ordering, len);
} }
newnode->relam = from->relam; COPY_SCALAR_FIELD(relam);
newnode->amcostestimate = from->amcostestimate; COPY_SCALAR_FIELD(amcostestimate);
newnode->indproc = from->indproc; COPY_SCALAR_FIELD(indproc);
Node_Copy(from, newnode, indpred); COPY_NODE_FIELD(indpred);
newnode->unique = from->unique; COPY_SCALAR_FIELD(unique);
COPY_INTLIST_FIELD(outer_relids);
newnode->outer_relids = listCopy(from->outer_relids); COPY_NODE_FIELD(inner_paths);
Node_Copy(from, newnode, inner_paths);
return newnode; return newnode;
} }
/* ---------------- /*
* CopyPathFields * CopyPathFields
* *
* This function copies the fields of the Path node. It is used by * This function copies the fields of the Path node. It is used by
* all the copy functions for classes which inherit from Path. * all the copy functions for classes which inherit from Path.
* ----------------
*/ */
static void static void
CopyPathFields(Path *from, Path *newnode) CopyPathFields(Path *from, Path *newnode)
...@@ -1221,21 +1033,18 @@ CopyPathFields(Path *from, Path *newnode) ...@@ -1221,21 +1033,18 @@ CopyPathFields(Path *from, Path *newnode)
/* /*
* Modify the next line, since it causes the copying to cycle (i.e. * 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: * the parent points right back here! -- JMH, 7/7/92. Old version:
* Node_Copy(from, newnode, parent); * COPY_NODE_FIELD(parent);
*/ */
newnode->parent = from->parent; COPY_SCALAR_FIELD(parent);
newnode->startup_cost = from->startup_cost;
newnode->total_cost = from->total_cost;
newnode->pathtype = from->pathtype; COPY_SCALAR_FIELD(startup_cost);
COPY_SCALAR_FIELD(total_cost);
Node_Copy(from, newnode, pathkeys); COPY_SCALAR_FIELD(pathtype);
COPY_NODE_FIELD(pathkeys);
} }
/* ---------------- /*
* _copyPath * _copyPath
* ----------------
*/ */
static Path * static Path *
_copyPath(Path *from) _copyPath(Path *from)
...@@ -1247,9 +1056,8 @@ _copyPath(Path *from) ...@@ -1247,9 +1056,8 @@ _copyPath(Path *from)
return newnode; return newnode;
} }
/* ---------------- /*
* _copyIndexPath * _copyIndexPath
* ----------------
*/ */
static IndexPath * static IndexPath *
_copyIndexPath(IndexPath *from) _copyIndexPath(IndexPath *from)
...@@ -1257,24 +1065,23 @@ _copyIndexPath(IndexPath *from) ...@@ -1257,24 +1065,23 @@ _copyIndexPath(IndexPath *from)
IndexPath *newnode = makeNode(IndexPath); IndexPath *newnode = makeNode(IndexPath);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPathFields((Path *) from, (Path *) newnode); CopyPathFields((Path *) from, (Path *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, indexinfo); COPY_NODE_FIELD(indexinfo);
Node_Copy(from, newnode, indexqual); COPY_NODE_FIELD(indexqual);
newnode->indexscandir = from->indexscandir; COPY_SCALAR_FIELD(indexscandir);
newnode->rows = from->rows; COPY_SCALAR_FIELD(rows);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyTidPath * _copyTidPath
* ----------------
*/ */
static TidPath * static TidPath *
_copyTidPath(TidPath *from) _copyTidPath(TidPath *from)
...@@ -1282,22 +1089,21 @@ _copyTidPath(TidPath *from) ...@@ -1282,22 +1089,21 @@ _copyTidPath(TidPath *from)
TidPath *newnode = makeNode(TidPath); TidPath *newnode = makeNode(TidPath);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPathFields((Path *) from, (Path *) newnode); CopyPathFields((Path *) from, (Path *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, tideval); COPY_NODE_FIELD(tideval);
newnode->unjoined_relids = listCopy(from->unjoined_relids); COPY_INTLIST_FIELD(unjoined_relids);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyAppendPath * _copyAppendPath
* ----------------
*/ */
static AppendPath * static AppendPath *
_copyAppendPath(AppendPath *from) _copyAppendPath(AppendPath *from)
...@@ -1305,21 +1111,20 @@ _copyAppendPath(AppendPath *from) ...@@ -1305,21 +1111,20 @@ _copyAppendPath(AppendPath *from)
AppendPath *newnode = makeNode(AppendPath); AppendPath *newnode = makeNode(AppendPath);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPathFields((Path *) from, (Path *) newnode); CopyPathFields((Path *) from, (Path *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, subpaths); COPY_NODE_FIELD(subpaths);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyResultPath * _copyResultPath
* ----------------
*/ */
static ResultPath * static ResultPath *
_copyResultPath(ResultPath *from) _copyResultPath(ResultPath *from)
...@@ -1327,38 +1132,38 @@ _copyResultPath(ResultPath *from) ...@@ -1327,38 +1132,38 @@ _copyResultPath(ResultPath *from)
ResultPath *newnode = makeNode(ResultPath); ResultPath *newnode = makeNode(ResultPath);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPathFields((Path *) from, (Path *) newnode); CopyPathFields((Path *) from, (Path *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, subpath); COPY_NODE_FIELD(subpath);
Node_Copy(from, newnode, constantqual); COPY_NODE_FIELD(constantqual);
return newnode; return newnode;
} }
/* ---------------- /*
* CopyJoinPathFields * CopyJoinPathFields
* *
* This function copies the fields of the JoinPath node. It is used by * This function copies the fields of the JoinPath node. It is used by
* all the copy functions for classes which inherit from JoinPath. * all the copy functions for classes which inherit from JoinPath.
* ----------------
*/ */
static void static void
CopyJoinPathFields(JoinPath *from, JoinPath *newnode) CopyJoinPathFields(JoinPath *from, JoinPath *newnode)
{ {
newnode->jointype = from->jointype; CopyPathFields((Path *) from, (Path *) newnode);
Node_Copy(from, newnode, outerjoinpath);
Node_Copy(from, newnode, innerjoinpath); COPY_SCALAR_FIELD(jointype);
Node_Copy(from, newnode, joinrestrictinfo); COPY_NODE_FIELD(outerjoinpath);
COPY_NODE_FIELD(innerjoinpath);
COPY_NODE_FIELD(joinrestrictinfo);
} }
/* ---------------- /*
* _copyNestPath * _copyNestPath
* ----------------
*/ */
static NestPath * static NestPath *
_copyNestPath(NestPath *from) _copyNestPath(NestPath *from)
...@@ -1366,17 +1171,15 @@ _copyNestPath(NestPath *from) ...@@ -1366,17 +1171,15 @@ _copyNestPath(NestPath *from)
NestPath *newnode = makeNode(NestPath); NestPath *newnode = makeNode(NestPath);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPathFields((Path *) from, (Path *) newnode);
CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode); CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyMergePath * _copyMergePath
* ----------------
*/ */
static MergePath * static MergePath *
_copyMergePath(MergePath *from) _copyMergePath(MergePath *from)
...@@ -1384,24 +1187,22 @@ _copyMergePath(MergePath *from) ...@@ -1384,24 +1187,22 @@ _copyMergePath(MergePath *from)
MergePath *newnode = makeNode(MergePath); MergePath *newnode = makeNode(MergePath);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPathFields((Path *) from, (Path *) newnode);
CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode); CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
/* /*
* copy the remainder of the node * copy remainder of node
*/ */
Node_Copy(from, newnode, path_mergeclauses); COPY_NODE_FIELD(path_mergeclauses);
Node_Copy(from, newnode, outersortkeys); COPY_NODE_FIELD(outersortkeys);
Node_Copy(from, newnode, innersortkeys); COPY_NODE_FIELD(innersortkeys);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyHashPath * _copyHashPath
* ----------------
*/ */
static HashPath * static HashPath *
_copyHashPath(HashPath *from) _copyHashPath(HashPath *from)
...@@ -1409,57 +1210,48 @@ _copyHashPath(HashPath *from) ...@@ -1409,57 +1210,48 @@ _copyHashPath(HashPath *from)
HashPath *newnode = makeNode(HashPath); HashPath *newnode = makeNode(HashPath);
/* /*
* copy the node superclass fields * copy node superclass fields
*/ */
CopyPathFields((Path *) from, (Path *) newnode);
CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode); CopyJoinPathFields((JoinPath *) from, (JoinPath *) newnode);
/* /*
* copy remainder of node * copy remainder of node
*/ */
Node_Copy(from, newnode, path_hashclauses); COPY_NODE_FIELD(path_hashclauses);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyPathKeyItem * _copyPathKeyItem
* ----------------
*/ */
static PathKeyItem * static PathKeyItem *
_copyPathKeyItem(PathKeyItem *from) _copyPathKeyItem(PathKeyItem *from)
{ {
PathKeyItem *newnode = makeNode(PathKeyItem); PathKeyItem *newnode = makeNode(PathKeyItem);
/* COPY_NODE_FIELD(key);
* copy remainder of node COPY_SCALAR_FIELD(sortop);
*/
Node_Copy(from, newnode, key);
newnode->sortop = from->sortop;
return newnode; return newnode;
} }
/* ---------------- /*
* _copyRestrictInfo * _copyRestrictInfo
* ----------------
*/ */
static RestrictInfo * static RestrictInfo *
_copyRestrictInfo(RestrictInfo *from) _copyRestrictInfo(RestrictInfo *from)
{ {
RestrictInfo *newnode = makeNode(RestrictInfo); RestrictInfo *newnode = makeNode(RestrictInfo);
/* COPY_NODE_FIELD(clause);
* copy remainder of node COPY_SCALAR_FIELD(ispusheddown);
*/ COPY_NODE_FIELD(subclauseindices); /* XXX probably bad */
Node_Copy(from, newnode, clause); COPY_SCALAR_FIELD(eval_cost);
newnode->ispusheddown = from->ispusheddown; COPY_SCALAR_FIELD(this_selec);
Node_Copy(from, newnode, subclauseindices); COPY_SCALAR_FIELD(mergejoinoperator);
newnode->eval_cost = from->eval_cost; COPY_SCALAR_FIELD(left_sortop);
newnode->this_selec = from->this_selec; COPY_SCALAR_FIELD(right_sortop);
newnode->mergejoinoperator = from->mergejoinoperator;
newnode->left_sortop = from->left_sortop;
newnode->right_sortop = from->right_sortop;
/* /*
* Do not copy pathkeys, since they'd not be canonical in a copied * Do not copy pathkeys, since they'd not be canonical in a copied
...@@ -1467,48 +1259,41 @@ _copyRestrictInfo(RestrictInfo *from) ...@@ -1467,48 +1259,41 @@ _copyRestrictInfo(RestrictInfo *from)
*/ */
newnode->left_pathkey = NIL; newnode->left_pathkey = NIL;
newnode->right_pathkey = NIL; newnode->right_pathkey = NIL;
newnode->left_mergescansel = from->left_mergescansel;
newnode->right_mergescansel = from->right_mergescansel; COPY_SCALAR_FIELD(left_mergescansel);
newnode->hashjoinoperator = from->hashjoinoperator; COPY_SCALAR_FIELD(right_mergescansel);
newnode->left_bucketsize = from->left_bucketsize; COPY_SCALAR_FIELD(hashjoinoperator);
newnode->right_bucketsize = from->right_bucketsize; COPY_SCALAR_FIELD(left_bucketsize);
COPY_SCALAR_FIELD(right_bucketsize);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyJoinInfo * _copyJoinInfo
* ----------------
*/ */
static JoinInfo * static JoinInfo *
_copyJoinInfo(JoinInfo *from) _copyJoinInfo(JoinInfo *from)
{ {
JoinInfo *newnode = makeNode(JoinInfo); JoinInfo *newnode = makeNode(JoinInfo);
/* COPY_INTLIST_FIELD(unjoined_relids);
* copy remainder of node COPY_NODE_FIELD(jinfo_restrictinfo);
*/
newnode->unjoined_relids = listCopy(from->unjoined_relids);
Node_Copy(from, newnode, jinfo_restrictinfo);
return newnode; return newnode;
} }
/* ---------------- /*
* _copyInnerIndexscanInfo * _copyInnerIndexscanInfo
* ----------------
*/ */
static InnerIndexscanInfo * static InnerIndexscanInfo *
_copyInnerIndexscanInfo(InnerIndexscanInfo *from) _copyInnerIndexscanInfo(InnerIndexscanInfo *from)
{ {
InnerIndexscanInfo *newnode = makeNode(InnerIndexscanInfo); InnerIndexscanInfo *newnode = makeNode(InnerIndexscanInfo);
/* COPY_INTLIST_FIELD(other_relids);
* copy remainder of node COPY_SCALAR_FIELD(isouterjoin);
*/ COPY_NODE_FIELD(best_innerpath);
newnode->other_relids = listCopy(from->other_relids);
newnode->isouterjoin = from->isouterjoin;
Node_Copy(from, newnode, best_innerpath);
return newnode; return newnode;
} }
...@@ -1523,9 +1308,10 @@ _copyTargetEntry(TargetEntry *from) ...@@ -1523,9 +1308,10 @@ _copyTargetEntry(TargetEntry *from)
{ {
TargetEntry *newnode = makeNode(TargetEntry); TargetEntry *newnode = makeNode(TargetEntry);
Node_Copy(from, newnode, resdom); COPY_NODE_FIELD(resdom);
Node_Copy(from, newnode, fjoin); COPY_NODE_FIELD(fjoin);
Node_Copy(from, newnode, expr); COPY_NODE_FIELD(expr);
return newnode; return newnode;
} }
...@@ -1534,20 +1320,20 @@ _copyRangeTblEntry(RangeTblEntry *from) ...@@ -1534,20 +1320,20 @@ _copyRangeTblEntry(RangeTblEntry *from)
{ {
RangeTblEntry *newnode = makeNode(RangeTblEntry); RangeTblEntry *newnode = makeNode(RangeTblEntry);
newnode->rtekind = from->rtekind; COPY_SCALAR_FIELD(rtekind);
newnode->relid = from->relid; COPY_SCALAR_FIELD(relid);
Node_Copy(from, newnode, subquery); COPY_NODE_FIELD(subquery);
Node_Copy(from, newnode, funcexpr); COPY_NODE_FIELD(funcexpr);
Node_Copy(from, newnode, coldeflist); COPY_NODE_FIELD(coldeflist);
newnode->jointype = from->jointype; COPY_SCALAR_FIELD(jointype);
Node_Copy(from, newnode, joinaliasvars); COPY_NODE_FIELD(joinaliasvars);
Node_Copy(from, newnode, alias); COPY_NODE_FIELD(alias);
Node_Copy(from, newnode, eref); COPY_NODE_FIELD(eref);
newnode->inh = from->inh; COPY_SCALAR_FIELD(inh);
newnode->inFromCl = from->inFromCl; COPY_SCALAR_FIELD(inFromCl);
newnode->checkForRead = from->checkForRead; COPY_SCALAR_FIELD(checkForRead);
newnode->checkForWrite = from->checkForWrite; COPY_SCALAR_FIELD(checkForWrite);
newnode->checkAsUser = from->checkAsUser; COPY_SCALAR_FIELD(checkAsUser);
return newnode; return newnode;
} }
...@@ -1557,17 +1343,16 @@ _copyFkConstraint(FkConstraint *from) ...@@ -1557,17 +1343,16 @@ _copyFkConstraint(FkConstraint *from)
{ {
FkConstraint *newnode = makeNode(FkConstraint); FkConstraint *newnode = makeNode(FkConstraint);
if (from->constr_name) COPY_STRING_FIELD(constr_name);
newnode->constr_name = pstrdup(from->constr_name); COPY_NODE_FIELD(pktable);
Node_Copy(from, newnode, pktable); COPY_NODE_FIELD(fk_attrs);
Node_Copy(from, newnode, fk_attrs); COPY_NODE_FIELD(pk_attrs);
Node_Copy(from, newnode, pk_attrs); COPY_SCALAR_FIELD(fk_matchtype);
newnode->fk_matchtype = from->fk_matchtype; COPY_SCALAR_FIELD(fk_upd_action);
newnode->fk_upd_action = from->fk_upd_action; COPY_SCALAR_FIELD(fk_del_action);
newnode->fk_del_action = from->fk_del_action; COPY_SCALAR_FIELD(deferrable);
newnode->deferrable = from->deferrable; COPY_SCALAR_FIELD(initdeferred);
newnode->initdeferred = from->initdeferred; COPY_SCALAR_FIELD(skip_validation);
newnode->skip_validation = from->skip_validation;
return newnode; return newnode;
} }
...@@ -1577,8 +1362,19 @@ _copySortClause(SortClause *from) ...@@ -1577,8 +1362,19 @@ _copySortClause(SortClause *from)
{ {
SortClause *newnode = makeNode(SortClause); SortClause *newnode = makeNode(SortClause);
newnode->tleSortGroupRef = from->tleSortGroupRef; COPY_SCALAR_FIELD(tleSortGroupRef);
newnode->sortop = from->sortop; COPY_SCALAR_FIELD(sortop);
return newnode;
}
static GroupClause *
_copyGroupClause(GroupClause *from)
{
GroupClause *newnode = makeNode(GroupClause);
COPY_SCALAR_FIELD(tleSortGroupRef);
COPY_SCALAR_FIELD(sortop);
return newnode; return newnode;
} }
...@@ -1588,10 +1384,10 @@ _copyAExpr(A_Expr *from) ...@@ -1588,10 +1384,10 @@ _copyAExpr(A_Expr *from)
{ {
A_Expr *newnode = makeNode(A_Expr); A_Expr *newnode = makeNode(A_Expr);
newnode->oper = from->oper; COPY_SCALAR_FIELD(oper);
Node_Copy(from, newnode, name); COPY_NODE_FIELD(name);
Node_Copy(from, newnode, lexpr); COPY_NODE_FIELD(lexpr);
Node_Copy(from, newnode, rexpr); COPY_NODE_FIELD(rexpr);
return newnode; return newnode;
} }
...@@ -1601,8 +1397,8 @@ _copyColumnRef(ColumnRef *from) ...@@ -1601,8 +1397,8 @@ _copyColumnRef(ColumnRef *from)
{ {
ColumnRef *newnode = makeNode(ColumnRef); ColumnRef *newnode = makeNode(ColumnRef);
Node_Copy(from, newnode, fields); COPY_NODE_FIELD(fields);
Node_Copy(from, newnode, indirection); COPY_NODE_FIELD(indirection);
return newnode; return newnode;
} }
...@@ -1612,9 +1408,9 @@ _copyParamRef(ParamRef *from) ...@@ -1612,9 +1408,9 @@ _copyParamRef(ParamRef *from)
{ {
ParamRef *newnode = makeNode(ParamRef); ParamRef *newnode = makeNode(ParamRef);
newnode->number = from->number; COPY_SCALAR_FIELD(number);
Node_Copy(from, newnode, fields); COPY_NODE_FIELD(fields);
Node_Copy(from, newnode, indirection); COPY_NODE_FIELD(indirection);
return newnode; return newnode;
} }
...@@ -1625,16 +1421,16 @@ _copyAConst(A_Const *from) ...@@ -1625,16 +1421,16 @@ _copyAConst(A_Const *from)
A_Const *newnode = makeNode(A_Const); A_Const *newnode = makeNode(A_Const);
/* This part must duplicate _copyValue */ /* This part must duplicate _copyValue */
newnode->val.type = from->val.type; COPY_SCALAR_FIELD(val.type);
switch (from->val.type) switch (from->val.type)
{ {
case T_Integer: case T_Integer:
newnode->val.val.ival = from->val.val.ival; COPY_SCALAR_FIELD(val.val.ival);
break; break;
case T_Float: case T_Float:
case T_String: case T_String:
case T_BitString: case T_BitString:
newnode->val.val.str = pstrdup(from->val.val.str); COPY_STRING_FIELD(val.val.str);
break; break;
case T_Null: case T_Null:
/* nothing to do */ /* nothing to do */
...@@ -1644,7 +1440,7 @@ _copyAConst(A_Const *from) ...@@ -1644,7 +1440,7 @@ _copyAConst(A_Const *from)
break; break;
} }
Node_Copy(from, newnode, typename); COPY_NODE_FIELD(typename);
return newnode; return newnode;
} }
...@@ -1654,10 +1450,10 @@ _copyFuncCall(FuncCall *from) ...@@ -1654,10 +1450,10 @@ _copyFuncCall(FuncCall *from)
{ {
FuncCall *newnode = makeNode(FuncCall); FuncCall *newnode = makeNode(FuncCall);
Node_Copy(from, newnode, funcname); COPY_NODE_FIELD(funcname);
Node_Copy(from, newnode, args); COPY_NODE_FIELD(args);
newnode->agg_star = from->agg_star; COPY_SCALAR_FIELD(agg_star);
newnode->agg_distinct = from->agg_distinct; COPY_SCALAR_FIELD(agg_distinct);
return newnode; return newnode;
} }
...@@ -1667,8 +1463,8 @@ _copyAIndices(A_Indices *from) ...@@ -1667,8 +1463,8 @@ _copyAIndices(A_Indices *from)
{ {
A_Indices *newnode = makeNode(A_Indices); A_Indices *newnode = makeNode(A_Indices);
Node_Copy(from, newnode, lidx); COPY_NODE_FIELD(lidx);
Node_Copy(from, newnode, uidx); COPY_NODE_FIELD(uidx);
return newnode; return newnode;
} }
...@@ -1678,9 +1474,9 @@ _copyExprFieldSelect(ExprFieldSelect *from) ...@@ -1678,9 +1474,9 @@ _copyExprFieldSelect(ExprFieldSelect *from)
{ {
ExprFieldSelect *newnode = makeNode(ExprFieldSelect); ExprFieldSelect *newnode = makeNode(ExprFieldSelect);
Node_Copy(from, newnode, arg); COPY_NODE_FIELD(arg);
Node_Copy(from, newnode, fields); COPY_NODE_FIELD(fields);
Node_Copy(from, newnode, indirection); COPY_NODE_FIELD(indirection);
return newnode; return newnode;
} }
...@@ -1690,10 +1486,9 @@ _copyResTarget(ResTarget *from) ...@@ -1690,10 +1486,9 @@ _copyResTarget(ResTarget *from)
{ {
ResTarget *newnode = makeNode(ResTarget); ResTarget *newnode = makeNode(ResTarget);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_NODE_FIELD(indirection);
Node_Copy(from, newnode, indirection); COPY_NODE_FIELD(val);
Node_Copy(from, newnode, val);
return newnode; return newnode;
} }
...@@ -1703,13 +1498,13 @@ _copyTypeName(TypeName *from) ...@@ -1703,13 +1498,13 @@ _copyTypeName(TypeName *from)
{ {
TypeName *newnode = makeNode(TypeName); TypeName *newnode = makeNode(TypeName);
Node_Copy(from, newnode, names); COPY_NODE_FIELD(names);
newnode->typeid = from->typeid; COPY_SCALAR_FIELD(typeid);
newnode->timezone = from->timezone; COPY_SCALAR_FIELD(timezone);
newnode->setof = from->setof; COPY_SCALAR_FIELD(setof);
newnode->pct_type = from->pct_type; COPY_SCALAR_FIELD(pct_type);
newnode->typmod = from->typmod; COPY_SCALAR_FIELD(typmod);
Node_Copy(from, newnode, arrayBounds); COPY_NODE_FIELD(arrayBounds);
return newnode; return newnode;
} }
...@@ -1719,38 +1514,8 @@ _copySortGroupBy(SortGroupBy *from) ...@@ -1719,38 +1514,8 @@ _copySortGroupBy(SortGroupBy *from)
{ {
SortGroupBy *newnode = makeNode(SortGroupBy); SortGroupBy *newnode = makeNode(SortGroupBy);
Node_Copy(from, newnode, useOp); COPY_NODE_FIELD(useOp);
Node_Copy(from, newnode, node); COPY_NODE_FIELD(node);
return newnode;
}
static Alias *
_copyAlias(Alias *from)
{
Alias *newnode = makeNode(Alias);
if (from->aliasname)
newnode->aliasname = pstrdup(from->aliasname);
Node_Copy(from, newnode, colnames);
return newnode;
}
static RangeVar *
_copyRangeVar(RangeVar *from)
{
RangeVar *newnode = makeNode(RangeVar);
if (from->catalogname)
newnode->catalogname = pstrdup(from->catalogname);
if (from->schemaname)
newnode->schemaname = pstrdup(from->schemaname);
if (from->relname)
newnode->relname = pstrdup(from->relname);
newnode->inhOpt = from->inhOpt;
newnode->istemp = from->istemp;
Node_Copy(from, newnode, alias);
return newnode; return newnode;
} }
...@@ -1760,8 +1525,8 @@ _copyRangeSubselect(RangeSubselect *from) ...@@ -1760,8 +1525,8 @@ _copyRangeSubselect(RangeSubselect *from)
{ {
RangeSubselect *newnode = makeNode(RangeSubselect); RangeSubselect *newnode = makeNode(RangeSubselect);
Node_Copy(from, newnode, subquery); COPY_NODE_FIELD(subquery);
Node_Copy(from, newnode, alias); COPY_NODE_FIELD(alias);
return newnode; return newnode;
} }
...@@ -1771,9 +1536,9 @@ _copyRangeFunction(RangeFunction *from) ...@@ -1771,9 +1536,9 @@ _copyRangeFunction(RangeFunction *from)
{ {
RangeFunction *newnode = makeNode(RangeFunction); RangeFunction *newnode = makeNode(RangeFunction);
Node_Copy(from, newnode, funccallnode); COPY_NODE_FIELD(funccallnode);
Node_Copy(from, newnode, alias); COPY_NODE_FIELD(alias);
Node_Copy(from, newnode, coldeflist); COPY_NODE_FIELD(coldeflist);
return newnode; return newnode;
} }
...@@ -1783,8 +1548,8 @@ _copyTypeCast(TypeCast *from) ...@@ -1783,8 +1548,8 @@ _copyTypeCast(TypeCast *from)
{ {
TypeCast *newnode = makeNode(TypeCast); TypeCast *newnode = makeNode(TypeCast);
Node_Copy(from, newnode, arg); COPY_NODE_FIELD(arg);
Node_Copy(from, newnode, typename); COPY_NODE_FIELD(typename);
return newnode; return newnode;
} }
...@@ -1794,11 +1559,10 @@ _copyIndexElem(IndexElem *from) ...@@ -1794,11 +1559,10 @@ _copyIndexElem(IndexElem *from)
{ {
IndexElem *newnode = makeNode(IndexElem); IndexElem *newnode = makeNode(IndexElem);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_NODE_FIELD(funcname);
Node_Copy(from, newnode, funcname); COPY_NODE_FIELD(args);
Node_Copy(from, newnode, args); COPY_NODE_FIELD(opclass);
Node_Copy(from, newnode, opclass);
return newnode; return newnode;
} }
...@@ -1808,17 +1572,15 @@ _copyColumnDef(ColumnDef *from) ...@@ -1808,17 +1572,15 @@ _copyColumnDef(ColumnDef *from)
{ {
ColumnDef *newnode = makeNode(ColumnDef); ColumnDef *newnode = makeNode(ColumnDef);
if (from->colname) COPY_STRING_FIELD(colname);
newnode->colname = pstrdup(from->colname); COPY_NODE_FIELD(typename);
Node_Copy(from, newnode, typename); COPY_SCALAR_FIELD(inhcount);
newnode->inhcount = from->inhcount; COPY_SCALAR_FIELD(is_local);
newnode->is_local = from->is_local; COPY_SCALAR_FIELD(is_not_null);
newnode->is_not_null = from->is_not_null; COPY_NODE_FIELD(raw_default);
Node_Copy(from, newnode, raw_default); COPY_STRING_FIELD(cooked_default);
if (from->cooked_default) COPY_NODE_FIELD(constraints);
newnode->cooked_default = pstrdup(from->cooked_default); COPY_NODE_FIELD(support);
Node_Copy(from, newnode, constraints);
Node_Copy(from, newnode, support);
return newnode; return newnode;
} }
...@@ -1828,62 +1590,131 @@ _copyConstraint(Constraint *from) ...@@ -1828,62 +1590,131 @@ _copyConstraint(Constraint *from)
{ {
Constraint *newnode = makeNode(Constraint); Constraint *newnode = makeNode(Constraint);
newnode->contype = from->contype; COPY_SCALAR_FIELD(contype);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_NODE_FIELD(raw_expr);
Node_Copy(from, newnode, raw_expr); COPY_STRING_FIELD(cooked_expr);
if (from->cooked_expr) COPY_NODE_FIELD(keys);
newnode->cooked_expr = pstrdup(from->cooked_expr);
Node_Copy(from, newnode, keys);
return newnode; return newnode;
} }
static DefElem * static CaseExpr *
_copyDefElem(DefElem *from) _copyCaseExpr(CaseExpr *from)
{ {
DefElem *newnode = makeNode(DefElem); CaseExpr *newnode = makeNode(CaseExpr);
if (from->defname) COPY_SCALAR_FIELD(casetype);
newnode->defname = pstrdup(from->defname); COPY_NODE_FIELD(arg);
Node_Copy(from, newnode, arg); COPY_NODE_FIELD(args);
COPY_NODE_FIELD(defresult);
return newnode; return newnode;
} }
static Query * static CaseWhen *
_copyQuery(Query *from) _copyCaseWhen(CaseWhen *from)
{ {
Query *newnode = makeNode(Query); CaseWhen *newnode = makeNode(CaseWhen);
newnode->commandType = from->commandType; COPY_NODE_FIELD(expr);
newnode->querySource = from->querySource; COPY_NODE_FIELD(result);
Node_Copy(from, newnode, utilityStmt);
newnode->resultRelation = from->resultRelation;
Node_Copy(from, newnode, into);
newnode->isPortal = from->isPortal;
newnode->isBinary = from->isBinary;
newnode->hasAggs = from->hasAggs;
newnode->hasSubLinks = from->hasSubLinks;
Node_Copy(from, newnode, rtable); return newnode;
Node_Copy(from, newnode, jointree); }
newnode->rowMarks = listCopy(from->rowMarks); static NullTest *
_copyNullTest(NullTest *from)
{
NullTest *newnode = makeNode(NullTest);
Node_Copy(from, newnode, targetList); COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(nulltesttype);
Node_Copy(from, newnode, groupClause); return newnode;
Node_Copy(from, newnode, havingQual); }
Node_Copy(from, newnode, distinctClause);
Node_Copy(from, newnode, sortClause);
Node_Copy(from, newnode, limitOffset); static BooleanTest *
Node_Copy(from, newnode, limitCount); _copyBooleanTest(BooleanTest *from)
{
BooleanTest *newnode = makeNode(BooleanTest);
Node_Copy(from, newnode, setOperations); COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(booltesttype);
return newnode;
}
static ConstraintTest *
_copyConstraintTest(ConstraintTest *from)
{
ConstraintTest *newnode = makeNode(ConstraintTest);
COPY_NODE_FIELD(arg);
COPY_SCALAR_FIELD(testtype);
COPY_STRING_FIELD(name);
COPY_STRING_FIELD(domname);
COPY_NODE_FIELD(check_expr);
return newnode;
}
static DomainConstraintValue *
_copyDomainConstraintValue(DomainConstraintValue *from)
{
DomainConstraintValue *newnode = makeNode(DomainConstraintValue);
return newnode;
}
static ConstraintTestValue *
_copyConstraintTestValue(ConstraintTestValue *from)
{
ConstraintTestValue *newnode = makeNode(ConstraintTestValue);
newnode->resultRelations = listCopy(from->resultRelations); COPY_SCALAR_FIELD(typeId);
COPY_SCALAR_FIELD(typeMod);
return newnode;
}
static DefElem *
_copyDefElem(DefElem *from)
{
DefElem *newnode = makeNode(DefElem);
COPY_STRING_FIELD(defname);
COPY_NODE_FIELD(arg);
return newnode;
}
static Query *
_copyQuery(Query *from)
{
Query *newnode = makeNode(Query);
COPY_SCALAR_FIELD(commandType);
COPY_SCALAR_FIELD(querySource);
COPY_NODE_FIELD(utilityStmt);
COPY_SCALAR_FIELD(resultRelation);
COPY_NODE_FIELD(into);
COPY_SCALAR_FIELD(isPortal);
COPY_SCALAR_FIELD(isBinary);
COPY_SCALAR_FIELD(hasAggs);
COPY_SCALAR_FIELD(hasSubLinks);
COPY_NODE_FIELD(rtable);
COPY_NODE_FIELD(jointree);
COPY_INTLIST_FIELD(rowMarks);
COPY_NODE_FIELD(targetList);
COPY_NODE_FIELD(groupClause);
COPY_NODE_FIELD(havingQual);
COPY_NODE_FIELD(distinctClause);
COPY_NODE_FIELD(sortClause);
COPY_NODE_FIELD(limitOffset);
COPY_NODE_FIELD(limitCount);
COPY_NODE_FIELD(setOperations);
COPY_INTLIST_FIELD(resultRelations);
/* /*
* We do not copy the planner internal fields: base_rel_list, * We do not copy the planner internal fields: base_rel_list,
...@@ -1899,10 +1730,10 @@ _copyInsertStmt(InsertStmt *from) ...@@ -1899,10 +1730,10 @@ _copyInsertStmt(InsertStmt *from)
{ {
InsertStmt *newnode = makeNode(InsertStmt); InsertStmt *newnode = makeNode(InsertStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
Node_Copy(from, newnode, cols); COPY_NODE_FIELD(cols);
Node_Copy(from, newnode, targetList); COPY_NODE_FIELD(targetList);
Node_Copy(from, newnode, selectStmt); COPY_NODE_FIELD(selectStmt);
return newnode; return newnode;
} }
...@@ -1912,8 +1743,8 @@ _copyDeleteStmt(DeleteStmt *from) ...@@ -1912,8 +1743,8 @@ _copyDeleteStmt(DeleteStmt *from)
{ {
DeleteStmt *newnode = makeNode(DeleteStmt); DeleteStmt *newnode = makeNode(DeleteStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
Node_Copy(from, newnode, whereClause); COPY_NODE_FIELD(whereClause);
return newnode; return newnode;
} }
...@@ -1923,10 +1754,10 @@ _copyUpdateStmt(UpdateStmt *from) ...@@ -1923,10 +1754,10 @@ _copyUpdateStmt(UpdateStmt *from)
{ {
UpdateStmt *newnode = makeNode(UpdateStmt); UpdateStmt *newnode = makeNode(UpdateStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
Node_Copy(from, newnode, targetList); COPY_NODE_FIELD(targetList);
Node_Copy(from, newnode, whereClause); COPY_NODE_FIELD(whereClause);
Node_Copy(from, newnode, fromClause); COPY_NODE_FIELD(fromClause);
return newnode; return newnode;
} }
...@@ -1936,25 +1767,24 @@ _copySelectStmt(SelectStmt *from) ...@@ -1936,25 +1767,24 @@ _copySelectStmt(SelectStmt *from)
{ {
SelectStmt *newnode = makeNode(SelectStmt); SelectStmt *newnode = makeNode(SelectStmt);
Node_Copy(from, newnode, distinctClause); COPY_NODE_FIELD(distinctClause);
Node_Copy(from, newnode, into); COPY_NODE_FIELD(into);
Node_Copy(from, newnode, intoColNames); COPY_NODE_FIELD(intoColNames);
Node_Copy(from, newnode, targetList); COPY_NODE_FIELD(targetList);
Node_Copy(from, newnode, fromClause); COPY_NODE_FIELD(fromClause);
Node_Copy(from, newnode, whereClause); COPY_NODE_FIELD(whereClause);
Node_Copy(from, newnode, groupClause); COPY_NODE_FIELD(groupClause);
Node_Copy(from, newnode, havingClause); COPY_NODE_FIELD(havingClause);
Node_Copy(from, newnode, sortClause); COPY_NODE_FIELD(sortClause);
if (from->portalname) COPY_STRING_FIELD(portalname);
newnode->portalname = pstrdup(from->portalname); COPY_SCALAR_FIELD(binary);
newnode->binary = from->binary; COPY_NODE_FIELD(limitOffset);
Node_Copy(from, newnode, limitOffset); COPY_NODE_FIELD(limitCount);
Node_Copy(from, newnode, limitCount); COPY_NODE_FIELD(forUpdate);
Node_Copy(from, newnode, forUpdate); COPY_SCALAR_FIELD(op);
newnode->op = from->op; COPY_SCALAR_FIELD(all);
newnode->all = from->all; COPY_NODE_FIELD(larg);
Node_Copy(from, newnode, larg); COPY_NODE_FIELD(rarg);
Node_Copy(from, newnode, rarg);
return newnode; return newnode;
} }
...@@ -1964,11 +1794,11 @@ _copySetOperationStmt(SetOperationStmt *from) ...@@ -1964,11 +1794,11 @@ _copySetOperationStmt(SetOperationStmt *from)
{ {
SetOperationStmt *newnode = makeNode(SetOperationStmt); SetOperationStmt *newnode = makeNode(SetOperationStmt);
newnode->op = from->op; COPY_SCALAR_FIELD(op);
newnode->all = from->all; COPY_SCALAR_FIELD(all);
Node_Copy(from, newnode, larg); COPY_NODE_FIELD(larg);
Node_Copy(from, newnode, rarg); COPY_NODE_FIELD(rarg);
newnode->colTypes = listCopy(from->colTypes); COPY_INTLIST_FIELD(colTypes);
return newnode; return newnode;
} }
...@@ -1978,12 +1808,11 @@ _copyAlterTableStmt(AlterTableStmt *from) ...@@ -1978,12 +1808,11 @@ _copyAlterTableStmt(AlterTableStmt *from)
{ {
AlterTableStmt *newnode = makeNode(AlterTableStmt); AlterTableStmt *newnode = makeNode(AlterTableStmt);
newnode->subtype = from->subtype; COPY_SCALAR_FIELD(subtype);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_NODE_FIELD(def);
Node_Copy(from, newnode, def); COPY_SCALAR_FIELD(behavior);
newnode->behavior = from->behavior;
return newnode; return newnode;
} }
...@@ -1993,11 +1822,11 @@ _copyGrantStmt(GrantStmt *from) ...@@ -1993,11 +1822,11 @@ _copyGrantStmt(GrantStmt *from)
{ {
GrantStmt *newnode = makeNode(GrantStmt); GrantStmt *newnode = makeNode(GrantStmt);
newnode->is_grant = from->is_grant; COPY_SCALAR_FIELD(is_grant);
newnode->objtype = from->objtype; COPY_SCALAR_FIELD(objtype);
Node_Copy(from, newnode, objects); COPY_NODE_FIELD(objects);
newnode->privileges = listCopy(from->privileges); COPY_INTLIST_FIELD(privileges);
Node_Copy(from, newnode, grantees); COPY_NODE_FIELD(grantees);
return newnode; return newnode;
} }
...@@ -2007,10 +1836,8 @@ _copyPrivGrantee(PrivGrantee *from) ...@@ -2007,10 +1836,8 @@ _copyPrivGrantee(PrivGrantee *from)
{ {
PrivGrantee *newnode = makeNode(PrivGrantee); PrivGrantee *newnode = makeNode(PrivGrantee);
if (from->username) COPY_STRING_FIELD(username);
newnode->username = pstrdup(from->username); COPY_STRING_FIELD(groupname);
if (from->groupname)
newnode->groupname = pstrdup(from->groupname);
return newnode; return newnode;
} }
...@@ -2020,8 +1847,8 @@ _copyFuncWithArgs(FuncWithArgs *from) ...@@ -2020,8 +1847,8 @@ _copyFuncWithArgs(FuncWithArgs *from)
{ {
FuncWithArgs *newnode = makeNode(FuncWithArgs); FuncWithArgs *newnode = makeNode(FuncWithArgs);
Node_Copy(from, newnode, funcname); COPY_NODE_FIELD(funcname);
Node_Copy(from, newnode, funcargs); COPY_NODE_FIELD(funcargs);
return newnode; return newnode;
} }
...@@ -2040,8 +1867,7 @@ _copyClosePortalStmt(ClosePortalStmt *from) ...@@ -2040,8 +1867,7 @@ _copyClosePortalStmt(ClosePortalStmt *from)
{ {
ClosePortalStmt *newnode = makeNode(ClosePortalStmt); ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
if (from->portalname) COPY_STRING_FIELD(portalname);
newnode->portalname = pstrdup(from->portalname);
return newnode; return newnode;
} }
...@@ -2051,9 +1877,8 @@ _copyClusterStmt(ClusterStmt *from) ...@@ -2051,9 +1877,8 @@ _copyClusterStmt(ClusterStmt *from)
{ {
ClusterStmt *newnode = makeNode(ClusterStmt); ClusterStmt *newnode = makeNode(ClusterStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
if (from->indexname) COPY_STRING_FIELD(indexname);
newnode->indexname = pstrdup(from->indexname);
return newnode; return newnode;
} }
...@@ -2063,12 +1888,11 @@ _copyCopyStmt(CopyStmt *from) ...@@ -2063,12 +1888,11 @@ _copyCopyStmt(CopyStmt *from)
{ {
CopyStmt *newnode = makeNode(CopyStmt); CopyStmt *newnode = makeNode(CopyStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
Node_Copy(from, newnode, attlist); COPY_NODE_FIELD(attlist);
newnode->is_from = from->is_from; COPY_SCALAR_FIELD(is_from);
if (from->filename) COPY_STRING_FIELD(filename);
newnode->filename = pstrdup(from->filename); COPY_NODE_FIELD(options);
Node_Copy(from, newnode, options);
return newnode; return newnode;
} }
...@@ -2078,12 +1902,12 @@ _copyCreateStmt(CreateStmt *from) ...@@ -2078,12 +1902,12 @@ _copyCreateStmt(CreateStmt *from)
{ {
CreateStmt *newnode = makeNode(CreateStmt); CreateStmt *newnode = makeNode(CreateStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
Node_Copy(from, newnode, tableElts); COPY_NODE_FIELD(tableElts);
Node_Copy(from, newnode, inhRelations); COPY_NODE_FIELD(inhRelations);
Node_Copy(from, newnode, constraints); COPY_NODE_FIELD(constraints);
newnode->hasoids = from->hasoids; COPY_SCALAR_FIELD(hasoids);
newnode->oncommit = from->oncommit; COPY_SCALAR_FIELD(oncommit);
return newnode; return newnode;
} }
...@@ -2093,9 +1917,9 @@ _copyDefineStmt(DefineStmt *from) ...@@ -2093,9 +1917,9 @@ _copyDefineStmt(DefineStmt *from)
{ {
DefineStmt *newnode = makeNode(DefineStmt); DefineStmt *newnode = makeNode(DefineStmt);
newnode->defType = from->defType; COPY_SCALAR_FIELD(defType);
Node_Copy(from, newnode, defnames); COPY_NODE_FIELD(defnames);
Node_Copy(from, newnode, definition); COPY_NODE_FIELD(definition);
return newnode; return newnode;
} }
...@@ -2105,9 +1929,9 @@ _copyDropStmt(DropStmt *from) ...@@ -2105,9 +1929,9 @@ _copyDropStmt(DropStmt *from)
{ {
DropStmt *newnode = makeNode(DropStmt); DropStmt *newnode = makeNode(DropStmt);
Node_Copy(from, newnode, objects); COPY_NODE_FIELD(objects);
newnode->removeType = from->removeType; COPY_SCALAR_FIELD(removeType);
newnode->behavior = from->behavior; COPY_SCALAR_FIELD(behavior);
return newnode; return newnode;
} }
...@@ -2117,7 +1941,7 @@ _copyTruncateStmt(TruncateStmt *from) ...@@ -2117,7 +1941,7 @@ _copyTruncateStmt(TruncateStmt *from)
{ {
TruncateStmt *newnode = makeNode(TruncateStmt); TruncateStmt *newnode = makeNode(TruncateStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
return newnode; return newnode;
} }
...@@ -2127,11 +1951,10 @@ _copyCommentStmt(CommentStmt *from) ...@@ -2127,11 +1951,10 @@ _copyCommentStmt(CommentStmt *from)
{ {
CommentStmt *newnode = makeNode(CommentStmt); CommentStmt *newnode = makeNode(CommentStmt);
newnode->objtype = from->objtype; COPY_SCALAR_FIELD(objtype);
Node_Copy(from, newnode, objname); COPY_NODE_FIELD(objname);
Node_Copy(from, newnode, objargs); COPY_NODE_FIELD(objargs);
if (from->comment) COPY_STRING_FIELD(comment);
newnode->comment = pstrdup(from->comment);
return newnode; return newnode;
} }
...@@ -2141,10 +1964,10 @@ _copyFetchStmt(FetchStmt *from) ...@@ -2141,10 +1964,10 @@ _copyFetchStmt(FetchStmt *from)
{ {
FetchStmt *newnode = makeNode(FetchStmt); FetchStmt *newnode = makeNode(FetchStmt);
newnode->direction = from->direction; COPY_SCALAR_FIELD(direction);
newnode->howMany = from->howMany; COPY_SCALAR_FIELD(howMany);
newnode->portalname = pstrdup(from->portalname); COPY_STRING_FIELD(portalname);
newnode->ismove = from->ismove; COPY_SCALAR_FIELD(ismove);
return newnode; return newnode;
} }
...@@ -2154,15 +1977,15 @@ _copyIndexStmt(IndexStmt *from) ...@@ -2154,15 +1977,15 @@ _copyIndexStmt(IndexStmt *from)
{ {
IndexStmt *newnode = makeNode(IndexStmt); IndexStmt *newnode = makeNode(IndexStmt);
newnode->idxname = pstrdup(from->idxname); COPY_STRING_FIELD(idxname);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
newnode->accessMethod = pstrdup(from->accessMethod); COPY_STRING_FIELD(accessMethod);
Node_Copy(from, newnode, indexParams); COPY_NODE_FIELD(indexParams);
Node_Copy(from, newnode, whereClause); COPY_NODE_FIELD(whereClause);
Node_Copy(from, newnode, rangetable); COPY_NODE_FIELD(rangetable);
newnode->unique = from->unique; COPY_SCALAR_FIELD(unique);
newnode->primary = from->primary; COPY_SCALAR_FIELD(primary);
newnode->isconstraint = from->isconstraint; COPY_SCALAR_FIELD(isconstraint);
return newnode; return newnode;
} }
...@@ -2172,12 +1995,12 @@ _copyCreateFunctionStmt(CreateFunctionStmt *from) ...@@ -2172,12 +1995,12 @@ _copyCreateFunctionStmt(CreateFunctionStmt *from)
{ {
CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt); CreateFunctionStmt *newnode = makeNode(CreateFunctionStmt);
newnode->replace = from->replace; COPY_SCALAR_FIELD(replace);
Node_Copy(from, newnode, funcname); COPY_NODE_FIELD(funcname);
Node_Copy(from, newnode, argTypes); COPY_NODE_FIELD(argTypes);
Node_Copy(from, newnode, returnType); COPY_NODE_FIELD(returnType);
Node_Copy(from, newnode, options); COPY_NODE_FIELD(options);
Node_Copy(from, newnode, withClause); COPY_NODE_FIELD(withClause);
return newnode; return newnode;
} }
...@@ -2187,9 +2010,9 @@ _copyRemoveAggrStmt(RemoveAggrStmt *from) ...@@ -2187,9 +2010,9 @@ _copyRemoveAggrStmt(RemoveAggrStmt *from)
{ {
RemoveAggrStmt *newnode = makeNode(RemoveAggrStmt); RemoveAggrStmt *newnode = makeNode(RemoveAggrStmt);
Node_Copy(from, newnode, aggname); COPY_NODE_FIELD(aggname);
Node_Copy(from, newnode, aggtype); COPY_NODE_FIELD(aggtype);
newnode->behavior = from->behavior; COPY_SCALAR_FIELD(behavior);
return newnode; return newnode;
} }
...@@ -2199,9 +2022,9 @@ _copyRemoveFuncStmt(RemoveFuncStmt *from) ...@@ -2199,9 +2022,9 @@ _copyRemoveFuncStmt(RemoveFuncStmt *from)
{ {
RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt); RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
Node_Copy(from, newnode, funcname); COPY_NODE_FIELD(funcname);
Node_Copy(from, newnode, args); COPY_NODE_FIELD(args);
newnode->behavior = from->behavior; COPY_SCALAR_FIELD(behavior);
return newnode; return newnode;
} }
...@@ -2211,9 +2034,9 @@ _copyRemoveOperStmt(RemoveOperStmt *from) ...@@ -2211,9 +2034,9 @@ _copyRemoveOperStmt(RemoveOperStmt *from)
{ {
RemoveOperStmt *newnode = makeNode(RemoveOperStmt); RemoveOperStmt *newnode = makeNode(RemoveOperStmt);
Node_Copy(from, newnode, opname); COPY_NODE_FIELD(opname);
Node_Copy(from, newnode, args); COPY_NODE_FIELD(args);
newnode->behavior = from->behavior; COPY_SCALAR_FIELD(behavior);
return newnode; return newnode;
} }
...@@ -2223,10 +2046,9 @@ _copyRemoveOpClassStmt(RemoveOpClassStmt *from) ...@@ -2223,10 +2046,9 @@ _copyRemoveOpClassStmt(RemoveOpClassStmt *from)
{ {
RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt); RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
Node_Copy(from, newnode, opclassname); COPY_NODE_FIELD(opclassname);
if (from->amname) COPY_STRING_FIELD(amname);
newnode->amname = pstrdup(from->amname); COPY_SCALAR_FIELD(behavior);
newnode->behavior = from->behavior;
return newnode; return newnode;
} }
...@@ -2236,12 +2058,10 @@ _copyRenameStmt(RenameStmt *from) ...@@ -2236,12 +2058,10 @@ _copyRenameStmt(RenameStmt *from)
{ {
RenameStmt *newnode = makeNode(RenameStmt); RenameStmt *newnode = makeNode(RenameStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
if (from->oldname) COPY_STRING_FIELD(oldname);
newnode->oldname = pstrdup(from->oldname); COPY_STRING_FIELD(newname);
if (from->newname) COPY_SCALAR_FIELD(renameType);
newnode->newname = pstrdup(from->newname);
newnode->renameType = from->renameType;
return newnode; return newnode;
} }
...@@ -2251,13 +2071,13 @@ _copyRuleStmt(RuleStmt *from) ...@@ -2251,13 +2071,13 @@ _copyRuleStmt(RuleStmt *from)
{ {
RuleStmt *newnode = makeNode(RuleStmt); RuleStmt *newnode = makeNode(RuleStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
newnode->rulename = pstrdup(from->rulename); COPY_STRING_FIELD(rulename);
Node_Copy(from, newnode, whereClause); COPY_NODE_FIELD(whereClause);
newnode->event = from->event; COPY_SCALAR_FIELD(event);
newnode->instead = from->instead; COPY_SCALAR_FIELD(instead);
newnode->replace = from->replace; COPY_NODE_FIELD(actions);
Node_Copy(from, newnode, actions); COPY_SCALAR_FIELD(replace);
return newnode; return newnode;
} }
...@@ -2267,7 +2087,7 @@ _copyNotifyStmt(NotifyStmt *from) ...@@ -2267,7 +2087,7 @@ _copyNotifyStmt(NotifyStmt *from)
{ {
NotifyStmt *newnode = makeNode(NotifyStmt); NotifyStmt *newnode = makeNode(NotifyStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
return newnode; return newnode;
} }
...@@ -2277,7 +2097,7 @@ _copyListenStmt(ListenStmt *from) ...@@ -2277,7 +2097,7 @@ _copyListenStmt(ListenStmt *from)
{ {
ListenStmt *newnode = makeNode(ListenStmt); ListenStmt *newnode = makeNode(ListenStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
return newnode; return newnode;
} }
...@@ -2287,7 +2107,7 @@ _copyUnlistenStmt(UnlistenStmt *from) ...@@ -2287,7 +2107,7 @@ _copyUnlistenStmt(UnlistenStmt *from)
{ {
UnlistenStmt *newnode = makeNode(UnlistenStmt); UnlistenStmt *newnode = makeNode(UnlistenStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
return newnode; return newnode;
} }
...@@ -2297,8 +2117,8 @@ _copyTransactionStmt(TransactionStmt *from) ...@@ -2297,8 +2117,8 @@ _copyTransactionStmt(TransactionStmt *from)
{ {
TransactionStmt *newnode = makeNode(TransactionStmt); TransactionStmt *newnode = makeNode(TransactionStmt);
newnode->command = from->command; COPY_SCALAR_FIELD(command);
Node_Copy(from, newnode, options); COPY_NODE_FIELD(options);
return newnode; return newnode;
} }
...@@ -2308,8 +2128,8 @@ _copyCompositeTypeStmt(CompositeTypeStmt *from) ...@@ -2308,8 +2128,8 @@ _copyCompositeTypeStmt(CompositeTypeStmt *from)
{ {
CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt); CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt);
Node_Copy(from, newnode, typevar); COPY_NODE_FIELD(typevar);
Node_Copy(from, newnode, coldeflist); COPY_NODE_FIELD(coldeflist);
return newnode; return newnode;
} }
...@@ -2319,10 +2139,10 @@ _copyViewStmt(ViewStmt *from) ...@@ -2319,10 +2139,10 @@ _copyViewStmt(ViewStmt *from)
{ {
ViewStmt *newnode = makeNode(ViewStmt); ViewStmt *newnode = makeNode(ViewStmt);
Node_Copy(from, newnode, view); COPY_NODE_FIELD(view);
Node_Copy(from, newnode, aliases); COPY_NODE_FIELD(aliases);
Node_Copy(from, newnode, query); COPY_NODE_FIELD(query);
newnode->replace = from->replace; COPY_SCALAR_FIELD(replace);
return newnode; return newnode;
} }
...@@ -2332,8 +2152,7 @@ _copyLoadStmt(LoadStmt *from) ...@@ -2332,8 +2152,7 @@ _copyLoadStmt(LoadStmt *from)
{ {
LoadStmt *newnode = makeNode(LoadStmt); LoadStmt *newnode = makeNode(LoadStmt);
if (from->filename) COPY_STRING_FIELD(filename);
newnode->filename = pstrdup(from->filename);
return newnode; return newnode;
} }
...@@ -2343,9 +2162,9 @@ _copyCreateDomainStmt(CreateDomainStmt *from) ...@@ -2343,9 +2162,9 @@ _copyCreateDomainStmt(CreateDomainStmt *from)
{ {
CreateDomainStmt *newnode = makeNode(CreateDomainStmt); CreateDomainStmt *newnode = makeNode(CreateDomainStmt);
Node_Copy(from, newnode, domainname); COPY_NODE_FIELD(domainname);
Node_Copy(from, newnode, typename); COPY_NODE_FIELD(typename);
Node_Copy(from, newnode, constraints); COPY_NODE_FIELD(constraints);
return newnode; return newnode;
} }
...@@ -2355,12 +2174,11 @@ _copyCreateOpClassStmt(CreateOpClassStmt *from) ...@@ -2355,12 +2174,11 @@ _copyCreateOpClassStmt(CreateOpClassStmt *from)
{ {
CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt); CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
Node_Copy(from, newnode, opclassname); COPY_NODE_FIELD(opclassname);
if (from->amname) COPY_STRING_FIELD(amname);
newnode->amname = pstrdup(from->amname); COPY_NODE_FIELD(datatype);
Node_Copy(from, newnode, datatype); COPY_NODE_FIELD(items);
Node_Copy(from, newnode, items); COPY_SCALAR_FIELD(isDefault);
newnode->isDefault = from->isDefault;
return newnode; return newnode;
} }
...@@ -2370,12 +2188,12 @@ _copyCreateOpClassItem(CreateOpClassItem *from) ...@@ -2370,12 +2188,12 @@ _copyCreateOpClassItem(CreateOpClassItem *from)
{ {
CreateOpClassItem *newnode = makeNode(CreateOpClassItem); CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
newnode->itemtype = from->itemtype; COPY_SCALAR_FIELD(itemtype);
Node_Copy(from, newnode, name); COPY_NODE_FIELD(name);
Node_Copy(from, newnode, args); COPY_NODE_FIELD(args);
newnode->number = from->number; COPY_SCALAR_FIELD(number);
newnode->recheck = from->recheck; COPY_SCALAR_FIELD(recheck);
Node_Copy(from, newnode, storedtype); COPY_NODE_FIELD(storedtype);
return newnode; return newnode;
} }
...@@ -2385,9 +2203,8 @@ _copyCreatedbStmt(CreatedbStmt *from) ...@@ -2385,9 +2203,8 @@ _copyCreatedbStmt(CreatedbStmt *from)
{ {
CreatedbStmt *newnode = makeNode(CreatedbStmt); CreatedbStmt *newnode = makeNode(CreatedbStmt);
if (from->dbname) COPY_STRING_FIELD(dbname);
newnode->dbname = pstrdup(from->dbname); COPY_NODE_FIELD(options);
Node_Copy(from, newnode, options);
return newnode; return newnode;
} }
...@@ -2397,11 +2214,9 @@ _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from) ...@@ -2397,11 +2214,9 @@ _copyAlterDatabaseSetStmt(AlterDatabaseSetStmt *from)
{ {
AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt); AlterDatabaseSetStmt *newnode = makeNode(AlterDatabaseSetStmt);
if (from->dbname) COPY_STRING_FIELD(dbname);
newnode->dbname = pstrdup(from->dbname); COPY_STRING_FIELD(variable);
if (from->variable) COPY_NODE_FIELD(value);
newnode->variable = pstrdup(from->variable);
Node_Copy(from, newnode, value);
return newnode; return newnode;
} }
...@@ -2411,8 +2226,7 @@ _copyDropdbStmt(DropdbStmt *from) ...@@ -2411,8 +2226,7 @@ _copyDropdbStmt(DropdbStmt *from)
{ {
DropdbStmt *newnode = makeNode(DropdbStmt); DropdbStmt *newnode = makeNode(DropdbStmt);
if (from->dbname) COPY_STRING_FIELD(dbname);
newnode->dbname = pstrdup(from->dbname);
return newnode; return newnode;
} }
...@@ -2422,13 +2236,13 @@ _copyVacuumStmt(VacuumStmt *from) ...@@ -2422,13 +2236,13 @@ _copyVacuumStmt(VacuumStmt *from)
{ {
VacuumStmt *newnode = makeNode(VacuumStmt); VacuumStmt *newnode = makeNode(VacuumStmt);
newnode->vacuum = from->vacuum; COPY_SCALAR_FIELD(vacuum);
newnode->full = from->full; COPY_SCALAR_FIELD(full);
newnode->analyze = from->analyze; COPY_SCALAR_FIELD(analyze);
newnode->freeze = from->freeze; COPY_SCALAR_FIELD(freeze);
newnode->verbose = from->verbose; COPY_SCALAR_FIELD(verbose);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
Node_Copy(from, newnode, va_cols); COPY_NODE_FIELD(va_cols);
return newnode; return newnode;
} }
...@@ -2438,9 +2252,9 @@ _copyExplainStmt(ExplainStmt *from) ...@@ -2438,9 +2252,9 @@ _copyExplainStmt(ExplainStmt *from)
{ {
ExplainStmt *newnode = makeNode(ExplainStmt); ExplainStmt *newnode = makeNode(ExplainStmt);
Node_Copy(from, newnode, query); COPY_NODE_FIELD(query);
newnode->verbose = from->verbose; COPY_SCALAR_FIELD(verbose);
newnode->analyze = from->analyze; COPY_SCALAR_FIELD(analyze);
return newnode; return newnode;
} }
...@@ -2450,8 +2264,8 @@ _copyCreateSeqStmt(CreateSeqStmt *from) ...@@ -2450,8 +2264,8 @@ _copyCreateSeqStmt(CreateSeqStmt *from)
{ {
CreateSeqStmt *newnode = makeNode(CreateSeqStmt); CreateSeqStmt *newnode = makeNode(CreateSeqStmt);
Node_Copy(from, newnode, sequence); COPY_NODE_FIELD(sequence);
Node_Copy(from, newnode, options); COPY_NODE_FIELD(options);
return newnode; return newnode;
} }
...@@ -2461,10 +2275,9 @@ _copyVariableSetStmt(VariableSetStmt *from) ...@@ -2461,10 +2275,9 @@ _copyVariableSetStmt(VariableSetStmt *from)
{ {
VariableSetStmt *newnode = makeNode(VariableSetStmt); VariableSetStmt *newnode = makeNode(VariableSetStmt);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_NODE_FIELD(args);
Node_Copy(from, newnode, args); COPY_SCALAR_FIELD(is_local);
newnode->is_local = from->is_local;
return newnode; return newnode;
} }
...@@ -2474,8 +2287,7 @@ _copyVariableShowStmt(VariableShowStmt *from) ...@@ -2474,8 +2287,7 @@ _copyVariableShowStmt(VariableShowStmt *from)
{ {
VariableShowStmt *newnode = makeNode(VariableShowStmt); VariableShowStmt *newnode = makeNode(VariableShowStmt);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name);
return newnode; return newnode;
} }
...@@ -2485,8 +2297,7 @@ _copyVariableResetStmt(VariableResetStmt *from) ...@@ -2485,8 +2297,7 @@ _copyVariableResetStmt(VariableResetStmt *from)
{ {
VariableResetStmt *newnode = makeNode(VariableResetStmt); VariableResetStmt *newnode = makeNode(VariableResetStmt);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name);
return newnode; return newnode;
} }
...@@ -2496,18 +2307,17 @@ _copyCreateTrigStmt(CreateTrigStmt *from) ...@@ -2496,18 +2307,17 @@ _copyCreateTrigStmt(CreateTrigStmt *from)
{ {
CreateTrigStmt *newnode = makeNode(CreateTrigStmt); CreateTrigStmt *newnode = makeNode(CreateTrigStmt);
if (from->trigname) COPY_STRING_FIELD(trigname);
newnode->trigname = pstrdup(from->trigname); COPY_NODE_FIELD(relation);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(funcname);
Node_Copy(from, newnode, funcname); COPY_NODE_FIELD(args);
Node_Copy(from, newnode, args); COPY_SCALAR_FIELD(before);
newnode->before = from->before; COPY_SCALAR_FIELD(row);
newnode->row = from->row; strcpy(newnode->actions, from->actions); /* in-line string field */
memcpy(newnode->actions, from->actions, sizeof(from->actions)); COPY_SCALAR_FIELD(isconstraint);
newnode->isconstraint = from->isconstraint; COPY_SCALAR_FIELD(deferrable);
newnode->deferrable = from->deferrable; COPY_SCALAR_FIELD(initdeferred);
newnode->initdeferred = from->initdeferred; COPY_NODE_FIELD(constrrel);
Node_Copy(from, newnode, constrrel);
return newnode; return newnode;
} }
...@@ -2517,11 +2327,10 @@ _copyDropPropertyStmt(DropPropertyStmt *from) ...@@ -2517,11 +2327,10 @@ _copyDropPropertyStmt(DropPropertyStmt *from)
{ {
DropPropertyStmt *newnode = makeNode(DropPropertyStmt); DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
if (from->property) COPY_STRING_FIELD(property);
newnode->property = pstrdup(from->property); COPY_SCALAR_FIELD(removeType);
newnode->removeType = from->removeType; COPY_SCALAR_FIELD(behavior);
newnode->behavior = from->behavior;
return newnode; return newnode;
} }
...@@ -2531,11 +2340,10 @@ _copyCreatePLangStmt(CreatePLangStmt *from) ...@@ -2531,11 +2340,10 @@ _copyCreatePLangStmt(CreatePLangStmt *from)
{ {
CreatePLangStmt *newnode = makeNode(CreatePLangStmt); CreatePLangStmt *newnode = makeNode(CreatePLangStmt);
if (from->plname) COPY_STRING_FIELD(plname);
newnode->plname = pstrdup(from->plname); COPY_NODE_FIELD(plhandler);
Node_Copy(from, newnode, plhandler); COPY_NODE_FIELD(plvalidator);
Node_Copy(from, newnode, plvalidator); COPY_SCALAR_FIELD(pltrusted);
newnode->pltrusted = from->pltrusted;
return newnode; return newnode;
} }
...@@ -2545,9 +2353,8 @@ _copyDropPLangStmt(DropPLangStmt *from) ...@@ -2545,9 +2353,8 @@ _copyDropPLangStmt(DropPLangStmt *from)
{ {
DropPLangStmt *newnode = makeNode(DropPLangStmt); DropPLangStmt *newnode = makeNode(DropPLangStmt);
if (from->plname) COPY_STRING_FIELD(plname);
newnode->plname = pstrdup(from->plname); COPY_SCALAR_FIELD(behavior);
newnode->behavior = from->behavior;
return newnode; return newnode;
} }
...@@ -2557,9 +2364,8 @@ _copyCreateUserStmt(CreateUserStmt *from) ...@@ -2557,9 +2364,8 @@ _copyCreateUserStmt(CreateUserStmt *from)
{ {
CreateUserStmt *newnode = makeNode(CreateUserStmt); CreateUserStmt *newnode = makeNode(CreateUserStmt);
if (from->user) COPY_STRING_FIELD(user);
newnode->user = pstrdup(from->user); COPY_NODE_FIELD(options);
Node_Copy(from, newnode, options);
return newnode; return newnode;
} }
...@@ -2569,9 +2375,8 @@ _copyAlterUserStmt(AlterUserStmt *from) ...@@ -2569,9 +2375,8 @@ _copyAlterUserStmt(AlterUserStmt *from)
{ {
AlterUserStmt *newnode = makeNode(AlterUserStmt); AlterUserStmt *newnode = makeNode(AlterUserStmt);
if (from->user) COPY_STRING_FIELD(user);
newnode->user = pstrdup(from->user); COPY_NODE_FIELD(options);
Node_Copy(from, newnode, options);
return newnode; return newnode;
} }
...@@ -2581,11 +2386,9 @@ _copyAlterUserSetStmt(AlterUserSetStmt *from) ...@@ -2581,11 +2386,9 @@ _copyAlterUserSetStmt(AlterUserSetStmt *from)
{ {
AlterUserSetStmt *newnode = makeNode(AlterUserSetStmt); AlterUserSetStmt *newnode = makeNode(AlterUserSetStmt);
if (from->user) COPY_STRING_FIELD(user);
newnode->user = pstrdup(from->user); COPY_STRING_FIELD(variable);
if (from->variable) COPY_NODE_FIELD(value);
newnode->variable = pstrdup(from->variable);
Node_Copy(from, newnode, value);
return newnode; return newnode;
} }
...@@ -2595,7 +2398,7 @@ _copyDropUserStmt(DropUserStmt *from) ...@@ -2595,7 +2398,7 @@ _copyDropUserStmt(DropUserStmt *from)
{ {
DropUserStmt *newnode = makeNode(DropUserStmt); DropUserStmt *newnode = makeNode(DropUserStmt);
Node_Copy(from, newnode, users); COPY_NODE_FIELD(users);
return newnode; return newnode;
} }
...@@ -2605,9 +2408,8 @@ _copyLockStmt(LockStmt *from) ...@@ -2605,9 +2408,8 @@ _copyLockStmt(LockStmt *from)
{ {
LockStmt *newnode = makeNode(LockStmt); LockStmt *newnode = makeNode(LockStmt);
Node_Copy(from, newnode, relations); COPY_NODE_FIELD(relations);
COPY_SCALAR_FIELD(mode);
newnode->mode = from->mode;
return newnode; return newnode;
} }
...@@ -2617,8 +2419,8 @@ _copyConstraintsSetStmt(ConstraintsSetStmt *from) ...@@ -2617,8 +2419,8 @@ _copyConstraintsSetStmt(ConstraintsSetStmt *from)
{ {
ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt); ConstraintsSetStmt *newnode = makeNode(ConstraintsSetStmt);
Node_Copy(from, newnode, constraints); COPY_NODE_FIELD(constraints);
newnode->deferred = from->deferred; COPY_SCALAR_FIELD(deferred);
return newnode; return newnode;
} }
...@@ -2628,9 +2430,8 @@ _copyCreateGroupStmt(CreateGroupStmt *from) ...@@ -2628,9 +2430,8 @@ _copyCreateGroupStmt(CreateGroupStmt *from)
{ {
CreateGroupStmt *newnode = makeNode(CreateGroupStmt); CreateGroupStmt *newnode = makeNode(CreateGroupStmt);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_NODE_FIELD(options);
Node_Copy(from, newnode, options);
return newnode; return newnode;
} }
...@@ -2640,10 +2441,9 @@ _copyAlterGroupStmt(AlterGroupStmt *from) ...@@ -2640,10 +2441,9 @@ _copyAlterGroupStmt(AlterGroupStmt *from)
{ {
AlterGroupStmt *newnode = makeNode(AlterGroupStmt); AlterGroupStmt *newnode = makeNode(AlterGroupStmt);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_SCALAR_FIELD(action);
newnode->action = from->action; COPY_NODE_FIELD(listUsers);
Node_Copy(from, newnode, listUsers);
return newnode; return newnode;
} }
...@@ -2653,8 +2453,7 @@ _copyDropGroupStmt(DropGroupStmt *from) ...@@ -2653,8 +2453,7 @@ _copyDropGroupStmt(DropGroupStmt *from)
{ {
DropGroupStmt *newnode = makeNode(DropGroupStmt); DropGroupStmt *newnode = makeNode(DropGroupStmt);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name);
return newnode; return newnode;
} }
...@@ -2664,12 +2463,11 @@ _copyReindexStmt(ReindexStmt *from) ...@@ -2664,12 +2463,11 @@ _copyReindexStmt(ReindexStmt *from)
{ {
ReindexStmt *newnode = makeNode(ReindexStmt); ReindexStmt *newnode = makeNode(ReindexStmt);
newnode->reindexType = from->reindexType; COPY_SCALAR_FIELD(reindexType);
Node_Copy(from, newnode, relation); COPY_NODE_FIELD(relation);
if (from->name) COPY_STRING_FIELD(name);
newnode->name = pstrdup(from->name); COPY_SCALAR_FIELD(force);
newnode->force = from->force; COPY_SCALAR_FIELD(all);
newnode->all = from->all;
return newnode; return newnode;
} }
...@@ -2679,10 +2477,9 @@ _copyCreateSchemaStmt(CreateSchemaStmt *from) ...@@ -2679,10 +2477,9 @@ _copyCreateSchemaStmt(CreateSchemaStmt *from)
{ {
CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt); CreateSchemaStmt *newnode = makeNode(CreateSchemaStmt);
newnode->schemaname = pstrdup(from->schemaname); COPY_STRING_FIELD(schemaname);
if (from->authid) COPY_STRING_FIELD(authid);
newnode->authid = pstrdup(from->authid); COPY_NODE_FIELD(schemaElts);
Node_Copy(from, newnode, schemaElts);
return newnode; return newnode;
} }
...@@ -2692,11 +2489,11 @@ _copyCreateConversionStmt(CreateConversionStmt *from) ...@@ -2692,11 +2489,11 @@ _copyCreateConversionStmt(CreateConversionStmt *from)
{ {
CreateConversionStmt *newnode = makeNode(CreateConversionStmt); CreateConversionStmt *newnode = makeNode(CreateConversionStmt);
Node_Copy(from, newnode, conversion_name); COPY_NODE_FIELD(conversion_name);
newnode->for_encoding_name = pstrdup(from->for_encoding_name); COPY_STRING_FIELD(for_encoding_name);
newnode->to_encoding_name = pstrdup(from->to_encoding_name); COPY_STRING_FIELD(to_encoding_name);
Node_Copy(from, newnode, func_name); COPY_NODE_FIELD(func_name);
newnode->def = from->def; COPY_SCALAR_FIELD(def);
return newnode; return newnode;
} }
...@@ -2706,10 +2503,10 @@ _copyCreateCastStmt(CreateCastStmt *from) ...@@ -2706,10 +2503,10 @@ _copyCreateCastStmt(CreateCastStmt *from)
{ {
CreateCastStmt *newnode = makeNode(CreateCastStmt); CreateCastStmt *newnode = makeNode(CreateCastStmt);
Node_Copy(from, newnode, sourcetype); COPY_NODE_FIELD(sourcetype);
Node_Copy(from, newnode, targettype); COPY_NODE_FIELD(targettype);
Node_Copy(from, newnode, func); COPY_NODE_FIELD(func);
newnode->context = from->context; COPY_SCALAR_FIELD(context);
return newnode; return newnode;
} }
...@@ -2719,9 +2516,9 @@ _copyDropCastStmt(DropCastStmt *from) ...@@ -2719,9 +2516,9 @@ _copyDropCastStmt(DropCastStmt *from)
{ {
DropCastStmt *newnode = makeNode(DropCastStmt); DropCastStmt *newnode = makeNode(DropCastStmt);
Node_Copy(from, newnode, sourcetype); COPY_NODE_FIELD(sourcetype);
Node_Copy(from, newnode, targettype); COPY_NODE_FIELD(targettype);
newnode->behavior = from->behavior; COPY_SCALAR_FIELD(behavior);
return newnode; return newnode;
} }
...@@ -2731,10 +2528,10 @@ _copyPrepareStmt(PrepareStmt *from) ...@@ -2731,10 +2528,10 @@ _copyPrepareStmt(PrepareStmt *from)
{ {
PrepareStmt *newnode = makeNode(PrepareStmt); PrepareStmt *newnode = makeNode(PrepareStmt);
newnode->name = pstrdup(from->name); COPY_STRING_FIELD(name);
Node_Copy(from, newnode, argtypes); COPY_NODE_FIELD(argtypes);
newnode->argtype_oids = listCopy(from->argtype_oids); COPY_INTLIST_FIELD(argtype_oids);
Node_Copy(from, newnode, query); COPY_NODE_FIELD(query);
return newnode; return newnode;
} }
...@@ -2744,9 +2541,9 @@ _copyExecuteStmt(ExecuteStmt *from) ...@@ -2744,9 +2541,9 @@ _copyExecuteStmt(ExecuteStmt *from)
{ {
ExecuteStmt *newnode = makeNode(ExecuteStmt); ExecuteStmt *newnode = makeNode(ExecuteStmt);
newnode->name = pstrdup(from->name); COPY_STRING_FIELD(name);
Node_Copy(from, newnode, into); COPY_NODE_FIELD(into);
Node_Copy(from, newnode, params); COPY_NODE_FIELD(params);
return newnode; return newnode;
} }
...@@ -2756,7 +2553,7 @@ _copyDeallocateStmt(DeallocateStmt *from) ...@@ -2756,7 +2553,7 @@ _copyDeallocateStmt(DeallocateStmt *from)
{ {
DeallocateStmt *newnode = makeNode(DeallocateStmt); DeallocateStmt *newnode = makeNode(DeallocateStmt);
newnode->name = pstrdup(from->name); COPY_STRING_FIELD(name);
return newnode; return newnode;
} }
...@@ -2774,16 +2571,16 @@ _copyValue(Value *from) ...@@ -2774,16 +2571,16 @@ _copyValue(Value *from)
/* See also _copyAConst when changing this code! */ /* See also _copyAConst when changing this code! */
newnode->type = from->type; COPY_SCALAR_FIELD(type);
switch (from->type) switch (from->type)
{ {
case T_Integer: case T_Integer:
newnode->val.ival = from->val.ival; COPY_SCALAR_FIELD(val.ival);
break; break;
case T_Float: case T_Float:
case T_String: case T_String:
case T_BitString: case T_BitString:
newnode->val.str = pstrdup(from->val.str); COPY_STRING_FIELD(val.str);
break; break;
case T_Null: case T_Null:
/* nothing to do */ /* nothing to do */
...@@ -2795,10 +2592,11 @@ _copyValue(Value *from) ...@@ -2795,10 +2592,11 @@ _copyValue(Value *from)
return newnode; return newnode;
} }
/* ---------------- /*
* copyObject returns a copy of the node or list. If it is a list, it * copyObject
* recursively copies its items. *
* ---------------- * Create a copy of a Node tree or list. This is a "deep" copy: all
* substructure is copied too, recursively.
*/ */
void * void *
copyObject(void *from) copyObject(void *from)
...@@ -2889,6 +2687,12 @@ copyObject(void *from) ...@@ -2889,6 +2687,12 @@ copyObject(void *from)
case T_Fjoin: case T_Fjoin:
retval = _copyFjoin(from); retval = _copyFjoin(from);
break; break;
case T_Alias:
retval = _copyAlias(from);
break;
case T_RangeVar:
retval = _copyRangeVar(from);
break;
case T_Expr: case T_Expr:
retval = _copyExpr(from); retval = _copyExpr(from);
break; break;
...@@ -2904,18 +2708,15 @@ copyObject(void *from) ...@@ -2904,18 +2708,15 @@ copyObject(void *from)
case T_Param: case T_Param:
retval = _copyParam(from); retval = _copyParam(from);
break; break;
case T_Func:
retval = _copyFunc(from);
break;
case T_Aggref: case T_Aggref:
retval = _copyAggref(from); retval = _copyAggref(from);
break; break;
case T_SubLink: case T_SubLink:
retval = _copySubLink(from); retval = _copySubLink(from);
break; break;
case T_Func:
retval = _copyFunc(from);
break;
case T_ArrayRef:
retval = _copyArrayRef(from);
break;
case T_FieldSelect: case T_FieldSelect:
retval = _copyFieldSelect(from); retval = _copyFieldSelect(from);
break; break;
...@@ -2925,11 +2726,14 @@ copyObject(void *from) ...@@ -2925,11 +2726,14 @@ copyObject(void *from)
case T_RangeTblRef: case T_RangeTblRef:
retval = _copyRangeTblRef(from); retval = _copyRangeTblRef(from);
break; break;
case T_JoinExpr:
retval = _copyJoinExpr(from);
break;
case T_FromExpr: case T_FromExpr:
retval = _copyFromExpr(from); retval = _copyFromExpr(from);
break; break;
case T_JoinExpr: case T_ArrayRef:
retval = _copyJoinExpr(from); retval = _copyArrayRef(from);
break; break;
/* /*
...@@ -3239,12 +3043,6 @@ copyObject(void *from) ...@@ -3239,12 +3043,6 @@ copyObject(void *from)
case T_SortGroupBy: case T_SortGroupBy:
retval = _copySortGroupBy(from); retval = _copySortGroupBy(from);
break; break;
case T_Alias:
retval = _copyAlias(from);
break;
case T_RangeVar:
retval = _copyRangeVar(from);
break;
case T_RangeSubselect: case T_RangeSubselect:
retval = _copyRangeSubselect(from); retval = _copyRangeSubselect(from);
break; break;
...@@ -3318,5 +3116,6 @@ copyObject(void *from) ...@@ -3318,5 +3116,6 @@ copyObject(void *from)
retval = from; /* keep compiler quiet */ retval = from; /* keep compiler quiet */
break; break;
} }
return retval; return retval;
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.167 2002/11/24 21:52:13 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.168 2002/11/25 03:33:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -32,10 +32,52 @@ ...@@ -32,10 +32,52 @@
#include "utils/datum.h" #include "utils/datum.h"
/*
* Macros to simplify comparison of different kinds of fields. Use these
* wherever possible to reduce the chance for silly typos. Note that these
* hard-wire the convention that the local variables in an Equal routine are
* named 'a' and 'b'.
*/
/* Compare a simple scalar field (int, float, bool, enum, etc) */
#define COMPARE_SCALAR_FIELD(fldname) \
do { \
if (a->fldname != b->fldname) \
return false; \
} while (0)
/* Compare a field that is a pointer to some kind of Node or Node tree */
#define COMPARE_NODE_FIELD(fldname) \
do { \
if (!equal(a->fldname, b->fldname)) \
return false; \
} while (0)
/* Compare a field that is a pointer to a list of integers */
#define COMPARE_INTLIST_FIELD(fldname) \
do { \
if (!equali(a->fldname, b->fldname)) \
return false; \
} while (0)
/* Compare a field that is a pointer to a C string, or perhaps NULL */
#define COMPARE_STRING_FIELD(fldname) \
do { \
if (!equalstr(a->fldname, b->fldname)) \
return false; \
} while (0)
/* Macro for comparing string fields that might be NULL */ /* Macro for comparing string fields that might be NULL */
#define equalstr(a, b) \ #define equalstr(a, b) \
(((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b)) (((a) != NULL && (b) != NULL) ? (strcmp(a, b) == 0) : (a) == (b))
/* Compare a field that is a pointer to a simple palloc'd object of size sz */
#define COMPARE_POINTER_FIELD(fldname, sz) \
do { \
if (memcmp(a->fldname, b->fldname, (sz)) != 0) \
return false; \
} while (0)
/* /*
* Stuff from primnodes.h * Stuff from primnodes.h
...@@ -44,21 +86,14 @@ ...@@ -44,21 +86,14 @@
static bool static bool
_equalResdom(Resdom *a, Resdom *b) _equalResdom(Resdom *a, Resdom *b)
{ {
if (a->resno != b->resno) COMPARE_SCALAR_FIELD(resno);
return false; COMPARE_SCALAR_FIELD(restype);
if (a->restype != b->restype) COMPARE_SCALAR_FIELD(restypmod);
return false; COMPARE_STRING_FIELD(resname);
if (a->restypmod != b->restypmod) COMPARE_SCALAR_FIELD(ressortgroupref);
return false; COMPARE_SCALAR_FIELD(reskey);
if (!equalstr(a->resname, b->resname)) COMPARE_SCALAR_FIELD(reskeyop);
return false; COMPARE_SCALAR_FIELD(resjunk);
if (a->ressortgroupref != b->ressortgroupref)
return false;
if (a->reskey != b->reskey)
return false;
if (a->reskeyop != b->reskeyop)
return false;
/* we ignore resjunk flag ... is this correct? */
return true; return true;
} }
...@@ -66,20 +101,33 @@ _equalResdom(Resdom *a, Resdom *b) ...@@ -66,20 +101,33 @@ _equalResdom(Resdom *a, Resdom *b)
static bool static bool
_equalFjoin(Fjoin *a, Fjoin *b) _equalFjoin(Fjoin *a, Fjoin *b)
{ {
int nNodes; COMPARE_SCALAR_FIELD(fj_initialized);
COMPARE_SCALAR_FIELD(fj_nNodes);
COMPARE_NODE_FIELD(fj_innerNode);
COMPARE_POINTER_FIELD(fj_results, a->fj_nNodes * sizeof(Datum));
COMPARE_POINTER_FIELD(fj_alwaysDone, a->fj_nNodes * sizeof(bool));
if (a->fj_initialized != b->fj_initialized) return true;
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; static bool
if (memcmp(a->fj_results, b->fj_results, nNodes * sizeof(Datum)) != 0) _equalAlias(Alias *a, Alias *b)
return false; {
if (memcmp(a->fj_alwaysDone, b->fj_alwaysDone, nNodes * sizeof(bool)) != 0) COMPARE_STRING_FIELD(aliasname);
return false; COMPARE_NODE_FIELD(colnames);
return true;
}
static bool
_equalRangeVar(RangeVar *a, RangeVar *b)
{
COMPARE_STRING_FIELD(catalogname);
COMPARE_STRING_FIELD(schemaname);
COMPARE_STRING_FIELD(relname);
COMPARE_SCALAR_FIELD(inhOpt);
COMPARE_SCALAR_FIELD(istemp);
COMPARE_NODE_FIELD(alias);
return true; return true;
} }
...@@ -92,12 +140,9 @@ _equalExpr(Expr *a, Expr *b) ...@@ -92,12 +140,9 @@ _equalExpr(Expr *a, Expr *b)
* to set it in created nodes, and it is logically a derivative of the * to set it in created nodes, and it is logically a derivative of the
* oper field anyway. * oper field anyway.
*/ */
if (a->opType != b->opType) COMPARE_SCALAR_FIELD(opType);
return false; COMPARE_NODE_FIELD(oper);
if (!equal(a->oper, b->oper)) COMPARE_NODE_FIELD(args);
return false;
if (!equal(a->args, b->args))
return false;
return true; return true;
} }
...@@ -105,20 +150,13 @@ _equalExpr(Expr *a, Expr *b) ...@@ -105,20 +150,13 @@ _equalExpr(Expr *a, Expr *b)
static bool static bool
_equalVar(Var *a, Var *b) _equalVar(Var *a, Var *b)
{ {
if (a->varno != b->varno) COMPARE_SCALAR_FIELD(varno);
return false; COMPARE_SCALAR_FIELD(varattno);
if (a->varattno != b->varattno) COMPARE_SCALAR_FIELD(vartype);
return false; COMPARE_SCALAR_FIELD(vartypmod);
if (a->vartype != b->vartype) COMPARE_SCALAR_FIELD(varlevelsup);
return false; COMPARE_SCALAR_FIELD(varnoold);
if (a->vartypmod != b->vartypmod) COMPARE_SCALAR_FIELD(varoattno);
return false;
if (a->varlevelsup != b->varlevelsup)
return false;
if (a->varnoold != b->varnoold)
return false;
if (a->varoattno != b->varoattno)
return false;
return true; return true;
} }
...@@ -126,12 +164,9 @@ _equalVar(Var *a, Var *b) ...@@ -126,12 +164,9 @@ _equalVar(Var *a, Var *b)
static bool static bool
_equalOper(Oper *a, Oper *b) _equalOper(Oper *a, Oper *b)
{ {
if (a->opno != b->opno) COMPARE_SCALAR_FIELD(opno);
return false; COMPARE_SCALAR_FIELD(opresulttype);
if (a->opresulttype != b->opresulttype) COMPARE_SCALAR_FIELD(opretset);
return false;
if (a->opretset != b->opretset)
return false;
/* /*
* We do not examine opid or op_fcache, since these are logically * We do not examine opid or op_fcache, since these are logically
...@@ -151,14 +186,10 @@ _equalOper(Oper *a, Oper *b) ...@@ -151,14 +186,10 @@ _equalOper(Oper *a, Oper *b)
static bool static bool
_equalConst(Const *a, Const *b) _equalConst(Const *a, Const *b)
{ {
if (a->consttype != b->consttype) COMPARE_SCALAR_FIELD(consttype);
return false; COMPARE_SCALAR_FIELD(constlen);
if (a->constlen != b->constlen) COMPARE_SCALAR_FIELD(constisnull);
return false; COMPARE_SCALAR_FIELD(constbyval);
if (a->constisnull != b->constisnull)
return false;
if (a->constbyval != b->constbyval)
return false;
/* XXX What about constisset and constiscast? */ /* XXX What about constisset and constiscast? */
/* /*
...@@ -175,30 +206,24 @@ _equalConst(Const *a, Const *b) ...@@ -175,30 +206,24 @@ _equalConst(Const *a, Const *b)
static bool static bool
_equalParam(Param *a, Param *b) _equalParam(Param *a, Param *b)
{ {
if (a->paramkind != b->paramkind) COMPARE_SCALAR_FIELD(paramkind);
return false; COMPARE_SCALAR_FIELD(paramtype);
if (a->paramtype != b->paramtype)
return false;
switch (a->paramkind) switch (a->paramkind)
{ {
case PARAM_NAMED: case PARAM_NAMED:
case PARAM_NEW: case PARAM_NEW:
case PARAM_OLD: case PARAM_OLD:
if (strcmp(a->paramname, b->paramname) != 0) COMPARE_STRING_FIELD(paramname);
return false;
break; break;
case PARAM_NUM: case PARAM_NUM:
case PARAM_EXEC: case PARAM_EXEC:
if (a->paramid != b->paramid) COMPARE_SCALAR_FIELD(paramid);
return false;
break; break;
case PARAM_INVALID: case PARAM_INVALID:
/* /*
* XXX: Hmmm... What are we supposed to return in this case ?? * XXX: Hmmm... What are we supposed to return in this case ??
*/ */
return true;
break; break;
default: default:
elog(ERROR, "_equalParam: Invalid paramkind value: %d", elog(ERROR, "_equalParam: Invalid paramkind value: %d",
...@@ -211,12 +236,9 @@ _equalParam(Param *a, Param *b) ...@@ -211,12 +236,9 @@ _equalParam(Param *a, Param *b)
static bool static bool
_equalFunc(Func *a, Func *b) _equalFunc(Func *a, Func *b)
{ {
if (a->funcid != b->funcid) COMPARE_SCALAR_FIELD(funcid);
return false; COMPARE_SCALAR_FIELD(funcresulttype);
if (a->funcresulttype != b->funcresulttype) COMPARE_SCALAR_FIELD(funcretset);
return false;
if (a->funcretset != b->funcretset)
return false;
/* /*
* Special-case COERCE_DONTCARE, so that pathkeys can build coercion * Special-case COERCE_DONTCARE, so that pathkeys can build coercion
* nodes that are equal() to both explicit and implicit coercions. * nodes that are equal() to both explicit and implicit coercions.
...@@ -234,83 +256,45 @@ _equalFunc(Func *a, Func *b) ...@@ -234,83 +256,45 @@ _equalFunc(Func *a, Func *b)
static bool static bool
_equalAggref(Aggref *a, Aggref *b) _equalAggref(Aggref *a, Aggref *b)
{ {
if (a->aggfnoid != b->aggfnoid) COMPARE_SCALAR_FIELD(aggfnoid);
return false; COMPARE_SCALAR_FIELD(aggtype);
if (a->aggtype != b->aggtype) COMPARE_NODE_FIELD(target);
return false; COMPARE_SCALAR_FIELD(aggstar);
if (!equal(a->target, b->target)) COMPARE_SCALAR_FIELD(aggdistinct);
return false;
if (a->aggstar != b->aggstar)
return false;
if (a->aggdistinct != b->aggdistinct)
return false;
/* ignore aggno, which is only a private field for the executor */ /* ignore aggno, which is only a private field for the executor */
return true; return true;
} }
static bool static bool
_equalSubLink(SubLink *a, SubLink *b) _equalSubLink(SubLink *a, SubLink *b)
{ {
if (a->subLinkType != b->subLinkType) COMPARE_SCALAR_FIELD(subLinkType);
return false; COMPARE_SCALAR_FIELD(useor);
if (a->useor != b->useor) COMPARE_NODE_FIELD(lefthand);
return false; COMPARE_NODE_FIELD(oper);
if (!equal(a->lefthand, b->lefthand)) COMPARE_NODE_FIELD(subselect);
return false;
if (!equal(a->oper, b->oper))
return false;
if (!equal(a->subselect, b->subselect))
return false;
return true;
}
static bool
_equalArrayRef(ArrayRef *a, ArrayRef *b)
{
if (a->refrestype != b->refrestype)
return false;
if (a->refattrlength != b->refattrlength)
return false;
if (a->refelemlength != b->refelemlength)
return false;
if (a->refelembyval != b->refelembyval)
return false;
if (a->refelemalign != b->refelemalign)
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;
if (!equal(a->refassgnexpr, b->refassgnexpr))
return false;
return true; return true;
} }
static bool static bool
_equalFieldSelect(FieldSelect *a, FieldSelect *b) _equalFieldSelect(FieldSelect *a, FieldSelect *b)
{ {
if (!equal(a->arg, b->arg)) COMPARE_NODE_FIELD(arg);
return false; COMPARE_SCALAR_FIELD(fieldnum);
if (a->fieldnum != b->fieldnum) COMPARE_SCALAR_FIELD(resulttype);
return false; COMPARE_SCALAR_FIELD(resulttypmod);
if (a->resulttype != b->resulttype)
return false;
if (a->resulttypmod != b->resulttypmod)
return false;
return true; return true;
} }
static bool static bool
_equalRelabelType(RelabelType *a, RelabelType *b) _equalRelabelType(RelabelType *a, RelabelType *b)
{ {
if (!equal(a->arg, b->arg)) COMPARE_NODE_FIELD(arg);
return false; COMPARE_SCALAR_FIELD(resulttype);
if (a->resulttype != b->resulttype) COMPARE_SCALAR_FIELD(resulttypmod);
return false;
if (a->resulttypmod != b->resulttypmod)
return false;
/* /*
* Special-case COERCE_DONTCARE, so that pathkeys can build coercion * Special-case COERCE_DONTCARE, so that pathkeys can build coercion
* nodes that are equal() to both explicit and implicit coercions. * nodes that are equal() to both explicit and implicit coercions.
...@@ -319,14 +303,29 @@ _equalRelabelType(RelabelType *a, RelabelType *b) ...@@ -319,14 +303,29 @@ _equalRelabelType(RelabelType *a, RelabelType *b)
a->relabelformat != COERCE_DONTCARE && a->relabelformat != COERCE_DONTCARE &&
b->relabelformat != COERCE_DONTCARE) b->relabelformat != COERCE_DONTCARE)
return false; return false;
return true; return true;
} }
static bool static bool
_equalRangeTblRef(RangeTblRef *a, RangeTblRef *b) _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
{ {
if (a->rtindex != b->rtindex) COMPARE_SCALAR_FIELD(rtindex);
return false;
return true;
}
static bool
_equalJoinExpr(JoinExpr *a, JoinExpr *b)
{
COMPARE_SCALAR_FIELD(jointype);
COMPARE_SCALAR_FIELD(isNatural);
COMPARE_NODE_FIELD(larg);
COMPARE_NODE_FIELD(rarg);
COMPARE_NODE_FIELD(using);
COMPARE_NODE_FIELD(quals);
COMPARE_NODE_FIELD(alias);
COMPARE_SCALAR_FIELD(rtindex);
return true; return true;
} }
...@@ -334,37 +333,46 @@ _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b) ...@@ -334,37 +333,46 @@ _equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
static bool static bool
_equalFromExpr(FromExpr *a, FromExpr *b) _equalFromExpr(FromExpr *a, FromExpr *b)
{ {
if (!equal(a->fromlist, b->fromlist)) COMPARE_NODE_FIELD(fromlist);
return false; COMPARE_NODE_FIELD(quals);
if (!equal(a->quals, b->quals))
return false;
return true; return true;
} }
static bool static bool
_equalJoinExpr(JoinExpr *a, JoinExpr *b) _equalArrayRef(ArrayRef *a, ArrayRef *b)
{ {
if (a->jointype != b->jointype) COMPARE_SCALAR_FIELD(refrestype);
return false; COMPARE_SCALAR_FIELD(refattrlength);
if (a->isNatural != b->isNatural) COMPARE_SCALAR_FIELD(refelemlength);
return false; COMPARE_SCALAR_FIELD(refelembyval);
if (!equal(a->larg, b->larg)) COMPARE_SCALAR_FIELD(refelemalign);
return false; COMPARE_NODE_FIELD(refupperindexpr);
if (!equal(a->rarg, b->rarg)) COMPARE_NODE_FIELD(reflowerindexpr);
return false; COMPARE_NODE_FIELD(refexpr);
if (!equal(a->using, b->using)) COMPARE_NODE_FIELD(refassgnexpr);
return false;
if (!equal(a->quals, b->quals))
return false;
if (!equal(a->alias, b->alias))
return false;
if (a->rtindex != b->rtindex)
return false;
return true; return true;
} }
/*
* Stuff from plannodes.h
*/
static bool
_equalSubPlan(SubPlan *a, SubPlan *b)
{
/* should compare plans, but have to settle for comparing plan IDs */
COMPARE_SCALAR_FIELD(plan_id);
COMPARE_NODE_FIELD(rtable);
COMPARE_NODE_FIELD(sublink);
return true;
}
/* /*
* Stuff from relation.h * Stuff from relation.h
*/ */
...@@ -376,7 +384,9 @@ _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b) ...@@ -376,7 +384,9 @@ _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
* We treat RelOptInfos as equal if they refer to the same base rels * We treat RelOptInfos as equal if they refer to the same base rels
* joined in the same order. Is this appropriate/sufficient? * joined in the same order. Is this appropriate/sufficient?
*/ */
return equali(a->relids, b->relids); COMPARE_INTLIST_FIELD(relids);
return true;
} }
static bool static bool
...@@ -386,35 +396,23 @@ _equalIndexOptInfo(IndexOptInfo *a, IndexOptInfo *b) ...@@ -386,35 +396,23 @@ _equalIndexOptInfo(IndexOptInfo *a, IndexOptInfo *b)
* We treat IndexOptInfos as equal if they refer to the same index. Is * We treat IndexOptInfos as equal if they refer to the same index. Is
* this sufficient? * this sufficient?
*/ */
if (a->indexoid != b->indexoid) COMPARE_SCALAR_FIELD(indexoid);
return false;
return true;
}
static bool
_equalPathKeyItem(PathKeyItem *a, PathKeyItem *b)
{
if (a->sortop != b->sortop)
return false;
if (!equal(a->key, b->key))
return false;
return true; return true;
} }
static bool static bool
_equalPath(Path *a, Path *b) _equalPath(Path *a, Path *b)
{ {
if (a->pathtype != b->pathtype) /* This is safe only because _equalRelOptInfo is incomplete... */
return false; COMPARE_NODE_FIELD(parent);
if (!equal(a->parent, b->parent))
return false;
/* /*
* do not check path costs, since they may not be set yet, and being * do not check path costs, since they may not be set yet, and being
* float values there are roundoff error issues anyway... * float values there are roundoff error issues anyway...
*/ */
if (!equal(a->pathkeys, b->pathkeys)) COMPARE_SCALAR_FIELD(pathtype);
return false; COMPARE_NODE_FIELD(pathkeys);
return true; return true;
} }
...@@ -423,12 +421,9 @@ _equalIndexPath(IndexPath *a, IndexPath *b) ...@@ -423,12 +421,9 @@ _equalIndexPath(IndexPath *a, IndexPath *b)
{ {
if (!_equalPath((Path *) a, (Path *) b)) if (!_equalPath((Path *) a, (Path *) b))
return false; return false;
if (!equal(a->indexinfo, b->indexinfo)) COMPARE_NODE_FIELD(indexinfo);
return false; COMPARE_NODE_FIELD(indexqual);
if (!equal(a->indexqual, b->indexqual)) COMPARE_SCALAR_FIELD(indexscandir);
return false;
if (a->indexscandir != b->indexscandir)
return false;
/* /*
* Skip 'rows' because of possibility of floating-point roundoff * Skip 'rows' because of possibility of floating-point roundoff
...@@ -442,10 +437,9 @@ _equalTidPath(TidPath *a, TidPath *b) ...@@ -442,10 +437,9 @@ _equalTidPath(TidPath *a, TidPath *b)
{ {
if (!_equalPath((Path *) a, (Path *) b)) if (!_equalPath((Path *) a, (Path *) b))
return false; return false;
if (!equal(a->tideval, b->tideval)) COMPARE_NODE_FIELD(tideval);
return false; COMPARE_INTLIST_FIELD(unjoined_relids);
if (!equali(a->unjoined_relids, b->unjoined_relids))
return false;
return true; return true;
} }
...@@ -454,8 +448,8 @@ _equalAppendPath(AppendPath *a, AppendPath *b) ...@@ -454,8 +448,8 @@ _equalAppendPath(AppendPath *a, AppendPath *b)
{ {
if (!_equalPath((Path *) a, (Path *) b)) if (!_equalPath((Path *) a, (Path *) b))
return false; return false;
if (!equal(a->subpaths, b->subpaths)) COMPARE_NODE_FIELD(subpaths);
return false;
return true; return true;
} }
...@@ -464,10 +458,9 @@ _equalResultPath(ResultPath *a, ResultPath *b) ...@@ -464,10 +458,9 @@ _equalResultPath(ResultPath *a, ResultPath *b)
{ {
if (!_equalPath((Path *) a, (Path *) b)) if (!_equalPath((Path *) a, (Path *) b))
return false; return false;
if (!equal(a->subpath, b->subpath)) COMPARE_NODE_FIELD(subpath);
return false; COMPARE_NODE_FIELD(constantqual);
if (!equal(a->constantqual, b->constantqual))
return false;
return true; return true;
} }
...@@ -476,14 +469,11 @@ _equalJoinPath(JoinPath *a, JoinPath *b) ...@@ -476,14 +469,11 @@ _equalJoinPath(JoinPath *a, JoinPath *b)
{ {
if (!_equalPath((Path *) a, (Path *) b)) if (!_equalPath((Path *) a, (Path *) b))
return false; return false;
if (a->jointype != b->jointype) COMPARE_SCALAR_FIELD(jointype);
return false; COMPARE_NODE_FIELD(outerjoinpath);
if (!equal(a->outerjoinpath, b->outerjoinpath)) COMPARE_NODE_FIELD(innerjoinpath);
return false; COMPARE_NODE_FIELD(joinrestrictinfo);
if (!equal(a->innerjoinpath, b->innerjoinpath))
return false;
if (!equal(a->joinrestrictinfo, b->joinrestrictinfo))
return false;
return true; return true;
} }
...@@ -492,6 +482,7 @@ _equalNestPath(NestPath *a, NestPath *b) ...@@ -492,6 +482,7 @@ _equalNestPath(NestPath *a, NestPath *b)
{ {
if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b)) if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
return false; return false;
return true; return true;
} }
...@@ -500,12 +491,10 @@ _equalMergePath(MergePath *a, MergePath *b) ...@@ -500,12 +491,10 @@ _equalMergePath(MergePath *a, MergePath *b)
{ {
if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b)) if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
return false; return false;
if (!equal(a->path_mergeclauses, b->path_mergeclauses)) COMPARE_NODE_FIELD(path_mergeclauses);
return false; COMPARE_NODE_FIELD(outersortkeys);
if (!equal(a->outersortkeys, b->outersortkeys)) COMPARE_NODE_FIELD(innersortkeys);
return false;
if (!equal(a->innersortkeys, b->innersortkeys))
return false;
return true; return true;
} }
...@@ -514,23 +503,16 @@ _equalHashPath(HashPath *a, HashPath *b) ...@@ -514,23 +503,16 @@ _equalHashPath(HashPath *a, HashPath *b)
{ {
if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b)) if (!_equalJoinPath((JoinPath *) a, (JoinPath *) b))
return false; return false;
if (!equal(a->path_hashclauses, b->path_hashclauses)) COMPARE_NODE_FIELD(path_hashclauses);
return false;
return true; return true;
} }
static bool static bool
_equalSubPlan(SubPlan *a, SubPlan *b) _equalPathKeyItem(PathKeyItem *a, PathKeyItem *b)
{ {
/* should compare plans, but have to settle for comparing plan IDs */ COMPARE_NODE_FIELD(key);
if (a->plan_id != b->plan_id) COMPARE_SCALAR_FIELD(sortop);
return false;
if (!equal(a->rtable, b->rtable))
return false;
if (!equal(a->sublink, b->sublink))
return false;
return true; return true;
} }
...@@ -538,50 +520,42 @@ _equalSubPlan(SubPlan *a, SubPlan *b) ...@@ -538,50 +520,42 @@ _equalSubPlan(SubPlan *a, SubPlan *b)
static bool static bool
_equalRestrictInfo(RestrictInfo *a, RestrictInfo *b) _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
{ {
if (!equal(a->clause, b->clause)) COMPARE_NODE_FIELD(clause);
return false; COMPARE_SCALAR_FIELD(ispusheddown);
if (a->ispusheddown != b->ispusheddown)
return false;
/* /*
* We ignore subclauseindices, eval_cost, this_selec, left/right_pathkey, * We ignore subclauseindices, eval_cost, this_selec, left/right_pathkey,
* and left/right_bucketsize, since they may not be set yet, and should be * and left/right_bucketsize, since they may not be set yet, and should be
* derivable from the clause anyway. Probably it's not really necessary * derivable from the clause anyway. Probably it's not really necessary
* to compare any of these remaining fields ... * to compare any of these remaining fields ...
*/ */
if (a->mergejoinoperator != b->mergejoinoperator) COMPARE_SCALAR_FIELD(mergejoinoperator);
return false; COMPARE_SCALAR_FIELD(left_sortop);
if (a->left_sortop != b->left_sortop) COMPARE_SCALAR_FIELD(right_sortop);
return false; COMPARE_SCALAR_FIELD(hashjoinoperator);
if (a->right_sortop != b->right_sortop)
return false;
if (a->hashjoinoperator != b->hashjoinoperator)
return false;
return true; return true;
} }
static bool static bool
_equalJoinInfo(JoinInfo *a, JoinInfo *b) _equalJoinInfo(JoinInfo *a, JoinInfo *b)
{ {
if (!equali(a->unjoined_relids, b->unjoined_relids)) COMPARE_INTLIST_FIELD(unjoined_relids);
return false; COMPARE_NODE_FIELD(jinfo_restrictinfo);
if (!equal(a->jinfo_restrictinfo, b->jinfo_restrictinfo))
return false;
return true; return true;
} }
static bool static bool
_equalInnerIndexscanInfo(InnerIndexscanInfo *a, InnerIndexscanInfo *b) _equalInnerIndexscanInfo(InnerIndexscanInfo *a, InnerIndexscanInfo *b)
{ {
if (!equali(a->other_relids, b->other_relids)) COMPARE_INTLIST_FIELD(other_relids);
return false; COMPARE_SCALAR_FIELD(isouterjoin);
if (a->isouterjoin != b->isouterjoin) COMPARE_NODE_FIELD(best_innerpath);
return false;
if (!equal(a->best_innerpath, b->best_innerpath))
return false;
return true; return true;
} }
/* /*
* Stuff from parsenodes.h * Stuff from parsenodes.h
*/ */
...@@ -589,48 +563,27 @@ _equalInnerIndexscanInfo(InnerIndexscanInfo *a, InnerIndexscanInfo *b) ...@@ -589,48 +563,27 @@ _equalInnerIndexscanInfo(InnerIndexscanInfo *a, InnerIndexscanInfo *b)
static bool static bool
_equalQuery(Query *a, Query *b) _equalQuery(Query *a, Query *b)
{ {
if (a->commandType != b->commandType) COMPARE_SCALAR_FIELD(commandType);
return false; COMPARE_SCALAR_FIELD(querySource);
if (a->querySource != b->querySource) COMPARE_NODE_FIELD(utilityStmt);
return false; COMPARE_SCALAR_FIELD(resultRelation);
if (!equal(a->utilityStmt, b->utilityStmt)) COMPARE_NODE_FIELD(into);
return false; COMPARE_SCALAR_FIELD(isPortal);
if (a->resultRelation != b->resultRelation) COMPARE_SCALAR_FIELD(isBinary);
return false; COMPARE_SCALAR_FIELD(hasAggs);
if (!equal(a->into, b->into)) COMPARE_SCALAR_FIELD(hasSubLinks);
return false; COMPARE_NODE_FIELD(rtable);
if (a->isPortal != b->isPortal) COMPARE_NODE_FIELD(jointree);
return false; COMPARE_INTLIST_FIELD(rowMarks);
if (a->isBinary != b->isBinary) COMPARE_NODE_FIELD(targetList);
return false; COMPARE_NODE_FIELD(groupClause);
if (a->hasAggs != b->hasAggs) COMPARE_NODE_FIELD(havingQual);
return false; COMPARE_NODE_FIELD(distinctClause);
if (a->hasSubLinks != b->hasSubLinks) COMPARE_NODE_FIELD(sortClause);
return false; COMPARE_NODE_FIELD(limitOffset);
if (!equal(a->rtable, b->rtable)) COMPARE_NODE_FIELD(limitCount);
return false; COMPARE_NODE_FIELD(setOperations);
if (!equal(a->jointree, b->jointree)) COMPARE_INTLIST_FIELD(resultRelations);
return false;
if (!equali(a->rowMarks, b->rowMarks))
return false;
if (!equal(a->targetList, b->targetList))
return false;
if (!equal(a->groupClause, b->groupClause))
return false;
if (!equal(a->havingQual, b->havingQual))
return false;
if (!equal(a->distinctClause, b->distinctClause))
return false;
if (!equal(a->sortClause, b->sortClause))
return false;
if (!equal(a->limitOffset, b->limitOffset))
return false;
if (!equal(a->limitCount, b->limitCount))
return false;
if (!equal(a->setOperations, b->setOperations))
return false;
if (!equali(a->resultRelations, b->resultRelations))
return false;
/* /*
* We do not check the internal-to-the-planner fields: base_rel_list, * We do not check the internal-to-the-planner fields: base_rel_list,
...@@ -644,14 +597,10 @@ _equalQuery(Query *a, Query *b) ...@@ -644,14 +597,10 @@ _equalQuery(Query *a, Query *b)
static bool static bool
_equalInsertStmt(InsertStmt *a, InsertStmt *b) _equalInsertStmt(InsertStmt *a, InsertStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_NODE_FIELD(cols);
if (!equal(a->cols, b->cols)) COMPARE_NODE_FIELD(targetList);
return false; COMPARE_NODE_FIELD(selectStmt);
if (!equal(a->targetList, b->targetList))
return false;
if (!equal(a->selectStmt, b->selectStmt))
return false;
return true; return true;
} }
...@@ -659,10 +608,8 @@ _equalInsertStmt(InsertStmt *a, InsertStmt *b) ...@@ -659,10 +608,8 @@ _equalInsertStmt(InsertStmt *a, InsertStmt *b)
static bool static bool
_equalDeleteStmt(DeleteStmt *a, DeleteStmt *b) _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_NODE_FIELD(whereClause);
if (!equal(a->whereClause, b->whereClause))
return false;
return true; return true;
} }
...@@ -670,14 +617,10 @@ _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b) ...@@ -670,14 +617,10 @@ _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
static bool static bool
_equalUpdateStmt(UpdateStmt *a, UpdateStmt *b) _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_NODE_FIELD(targetList);
if (!equal(a->targetList, b->targetList)) COMPARE_NODE_FIELD(whereClause);
return false; COMPARE_NODE_FIELD(fromClause);
if (!equal(a->whereClause, b->whereClause))
return false;
if (!equal(a->fromClause, b->fromClause))
return false;
return true; return true;
} }
...@@ -685,42 +628,24 @@ _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b) ...@@ -685,42 +628,24 @@ _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
static bool static bool
_equalSelectStmt(SelectStmt *a, SelectStmt *b) _equalSelectStmt(SelectStmt *a, SelectStmt *b)
{ {
if (!equal(a->distinctClause, b->distinctClause)) COMPARE_NODE_FIELD(distinctClause);
return false; COMPARE_NODE_FIELD(into);
if (!equal(a->into, b->into)) COMPARE_NODE_FIELD(intoColNames);
return false; COMPARE_NODE_FIELD(targetList);
if (!equal(a->intoColNames, b->intoColNames)) COMPARE_NODE_FIELD(fromClause);
return false; COMPARE_NODE_FIELD(whereClause);
if (!equal(a->targetList, b->targetList)) COMPARE_NODE_FIELD(groupClause);
return false; COMPARE_NODE_FIELD(havingClause);
if (!equal(a->fromClause, b->fromClause)) COMPARE_NODE_FIELD(sortClause);
return false; COMPARE_STRING_FIELD(portalname);
if (!equal(a->whereClause, b->whereClause)) COMPARE_SCALAR_FIELD(binary);
return false; COMPARE_NODE_FIELD(limitOffset);
if (!equal(a->groupClause, b->groupClause)) COMPARE_NODE_FIELD(limitCount);
return false; COMPARE_NODE_FIELD(forUpdate);
if (!equal(a->havingClause, b->havingClause)) COMPARE_SCALAR_FIELD(op);
return false; COMPARE_SCALAR_FIELD(all);
if (!equal(a->sortClause, b->sortClause)) COMPARE_NODE_FIELD(larg);
return false; COMPARE_NODE_FIELD(rarg);
if (!equalstr(a->portalname, b->portalname))
return false;
if (a->binary != b->binary)
return false;
if (!equal(a->limitOffset, b->limitOffset))
return false;
if (!equal(a->limitCount, b->limitCount))
return false;
if (!equal(a->forUpdate, b->forUpdate))
return false;
if (a->op != b->op)
return false;
if (a->all != b->all)
return false;
if (!equal(a->larg, b->larg))
return false;
if (!equal(a->rarg, b->rarg))
return false;
return true; return true;
} }
...@@ -728,16 +653,11 @@ _equalSelectStmt(SelectStmt *a, SelectStmt *b) ...@@ -728,16 +653,11 @@ _equalSelectStmt(SelectStmt *a, SelectStmt *b)
static bool static bool
_equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b) _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
{ {
if (a->op != b->op) COMPARE_SCALAR_FIELD(op);
return false; COMPARE_SCALAR_FIELD(all);
if (a->all != b->all) COMPARE_NODE_FIELD(larg);
return false; COMPARE_NODE_FIELD(rarg);
if (!equal(a->larg, b->larg)) COMPARE_INTLIST_FIELD(colTypes);
return false;
if (!equal(a->rarg, b->rarg))
return false;
if (!equali(a->colTypes, b->colTypes))
return false;
return true; return true;
} }
...@@ -745,16 +665,11 @@ _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b) ...@@ -745,16 +665,11 @@ _equalSetOperationStmt(SetOperationStmt *a, SetOperationStmt *b)
static bool static bool
_equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b) _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
{ {
if (a->subtype != b->subtype) COMPARE_SCALAR_FIELD(subtype);
return false; COMPARE_NODE_FIELD(relation);
if (!equal(a->relation, b->relation)) COMPARE_STRING_FIELD(name);
return false; COMPARE_NODE_FIELD(def);
if (!equalstr(a->name, b->name)) COMPARE_SCALAR_FIELD(behavior);
return false;
if (!equal(a->def, b->def))
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -762,16 +677,11 @@ _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b) ...@@ -762,16 +677,11 @@ _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
static bool static bool
_equalGrantStmt(GrantStmt *a, GrantStmt *b) _equalGrantStmt(GrantStmt *a, GrantStmt *b)
{ {
if (a->is_grant != b->is_grant) COMPARE_SCALAR_FIELD(is_grant);
return false; COMPARE_SCALAR_FIELD(objtype);
if (a->objtype != b->objtype) COMPARE_NODE_FIELD(objects);
return false; COMPARE_INTLIST_FIELD(privileges);
if (!equal(a->objects, b->objects)) COMPARE_NODE_FIELD(grantees);
return false;
if (!equali(a->privileges, b->privileges))
return false;
if (!equal(a->grantees, b->grantees))
return false;
return true; return true;
} }
...@@ -779,15 +689,19 @@ _equalGrantStmt(GrantStmt *a, GrantStmt *b) ...@@ -779,15 +689,19 @@ _equalGrantStmt(GrantStmt *a, GrantStmt *b)
static bool static bool
_equalPrivGrantee(PrivGrantee *a, PrivGrantee *b) _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b)
{ {
return equalstr(a->username, b->username) COMPARE_STRING_FIELD(username);
&& equalstr(a->groupname, b->groupname); COMPARE_STRING_FIELD(groupname);
return true;
} }
static bool static bool
_equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b) _equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b)
{ {
return equal(a->funcname, b->funcname) COMPARE_NODE_FIELD(funcname);
&& equal(a->funcargs, b->funcargs); COMPARE_NODE_FIELD(funcargs);
return true;
} }
static bool static bool
...@@ -799,8 +713,7 @@ _equalInsertDefault(InsertDefault *a, InsertDefault *b) ...@@ -799,8 +713,7 @@ _equalInsertDefault(InsertDefault *a, InsertDefault *b)
static bool static bool
_equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b) _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
{ {
if (!equalstr(a->portalname, b->portalname)) COMPARE_STRING_FIELD(portalname);
return false;
return true; return true;
} }
...@@ -808,10 +721,8 @@ _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b) ...@@ -808,10 +721,8 @@ _equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
static bool static bool
_equalClusterStmt(ClusterStmt *a, ClusterStmt *b) _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_STRING_FIELD(indexname);
if (!equalstr(a->indexname, b->indexname))
return false;
return true; return true;
} }
...@@ -819,16 +730,11 @@ _equalClusterStmt(ClusterStmt *a, ClusterStmt *b) ...@@ -819,16 +730,11 @@ _equalClusterStmt(ClusterStmt *a, ClusterStmt *b)
static bool static bool
_equalCopyStmt(CopyStmt *a, CopyStmt *b) _equalCopyStmt(CopyStmt *a, CopyStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_NODE_FIELD(attlist);
if (!equal(a->attlist, b->attlist)) COMPARE_SCALAR_FIELD(is_from);
return false; COMPARE_STRING_FIELD(filename);
if (a->is_from != b->is_from) COMPARE_NODE_FIELD(options);
return false;
if (!equalstr(a->filename, b->filename))
return false;
if (!equal(a->options, b->options))
return false;
return true; return true;
} }
...@@ -836,18 +742,12 @@ _equalCopyStmt(CopyStmt *a, CopyStmt *b) ...@@ -836,18 +742,12 @@ _equalCopyStmt(CopyStmt *a, CopyStmt *b)
static bool static bool
_equalCreateStmt(CreateStmt *a, CreateStmt *b) _equalCreateStmt(CreateStmt *a, CreateStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_NODE_FIELD(tableElts);
if (!equal(a->tableElts, b->tableElts)) COMPARE_NODE_FIELD(inhRelations);
return false; COMPARE_NODE_FIELD(constraints);
if (!equal(a->inhRelations, b->inhRelations)) COMPARE_SCALAR_FIELD(hasoids);
return false; COMPARE_SCALAR_FIELD(oncommit);
if (!equal(a->constraints, b->constraints))
return false;
if (a->hasoids != b->hasoids)
return false;
if (a->oncommit != b->oncommit)
return false;
return true; return true;
} }
...@@ -855,12 +755,9 @@ _equalCreateStmt(CreateStmt *a, CreateStmt *b) ...@@ -855,12 +755,9 @@ _equalCreateStmt(CreateStmt *a, CreateStmt *b)
static bool static bool
_equalDefineStmt(DefineStmt *a, DefineStmt *b) _equalDefineStmt(DefineStmt *a, DefineStmt *b)
{ {
if (a->defType != b->defType) COMPARE_SCALAR_FIELD(defType);
return false; COMPARE_NODE_FIELD(defnames);
if (!equal(a->defnames, b->defnames)) COMPARE_NODE_FIELD(definition);
return false;
if (!equal(a->definition, b->definition))
return false;
return true; return true;
} }
...@@ -868,12 +765,9 @@ _equalDefineStmt(DefineStmt *a, DefineStmt *b) ...@@ -868,12 +765,9 @@ _equalDefineStmt(DefineStmt *a, DefineStmt *b)
static bool static bool
_equalDropStmt(DropStmt *a, DropStmt *b) _equalDropStmt(DropStmt *a, DropStmt *b)
{ {
if (!equal(a->objects, b->objects)) COMPARE_NODE_FIELD(objects);
return false; COMPARE_SCALAR_FIELD(removeType);
if (a->removeType != b->removeType) COMPARE_SCALAR_FIELD(behavior);
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -881,8 +775,7 @@ _equalDropStmt(DropStmt *a, DropStmt *b) ...@@ -881,8 +775,7 @@ _equalDropStmt(DropStmt *a, DropStmt *b)
static bool static bool
_equalTruncateStmt(TruncateStmt *a, TruncateStmt *b) _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false;
return true; return true;
} }
...@@ -890,14 +783,10 @@ _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b) ...@@ -890,14 +783,10 @@ _equalTruncateStmt(TruncateStmt *a, TruncateStmt *b)
static bool static bool
_equalCommentStmt(CommentStmt *a, CommentStmt *b) _equalCommentStmt(CommentStmt *a, CommentStmt *b)
{ {
if (a->objtype != b->objtype) COMPARE_SCALAR_FIELD(objtype);
return false; COMPARE_NODE_FIELD(objname);
if (!equal(a->objname, b->objname)) COMPARE_NODE_FIELD(objargs);
return false; COMPARE_STRING_FIELD(comment);
if (!equal(a->objargs, b->objargs))
return false;
if (!equalstr(a->comment, b->comment))
return false;
return true; return true;
} }
...@@ -905,14 +794,10 @@ _equalCommentStmt(CommentStmt *a, CommentStmt *b) ...@@ -905,14 +794,10 @@ _equalCommentStmt(CommentStmt *a, CommentStmt *b)
static bool static bool
_equalFetchStmt(FetchStmt *a, FetchStmt *b) _equalFetchStmt(FetchStmt *a, FetchStmt *b)
{ {
if (a->direction != b->direction) COMPARE_SCALAR_FIELD(direction);
return false; COMPARE_SCALAR_FIELD(howMany);
if (a->howMany != b->howMany) COMPARE_STRING_FIELD(portalname);
return false; COMPARE_SCALAR_FIELD(ismove);
if (!equalstr(a->portalname, b->portalname))
return false;
if (a->ismove != b->ismove)
return false;
return true; return true;
} }
...@@ -920,24 +805,15 @@ _equalFetchStmt(FetchStmt *a, FetchStmt *b) ...@@ -920,24 +805,15 @@ _equalFetchStmt(FetchStmt *a, FetchStmt *b)
static bool static bool
_equalIndexStmt(IndexStmt *a, IndexStmt *b) _equalIndexStmt(IndexStmt *a, IndexStmt *b)
{ {
if (!equalstr(a->idxname, b->idxname)) COMPARE_STRING_FIELD(idxname);
return false; COMPARE_NODE_FIELD(relation);
if (!equal(a->relation, b->relation)) COMPARE_STRING_FIELD(accessMethod);
return false; COMPARE_NODE_FIELD(indexParams);
if (!equalstr(a->accessMethod, b->accessMethod)) COMPARE_NODE_FIELD(whereClause);
return false; COMPARE_NODE_FIELD(rangetable);
if (!equal(a->indexParams, b->indexParams)) COMPARE_SCALAR_FIELD(unique);
return false; COMPARE_SCALAR_FIELD(primary);
if (!equal(a->whereClause, b->whereClause)) COMPARE_SCALAR_FIELD(isconstraint);
return false;
if (!equal(a->rangetable, b->rangetable))
return false;
if (a->unique != b->unique)
return false;
if (a->primary != b->primary)
return false;
if (a->isconstraint != b->isconstraint)
return false;
return true; return true;
} }
...@@ -945,18 +821,12 @@ _equalIndexStmt(IndexStmt *a, IndexStmt *b) ...@@ -945,18 +821,12 @@ _equalIndexStmt(IndexStmt *a, IndexStmt *b)
static bool static bool
_equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b) _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b)
{ {
if (a->replace != b->replace) COMPARE_SCALAR_FIELD(replace);
return false; COMPARE_NODE_FIELD(funcname);
if (!equal(a->funcname, b->funcname)) COMPARE_NODE_FIELD(argTypes);
return false; COMPARE_NODE_FIELD(returnType);
if (!equal(a->argTypes, b->argTypes)) COMPARE_NODE_FIELD(options);
return false; COMPARE_NODE_FIELD(withClause);
if (!equal(a->returnType, b->returnType))
return false;
if (!equal(a->options, b->options))
return false;
if (!equal(a->withClause, b->withClause))
return false;
return true; return true;
} }
...@@ -964,12 +834,9 @@ _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b) ...@@ -964,12 +834,9 @@ _equalCreateFunctionStmt(CreateFunctionStmt *a, CreateFunctionStmt *b)
static bool static bool
_equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b) _equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b)
{ {
if (!equal(a->aggname, b->aggname)) COMPARE_NODE_FIELD(aggname);
return false; COMPARE_NODE_FIELD(aggtype);
if (!equal(a->aggtype, b->aggtype)) COMPARE_SCALAR_FIELD(behavior);
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -977,12 +844,9 @@ _equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b) ...@@ -977,12 +844,9 @@ _equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b)
static bool static bool
_equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b) _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
{ {
if (!equal(a->funcname, b->funcname)) COMPARE_NODE_FIELD(funcname);
return false; COMPARE_NODE_FIELD(args);
if (!equal(a->args, b->args)) COMPARE_SCALAR_FIELD(behavior);
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -990,12 +854,9 @@ _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b) ...@@ -990,12 +854,9 @@ _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b)
static bool static bool
_equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b) _equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b)
{ {
if (!equal(a->opname, b->opname)) COMPARE_NODE_FIELD(opname);
return false; COMPARE_NODE_FIELD(args);
if (!equal(a->args, b->args)) COMPARE_SCALAR_FIELD(behavior);
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -1003,12 +864,9 @@ _equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b) ...@@ -1003,12 +864,9 @@ _equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b)
static bool static bool
_equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b) _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
{ {
if (!equal(a->opclassname, b->opclassname)) COMPARE_NODE_FIELD(opclassname);
return false; COMPARE_STRING_FIELD(amname);
if (!equalstr(a->amname, b->amname)) COMPARE_SCALAR_FIELD(behavior);
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -1016,14 +874,10 @@ _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b) ...@@ -1016,14 +874,10 @@ _equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
static bool static bool
_equalRenameStmt(RenameStmt *a, RenameStmt *b) _equalRenameStmt(RenameStmt *a, RenameStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_STRING_FIELD(oldname);
if (!equalstr(a->oldname, b->oldname)) COMPARE_STRING_FIELD(newname);
return false; COMPARE_SCALAR_FIELD(renameType);
if (!equalstr(a->newname, b->newname))
return false;
if (a->renameType != b->renameType)
return false;
return true; return true;
} }
...@@ -1031,20 +885,13 @@ _equalRenameStmt(RenameStmt *a, RenameStmt *b) ...@@ -1031,20 +885,13 @@ _equalRenameStmt(RenameStmt *a, RenameStmt *b)
static bool static bool
_equalRuleStmt(RuleStmt *a, RuleStmt *b) _equalRuleStmt(RuleStmt *a, RuleStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_STRING_FIELD(rulename);
if (!equalstr(a->rulename, b->rulename)) COMPARE_NODE_FIELD(whereClause);
return false; COMPARE_SCALAR_FIELD(event);
if (!equal(a->whereClause, b->whereClause)) COMPARE_SCALAR_FIELD(instead);
return false; COMPARE_NODE_FIELD(actions);
if (a->event != b->event) COMPARE_SCALAR_FIELD(replace);
return false;
if (a->instead != b->instead)
return false;
if (a->replace != b->replace)
return false;
if (!equal(a->actions, b->actions))
return false;
return true; return true;
} }
...@@ -1052,8 +899,7 @@ _equalRuleStmt(RuleStmt *a, RuleStmt *b) ...@@ -1052,8 +899,7 @@ _equalRuleStmt(RuleStmt *a, RuleStmt *b)
static bool static bool
_equalNotifyStmt(NotifyStmt *a, NotifyStmt *b) _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false;
return true; return true;
} }
...@@ -1061,8 +907,7 @@ _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b) ...@@ -1061,8 +907,7 @@ _equalNotifyStmt(NotifyStmt *a, NotifyStmt *b)
static bool static bool
_equalListenStmt(ListenStmt *a, ListenStmt *b) _equalListenStmt(ListenStmt *a, ListenStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false;
return true; return true;
} }
...@@ -1070,8 +915,7 @@ _equalListenStmt(ListenStmt *a, ListenStmt *b) ...@@ -1070,8 +915,7 @@ _equalListenStmt(ListenStmt *a, ListenStmt *b)
static bool static bool
_equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b) _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false;
return true; return true;
} }
...@@ -1079,10 +923,8 @@ _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b) ...@@ -1079,10 +923,8 @@ _equalUnlistenStmt(UnlistenStmt *a, UnlistenStmt *b)
static bool static bool
_equalTransactionStmt(TransactionStmt *a, TransactionStmt *b) _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
{ {
if (a->command != b->command) COMPARE_SCALAR_FIELD(command);
return false; COMPARE_NODE_FIELD(options);
if (!equal(a->options, b->options))
return false;
return true; return true;
} }
...@@ -1090,25 +932,19 @@ _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b) ...@@ -1090,25 +932,19 @@ _equalTransactionStmt(TransactionStmt *a, TransactionStmt *b)
static bool static bool
_equalCompositeTypeStmt(CompositeTypeStmt *a, CompositeTypeStmt *b) _equalCompositeTypeStmt(CompositeTypeStmt *a, CompositeTypeStmt *b)
{ {
if (!equal(a->typevar, b->typevar)) COMPARE_NODE_FIELD(typevar);
return false; COMPARE_NODE_FIELD(coldeflist);
if (!equal(a->coldeflist, b->coldeflist))
return false;
return true; return true;
} }
static bool static bool
_equalViewStmt(ViewStmt *a, ViewStmt *b) _equalViewStmt(ViewStmt *a, ViewStmt *b)
{ {
if (!equal(a->view, b->view)) COMPARE_NODE_FIELD(view);
return false; COMPARE_NODE_FIELD(aliases);
if (!equal(a->aliases, b->aliases)) COMPARE_NODE_FIELD(query);
return false; COMPARE_SCALAR_FIELD(replace);
if (!equal(a->query, b->query))
return false;
if (a->replace != b->replace)
return false;
return true; return true;
} }
...@@ -1116,8 +952,7 @@ _equalViewStmt(ViewStmt *a, ViewStmt *b) ...@@ -1116,8 +952,7 @@ _equalViewStmt(ViewStmt *a, ViewStmt *b)
static bool static bool
_equalLoadStmt(LoadStmt *a, LoadStmt *b) _equalLoadStmt(LoadStmt *a, LoadStmt *b)
{ {
if (!equalstr(a->filename, b->filename)) COMPARE_STRING_FIELD(filename);
return false;
return true; return true;
} }
...@@ -1125,12 +960,9 @@ _equalLoadStmt(LoadStmt *a, LoadStmt *b) ...@@ -1125,12 +960,9 @@ _equalLoadStmt(LoadStmt *a, LoadStmt *b)
static bool static bool
_equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b) _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
{ {
if (!equal(a->domainname, b->domainname)) COMPARE_NODE_FIELD(domainname);
return false; COMPARE_NODE_FIELD(typename);
if (!equal(a->typename, b->typename)) COMPARE_NODE_FIELD(constraints);
return false;
if (!equal(a->constraints, b->constraints))
return false;
return true; return true;
} }
...@@ -1138,16 +970,11 @@ _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b) ...@@ -1138,16 +970,11 @@ _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
static bool static bool
_equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b) _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
{ {
if (!equal(a->opclassname, b->opclassname)) COMPARE_NODE_FIELD(opclassname);
return false; COMPARE_STRING_FIELD(amname);
if (!equalstr(a->amname, b->amname)) COMPARE_NODE_FIELD(datatype);
return false; COMPARE_NODE_FIELD(items);
if (!equal(a->datatype, b->datatype)) COMPARE_SCALAR_FIELD(isDefault);
return false;
if (!equal(a->items, b->items))
return false;
if (a->isDefault != b->isDefault)
return false;
return true; return true;
} }
...@@ -1155,18 +982,12 @@ _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b) ...@@ -1155,18 +982,12 @@ _equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
static bool static bool
_equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b) _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
{ {
if (a->itemtype != b->itemtype) COMPARE_SCALAR_FIELD(itemtype);
return false; COMPARE_NODE_FIELD(name);
if (!equal(a->name, b->name)) COMPARE_NODE_FIELD(args);
return false; COMPARE_SCALAR_FIELD(number);
if (!equal(a->args, b->args)) COMPARE_SCALAR_FIELD(recheck);
return false; COMPARE_NODE_FIELD(storedtype);
if (a->number != b->number)
return false;
if (a->recheck != b->recheck)
return false;
if (!equal(a->storedtype, b->storedtype))
return false;
return true; return true;
} }
...@@ -1174,10 +995,8 @@ _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b) ...@@ -1174,10 +995,8 @@ _equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
static bool static bool
_equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b) _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
{ {
if (!equalstr(a->dbname, b->dbname)) COMPARE_STRING_FIELD(dbname);
return false; COMPARE_NODE_FIELD(options);
if (!equal(a->options, b->options))
return false;
return true; return true;
} }
...@@ -1185,12 +1004,9 @@ _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b) ...@@ -1185,12 +1004,9 @@ _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
static bool static bool
_equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b) _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b)
{ {
if (!equalstr(a->dbname, b->dbname)) COMPARE_STRING_FIELD(dbname);
return false; COMPARE_STRING_FIELD(variable);
if (!equalstr(a->variable, b->variable)) COMPARE_NODE_FIELD(value);
return false;
if (!equal(a->value, b->value))
return false;
return true; return true;
} }
...@@ -1198,8 +1014,7 @@ _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b) ...@@ -1198,8 +1014,7 @@ _equalAlterDatabaseSetStmt(AlterDatabaseSetStmt *a, AlterDatabaseSetStmt *b)
static bool static bool
_equalDropdbStmt(DropdbStmt *a, DropdbStmt *b) _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
{ {
if (!equalstr(a->dbname, b->dbname)) COMPARE_STRING_FIELD(dbname);
return false;
return true; return true;
} }
...@@ -1207,20 +1022,13 @@ _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b) ...@@ -1207,20 +1022,13 @@ _equalDropdbStmt(DropdbStmt *a, DropdbStmt *b)
static bool static bool
_equalVacuumStmt(VacuumStmt *a, VacuumStmt *b) _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
{ {
if (a->vacuum != b->vacuum) COMPARE_SCALAR_FIELD(vacuum);
return false; COMPARE_SCALAR_FIELD(full);
if (a->full != b->full) COMPARE_SCALAR_FIELD(analyze);
return false; COMPARE_SCALAR_FIELD(freeze);
if (a->analyze != b->analyze) COMPARE_SCALAR_FIELD(verbose);
return false; COMPARE_NODE_FIELD(relation);
if (a->freeze != b->freeze) COMPARE_NODE_FIELD(va_cols);
return false;
if (a->verbose != b->verbose)
return false;
if (!equal(a->relation, b->relation))
return false;
if (!equal(a->va_cols, b->va_cols))
return false;
return true; return true;
} }
...@@ -1228,12 +1036,9 @@ _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b) ...@@ -1228,12 +1036,9 @@ _equalVacuumStmt(VacuumStmt *a, VacuumStmt *b)
static bool static bool
_equalExplainStmt(ExplainStmt *a, ExplainStmt *b) _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
{ {
if (!equal(a->query, b->query)) COMPARE_NODE_FIELD(query);
return false; COMPARE_SCALAR_FIELD(verbose);
if (a->verbose != b->verbose) COMPARE_SCALAR_FIELD(analyze);
return false;
if (a->analyze != b->analyze)
return false;
return true; return true;
} }
...@@ -1241,10 +1046,8 @@ _equalExplainStmt(ExplainStmt *a, ExplainStmt *b) ...@@ -1241,10 +1046,8 @@ _equalExplainStmt(ExplainStmt *a, ExplainStmt *b)
static bool static bool
_equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b) _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
{ {
if (!equal(a->sequence, b->sequence)) COMPARE_NODE_FIELD(sequence);
return false; COMPARE_NODE_FIELD(options);
if (!equal(a->options, b->options))
return false;
return true; return true;
} }
...@@ -1252,12 +1055,9 @@ _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b) ...@@ -1252,12 +1055,9 @@ _equalCreateSeqStmt(CreateSeqStmt *a, CreateSeqStmt *b)
static bool static bool
_equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b) _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false; COMPARE_NODE_FIELD(args);
if (!equal(a->args, b->args)) COMPARE_SCALAR_FIELD(is_local);
return false;
if (a->is_local != b->is_local)
return false;
return true; return true;
} }
...@@ -1265,8 +1065,7 @@ _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b) ...@@ -1265,8 +1065,7 @@ _equalVariableSetStmt(VariableSetStmt *a, VariableSetStmt *b)
static bool static bool
_equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b) _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false;
return true; return true;
} }
...@@ -1274,8 +1073,7 @@ _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b) ...@@ -1274,8 +1073,7 @@ _equalVariableShowStmt(VariableShowStmt *a, VariableShowStmt *b)
static bool static bool
_equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b) _equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false;
return true; return true;
} }
...@@ -1283,28 +1081,18 @@ _equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b) ...@@ -1283,28 +1081,18 @@ _equalVariableResetStmt(VariableResetStmt *a, VariableResetStmt *b)
static bool static bool
_equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b) _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
{ {
if (!equalstr(a->trigname, b->trigname)) COMPARE_STRING_FIELD(trigname);
return false; COMPARE_NODE_FIELD(relation);
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(funcname);
return false; COMPARE_NODE_FIELD(args);
if (!equal(a->funcname, b->funcname)) COMPARE_SCALAR_FIELD(before);
return false; COMPARE_SCALAR_FIELD(row);
if (!equal(a->args, b->args)) if (strcmp(a->actions, b->actions) != 0) /* in-line string field */
return false;
if (a->before != b->before)
return false;
if (a->row != b->row)
return false;
if (strcmp(a->actions, b->actions) != 0)
return false;
if (a->isconstraint != b->isconstraint)
return false;
if (a->deferrable != b->deferrable)
return false;
if (a->initdeferred != b->initdeferred)
return false;
if (!equal(a->constrrel, b->constrrel))
return false; return false;
COMPARE_SCALAR_FIELD(isconstraint);
COMPARE_SCALAR_FIELD(deferrable);
COMPARE_SCALAR_FIELD(initdeferred);
COMPARE_NODE_FIELD(constrrel);
return true; return true;
} }
...@@ -1312,14 +1100,10 @@ _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b) ...@@ -1312,14 +1100,10 @@ _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b)
static bool static bool
_equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b) _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b)
{ {
if (!equal(a->relation, b->relation)) COMPARE_NODE_FIELD(relation);
return false; COMPARE_STRING_FIELD(property);
if (!equalstr(a->property, b->property)) COMPARE_SCALAR_FIELD(removeType);
return false; COMPARE_SCALAR_FIELD(behavior);
if (a->removeType != b->removeType)
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -1327,14 +1111,10 @@ _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b) ...@@ -1327,14 +1111,10 @@ _equalDropPropertyStmt(DropPropertyStmt *a, DropPropertyStmt *b)
static bool static bool
_equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b) _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
{ {
if (!equalstr(a->plname, b->plname)) COMPARE_STRING_FIELD(plname);
return false; COMPARE_NODE_FIELD(plhandler);
if (!equal(a->plhandler, b->plhandler)) COMPARE_NODE_FIELD(plvalidator);
return false; COMPARE_SCALAR_FIELD(pltrusted);
if (!equal(a->plvalidator, b->plvalidator))
return false;
if (a->pltrusted != b->pltrusted)
return false;
return true; return true;
} }
...@@ -1342,10 +1122,8 @@ _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b) ...@@ -1342,10 +1122,8 @@ _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b)
static bool static bool
_equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b) _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
{ {
if (!equalstr(a->plname, b->plname)) COMPARE_STRING_FIELD(plname);
return false; COMPARE_SCALAR_FIELD(behavior);
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -1353,10 +1131,8 @@ _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b) ...@@ -1353,10 +1131,8 @@ _equalDropPLangStmt(DropPLangStmt *a, DropPLangStmt *b)
static bool static bool
_equalCreateUserStmt(CreateUserStmt *a, CreateUserStmt *b) _equalCreateUserStmt(CreateUserStmt *a, CreateUserStmt *b)
{ {
if (!equalstr(a->user, b->user)) COMPARE_STRING_FIELD(user);
return false; COMPARE_NODE_FIELD(options);
if (!equal(a->options, b->options))
return false;
return true; return true;
} }
...@@ -1364,10 +1140,8 @@ _equalCreateUserStmt(CreateUserStmt *a, CreateUserStmt *b) ...@@ -1364,10 +1140,8 @@ _equalCreateUserStmt(CreateUserStmt *a, CreateUserStmt *b)
static bool static bool
_equalAlterUserStmt(AlterUserStmt *a, AlterUserStmt *b) _equalAlterUserStmt(AlterUserStmt *a, AlterUserStmt *b)
{ {
if (!equalstr(a->user, b->user)) COMPARE_STRING_FIELD(user);
return false; COMPARE_NODE_FIELD(options);
if (!equal(a->options, b->options))
return false;
return true; return true;
} }
...@@ -1375,12 +1149,9 @@ _equalAlterUserStmt(AlterUserStmt *a, AlterUserStmt *b) ...@@ -1375,12 +1149,9 @@ _equalAlterUserStmt(AlterUserStmt *a, AlterUserStmt *b)
static bool static bool
_equalAlterUserSetStmt(AlterUserSetStmt *a, AlterUserSetStmt *b) _equalAlterUserSetStmt(AlterUserSetStmt *a, AlterUserSetStmt *b)
{ {
if (!equalstr(a->user, b->user)) COMPARE_STRING_FIELD(user);
return false; COMPARE_STRING_FIELD(variable);
if (!equalstr(a->variable, b->variable)) COMPARE_NODE_FIELD(value);
return false;
if (!equal(a->value, b->value))
return false;
return true; return true;
} }
...@@ -1388,8 +1159,7 @@ _equalAlterUserSetStmt(AlterUserSetStmt *a, AlterUserSetStmt *b) ...@@ -1388,8 +1159,7 @@ _equalAlterUserSetStmt(AlterUserSetStmt *a, AlterUserSetStmt *b)
static bool static bool
_equalDropUserStmt(DropUserStmt *a, DropUserStmt *b) _equalDropUserStmt(DropUserStmt *a, DropUserStmt *b)
{ {
if (!equal(a->users, b->users)) COMPARE_NODE_FIELD(users);
return false;
return true; return true;
} }
...@@ -1397,10 +1167,8 @@ _equalDropUserStmt(DropUserStmt *a, DropUserStmt *b) ...@@ -1397,10 +1167,8 @@ _equalDropUserStmt(DropUserStmt *a, DropUserStmt *b)
static bool static bool
_equalLockStmt(LockStmt *a, LockStmt *b) _equalLockStmt(LockStmt *a, LockStmt *b)
{ {
if (!equal(a->relations, b->relations)) COMPARE_NODE_FIELD(relations);
return false; COMPARE_SCALAR_FIELD(mode);
if (a->mode != b->mode)
return false;
return true; return true;
} }
...@@ -1408,10 +1176,8 @@ _equalLockStmt(LockStmt *a, LockStmt *b) ...@@ -1408,10 +1176,8 @@ _equalLockStmt(LockStmt *a, LockStmt *b)
static bool static bool
_equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b) _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
{ {
if (!equal(a->constraints, b->constraints)) COMPARE_NODE_FIELD(constraints);
return false; COMPARE_SCALAR_FIELD(deferred);
if (a->deferred != b->deferred)
return false;
return true; return true;
} }
...@@ -1419,10 +1185,8 @@ _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b) ...@@ -1419,10 +1185,8 @@ _equalConstraintsSetStmt(ConstraintsSetStmt *a, ConstraintsSetStmt *b)
static bool static bool
_equalCreateGroupStmt(CreateGroupStmt *a, CreateGroupStmt *b) _equalCreateGroupStmt(CreateGroupStmt *a, CreateGroupStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false; COMPARE_NODE_FIELD(options);
if (!equal(a->options, b->options))
return false;
return true; return true;
} }
...@@ -1430,12 +1194,9 @@ _equalCreateGroupStmt(CreateGroupStmt *a, CreateGroupStmt *b) ...@@ -1430,12 +1194,9 @@ _equalCreateGroupStmt(CreateGroupStmt *a, CreateGroupStmt *b)
static bool static bool
_equalAlterGroupStmt(AlterGroupStmt *a, AlterGroupStmt *b) _equalAlterGroupStmt(AlterGroupStmt *a, AlterGroupStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false; COMPARE_SCALAR_FIELD(action);
if (a->action != b->action) COMPARE_NODE_FIELD(listUsers);
return false;
if (!equal(a->listUsers, b->listUsers))
return false;
return true; return true;
} }
...@@ -1443,8 +1204,7 @@ _equalAlterGroupStmt(AlterGroupStmt *a, AlterGroupStmt *b) ...@@ -1443,8 +1204,7 @@ _equalAlterGroupStmt(AlterGroupStmt *a, AlterGroupStmt *b)
static bool static bool
_equalDropGroupStmt(DropGroupStmt *a, DropGroupStmt *b) _equalDropGroupStmt(DropGroupStmt *a, DropGroupStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false;
return true; return true;
} }
...@@ -1452,16 +1212,11 @@ _equalDropGroupStmt(DropGroupStmt *a, DropGroupStmt *b) ...@@ -1452,16 +1212,11 @@ _equalDropGroupStmt(DropGroupStmt *a, DropGroupStmt *b)
static bool static bool
_equalReindexStmt(ReindexStmt *a, ReindexStmt *b) _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
{ {
if (a->reindexType != b->reindexType) COMPARE_SCALAR_FIELD(reindexType);
return false; COMPARE_NODE_FIELD(relation);
if (!equal(a->relation, b->relation)) COMPARE_STRING_FIELD(name);
return false; COMPARE_SCALAR_FIELD(force);
if (!equalstr(a->name, b->name)) COMPARE_SCALAR_FIELD(all);
return false;
if (a->force != b->force)
return false;
if (a->all != b->all)
return false;
return true; return true;
} }
...@@ -1469,12 +1224,9 @@ _equalReindexStmt(ReindexStmt *a, ReindexStmt *b) ...@@ -1469,12 +1224,9 @@ _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
static bool static bool
_equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b) _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b)
{ {
if (!equalstr(a->schemaname, b->schemaname)) COMPARE_STRING_FIELD(schemaname);
return false; COMPARE_STRING_FIELD(authid);
if (!equalstr(a->authid, b->authid)) COMPARE_NODE_FIELD(schemaElts);
return false;
if (!equal(a->schemaElts, b->schemaElts))
return false;
return true; return true;
} }
...@@ -1482,16 +1234,11 @@ _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b) ...@@ -1482,16 +1234,11 @@ _equalCreateSchemaStmt(CreateSchemaStmt *a, CreateSchemaStmt *b)
static bool static bool
_equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b) _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
{ {
if (!equal(a->conversion_name, b->conversion_name)) COMPARE_NODE_FIELD(conversion_name);
return false; COMPARE_STRING_FIELD(for_encoding_name);
if (!equalstr(a->for_encoding_name, b->for_encoding_name)) COMPARE_STRING_FIELD(to_encoding_name);
return false; COMPARE_NODE_FIELD(func_name);
if (!equalstr(a->to_encoding_name, b->to_encoding_name)) COMPARE_SCALAR_FIELD(def);
return false;
if (!equal(a->func_name, b->func_name))
return false;
if (a->def != b->def)
return false;
return true; return true;
} }
...@@ -1499,14 +1246,10 @@ _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b) ...@@ -1499,14 +1246,10 @@ _equalCreateConversionStmt(CreateConversionStmt *a, CreateConversionStmt *b)
static bool static bool
_equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b) _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
{ {
if (!equal(a->sourcetype, b->sourcetype)) COMPARE_NODE_FIELD(sourcetype);
return false; COMPARE_NODE_FIELD(targettype);
if (!equal(a->targettype, b->targettype)) COMPARE_NODE_FIELD(func);
return false; COMPARE_SCALAR_FIELD(context);
if (!equal(a->func, b->func))
return false;
if (a->context != b->context)
return false;
return true; return true;
} }
...@@ -1514,12 +1257,9 @@ _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b) ...@@ -1514,12 +1257,9 @@ _equalCreateCastStmt(CreateCastStmt *a, CreateCastStmt *b)
static bool static bool
_equalDropCastStmt(DropCastStmt *a, DropCastStmt *b) _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
{ {
if (!equal(a->sourcetype, b->sourcetype)) COMPARE_NODE_FIELD(sourcetype);
return false; COMPARE_NODE_FIELD(targettype);
if (!equal(a->targettype, b->targettype)) COMPARE_SCALAR_FIELD(behavior);
return false;
if (a->behavior != b->behavior)
return false;
return true; return true;
} }
...@@ -1527,14 +1267,10 @@ _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b) ...@@ -1527,14 +1267,10 @@ _equalDropCastStmt(DropCastStmt *a, DropCastStmt *b)
static bool static bool
_equalPrepareStmt(PrepareStmt *a, PrepareStmt *b) _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false; COMPARE_NODE_FIELD(argtypes);
if (!equal(a->argtypes, b->argtypes)) COMPARE_INTLIST_FIELD(argtype_oids);
return false; COMPARE_NODE_FIELD(query);
if (!equali(a->argtype_oids, b->argtype_oids))
return false;
if (!equal(a->query, b->query))
return false;
return true; return true;
} }
...@@ -1542,12 +1278,9 @@ _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b) ...@@ -1542,12 +1278,9 @@ _equalPrepareStmt(PrepareStmt *a, PrepareStmt *b)
static bool static bool
_equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b) _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false; COMPARE_NODE_FIELD(into);
if (!equal(a->into, b->into)) COMPARE_NODE_FIELD(params);
return false;
if (!equal(a->params, b->params))
return false;
return true; return true;
} }
...@@ -1555,23 +1288,23 @@ _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b) ...@@ -1555,23 +1288,23 @@ _equalExecuteStmt(ExecuteStmt *a, ExecuteStmt *b)
static bool static bool
_equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b) _equalDeallocateStmt(DeallocateStmt *a, DeallocateStmt *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false;
return true; return true;
} }
/*
* stuff from parsenodes.h
*/
static bool static bool
_equalAExpr(A_Expr *a, A_Expr *b) _equalAExpr(A_Expr *a, A_Expr *b)
{ {
if (a->oper != b->oper) COMPARE_SCALAR_FIELD(oper);
return false; COMPARE_NODE_FIELD(name);
if (!equal(a->name, b->name)) COMPARE_NODE_FIELD(lexpr);
return false; COMPARE_NODE_FIELD(rexpr);
if (!equal(a->lexpr, b->lexpr))
return false;
if (!equal(a->rexpr, b->rexpr))
return false;
return true; return true;
} }
...@@ -1579,10 +1312,8 @@ _equalAExpr(A_Expr *a, A_Expr *b) ...@@ -1579,10 +1312,8 @@ _equalAExpr(A_Expr *a, A_Expr *b)
static bool static bool
_equalColumnRef(ColumnRef *a, ColumnRef *b) _equalColumnRef(ColumnRef *a, ColumnRef *b)
{ {
if (!equal(a->fields, b->fields)) COMPARE_NODE_FIELD(fields);
return false; COMPARE_NODE_FIELD(indirection);
if (!equal(a->indirection, b->indirection))
return false;
return true; return true;
} }
...@@ -1590,12 +1321,9 @@ _equalColumnRef(ColumnRef *a, ColumnRef *b) ...@@ -1590,12 +1321,9 @@ _equalColumnRef(ColumnRef *a, ColumnRef *b)
static bool static bool
_equalParamRef(ParamRef *a, ParamRef *b) _equalParamRef(ParamRef *a, ParamRef *b)
{ {
if (a->number != b->number) COMPARE_SCALAR_FIELD(number);
return false; COMPARE_NODE_FIELD(fields);
if (!equal(a->fields, b->fields)) COMPARE_NODE_FIELD(indirection);
return false;
if (!equal(a->indirection, b->indirection))
return false;
return true; return true;
} }
...@@ -1603,10 +1331,9 @@ _equalParamRef(ParamRef *a, ParamRef *b) ...@@ -1603,10 +1331,9 @@ _equalParamRef(ParamRef *a, ParamRef *b)
static bool static bool
_equalAConst(A_Const *a, A_Const *b) _equalAConst(A_Const *a, A_Const *b)
{ {
if (!equal(&a->val, &b->val)) if (!equal(&a->val, &b->val)) /* hack for in-line Value field */
return false;
if (!equal(a->typename, b->typename))
return false; return false;
COMPARE_NODE_FIELD(typename);
return true; return true;
} }
...@@ -1614,14 +1341,10 @@ _equalAConst(A_Const *a, A_Const *b) ...@@ -1614,14 +1341,10 @@ _equalAConst(A_Const *a, A_Const *b)
static bool static bool
_equalFuncCall(FuncCall *a, FuncCall *b) _equalFuncCall(FuncCall *a, FuncCall *b)
{ {
if (!equal(a->funcname, b->funcname)) COMPARE_NODE_FIELD(funcname);
return false; COMPARE_NODE_FIELD(args);
if (!equal(a->args, b->args)) COMPARE_SCALAR_FIELD(agg_star);
return false; COMPARE_SCALAR_FIELD(agg_distinct);
if (a->agg_star != b->agg_star)
return false;
if (a->agg_distinct != b->agg_distinct)
return false;
return true; return true;
} }
...@@ -1629,10 +1352,8 @@ _equalFuncCall(FuncCall *a, FuncCall *b) ...@@ -1629,10 +1352,8 @@ _equalFuncCall(FuncCall *a, FuncCall *b)
static bool static bool
_equalAIndices(A_Indices *a, A_Indices *b) _equalAIndices(A_Indices *a, A_Indices *b)
{ {
if (!equal(a->lidx, b->lidx)) COMPARE_NODE_FIELD(lidx);
return false; COMPARE_NODE_FIELD(uidx);
if (!equal(a->uidx, b->uidx))
return false;
return true; return true;
} }
...@@ -1640,12 +1361,9 @@ _equalAIndices(A_Indices *a, A_Indices *b) ...@@ -1640,12 +1361,9 @@ _equalAIndices(A_Indices *a, A_Indices *b)
static bool static bool
_equalExprFieldSelect(ExprFieldSelect *a, ExprFieldSelect *b) _equalExprFieldSelect(ExprFieldSelect *a, ExprFieldSelect *b)
{ {
if (!equal(a->arg, b->arg)) COMPARE_NODE_FIELD(arg);
return false; COMPARE_NODE_FIELD(fields);
if (!equal(a->fields, b->fields)) COMPARE_NODE_FIELD(indirection);
return false;
if (!equal(a->indirection, b->indirection))
return false;
return true; return true;
} }
...@@ -1653,64 +1371,41 @@ _equalExprFieldSelect(ExprFieldSelect *a, ExprFieldSelect *b) ...@@ -1653,64 +1371,41 @@ _equalExprFieldSelect(ExprFieldSelect *a, ExprFieldSelect *b)
static bool static bool
_equalResTarget(ResTarget *a, ResTarget *b) _equalResTarget(ResTarget *a, ResTarget *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false; COMPARE_NODE_FIELD(indirection);
if (!equal(a->indirection, b->indirection)) COMPARE_NODE_FIELD(val);
return false;
if (!equal(a->val, b->val))
return false;
return true;
}
static bool
_equalTypeCast(TypeCast *a, TypeCast *b)
{
if (!equal(a->arg, b->arg))
return false;
if (!equal(a->typename, b->typename))
return false;
return true; return true;
} }
static bool static bool
_equalSortGroupBy(SortGroupBy *a, SortGroupBy *b) _equalTypeName(TypeName *a, TypeName *b)
{ {
if (!equal(a->useOp, b->useOp)) COMPARE_NODE_FIELD(names);
return false; COMPARE_SCALAR_FIELD(typeid);
if (!equal(a->node, b->node)) COMPARE_SCALAR_FIELD(timezone);
return false; COMPARE_SCALAR_FIELD(setof);
COMPARE_SCALAR_FIELD(pct_type);
COMPARE_SCALAR_FIELD(typmod);
COMPARE_NODE_FIELD(arrayBounds);
return true; return true;
} }
static bool static bool
_equalAlias(Alias *a, Alias *b) _equalTypeCast(TypeCast *a, TypeCast *b)
{ {
if (!equalstr(a->aliasname, b->aliasname)) COMPARE_NODE_FIELD(arg);
return false; COMPARE_NODE_FIELD(typename);
if (!equal(a->colnames, b->colnames))
return false;
return true; return true;
} }
static bool static bool
_equalRangeVar(RangeVar *a, RangeVar *b) _equalSortGroupBy(SortGroupBy *a, SortGroupBy *b)
{ {
if (!equalstr(a->catalogname, b->catalogname)) COMPARE_NODE_FIELD(useOp);
return false; COMPARE_NODE_FIELD(node);
if (!equalstr(a->schemaname, b->schemaname))
return false;
if (!equalstr(a->relname, b->relname))
return false;
if (a->inhOpt != b->inhOpt)
return false;
if (a->istemp != b->istemp)
return false;
if (!equal(a->alias, b->alias))
return false;
return true; return true;
} }
...@@ -1718,10 +1413,8 @@ _equalRangeVar(RangeVar *a, RangeVar *b) ...@@ -1718,10 +1413,8 @@ _equalRangeVar(RangeVar *a, RangeVar *b)
static bool static bool
_equalRangeSubselect(RangeSubselect *a, RangeSubselect *b) _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
{ {
if (!equal(a->subquery, b->subquery)) COMPARE_NODE_FIELD(subquery);
return false; COMPARE_NODE_FIELD(alias);
if (!equal(a->alias, b->alias))
return false;
return true; return true;
} }
...@@ -1729,33 +1422,9 @@ _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b) ...@@ -1729,33 +1422,9 @@ _equalRangeSubselect(RangeSubselect *a, RangeSubselect *b)
static bool static bool
_equalRangeFunction(RangeFunction *a, RangeFunction *b) _equalRangeFunction(RangeFunction *a, RangeFunction *b)
{ {
if (!equal(a->funccallnode, b->funccallnode)) COMPARE_NODE_FIELD(funccallnode);
return false; COMPARE_NODE_FIELD(alias);
if (!equal(a->alias, b->alias)) COMPARE_NODE_FIELD(coldeflist);
return false;
if (!equal(a->coldeflist, b->coldeflist))
return false;
return true;
}
static bool
_equalTypeName(TypeName *a, TypeName *b)
{
if (!equal(a->names, b->names))
return false;
if (a->typeid != b->typeid)
return false;
if (a->timezone != b->timezone)
return false;
if (a->setof != b->setof)
return false;
if (a->pct_type != b->pct_type)
return false;
if (a->typmod != b->typmod)
return false;
if (!equal(a->arrayBounds, b->arrayBounds))
return false;
return true; return true;
} }
...@@ -1763,14 +1432,10 @@ _equalTypeName(TypeName *a, TypeName *b) ...@@ -1763,14 +1432,10 @@ _equalTypeName(TypeName *a, TypeName *b)
static bool static bool
_equalIndexElem(IndexElem *a, IndexElem *b) _equalIndexElem(IndexElem *a, IndexElem *b)
{ {
if (!equalstr(a->name, b->name)) COMPARE_STRING_FIELD(name);
return false; COMPARE_NODE_FIELD(funcname);
if (!equal(a->funcname, b->funcname)) COMPARE_NODE_FIELD(args);
return false; COMPARE_NODE_FIELD(opclass);
if (!equal(a->args, b->args))
return false;
if (!equal(a->opclass, b->opclass))
return false;
return true; return true;
} }
...@@ -1778,24 +1443,15 @@ _equalIndexElem(IndexElem *a, IndexElem *b) ...@@ -1778,24 +1443,15 @@ _equalIndexElem(IndexElem *a, IndexElem *b)
static bool static bool
_equalColumnDef(ColumnDef *a, ColumnDef *b) _equalColumnDef(ColumnDef *a, ColumnDef *b)
{ {
if (!equalstr(a->colname, b->colname)) COMPARE_STRING_FIELD(colname);
return false; COMPARE_NODE_FIELD(typename);
if (!equal(a->typename, b->typename)) COMPARE_SCALAR_FIELD(inhcount);
return false; COMPARE_SCALAR_FIELD(is_local);
if (a->inhcount != b->inhcount) COMPARE_SCALAR_FIELD(is_not_null);
return false; COMPARE_NODE_FIELD(raw_default);
if (a->is_local != b->is_local) COMPARE_STRING_FIELD(cooked_default);
return false; COMPARE_NODE_FIELD(constraints);
if (a->is_not_null != b->is_not_null) COMPARE_NODE_FIELD(support);
return false;
if (!equal(a->raw_default, b->raw_default))
return false;
if (!equalstr(a->cooked_default, b->cooked_default))
return false;
if (!equal(a->constraints, b->constraints))
return false;
if (!equal(a->support, b->support))
return false;
return true; return true;
} }
...@@ -1803,16 +1459,11 @@ _equalColumnDef(ColumnDef *a, ColumnDef *b) ...@@ -1803,16 +1459,11 @@ _equalColumnDef(ColumnDef *a, ColumnDef *b)
static bool static bool
_equalConstraint(Constraint *a, Constraint *b) _equalConstraint(Constraint *a, Constraint *b)
{ {
if (a->contype != b->contype) COMPARE_SCALAR_FIELD(contype);
return false; COMPARE_STRING_FIELD(name);
if (!equalstr(a->name, b->name)) COMPARE_NODE_FIELD(raw_expr);
return false; COMPARE_STRING_FIELD(cooked_expr);
if (!equal(a->raw_expr, b->raw_expr)) COMPARE_NODE_FIELD(keys);
return false;
if (!equalstr(a->cooked_expr, b->cooked_expr))
return false;
if (!equal(a->keys, b->keys))
return false;
return true; return true;
} }
...@@ -1820,10 +1471,8 @@ _equalConstraint(Constraint *a, Constraint *b) ...@@ -1820,10 +1471,8 @@ _equalConstraint(Constraint *a, Constraint *b)
static bool static bool
_equalDefElem(DefElem *a, DefElem *b) _equalDefElem(DefElem *a, DefElem *b)
{ {
if (!equalstr(a->defname, b->defname)) COMPARE_STRING_FIELD(defname);
return false; COMPARE_NODE_FIELD(arg);
if (!equal(a->arg, b->arg))
return false;
return true; return true;
} }
...@@ -1831,12 +1480,9 @@ _equalDefElem(DefElem *a, DefElem *b) ...@@ -1831,12 +1480,9 @@ _equalDefElem(DefElem *a, DefElem *b)
static bool static bool
_equalTargetEntry(TargetEntry *a, TargetEntry *b) _equalTargetEntry(TargetEntry *a, TargetEntry *b)
{ {
if (!equal(a->resdom, b->resdom)) COMPARE_NODE_FIELD(resdom);
return false; COMPARE_NODE_FIELD(fjoin);
if (!equal(a->fjoin, b->fjoin)) COMPARE_NODE_FIELD(expr);
return false;
if (!equal(a->expr, b->expr))
return false;
return true; return true;
} }
...@@ -1844,34 +1490,20 @@ _equalTargetEntry(TargetEntry *a, TargetEntry *b) ...@@ -1844,34 +1490,20 @@ _equalTargetEntry(TargetEntry *a, TargetEntry *b)
static bool static bool
_equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b) _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
{ {
if (a->rtekind != b->rtekind) COMPARE_SCALAR_FIELD(rtekind);
return false; COMPARE_SCALAR_FIELD(relid);
if (a->relid != b->relid) COMPARE_NODE_FIELD(subquery);
return false; COMPARE_NODE_FIELD(funcexpr);
if (!equal(a->subquery, b->subquery)) COMPARE_NODE_FIELD(coldeflist);
return false; COMPARE_SCALAR_FIELD(jointype);
if (!equal(a->funcexpr, b->funcexpr)) COMPARE_NODE_FIELD(joinaliasvars);
return false; COMPARE_NODE_FIELD(alias);
if (!equal(a->coldeflist, b->coldeflist)) COMPARE_NODE_FIELD(eref);
return false; COMPARE_SCALAR_FIELD(inh);
if (a->jointype != b->jointype) COMPARE_SCALAR_FIELD(inFromCl);
return false; COMPARE_SCALAR_FIELD(checkForRead);
if (!equal(a->joinaliasvars, b->joinaliasvars)) COMPARE_SCALAR_FIELD(checkForWrite);
return false; COMPARE_SCALAR_FIELD(checkAsUser);
if (!equal(a->alias, b->alias))
return false;
if (!equal(a->eref, b->eref))
return false;
if (a->inh != b->inh)
return false;
if (a->inFromCl != b->inFromCl)
return false;
if (a->checkForRead != b->checkForRead)
return false;
if (a->checkForWrite != b->checkForWrite)
return false;
if (a->checkAsUser != b->checkAsUser)
return false;
return true; return true;
} }
...@@ -1879,10 +1511,8 @@ _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b) ...@@ -1879,10 +1511,8 @@ _equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
static bool static bool
_equalSortClause(SortClause *a, SortClause *b) _equalSortClause(SortClause *a, SortClause *b)
{ {
if (a->tleSortGroupRef != b->tleSortGroupRef) COMPARE_SCALAR_FIELD(tleSortGroupRef);
return false; COMPARE_SCALAR_FIELD(sortop);
if (a->sortop != b->sortop)
return false;
return true; return true;
} }
...@@ -1890,26 +1520,16 @@ _equalSortClause(SortClause *a, SortClause *b) ...@@ -1890,26 +1520,16 @@ _equalSortClause(SortClause *a, SortClause *b)
static bool static bool
_equalFkConstraint(FkConstraint *a, FkConstraint *b) _equalFkConstraint(FkConstraint *a, FkConstraint *b)
{ {
if (!equalstr(a->constr_name, b->constr_name)) COMPARE_STRING_FIELD(constr_name);
return false; COMPARE_NODE_FIELD(pktable);
if (!equal(a->pktable, b->pktable)) COMPARE_NODE_FIELD(fk_attrs);
return false; COMPARE_NODE_FIELD(pk_attrs);
if (!equal(a->fk_attrs, b->fk_attrs)) COMPARE_SCALAR_FIELD(fk_matchtype);
return false; COMPARE_SCALAR_FIELD(fk_upd_action);
if (!equal(a->pk_attrs, b->pk_attrs)) COMPARE_SCALAR_FIELD(fk_del_action);
return false; COMPARE_SCALAR_FIELD(deferrable);
if (a->fk_matchtype != b->fk_matchtype) COMPARE_SCALAR_FIELD(initdeferred);
return false; COMPARE_SCALAR_FIELD(skip_validation);
if (a->fk_upd_action != b->fk_upd_action)
return false;
if (a->fk_del_action != b->fk_del_action)
return false;
if (a->deferrable != b->deferrable)
return false;
if (a->initdeferred != b->initdeferred)
return false;
if (a->skip_validation != b->skip_validation)
return false;
return true; return true;
} }
...@@ -1917,14 +1537,10 @@ _equalFkConstraint(FkConstraint *a, FkConstraint *b) ...@@ -1917,14 +1537,10 @@ _equalFkConstraint(FkConstraint *a, FkConstraint *b)
static bool static bool
_equalCaseExpr(CaseExpr *a, CaseExpr *b) _equalCaseExpr(CaseExpr *a, CaseExpr *b)
{ {
if (a->casetype != b->casetype) COMPARE_SCALAR_FIELD(casetype);
return false; COMPARE_NODE_FIELD(arg);
if (!equal(a->arg, b->arg)) COMPARE_NODE_FIELD(args);
return false; COMPARE_NODE_FIELD(defresult);
if (!equal(a->args, b->args))
return false;
if (!equal(a->defresult, b->defresult))
return false;
return true; return true;
} }
...@@ -1932,10 +1548,8 @@ _equalCaseExpr(CaseExpr *a, CaseExpr *b) ...@@ -1932,10 +1548,8 @@ _equalCaseExpr(CaseExpr *a, CaseExpr *b)
static bool static bool
_equalCaseWhen(CaseWhen *a, CaseWhen *b) _equalCaseWhen(CaseWhen *a, CaseWhen *b)
{ {
if (!equal(a->expr, b->expr)) COMPARE_NODE_FIELD(expr);
return false; COMPARE_NODE_FIELD(result);
if (!equal(a->result, b->result))
return false;
return true; return true;
} }
...@@ -1943,72 +1557,68 @@ _equalCaseWhen(CaseWhen *a, CaseWhen *b) ...@@ -1943,72 +1557,68 @@ _equalCaseWhen(CaseWhen *a, CaseWhen *b)
static bool static bool
_equalNullTest(NullTest *a, NullTest *b) _equalNullTest(NullTest *a, NullTest *b)
{ {
if (!equal(a->arg, b->arg)) COMPARE_NODE_FIELD(arg);
return false; COMPARE_SCALAR_FIELD(nulltesttype);
if (a->nulltesttype != b->nulltesttype)
return false;
return true; return true;
} }
static bool static bool
_equalBooleanTest(BooleanTest *a, BooleanTest *b) _equalBooleanTest(BooleanTest *a, BooleanTest *b)
{ {
if (!equal(a->arg, b->arg)) COMPARE_NODE_FIELD(arg);
return false; COMPARE_SCALAR_FIELD(booltesttype);
if (a->booltesttype != b->booltesttype)
return false;
return true; return true;
} }
static bool static bool
_equalConstraintTest(ConstraintTest *a, ConstraintTest *b) _equalConstraintTest(ConstraintTest *a, ConstraintTest *b)
{ {
if (!equal(a->arg, b->arg)) COMPARE_NODE_FIELD(arg);
return false; COMPARE_SCALAR_FIELD(testtype);
if (a->testtype != b->testtype) COMPARE_STRING_FIELD(name);
return false; COMPARE_STRING_FIELD(domname);
if (!equalstr(a->name, b->name)) COMPARE_NODE_FIELD(check_expr);
return false;
if (!equalstr(a->domname, b->domname))
return false;
if (!equal(a->check_expr, b->check_expr))
return false;
return true; return true;
} }
static bool static bool
_equalConstraintTestValue(ConstraintTestValue *a, ConstraintTestValue *b) _equalDomainConstraintValue(DomainConstraintValue *a, DomainConstraintValue *b)
{ {
if (a->typeId != b->typeId)
return false;
if (a->typeMod != b->typeMod)
return false;
return true; return true;
} }
static bool static bool
_equalDomainConstraintValue(DomainConstraintValue *a, DomainConstraintValue *b) _equalConstraintTestValue(ConstraintTestValue *a, ConstraintTestValue *b)
{ {
COMPARE_SCALAR_FIELD(typeId);
COMPARE_SCALAR_FIELD(typeMod);
return true; return true;
} }
/* /*
* Stuff from pg_list.h * Stuff from pg_list.h
*/ */
static bool static bool
_equalValue(Value *a, Value *b) _equalValue(Value *a, Value *b)
{ {
if (a->type != b->type) COMPARE_SCALAR_FIELD(type);
return false;
switch (a->type) switch (a->type)
{ {
case T_Integer: case T_Integer:
return a->val.ival == b->val.ival; COMPARE_SCALAR_FIELD(val.ival);
break;
case T_Float: case T_Float:
case T_String: case T_String:
case T_BitString: case T_BitString:
return strcmp(a->val.str, b->val.str) == 0; COMPARE_STRING_FIELD(val.str);
break;
case T_Null: case T_Null:
/* nothing to do */ /* nothing to do */
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment