summaryrefslogtreecommitdiff
path: root/src/backend/nodes
diff options
context:
space:
mode:
authorTom Lane2002-12-12 15:49:42 +0000
committerTom Lane2002-12-12 15:49:42 +0000
commita0bf885f9eaccadd23b766ecbc064f17f06ae883 (patch)
tree62b65e5cf1a8ec02ece3a98c15457ddff018bb94 /src/backend/nodes
parentdebb072886efcb15e7f0825e35b168afe316d37d (diff)
Phase 2 of read-only-plans project: restructure expression-tree nodes
so that all executable expression nodes inherit from a common supertype Expr. This is somewhat of an exercise in code purity rather than any real functional advance, but getting rid of the extra Oper or Func node formerly used in each operator or function call should provide at least a little space and speed improvement. initdb forced by changes in stored-rules representation.
Diffstat (limited to 'src/backend/nodes')
-rw-r--r--src/backend/nodes/copyfuncs.c510
-rw-r--r--src/backend/nodes/equalfuncs.c435
-rw-r--r--src/backend/nodes/makefuncs.c49
-rw-r--r--src/backend/nodes/nodeFuncs.c47
-rw-r--r--src/backend/nodes/outfuncs.c1039
-rw-r--r--src/backend/nodes/print.c6
-rw-r--r--src/backend/nodes/readfuncs.c458
7 files changed, 1319 insertions, 1225 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index a978e233e3d..f7aa8fcb7ec 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.229 2002/12/06 05:00:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.230 2002/12/12 15:49:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -563,21 +563,6 @@ _copyLimit(Limit *from)
return newnode;
}
-static SubPlan *
-_copySubPlan(SubPlan *from)
-{
- SubPlan *newnode = makeNode(SubPlan);
-
- COPY_NODE_FIELD(plan);
- COPY_SCALAR_FIELD(plan_id);
- COPY_NODE_FIELD(rtable);
- COPY_INTLIST_FIELD(setParam);
- COPY_INTLIST_FIELD(parParam);
- COPY_NODE_FIELD(sublink);
-
- return newnode;
-}
-
/* ****************************************************************
* primnodes.h copy functions
* ****************************************************************
@@ -603,20 +588,9 @@ _copyResdom(Resdom *from)
return newnode;
}
-static Fjoin *
-_copyFjoin(Fjoin *from)
-{
- Fjoin *newnode = makeNode(Fjoin);
-
- COPY_SCALAR_FIELD(fj_initialized);
- 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));
-
- return newnode;
-}
-
+/*
+ * _copyAlias
+ */
static Alias *
_copyAlias(Alias *from)
{
@@ -628,6 +602,9 @@ _copyAlias(Alias *from)
return newnode;
}
+/*
+ * _copyRangeVar
+ */
static RangeVar *
_copyRangeVar(RangeVar *from)
{
@@ -644,20 +621,11 @@ _copyRangeVar(RangeVar *from)
}
/*
- * _copyExpr
+ * We don't need a _copyExpr because Expr is an abstract supertype which
+ * should never actually get instantiated. Also, since it has no common
+ * fields except NodeTag, there's no need for a helper routine to factor
+ * out copying the common fields...
*/
-static Expr *
-_copyExpr(Expr *from)
-{
- Expr *newnode = makeNode(Expr);
-
- COPY_SCALAR_FIELD(typeOid);
- COPY_SCALAR_FIELD(opType);
- COPY_NODE_FIELD(oper);
- COPY_NODE_FIELD(args);
-
- return newnode;
-}
/*
* _copyVar
@@ -679,25 +647,6 @@ _copyVar(Var *from)
}
/*
- * _copyOper
- */
-static Oper *
-_copyOper(Oper *from)
-{
- Oper *newnode = makeNode(Oper);
-
- COPY_SCALAR_FIELD(opno);
- COPY_SCALAR_FIELD(opid);
- COPY_SCALAR_FIELD(opresulttype);
- COPY_SCALAR_FIELD(opretset);
-
- /* Do not copy the run-time state, if any */
- newnode->op_fcache = NULL;
-
- return newnode;
-}
-
-/*
* _copyConst
*/
static Const *
@@ -749,17 +698,57 @@ _copyParam(Param *from)
}
/*
- * _copyFunc
+ * _copyAggref
*/
-static Func *
-_copyFunc(Func *from)
+static Aggref *
+_copyAggref(Aggref *from)
{
- Func *newnode = makeNode(Func);
+ Aggref *newnode = makeNode(Aggref);
+
+ COPY_SCALAR_FIELD(aggfnoid);
+ COPY_SCALAR_FIELD(aggtype);
+ COPY_NODE_FIELD(target);
+ COPY_SCALAR_FIELD(aggstar);
+ COPY_SCALAR_FIELD(aggdistinct);
+ COPY_SCALAR_FIELD(aggno); /* will go away soon */
+
+ return newnode;
+}
+
+/*
+ * _copyArrayRef
+ */
+static ArrayRef *
+_copyArrayRef(ArrayRef *from)
+{
+ ArrayRef *newnode = makeNode(ArrayRef);
+
+ COPY_SCALAR_FIELD(refrestype);
+ COPY_SCALAR_FIELD(refattrlength);
+ COPY_SCALAR_FIELD(refelemlength);
+ COPY_SCALAR_FIELD(refelembyval);
+ COPY_SCALAR_FIELD(refelemalign);
+ COPY_NODE_FIELD(refupperindexpr);
+ COPY_NODE_FIELD(reflowerindexpr);
+ COPY_NODE_FIELD(refexpr);
+ COPY_NODE_FIELD(refassgnexpr);
+
+ return newnode;
+}
+
+/*
+ * _copyFuncExpr
+ */
+static FuncExpr *
+_copyFuncExpr(FuncExpr *from)
+{
+ FuncExpr *newnode = makeNode(FuncExpr);
COPY_SCALAR_FIELD(funcid);
COPY_SCALAR_FIELD(funcresulttype);
COPY_SCALAR_FIELD(funcretset);
COPY_SCALAR_FIELD(funcformat);
+ COPY_NODE_FIELD(args);
/* Do not copy the run-time state, if any */
newnode->func_fcache = NULL;
@@ -768,19 +757,55 @@ _copyFunc(Func *from)
}
/*
- * _copyAggref
+ * _copyOpExpr
*/
-static Aggref *
-_copyAggref(Aggref *from)
+static OpExpr *
+_copyOpExpr(OpExpr *from)
{
- Aggref *newnode = makeNode(Aggref);
+ OpExpr *newnode = makeNode(OpExpr);
- COPY_SCALAR_FIELD(aggfnoid);
- COPY_SCALAR_FIELD(aggtype);
- COPY_NODE_FIELD(target);
- COPY_SCALAR_FIELD(aggstar);
- COPY_SCALAR_FIELD(aggdistinct);
- COPY_SCALAR_FIELD(aggno); /* probably not necessary */
+ COPY_SCALAR_FIELD(opno);
+ COPY_SCALAR_FIELD(opfuncid);
+ COPY_SCALAR_FIELD(opresulttype);
+ COPY_SCALAR_FIELD(opretset);
+ COPY_NODE_FIELD(args);
+
+ /* Do not copy the run-time state, if any */
+ newnode->op_fcache = NULL;
+
+ return newnode;
+}
+
+/*
+ * _copyDistinctExpr
+ */
+static DistinctExpr *
+_copyDistinctExpr(DistinctExpr *from)
+{
+ DistinctExpr *newnode = makeNode(DistinctExpr);
+
+ COPY_SCALAR_FIELD(opno);
+ COPY_SCALAR_FIELD(opfuncid);
+ COPY_SCALAR_FIELD(opresulttype);
+ COPY_SCALAR_FIELD(opretset);
+ COPY_NODE_FIELD(args);
+
+ /* Do not copy the run-time state, if any */
+ newnode->op_fcache = NULL;
+
+ return newnode;
+}
+
+/*
+ * _copyBoolExpr
+ */
+static BoolExpr *
+_copyBoolExpr(BoolExpr *from)
+{
+ BoolExpr *newnode = makeNode(BoolExpr);
+
+ COPY_SCALAR_FIELD(boolop);
+ COPY_NODE_FIELD(args);
return newnode;
}
@@ -803,6 +828,26 @@ _copySubLink(SubLink *from)
}
/*
+ * _copySubPlanExpr
+ */
+static SubPlanExpr *
+_copySubPlanExpr(SubPlanExpr *from)
+{
+ SubPlanExpr *newnode = makeNode(SubPlanExpr);
+
+ COPY_SCALAR_FIELD(typeOid);
+ COPY_NODE_FIELD(plan);
+ COPY_SCALAR_FIELD(plan_id);
+ COPY_NODE_FIELD(rtable);
+ COPY_INTLIST_FIELD(setParam);
+ COPY_INTLIST_FIELD(parParam);
+ COPY_NODE_FIELD(args);
+ COPY_NODE_FIELD(sublink);
+
+ return newnode;
+}
+
+/*
* _copyFieldSelect
*/
static FieldSelect *
@@ -834,6 +879,112 @@ _copyRelabelType(RelabelType *from)
return newnode;
}
+/*
+ * _copyCaseExpr
+ */
+static CaseExpr *
+_copyCaseExpr(CaseExpr *from)
+{
+ CaseExpr *newnode = makeNode(CaseExpr);
+
+ COPY_SCALAR_FIELD(casetype);
+ COPY_NODE_FIELD(arg);
+ COPY_NODE_FIELD(args);
+ COPY_NODE_FIELD(defresult);
+
+ return newnode;
+}
+
+/*
+ * _copyCaseWhen
+ */
+static CaseWhen *
+_copyCaseWhen(CaseWhen *from)
+{
+ CaseWhen *newnode = makeNode(CaseWhen);
+
+ COPY_NODE_FIELD(expr);
+ COPY_NODE_FIELD(result);
+
+ return newnode;
+}
+
+/*
+ * _copyNullTest
+ */
+static NullTest *
+_copyNullTest(NullTest *from)
+{
+ NullTest *newnode = makeNode(NullTest);
+
+ COPY_NODE_FIELD(arg);
+ COPY_SCALAR_FIELD(nulltesttype);
+
+ return newnode;
+}
+
+/*
+ * _copyBooleanTest
+ */
+static BooleanTest *
+_copyBooleanTest(BooleanTest *from)
+{
+ BooleanTest *newnode = makeNode(BooleanTest);
+
+ COPY_NODE_FIELD(arg);
+ COPY_SCALAR_FIELD(booltesttype);
+
+ return newnode;
+}
+
+/*
+ * _copyConstraintTest
+ */
+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;
+}
+
+/*
+ * _copyConstraintTestValue
+ */
+static ConstraintTestValue *
+_copyConstraintTestValue(ConstraintTestValue *from)
+{
+ ConstraintTestValue *newnode = makeNode(ConstraintTestValue);
+
+ COPY_SCALAR_FIELD(typeId);
+ COPY_SCALAR_FIELD(typeMod);
+
+ return newnode;
+}
+
+/*
+ * _copyTargetEntry
+ */
+static TargetEntry *
+_copyTargetEntry(TargetEntry *from)
+{
+ TargetEntry *newnode = makeNode(TargetEntry);
+
+ COPY_NODE_FIELD(resdom);
+ COPY_NODE_FIELD(expr);
+
+ return newnode;
+}
+
+/*
+ * _copyRangeTblRef
+ */
static RangeTblRef *
_copyRangeTblRef(RangeTblRef *from)
{
@@ -844,6 +995,9 @@ _copyRangeTblRef(RangeTblRef *from)
return newnode;
}
+/*
+ * _copyJoinExpr
+ */
static JoinExpr *
_copyJoinExpr(JoinExpr *from)
{
@@ -861,6 +1015,9 @@ _copyJoinExpr(JoinExpr *from)
return newnode;
}
+/*
+ * _copyFromExpr
+ */
static FromExpr *
_copyFromExpr(FromExpr *from)
{
@@ -872,24 +1029,6 @@ _copyFromExpr(FromExpr *from)
return newnode;
}
-static ArrayRef *
-_copyArrayRef(ArrayRef *from)
-{
- ArrayRef *newnode = makeNode(ArrayRef);
-
- COPY_SCALAR_FIELD(refrestype);
- COPY_SCALAR_FIELD(refattrlength);
- COPY_SCALAR_FIELD(refelemlength);
- COPY_SCALAR_FIELD(refelembyval);
- COPY_SCALAR_FIELD(refelemalign);
- COPY_NODE_FIELD(refupperindexpr);
- COPY_NODE_FIELD(reflowerindexpr);
- COPY_NODE_FIELD(refexpr);
- COPY_NODE_FIELD(refassgnexpr);
-
- return newnode;
-}
-
/* ****************************************************************
* relation.h copy functions
*
@@ -964,18 +1103,6 @@ _copyJoinInfo(JoinInfo *from)
* ****************************************************************
*/
-static TargetEntry *
-_copyTargetEntry(TargetEntry *from)
-{
- TargetEntry *newnode = makeNode(TargetEntry);
-
- COPY_NODE_FIELD(resdom);
- COPY_NODE_FIELD(fjoin);
- COPY_NODE_FIELD(expr);
-
- return newnode;
-}
-
static RangeTblEntry *
_copyRangeTblEntry(RangeTblEntry *from)
{
@@ -1170,6 +1297,14 @@ _copyTypeName(TypeName *from)
return newnode;
}
+static DomainConstraintValue *
+_copyDomainConstraintValue(DomainConstraintValue *from)
+{
+ DomainConstraintValue *newnode = makeNode(DomainConstraintValue);
+
+ return newnode;
+}
+
static SortGroupBy *
_copySortGroupBy(SortGroupBy *from)
{
@@ -1260,85 +1395,6 @@ _copyConstraint(Constraint *from)
return newnode;
}
-static CaseExpr *
-_copyCaseExpr(CaseExpr *from)
-{
- CaseExpr *newnode = makeNode(CaseExpr);
-
- COPY_SCALAR_FIELD(casetype);
- COPY_NODE_FIELD(arg);
- COPY_NODE_FIELD(args);
- COPY_NODE_FIELD(defresult);
-
- return newnode;
-}
-
-static CaseWhen *
-_copyCaseWhen(CaseWhen *from)
-{
- CaseWhen *newnode = makeNode(CaseWhen);
-
- COPY_NODE_FIELD(expr);
- COPY_NODE_FIELD(result);
-
- return newnode;
-}
-
-static NullTest *
-_copyNullTest(NullTest *from)
-{
- NullTest *newnode = makeNode(NullTest);
-
- COPY_NODE_FIELD(arg);
- COPY_SCALAR_FIELD(nulltesttype);
-
- return newnode;
-}
-
-static BooleanTest *
-_copyBooleanTest(BooleanTest *from)
-{
- BooleanTest *newnode = makeNode(BooleanTest);
-
- 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);
-
- COPY_SCALAR_FIELD(typeId);
- COPY_SCALAR_FIELD(typeMod);
-
- return newnode;
-}
-
static DefElem *
_copyDefElem(DefElem *from)
{
@@ -2350,9 +2406,6 @@ copyObject(void *from)
case T_Limit:
retval = _copyLimit(from);
break;
- case T_SubPlan:
- retval = _copySubPlan(from);
- break;
/*
* PRIMITIVE NODES
@@ -2360,45 +2413,72 @@ copyObject(void *from)
case T_Resdom:
retval = _copyResdom(from);
break;
- case T_Fjoin:
- retval = _copyFjoin(from);
- break;
case T_Alias:
retval = _copyAlias(from);
break;
case T_RangeVar:
retval = _copyRangeVar(from);
break;
- case T_Expr:
- retval = _copyExpr(from);
- break;
case T_Var:
retval = _copyVar(from);
break;
- case T_Oper:
- retval = _copyOper(from);
- break;
case T_Const:
retval = _copyConst(from);
break;
case T_Param:
retval = _copyParam(from);
break;
- case T_Func:
- retval = _copyFunc(from);
- break;
case T_Aggref:
retval = _copyAggref(from);
break;
+ case T_ArrayRef:
+ retval = _copyArrayRef(from);
+ break;
+ case T_FuncExpr:
+ retval = _copyFuncExpr(from);
+ break;
+ case T_OpExpr:
+ retval = _copyOpExpr(from);
+ break;
+ case T_DistinctExpr:
+ retval = _copyDistinctExpr(from);
+ break;
+ case T_BoolExpr:
+ retval = _copyBoolExpr(from);
+ break;
case T_SubLink:
retval = _copySubLink(from);
break;
+ case T_SubPlanExpr:
+ retval = _copySubPlanExpr(from);
+ break;
case T_FieldSelect:
retval = _copyFieldSelect(from);
break;
case T_RelabelType:
retval = _copyRelabelType(from);
break;
+ case T_CaseExpr:
+ retval = _copyCaseExpr(from);
+ break;
+ case T_CaseWhen:
+ retval = _copyCaseWhen(from);
+ break;
+ case T_NullTest:
+ retval = _copyNullTest(from);
+ break;
+ case T_BooleanTest:
+ retval = _copyBooleanTest(from);
+ break;
+ case T_ConstraintTest:
+ retval = _copyConstraintTest(from);
+ break;
+ case T_ConstraintTestValue:
+ retval = _copyConstraintTestValue(from);
+ break;
+ case T_TargetEntry:
+ retval = _copyTargetEntry(from);
+ break;
case T_RangeTblRef:
retval = _copyRangeTblRef(from);
break;
@@ -2408,9 +2488,6 @@ copyObject(void *from)
case T_FromExpr:
retval = _copyFromExpr(from);
break;
- case T_ArrayRef:
- retval = _copyArrayRef(from);
- break;
/*
* RELATION NODES
@@ -2686,6 +2763,9 @@ copyObject(void *from)
case T_TypeCast:
retval = _copyTypeCast(from);
break;
+ case T_DomainConstraintValue:
+ retval = _copyDomainConstraintValue(from);
+ break;
case T_SortGroupBy:
retval = _copySortGroupBy(from);
break;
@@ -2710,9 +2790,6 @@ copyObject(void *from)
case T_DefElem:
retval = _copyDefElem(from);
break;
- case T_TargetEntry:
- retval = _copyTargetEntry(from);
- break;
case T_RangeTblEntry:
retval = _copyRangeTblEntry(from);
break;
@@ -2722,24 +2799,6 @@ copyObject(void *from)
case T_GroupClause:
retval = _copyGroupClause(from);
break;
- case T_CaseExpr:
- retval = _copyCaseExpr(from);
- break;
- case T_CaseWhen:
- retval = _copyCaseWhen(from);
- break;
- case T_NullTest:
- retval = _copyNullTest(from);
- break;
- case T_BooleanTest:
- retval = _copyBooleanTest(from);
- break;
- case T_ConstraintTest:
- retval = _copyConstraintTest(from);
- break;
- case T_ConstraintTestValue:
- retval = _copyConstraintTestValue(from);
- break;
case T_FkConstraint:
retval = _copyFkConstraint(from);
break;
@@ -2752,9 +2811,6 @@ copyObject(void *from)
case T_InsertDefault:
retval = _copyInsertDefault(from);
break;
- case T_DomainConstraintValue:
- retval = _copyDomainConstraintValue(from);
- break;
default:
elog(ERROR, "copyObject: don't know how to copy node type %d",
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 71227097104..3b510382068 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.174 2002/12/06 05:00:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.175 2002/12/12 15:49:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,7 +27,6 @@
#include "nodes/params.h"
#include "nodes/parsenodes.h"
-#include "nodes/plannodes.h"
#include "nodes/relation.h"
#include "utils/datum.h"
@@ -99,18 +98,6 @@ _equalResdom(Resdom *a, Resdom *b)
}
static bool
-_equalFjoin(Fjoin *a, Fjoin *b)
-{
- 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));
-
- return true;
-}
-
-static bool
_equalAlias(Alias *a, Alias *b)
{
COMPARE_STRING_FIELD(aliasname);
@@ -132,20 +119,12 @@ _equalRangeVar(RangeVar *a, RangeVar *b)
return true;
}
-static bool
-_equalExpr(Expr *a, Expr *b)
-{
- /*
- * We do not examine typeOid, since the optimizer often doesn't bother
- * to set it in created nodes, and it is logically a derivative of the
- * oper field anyway.
- */
- COMPARE_SCALAR_FIELD(opType);
- COMPARE_NODE_FIELD(oper);
- COMPARE_NODE_FIELD(args);
-
- return true;
-}
+/*
+ * We don't need an _equalExpr because Expr is an abstract supertype which
+ * should never actually get instantiated. Also, since it has no common
+ * fields except NodeTag, there's no need for a helper routine to factor
+ * out comparing the common fields...
+ */
static bool
_equalVar(Var *a, Var *b)
@@ -162,28 +141,6 @@ _equalVar(Var *a, Var *b)
}
static bool
-_equalOper(Oper *a, Oper *b)
-{
- COMPARE_SCALAR_FIELD(opno);
- COMPARE_SCALAR_FIELD(opresulttype);
- COMPARE_SCALAR_FIELD(opretset);
-
- /*
- * We do not examine opid or op_fcache, since these are logically
- * derived from opno, and they may not be set yet depending on how far
- * along the node is in the parse/plan pipeline.
- *
- * (Besides, op_fcache is executor state, which we don't check --- see
- * notes at head of file.)
- *
- * It's probably not really necessary to check opresulttype or opretset,
- * either...
- */
-
- return true;
-}
-
-static bool
_equalConst(Const *a, Const *b)
{
COMPARE_SCALAR_FIELD(consttype);
@@ -226,7 +183,35 @@ _equalParam(Param *a, Param *b)
}
static bool
-_equalFunc(Func *a, Func *b)
+_equalAggref(Aggref *a, Aggref *b)
+{
+ COMPARE_SCALAR_FIELD(aggfnoid);
+ COMPARE_SCALAR_FIELD(aggtype);
+ COMPARE_NODE_FIELD(target);
+ COMPARE_SCALAR_FIELD(aggstar);
+ COMPARE_SCALAR_FIELD(aggdistinct);
+
+ return true;
+}
+
+static bool
+_equalArrayRef(ArrayRef *a, ArrayRef *b)
+{
+ COMPARE_SCALAR_FIELD(refrestype);
+ COMPARE_SCALAR_FIELD(refattrlength);
+ COMPARE_SCALAR_FIELD(refelemlength);
+ COMPARE_SCALAR_FIELD(refelembyval);
+ COMPARE_SCALAR_FIELD(refelemalign);
+ COMPARE_NODE_FIELD(refupperindexpr);
+ COMPARE_NODE_FIELD(reflowerindexpr);
+ COMPARE_NODE_FIELD(refexpr);
+ COMPARE_NODE_FIELD(refassgnexpr);
+
+ return true;
+}
+
+static bool
+_equalFuncExpr(FuncExpr *a, FuncExpr *b)
{
COMPARE_SCALAR_FIELD(funcid);
COMPARE_SCALAR_FIELD(funcresulttype);
@@ -240,20 +225,60 @@ _equalFunc(Func *a, Func *b)
b->funcformat != COERCE_DONTCARE)
return false;
- /* Note we do not look at func_fcache; see notes for _equalOper */
+ COMPARE_NODE_FIELD(args);
return true;
}
static bool
-_equalAggref(Aggref *a, Aggref *b)
+_equalOpExpr(OpExpr *a, OpExpr *b)
{
- COMPARE_SCALAR_FIELD(aggfnoid);
- COMPARE_SCALAR_FIELD(aggtype);
- COMPARE_NODE_FIELD(target);
- COMPARE_SCALAR_FIELD(aggstar);
- COMPARE_SCALAR_FIELD(aggdistinct);
- /* ignore aggno, which is only a private field for the executor */
+ COMPARE_SCALAR_FIELD(opno);
+ /*
+ * Special-case opfuncid: it is allowable for it to differ if one
+ * node contains zero and the other doesn't. This just means that the
+ * one node isn't as far along in the parse/plan pipeline and hasn't
+ * had the opfuncid cache filled yet.
+ */
+ if (a->opfuncid != b->opfuncid &&
+ a->opfuncid != 0 &&
+ b->opfuncid != 0)
+ return false;
+
+ COMPARE_SCALAR_FIELD(opresulttype);
+ COMPARE_SCALAR_FIELD(opretset);
+ COMPARE_NODE_FIELD(args);
+
+ return true;
+}
+
+static bool
+_equalDistinctExpr(DistinctExpr *a, DistinctExpr *b)
+{
+ COMPARE_SCALAR_FIELD(opno);
+ /*
+ * Special-case opfuncid: it is allowable for it to differ if one
+ * node contains zero and the other doesn't. This just means that the
+ * one node isn't as far along in the parse/plan pipeline and hasn't
+ * had the opfuncid cache filled yet.
+ */
+ if (a->opfuncid != b->opfuncid &&
+ a->opfuncid != 0 &&
+ b->opfuncid != 0)
+ return false;
+
+ COMPARE_SCALAR_FIELD(opresulttype);
+ COMPARE_SCALAR_FIELD(opretset);
+ COMPARE_NODE_FIELD(args);
+
+ return true;
+}
+
+static bool
+_equalBoolExpr(BoolExpr *a, BoolExpr *b)
+{
+ COMPARE_SCALAR_FIELD(boolop);
+ COMPARE_NODE_FIELD(args);
return true;
}
@@ -271,6 +296,21 @@ _equalSubLink(SubLink *a, SubLink *b)
}
static bool
+_equalSubPlanExpr(SubPlanExpr *a, SubPlanExpr *b)
+{
+ COMPARE_SCALAR_FIELD(typeOid);
+ /* should compare plans, but have to settle for comparing plan IDs */
+ COMPARE_SCALAR_FIELD(plan_id);
+ COMPARE_NODE_FIELD(rtable);
+ COMPARE_INTLIST_FIELD(setParam);
+ COMPARE_INTLIST_FIELD(parParam);
+ COMPARE_NODE_FIELD(args);
+ COMPARE_NODE_FIELD(sublink);
+
+ return true;
+}
+
+static bool
_equalFieldSelect(FieldSelect *a, FieldSelect *b)
{
COMPARE_NODE_FIELD(arg);
@@ -300,66 +340,101 @@ _equalRelabelType(RelabelType *a, RelabelType *b)
}
static bool
-_equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
+_equalCaseExpr(CaseExpr *a, CaseExpr *b)
{
- COMPARE_SCALAR_FIELD(rtindex);
+ COMPARE_SCALAR_FIELD(casetype);
+ COMPARE_NODE_FIELD(arg);
+ COMPARE_NODE_FIELD(args);
+ COMPARE_NODE_FIELD(defresult);
return true;
}
static bool
-_equalJoinExpr(JoinExpr *a, JoinExpr *b)
+_equalCaseWhen(CaseWhen *a, CaseWhen *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);
+ COMPARE_NODE_FIELD(expr);
+ COMPARE_NODE_FIELD(result);
return true;
}
static bool
-_equalFromExpr(FromExpr *a, FromExpr *b)
+_equalNullTest(NullTest *a, NullTest *b)
{
- COMPARE_NODE_FIELD(fromlist);
- COMPARE_NODE_FIELD(quals);
+ COMPARE_NODE_FIELD(arg);
+ COMPARE_SCALAR_FIELD(nulltesttype);
return true;
}
static bool
-_equalArrayRef(ArrayRef *a, ArrayRef *b)
+_equalBooleanTest(BooleanTest *a, BooleanTest *b)
{
- COMPARE_SCALAR_FIELD(refrestype);
- COMPARE_SCALAR_FIELD(refattrlength);
- COMPARE_SCALAR_FIELD(refelemlength);
- COMPARE_SCALAR_FIELD(refelembyval);
- COMPARE_SCALAR_FIELD(refelemalign);
- COMPARE_NODE_FIELD(refupperindexpr);
- COMPARE_NODE_FIELD(reflowerindexpr);
- COMPARE_NODE_FIELD(refexpr);
- COMPARE_NODE_FIELD(refassgnexpr);
+ COMPARE_NODE_FIELD(arg);
+ COMPARE_SCALAR_FIELD(booltesttype);
return true;
}
+static bool
+_equalConstraintTest(ConstraintTest *a, ConstraintTest *b)
+{
+ COMPARE_NODE_FIELD(arg);
+ COMPARE_SCALAR_FIELD(testtype);
+ COMPARE_STRING_FIELD(name);
+ COMPARE_STRING_FIELD(domname);
+ COMPARE_NODE_FIELD(check_expr);
-/*
- * Stuff from plannodes.h
- */
+ return true;
+}
static bool
-_equalSubPlan(SubPlan *a, SubPlan *b)
+_equalConstraintTestValue(ConstraintTestValue *a, ConstraintTestValue *b)
{
- /* should compare plans, but have to settle for comparing plan IDs */
- COMPARE_SCALAR_FIELD(plan_id);
+ COMPARE_SCALAR_FIELD(typeId);
+ COMPARE_SCALAR_FIELD(typeMod);
- COMPARE_NODE_FIELD(rtable);
- COMPARE_NODE_FIELD(sublink);
+ return true;
+}
+
+static bool
+_equalTargetEntry(TargetEntry *a, TargetEntry *b)
+{
+ COMPARE_NODE_FIELD(resdom);
+ COMPARE_NODE_FIELD(expr);
+
+ return true;
+}
+
+static bool
+_equalRangeTblRef(RangeTblRef *a, RangeTblRef *b)
+{
+ COMPARE_SCALAR_FIELD(rtindex);
+
+ 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;
+}
+
+static bool
+_equalFromExpr(FromExpr *a, FromExpr *b)
+{
+ COMPARE_NODE_FIELD(fromlist);
+ COMPARE_NODE_FIELD(quals);
return true;
}
@@ -574,6 +649,12 @@ _equalInsertDefault(InsertDefault *a, InsertDefault *b)
}
static bool
+_equalDomainConstraintValue(DomainConstraintValue *a, DomainConstraintValue *b)
+{
+ return true;
+}
+
+static bool
_equalClosePortalStmt(ClosePortalStmt *a, ClosePortalStmt *b)
{
COMPARE_STRING_FIELD(portalname);
@@ -1341,16 +1422,6 @@ _equalDefElem(DefElem *a, DefElem *b)
}
static bool
-_equalTargetEntry(TargetEntry *a, TargetEntry *b)
-{
- COMPARE_NODE_FIELD(resdom);
- COMPARE_NODE_FIELD(fjoin);
- COMPARE_NODE_FIELD(expr);
-
- return true;
-}
-
-static bool
_equalRangeTblEntry(RangeTblEntry *a, RangeTblEntry *b)
{
COMPARE_SCALAR_FIELD(rtekind);
@@ -1397,71 +1468,6 @@ _equalFkConstraint(FkConstraint *a, FkConstraint *b)
return true;
}
-static bool
-_equalCaseExpr(CaseExpr *a, CaseExpr *b)
-{
- COMPARE_SCALAR_FIELD(casetype);
- COMPARE_NODE_FIELD(arg);
- COMPARE_NODE_FIELD(args);
- COMPARE_NODE_FIELD(defresult);
-
- return true;
-}
-
-static bool
-_equalCaseWhen(CaseWhen *a, CaseWhen *b)
-{
- COMPARE_NODE_FIELD(expr);
- COMPARE_NODE_FIELD(result);
-
- return true;
-}
-
-static bool
-_equalNullTest(NullTest *a, NullTest *b)
-{
- COMPARE_NODE_FIELD(arg);
- COMPARE_SCALAR_FIELD(nulltesttype);
-
- return true;
-}
-
-static bool
-_equalBooleanTest(BooleanTest *a, BooleanTest *b)
-{
- COMPARE_NODE_FIELD(arg);
- COMPARE_SCALAR_FIELD(booltesttype);
-
- return true;
-}
-
-static bool
-_equalConstraintTest(ConstraintTest *a, ConstraintTest *b)
-{
- COMPARE_NODE_FIELD(arg);
- COMPARE_SCALAR_FIELD(testtype);
- COMPARE_STRING_FIELD(name);
- COMPARE_STRING_FIELD(domname);
- COMPARE_NODE_FIELD(check_expr);
-
- return true;
-}
-
-static bool
-_equalDomainConstraintValue(DomainConstraintValue *a, DomainConstraintValue *b)
-{
- return true;
-}
-
-static bool
-_equalConstraintTestValue(ConstraintTestValue *a, ConstraintTestValue *b)
-{
- COMPARE_SCALAR_FIELD(typeId);
- COMPARE_SCALAR_FIELD(typeMod);
-
- return true;
-}
-
/*
* Stuff from pg_list.h
@@ -1519,25 +1525,21 @@ equal(void *a, void *b)
switch (nodeTag(a))
{
- case T_SubPlan:
- retval = _equalSubPlan(a, b);
- break;
-
+ /*
+ * PRIMITIVE NODES
+ */
case T_Resdom:
retval = _equalResdom(a, b);
break;
- case T_Fjoin:
- retval = _equalFjoin(a, b);
+ case T_Alias:
+ retval = _equalAlias(a, b);
break;
- case T_Expr:
- retval = _equalExpr(a, b);
+ case T_RangeVar:
+ retval = _equalRangeVar(a, b);
break;
case T_Var:
retval = _equalVar(a, b);
break;
- case T_Oper:
- retval = _equalOper(a, b);
- break;
case T_Const:
retval = _equalConst(a, b);
break;
@@ -1547,21 +1549,54 @@ equal(void *a, void *b)
case T_Aggref:
retval = _equalAggref(a, b);
break;
+ case T_ArrayRef:
+ retval = _equalArrayRef(a, b);
+ break;
+ case T_FuncExpr:
+ retval = _equalFuncExpr(a, b);
+ break;
+ case T_OpExpr:
+ retval = _equalOpExpr(a, b);
+ break;
+ case T_DistinctExpr:
+ retval = _equalDistinctExpr(a, b);
+ break;
+ case T_BoolExpr:
+ retval = _equalBoolExpr(a, b);
+ break;
case T_SubLink:
retval = _equalSubLink(a, b);
break;
- case T_Func:
- retval = _equalFunc(a, b);
+ case T_SubPlanExpr:
+ retval = _equalSubPlanExpr(a, b);
break;
case T_FieldSelect:
retval = _equalFieldSelect(a, b);
break;
- case T_ArrayRef:
- retval = _equalArrayRef(a, b);
- break;
case T_RelabelType:
retval = _equalRelabelType(a, b);
break;
+ case T_CaseExpr:
+ retval = _equalCaseExpr(a, b);
+ break;
+ case T_CaseWhen:
+ retval = _equalCaseWhen(a, b);
+ break;
+ case T_NullTest:
+ retval = _equalNullTest(a, b);
+ break;
+ case T_BooleanTest:
+ retval = _equalBooleanTest(a, b);
+ break;
+ case T_ConstraintTest:
+ retval = _equalConstraintTest(a, b);
+ break;
+ case T_ConstraintTestValue:
+ retval = _equalConstraintTestValue(a, b);
+ break;
+ case T_TargetEntry:
+ retval = _equalTargetEntry(a, b);
+ break;
case T_RangeTblRef:
retval = _equalRangeTblRef(a, b);
break;
@@ -1572,6 +1607,9 @@ equal(void *a, void *b)
retval = _equalJoinExpr(a, b);
break;
+ /*
+ * RELATION NODES
+ */
case T_PathKeyItem:
retval = _equalPathKeyItem(a, b);
break;
@@ -1582,6 +1620,9 @@ equal(void *a, void *b)
retval = _equalJoinInfo(a, b);
break;
+ /*
+ * LIST NODES
+ */
case T_List:
{
List *la = (List *) a;
@@ -1612,6 +1653,9 @@ equal(void *a, void *b)
retval = _equalValue(a, b);
break;
+ /*
+ * PARSE NODES
+ */
case T_Query:
retval = _equalQuery(a, b);
break;
@@ -1844,12 +1888,6 @@ equal(void *a, void *b)
case T_SortGroupBy:
retval = _equalSortGroupBy(a, b);
break;
- case T_Alias:
- retval = _equalAlias(a, b);
- break;
- case T_RangeVar:
- retval = _equalRangeVar(a, b);
- break;
case T_RangeSubselect:
retval = _equalRangeSubselect(a, b);
break;
@@ -1871,9 +1909,6 @@ equal(void *a, void *b)
case T_DefElem:
retval = _equalDefElem(a, b);
break;
- case T_TargetEntry:
- retval = _equalTargetEntry(a, b);
- break;
case T_RangeTblEntry:
retval = _equalRangeTblEntry(a, b);
break;
@@ -1884,24 +1919,6 @@ equal(void *a, void *b)
/* GroupClause is equivalent to SortClause */
retval = _equalSortClause(a, b);
break;
- case T_CaseExpr:
- retval = _equalCaseExpr(a, b);
- break;
- case T_CaseWhen:
- retval = _equalCaseWhen(a, b);
- break;
- case T_NullTest:
- retval = _equalNullTest(a, b);
- break;
- case T_BooleanTest:
- retval = _equalBooleanTest(a, b);
- break;
- case T_ConstraintTest:
- retval = _equalConstraintTest(a, b);
- break;
- case T_ConstraintTestValue:
- retval = _equalConstraintTestValue(a, b);
- break;
case T_FkConstraint:
retval = _equalFkConstraint(a, b);
break;
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index a97a6df2fda..de13e943d5e 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -1,4 +1,5 @@
-/*
+/*-------------------------------------------------------------------------
+ *
* makefuncs.c
* creator functions for primitive nodes. The functions here are for
* the most frequently created nodes.
@@ -8,7 +9,9 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.36 2002/11/25 21:29:36 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.37 2002/12/12 15:49:28 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
*/
#include "postgres.h"
@@ -50,29 +53,8 @@ makeSimpleA_Expr(int oper, const char *name,
}
/*
- * makeOper -
- * creates an Oper node
- */
-Oper *
-makeOper(Oid opno,
- Oid opid,
- Oid opresulttype,
- bool opretset)
-{
- Oper *oper = makeNode(Oper);
-
- oper->opno = opno;
- oper->opid = opid;
- oper->opresulttype = opresulttype;
- oper->opretset = opretset;
- oper->op_fcache = NULL;
- return oper;
-}
-
-/*
* makeVar -
* creates a Var node
- *
*/
Var *
makeVar(Index varno,
@@ -104,10 +86,10 @@ makeVar(Index varno,
/*
* makeTargetEntry -
- * creates a TargetEntry node(contains a Resdom)
+ * creates a TargetEntry node (contains a Resdom)
*/
TargetEntry *
-makeTargetEntry(Resdom *resdom, Node *expr)
+makeTargetEntry(Resdom *resdom, Expr *expr)
{
TargetEntry *rt = makeNode(TargetEntry);
@@ -189,6 +171,21 @@ makeNullConst(Oid consttype)
}
/*
+ * makeBoolExpr -
+ * creates a BoolExpr node
+ */
+Expr *
+makeBoolExpr(BoolExprType boolop, List *args)
+{
+ BoolExpr *b = makeNode(BoolExpr);
+
+ b->boolop = boolop;
+ b->args = args;
+
+ return (Expr *) b;
+}
+
+/*
* makeAlias -
* creates an Alias node
*
@@ -210,7 +207,7 @@ makeAlias(const char *aliasname, List *colnames)
* creates a RelabelType node
*/
RelabelType *
-makeRelabelType(Node *arg, Oid rtype, int32 rtypmod, CoercionForm rformat)
+makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, CoercionForm rformat)
{
RelabelType *r = makeNode(RelabelType);
diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c
index f2bfb0a7d2d..299c910cc3b 100644
--- a/src/backend/nodes/nodeFuncs.c
+++ b/src/backend/nodes/nodeFuncs.c
@@ -8,12 +8,10 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.19 2002/09/02 02:47:02 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.20 2002/12/12 15:49:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
-
-
#include "postgres.h"
#include "nodes/nodeFuncs.h"
@@ -21,6 +19,7 @@
static bool var_is_inner(Var *var);
+
/*
* single_node -
* Returns t if node corresponds to a single-noded expression
@@ -79,41 +78,15 @@ var_is_rel(Var *var)
*****************************************************************************/
/*
- * replace_opid -
- *
- * Given a oper node, resets the opfid field with the
- * procedure OID (regproc id).
- *
- * Returns the modified oper node.
+ * set_opfuncid -
*
+ * Set the opfuncid (procedure OID) in an OpExpr node,
+ * if it hasn't been set already.
*/
-Oper *
-replace_opid(Oper *oper)
+void
+set_opfuncid(OpExpr *opexpr)
{
- oper->opid = get_opcode(oper->opno);
- oper->op_fcache = NULL;
- return oper;
+ if (opexpr->opfuncid == InvalidOid)
+ opexpr->opfuncid = get_opcode(opexpr->opno);
+ opexpr->op_fcache = NULL; /* XXX will go away soon */
}
-
-/*****************************************************************************
- * constant (CONST, PARAM) nodes
- *****************************************************************************/
-
-#ifdef NOT_USED
-/*
- * non_null -
- * Returns t if the node is a non-null constant, e.g., if the node has a
- * valid `constvalue' field.
- */
-bool
-non_null(Expr *c)
-{
-
- if (IsA(c, Const) &&
- !((Const *) c)->constisnull)
- return true;
- else
- return false;
-}
-
-#endif
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 2c254001eec..bd44816e6fa 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.186 2002/12/05 15:50:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.187 2002/12/12 15:49:28 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@@ -99,9 +99,9 @@
#define booltostr(x) ((x) ? "true" : "false")
-static void _outDatum(StringInfo str, Datum value, int typlen, bool typbyval);
static void _outNode(StringInfo str, void *obj);
+
/*
* _outToken
* Convert an ordinary string (eg, an identifier) into a form that
@@ -172,196 +172,41 @@ _outOidList(StringInfo str, List *list)
appendStringInfoChar(str, ')');
}
+/*
+ * Print the value of a Datum given its type.
+ */
static void
-_outCreateStmt(StringInfo str, CreateStmt *node)
-{
- WRITE_NODE_TYPE("CREATE");
-
- WRITE_NODE_FIELD(relation);
- WRITE_NODE_FIELD(tableElts);
- WRITE_NODE_FIELD(inhRelations);
- WRITE_NODE_FIELD(constraints);
- WRITE_BOOL_FIELD(hasoids);
- WRITE_ENUM_FIELD(oncommit, OnCommitAction);
-}
-
-static void
-_outIndexStmt(StringInfo str, IndexStmt *node)
-{
- WRITE_NODE_TYPE("INDEX");
-
- WRITE_STRING_FIELD(idxname);
- WRITE_NODE_FIELD(relation);
- WRITE_STRING_FIELD(accessMethod);
- WRITE_NODE_FIELD(indexParams);
- WRITE_NODE_FIELD(whereClause);
- WRITE_NODE_FIELD(rangetable);
- WRITE_BOOL_FIELD(unique);
- WRITE_BOOL_FIELD(primary);
- WRITE_BOOL_FIELD(isconstraint);
-}
-
-static void
-_outNotifyStmt(StringInfo str, NotifyStmt *node)
-{
- WRITE_NODE_TYPE("NOTIFY");
-
- WRITE_NODE_FIELD(relation);
-}
-
-static void
-_outSelectStmt(StringInfo str, SelectStmt *node)
-{
- WRITE_NODE_TYPE("SELECT");
-
- /* XXX this is pretty durn incomplete */
- WRITE_NODE_FIELD(whereClause);
-}
-
-static void
-_outFuncCall(StringInfo str, FuncCall *node)
-{
- WRITE_NODE_TYPE("FUNCCALL");
-
- WRITE_NODE_FIELD(funcname);
- WRITE_NODE_FIELD(args);
- WRITE_BOOL_FIELD(agg_star);
- WRITE_BOOL_FIELD(agg_distinct);
-}
-
-static void
-_outColumnDef(StringInfo str, ColumnDef *node)
-{
- WRITE_NODE_TYPE("COLUMNDEF");
-
- WRITE_STRING_FIELD(colname);
- WRITE_NODE_FIELD(typename);
- WRITE_INT_FIELD(inhcount);
- WRITE_BOOL_FIELD(is_local);
- WRITE_BOOL_FIELD(is_not_null);
- WRITE_NODE_FIELD(raw_default);
- WRITE_STRING_FIELD(cooked_default);
- WRITE_NODE_FIELD(constraints);
- WRITE_NODE_FIELD(support);
-}
-
-static void
-_outTypeName(StringInfo str, TypeName *node)
-{
- WRITE_NODE_TYPE("TYPENAME");
-
- WRITE_NODE_FIELD(names);
- WRITE_OID_FIELD(typeid);
- WRITE_BOOL_FIELD(timezone);
- WRITE_BOOL_FIELD(setof);
- WRITE_BOOL_FIELD(pct_type);
- WRITE_INT_FIELD(typmod);
- WRITE_NODE_FIELD(arrayBounds);
-}
-
-static void
-_outTypeCast(StringInfo str, TypeCast *node)
-{
- WRITE_NODE_TYPE("TYPECAST");
-
- WRITE_NODE_FIELD(arg);
- WRITE_NODE_FIELD(typename);
-}
-
-static void
-_outIndexElem(StringInfo str, IndexElem *node)
-{
- WRITE_NODE_TYPE("INDEXELEM");
-
- WRITE_STRING_FIELD(name);
- WRITE_NODE_FIELD(funcname);
- WRITE_NODE_FIELD(args);
- WRITE_NODE_FIELD(opclass);
-}
-
-static void
-_outQuery(StringInfo str, Query *node)
+_outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
{
- WRITE_NODE_TYPE("QUERY");
+ Size length,
+ i;
+ char *s;
- WRITE_ENUM_FIELD(commandType, CmdType);
- WRITE_ENUM_FIELD(querySource, QuerySource);
+ length = datumGetSize(value, typbyval, typlen);
- /*
- * Hack to work around missing outfuncs routines for a lot of the
- * utility-statement node types. (The only one we actually *need* for
- * rules support is NotifyStmt.) Someday we ought to support 'em all,
- * but for the meantime do this to avoid getting lots of warnings when
- * running with debug_print_parse on.
- */
- if (node->utilityStmt)
+ if (typbyval)
{
- switch (nodeTag(node->utilityStmt))
+ s = (char *) (&value);
+ appendStringInfo(str, "%u [ ", (unsigned int) length);
+ for (i = 0; i < (Size) sizeof(Datum); i++)
+ appendStringInfo(str, "%d ", (int) (s[i]));
+ appendStringInfo(str, "]");
+ }
+ else
+ {
+ s = (char *) DatumGetPointer(value);
+ if (!PointerIsValid(s))
+ appendStringInfo(str, "0 [ ]");
+ else
{
- case T_CreateStmt:
- case T_IndexStmt:
- case T_NotifyStmt:
- WRITE_NODE_FIELD(utilityStmt);
- break;
- default:
- appendStringInfo(str, " :utilityStmt ?");
- break;
+ appendStringInfo(str, "%u [ ", (unsigned int) length);
+ for (i = 0; i < length; i++)
+ appendStringInfo(str, "%d ", (int) (s[i]));
+ appendStringInfo(str, "]");
}
}
- else
- appendStringInfo(str, " :utilityStmt <>");
-
- WRITE_INT_FIELD(resultRelation);
- WRITE_NODE_FIELD(into);
- WRITE_BOOL_FIELD(isPortal);
- WRITE_BOOL_FIELD(isBinary);
- WRITE_BOOL_FIELD(hasAggs);
- WRITE_BOOL_FIELD(hasSubLinks);
- WRITE_NODE_FIELD(rtable);
- WRITE_NODE_FIELD(jointree);
- WRITE_INTLIST_FIELD(rowMarks);
- WRITE_NODE_FIELD(targetList);
- WRITE_NODE_FIELD(groupClause);
- WRITE_NODE_FIELD(havingQual);
- WRITE_NODE_FIELD(distinctClause);
- WRITE_NODE_FIELD(sortClause);
- WRITE_NODE_FIELD(limitOffset);
- WRITE_NODE_FIELD(limitCount);
- WRITE_NODE_FIELD(setOperations);
- WRITE_INTLIST_FIELD(resultRelations);
-
- /* planner-internal fields are not written out */
}
-static void
-_outSortClause(StringInfo str, SortClause *node)
-{
- WRITE_NODE_TYPE("SORTCLAUSE");
-
- WRITE_UINT_FIELD(tleSortGroupRef);
- WRITE_OID_FIELD(sortop);
-}
-
-static void
-_outGroupClause(StringInfo str, GroupClause *node)
-{
- WRITE_NODE_TYPE("GROUPCLAUSE");
-
- WRITE_UINT_FIELD(tleSortGroupRef);
- WRITE_OID_FIELD(sortop);
-}
-
-static void
-_outSetOperationStmt(StringInfo str, SetOperationStmt *node)
-{
- WRITE_NODE_TYPE("SETOPERATIONSTMT");
-
- WRITE_ENUM_FIELD(op, SetOperation);
- WRITE_BOOL_FIELD(all);
- WRITE_NODE_FIELD(larg);
- WRITE_NODE_FIELD(rarg);
- WRITE_OIDLIST_FIELD(colTypes);
-}
/*
* Stuff from plannodes.h
@@ -631,19 +476,6 @@ _outHash(StringInfo str, Hash *node)
WRITE_NODE_FIELD(hashkeys);
}
-static void
-_outSubPlan(StringInfo str, SubPlan *node)
-{
- WRITE_NODE_TYPE("SUBPLAN");
-
- WRITE_NODE_FIELD(plan);
- WRITE_INT_FIELD(plan_id);
- WRITE_NODE_FIELD(rtable);
- WRITE_INTLIST_FIELD(setParam);
- WRITE_INTLIST_FIELD(parParam);
- WRITE_NODE_FIELD(sublink);
-}
-
/*****************************************************************************
*
* Stuff from primnodes.h.
@@ -666,44 +498,28 @@ _outResdom(StringInfo str, Resdom *node)
}
static void
-_outExpr(StringInfo str, Expr *node)
+_outAlias(StringInfo str, Alias *node)
{
- char *opstr = NULL;
-
- WRITE_NODE_TYPE("EXPR");
+ WRITE_NODE_TYPE("ALIAS");
- WRITE_OID_FIELD(typeOid);
+ WRITE_STRING_FIELD(aliasname);
+ WRITE_NODE_FIELD(colnames);
+}
- /* do-it-yourself enum representation */
- switch (node->opType)
- {
- case OP_EXPR:
- opstr = "op";
- break;
- case DISTINCT_EXPR:
- opstr = "distinct";
- break;
- case FUNC_EXPR:
- opstr = "func";
- break;
- case OR_EXPR:
- opstr = "or";
- break;
- case AND_EXPR:
- opstr = "and";
- break;
- case NOT_EXPR:
- opstr = "not";
- break;
- case SUBPLAN_EXPR:
- opstr = "subp";
- break;
- }
- appendStringInfo(str, " :opType ");
- _outToken(str, opstr);
+static void
+_outRangeVar(StringInfo str, RangeVar *node)
+{
+ WRITE_NODE_TYPE("RANGEVAR");
- WRITE_NODE_FIELD(oper);
- WRITE_NODE_FIELD(args);
+ /*
+ * we deliberately ignore catalogname here, since it is presently not
+ * semantically meaningful
+ */
+ WRITE_STRING_FIELD(schemaname);
+ WRITE_STRING_FIELD(relname);
+ WRITE_ENUM_FIELD(inhOpt, InhOption);
+ WRITE_BOOL_FIELD(istemp);
+ WRITE_NODE_FIELD(alias);
}
static void
@@ -738,6 +554,17 @@ _outConst(StringInfo str, Const *node)
}
static void
+_outParam(StringInfo str, Param *node)
+{
+ WRITE_NODE_TYPE("PARAM");
+
+ WRITE_INT_FIELD(paramkind);
+ WRITE_INT_FIELD(paramid);
+ WRITE_STRING_FIELD(paramname);
+ WRITE_OID_FIELD(paramtype);
+}
+
+static void
_outAggref(StringInfo str, Aggref *node)
{
WRITE_NODE_TYPE("AGGREF");
@@ -747,19 +574,6 @@ _outAggref(StringInfo str, Aggref *node)
WRITE_NODE_FIELD(target);
WRITE_BOOL_FIELD(aggstar);
WRITE_BOOL_FIELD(aggdistinct);
- /* aggno is not saved since it is just executor state */
-}
-
-static void
-_outSubLink(StringInfo str, SubLink *node)
-{
- WRITE_NODE_TYPE("SUBLINK");
-
- WRITE_ENUM_FIELD(subLinkType, SubLinkType);
- WRITE_BOOL_FIELD(useor);
- WRITE_NODE_FIELD(lefthand);
- WRITE_NODE_FIELD(oper);
- WRITE_NODE_FIELD(subselect);
}
static void
@@ -779,36 +593,92 @@ _outArrayRef(StringInfo str, ArrayRef *node)
}
static void
-_outFunc(StringInfo str, Func *node)
+_outFuncExpr(StringInfo str, FuncExpr *node)
{
- WRITE_NODE_TYPE("FUNC");
+ WRITE_NODE_TYPE("FUNCEXPR");
WRITE_OID_FIELD(funcid);
WRITE_OID_FIELD(funcresulttype);
WRITE_BOOL_FIELD(funcretset);
WRITE_ENUM_FIELD(funcformat, CoercionForm);
+ WRITE_NODE_FIELD(args);
}
static void
-_outOper(StringInfo str, Oper *node)
+_outOpExpr(StringInfo str, OpExpr *node)
{
- WRITE_NODE_TYPE("OPER");
+ WRITE_NODE_TYPE("OPEXPR");
WRITE_OID_FIELD(opno);
- WRITE_OID_FIELD(opid);
+ WRITE_OID_FIELD(opfuncid);
WRITE_OID_FIELD(opresulttype);
WRITE_BOOL_FIELD(opretset);
+ WRITE_NODE_FIELD(args);
}
static void
-_outParam(StringInfo str, Param *node)
+_outDistinctExpr(StringInfo str, DistinctExpr *node)
{
- WRITE_NODE_TYPE("PARAM");
+ WRITE_NODE_TYPE("DISTINCTEXPR");
- WRITE_INT_FIELD(paramkind);
- WRITE_INT_FIELD(paramid);
- WRITE_STRING_FIELD(paramname);
- WRITE_OID_FIELD(paramtype);
+ WRITE_OID_FIELD(opno);
+ WRITE_OID_FIELD(opfuncid);
+ WRITE_OID_FIELD(opresulttype);
+ WRITE_BOOL_FIELD(opretset);
+ WRITE_NODE_FIELD(args);
+}
+
+static void
+_outBoolExpr(StringInfo str, BoolExpr *node)
+{
+ char *opstr = NULL;
+
+ WRITE_NODE_TYPE("BOOLEXPR");
+
+ /* do-it-yourself enum representation */
+ switch (node->boolop)
+ {
+ case AND_EXPR:
+ opstr = "and";
+ break;
+ case OR_EXPR:
+ opstr = "or";
+ break;
+ case NOT_EXPR:
+ opstr = "not";
+ break;
+ }
+ appendStringInfo(str, " :boolop ");
+ _outToken(str, opstr);
+
+ WRITE_NODE_FIELD(args);
+}
+
+static void
+_outSubLink(StringInfo str, SubLink *node)
+{
+ WRITE_NODE_TYPE("SUBLINK");
+
+ WRITE_ENUM_FIELD(subLinkType, SubLinkType);
+ WRITE_BOOL_FIELD(useor);
+ WRITE_NODE_FIELD(lefthand);
+ WRITE_NODE_FIELD(oper);
+ WRITE_NODE_FIELD(subselect);
+}
+
+static void
+_outSubPlanExpr(StringInfo str, SubPlanExpr *node)
+{
+ WRITE_NODE_TYPE("SUBPLANEXPR");
+
+ WRITE_OID_FIELD(typeOid);
+ WRITE_NODE_FIELD(plan);
+ WRITE_INT_FIELD(plan_id);
+ WRITE_NODE_FIELD(rtable);
+ WRITE_INTLIST_FIELD(setParam);
+ WRITE_INTLIST_FIELD(parParam);
+ WRITE_NODE_FIELD(args);
+ WRITE_NODE_FIELD(sublink);
}
static void
@@ -834,35 +704,62 @@ _outRelabelType(StringInfo str, RelabelType *node)
}
static void
-_outRangeTblRef(StringInfo str, RangeTblRef *node)
+_outCaseExpr(StringInfo str, CaseExpr *node)
{
- WRITE_NODE_TYPE("RANGETBLREF");
+ WRITE_NODE_TYPE("CASE");
- WRITE_INT_FIELD(rtindex);
+ WRITE_OID_FIELD(casetype);
+ WRITE_NODE_FIELD(arg);
+ WRITE_NODE_FIELD(args);
+ WRITE_NODE_FIELD(defresult);
}
static void
-_outJoinExpr(StringInfo str, JoinExpr *node)
+_outCaseWhen(StringInfo str, CaseWhen *node)
{
- WRITE_NODE_TYPE("JOINEXPR");
+ WRITE_NODE_TYPE("WHEN");
- WRITE_ENUM_FIELD(jointype, JoinType);
- WRITE_BOOL_FIELD(isNatural);
- WRITE_NODE_FIELD(larg);
- WRITE_NODE_FIELD(rarg);
- WRITE_NODE_FIELD(using);
- WRITE_NODE_FIELD(quals);
- WRITE_NODE_FIELD(alias);
- WRITE_INT_FIELD(rtindex);
+ WRITE_NODE_FIELD(expr);
+ WRITE_NODE_FIELD(result);
}
static void
-_outFromExpr(StringInfo str, FromExpr *node)
+_outNullTest(StringInfo str, NullTest *node)
{
- WRITE_NODE_TYPE("FROMEXPR");
+ WRITE_NODE_TYPE("NULLTEST");
- WRITE_NODE_FIELD(fromlist);
- WRITE_NODE_FIELD(quals);
+ WRITE_NODE_FIELD(arg);
+ WRITE_ENUM_FIELD(nulltesttype, NullTestType);
+}
+
+static void
+_outBooleanTest(StringInfo str, BooleanTest *node)
+{
+ WRITE_NODE_TYPE("BOOLEANTEST");
+
+ WRITE_NODE_FIELD(arg);
+ WRITE_ENUM_FIELD(booltesttype, BoolTestType);
+}
+
+static void
+_outConstraintTest(StringInfo str, ConstraintTest *node)
+{
+ WRITE_NODE_TYPE("CONSTRAINTTEST");
+
+ WRITE_NODE_FIELD(arg);
+ WRITE_ENUM_FIELD(testtype, ConstraintTestType);
+ WRITE_STRING_FIELD(name);
+ WRITE_STRING_FIELD(domname);
+ WRITE_NODE_FIELD(check_expr);
+}
+
+static void
+_outConstraintTestValue(StringInfo str, ConstraintTestValue *node)
+{
+ WRITE_NODE_TYPE("CONSTRAINTTESTVALUE");
+
+ WRITE_OID_FIELD(typeId);
+ WRITE_INT_FIELD(typeMod);
}
static void
@@ -871,58 +768,47 @@ _outTargetEntry(StringInfo str, TargetEntry *node)
WRITE_NODE_TYPE("TARGETENTRY");
WRITE_NODE_FIELD(resdom);
- /* fjoin not supported ... */
WRITE_NODE_FIELD(expr);
}
static void
-_outAlias(StringInfo str, Alias *node)
+_outRangeTblRef(StringInfo str, RangeTblRef *node)
{
- WRITE_NODE_TYPE("ALIAS");
+ WRITE_NODE_TYPE("RANGETBLREF");
- WRITE_STRING_FIELD(aliasname);
- WRITE_NODE_FIELD(colnames);
+ WRITE_INT_FIELD(rtindex);
}
static void
-_outRangeTblEntry(StringInfo str, RangeTblEntry *node)
+_outJoinExpr(StringInfo str, JoinExpr *node)
{
- WRITE_NODE_TYPE("RTE");
+ WRITE_NODE_TYPE("JOINEXPR");
- /* put alias + eref first to make dump more legible */
+ WRITE_ENUM_FIELD(jointype, JoinType);
+ WRITE_BOOL_FIELD(isNatural);
+ WRITE_NODE_FIELD(larg);
+ WRITE_NODE_FIELD(rarg);
+ WRITE_NODE_FIELD(using);
+ WRITE_NODE_FIELD(quals);
WRITE_NODE_FIELD(alias);
- WRITE_NODE_FIELD(eref);
- WRITE_ENUM_FIELD(rtekind, RTEKind);
+ WRITE_INT_FIELD(rtindex);
+}
- switch (node->rtekind)
- {
- case RTE_RELATION:
- case RTE_SPECIAL:
- WRITE_OID_FIELD(relid);
- break;
- case RTE_SUBQUERY:
- WRITE_NODE_FIELD(subquery);
- break;
- case RTE_FUNCTION:
- WRITE_NODE_FIELD(funcexpr);
- WRITE_NODE_FIELD(coldeflist);
- break;
- case RTE_JOIN:
- WRITE_ENUM_FIELD(jointype, JoinType);
- WRITE_NODE_FIELD(joinaliasvars);
- break;
- default:
- elog(ERROR, "bogus rte kind %d", (int) node->rtekind);
- break;
- }
+static void
+_outFromExpr(StringInfo str, FromExpr *node)
+{
+ WRITE_NODE_TYPE("FROMEXPR");
- WRITE_BOOL_FIELD(inh);
- WRITE_BOOL_FIELD(inFromCl);
- WRITE_BOOL_FIELD(checkForRead);
- WRITE_BOOL_FIELD(checkForWrite);
- WRITE_OID_FIELD(checkAsUser);
+ WRITE_NODE_FIELD(fromlist);
+ WRITE_NODE_FIELD(quals);
}
+/*****************************************************************************
+ *
+ * Stuff from relation.h.
+ *
+ *****************************************************************************/
+
/*
* print the basic stuff of all nodes that inherit from Path
*
@@ -1078,39 +964,240 @@ _outJoinInfo(StringInfo str, JoinInfo *node)
WRITE_NODE_FIELD(jinfo_restrictinfo);
}
-/*
- * Print the value of a Datum given its type.
- */
+/*****************************************************************************
+ *
+ * Stuff from parsenodes.h.
+ *
+ *****************************************************************************/
+
static void
-_outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
+_outCreateStmt(StringInfo str, CreateStmt *node)
{
- Size length,
- i;
- char *s;
+ WRITE_NODE_TYPE("CREATE");
- length = datumGetSize(value, typbyval, typlen);
+ WRITE_NODE_FIELD(relation);
+ WRITE_NODE_FIELD(tableElts);
+ WRITE_NODE_FIELD(inhRelations);
+ WRITE_NODE_FIELD(constraints);
+ WRITE_BOOL_FIELD(hasoids);
+ WRITE_ENUM_FIELD(oncommit, OnCommitAction);
+}
- if (typbyval)
+static void
+_outIndexStmt(StringInfo str, IndexStmt *node)
+{
+ WRITE_NODE_TYPE("INDEX");
+
+ WRITE_STRING_FIELD(idxname);
+ WRITE_NODE_FIELD(relation);
+ WRITE_STRING_FIELD(accessMethod);
+ WRITE_NODE_FIELD(indexParams);
+ WRITE_NODE_FIELD(whereClause);
+ WRITE_NODE_FIELD(rangetable);
+ WRITE_BOOL_FIELD(unique);
+ WRITE_BOOL_FIELD(primary);
+ WRITE_BOOL_FIELD(isconstraint);
+}
+
+static void
+_outNotifyStmt(StringInfo str, NotifyStmt *node)
+{
+ WRITE_NODE_TYPE("NOTIFY");
+
+ WRITE_NODE_FIELD(relation);
+}
+
+static void
+_outSelectStmt(StringInfo str, SelectStmt *node)
+{
+ WRITE_NODE_TYPE("SELECT");
+
+ /* XXX this is pretty durn incomplete */
+ WRITE_NODE_FIELD(whereClause);
+}
+
+static void
+_outFuncCall(StringInfo str, FuncCall *node)
+{
+ WRITE_NODE_TYPE("FUNCCALL");
+
+ WRITE_NODE_FIELD(funcname);
+ WRITE_NODE_FIELD(args);
+ WRITE_BOOL_FIELD(agg_star);
+ WRITE_BOOL_FIELD(agg_distinct);
+}
+
+static void
+_outColumnDef(StringInfo str, ColumnDef *node)
+{
+ WRITE_NODE_TYPE("COLUMNDEF");
+
+ WRITE_STRING_FIELD(colname);
+ WRITE_NODE_FIELD(typename);
+ WRITE_INT_FIELD(inhcount);
+ WRITE_BOOL_FIELD(is_local);
+ WRITE_BOOL_FIELD(is_not_null);
+ WRITE_NODE_FIELD(raw_default);
+ WRITE_STRING_FIELD(cooked_default);
+ WRITE_NODE_FIELD(constraints);
+ WRITE_NODE_FIELD(support);
+}
+
+static void
+_outTypeName(StringInfo str, TypeName *node)
+{
+ WRITE_NODE_TYPE("TYPENAME");
+
+ WRITE_NODE_FIELD(names);
+ WRITE_OID_FIELD(typeid);
+ WRITE_BOOL_FIELD(timezone);
+ WRITE_BOOL_FIELD(setof);
+ WRITE_BOOL_FIELD(pct_type);
+ WRITE_INT_FIELD(typmod);
+ WRITE_NODE_FIELD(arrayBounds);
+}
+
+static void
+_outTypeCast(StringInfo str, TypeCast *node)
+{
+ WRITE_NODE_TYPE("TYPECAST");
+
+ WRITE_NODE_FIELD(arg);
+ WRITE_NODE_FIELD(typename);
+}
+
+static void
+_outIndexElem(StringInfo str, IndexElem *node)
+{
+ WRITE_NODE_TYPE("INDEXELEM");
+
+ WRITE_STRING_FIELD(name);
+ WRITE_NODE_FIELD(funcname);
+ WRITE_NODE_FIELD(args);
+ WRITE_NODE_FIELD(opclass);
+}
+
+static void
+_outQuery(StringInfo str, Query *node)
+{
+ WRITE_NODE_TYPE("QUERY");
+
+ WRITE_ENUM_FIELD(commandType, CmdType);
+ WRITE_ENUM_FIELD(querySource, QuerySource);
+
+ /*
+ * Hack to work around missing outfuncs routines for a lot of the
+ * utility-statement node types. (The only one we actually *need* for
+ * rules support is NotifyStmt.) Someday we ought to support 'em all,
+ * but for the meantime do this to avoid getting lots of warnings when
+ * running with debug_print_parse on.
+ */
+ if (node->utilityStmt)
{
- s = (char *) (&value);
- appendStringInfo(str, "%u [ ", (unsigned int) length);
- for (i = 0; i < (Size) sizeof(Datum); i++)
- appendStringInfo(str, "%d ", (int) (s[i]));
- appendStringInfo(str, "]");
+ switch (nodeTag(node->utilityStmt))
+ {
+ case T_CreateStmt:
+ case T_IndexStmt:
+ case T_NotifyStmt:
+ WRITE_NODE_FIELD(utilityStmt);
+ break;
+ default:
+ appendStringInfo(str, " :utilityStmt ?");
+ break;
+ }
}
else
+ appendStringInfo(str, " :utilityStmt <>");
+
+ WRITE_INT_FIELD(resultRelation);
+ WRITE_NODE_FIELD(into);
+ WRITE_BOOL_FIELD(isPortal);
+ WRITE_BOOL_FIELD(isBinary);
+ WRITE_BOOL_FIELD(hasAggs);
+ WRITE_BOOL_FIELD(hasSubLinks);
+ WRITE_NODE_FIELD(rtable);
+ WRITE_NODE_FIELD(jointree);
+ WRITE_INTLIST_FIELD(rowMarks);
+ WRITE_NODE_FIELD(targetList);
+ WRITE_NODE_FIELD(groupClause);
+ WRITE_NODE_FIELD(havingQual);
+ WRITE_NODE_FIELD(distinctClause);
+ WRITE_NODE_FIELD(sortClause);
+ WRITE_NODE_FIELD(limitOffset);
+ WRITE_NODE_FIELD(limitCount);
+ WRITE_NODE_FIELD(setOperations);
+ WRITE_INTLIST_FIELD(resultRelations);
+
+ /* planner-internal fields are not written out */
+}
+
+static void
+_outSortClause(StringInfo str, SortClause *node)
+{
+ WRITE_NODE_TYPE("SORTCLAUSE");
+
+ WRITE_UINT_FIELD(tleSortGroupRef);
+ WRITE_OID_FIELD(sortop);
+}
+
+static void
+_outGroupClause(StringInfo str, GroupClause *node)
+{
+ WRITE_NODE_TYPE("GROUPCLAUSE");
+
+ WRITE_UINT_FIELD(tleSortGroupRef);
+ WRITE_OID_FIELD(sortop);
+}
+
+static void
+_outSetOperationStmt(StringInfo str, SetOperationStmt *node)
+{
+ WRITE_NODE_TYPE("SETOPERATIONSTMT");
+
+ WRITE_ENUM_FIELD(op, SetOperation);
+ WRITE_BOOL_FIELD(all);
+ WRITE_NODE_FIELD(larg);
+ WRITE_NODE_FIELD(rarg);
+ WRITE_OIDLIST_FIELD(colTypes);
+}
+
+static void
+_outRangeTblEntry(StringInfo str, RangeTblEntry *node)
+{
+ WRITE_NODE_TYPE("RTE");
+
+ /* put alias + eref first to make dump more legible */
+ WRITE_NODE_FIELD(alias);
+ WRITE_NODE_FIELD(eref);
+ WRITE_ENUM_FIELD(rtekind, RTEKind);
+
+ switch (node->rtekind)
{
- s = (char *) DatumGetPointer(value);
- if (!PointerIsValid(s))
- appendStringInfo(str, "0 [ ]");
- else
- {
- appendStringInfo(str, "%u [ ", (unsigned int) length);
- for (i = 0; i < length; i++)
- appendStringInfo(str, "%d ", (int) (s[i]));
- appendStringInfo(str, "]");
- }
+ case RTE_RELATION:
+ case RTE_SPECIAL:
+ WRITE_OID_FIELD(relid);
+ break;
+ case RTE_SUBQUERY:
+ WRITE_NODE_FIELD(subquery);
+ break;
+ case RTE_FUNCTION:
+ WRITE_NODE_FIELD(funcexpr);
+ WRITE_NODE_FIELD(coldeflist);
+ break;
+ case RTE_JOIN:
+ WRITE_ENUM_FIELD(jointype, JoinType);
+ WRITE_NODE_FIELD(joinaliasvars);
+ break;
+ default:
+ elog(ERROR, "bogus rte kind %d", (int) node->rtekind);
+ break;
}
+
+ WRITE_BOOL_FIELD(inh);
+ WRITE_BOOL_FIELD(inFromCl);
+ WRITE_BOOL_FIELD(checkForRead);
+ WRITE_BOOL_FIELD(checkForWrite);
+ WRITE_OID_FIELD(checkAsUser);
}
static void
@@ -1175,22 +1262,6 @@ _outValue(StringInfo str, Value *value)
}
static void
-_outRangeVar(StringInfo str, RangeVar *node)
-{
- WRITE_NODE_TYPE("RANGEVAR");
-
- /*
- * we deliberately ignore catalogname here, since it is presently not
- * semantically meaningful
- */
- WRITE_STRING_FIELD(schemaname);
- WRITE_STRING_FIELD(relname);
- WRITE_ENUM_FIELD(inhOpt, InhOption);
- WRITE_BOOL_FIELD(istemp);
- WRITE_NODE_FIELD(alias);
-}
-
-static void
_outColumnRef(StringInfo str, ColumnRef *node)
{
WRITE_NODE_TYPE("COLUMNREF");
@@ -1229,6 +1300,12 @@ _outExprFieldSelect(StringInfo str, ExprFieldSelect *node)
}
static void
+_outDomainConstraintValue(StringInfo str, DomainConstraintValue *node)
+{
+ WRITE_NODE_TYPE("DOMAINCONSTRAINTVALUE");
+}
+
+static void
_outConstraint(StringInfo str, Constraint *node)
{
WRITE_NODE_TYPE("CONSTRAINT");
@@ -1287,71 +1364,6 @@ _outFkConstraint(StringInfo str, FkConstraint *node)
WRITE_BOOL_FIELD(skip_validation);
}
-static void
-_outCaseExpr(StringInfo str, CaseExpr *node)
-{
- WRITE_NODE_TYPE("CASE");
-
- WRITE_OID_FIELD(casetype);
- WRITE_NODE_FIELD(arg);
- WRITE_NODE_FIELD(args);
- WRITE_NODE_FIELD(defresult);
-}
-
-static void
-_outCaseWhen(StringInfo str, CaseWhen *node)
-{
- WRITE_NODE_TYPE("WHEN");
-
- WRITE_NODE_FIELD(expr);
- WRITE_NODE_FIELD(result);
-}
-
-static void
-_outNullTest(StringInfo str, NullTest *node)
-{
- WRITE_NODE_TYPE("NULLTEST");
-
- WRITE_NODE_FIELD(arg);
- WRITE_ENUM_FIELD(nulltesttype, NullTestType);
-}
-
-static void
-_outBooleanTest(StringInfo str, BooleanTest *node)
-{
- WRITE_NODE_TYPE("BOOLEANTEST");
-
- WRITE_NODE_FIELD(arg);
- WRITE_ENUM_FIELD(booltesttype, BoolTestType);
-}
-
-static void
-_outConstraintTest(StringInfo str, ConstraintTest *node)
-{
- WRITE_NODE_TYPE("CONSTRAINTTEST");
-
- WRITE_NODE_FIELD(arg);
- WRITE_ENUM_FIELD(testtype, ConstraintTestType);
- WRITE_STRING_FIELD(name);
- WRITE_STRING_FIELD(domname);
- WRITE_NODE_FIELD(check_expr);
-}
-
-static void
-_outDomainConstraintValue(StringInfo str, DomainConstraintValue *node)
-{
- WRITE_NODE_TYPE("DOMAINCONSTRAINTVALUE");
-}
-
-static void
-_outConstraintTestValue(StringInfo str, ConstraintTestValue *node)
-{
- WRITE_NODE_TYPE("CONSTRAINTTESTVALUE");
-
- WRITE_OID_FIELD(typeId);
- WRITE_INT_FIELD(typeMod);
-}
-
/*
* _outNode -
@@ -1392,42 +1404,6 @@ _outNode(StringInfo str, void *obj)
appendStringInfoChar(str, '{');
switch (nodeTag(obj))
{
- case T_CreateStmt:
- _outCreateStmt(str, obj);
- break;
- case T_IndexStmt:
- _outIndexStmt(str, obj);
- break;
- case T_NotifyStmt:
- _outNotifyStmt(str, obj);
- break;
- case T_SelectStmt:
- _outSelectStmt(str, obj);
- break;
- case T_ColumnDef:
- _outColumnDef(str, obj);
- break;
- case T_TypeName:
- _outTypeName(str, obj);
- break;
- case T_TypeCast:
- _outTypeCast(str, obj);
- break;
- case T_IndexElem:
- _outIndexElem(str, obj);
- break;
- case T_Query:
- _outQuery(str, obj);
- break;
- case T_SortClause:
- _outSortClause(str, obj);
- break;
- case T_GroupClause:
- _outGroupClause(str, obj);
- break;
- case T_SetOperationStmt:
- _outSetOperationStmt(str, obj);
- break;
case T_Plan:
_outPlan(str, obj);
break;
@@ -1437,18 +1413,6 @@ _outNode(StringInfo str, void *obj)
case T_Append:
_outAppend(str, obj);
break;
- case T_Join:
- _outJoin(str, obj);
- break;
- case T_NestLoop:
- _outNestLoop(str, obj);
- break;
- case T_MergeJoin:
- _outMergeJoin(str, obj);
- break;
- case T_HashJoin:
- _outHashJoin(str, obj);
- break;
case T_Scan:
_outScan(str, obj);
break;
@@ -1467,11 +1431,17 @@ _outNode(StringInfo str, void *obj)
case T_FunctionScan:
_outFunctionScan(str, obj);
break;
- case T_Material:
- _outMaterial(str, obj);
+ case T_Join:
+ _outJoin(str, obj);
break;
- case T_Sort:
- _outSort(str, obj);
+ case T_NestLoop:
+ _outNestLoop(str, obj);
+ break;
+ case T_MergeJoin:
+ _outMergeJoin(str, obj);
+ break;
+ case T_HashJoin:
+ _outHashJoin(str, obj);
break;
case T_Agg:
_outAgg(str, obj);
@@ -1479,6 +1449,12 @@ _outNode(StringInfo str, void *obj)
case T_Group:
_outGroup(str, obj);
break;
+ case T_Material:
+ _outMaterial(str, obj);
+ break;
+ case T_Sort:
+ _outSort(str, obj);
+ break;
case T_Unique:
_outUnique(str, obj);
break;
@@ -1491,14 +1467,14 @@ _outNode(StringInfo str, void *obj)
case T_Hash:
_outHash(str, obj);
break;
- case T_SubPlan:
- _outSubPlan(str, obj);
- break;
case T_Resdom:
_outResdom(str, obj);
break;
- case T_Expr:
- _outExpr(str, obj);
+ case T_Alias:
+ _outAlias(str, obj);
+ break;
+ case T_RangeVar:
+ _outRangeVar(str, obj);
break;
case T_Var:
_outVar(str, obj);
@@ -1506,23 +1482,32 @@ _outNode(StringInfo str, void *obj)
case T_Const:
_outConst(str, obj);
break;
+ case T_Param:
+ _outParam(str, obj);
+ break;
case T_Aggref:
_outAggref(str, obj);
break;
- case T_SubLink:
- _outSubLink(str, obj);
- break;
case T_ArrayRef:
_outArrayRef(str, obj);
break;
- case T_Func:
- _outFunc(str, obj);
+ case T_FuncExpr:
+ _outFuncExpr(str, obj);
break;
- case T_Oper:
- _outOper(str, obj);
+ case T_OpExpr:
+ _outOpExpr(str, obj);
break;
- case T_Param:
- _outParam(str, obj);
+ case T_DistinctExpr:
+ _outDistinctExpr(str, obj);
+ break;
+ case T_BoolExpr:
+ _outBoolExpr(str, obj);
+ break;
+ case T_SubLink:
+ _outSubLink(str, obj);
+ break;
+ case T_SubPlanExpr:
+ _outSubPlanExpr(str, obj);
break;
case T_FieldSelect:
_outFieldSelect(str, obj);
@@ -1530,24 +1515,37 @@ _outNode(StringInfo str, void *obj)
case T_RelabelType:
_outRelabelType(str, obj);
break;
- case T_RangeTblRef:
- _outRangeTblRef(str, obj);
+ case T_CaseExpr:
+ _outCaseExpr(str, obj);
break;
- case T_FromExpr:
- _outFromExpr(str, obj);
+ case T_CaseWhen:
+ _outCaseWhen(str, obj);
break;
- case T_JoinExpr:
- _outJoinExpr(str, obj);
+ case T_NullTest:
+ _outNullTest(str, obj);
+ break;
+ case T_BooleanTest:
+ _outBooleanTest(str, obj);
+ break;
+ case T_ConstraintTest:
+ _outConstraintTest(str, obj);
+ break;
+ case T_ConstraintTestValue:
+ _outConstraintTestValue(str, obj);
break;
case T_TargetEntry:
_outTargetEntry(str, obj);
break;
- case T_Alias:
- _outAlias(str, obj);
+ case T_RangeTblRef:
+ _outRangeTblRef(str, obj);
break;
- case T_RangeTblEntry:
- _outRangeTblEntry(str, obj);
+ case T_JoinExpr:
+ _outJoinExpr(str, obj);
+ break;
+ case T_FromExpr:
+ _outFromExpr(str, obj);
break;
+
case T_Path:
_outPath(str, obj);
break;
@@ -1584,12 +1582,49 @@ _outNode(StringInfo str, void *obj)
case T_JoinInfo:
_outJoinInfo(str, obj);
break;
+
+ case T_CreateStmt:
+ _outCreateStmt(str, obj);
+ break;
+ case T_IndexStmt:
+ _outIndexStmt(str, obj);
+ break;
+ case T_NotifyStmt:
+ _outNotifyStmt(str, obj);
+ break;
+ case T_SelectStmt:
+ _outSelectStmt(str, obj);
+ break;
+ case T_ColumnDef:
+ _outColumnDef(str, obj);
+ break;
+ case T_TypeName:
+ _outTypeName(str, obj);
+ break;
+ case T_TypeCast:
+ _outTypeCast(str, obj);
+ break;
+ case T_IndexElem:
+ _outIndexElem(str, obj);
+ break;
+ case T_Query:
+ _outQuery(str, obj);
+ break;
+ case T_SortClause:
+ _outSortClause(str, obj);
+ break;
+ case T_GroupClause:
+ _outGroupClause(str, obj);
+ break;
+ case T_SetOperationStmt:
+ _outSetOperationStmt(str, obj);
+ break;
+ case T_RangeTblEntry:
+ _outRangeTblEntry(str, obj);
+ break;
case T_A_Expr:
_outAExpr(str, obj);
break;
- case T_RangeVar:
- _outRangeVar(str, obj);
- break;
case T_ColumnRef:
_outColumnRef(str, obj);
break;
@@ -1602,36 +1637,18 @@ _outNode(StringInfo str, void *obj)
case T_ExprFieldSelect:
_outExprFieldSelect(str, obj);
break;
+ case T_DomainConstraintValue:
+ _outDomainConstraintValue(str, obj);
+ break;
case T_Constraint:
_outConstraint(str, obj);
break;
case T_FkConstraint:
_outFkConstraint(str, obj);
break;
- case T_CaseExpr:
- _outCaseExpr(str, obj);
- break;
- case T_CaseWhen:
- _outCaseWhen(str, obj);
- break;
- case T_NullTest:
- _outNullTest(str, obj);
- break;
- case T_BooleanTest:
- _outBooleanTest(str, obj);
- break;
- case T_ConstraintTest:
- _outConstraintTest(str, obj);
- break;
- case T_ConstraintTestValue:
- _outConstraintTestValue(str, obj);
- break;
case T_FuncCall:
_outFuncCall(str, obj);
break;
- case T_DomainConstraintValue:
- _outDomainConstraintValue(str, obj);
- break;
default:
elog(WARNING, "_outNode: don't know how to print type %d",
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c
index e8afda6b208..dd5186860bf 100644
--- a/src/backend/nodes/print.c
+++ b/src/backend/nodes/print.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.57 2002/09/04 20:31:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.58 2002/12/12 15:49:28 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -371,7 +371,7 @@ print_expr(Node *expr, List *rtable)
char *opname;
print_expr((Node *) get_leftop(e), rtable);
- opname = get_opname(((Oper *) e->oper)->opno);
+ opname = get_opname(((OpExpr *) e)->opno);
printf(" %s ", ((opname != NULL) ? opname : "(invalid operator)"));
print_expr((Node *) get_rightop(e), rtable);
}
@@ -432,7 +432,7 @@ print_tl(List *tlist, List *rtable)
printf("(%d):\t", tle->resdom->reskey);
else
printf(" :\t");
- print_expr(tle->expr, rtable);
+ print_expr((Node *) tle->expr, rtable);
printf("\n");
}
printf(")\n");
diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c
index eca2e3017b0..bb4a565a8b5 100644
--- a/src/backend/nodes/readfuncs.c
+++ b/src/backend/nodes/readfuncs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.140 2002/11/25 21:29:38 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.141 2002/12/12 15:49:28 tgl Exp $
*
* NOTES
* Path and Plan nodes do not have any readfuncs support, because we
@@ -302,38 +302,30 @@ _readResdom(void)
READ_DONE();
}
-/*
- * _readExpr
- */
-static Expr *
-_readExpr(void)
+static Alias *
+_readAlias(void)
{
- READ_LOCALS(Expr);
+ READ_LOCALS(Alias);
- READ_OID_FIELD(typeOid);
+ READ_STRING_FIELD(aliasname);
+ READ_NODE_FIELD(colnames);
- /* do-it-yourself enum representation */
- token = pg_strtok(&length); /* skip :opType */
- token = pg_strtok(&length); /* get field value */
- if (strncmp(token, "op", 2) == 0)
- local_node->opType = OP_EXPR;
- else if (strncmp(token, "distinct", 8) == 0)
- local_node->opType = DISTINCT_EXPR;
- else if (strncmp(token, "func", 4) == 0)
- local_node->opType = FUNC_EXPR;
- else if (strncmp(token, "or", 2) == 0)
- local_node->opType = OR_EXPR;
- else if (strncmp(token, "and", 3) == 0)
- local_node->opType = AND_EXPR;
- else if (strncmp(token, "not", 3) == 0)
- local_node->opType = NOT_EXPR;
- else if (strncmp(token, "subp", 4) == 0)
- local_node->opType = SUBPLAN_EXPR;
- else
- elog(ERROR, "_readExpr: unknown opType \"%.*s\"", length, token);
+ READ_DONE();
+}
- READ_NODE_FIELD(oper);
- READ_NODE_FIELD(args);
+static RangeVar *
+_readRangeVar(void)
+{
+ READ_LOCALS(RangeVar);
+
+ local_node->catalogname = NULL; /* not currently saved in output
+ * format */
+
+ READ_STRING_FIELD(schemaname);
+ READ_STRING_FIELD(relname);
+ READ_ENUM_FIELD(inhOpt, InhOption);
+ READ_BOOL_FIELD(istemp);
+ READ_NODE_FIELD(alias);
READ_DONE();
}
@@ -358,27 +350,6 @@ _readVar(void)
}
/*
- * _readArrayRef
- */
-static ArrayRef *
-_readArrayRef(void)
-{
- READ_LOCALS(ArrayRef);
-
- READ_OID_FIELD(refrestype);
- READ_INT_FIELD(refattrlength);
- READ_INT_FIELD(refelemlength);
- READ_BOOL_FIELD(refelembyval);
- READ_CHAR_FIELD(refelemalign);
- READ_NODE_FIELD(refupperindexpr);
- READ_NODE_FIELD(reflowerindexpr);
- READ_NODE_FIELD(refexpr);
- READ_NODE_FIELD(refassgnexpr);
-
- READ_DONE();
-}
-
-/*
* _readConst
*/
static Const *
@@ -401,17 +372,72 @@ _readConst(void)
}
/*
- * _readFunc
+ * _readParam
+ */
+static Param *
+_readParam(void)
+{
+ READ_LOCALS(Param);
+
+ READ_INT_FIELD(paramkind);
+ READ_INT_FIELD(paramid);
+ READ_STRING_FIELD(paramname);
+ READ_OID_FIELD(paramtype);
+
+ READ_DONE();
+}
+
+/*
+ * _readAggref
+ */
+static Aggref *
+_readAggref(void)
+{
+ READ_LOCALS(Aggref);
+
+ READ_OID_FIELD(aggfnoid);
+ READ_OID_FIELD(aggtype);
+ READ_NODE_FIELD(target);
+ READ_BOOL_FIELD(aggstar);
+ READ_BOOL_FIELD(aggdistinct);
+
+ READ_DONE();
+}
+
+/*
+ * _readArrayRef
*/
-static Func *
-_readFunc(void)
+static ArrayRef *
+_readArrayRef(void)
{
- READ_LOCALS(Func);
+ READ_LOCALS(ArrayRef);
+
+ READ_OID_FIELD(refrestype);
+ READ_INT_FIELD(refattrlength);
+ READ_INT_FIELD(refelemlength);
+ READ_BOOL_FIELD(refelembyval);
+ READ_CHAR_FIELD(refelemalign);
+ READ_NODE_FIELD(refupperindexpr);
+ READ_NODE_FIELD(reflowerindexpr);
+ READ_NODE_FIELD(refexpr);
+ READ_NODE_FIELD(refassgnexpr);
+
+ READ_DONE();
+}
+
+/*
+ * _readFuncExpr
+ */
+static FuncExpr *
+_readFuncExpr(void)
+{
+ READ_LOCALS(FuncExpr);
READ_OID_FIELD(funcid);
READ_OID_FIELD(funcresulttype);
READ_BOOL_FIELD(funcretset);
READ_ENUM_FIELD(funcformat, CoercionForm);
+ READ_NODE_FIELD(args);
local_node->func_fcache = NULL;
@@ -419,17 +445,28 @@ _readFunc(void)
}
/*
- * _readOper
+ * _readOpExpr
*/
-static Oper *
-_readOper(void)
+static OpExpr *
+_readOpExpr(void)
{
- READ_LOCALS(Oper);
+ READ_LOCALS(OpExpr);
READ_OID_FIELD(opno);
- READ_OID_FIELD(opid);
+ READ_OID_FIELD(opfuncid);
+ /*
+ * The opfuncid is stored in the textual format primarily for debugging
+ * and documentation reasons. We want to always read it as zero to force
+ * it to be re-looked-up in the pg_operator entry. This ensures that
+ * stored rules don't have hidden dependencies on operators' functions.
+ * (We don't currently support an ALTER OPERATOR command, but might
+ * someday.)
+ */
+ local_node->opfuncid = InvalidOid;
+
READ_OID_FIELD(opresulttype);
READ_BOOL_FIELD(opretset);
+ READ_NODE_FIELD(args);
local_node->op_fcache = NULL;
@@ -437,52 +474,55 @@ _readOper(void)
}
/*
- * _readParam
+ * _readDistinctExpr
*/
-static Param *
-_readParam(void)
+static DistinctExpr *
+_readDistinctExpr(void)
{
- READ_LOCALS(Param);
-
- READ_INT_FIELD(paramkind);
- READ_INT_FIELD(paramid);
- READ_STRING_FIELD(paramname);
- READ_OID_FIELD(paramtype);
+ READ_LOCALS(DistinctExpr);
- READ_DONE();
-}
+ READ_OID_FIELD(opno);
+ READ_OID_FIELD(opfuncid);
+ /*
+ * The opfuncid is stored in the textual format primarily for debugging
+ * and documentation reasons. We want to always read it as zero to force
+ * it to be re-looked-up in the pg_operator entry. This ensures that
+ * stored rules don't have hidden dependencies on operators' functions.
+ * (We don't currently support an ALTER OPERATOR command, but might
+ * someday.)
+ */
+ local_node->opfuncid = InvalidOid;
-/*
- * _readAggref
- */
-static Aggref *
-_readAggref(void)
-{
- READ_LOCALS(Aggref);
+ READ_OID_FIELD(opresulttype);
+ READ_BOOL_FIELD(opretset);
+ READ_NODE_FIELD(args);
- READ_OID_FIELD(aggfnoid);
- READ_OID_FIELD(aggtype);
- READ_NODE_FIELD(target);
- READ_BOOL_FIELD(aggstar);
- READ_BOOL_FIELD(aggdistinct);
- /* aggno is not saved since it is just executor state */
+ local_node->op_fcache = NULL;
READ_DONE();
}
-static RangeVar *
-_readRangeVar(void)
+/*
+ * _readBoolExpr
+ */
+static BoolExpr *
+_readBoolExpr(void)
{
- READ_LOCALS(RangeVar);
+ READ_LOCALS(BoolExpr);
- local_node->catalogname = NULL; /* not currently saved in output
- * format */
+ /* do-it-yourself enum representation */
+ token = pg_strtok(&length); /* skip :boolop */
+ token = pg_strtok(&length); /* get field value */
+ if (strncmp(token, "and", 3) == 0)
+ local_node->boolop = AND_EXPR;
+ else if (strncmp(token, "or", 2) == 0)
+ local_node->boolop = OR_EXPR;
+ else if (strncmp(token, "not", 3) == 0)
+ local_node->boolop = NOT_EXPR;
+ else
+ elog(ERROR, "_readBoolExpr: unknown boolop \"%.*s\"", length, token);
- READ_STRING_FIELD(schemaname);
- READ_STRING_FIELD(relname);
- READ_ENUM_FIELD(inhOpt, InhOption);
- READ_BOOL_FIELD(istemp);
- READ_NODE_FIELD(alias);
+ READ_NODE_FIELD(args);
READ_DONE();
}
@@ -505,6 +545,10 @@ _readSubLink(void)
}
/*
+ * _readSubPlanExpr is not needed since it doesn't appear in stored rules.
+ */
+
+/*
* _readFieldSelect
*/
static FieldSelect *
@@ -537,58 +581,6 @@ _readRelabelType(void)
}
/*
- * _readRangeTblRef
- */
-static RangeTblRef *
-_readRangeTblRef(void)
-{
- READ_LOCALS(RangeTblRef);
-
- READ_INT_FIELD(rtindex);
-
- READ_DONE();
-}
-
-/*
- * _readJoinExpr
- */
-static JoinExpr *
-_readJoinExpr(void)
-{
- READ_LOCALS(JoinExpr);
-
- READ_ENUM_FIELD(jointype, JoinType);
- READ_BOOL_FIELD(isNatural);
- READ_NODE_FIELD(larg);
- READ_NODE_FIELD(rarg);
- READ_NODE_FIELD(using);
- READ_NODE_FIELD(quals);
- READ_NODE_FIELD(alias);
- READ_INT_FIELD(rtindex);
-
- READ_DONE();
-}
-
-/*
- * _readFromExpr
- */
-static FromExpr *
-_readFromExpr(void)
-{
- READ_LOCALS(FromExpr);
-
- READ_NODE_FIELD(fromlist);
- READ_NODE_FIELD(quals);
-
- READ_DONE();
-}
-
-
-/*
- * Stuff from parsenodes.h.
- */
-
-/*
* _readCaseExpr
*/
static CaseExpr *
@@ -664,17 +656,6 @@ _readConstraintTest(void)
}
/*
- * _readDomainConstraintValue
- */
-static DomainConstraintValue *
-_readDomainConstraintValue(void)
-{
- READ_LOCALS_NO_FIELDS(DomainConstraintValue);
-
- READ_DONE();
-}
-
-/*
* _readConstraintTestValue
*/
static ConstraintTestValue *
@@ -697,12 +678,63 @@ _readTargetEntry(void)
READ_LOCALS(TargetEntry);
READ_NODE_FIELD(resdom);
- /* fjoin not supported ... */
READ_NODE_FIELD(expr);
READ_DONE();
}
+/*
+ * _readRangeTblRef
+ */
+static RangeTblRef *
+_readRangeTblRef(void)
+{
+ READ_LOCALS(RangeTblRef);
+
+ READ_INT_FIELD(rtindex);
+
+ READ_DONE();
+}
+
+/*
+ * _readJoinExpr
+ */
+static JoinExpr *
+_readJoinExpr(void)
+{
+ READ_LOCALS(JoinExpr);
+
+ READ_ENUM_FIELD(jointype, JoinType);
+ READ_BOOL_FIELD(isNatural);
+ READ_NODE_FIELD(larg);
+ READ_NODE_FIELD(rarg);
+ READ_NODE_FIELD(using);
+ READ_NODE_FIELD(quals);
+ READ_NODE_FIELD(alias);
+ READ_INT_FIELD(rtindex);
+
+ READ_DONE();
+}
+
+/*
+ * _readFromExpr
+ */
+static FromExpr *
+_readFromExpr(void)
+{
+ READ_LOCALS(FromExpr);
+
+ READ_NODE_FIELD(fromlist);
+ READ_NODE_FIELD(quals);
+
+ READ_DONE();
+}
+
+
+/*
+ * Stuff from parsenodes.h.
+ */
+
static ColumnRef *
_readColumnRef(void)
{
@@ -760,13 +792,13 @@ _readExprFieldSelect(void)
READ_DONE();
}
-static Alias *
-_readAlias(void)
+/*
+ * _readDomainConstraintValue
+ */
+static DomainConstraintValue *
+_readDomainConstraintValue(void)
{
- READ_LOCALS(Alias);
-
- READ_STRING_FIELD(aliasname);
- READ_NODE_FIELD(colnames);
+ READ_LOCALS_NO_FIELDS(DomainConstraintValue);
READ_DONE();
}
@@ -835,53 +867,7 @@ parseNodeString(void)
#define MATCH(tokname, namelen) \
(length == namelen && strncmp(token, tokname, namelen) == 0)
- if (MATCH("AGGREF", 6))
- return_value = _readAggref();
- else if (MATCH("SUBLINK", 7))
- return_value = _readSubLink();
- else if (MATCH("FIELDSELECT", 11))
- return_value = _readFieldSelect();
- else if (MATCH("RELABELTYPE", 11))
- return_value = _readRelabelType();
- else if (MATCH("RANGETBLREF", 11))
- return_value = _readRangeTblRef();
- else if (MATCH("FROMEXPR", 8))
- return_value = _readFromExpr();
- else if (MATCH("JOINEXPR", 8))
- return_value = _readJoinExpr();
- else if (MATCH("RESDOM", 6))
- return_value = _readResdom();
- else if (MATCH("EXPR", 4))
- return_value = _readExpr();
- else if (MATCH("ARRAYREF", 8))
- return_value = _readArrayRef();
- else if (MATCH("VAR", 3))
- return_value = _readVar();
- else if (MATCH("CONST", 5))
- return_value = _readConst();
- else if (MATCH("FUNC", 4))
- return_value = _readFunc();
- else if (MATCH("OPER", 4))
- return_value = _readOper();
- else if (MATCH("PARAM", 5))
- return_value = _readParam();
- else if (MATCH("TARGETENTRY", 11))
- return_value = _readTargetEntry();
- else if (MATCH("RANGEVAR", 8))
- return_value = _readRangeVar();
- else if (MATCH("COLUMNREF", 9))
- return_value = _readColumnRef();
- else if (MATCH("COLUMNDEF", 9))
- return_value = _readColumnDef();
- else if (MATCH("TYPENAME", 8))
- return_value = _readTypeName();
- else if (MATCH("EXPRFIELDSELECT", 15))
- return_value = _readExprFieldSelect();
- else if (MATCH("ALIAS", 5))
- return_value = _readAlias();
- else if (MATCH("RTE", 3))
- return_value = _readRangeTblEntry();
- else if (MATCH("QUERY", 5))
+ if (MATCH("QUERY", 5))
return_value = _readQuery();
else if (MATCH("NOTIFY", 6))
return_value = _readNotifyStmt();
@@ -891,6 +877,36 @@ parseNodeString(void)
return_value = _readGroupClause();
else if (MATCH("SETOPERATIONSTMT", 16))
return_value = _readSetOperationStmt();
+ else if (MATCH("RESDOM", 6))
+ return_value = _readResdom();
+ else if (MATCH("ALIAS", 5))
+ return_value = _readAlias();
+ else if (MATCH("RANGEVAR", 8))
+ return_value = _readRangeVar();
+ else if (MATCH("VAR", 3))
+ return_value = _readVar();
+ else if (MATCH("CONST", 5))
+ return_value = _readConst();
+ else if (MATCH("PARAM", 5))
+ return_value = _readParam();
+ else if (MATCH("AGGREF", 6))
+ return_value = _readAggref();
+ else if (MATCH("ARRAYREF", 8))
+ return_value = _readArrayRef();
+ else if (MATCH("FUNCEXPR", 8))
+ return_value = _readFuncExpr();
+ else if (MATCH("OPEXPR", 6))
+ return_value = _readOpExpr();
+ else if (MATCH("DISTINCTEXPR", 12))
+ return_value = _readDistinctExpr();
+ else if (MATCH("BOOLEXPR", 8))
+ return_value = _readBoolExpr();
+ else if (MATCH("SUBLINK", 7))
+ return_value = _readSubLink();
+ else if (MATCH("FIELDSELECT", 11))
+ return_value = _readFieldSelect();
+ else if (MATCH("RELABELTYPE", 11))
+ return_value = _readRelabelType();
else if (MATCH("CASE", 4))
return_value = _readCaseExpr();
else if (MATCH("WHEN", 4))
@@ -901,10 +917,28 @@ parseNodeString(void)
return_value = _readBooleanTest();
else if (MATCH("CONSTRAINTTEST", 14))
return_value = _readConstraintTest();
- else if (MATCH("DOMAINCONSTRAINTVALUE", 21))
- return_value = _readDomainConstraintValue();
else if (MATCH("CONSTRAINTTESTVALUE", 19))
return_value = _readConstraintTestValue();
+ else if (MATCH("TARGETENTRY", 11))
+ return_value = _readTargetEntry();
+ else if (MATCH("RANGETBLREF", 11))
+ return_value = _readRangeTblRef();
+ else if (MATCH("JOINEXPR", 8))
+ return_value = _readJoinExpr();
+ else if (MATCH("FROMEXPR", 8))
+ return_value = _readFromExpr();
+ else if (MATCH("COLUMNREF", 9))
+ return_value = _readColumnRef();
+ else if (MATCH("COLUMNDEF", 9))
+ return_value = _readColumnDef();
+ else if (MATCH("TYPENAME", 8))
+ return_value = _readTypeName();
+ else if (MATCH("EXPRFIELDSELECT", 15))
+ return_value = _readExprFieldSelect();
+ else if (MATCH("DOMAINCONSTRAINTVALUE", 21))
+ return_value = _readDomainConstraintValue();
+ else if (MATCH("RTE", 3))
+ return_value = _readRangeTblEntry();
else
{
elog(ERROR, "badly formatted node string \"%.32s\"...", token);