]> granicus.if.org Git - postgresql/blobdiff - src/backend/nodes/outfuncs.c
Fix PARAM_EXEC assignment mechanism to be safe in the presence of WITH.
[postgresql] / src / backend / nodes / outfuncs.c
index 79665ed12a04c44cc9f61a7eaf865483c1374232..02a0f62a53a4e3d06a3ad48d523e959d5d6b2ab7 100644 (file)
@@ -3,12 +3,12 @@
  * outfuncs.c
  *       Output functions for Postgres tree nodes.
  *
- * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.366 2009/10/08 02:39:21 tgl Exp $
+ *       src/backend/nodes/outfuncs.c
  *
  * NOTES
  *       Every node type that can appear in stored rules' parsetrees *must*
@@ -96,7 +96,7 @@
 
 #define booltostr(x)  ((x) ? "true" : "false")
 
-static void _outNode(StringInfo str, void *obj);
+static void _outNode(StringInfo str, const void *obj);
 
 
 /*
@@ -107,7 +107,7 @@ static void _outNode(StringInfo str, void *obj);
  *       If a null or empty string is given, it is encoded as "<>".
  */
 static void
-_outToken(StringInfo str, char *s)
+_outToken(StringInfo str, const char *s)
 {
        if (s == NULL || *s == '\0')
        {
@@ -139,9 +139,9 @@ _outToken(StringInfo str, char *s)
 }
 
 static void
-_outList(StringInfo str, List *node)
+_outList(StringInfo str, const List *node)
 {
-       ListCell   *lc;
+       const ListCell *lc;
 
        appendStringInfoChar(str, '(');
 
@@ -182,7 +182,7 @@ _outList(StringInfo str, List *node)
  * Note: the output format is "(b int int ...)", similar to an integer List.
  */
 static void
-_outBitmapset(StringInfo str, Bitmapset *bms)
+_outBitmapset(StringInfo str, const Bitmapset *bms)
 {
        Bitmapset  *tmpset;
        int                     x;
@@ -237,20 +237,22 @@ _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
  */
 
 static void
-_outPlannedStmt(StringInfo str, PlannedStmt *node)
+_outPlannedStmt(StringInfo str, const PlannedStmt *node)
 {
        WRITE_NODE_TYPE("PLANNEDSTMT");
 
        WRITE_ENUM_FIELD(commandType, CmdType);
+       WRITE_UINT_FIELD(queryId);
+       WRITE_BOOL_FIELD(hasReturning);
+       WRITE_BOOL_FIELD(hasModifyingCTE);
        WRITE_BOOL_FIELD(canSetTag);
+       WRITE_BOOL_FIELD(transientPlan);
        WRITE_NODE_FIELD(planTree);
        WRITE_NODE_FIELD(rtable);
        WRITE_NODE_FIELD(resultRelations);
        WRITE_NODE_FIELD(utilityStmt);
-       WRITE_NODE_FIELD(intoClause);
        WRITE_NODE_FIELD(subplans);
        WRITE_BITMAPSET_FIELD(rewindPlanIDs);
-       WRITE_NODE_FIELD(returningLists);
        WRITE_NODE_FIELD(rowMarks);
        WRITE_NODE_FIELD(relationOids);
        WRITE_NODE_FIELD(invalItems);
@@ -261,7 +263,7 @@ _outPlannedStmt(StringInfo str, PlannedStmt *node)
  * print the basic stuff of all nodes that inherit from Plan
  */
 static void
-_outPlanInfo(StringInfo str, Plan *node)
+_outPlanInfo(StringInfo str, const Plan *node)
 {
        WRITE_FLOAT_FIELD(startup_cost, "%.2f");
        WRITE_FLOAT_FIELD(total_cost, "%.2f");
@@ -280,9 +282,9 @@ _outPlanInfo(StringInfo str, Plan *node)
  * print the basic stuff of all nodes that inherit from Scan
  */
 static void
-_outScanInfo(StringInfo str, Scan *node)
+_outScanInfo(StringInfo str, const Scan *node)
 {
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_UINT_FIELD(scanrelid);
 }
@@ -291,9 +293,9 @@ _outScanInfo(StringInfo str, Scan *node)
  * print the basic stuff of all nodes that inherit from Join
  */
 static void
-_outJoinPlanInfo(StringInfo str, Join *node)
+_outJoinPlanInfo(StringInfo str, const Join *node)
 {
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_ENUM_FIELD(jointype, JoinType);
        WRITE_NODE_FIELD(joinqual);
@@ -301,42 +303,88 @@ _outJoinPlanInfo(StringInfo str, Join *node)
 
 
 static void
-_outPlan(StringInfo str, Plan *node)
+_outPlan(StringInfo str, const Plan *node)
 {
        WRITE_NODE_TYPE("PLAN");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 }
 
 static void
-_outResult(StringInfo str, Result *node)
+_outResult(StringInfo str, const Result *node)
 {
        WRITE_NODE_TYPE("RESULT");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_NODE_FIELD(resconstantqual);
 }
 
 static void
-_outAppend(StringInfo str, Append *node)
+_outModifyTable(StringInfo str, const ModifyTable *node)
+{
+       WRITE_NODE_TYPE("MODIFYTABLE");
+
+       _outPlanInfo(str, (const Plan *) node);
+
+       WRITE_ENUM_FIELD(operation, CmdType);
+       WRITE_BOOL_FIELD(canSetTag);
+       WRITE_NODE_FIELD(resultRelations);
+       WRITE_INT_FIELD(resultRelIndex);
+       WRITE_NODE_FIELD(plans);
+       WRITE_NODE_FIELD(returningLists);
+       WRITE_NODE_FIELD(rowMarks);
+       WRITE_INT_FIELD(epqParam);
+}
+
+static void
+_outAppend(StringInfo str, const Append *node)
 {
        WRITE_NODE_TYPE("APPEND");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_NODE_FIELD(appendplans);
-       WRITE_BOOL_FIELD(isTarget);
 }
 
 static void
-_outRecursiveUnion(StringInfo str, RecursiveUnion *node)
+_outMergeAppend(StringInfo str, const MergeAppend *node)
+{
+       int                     i;
+
+       WRITE_NODE_TYPE("MERGEAPPEND");
+
+       _outPlanInfo(str, (const Plan *) node);
+
+       WRITE_NODE_FIELD(mergeplans);
+
+       WRITE_INT_FIELD(numCols);
+
+       appendStringInfo(str, " :sortColIdx");
+       for (i = 0; i < node->numCols; i++)
+               appendStringInfo(str, " %d", node->sortColIdx[i]);
+
+       appendStringInfo(str, " :sortOperators");
+       for (i = 0; i < node->numCols; i++)
+               appendStringInfo(str, " %u", node->sortOperators[i]);
+
+       appendStringInfo(str, " :collations");
+       for (i = 0; i < node->numCols; i++)
+               appendStringInfo(str, " %u", node->collations[i]);
+
+       appendStringInfo(str, " :nullsFirst");
+       for (i = 0; i < node->numCols; i++)
+               appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
+}
+
+static void
+_outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
 {
        int                     i;
 
        WRITE_NODE_TYPE("RECURSIVEUNION");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_INT_FIELD(wtParam);
        WRITE_INT_FIELD(numCols);
@@ -353,60 +401,76 @@ _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
 }
 
 static void
-_outBitmapAnd(StringInfo str, BitmapAnd *node)
+_outBitmapAnd(StringInfo str, const BitmapAnd *node)
 {
        WRITE_NODE_TYPE("BITMAPAND");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_NODE_FIELD(bitmapplans);
 }
 
 static void
-_outBitmapOr(StringInfo str, BitmapOr *node)
+_outBitmapOr(StringInfo str, const BitmapOr *node)
 {
        WRITE_NODE_TYPE("BITMAPOR");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_NODE_FIELD(bitmapplans);
 }
 
 static void
-_outScan(StringInfo str, Scan *node)
+_outScan(StringInfo str, const Scan *node)
 {
        WRITE_NODE_TYPE("SCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, node);
 }
 
 static void
-_outSeqScan(StringInfo str, SeqScan *node)
+_outSeqScan(StringInfo str, const SeqScan *node)
 {
        WRITE_NODE_TYPE("SEQSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 }
 
 static void
-_outIndexScan(StringInfo str, IndexScan *node)
+_outIndexScan(StringInfo str, const IndexScan *node)
 {
        WRITE_NODE_TYPE("INDEXSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_OID_FIELD(indexid);
        WRITE_NODE_FIELD(indexqual);
        WRITE_NODE_FIELD(indexqualorig);
+       WRITE_NODE_FIELD(indexorderby);
+       WRITE_NODE_FIELD(indexorderbyorig);
+       WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
+}
+
+static void
+_outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
+{
+       WRITE_NODE_TYPE("INDEXONLYSCAN");
+
+       _outScanInfo(str, (const Scan *) node);
+
+       WRITE_OID_FIELD(indexid);
+       WRITE_NODE_FIELD(indexqual);
+       WRITE_NODE_FIELD(indexorderby);
+       WRITE_NODE_FIELD(indextlist);
        WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
 }
 
 static void
-_outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
+_outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
 {
        WRITE_NODE_TYPE("BITMAPINDEXSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_OID_FIELD(indexid);
        WRITE_NODE_FIELD(indexqual);
@@ -414,105 +478,119 @@ _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
 }
 
 static void
-_outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
+_outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
 {
        WRITE_NODE_TYPE("BITMAPHEAPSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_NODE_FIELD(bitmapqualorig);
 }
 
 static void
-_outTidScan(StringInfo str, TidScan *node)
+_outTidScan(StringInfo str, const TidScan *node)
 {
        WRITE_NODE_TYPE("TIDSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_NODE_FIELD(tidquals);
 }
 
 static void
-_outSubqueryScan(StringInfo str, SubqueryScan *node)
+_outSubqueryScan(StringInfo str, const SubqueryScan *node)
 {
        WRITE_NODE_TYPE("SUBQUERYSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_NODE_FIELD(subplan);
-       WRITE_NODE_FIELD(subrtable);
 }
 
 static void
-_outFunctionScan(StringInfo str, FunctionScan *node)
+_outFunctionScan(StringInfo str, const FunctionScan *node)
 {
        WRITE_NODE_TYPE("FUNCTIONSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_NODE_FIELD(funcexpr);
        WRITE_NODE_FIELD(funccolnames);
        WRITE_NODE_FIELD(funccoltypes);
        WRITE_NODE_FIELD(funccoltypmods);
+       WRITE_NODE_FIELD(funccolcollations);
 }
 
 static void
-_outValuesScan(StringInfo str, ValuesScan *node)
+_outValuesScan(StringInfo str, const ValuesScan *node)
 {
        WRITE_NODE_TYPE("VALUESSCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_NODE_FIELD(values_lists);
 }
 
 static void
-_outCteScan(StringInfo str, CteScan *node)
+_outCteScan(StringInfo str, const CteScan *node)
 {
        WRITE_NODE_TYPE("CTESCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_INT_FIELD(ctePlanId);
        WRITE_INT_FIELD(cteParam);
 }
 
 static void
-_outWorkTableScan(StringInfo str, WorkTableScan *node)
+_outWorkTableScan(StringInfo str, const WorkTableScan *node)
 {
        WRITE_NODE_TYPE("WORKTABLESCAN");
 
-       _outScanInfo(str, (Scan *) node);
+       _outScanInfo(str, (const Scan *) node);
 
        WRITE_INT_FIELD(wtParam);
 }
 
 static void
-_outJoin(StringInfo str, Join *node)
+_outForeignScan(StringInfo str, const ForeignScan *node)
+{
+       WRITE_NODE_TYPE("FOREIGNSCAN");
+
+       _outScanInfo(str, (const Scan *) node);
+
+       WRITE_NODE_FIELD(fdw_exprs);
+       WRITE_NODE_FIELD(fdw_private);
+       WRITE_BOOL_FIELD(fsSystemCol);
+}
+
+static void
+_outJoin(StringInfo str, const Join *node)
 {
        WRITE_NODE_TYPE("JOIN");
 
-       _outJoinPlanInfo(str, (Join *) node);
+       _outJoinPlanInfo(str, (const Join *) node);
 }
 
 static void
-_outNestLoop(StringInfo str, NestLoop *node)
+_outNestLoop(StringInfo str, const NestLoop *node)
 {
        WRITE_NODE_TYPE("NESTLOOP");
 
-       _outJoinPlanInfo(str, (Join *) node);
+       _outJoinPlanInfo(str, (const Join *) node);
+
+       WRITE_NODE_FIELD(nestParams);
 }
 
 static void
-_outMergeJoin(StringInfo str, MergeJoin *node)
+_outMergeJoin(StringInfo str, const MergeJoin *node)
 {
        int                     numCols;
        int                     i;
 
        WRITE_NODE_TYPE("MERGEJOIN");
 
-       _outJoinPlanInfo(str, (Join *) node);
+       _outJoinPlanInfo(str, (const Join *) node);
 
        WRITE_NODE_FIELD(mergeclauses);
 
@@ -522,6 +600,10 @@ _outMergeJoin(StringInfo str, MergeJoin *node)
        for (i = 0; i < numCols; i++)
                appendStringInfo(str, " %u", node->mergeFamilies[i]);
 
+       appendStringInfo(str, " :mergeCollations");
+       for (i = 0; i < numCols; i++)
+               appendStringInfo(str, " %u", node->mergeCollations[i]);
+
        appendStringInfo(str, " :mergeStrategies");
        for (i = 0; i < numCols; i++)
                appendStringInfo(str, " %d", node->mergeStrategies[i]);
@@ -532,23 +614,23 @@ _outMergeJoin(StringInfo str, MergeJoin *node)
 }
 
 static void
-_outHashJoin(StringInfo str, HashJoin *node)
+_outHashJoin(StringInfo str, const HashJoin *node)
 {
        WRITE_NODE_TYPE("HASHJOIN");
 
-       _outJoinPlanInfo(str, (Join *) node);
+       _outJoinPlanInfo(str, (const Join *) node);
 
        WRITE_NODE_FIELD(hashclauses);
 }
 
 static void
-_outAgg(StringInfo str, Agg *node)
+_outAgg(StringInfo str, const Agg *node)
 {
        int                     i;
 
        WRITE_NODE_TYPE("AGG");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
        WRITE_INT_FIELD(numCols);
@@ -565,13 +647,13 @@ _outAgg(StringInfo str, Agg *node)
 }
 
 static void
-_outWindowAgg(StringInfo str, WindowAgg *node)
+_outWindowAgg(StringInfo str, const WindowAgg *node)
 {
        int                     i;
 
        WRITE_NODE_TYPE("WINDOWAGG");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_UINT_FIELD(winref);
        WRITE_INT_FIELD(partNumCols);
@@ -595,16 +677,18 @@ _outWindowAgg(StringInfo str, WindowAgg *node)
                appendStringInfo(str, " %u", node->ordOperators[i]);
 
        WRITE_INT_FIELD(frameOptions);
+       WRITE_NODE_FIELD(startOffset);
+       WRITE_NODE_FIELD(endOffset);
 }
 
 static void
-_outGroup(StringInfo str, Group *node)
+_outGroup(StringInfo str, const Group *node)
 {
        int                     i;
 
        WRITE_NODE_TYPE("GROUP");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_INT_FIELD(numCols);
 
@@ -618,21 +702,21 @@ _outGroup(StringInfo str, Group *node)
 }
 
 static void
-_outMaterial(StringInfo str, Material *node)
+_outMaterial(StringInfo str, const Material *node)
 {
        WRITE_NODE_TYPE("MATERIAL");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 }
 
 static void
-_outSort(StringInfo str, Sort *node)
+_outSort(StringInfo str, const Sort *node)
 {
        int                     i;
 
        WRITE_NODE_TYPE("SORT");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_INT_FIELD(numCols);
 
@@ -644,19 +728,23 @@ _outSort(StringInfo str, Sort *node)
        for (i = 0; i < node->numCols; i++)
                appendStringInfo(str, " %u", node->sortOperators[i]);
 
+       appendStringInfo(str, " :collations");
+       for (i = 0; i < node->numCols; i++)
+               appendStringInfo(str, " %u", node->collations[i]);
+
        appendStringInfo(str, " :nullsFirst");
        for (i = 0; i < node->numCols; i++)
                appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
 }
 
 static void
-_outUnique(StringInfo str, Unique *node)
+_outUnique(StringInfo str, const Unique *node)
 {
        int                     i;
 
        WRITE_NODE_TYPE("UNIQUE");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_INT_FIELD(numCols);
 
@@ -670,26 +758,27 @@ _outUnique(StringInfo str, Unique *node)
 }
 
 static void
-_outHash(StringInfo str, Hash *node)
+_outHash(StringInfo str, const Hash *node)
 {
        WRITE_NODE_TYPE("HASH");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_OID_FIELD(skewTable);
        WRITE_INT_FIELD(skewColumn);
+       WRITE_BOOL_FIELD(skewInherit);
        WRITE_OID_FIELD(skewColType);
        WRITE_INT_FIELD(skewColTypmod);
 }
 
 static void
-_outSetOp(StringInfo str, SetOp *node)
+_outSetOp(StringInfo str, const SetOp *node)
 {
        int                     i;
 
        WRITE_NODE_TYPE("SETOP");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_ENUM_FIELD(cmd, SetOpCmd);
        WRITE_ENUM_FIELD(strategy, SetOpStrategy);
@@ -709,25 +798,56 @@ _outSetOp(StringInfo str, SetOp *node)
 }
 
 static void
-_outLimit(StringInfo str, Limit *node)
+_outLockRows(StringInfo str, const LockRows *node)
+{
+       WRITE_NODE_TYPE("LOCKROWS");
+
+       _outPlanInfo(str, (const Plan *) node);
+
+       WRITE_NODE_FIELD(rowMarks);
+       WRITE_INT_FIELD(epqParam);
+}
+
+static void
+_outLimit(StringInfo str, const Limit *node)
 {
        WRITE_NODE_TYPE("LIMIT");
 
-       _outPlanInfo(str, (Plan *) node);
+       _outPlanInfo(str, (const Plan *) node);
 
        WRITE_NODE_FIELD(limitOffset);
        WRITE_NODE_FIELD(limitCount);
 }
 
 static void
-_outPlanInvalItem(StringInfo str, PlanInvalItem *node)
+_outNestLoopParam(StringInfo str, const NestLoopParam *node)
+{
+       WRITE_NODE_TYPE("NESTLOOPPARAM");
+
+       WRITE_INT_FIELD(paramno);
+       WRITE_NODE_FIELD(paramval);
+}
+
+static void
+_outPlanRowMark(StringInfo str, const PlanRowMark *node)
+{
+       WRITE_NODE_TYPE("PLANROWMARK");
+
+       WRITE_UINT_FIELD(rti);
+       WRITE_UINT_FIELD(prti);
+       WRITE_UINT_FIELD(rowmarkId);
+       WRITE_ENUM_FIELD(markType, RowMarkType);
+       WRITE_BOOL_FIELD(noWait);
+       WRITE_BOOL_FIELD(isParent);
+}
+
+static void
+_outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
 {
        WRITE_NODE_TYPE("PLANINVALITEM");
 
        WRITE_INT_FIELD(cacheId);
-       appendStringInfo(str, " :tupleId (%u,%u)",
-                                        ItemPointerGetBlockNumber(&node->tupleId),
-                                        ItemPointerGetOffsetNumber(&node->tupleId));
+       WRITE_UINT_FIELD(hashValue);
 }
 
 /*****************************************************************************
@@ -737,7 +857,7 @@ _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
  *****************************************************************************/
 
 static void
-_outAlias(StringInfo str, Alias *node)
+_outAlias(StringInfo str, const Alias *node)
 {
        WRITE_NODE_TYPE("ALIAS");
 
@@ -746,7 +866,7 @@ _outAlias(StringInfo str, Alias *node)
 }
 
 static void
-_outRangeVar(StringInfo str, RangeVar *node)
+_outRangeVar(StringInfo str, const RangeVar *node)
 {
        WRITE_NODE_TYPE("RANGEVAR");
 
@@ -757,13 +877,13 @@ _outRangeVar(StringInfo str, RangeVar *node)
        WRITE_STRING_FIELD(schemaname);
        WRITE_STRING_FIELD(relname);
        WRITE_ENUM_FIELD(inhOpt, InhOption);
-       WRITE_BOOL_FIELD(istemp);
+       WRITE_CHAR_FIELD(relpersistence);
        WRITE_NODE_FIELD(alias);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outIntoClause(StringInfo str, IntoClause *node)
+_outIntoClause(StringInfo str, const IntoClause *node)
 {
        WRITE_NODE_TYPE("INTOCLAUSE");
 
@@ -772,10 +892,11 @@ _outIntoClause(StringInfo str, IntoClause *node)
        WRITE_NODE_FIELD(options);
        WRITE_ENUM_FIELD(onCommit, OnCommitAction);
        WRITE_STRING_FIELD(tableSpaceName);
+       WRITE_BOOL_FIELD(skipData);
 }
 
 static void
-_outVar(StringInfo str, Var *node)
+_outVar(StringInfo str, const Var *node)
 {
        WRITE_NODE_TYPE("VAR");
 
@@ -783,6 +904,7 @@ _outVar(StringInfo str, Var *node)
        WRITE_INT_FIELD(varattno);
        WRITE_OID_FIELD(vartype);
        WRITE_INT_FIELD(vartypmod);
+       WRITE_OID_FIELD(varcollid);
        WRITE_UINT_FIELD(varlevelsup);
        WRITE_UINT_FIELD(varnoold);
        WRITE_INT_FIELD(varoattno);
@@ -790,12 +912,13 @@ _outVar(StringInfo str, Var *node)
 }
 
 static void
-_outConst(StringInfo str, Const *node)
+_outConst(StringInfo str, const Const *node)
 {
        WRITE_NODE_TYPE("CONST");
 
        WRITE_OID_FIELD(consttype);
        WRITE_INT_FIELD(consttypmod);
+       WRITE_OID_FIELD(constcollid);
        WRITE_INT_FIELD(constlen);
        WRITE_BOOL_FIELD(constbyval);
        WRITE_BOOL_FIELD(constisnull);
@@ -809,7 +932,7 @@ _outConst(StringInfo str, Const *node)
 }
 
 static void
-_outParam(StringInfo str, Param *node)
+_outParam(StringInfo str, const Param *node)
 {
        WRITE_NODE_TYPE("PARAM");
 
@@ -817,30 +940,36 @@ _outParam(StringInfo str, Param *node)
        WRITE_INT_FIELD(paramid);
        WRITE_OID_FIELD(paramtype);
        WRITE_INT_FIELD(paramtypmod);
+       WRITE_OID_FIELD(paramcollid);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outAggref(StringInfo str, Aggref *node)
+_outAggref(StringInfo str, const Aggref *node)
 {
        WRITE_NODE_TYPE("AGGREF");
 
        WRITE_OID_FIELD(aggfnoid);
        WRITE_OID_FIELD(aggtype);
+       WRITE_OID_FIELD(aggcollid);
+       WRITE_OID_FIELD(inputcollid);
        WRITE_NODE_FIELD(args);
-       WRITE_UINT_FIELD(agglevelsup);
+       WRITE_NODE_FIELD(aggorder);
+       WRITE_NODE_FIELD(aggdistinct);
        WRITE_BOOL_FIELD(aggstar);
-       WRITE_BOOL_FIELD(aggdistinct);
+       WRITE_UINT_FIELD(agglevelsup);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outWindowFunc(StringInfo str, WindowFunc *node)
+_outWindowFunc(StringInfo str, const WindowFunc *node)
 {
        WRITE_NODE_TYPE("WINDOWFUNC");
 
        WRITE_OID_FIELD(winfnoid);
        WRITE_OID_FIELD(wintype);
+       WRITE_OID_FIELD(wincollid);
+       WRITE_OID_FIELD(inputcollid);
        WRITE_NODE_FIELD(args);
        WRITE_UINT_FIELD(winref);
        WRITE_BOOL_FIELD(winstar);
@@ -849,13 +978,14 @@ _outWindowFunc(StringInfo str, WindowFunc *node)
 }
 
 static void
-_outArrayRef(StringInfo str, ArrayRef *node)
+_outArrayRef(StringInfo str, const ArrayRef *node)
 {
        WRITE_NODE_TYPE("ARRAYREF");
 
        WRITE_OID_FIELD(refarraytype);
        WRITE_OID_FIELD(refelemtype);
        WRITE_INT_FIELD(reftypmod);
+       WRITE_OID_FIELD(refcollid);
        WRITE_NODE_FIELD(refupperindexpr);
        WRITE_NODE_FIELD(reflowerindexpr);
        WRITE_NODE_FIELD(refexpr);
@@ -863,7 +993,7 @@ _outArrayRef(StringInfo str, ArrayRef *node)
 }
 
 static void
-_outFuncExpr(StringInfo str, FuncExpr *node)
+_outFuncExpr(StringInfo str, const FuncExpr *node)
 {
        WRITE_NODE_TYPE("FUNCEXPR");
 
@@ -871,12 +1001,14 @@ _outFuncExpr(StringInfo str, FuncExpr *node)
        WRITE_OID_FIELD(funcresulttype);
        WRITE_BOOL_FIELD(funcretset);
        WRITE_ENUM_FIELD(funcformat, CoercionForm);
+       WRITE_OID_FIELD(funccollid);
+       WRITE_OID_FIELD(inputcollid);
        WRITE_NODE_FIELD(args);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outNamedArgExpr(StringInfo str, NamedArgExpr *node)
+_outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
 {
        WRITE_NODE_TYPE("NAMEDARGEXPR");
 
@@ -887,7 +1019,7 @@ _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
 }
 
 static void
-_outOpExpr(StringInfo str, OpExpr *node)
+_outOpExpr(StringInfo str, const OpExpr *node)
 {
        WRITE_NODE_TYPE("OPEXPR");
 
@@ -895,12 +1027,14 @@ _outOpExpr(StringInfo str, OpExpr *node)
        WRITE_OID_FIELD(opfuncid);
        WRITE_OID_FIELD(opresulttype);
        WRITE_BOOL_FIELD(opretset);
+       WRITE_OID_FIELD(opcollid);
+       WRITE_OID_FIELD(inputcollid);
        WRITE_NODE_FIELD(args);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outDistinctExpr(StringInfo str, DistinctExpr *node)
+_outDistinctExpr(StringInfo str, const DistinctExpr *node)
 {
        WRITE_NODE_TYPE("DISTINCTEXPR");
 
@@ -908,24 +1042,42 @@ _outDistinctExpr(StringInfo str, DistinctExpr *node)
        WRITE_OID_FIELD(opfuncid);
        WRITE_OID_FIELD(opresulttype);
        WRITE_BOOL_FIELD(opretset);
+       WRITE_OID_FIELD(opcollid);
+       WRITE_OID_FIELD(inputcollid);
+       WRITE_NODE_FIELD(args);
+       WRITE_LOCATION_FIELD(location);
+}
+
+static void
+_outNullIfExpr(StringInfo str, const NullIfExpr *node)
+{
+       WRITE_NODE_TYPE("NULLIFEXPR");
+
+       WRITE_OID_FIELD(opno);
+       WRITE_OID_FIELD(opfuncid);
+       WRITE_OID_FIELD(opresulttype);
+       WRITE_BOOL_FIELD(opretset);
+       WRITE_OID_FIELD(opcollid);
+       WRITE_OID_FIELD(inputcollid);
        WRITE_NODE_FIELD(args);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
+_outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
 {
        WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
 
        WRITE_OID_FIELD(opno);
        WRITE_OID_FIELD(opfuncid);
        WRITE_BOOL_FIELD(useOr);
+       WRITE_OID_FIELD(inputcollid);
        WRITE_NODE_FIELD(args);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outBoolExpr(StringInfo str, BoolExpr *node)
+_outBoolExpr(StringInfo str, const BoolExpr *node)
 {
        char       *opstr = NULL;
 
@@ -952,7 +1104,7 @@ _outBoolExpr(StringInfo str, BoolExpr *node)
 }
 
 static void
-_outSubLink(StringInfo str, SubLink *node)
+_outSubLink(StringInfo str, const SubLink *node)
 {
        WRITE_NODE_TYPE("SUBLINK");
 
@@ -964,7 +1116,7 @@ _outSubLink(StringInfo str, SubLink *node)
 }
 
 static void
-_outSubPlan(StringInfo str, SubPlan *node)
+_outSubPlan(StringInfo str, const SubPlan *node)
 {
        WRITE_NODE_TYPE("SUBPLAN");
 
@@ -975,6 +1127,7 @@ _outSubPlan(StringInfo str, SubPlan *node)
        WRITE_STRING_FIELD(plan_name);
        WRITE_OID_FIELD(firstColType);
        WRITE_INT_FIELD(firstColTypmod);
+       WRITE_OID_FIELD(firstColCollation);
        WRITE_BOOL_FIELD(useHashTable);
        WRITE_BOOL_FIELD(unknownEqFalse);
        WRITE_NODE_FIELD(setParam);
@@ -985,7 +1138,7 @@ _outSubPlan(StringInfo str, SubPlan *node)
 }
 
 static void
-_outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
+_outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
 {
        WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
 
@@ -993,7 +1146,7 @@ _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
 }
 
 static void
-_outFieldSelect(StringInfo str, FieldSelect *node)
+_outFieldSelect(StringInfo str, const FieldSelect *node)
 {
        WRITE_NODE_TYPE("FIELDSELECT");
 
@@ -1001,10 +1154,11 @@ _outFieldSelect(StringInfo str, FieldSelect *node)
        WRITE_INT_FIELD(fieldnum);
        WRITE_OID_FIELD(resulttype);
        WRITE_INT_FIELD(resulttypmod);
+       WRITE_OID_FIELD(resultcollid);
 }
 
 static void
-_outFieldStore(StringInfo str, FieldStore *node)
+_outFieldStore(StringInfo str, const FieldStore *node)
 {
        WRITE_NODE_TYPE("FIELDSTORE");
 
@@ -1015,30 +1169,32 @@ _outFieldStore(StringInfo str, FieldStore *node)
 }
 
 static void
-_outRelabelType(StringInfo str, RelabelType *node)
+_outRelabelType(StringInfo str, const RelabelType *node)
 {
        WRITE_NODE_TYPE("RELABELTYPE");
 
        WRITE_NODE_FIELD(arg);
        WRITE_OID_FIELD(resulttype);
        WRITE_INT_FIELD(resulttypmod);
+       WRITE_OID_FIELD(resultcollid);
        WRITE_ENUM_FIELD(relabelformat, CoercionForm);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outCoerceViaIO(StringInfo str, CoerceViaIO *node)
+_outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
 {
        WRITE_NODE_TYPE("COERCEVIAIO");
 
        WRITE_NODE_FIELD(arg);
        WRITE_OID_FIELD(resulttype);
+       WRITE_OID_FIELD(resultcollid);
        WRITE_ENUM_FIELD(coerceformat, CoercionForm);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
+_outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
 {
        WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
 
@@ -1046,13 +1202,14 @@ _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
        WRITE_OID_FIELD(elemfuncid);
        WRITE_OID_FIELD(resulttype);
        WRITE_INT_FIELD(resulttypmod);
+       WRITE_OID_FIELD(resultcollid);
        WRITE_BOOL_FIELD(isExplicit);
        WRITE_ENUM_FIELD(coerceformat, CoercionForm);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
+_outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
 {
        WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
 
@@ -1063,11 +1220,22 @@ _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
 }
 
 static void
-_outCaseExpr(StringInfo str, CaseExpr *node)
+_outCollateExpr(StringInfo str, const CollateExpr *node)
+{
+       WRITE_NODE_TYPE("COLLATE");
+
+       WRITE_NODE_FIELD(arg);
+       WRITE_OID_FIELD(collOid);
+       WRITE_LOCATION_FIELD(location);
+}
+
+static void
+_outCaseExpr(StringInfo str, const CaseExpr *node)
 {
        WRITE_NODE_TYPE("CASE");
 
        WRITE_OID_FIELD(casetype);
+       WRITE_OID_FIELD(casecollid);
        WRITE_NODE_FIELD(arg);
        WRITE_NODE_FIELD(args);
        WRITE_NODE_FIELD(defresult);
@@ -1075,7 +1243,7 @@ _outCaseExpr(StringInfo str, CaseExpr *node)
 }
 
 static void
-_outCaseWhen(StringInfo str, CaseWhen *node)
+_outCaseWhen(StringInfo str, const CaseWhen *node)
 {
        WRITE_NODE_TYPE("WHEN");
 
@@ -1085,20 +1253,22 @@ _outCaseWhen(StringInfo str, CaseWhen *node)
 }
 
 static void
-_outCaseTestExpr(StringInfo str, CaseTestExpr *node)
+_outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
 {
        WRITE_NODE_TYPE("CASETESTEXPR");
 
        WRITE_OID_FIELD(typeId);
        WRITE_INT_FIELD(typeMod);
+       WRITE_OID_FIELD(collation);
 }
 
 static void
-_outArrayExpr(StringInfo str, ArrayExpr *node)
+_outArrayExpr(StringInfo str, const ArrayExpr *node)
 {
        WRITE_NODE_TYPE("ARRAY");
 
        WRITE_OID_FIELD(array_typeid);
+       WRITE_OID_FIELD(array_collid);
        WRITE_OID_FIELD(element_typeid);
        WRITE_NODE_FIELD(elements);
        WRITE_BOOL_FIELD(multidims);
@@ -1106,7 +1276,7 @@ _outArrayExpr(StringInfo str, ArrayExpr *node)
 }
 
 static void
-_outRowExpr(StringInfo str, RowExpr *node)
+_outRowExpr(StringInfo str, const RowExpr *node)
 {
        WRITE_NODE_TYPE("ROW");
 
@@ -1118,40 +1288,44 @@ _outRowExpr(StringInfo str, RowExpr *node)
 }
 
 static void
-_outRowCompareExpr(StringInfo str, RowCompareExpr *node)
+_outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
 {
        WRITE_NODE_TYPE("ROWCOMPARE");
 
        WRITE_ENUM_FIELD(rctype, RowCompareType);
        WRITE_NODE_FIELD(opnos);
        WRITE_NODE_FIELD(opfamilies);
+       WRITE_NODE_FIELD(inputcollids);
        WRITE_NODE_FIELD(largs);
        WRITE_NODE_FIELD(rargs);
 }
 
 static void
-_outCoalesceExpr(StringInfo str, CoalesceExpr *node)
+_outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
 {
        WRITE_NODE_TYPE("COALESCE");
 
        WRITE_OID_FIELD(coalescetype);
+       WRITE_OID_FIELD(coalescecollid);
        WRITE_NODE_FIELD(args);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outMinMaxExpr(StringInfo str, MinMaxExpr *node)
+_outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
 {
        WRITE_NODE_TYPE("MINMAX");
 
        WRITE_OID_FIELD(minmaxtype);
+       WRITE_OID_FIELD(minmaxcollid);
+       WRITE_OID_FIELD(inputcollid);
        WRITE_ENUM_FIELD(op, MinMaxOp);
        WRITE_NODE_FIELD(args);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outXmlExpr(StringInfo str, XmlExpr *node)
+_outXmlExpr(StringInfo str, const XmlExpr *node)
 {
        WRITE_NODE_TYPE("XMLEXPR");
 
@@ -1167,29 +1341,17 @@ _outXmlExpr(StringInfo str, XmlExpr *node)
 }
 
 static void
-_outNullIfExpr(StringInfo str, NullIfExpr *node)
-{
-       WRITE_NODE_TYPE("NULLIFEXPR");
-
-       WRITE_OID_FIELD(opno);
-       WRITE_OID_FIELD(opfuncid);
-       WRITE_OID_FIELD(opresulttype);
-       WRITE_BOOL_FIELD(opretset);
-       WRITE_NODE_FIELD(args);
-       WRITE_LOCATION_FIELD(location);
-}
-
-static void
-_outNullTest(StringInfo str, NullTest *node)
+_outNullTest(StringInfo str, const NullTest *node)
 {
        WRITE_NODE_TYPE("NULLTEST");
 
        WRITE_NODE_FIELD(arg);
        WRITE_ENUM_FIELD(nulltesttype, NullTestType);
+       WRITE_BOOL_FIELD(argisrow);
 }
 
 static void
-_outBooleanTest(StringInfo str, BooleanTest *node)
+_outBooleanTest(StringInfo str, const BooleanTest *node)
 {
        WRITE_NODE_TYPE("BOOLEANTEST");
 
@@ -1198,39 +1360,42 @@ _outBooleanTest(StringInfo str, BooleanTest *node)
 }
 
 static void
-_outCoerceToDomain(StringInfo str, CoerceToDomain *node)
+_outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
 {
        WRITE_NODE_TYPE("COERCETODOMAIN");
 
        WRITE_NODE_FIELD(arg);
        WRITE_OID_FIELD(resulttype);
        WRITE_INT_FIELD(resulttypmod);
+       WRITE_OID_FIELD(resultcollid);
        WRITE_ENUM_FIELD(coercionformat, CoercionForm);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
+_outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
 {
        WRITE_NODE_TYPE("COERCETODOMAINVALUE");
 
        WRITE_OID_FIELD(typeId);
        WRITE_INT_FIELD(typeMod);
+       WRITE_OID_FIELD(collation);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outSetToDefault(StringInfo str, SetToDefault *node)
+_outSetToDefault(StringInfo str, const SetToDefault *node)
 {
        WRITE_NODE_TYPE("SETTODEFAULT");
 
        WRITE_OID_FIELD(typeId);
        WRITE_INT_FIELD(typeMod);
+       WRITE_OID_FIELD(collation);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
+_outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
 {
        WRITE_NODE_TYPE("CURRENTOFEXPR");
 
@@ -1240,7 +1405,7 @@ _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
 }
 
 static void
-_outTargetEntry(StringInfo str, TargetEntry *node)
+_outTargetEntry(StringInfo str, const TargetEntry *node)
 {
        WRITE_NODE_TYPE("TARGETENTRY");
 
@@ -1254,7 +1419,7 @@ _outTargetEntry(StringInfo str, TargetEntry *node)
 }
 
 static void
-_outRangeTblRef(StringInfo str, RangeTblRef *node)
+_outRangeTblRef(StringInfo str, const RangeTblRef *node)
 {
        WRITE_NODE_TYPE("RANGETBLREF");
 
@@ -1262,7 +1427,7 @@ _outRangeTblRef(StringInfo str, RangeTblRef *node)
 }
 
 static void
-_outJoinExpr(StringInfo str, JoinExpr *node)
+_outJoinExpr(StringInfo str, const JoinExpr *node)
 {
        WRITE_NODE_TYPE("JOINEXPR");
 
@@ -1277,7 +1442,7 @@ _outJoinExpr(StringInfo str, JoinExpr *node)
 }
 
 static void
-_outFromExpr(StringInfo str, FromExpr *node)
+_outFromExpr(StringInfo str, const FromExpr *node)
 {
        WRITE_NODE_TYPE("FROMEXPR");
 
@@ -1294,12 +1459,24 @@ _outFromExpr(StringInfo str, FromExpr *node)
 /*
  * print the basic stuff of all nodes that inherit from Path
  *
- * Note we do NOT print the parent, else we'd be in infinite recursion
+ * Note we do NOT print the parent, else we'd be in infinite recursion.
+ * We can print the parent's relids for identification purposes, though.
+ * We also do not print the whole of param_info, since it's printed by
+ * _outRelOptInfo; it's sufficient and less cluttering to print just the
+ * required outer relids.
  */
 static void
-_outPathInfo(StringInfo str, Path *node)
+_outPathInfo(StringInfo str, const Path *node)
 {
        WRITE_ENUM_FIELD(pathtype, NodeTag);
+       appendStringInfo(str, " :parent_relids ");
+       _outBitmapset(str, node->parent->relids);
+       appendStringInfo(str, " :required_outer ");
+       if (node->param_info)
+               _outBitmapset(str, node->param_info->ppi_req_outer);
+       else
+               _outBitmapset(str, NULL);
+       WRITE_FLOAT_FIELD(rows, "%.0f");
        WRITE_FLOAT_FIELD(startup_cost, "%.2f");
        WRITE_FLOAT_FIELD(total_cost, "%.2f");
        WRITE_NODE_FIELD(pathkeys);
@@ -1309,9 +1486,9 @@ _outPathInfo(StringInfo str, Path *node)
  * print the basic stuff of all nodes that inherit from JoinPath
  */
 static void
-_outJoinPathInfo(StringInfo str, JoinPath *node)
+_outJoinPathInfo(StringInfo str, const JoinPath *node)
 {
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_ENUM_FIELD(jointype, JoinType);
        WRITE_NODE_FIELD(outerjoinpath);
@@ -1320,178 +1497,190 @@ _outJoinPathInfo(StringInfo str, JoinPath *node)
 }
 
 static void
-_outPath(StringInfo str, Path *node)
+_outPath(StringInfo str, const Path *node)
 {
        WRITE_NODE_TYPE("PATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 }
 
 static void
-_outIndexPath(StringInfo str, IndexPath *node)
+_outIndexPath(StringInfo str, const IndexPath *node)
 {
        WRITE_NODE_TYPE("INDEXPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(indexinfo);
        WRITE_NODE_FIELD(indexclauses);
        WRITE_NODE_FIELD(indexquals);
-       WRITE_BOOL_FIELD(isjoininner);
+       WRITE_NODE_FIELD(indexqualcols);
+       WRITE_NODE_FIELD(indexorderbys);
+       WRITE_NODE_FIELD(indexorderbycols);
        WRITE_ENUM_FIELD(indexscandir, ScanDirection);
        WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
        WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
-       WRITE_FLOAT_FIELD(rows, "%.0f");
 }
 
 static void
-_outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
+_outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
 {
        WRITE_NODE_TYPE("BITMAPHEAPPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(bitmapqual);
-       WRITE_BOOL_FIELD(isjoininner);
-       WRITE_FLOAT_FIELD(rows, "%.0f");
 }
 
 static void
-_outBitmapAndPath(StringInfo str, BitmapAndPath *node)
+_outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
 {
        WRITE_NODE_TYPE("BITMAPANDPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(bitmapquals);
        WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
 }
 
 static void
-_outBitmapOrPath(StringInfo str, BitmapOrPath *node)
+_outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
 {
        WRITE_NODE_TYPE("BITMAPORPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(bitmapquals);
        WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
 }
 
 static void
-_outTidPath(StringInfo str, TidPath *node)
+_outTidPath(StringInfo str, const TidPath *node)
 {
        WRITE_NODE_TYPE("TIDPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(tidquals);
 }
 
 static void
-_outAppendPath(StringInfo str, AppendPath *node)
+_outForeignPath(StringInfo str, const ForeignPath *node)
+{
+       WRITE_NODE_TYPE("FOREIGNPATH");
+
+       _outPathInfo(str, (const Path *) node);
+
+       WRITE_NODE_FIELD(fdw_private);
+}
+
+static void
+_outAppendPath(StringInfo str, const AppendPath *node)
 {
        WRITE_NODE_TYPE("APPENDPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
+
+       WRITE_NODE_FIELD(subpaths);
+}
+
+static void
+_outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
+{
+       WRITE_NODE_TYPE("MERGEAPPENDPATH");
+
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(subpaths);
+       WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
 }
 
 static void
-_outResultPath(StringInfo str, ResultPath *node)
+_outResultPath(StringInfo str, const ResultPath *node)
 {
        WRITE_NODE_TYPE("RESULTPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(quals);
 }
 
 static void
-_outMaterialPath(StringInfo str, MaterialPath *node)
+_outMaterialPath(StringInfo str, const MaterialPath *node)
 {
        WRITE_NODE_TYPE("MATERIALPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(subpath);
 }
 
 static void
-_outUniquePath(StringInfo str, UniquePath *node)
+_outUniquePath(StringInfo str, const UniquePath *node)
 {
        WRITE_NODE_TYPE("UNIQUEPATH");
 
-       _outPathInfo(str, (Path *) node);
+       _outPathInfo(str, (const Path *) node);
 
        WRITE_NODE_FIELD(subpath);
        WRITE_ENUM_FIELD(umethod, UniquePathMethod);
        WRITE_NODE_FIELD(in_operators);
        WRITE_NODE_FIELD(uniq_exprs);
-       WRITE_FLOAT_FIELD(rows, "%.0f");
-}
-
-static void
-_outNoOpPath(StringInfo str, NoOpPath *node)
-{
-       WRITE_NODE_TYPE("NOOPPATH");
-
-       _outPathInfo(str, (Path *) node);
-
-       WRITE_NODE_FIELD(subpath);
 }
 
 static void
-_outNestPath(StringInfo str, NestPath *node)
+_outNestPath(StringInfo str, const NestPath *node)
 {
        WRITE_NODE_TYPE("NESTPATH");
 
-       _outJoinPathInfo(str, (JoinPath *) node);
+       _outJoinPathInfo(str, (const JoinPath *) node);
 }
 
 static void
-_outMergePath(StringInfo str, MergePath *node)
+_outMergePath(StringInfo str, const MergePath *node)
 {
        WRITE_NODE_TYPE("MERGEPATH");
 
-       _outJoinPathInfo(str, (JoinPath *) node);
+       _outJoinPathInfo(str, (const JoinPath *) node);
 
        WRITE_NODE_FIELD(path_mergeclauses);
        WRITE_NODE_FIELD(outersortkeys);
        WRITE_NODE_FIELD(innersortkeys);
+       WRITE_BOOL_FIELD(materialize_inner);
 }
 
 static void
-_outHashPath(StringInfo str, HashPath *node)
+_outHashPath(StringInfo str, const HashPath *node)
 {
        WRITE_NODE_TYPE("HASHPATH");
 
-       _outJoinPathInfo(str, (JoinPath *) node);
+       _outJoinPathInfo(str, (const JoinPath *) node);
 
        WRITE_NODE_FIELD(path_hashclauses);
        WRITE_INT_FIELD(num_batches);
 }
 
 static void
-_outPlannerGlobal(StringInfo str, PlannerGlobal *node)
+_outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
 {
        WRITE_NODE_TYPE("PLANNERGLOBAL");
 
        /* NB: this isn't a complete set of fields */
-       WRITE_NODE_FIELD(paramlist);
        WRITE_NODE_FIELD(subplans);
-       WRITE_NODE_FIELD(subrtables);
        WRITE_BITMAPSET_FIELD(rewindPlanIDs);
        WRITE_NODE_FIELD(finalrtable);
+       WRITE_NODE_FIELD(finalrowmarks);
+       WRITE_NODE_FIELD(resultRelations);
        WRITE_NODE_FIELD(relationOids);
        WRITE_NODE_FIELD(invalItems);
+       WRITE_INT_FIELD(nParamExec);
        WRITE_UINT_FIELD(lastPHId);
+       WRITE_UINT_FIELD(lastRowMarkId);
        WRITE_BOOL_FIELD(transientPlan);
 }
 
 static void
-_outPlannerInfo(StringInfo str, PlannerInfo *node)
+_outPlannerInfo(StringInfo str, const PlannerInfo *node)
 {
        WRITE_NODE_TYPE("PLANNERINFO");
 
@@ -1499,9 +1688,10 @@ _outPlannerInfo(StringInfo str, PlannerInfo *node)
        WRITE_NODE_FIELD(parse);
        WRITE_NODE_FIELD(glob);
        WRITE_UINT_FIELD(query_level);
+       WRITE_NODE_FIELD(plan_params);
+       WRITE_BITMAPSET_FIELD(all_baserels);
        WRITE_NODE_FIELD(join_rel_list);
-       WRITE_NODE_FIELD(resultRelations);
-       WRITE_NODE_FIELD(returningLists);
+       WRITE_INT_FIELD(join_cur_level);
        WRITE_NODE_FIELD(init_plans);
        WRITE_NODE_FIELD(cte_plan_ids);
        WRITE_NODE_FIELD(eq_classes);
@@ -1510,24 +1700,32 @@ _outPlannerInfo(StringInfo str, PlannerInfo *node)
        WRITE_NODE_FIELD(right_join_clauses);
        WRITE_NODE_FIELD(full_join_clauses);
        WRITE_NODE_FIELD(join_info_list);
+       WRITE_NODE_FIELD(lateral_info_list);
        WRITE_NODE_FIELD(append_rel_list);
+       WRITE_NODE_FIELD(rowMarks);
        WRITE_NODE_FIELD(placeholder_list);
        WRITE_NODE_FIELD(query_pathkeys);
        WRITE_NODE_FIELD(group_pathkeys);
        WRITE_NODE_FIELD(window_pathkeys);
        WRITE_NODE_FIELD(distinct_pathkeys);
        WRITE_NODE_FIELD(sort_pathkeys);
+       WRITE_NODE_FIELD(minmax_aggs);
        WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
        WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
+       WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
+       WRITE_BOOL_FIELD(hasInheritedTarget);
        WRITE_BOOL_FIELD(hasJoinRTEs);
+       WRITE_BOOL_FIELD(hasLateralRTEs);
        WRITE_BOOL_FIELD(hasHavingQual);
        WRITE_BOOL_FIELD(hasPseudoConstantQuals);
        WRITE_BOOL_FIELD(hasRecursion);
        WRITE_INT_FIELD(wt_param_id);
+       WRITE_BITMAPSET_FIELD(curOuterRels);
+       WRITE_NODE_FIELD(curOuterParams);
 }
 
 static void
-_outRelOptInfo(StringInfo str, RelOptInfo *node)
+_outRelOptInfo(StringInfo str, const RelOptInfo *node)
 {
        WRITE_NODE_TYPE("RELOPTINFO");
 
@@ -1536,29 +1734,36 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
        WRITE_BITMAPSET_FIELD(relids);
        WRITE_FLOAT_FIELD(rows, "%.0f");
        WRITE_INT_FIELD(width);
+       WRITE_BOOL_FIELD(consider_startup);
        WRITE_NODE_FIELD(reltargetlist);
        WRITE_NODE_FIELD(pathlist);
+       WRITE_NODE_FIELD(ppilist);
        WRITE_NODE_FIELD(cheapest_startup_path);
        WRITE_NODE_FIELD(cheapest_total_path);
        WRITE_NODE_FIELD(cheapest_unique_path);
+       WRITE_NODE_FIELD(cheapest_parameterized_paths);
        WRITE_UINT_FIELD(relid);
+       WRITE_UINT_FIELD(reltablespace);
        WRITE_ENUM_FIELD(rtekind, RTEKind);
        WRITE_INT_FIELD(min_attr);
        WRITE_INT_FIELD(max_attr);
+       WRITE_NODE_FIELD(lateral_vars);
+       WRITE_BITMAPSET_FIELD(lateral_relids);
        WRITE_NODE_FIELD(indexlist);
        WRITE_UINT_FIELD(pages);
        WRITE_FLOAT_FIELD(tuples, "%.0f");
+       WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
        WRITE_NODE_FIELD(subplan);
-       WRITE_NODE_FIELD(subrtable);
+       WRITE_NODE_FIELD(subroot);
+       WRITE_NODE_FIELD(subplan_params);
+       /* we don't try to print fdwroutine or fdw_private */
        WRITE_NODE_FIELD(baserestrictinfo);
        WRITE_NODE_FIELD(joininfo);
        WRITE_BOOL_FIELD(has_eclass_joins);
-       WRITE_BITMAPSET_FIELD(index_outer_relids);
-       WRITE_NODE_FIELD(index_inner_paths);
 }
 
 static void
-_outIndexOptInfo(StringInfo str, IndexOptInfo *node)
+_outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
 {
        WRITE_NODE_TYPE("INDEXOPTINFO");
 
@@ -1568,14 +1773,18 @@ _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
        WRITE_UINT_FIELD(pages);
        WRITE_FLOAT_FIELD(tuples, "%.0f");
        WRITE_INT_FIELD(ncolumns);
-       WRITE_NODE_FIELD(indexprs);
+       WRITE_OID_FIELD(relam);
+       /* indexprs is redundant since we print indextlist */
        WRITE_NODE_FIELD(indpred);
+       WRITE_NODE_FIELD(indextlist);
        WRITE_BOOL_FIELD(predOK);
        WRITE_BOOL_FIELD(unique);
+       WRITE_BOOL_FIELD(immediate);
+       WRITE_BOOL_FIELD(hypothetical);
 }
 
 static void
-_outEquivalenceClass(StringInfo str, EquivalenceClass *node)
+_outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
 {
        /*
         * To simplify reading, we just chase up to the topmost merged EC and
@@ -1587,6 +1796,7 @@ _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
        WRITE_NODE_TYPE("EQUIVALENCECLASS");
 
        WRITE_NODE_FIELD(ec_opfamilies);
+       WRITE_OID_FIELD(ec_collation);
        WRITE_NODE_FIELD(ec_members);
        WRITE_NODE_FIELD(ec_sources);
        WRITE_NODE_FIELD(ec_derives);
@@ -1599,7 +1809,7 @@ _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
 }
 
 static void
-_outEquivalenceMember(StringInfo str, EquivalenceMember *node)
+_outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
 {
        WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
 
@@ -1611,7 +1821,7 @@ _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
 }
 
 static void
-_outPathKey(StringInfo str, PathKey *node)
+_outPathKey(StringInfo str, const PathKey *node)
 {
        WRITE_NODE_TYPE("PATHKEY");
 
@@ -1622,7 +1832,17 @@ _outPathKey(StringInfo str, PathKey *node)
 }
 
 static void
-_outRestrictInfo(StringInfo str, RestrictInfo *node)
+_outParamPathInfo(StringInfo str, const ParamPathInfo *node)
+{
+       WRITE_NODE_TYPE("PARAMPATHINFO");
+
+       WRITE_BITMAPSET_FIELD(ppi_req_outer);
+       WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
+       WRITE_NODE_FIELD(ppi_clauses);
+}
+
+static void
+_outRestrictInfo(StringInfo str, const RestrictInfo *node)
 {
        WRITE_NODE_TYPE("RESTRICTINFO");
 
@@ -1634,6 +1854,7 @@ _outRestrictInfo(StringInfo str, RestrictInfo *node)
        WRITE_BOOL_FIELD(pseudoconstant);
        WRITE_BITMAPSET_FIELD(clause_relids);
        WRITE_BITMAPSET_FIELD(required_relids);
+       WRITE_BITMAPSET_FIELD(outer_relids);
        WRITE_BITMAPSET_FIELD(nullable_relids);
        WRITE_BITMAPSET_FIELD(left_relids);
        WRITE_BITMAPSET_FIELD(right_relids);
@@ -1651,17 +1872,7 @@ _outRestrictInfo(StringInfo str, RestrictInfo *node)
 }
 
 static void
-_outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
-{
-       WRITE_NODE_TYPE("INNERINDEXSCANINFO");
-       WRITE_BITMAPSET_FIELD(other_relids);
-       WRITE_BOOL_FIELD(isouterjoin);
-       WRITE_NODE_FIELD(cheapest_startup_innerpath);
-       WRITE_NODE_FIELD(cheapest_total_innerpath);
-}
-
-static void
-_outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
+_outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
 {
        WRITE_NODE_TYPE("PLACEHOLDERVAR");
 
@@ -1672,7 +1883,7 @@ _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
 }
 
 static void
-_outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
+_outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
 {
        WRITE_NODE_TYPE("SPECIALJOININFO");
 
@@ -1687,7 +1898,16 @@ _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
 }
 
 static void
-_outAppendRelInfo(StringInfo str, AppendRelInfo *node)
+_outLateralJoinInfo(StringInfo str, const LateralJoinInfo *node)
+{
+       WRITE_NODE_TYPE("LATERALJOININFO");
+
+       WRITE_UINT_FIELD(lateral_rhs);
+       WRITE_BITMAPSET_FIELD(lateral_lhs);
+}
+
+static void
+_outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
 {
        WRITE_NODE_TYPE("APPENDRELINFO");
 
@@ -1700,7 +1920,7 @@ _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
 }
 
 static void
-_outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
+_outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
 {
        WRITE_NODE_TYPE("PLACEHOLDERINFO");
 
@@ -1708,16 +1928,31 @@ _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
        WRITE_NODE_FIELD(ph_var);
        WRITE_BITMAPSET_FIELD(ph_eval_at);
        WRITE_BITMAPSET_FIELD(ph_needed);
+       WRITE_BITMAPSET_FIELD(ph_may_need);
        WRITE_INT_FIELD(ph_width);
 }
 
 static void
-_outPlannerParamItem(StringInfo str, PlannerParamItem *node)
+_outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
+{
+       WRITE_NODE_TYPE("MINMAXAGGINFO");
+
+       WRITE_OID_FIELD(aggfnoid);
+       WRITE_OID_FIELD(aggsortop);
+       WRITE_NODE_FIELD(target);
+       /* We intentionally omit subroot --- too large, not interesting enough */
+       WRITE_NODE_FIELD(path);
+       WRITE_FLOAT_FIELD(pathcost, "%.2f");
+       WRITE_NODE_FIELD(param);
+}
+
+static void
+_outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
 {
        WRITE_NODE_TYPE("PLANNERPARAMITEM");
 
        WRITE_NODE_FIELD(item);
-       WRITE_UINT_FIELD(abslevel);
+       WRITE_INT_FIELD(paramId);
 }
 
 /*****************************************************************************
@@ -1726,22 +1961,44 @@ _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
  *
  *****************************************************************************/
 
+/*
+ * print the basic stuff of all nodes that inherit from CreateStmt
+ */
 static void
-_outCreateStmt(StringInfo str, CreateStmt *node)
+_outCreateStmtInfo(StringInfo str, const CreateStmt *node)
 {
-       WRITE_NODE_TYPE("CREATESTMT");
-
        WRITE_NODE_FIELD(relation);
        WRITE_NODE_FIELD(tableElts);
        WRITE_NODE_FIELD(inhRelations);
+       WRITE_NODE_FIELD(ofTypename);
        WRITE_NODE_FIELD(constraints);
        WRITE_NODE_FIELD(options);
        WRITE_ENUM_FIELD(oncommit, OnCommitAction);
        WRITE_STRING_FIELD(tablespacename);
+       WRITE_BOOL_FIELD(if_not_exists);
+}
+
+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);
 }
 
 static void
-_outIndexStmt(StringInfo str, IndexStmt *node)
+_outIndexStmt(StringInfo str, const IndexStmt *node)
 {
        WRITE_NODE_TYPE("INDEXSTMT");
 
@@ -1752,6 +2009,10 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
        WRITE_NODE_FIELD(indexParams);
        WRITE_NODE_FIELD(options);
        WRITE_NODE_FIELD(whereClause);
+       WRITE_NODE_FIELD(excludeOpNames);
+       WRITE_STRING_FIELD(idxcomment);
+       WRITE_OID_FIELD(indexOid);
+       WRITE_OID_FIELD(oldNode);
        WRITE_BOOL_FIELD(unique);
        WRITE_BOOL_FIELD(primary);
        WRITE_BOOL_FIELD(isconstraint);
@@ -1761,15 +2022,16 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
 }
 
 static void
-_outNotifyStmt(StringInfo str, NotifyStmt *node)
+_outNotifyStmt(StringInfo str, const NotifyStmt *node)
 {
        WRITE_NODE_TYPE("NOTIFY");
 
        WRITE_STRING_FIELD(conditionname);
+       WRITE_STRING_FIELD(payload);
 }
 
 static void
-_outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
+_outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
 {
        WRITE_NODE_TYPE("DECLARECURSOR");
 
@@ -1779,7 +2041,7 @@ _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
 }
 
 static void
-_outSelectStmt(StringInfo str, SelectStmt *node)
+_outSelectStmt(StringInfo str, const SelectStmt *node)
 {
        WRITE_NODE_TYPE("SELECT");
 
@@ -1791,12 +2053,12 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
        WRITE_NODE_FIELD(groupClause);
        WRITE_NODE_FIELD(havingClause);
        WRITE_NODE_FIELD(windowClause);
-       WRITE_NODE_FIELD(withClause);
        WRITE_NODE_FIELD(valuesLists);
        WRITE_NODE_FIELD(sortClause);
        WRITE_NODE_FIELD(limitOffset);
        WRITE_NODE_FIELD(limitCount);
        WRITE_NODE_FIELD(lockingClause);
+       WRITE_NODE_FIELD(withClause);
        WRITE_ENUM_FIELD(op, SetOperation);
        WRITE_BOOL_FIELD(all);
        WRITE_NODE_FIELD(larg);
@@ -1804,12 +2066,13 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
 }
 
 static void
-_outFuncCall(StringInfo str, FuncCall *node)
+_outFuncCall(StringInfo str, const FuncCall *node)
 {
        WRITE_NODE_TYPE("FUNCCALL");
 
        WRITE_NODE_FIELD(funcname);
        WRITE_NODE_FIELD(args);
+       WRITE_NODE_FIELD(agg_order);
        WRITE_BOOL_FIELD(agg_star);
        WRITE_BOOL_FIELD(agg_distinct);
        WRITE_BOOL_FIELD(func_variadic);
@@ -1818,7 +2081,7 @@ _outFuncCall(StringInfo str, FuncCall *node)
 }
 
 static void
-_outDefElem(StringInfo str, DefElem *node)
+_outDefElem(StringInfo str, const DefElem *node)
 {
        WRITE_NODE_TYPE("DEFELEM");
 
@@ -1829,7 +2092,16 @@ _outDefElem(StringInfo str, DefElem *node)
 }
 
 static void
-_outLockingClause(StringInfo str, LockingClause *node)
+_outTableLikeClause(StringInfo str, const TableLikeClause *node)
+{
+       WRITE_NODE_TYPE("TABLELIKECLAUSE");
+
+       WRITE_NODE_FIELD(relation);
+       WRITE_UINT_FIELD(options);
+}
+
+static void
+_outLockingClause(StringInfo str, const LockingClause *node)
 {
        WRITE_NODE_TYPE("LOCKINGCLAUSE");
 
@@ -1839,7 +2111,7 @@ _outLockingClause(StringInfo str, LockingClause *node)
 }
 
 static void
-_outXmlSerialize(StringInfo str, XmlSerialize *node)
+_outXmlSerialize(StringInfo str, const XmlSerialize *node)
 {
        WRITE_NODE_TYPE("XMLSERIALIZE");
 
@@ -1850,7 +2122,7 @@ _outXmlSerialize(StringInfo str, XmlSerialize *node)
 }
 
 static void
-_outColumnDef(StringInfo str, ColumnDef *node)
+_outColumnDef(StringInfo str, const ColumnDef *node)
 {
        WRITE_NODE_TYPE("COLUMNDEF");
 
@@ -1859,13 +2131,18 @@ _outColumnDef(StringInfo str, ColumnDef *node)
        WRITE_INT_FIELD(inhcount);
        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);
+       WRITE_OID_FIELD(collOid);
        WRITE_NODE_FIELD(constraints);
+       WRITE_NODE_FIELD(fdwoptions);
 }
 
 static void
-_outTypeName(StringInfo str, TypeName *node)
+_outTypeName(StringInfo str, const TypeName *node)
 {
        WRITE_NODE_TYPE("TYPENAME");
 
@@ -1880,7 +2157,7 @@ _outTypeName(StringInfo str, TypeName *node)
 }
 
 static void
-_outTypeCast(StringInfo str, TypeCast *node)
+_outTypeCast(StringInfo str, const TypeCast *node)
 {
        WRITE_NODE_TYPE("TYPECAST");
 
@@ -1890,24 +2167,37 @@ _outTypeCast(StringInfo str, TypeCast *node)
 }
 
 static void
-_outIndexElem(StringInfo str, IndexElem *node)
+_outCollateClause(StringInfo str, const CollateClause *node)
+{
+       WRITE_NODE_TYPE("COLLATECLAUSE");
+
+       WRITE_NODE_FIELD(arg);
+       WRITE_NODE_FIELD(collname);
+       WRITE_LOCATION_FIELD(location);
+}
+
+static void
+_outIndexElem(StringInfo str, const IndexElem *node)
 {
        WRITE_NODE_TYPE("INDEXELEM");
 
        WRITE_STRING_FIELD(name);
        WRITE_NODE_FIELD(expr);
+       WRITE_STRING_FIELD(indexcolname);
+       WRITE_NODE_FIELD(collation);
        WRITE_NODE_FIELD(opclass);
        WRITE_ENUM_FIELD(ordering, SortByDir);
        WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
 }
 
 static void
-_outQuery(StringInfo str, Query *node)
+_outQuery(StringInfo str, const Query *node)
 {
        WRITE_NODE_TYPE("QUERY");
 
        WRITE_ENUM_FIELD(commandType, CmdType);
        WRITE_ENUM_FIELD(querySource, QuerySource);
+       /* we intentionally do not print the queryId field */
        WRITE_BOOL_FIELD(canSetTag);
 
        /*
@@ -1936,12 +2226,13 @@ _outQuery(StringInfo str, Query *node)
                appendStringInfo(str, " :utilityStmt <>");
 
        WRITE_INT_FIELD(resultRelation);
-       WRITE_NODE_FIELD(intoClause);
        WRITE_BOOL_FIELD(hasAggs);
        WRITE_BOOL_FIELD(hasWindowFuncs);
        WRITE_BOOL_FIELD(hasSubLinks);
        WRITE_BOOL_FIELD(hasDistinctOn);
        WRITE_BOOL_FIELD(hasRecursive);
+       WRITE_BOOL_FIELD(hasModifyingCTE);
+       WRITE_BOOL_FIELD(hasForUpdate);
        WRITE_NODE_FIELD(cteList);
        WRITE_NODE_FIELD(rtable);
        WRITE_NODE_FIELD(jointree);
@@ -1956,10 +2247,11 @@ _outQuery(StringInfo str, Query *node)
        WRITE_NODE_FIELD(limitCount);
        WRITE_NODE_FIELD(rowMarks);
        WRITE_NODE_FIELD(setOperations);
+       WRITE_NODE_FIELD(constraintDeps);
 }
 
 static void
-_outSortGroupClause(StringInfo str, SortGroupClause *node)
+_outSortGroupClause(StringInfo str, const SortGroupClause *node)
 {
        WRITE_NODE_TYPE("SORTGROUPCLAUSE");
 
@@ -1967,10 +2259,11 @@ _outSortGroupClause(StringInfo str, SortGroupClause *node)
        WRITE_OID_FIELD(eqop);
        WRITE_OID_FIELD(sortop);
        WRITE_BOOL_FIELD(nulls_first);
+       WRITE_BOOL_FIELD(hashable);
 }
 
 static void
-_outWindowClause(StringInfo str, WindowClause *node)
+_outWindowClause(StringInfo str, const WindowClause *node)
 {
        WRITE_NODE_TYPE("WINDOWCLAUSE");
 
@@ -1979,24 +2272,25 @@ _outWindowClause(StringInfo str, WindowClause *node)
        WRITE_NODE_FIELD(partitionClause);
        WRITE_NODE_FIELD(orderClause);
        WRITE_INT_FIELD(frameOptions);
+       WRITE_NODE_FIELD(startOffset);
+       WRITE_NODE_FIELD(endOffset);
        WRITE_UINT_FIELD(winref);
        WRITE_BOOL_FIELD(copiedOrder);
 }
 
 static void
-_outRowMarkClause(StringInfo str, RowMarkClause *node)
+_outRowMarkClause(StringInfo str, const RowMarkClause *node)
 {
        WRITE_NODE_TYPE("ROWMARKCLAUSE");
 
        WRITE_UINT_FIELD(rti);
-       WRITE_UINT_FIELD(prti);
        WRITE_BOOL_FIELD(forUpdate);
        WRITE_BOOL_FIELD(noWait);
-       WRITE_BOOL_FIELD(isParent);
+       WRITE_BOOL_FIELD(pushedDown);
 }
 
 static void
-_outWithClause(StringInfo str, WithClause *node)
+_outWithClause(StringInfo str, const WithClause *node)
 {
        WRITE_NODE_TYPE("WITHCLAUSE");
 
@@ -2006,7 +2300,7 @@ _outWithClause(StringInfo str, WithClause *node)
 }
 
 static void
-_outCommonTableExpr(StringInfo str, CommonTableExpr *node)
+_outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
 {
        WRITE_NODE_TYPE("COMMONTABLEEXPR");
 
@@ -2019,10 +2313,11 @@ _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
        WRITE_NODE_FIELD(ctecolnames);
        WRITE_NODE_FIELD(ctecoltypes);
        WRITE_NODE_FIELD(ctecoltypmods);
+       WRITE_NODE_FIELD(ctecolcollations);
 }
 
 static void
-_outSetOperationStmt(StringInfo str, SetOperationStmt *node)
+_outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
 {
        WRITE_NODE_TYPE("SETOPERATIONSTMT");
 
@@ -2032,11 +2327,12 @@ _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
        WRITE_NODE_FIELD(rarg);
        WRITE_NODE_FIELD(colTypes);
        WRITE_NODE_FIELD(colTypmods);
+       WRITE_NODE_FIELD(colCollations);
        WRITE_NODE_FIELD(groupClauses);
 }
 
 static void
-_outRangeTblEntry(StringInfo str, RangeTblEntry *node)
+_outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
 {
        WRITE_NODE_TYPE("RTE");
 
@@ -2048,11 +2344,12 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
        switch (node->rtekind)
        {
                case RTE_RELATION:
-               case RTE_SPECIAL:
                        WRITE_OID_FIELD(relid);
+                       WRITE_CHAR_FIELD(relkind);
                        break;
                case RTE_SUBQUERY:
                        WRITE_NODE_FIELD(subquery);
+                       WRITE_BOOL_FIELD(security_barrier);
                        break;
                case RTE_JOIN:
                        WRITE_ENUM_FIELD(jointype, JoinType);
@@ -2062,9 +2359,11 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
                        WRITE_NODE_FIELD(funcexpr);
                        WRITE_NODE_FIELD(funccoltypes);
                        WRITE_NODE_FIELD(funccoltypmods);
+                       WRITE_NODE_FIELD(funccolcollations);
                        break;
                case RTE_VALUES:
                        WRITE_NODE_FIELD(values_lists);
+                       WRITE_NODE_FIELD(values_collations);
                        break;
                case RTE_CTE:
                        WRITE_STRING_FIELD(ctename);
@@ -2072,12 +2371,14 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
                        WRITE_BOOL_FIELD(self_reference);
                        WRITE_NODE_FIELD(ctecoltypes);
                        WRITE_NODE_FIELD(ctecoltypmods);
+                       WRITE_NODE_FIELD(ctecolcollations);
                        break;
                default:
                        elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
                        break;
        }
 
+       WRITE_BOOL_FIELD(lateral);
        WRITE_BOOL_FIELD(inh);
        WRITE_BOOL_FIELD(inFromCl);
        WRITE_UINT_FIELD(requiredPerms);
@@ -2087,7 +2388,7 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
 }
 
 static void
-_outAExpr(StringInfo str, A_Expr *node)
+_outAExpr(StringInfo str, const A_Expr *node)
 {
        WRITE_NODE_TYPE("AEXPR");
 
@@ -2143,7 +2444,7 @@ _outAExpr(StringInfo str, A_Expr *node)
 }
 
 static void
-_outValue(StringInfo str, Value *value)
+_outValue(StringInfo str, const Value *value)
 {
        switch (value->type)
        {
@@ -2178,7 +2479,7 @@ _outValue(StringInfo str, Value *value)
 }
 
 static void
-_outColumnRef(StringInfo str, ColumnRef *node)
+_outColumnRef(StringInfo str, const ColumnRef *node)
 {
        WRITE_NODE_TYPE("COLUMNREF");
 
@@ -2187,7 +2488,7 @@ _outColumnRef(StringInfo str, ColumnRef *node)
 }
 
 static void
-_outParamRef(StringInfo str, ParamRef *node)
+_outParamRef(StringInfo str, const ParamRef *node)
 {
        WRITE_NODE_TYPE("PARAMREF");
 
@@ -2196,7 +2497,7 @@ _outParamRef(StringInfo str, ParamRef *node)
 }
 
 static void
-_outAConst(StringInfo str, A_Const *node)
+_outAConst(StringInfo str, const A_Const *node)
 {
        WRITE_NODE_TYPE("A_CONST");
 
@@ -2206,13 +2507,13 @@ _outAConst(StringInfo str, A_Const *node)
 }
 
 static void
-_outA_Star(StringInfo str, A_Star *node)
+_outA_Star(StringInfo str, const A_Star *node)
 {
        WRITE_NODE_TYPE("A_STAR");
 }
 
 static void
-_outA_Indices(StringInfo str, A_Indices *node)
+_outA_Indices(StringInfo str, const A_Indices *node)
 {
        WRITE_NODE_TYPE("A_INDICES");
 
@@ -2221,7 +2522,7 @@ _outA_Indices(StringInfo str, A_Indices *node)
 }
 
 static void
-_outA_Indirection(StringInfo str, A_Indirection *node)
+_outA_Indirection(StringInfo str, const A_Indirection *node)
 {
        WRITE_NODE_TYPE("A_INDIRECTION");
 
@@ -2230,7 +2531,7 @@ _outA_Indirection(StringInfo str, A_Indirection *node)
 }
 
 static void
-_outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
+_outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
 {
        WRITE_NODE_TYPE("A_ARRAYEXPR");
 
@@ -2239,7 +2540,7 @@ _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
 }
 
 static void
-_outResTarget(StringInfo str, ResTarget *node)
+_outResTarget(StringInfo str, const ResTarget *node)
 {
        WRITE_NODE_TYPE("RESTARGET");
 
@@ -2250,7 +2551,7 @@ _outResTarget(StringInfo str, ResTarget *node)
 }
 
 static void
-_outSortBy(StringInfo str, SortBy *node)
+_outSortBy(StringInfo str, const SortBy *node)
 {
        WRITE_NODE_TYPE("SORTBY");
 
@@ -2262,7 +2563,7 @@ _outSortBy(StringInfo str, SortBy *node)
 }
 
 static void
-_outWindowDef(StringInfo str, WindowDef *node)
+_outWindowDef(StringInfo str, const WindowDef *node)
 {
        WRITE_NODE_TYPE("WINDOWDEF");
 
@@ -2271,30 +2572,34 @@ _outWindowDef(StringInfo str, WindowDef *node)
        WRITE_NODE_FIELD(partitionClause);
        WRITE_NODE_FIELD(orderClause);
        WRITE_INT_FIELD(frameOptions);
+       WRITE_NODE_FIELD(startOffset);
+       WRITE_NODE_FIELD(endOffset);
        WRITE_LOCATION_FIELD(location);
 }
 
 static void
-_outRangeSubselect(StringInfo str, RangeSubselect *node)
+_outRangeSubselect(StringInfo str, const RangeSubselect *node)
 {
        WRITE_NODE_TYPE("RANGESUBSELECT");
 
+       WRITE_BOOL_FIELD(lateral);
        WRITE_NODE_FIELD(subquery);
        WRITE_NODE_FIELD(alias);
 }
 
 static void
-_outRangeFunction(StringInfo str, RangeFunction *node)
+_outRangeFunction(StringInfo str, const RangeFunction *node)
 {
        WRITE_NODE_TYPE("RANGEFUNCTION");
 
+       WRITE_BOOL_FIELD(lateral);
        WRITE_NODE_FIELD(funccallnode);
        WRITE_NODE_FIELD(alias);
        WRITE_NODE_FIELD(coldeflist);
 }
 
 static void
-_outConstraint(StringInfo str, Constraint *node)
+_outConstraint(StringInfo str, const Constraint *node)
 {
        WRITE_NODE_TYPE("CONSTRAINT");
 
@@ -2322,6 +2627,7 @@ _outConstraint(StringInfo str, Constraint *node)
 
                case CONSTR_CHECK:
                        appendStringInfo(str, "CHECK");
+                       WRITE_BOOL_FIELD(is_no_inherit);
                        WRITE_NODE_FIELD(raw_expr);
                        WRITE_STRING_FIELD(cooked_expr);
                        break;
@@ -2330,14 +2636,28 @@ _outConstraint(StringInfo str, Constraint *node)
                        appendStringInfo(str, "PRIMARY_KEY");
                        WRITE_NODE_FIELD(keys);
                        WRITE_NODE_FIELD(options);
+                       WRITE_STRING_FIELD(indexname);
                        WRITE_STRING_FIELD(indexspace);
+                       /* access_method and where_clause not currently used */
                        break;
 
                case CONSTR_UNIQUE:
                        appendStringInfo(str, "UNIQUE");
                        WRITE_NODE_FIELD(keys);
                        WRITE_NODE_FIELD(options);
+                       WRITE_STRING_FIELD(indexname);
                        WRITE_STRING_FIELD(indexspace);
+                       /* access_method and where_clause not currently used */
+                       break;
+
+               case CONSTR_EXCLUSION:
+                       appendStringInfo(str, "EXCLUSION");
+                       WRITE_NODE_FIELD(exclusions);
+                       WRITE_NODE_FIELD(options);
+                       WRITE_STRING_FIELD(indexname);
+                       WRITE_STRING_FIELD(indexspace);
+                       WRITE_STRING_FIELD(access_method);
+                       WRITE_NODE_FIELD(where_clause);
                        break;
 
                case CONSTR_FOREIGN:
@@ -2348,7 +2668,9 @@ _outConstraint(StringInfo str, Constraint *node)
                        WRITE_CHAR_FIELD(fk_matchtype);
                        WRITE_CHAR_FIELD(fk_upd_action);
                        WRITE_CHAR_FIELD(fk_del_action);
+                       WRITE_NODE_FIELD(old_conpfeqop);
                        WRITE_BOOL_FIELD(skip_validation);
+                       WRITE_BOOL_FIELD(initially_valid);
                        break;
 
                case CONSTR_ATTR_DEFERRABLE:
@@ -2380,7 +2702,7 @@ _outConstraint(StringInfo str, Constraint *node)
  *       converts a Node into ascii string and append it to 'str'
  */
 static void
-_outNode(StringInfo str, void *obj)
+_outNode(StringInfo str, const void *obj)
 {
        if (obj == NULL)
                appendStringInfo(str, "<>");
@@ -2408,9 +2730,15 @@ _outNode(StringInfo str, void *obj)
                        case T_Result:
                                _outResult(str, obj);
                                break;
+                       case T_ModifyTable:
+                               _outModifyTable(str, obj);
+                               break;
                        case T_Append:
                                _outAppend(str, obj);
                                break;
+                       case T_MergeAppend:
+                               _outMergeAppend(str, obj);
+                               break;
                        case T_RecursiveUnion:
                                _outRecursiveUnion(str, obj);
                                break;
@@ -2429,6 +2757,9 @@ _outNode(StringInfo str, void *obj)
                        case T_IndexScan:
                                _outIndexScan(str, obj);
                                break;
+                       case T_IndexOnlyScan:
+                               _outIndexOnlyScan(str, obj);
+                               break;
                        case T_BitmapIndexScan:
                                _outBitmapIndexScan(str, obj);
                                break;
@@ -2453,6 +2784,9 @@ _outNode(StringInfo str, void *obj)
                        case T_WorkTableScan:
                                _outWorkTableScan(str, obj);
                                break;
+                       case T_ForeignScan:
+                               _outForeignScan(str, obj);
+                               break;
                        case T_Join:
                                _outJoin(str, obj);
                                break;
@@ -2489,9 +2823,18 @@ _outNode(StringInfo str, void *obj)
                        case T_SetOp:
                                _outSetOp(str, obj);
                                break;
+                       case T_LockRows:
+                               _outLockRows(str, obj);
+                               break;
                        case T_Limit:
                                _outLimit(str, obj);
                                break;
+                       case T_NestLoopParam:
+                               _outNestLoopParam(str, obj);
+                               break;
+                       case T_PlanRowMark:
+                               _outPlanRowMark(str, obj);
+                               break;
                        case T_PlanInvalItem:
                                _outPlanInvalItem(str, obj);
                                break;
@@ -2534,6 +2877,9 @@ _outNode(StringInfo str, void *obj)
                        case T_DistinctExpr:
                                _outDistinctExpr(str, obj);
                                break;
+                       case T_NullIfExpr:
+                               _outNullIfExpr(str, obj);
+                               break;
                        case T_ScalarArrayOpExpr:
                                _outScalarArrayOpExpr(str, obj);
                                break;
@@ -2567,6 +2913,9 @@ _outNode(StringInfo str, void *obj)
                        case T_ConvertRowtypeExpr:
                                _outConvertRowtypeExpr(str, obj);
                                break;
+                       case T_CollateExpr:
+                               _outCollateExpr(str, obj);
+                               break;
                        case T_CaseExpr:
                                _outCaseExpr(str, obj);
                                break;
@@ -2594,9 +2943,6 @@ _outNode(StringInfo str, void *obj)
                        case T_XmlExpr:
                                _outXmlExpr(str, obj);
                                break;
-                       case T_NullIfExpr:
-                               _outNullIfExpr(str, obj);
-                               break;
                        case T_NullTest:
                                _outNullTest(str, obj);
                                break;
@@ -2646,9 +2992,15 @@ _outNode(StringInfo str, void *obj)
                        case T_TidPath:
                                _outTidPath(str, obj);
                                break;
+                       case T_ForeignPath:
+                               _outForeignPath(str, obj);
+                               break;
                        case T_AppendPath:
                                _outAppendPath(str, obj);
                                break;
+                       case T_MergeAppendPath:
+                               _outMergeAppendPath(str, obj);
+                               break;
                        case T_ResultPath:
                                _outResultPath(str, obj);
                                break;
@@ -2658,9 +3010,6 @@ _outNode(StringInfo str, void *obj)
                        case T_UniquePath:
                                _outUniquePath(str, obj);
                                break;
-                       case T_NoOpPath:
-                               _outNoOpPath(str, obj);
-                               break;
                        case T_NestPath:
                                _outNestPath(str, obj);
                                break;
@@ -2691,24 +3040,30 @@ _outNode(StringInfo str, void *obj)
                        case T_PathKey:
                                _outPathKey(str, obj);
                                break;
+                       case T_ParamPathInfo:
+                               _outParamPathInfo(str, obj);
+                               break;
                        case T_RestrictInfo:
                                _outRestrictInfo(str, obj);
                                break;
-                       case T_InnerIndexscanInfo:
-                               _outInnerIndexscanInfo(str, obj);
-                               break;
                        case T_PlaceHolderVar:
                                _outPlaceHolderVar(str, obj);
                                break;
                        case T_SpecialJoinInfo:
                                _outSpecialJoinInfo(str, obj);
                                break;
+                       case T_LateralJoinInfo:
+                               _outLateralJoinInfo(str, obj);
+                               break;
                        case T_AppendRelInfo:
                                _outAppendRelInfo(str, obj);
                                break;
                        case T_PlaceHolderInfo:
                                _outPlaceHolderInfo(str, obj);
                                break;
+                       case T_MinMaxAggInfo:
+                               _outMinMaxAggInfo(str, obj);
+                               break;
                        case T_PlannerParamItem:
                                _outPlannerParamItem(str, obj);
                                break;
@@ -2716,6 +3071,9 @@ _outNode(StringInfo str, void *obj)
                        case T_CreateStmt:
                                _outCreateStmt(str, obj);
                                break;
+                       case T_CreateForeignTableStmt:
+                               _outCreateForeignTableStmt(str, obj);
+                               break;
                        case T_IndexStmt:
                                _outIndexStmt(str, obj);
                                break;
@@ -2737,6 +3095,9 @@ _outNode(StringInfo str, void *obj)
                        case T_TypeCast:
                                _outTypeCast(str, obj);
                                break;
+                       case T_CollateClause:
+                               _outCollateClause(str, obj);
+                               break;
                        case T_IndexElem:
                                _outIndexElem(str, obj);
                                break;
@@ -2812,6 +3173,9 @@ _outNode(StringInfo str, void *obj)
                        case T_DefElem:
                                _outDefElem(str, obj);
                                break;
+                       case T_TableLikeClause:
+                               _outTableLikeClause(str, obj);
+                               break;
                        case T_LockingClause:
                                _outLockingClause(str, obj);
                                break;
@@ -2838,7 +3202,7 @@ _outNode(StringInfo str, void *obj)
  *        returns the ascii representation of the Node as a palloc'd string
  */
 char *
-nodeToString(void *obj)
+nodeToString(const void *obj)
 {
        StringInfoData str;