I observed these inconsistencies in node support functions:
- _copyReassignOwnedStmt() uses COPY_SCALAR_FIELD() on the string field
"newrole", and _equalReassignOwnedStmt() uses COMPARE_NODE_FIELD().
- _outCreateForeignTableStmt() calls _outCreateStmt() directly. This produces
the label "CREATEFOREIGNTABLESTMTCREATESTMT". The attached patch splits
things out the way we normally do in outfuncs.c. There's no readfuncs.c
support, so this is strictly cosmetic.
- _outColumnDef() uses WRITE_INT_FIELD for the "storage" field, a char.
Again, no readfuncs.c support to create a compatibility problem.
- _copyRenameStmt() and _equalRenameStmt() ignore the "relationType" field,
but I can't see a good reason to do so. PostgreSQL 9.1 added this field,
but only recent master (after commit 38b9693f of 3 April 2012) references
the field beyond setting it in the parser.
- _copyViewStmt() and _equalViewStmt() ignore the "options" field, and
_equalColumnDef() ignores "fdwoptions". These are new in PostgreSQL 9.2,
and I see no good reason to ignore them.
I'd suggest backpatching the ReassignOwnedStmt() bits; the wrong code could
produce crashes. The rest are for master only.
Thanks,
nm
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index c94799b..eed0ea4 100644
*** a/src/backend/nodes/copyfuncs.c
--- b/src/backend/nodes/copyfuncs.c
***************
*** 2891,2896 **** _copyRenameStmt(const RenameStmt *from)
--- 2891,2897 ----
RenameStmt *newnode = makeNode(RenameStmt);
COPY_SCALAR_FIELD(renameType);
+ COPY_SCALAR_FIELD(relationType);
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objarg);
***************
*** 3047,3052 **** _copyViewStmt(const ViewStmt *from)
--- 3048,3054 ----
COPY_NODE_FIELD(aliases);
COPY_NODE_FIELD(query);
COPY_SCALAR_FIELD(replace);
+ COPY_NODE_FIELD(options);
return newnode;
}
***************
*** 3650,3656 **** _copyReassignOwnedStmt(const ReassignOwnedStmt *from)
ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
COPY_NODE_FIELD(roles);
! COPY_SCALAR_FIELD(newrole);
return newnode;
}
--- 3652,3658 ----
ReassignOwnedStmt *newnode = makeNode(ReassignOwnedStmt);
COPY_NODE_FIELD(roles);
! COPY_STRING_FIELD(newrole);
return newnode;
}
diff --git a/src/backend/nodes/equalindex 9564210..c06b068 100644
*** a/src/backend/nodes/equalfuncs.c
--- b/src/backend/nodes/equalfuncs.c
***************
*** 1306,1311 **** static bool
--- 1306,1312 ----
_equalRenameStmt(const RenameStmt *a, const RenameStmt *b)
{
COMPARE_SCALAR_FIELD(renameType);
+ COMPARE_SCALAR_FIELD(relationType);
COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objarg);
***************
*** 1438,1443 **** _equalViewStmt(const ViewStmt *a, const ViewStmt *b)
--- 1439,1445 ----
COMPARE_NODE_FIELD(aliases);
COMPARE_NODE_FIELD(query);
COMPARE_SCALAR_FIELD(replace);
+ COMPARE_NODE_FIELD(options);
return true;
}
***************
*** 1945,1951 **** static bool
_equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt
*b)
{
COMPARE_NODE_FIELD(roles);
! COMPARE_NODE_FIELD(newrole);
return true;
}
--- 1947,1953 ----
_equalReassignOwnedStmt(const ReassignOwnedStmt *a, const ReassignOwnedStmt
*b)
{
COMPARE_NODE_FIELD(roles);
! COMPARE_STRING_FIELD(newrole);
return true;
}
***************
*** 2182,2187 **** _equalColumnDef(const ColumnDef *a, const ColumnDef *b)
--- 2184,2190 ----
COMPARE_NODE_FIELD(collClause);
COMPARE_SCALAR_FIELD(collOid);
COMPARE_NODE_FIELD(constraints);
+ COMPARE_NODE_FIELD(fdwoptions);
return true;
}
diff --git a/src/backend/nodes/outfunindex 594b3fd..f713773 100644
*** a/src/backend/nodes/outfuncs.c
--- b/src/backend/nodes/outfuncs.c
***************
*** 1927,1937 **** _outPlannerParamItem(StringInfo str, const PlannerParamItem
*node)
*
*****************************************************************************/
static void
! _outCreateStmt(StringInfo str, const CreateStmt *node)
{
- WRITE_NODE_TYPE("CREATESTMT");
-
WRITE_NODE_FIELD(relation);
WRITE_NODE_FIELD(tableElts);
WRITE_NODE_FIELD(inhRelations);
--- 1927,1938 ----
*
*****************************************************************************/
+ /*
+ * print the basic stuff of all nodes that inherit from CreateStmt
+ */
static void
! _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
{
WRITE_NODE_FIELD(relation);
WRITE_NODE_FIELD(tableElts);
WRITE_NODE_FIELD(inhRelations);
***************
*** 1944,1954 **** _outCreateStmt(StringInfo str, const CreateStmt *node)
}
static void
_outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
{
WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
! _outCreateStmt(str, (const CreateStmt *) &node->base);
WRITE_STRING_FIELD(servername);
WRITE_NODE_FIELD(options);
--- 1945,1963 ----
}
static void
+ _outCreateStmt(StringInfo str, const CreateStmt *node)
+ {
+ WRITE_NODE_TYPE("CREATESTMT");
+
+ _outCreateStmtInfo(str, (const CreateStmt *) node);
+ }
+
+ static void
_outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
{
WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
! _outCreateStmtInfo(str, (const CreateStmt *) node);
WRITE_STRING_FIELD(servername);
WRITE_NODE_FIELD(options);
***************
*** 2088,2094 **** _outColumnDef(StringInfo str, const ColumnDef *node)
WRITE_BOOL_FIELD(is_local);
WRITE_BOOL_FIELD(is_not_null);
WRITE_BOOL_FIELD(is_from_type);
! WRITE_INT_FIELD(storage);
WRITE_NODE_FIELD(raw_default);
WRITE_NODE_FIELD(cooked_default);
WRITE_NODE_FIELD(collClause);
--- 2097,2103 ----
WRITE_BOOL_FIELD(is_local);
WRITE_BOOL_FIELD(is_not_null);
WRITE_BOOL_FIELD(is_from_type);
! WRITE_CHAR_FIELD(storage);
WRITE_NODE_FIELD(raw_default);
WRITE_NODE_FIELD(cooked_default);
WRITE_NODE_FIELD(collClause);
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers