1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/nodes/outfuncs.c
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify output of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire conventions about the names of the local variables in an Out
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41 appendStringInfoString(str, nodelabel)
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47 /* Write an unsigned integer field (anything written as ":fldname %u") */
48 #define WRITE_UINT_FIELD(fldname) \
49 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
51 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
52 #define WRITE_OID_FIELD(fldname) \
53 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
68 /* Write a float field --- caller must give format to define precision */
69 #define WRITE_FLOAT_FIELD(fldname,format) \
70 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75 booltostr(node->fldname))
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 _outToken(str, node->fldname))
82 /* Write a parse location field (actually same as INT case) */
83 #define WRITE_LOCATION_FIELD(fldname) \
84 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
86 /* Write a Node field */
87 #define WRITE_NODE_FIELD(fldname) \
88 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
89 _outNode(str, node->fldname))
91 /* Write a bitmapset field */
92 #define WRITE_BITMAPSET_FIELD(fldname) \
93 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
94 _outBitmapset(str, node->fldname))
97 #define booltostr(x) ((x) ? "true" : "false")
99 static void _outNode(StringInfo str, const void *obj);
104 * Convert an ordinary string (eg, an identifier) into a form that
105 * will be decoded back to a plain token by read.c's functions.
107 * If a null or empty string is given, it is encoded as "<>".
110 _outToken(StringInfo str, const char *s)
112 if (s == NULL || *s == '\0')
114 appendStringInfo(str, "<>");
119 * Look for characters or patterns that are treated specially by read.c
120 * (either in pg_strtok() or in nodeRead()), and therefore need a
121 * protective backslash.
123 /* These characters only need to be quoted at the start of the string */
126 isdigit((unsigned char) *s) ||
127 ((*s == '+' || *s == '-') &&
128 (isdigit((unsigned char) s[1]) || s[1] == '.')))
129 appendStringInfoChar(str, '\\');
132 /* These chars must be backslashed anywhere in the string */
133 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
136 appendStringInfoChar(str, '\\');
137 appendStringInfoChar(str, *s++);
142 _outList(StringInfo str, const List *node)
146 appendStringInfoChar(str, '(');
148 if (IsA(node, IntList))
149 appendStringInfoChar(str, 'i');
150 else if (IsA(node, OidList))
151 appendStringInfoChar(str, 'o');
156 * For the sake of backward compatibility, we emit a slightly
157 * different whitespace format for lists of nodes vs. other types of
158 * lists. XXX: is this necessary?
162 _outNode(str, lfirst(lc));
164 appendStringInfoChar(str, ' ');
166 else if (IsA(node, IntList))
167 appendStringInfo(str, " %d", lfirst_int(lc));
168 else if (IsA(node, OidList))
169 appendStringInfo(str, " %u", lfirst_oid(lc));
171 elog(ERROR, "unrecognized list node type: %d",
175 appendStringInfoChar(str, ')');
180 * converts a bitmap set of integers
182 * Note: the output format is "(b int int ...)", similar to an integer List.
185 _outBitmapset(StringInfo str, const Bitmapset *bms)
190 appendStringInfoChar(str, '(');
191 appendStringInfoChar(str, 'b');
192 tmpset = bms_copy(bms);
193 while ((x = bms_first_member(tmpset)) >= 0)
194 appendStringInfo(str, " %d", x);
196 appendStringInfoChar(str, ')');
200 * Print the value of a Datum given its type.
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
209 length = datumGetSize(value, typbyval, typlen);
213 s = (char *) (&value);
214 appendStringInfo(str, "%u [ ", (unsigned int) length);
215 for (i = 0; i < (Size) sizeof(Datum); i++)
216 appendStringInfo(str, "%d ", (int) (s[i]));
217 appendStringInfo(str, "]");
221 s = (char *) DatumGetPointer(value);
222 if (!PointerIsValid(s))
223 appendStringInfo(str, "0 [ ]");
226 appendStringInfo(str, "%u [ ", (unsigned int) length);
227 for (i = 0; i < length; i++)
228 appendStringInfo(str, "%d ", (int) (s[i]));
229 appendStringInfo(str, "]");
236 * Stuff from plannodes.h
240 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
242 WRITE_NODE_TYPE("PLANNEDSTMT");
244 WRITE_ENUM_FIELD(commandType, CmdType);
245 WRITE_UINT_FIELD(queryId);
246 WRITE_BOOL_FIELD(hasReturning);
247 WRITE_BOOL_FIELD(hasModifyingCTE);
248 WRITE_BOOL_FIELD(canSetTag);
249 WRITE_BOOL_FIELD(transientPlan);
250 WRITE_NODE_FIELD(planTree);
251 WRITE_NODE_FIELD(rtable);
252 WRITE_NODE_FIELD(resultRelations);
253 WRITE_NODE_FIELD(utilityStmt);
254 WRITE_NODE_FIELD(subplans);
255 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
256 WRITE_NODE_FIELD(rowMarks);
257 WRITE_NODE_FIELD(relationOids);
258 WRITE_NODE_FIELD(invalItems);
259 WRITE_INT_FIELD(nParamExec);
263 * print the basic stuff of all nodes that inherit from Plan
266 _outPlanInfo(StringInfo str, const Plan *node)
268 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
269 WRITE_FLOAT_FIELD(total_cost, "%.2f");
270 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
271 WRITE_INT_FIELD(plan_width);
272 WRITE_NODE_FIELD(targetlist);
273 WRITE_NODE_FIELD(qual);
274 WRITE_NODE_FIELD(lefttree);
275 WRITE_NODE_FIELD(righttree);
276 WRITE_NODE_FIELD(initPlan);
277 WRITE_BITMAPSET_FIELD(extParam);
278 WRITE_BITMAPSET_FIELD(allParam);
282 * print the basic stuff of all nodes that inherit from Scan
285 _outScanInfo(StringInfo str, const Scan *node)
287 _outPlanInfo(str, (const Plan *) node);
289 WRITE_UINT_FIELD(scanrelid);
293 * print the basic stuff of all nodes that inherit from Join
296 _outJoinPlanInfo(StringInfo str, const Join *node)
298 _outPlanInfo(str, (const Plan *) node);
300 WRITE_ENUM_FIELD(jointype, JoinType);
301 WRITE_NODE_FIELD(joinqual);
306 _outPlan(StringInfo str, const Plan *node)
308 WRITE_NODE_TYPE("PLAN");
310 _outPlanInfo(str, (const Plan *) node);
314 _outResult(StringInfo str, const Result *node)
316 WRITE_NODE_TYPE("RESULT");
318 _outPlanInfo(str, (const Plan *) node);
320 WRITE_NODE_FIELD(resconstantqual);
324 _outModifyTable(StringInfo str, const ModifyTable *node)
326 WRITE_NODE_TYPE("MODIFYTABLE");
328 _outPlanInfo(str, (const Plan *) node);
330 WRITE_ENUM_FIELD(operation, CmdType);
331 WRITE_BOOL_FIELD(canSetTag);
332 WRITE_NODE_FIELD(resultRelations);
333 WRITE_INT_FIELD(resultRelIndex);
334 WRITE_NODE_FIELD(plans);
335 WRITE_NODE_FIELD(returningLists);
336 WRITE_NODE_FIELD(rowMarks);
337 WRITE_INT_FIELD(epqParam);
341 _outAppend(StringInfo str, const Append *node)
343 WRITE_NODE_TYPE("APPEND");
345 _outPlanInfo(str, (const Plan *) node);
347 WRITE_NODE_FIELD(appendplans);
351 _outMergeAppend(StringInfo str, const MergeAppend *node)
355 WRITE_NODE_TYPE("MERGEAPPEND");
357 _outPlanInfo(str, (const Plan *) node);
359 WRITE_NODE_FIELD(mergeplans);
361 WRITE_INT_FIELD(numCols);
363 appendStringInfo(str, " :sortColIdx");
364 for (i = 0; i < node->numCols; i++)
365 appendStringInfo(str, " %d", node->sortColIdx[i]);
367 appendStringInfo(str, " :sortOperators");
368 for (i = 0; i < node->numCols; i++)
369 appendStringInfo(str, " %u", node->sortOperators[i]);
371 appendStringInfo(str, " :collations");
372 for (i = 0; i < node->numCols; i++)
373 appendStringInfo(str, " %u", node->collations[i]);
375 appendStringInfo(str, " :nullsFirst");
376 for (i = 0; i < node->numCols; i++)
377 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
381 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
385 WRITE_NODE_TYPE("RECURSIVEUNION");
387 _outPlanInfo(str, (const Plan *) node);
389 WRITE_INT_FIELD(wtParam);
390 WRITE_INT_FIELD(numCols);
392 appendStringInfo(str, " :dupColIdx");
393 for (i = 0; i < node->numCols; i++)
394 appendStringInfo(str, " %d", node->dupColIdx[i]);
396 appendStringInfo(str, " :dupOperators");
397 for (i = 0; i < node->numCols; i++)
398 appendStringInfo(str, " %u", node->dupOperators[i]);
400 WRITE_LONG_FIELD(numGroups);
404 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
406 WRITE_NODE_TYPE("BITMAPAND");
408 _outPlanInfo(str, (const Plan *) node);
410 WRITE_NODE_FIELD(bitmapplans);
414 _outBitmapOr(StringInfo str, const BitmapOr *node)
416 WRITE_NODE_TYPE("BITMAPOR");
418 _outPlanInfo(str, (const Plan *) node);
420 WRITE_NODE_FIELD(bitmapplans);
424 _outScan(StringInfo str, const Scan *node)
426 WRITE_NODE_TYPE("SCAN");
428 _outScanInfo(str, node);
432 _outSeqScan(StringInfo str, const SeqScan *node)
434 WRITE_NODE_TYPE("SEQSCAN");
436 _outScanInfo(str, (const Scan *) node);
440 _outIndexScan(StringInfo str, const IndexScan *node)
442 WRITE_NODE_TYPE("INDEXSCAN");
444 _outScanInfo(str, (const Scan *) node);
446 WRITE_OID_FIELD(indexid);
447 WRITE_NODE_FIELD(indexqual);
448 WRITE_NODE_FIELD(indexqualorig);
449 WRITE_NODE_FIELD(indexorderby);
450 WRITE_NODE_FIELD(indexorderbyorig);
451 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
455 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
457 WRITE_NODE_TYPE("INDEXONLYSCAN");
459 _outScanInfo(str, (const Scan *) node);
461 WRITE_OID_FIELD(indexid);
462 WRITE_NODE_FIELD(indexqual);
463 WRITE_NODE_FIELD(indexorderby);
464 WRITE_NODE_FIELD(indextlist);
465 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
469 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
471 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
473 _outScanInfo(str, (const Scan *) node);
475 WRITE_OID_FIELD(indexid);
476 WRITE_NODE_FIELD(indexqual);
477 WRITE_NODE_FIELD(indexqualorig);
481 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
483 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
485 _outScanInfo(str, (const Scan *) node);
487 WRITE_NODE_FIELD(bitmapqualorig);
491 _outTidScan(StringInfo str, const TidScan *node)
493 WRITE_NODE_TYPE("TIDSCAN");
495 _outScanInfo(str, (const Scan *) node);
497 WRITE_NODE_FIELD(tidquals);
501 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
503 WRITE_NODE_TYPE("SUBQUERYSCAN");
505 _outScanInfo(str, (const Scan *) node);
507 WRITE_NODE_FIELD(subplan);
511 _outFunctionScan(StringInfo str, const FunctionScan *node)
513 WRITE_NODE_TYPE("FUNCTIONSCAN");
515 _outScanInfo(str, (const Scan *) node);
517 WRITE_NODE_FIELD(funcexpr);
518 WRITE_NODE_FIELD(funccolnames);
519 WRITE_NODE_FIELD(funccoltypes);
520 WRITE_NODE_FIELD(funccoltypmods);
521 WRITE_NODE_FIELD(funccolcollations);
525 _outValuesScan(StringInfo str, const ValuesScan *node)
527 WRITE_NODE_TYPE("VALUESSCAN");
529 _outScanInfo(str, (const Scan *) node);
531 WRITE_NODE_FIELD(values_lists);
535 _outCteScan(StringInfo str, const CteScan *node)
537 WRITE_NODE_TYPE("CTESCAN");
539 _outScanInfo(str, (const Scan *) node);
541 WRITE_INT_FIELD(ctePlanId);
542 WRITE_INT_FIELD(cteParam);
546 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
548 WRITE_NODE_TYPE("WORKTABLESCAN");
550 _outScanInfo(str, (const Scan *) node);
552 WRITE_INT_FIELD(wtParam);
556 _outForeignScan(StringInfo str, const ForeignScan *node)
558 WRITE_NODE_TYPE("FOREIGNSCAN");
560 _outScanInfo(str, (const Scan *) node);
562 WRITE_NODE_FIELD(fdw_exprs);
563 WRITE_NODE_FIELD(fdw_private);
564 WRITE_BOOL_FIELD(fsSystemCol);
568 _outJoin(StringInfo str, const Join *node)
570 WRITE_NODE_TYPE("JOIN");
572 _outJoinPlanInfo(str, (const Join *) node);
576 _outNestLoop(StringInfo str, const NestLoop *node)
578 WRITE_NODE_TYPE("NESTLOOP");
580 _outJoinPlanInfo(str, (const Join *) node);
582 WRITE_NODE_FIELD(nestParams);
586 _outMergeJoin(StringInfo str, const MergeJoin *node)
591 WRITE_NODE_TYPE("MERGEJOIN");
593 _outJoinPlanInfo(str, (const Join *) node);
595 WRITE_NODE_FIELD(mergeclauses);
597 numCols = list_length(node->mergeclauses);
599 appendStringInfo(str, " :mergeFamilies");
600 for (i = 0; i < numCols; i++)
601 appendStringInfo(str, " %u", node->mergeFamilies[i]);
603 appendStringInfo(str, " :mergeCollations");
604 for (i = 0; i < numCols; i++)
605 appendStringInfo(str, " %u", node->mergeCollations[i]);
607 appendStringInfo(str, " :mergeStrategies");
608 for (i = 0; i < numCols; i++)
609 appendStringInfo(str, " %d", node->mergeStrategies[i]);
611 appendStringInfo(str, " :mergeNullsFirst");
612 for (i = 0; i < numCols; i++)
613 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
617 _outHashJoin(StringInfo str, const HashJoin *node)
619 WRITE_NODE_TYPE("HASHJOIN");
621 _outJoinPlanInfo(str, (const Join *) node);
623 WRITE_NODE_FIELD(hashclauses);
627 _outAgg(StringInfo str, const Agg *node)
631 WRITE_NODE_TYPE("AGG");
633 _outPlanInfo(str, (const Plan *) node);
635 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
636 WRITE_INT_FIELD(numCols);
638 appendStringInfo(str, " :grpColIdx");
639 for (i = 0; i < node->numCols; i++)
640 appendStringInfo(str, " %d", node->grpColIdx[i]);
642 appendStringInfo(str, " :grpOperators");
643 for (i = 0; i < node->numCols; i++)
644 appendStringInfo(str, " %u", node->grpOperators[i]);
646 WRITE_LONG_FIELD(numGroups);
650 _outWindowAgg(StringInfo str, const WindowAgg *node)
654 WRITE_NODE_TYPE("WINDOWAGG");
656 _outPlanInfo(str, (const Plan *) node);
658 WRITE_UINT_FIELD(winref);
659 WRITE_INT_FIELD(partNumCols);
661 appendStringInfo(str, " :partColIdx");
662 for (i = 0; i < node->partNumCols; i++)
663 appendStringInfo(str, " %d", node->partColIdx[i]);
665 appendStringInfo(str, " :partOperations");
666 for (i = 0; i < node->partNumCols; i++)
667 appendStringInfo(str, " %u", node->partOperators[i]);
669 WRITE_INT_FIELD(ordNumCols);
671 appendStringInfo(str, " :ordColIdx");
672 for (i = 0; i < node->ordNumCols; i++)
673 appendStringInfo(str, " %d", node->ordColIdx[i]);
675 appendStringInfo(str, " :ordOperations");
676 for (i = 0; i < node->ordNumCols; i++)
677 appendStringInfo(str, " %u", node->ordOperators[i]);
679 WRITE_INT_FIELD(frameOptions);
680 WRITE_NODE_FIELD(startOffset);
681 WRITE_NODE_FIELD(endOffset);
685 _outGroup(StringInfo str, const Group *node)
689 WRITE_NODE_TYPE("GROUP");
691 _outPlanInfo(str, (const Plan *) node);
693 WRITE_INT_FIELD(numCols);
695 appendStringInfo(str, " :grpColIdx");
696 for (i = 0; i < node->numCols; i++)
697 appendStringInfo(str, " %d", node->grpColIdx[i]);
699 appendStringInfo(str, " :grpOperators");
700 for (i = 0; i < node->numCols; i++)
701 appendStringInfo(str, " %u", node->grpOperators[i]);
705 _outMaterial(StringInfo str, const Material *node)
707 WRITE_NODE_TYPE("MATERIAL");
709 _outPlanInfo(str, (const Plan *) node);
713 _outSort(StringInfo str, const Sort *node)
717 WRITE_NODE_TYPE("SORT");
719 _outPlanInfo(str, (const Plan *) node);
721 WRITE_INT_FIELD(numCols);
723 appendStringInfo(str, " :sortColIdx");
724 for (i = 0; i < node->numCols; i++)
725 appendStringInfo(str, " %d", node->sortColIdx[i]);
727 appendStringInfo(str, " :sortOperators");
728 for (i = 0; i < node->numCols; i++)
729 appendStringInfo(str, " %u", node->sortOperators[i]);
731 appendStringInfo(str, " :collations");
732 for (i = 0; i < node->numCols; i++)
733 appendStringInfo(str, " %u", node->collations[i]);
735 appendStringInfo(str, " :nullsFirst");
736 for (i = 0; i < node->numCols; i++)
737 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
741 _outUnique(StringInfo str, const Unique *node)
745 WRITE_NODE_TYPE("UNIQUE");
747 _outPlanInfo(str, (const Plan *) node);
749 WRITE_INT_FIELD(numCols);
751 appendStringInfo(str, " :uniqColIdx");
752 for (i = 0; i < node->numCols; i++)
753 appendStringInfo(str, " %d", node->uniqColIdx[i]);
755 appendStringInfo(str, " :uniqOperators");
756 for (i = 0; i < node->numCols; i++)
757 appendStringInfo(str, " %u", node->uniqOperators[i]);
761 _outHash(StringInfo str, const Hash *node)
763 WRITE_NODE_TYPE("HASH");
765 _outPlanInfo(str, (const Plan *) node);
767 WRITE_OID_FIELD(skewTable);
768 WRITE_INT_FIELD(skewColumn);
769 WRITE_BOOL_FIELD(skewInherit);
770 WRITE_OID_FIELD(skewColType);
771 WRITE_INT_FIELD(skewColTypmod);
775 _outSetOp(StringInfo str, const SetOp *node)
779 WRITE_NODE_TYPE("SETOP");
781 _outPlanInfo(str, (const Plan *) node);
783 WRITE_ENUM_FIELD(cmd, SetOpCmd);
784 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
785 WRITE_INT_FIELD(numCols);
787 appendStringInfo(str, " :dupColIdx");
788 for (i = 0; i < node->numCols; i++)
789 appendStringInfo(str, " %d", node->dupColIdx[i]);
791 appendStringInfo(str, " :dupOperators");
792 for (i = 0; i < node->numCols; i++)
793 appendStringInfo(str, " %u", node->dupOperators[i]);
795 WRITE_INT_FIELD(flagColIdx);
796 WRITE_INT_FIELD(firstFlag);
797 WRITE_LONG_FIELD(numGroups);
801 _outLockRows(StringInfo str, const LockRows *node)
803 WRITE_NODE_TYPE("LOCKROWS");
805 _outPlanInfo(str, (const Plan *) node);
807 WRITE_NODE_FIELD(rowMarks);
808 WRITE_INT_FIELD(epqParam);
812 _outLimit(StringInfo str, const Limit *node)
814 WRITE_NODE_TYPE("LIMIT");
816 _outPlanInfo(str, (const Plan *) node);
818 WRITE_NODE_FIELD(limitOffset);
819 WRITE_NODE_FIELD(limitCount);
823 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
825 WRITE_NODE_TYPE("NESTLOOPPARAM");
827 WRITE_INT_FIELD(paramno);
828 WRITE_NODE_FIELD(paramval);
832 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
834 WRITE_NODE_TYPE("PLANROWMARK");
836 WRITE_UINT_FIELD(rti);
837 WRITE_UINT_FIELD(prti);
838 WRITE_UINT_FIELD(rowmarkId);
839 WRITE_ENUM_FIELD(markType, RowMarkType);
840 WRITE_BOOL_FIELD(noWait);
841 WRITE_BOOL_FIELD(isParent);
845 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
847 WRITE_NODE_TYPE("PLANINVALITEM");
849 WRITE_INT_FIELD(cacheId);
850 WRITE_UINT_FIELD(hashValue);
853 /*****************************************************************************
855 * Stuff from primnodes.h.
857 *****************************************************************************/
860 _outAlias(StringInfo str, const Alias *node)
862 WRITE_NODE_TYPE("ALIAS");
864 WRITE_STRING_FIELD(aliasname);
865 WRITE_NODE_FIELD(colnames);
869 _outRangeVar(StringInfo str, const RangeVar *node)
871 WRITE_NODE_TYPE("RANGEVAR");
874 * we deliberately ignore catalogname here, since it is presently not
875 * semantically meaningful
877 WRITE_STRING_FIELD(schemaname);
878 WRITE_STRING_FIELD(relname);
879 WRITE_ENUM_FIELD(inhOpt, InhOption);
880 WRITE_CHAR_FIELD(relpersistence);
881 WRITE_NODE_FIELD(alias);
882 WRITE_LOCATION_FIELD(location);
886 _outIntoClause(StringInfo str, const IntoClause *node)
888 WRITE_NODE_TYPE("INTOCLAUSE");
890 WRITE_NODE_FIELD(rel);
891 WRITE_NODE_FIELD(colNames);
892 WRITE_NODE_FIELD(options);
893 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
894 WRITE_STRING_FIELD(tableSpaceName);
895 WRITE_BOOL_FIELD(skipData);
899 _outVar(StringInfo str, const Var *node)
901 WRITE_NODE_TYPE("VAR");
903 WRITE_UINT_FIELD(varno);
904 WRITE_INT_FIELD(varattno);
905 WRITE_OID_FIELD(vartype);
906 WRITE_INT_FIELD(vartypmod);
907 WRITE_OID_FIELD(varcollid);
908 WRITE_UINT_FIELD(varlevelsup);
909 WRITE_UINT_FIELD(varnoold);
910 WRITE_INT_FIELD(varoattno);
911 WRITE_LOCATION_FIELD(location);
915 _outConst(StringInfo str, const Const *node)
917 WRITE_NODE_TYPE("CONST");
919 WRITE_OID_FIELD(consttype);
920 WRITE_INT_FIELD(consttypmod);
921 WRITE_OID_FIELD(constcollid);
922 WRITE_INT_FIELD(constlen);
923 WRITE_BOOL_FIELD(constbyval);
924 WRITE_BOOL_FIELD(constisnull);
925 WRITE_LOCATION_FIELD(location);
927 appendStringInfo(str, " :constvalue ");
928 if (node->constisnull)
929 appendStringInfo(str, "<>");
931 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
935 _outParam(StringInfo str, const Param *node)
937 WRITE_NODE_TYPE("PARAM");
939 WRITE_ENUM_FIELD(paramkind, ParamKind);
940 WRITE_INT_FIELD(paramid);
941 WRITE_OID_FIELD(paramtype);
942 WRITE_INT_FIELD(paramtypmod);
943 WRITE_OID_FIELD(paramcollid);
944 WRITE_LOCATION_FIELD(location);
948 _outAggref(StringInfo str, const Aggref *node)
950 WRITE_NODE_TYPE("AGGREF");
952 WRITE_OID_FIELD(aggfnoid);
953 WRITE_OID_FIELD(aggtype);
954 WRITE_OID_FIELD(aggcollid);
955 WRITE_OID_FIELD(inputcollid);
956 WRITE_NODE_FIELD(args);
957 WRITE_NODE_FIELD(aggorder);
958 WRITE_NODE_FIELD(aggdistinct);
959 WRITE_BOOL_FIELD(aggstar);
960 WRITE_UINT_FIELD(agglevelsup);
961 WRITE_LOCATION_FIELD(location);
965 _outWindowFunc(StringInfo str, const WindowFunc *node)
967 WRITE_NODE_TYPE("WINDOWFUNC");
969 WRITE_OID_FIELD(winfnoid);
970 WRITE_OID_FIELD(wintype);
971 WRITE_OID_FIELD(wincollid);
972 WRITE_OID_FIELD(inputcollid);
973 WRITE_NODE_FIELD(args);
974 WRITE_UINT_FIELD(winref);
975 WRITE_BOOL_FIELD(winstar);
976 WRITE_BOOL_FIELD(winagg);
977 WRITE_LOCATION_FIELD(location);
981 _outArrayRef(StringInfo str, const ArrayRef *node)
983 WRITE_NODE_TYPE("ARRAYREF");
985 WRITE_OID_FIELD(refarraytype);
986 WRITE_OID_FIELD(refelemtype);
987 WRITE_INT_FIELD(reftypmod);
988 WRITE_OID_FIELD(refcollid);
989 WRITE_NODE_FIELD(refupperindexpr);
990 WRITE_NODE_FIELD(reflowerindexpr);
991 WRITE_NODE_FIELD(refexpr);
992 WRITE_NODE_FIELD(refassgnexpr);
996 _outFuncExpr(StringInfo str, const FuncExpr *node)
998 WRITE_NODE_TYPE("FUNCEXPR");
1000 WRITE_OID_FIELD(funcid);
1001 WRITE_OID_FIELD(funcresulttype);
1002 WRITE_BOOL_FIELD(funcretset);
1003 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1004 WRITE_OID_FIELD(funccollid);
1005 WRITE_OID_FIELD(inputcollid);
1006 WRITE_NODE_FIELD(args);
1007 WRITE_LOCATION_FIELD(location);
1011 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1013 WRITE_NODE_TYPE("NAMEDARGEXPR");
1015 WRITE_NODE_FIELD(arg);
1016 WRITE_STRING_FIELD(name);
1017 WRITE_INT_FIELD(argnumber);
1018 WRITE_LOCATION_FIELD(location);
1022 _outOpExpr(StringInfo str, const OpExpr *node)
1024 WRITE_NODE_TYPE("OPEXPR");
1026 WRITE_OID_FIELD(opno);
1027 WRITE_OID_FIELD(opfuncid);
1028 WRITE_OID_FIELD(opresulttype);
1029 WRITE_BOOL_FIELD(opretset);
1030 WRITE_OID_FIELD(opcollid);
1031 WRITE_OID_FIELD(inputcollid);
1032 WRITE_NODE_FIELD(args);
1033 WRITE_LOCATION_FIELD(location);
1037 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1039 WRITE_NODE_TYPE("DISTINCTEXPR");
1041 WRITE_OID_FIELD(opno);
1042 WRITE_OID_FIELD(opfuncid);
1043 WRITE_OID_FIELD(opresulttype);
1044 WRITE_BOOL_FIELD(opretset);
1045 WRITE_OID_FIELD(opcollid);
1046 WRITE_OID_FIELD(inputcollid);
1047 WRITE_NODE_FIELD(args);
1048 WRITE_LOCATION_FIELD(location);
1052 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1054 WRITE_NODE_TYPE("NULLIFEXPR");
1056 WRITE_OID_FIELD(opno);
1057 WRITE_OID_FIELD(opfuncid);
1058 WRITE_OID_FIELD(opresulttype);
1059 WRITE_BOOL_FIELD(opretset);
1060 WRITE_OID_FIELD(opcollid);
1061 WRITE_OID_FIELD(inputcollid);
1062 WRITE_NODE_FIELD(args);
1063 WRITE_LOCATION_FIELD(location);
1067 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1069 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1071 WRITE_OID_FIELD(opno);
1072 WRITE_OID_FIELD(opfuncid);
1073 WRITE_BOOL_FIELD(useOr);
1074 WRITE_OID_FIELD(inputcollid);
1075 WRITE_NODE_FIELD(args);
1076 WRITE_LOCATION_FIELD(location);
1080 _outBoolExpr(StringInfo str, const BoolExpr *node)
1084 WRITE_NODE_TYPE("BOOLEXPR");
1086 /* do-it-yourself enum representation */
1087 switch (node->boolop)
1099 appendStringInfo(str, " :boolop ");
1100 _outToken(str, opstr);
1102 WRITE_NODE_FIELD(args);
1103 WRITE_LOCATION_FIELD(location);
1107 _outSubLink(StringInfo str, const SubLink *node)
1109 WRITE_NODE_TYPE("SUBLINK");
1111 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1112 WRITE_NODE_FIELD(testexpr);
1113 WRITE_NODE_FIELD(operName);
1114 WRITE_NODE_FIELD(subselect);
1115 WRITE_LOCATION_FIELD(location);
1119 _outSubPlan(StringInfo str, const SubPlan *node)
1121 WRITE_NODE_TYPE("SUBPLAN");
1123 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1124 WRITE_NODE_FIELD(testexpr);
1125 WRITE_NODE_FIELD(paramIds);
1126 WRITE_INT_FIELD(plan_id);
1127 WRITE_STRING_FIELD(plan_name);
1128 WRITE_OID_FIELD(firstColType);
1129 WRITE_INT_FIELD(firstColTypmod);
1130 WRITE_OID_FIELD(firstColCollation);
1131 WRITE_BOOL_FIELD(useHashTable);
1132 WRITE_BOOL_FIELD(unknownEqFalse);
1133 WRITE_NODE_FIELD(setParam);
1134 WRITE_NODE_FIELD(parParam);
1135 WRITE_NODE_FIELD(args);
1136 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1137 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1141 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1143 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1145 WRITE_NODE_FIELD(subplans);
1149 _outFieldSelect(StringInfo str, const FieldSelect *node)
1151 WRITE_NODE_TYPE("FIELDSELECT");
1153 WRITE_NODE_FIELD(arg);
1154 WRITE_INT_FIELD(fieldnum);
1155 WRITE_OID_FIELD(resulttype);
1156 WRITE_INT_FIELD(resulttypmod);
1157 WRITE_OID_FIELD(resultcollid);
1161 _outFieldStore(StringInfo str, const FieldStore *node)
1163 WRITE_NODE_TYPE("FIELDSTORE");
1165 WRITE_NODE_FIELD(arg);
1166 WRITE_NODE_FIELD(newvals);
1167 WRITE_NODE_FIELD(fieldnums);
1168 WRITE_OID_FIELD(resulttype);
1172 _outRelabelType(StringInfo str, const RelabelType *node)
1174 WRITE_NODE_TYPE("RELABELTYPE");
1176 WRITE_NODE_FIELD(arg);
1177 WRITE_OID_FIELD(resulttype);
1178 WRITE_INT_FIELD(resulttypmod);
1179 WRITE_OID_FIELD(resultcollid);
1180 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1181 WRITE_LOCATION_FIELD(location);
1185 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1187 WRITE_NODE_TYPE("COERCEVIAIO");
1189 WRITE_NODE_FIELD(arg);
1190 WRITE_OID_FIELD(resulttype);
1191 WRITE_OID_FIELD(resultcollid);
1192 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1193 WRITE_LOCATION_FIELD(location);
1197 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1199 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1201 WRITE_NODE_FIELD(arg);
1202 WRITE_OID_FIELD(elemfuncid);
1203 WRITE_OID_FIELD(resulttype);
1204 WRITE_INT_FIELD(resulttypmod);
1205 WRITE_OID_FIELD(resultcollid);
1206 WRITE_BOOL_FIELD(isExplicit);
1207 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1208 WRITE_LOCATION_FIELD(location);
1212 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1214 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1216 WRITE_NODE_FIELD(arg);
1217 WRITE_OID_FIELD(resulttype);
1218 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1219 WRITE_LOCATION_FIELD(location);
1223 _outCollateExpr(StringInfo str, const CollateExpr *node)
1225 WRITE_NODE_TYPE("COLLATE");
1227 WRITE_NODE_FIELD(arg);
1228 WRITE_OID_FIELD(collOid);
1229 WRITE_LOCATION_FIELD(location);
1233 _outCaseExpr(StringInfo str, const CaseExpr *node)
1235 WRITE_NODE_TYPE("CASE");
1237 WRITE_OID_FIELD(casetype);
1238 WRITE_OID_FIELD(casecollid);
1239 WRITE_NODE_FIELD(arg);
1240 WRITE_NODE_FIELD(args);
1241 WRITE_NODE_FIELD(defresult);
1242 WRITE_LOCATION_FIELD(location);
1246 _outCaseWhen(StringInfo str, const CaseWhen *node)
1248 WRITE_NODE_TYPE("WHEN");
1250 WRITE_NODE_FIELD(expr);
1251 WRITE_NODE_FIELD(result);
1252 WRITE_LOCATION_FIELD(location);
1256 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1258 WRITE_NODE_TYPE("CASETESTEXPR");
1260 WRITE_OID_FIELD(typeId);
1261 WRITE_INT_FIELD(typeMod);
1262 WRITE_OID_FIELD(collation);
1266 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1268 WRITE_NODE_TYPE("ARRAY");
1270 WRITE_OID_FIELD(array_typeid);
1271 WRITE_OID_FIELD(array_collid);
1272 WRITE_OID_FIELD(element_typeid);
1273 WRITE_NODE_FIELD(elements);
1274 WRITE_BOOL_FIELD(multidims);
1275 WRITE_LOCATION_FIELD(location);
1279 _outRowExpr(StringInfo str, const RowExpr *node)
1281 WRITE_NODE_TYPE("ROW");
1283 WRITE_NODE_FIELD(args);
1284 WRITE_OID_FIELD(row_typeid);
1285 WRITE_ENUM_FIELD(row_format, CoercionForm);
1286 WRITE_NODE_FIELD(colnames);
1287 WRITE_LOCATION_FIELD(location);
1291 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1293 WRITE_NODE_TYPE("ROWCOMPARE");
1295 WRITE_ENUM_FIELD(rctype, RowCompareType);
1296 WRITE_NODE_FIELD(opnos);
1297 WRITE_NODE_FIELD(opfamilies);
1298 WRITE_NODE_FIELD(inputcollids);
1299 WRITE_NODE_FIELD(largs);
1300 WRITE_NODE_FIELD(rargs);
1304 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1306 WRITE_NODE_TYPE("COALESCE");
1308 WRITE_OID_FIELD(coalescetype);
1309 WRITE_OID_FIELD(coalescecollid);
1310 WRITE_NODE_FIELD(args);
1311 WRITE_LOCATION_FIELD(location);
1315 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1317 WRITE_NODE_TYPE("MINMAX");
1319 WRITE_OID_FIELD(minmaxtype);
1320 WRITE_OID_FIELD(minmaxcollid);
1321 WRITE_OID_FIELD(inputcollid);
1322 WRITE_ENUM_FIELD(op, MinMaxOp);
1323 WRITE_NODE_FIELD(args);
1324 WRITE_LOCATION_FIELD(location);
1328 _outXmlExpr(StringInfo str, const XmlExpr *node)
1330 WRITE_NODE_TYPE("XMLEXPR");
1332 WRITE_ENUM_FIELD(op, XmlExprOp);
1333 WRITE_STRING_FIELD(name);
1334 WRITE_NODE_FIELD(named_args);
1335 WRITE_NODE_FIELD(arg_names);
1336 WRITE_NODE_FIELD(args);
1337 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1338 WRITE_OID_FIELD(type);
1339 WRITE_INT_FIELD(typmod);
1340 WRITE_LOCATION_FIELD(location);
1344 _outNullTest(StringInfo str, const NullTest *node)
1346 WRITE_NODE_TYPE("NULLTEST");
1348 WRITE_NODE_FIELD(arg);
1349 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1350 WRITE_BOOL_FIELD(argisrow);
1354 _outBooleanTest(StringInfo str, const BooleanTest *node)
1356 WRITE_NODE_TYPE("BOOLEANTEST");
1358 WRITE_NODE_FIELD(arg);
1359 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1363 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1365 WRITE_NODE_TYPE("COERCETODOMAIN");
1367 WRITE_NODE_FIELD(arg);
1368 WRITE_OID_FIELD(resulttype);
1369 WRITE_INT_FIELD(resulttypmod);
1370 WRITE_OID_FIELD(resultcollid);
1371 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1372 WRITE_LOCATION_FIELD(location);
1376 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1378 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1380 WRITE_OID_FIELD(typeId);
1381 WRITE_INT_FIELD(typeMod);
1382 WRITE_OID_FIELD(collation);
1383 WRITE_LOCATION_FIELD(location);
1387 _outSetToDefault(StringInfo str, const SetToDefault *node)
1389 WRITE_NODE_TYPE("SETTODEFAULT");
1391 WRITE_OID_FIELD(typeId);
1392 WRITE_INT_FIELD(typeMod);
1393 WRITE_OID_FIELD(collation);
1394 WRITE_LOCATION_FIELD(location);
1398 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1400 WRITE_NODE_TYPE("CURRENTOFEXPR");
1402 WRITE_UINT_FIELD(cvarno);
1403 WRITE_STRING_FIELD(cursor_name);
1404 WRITE_INT_FIELD(cursor_param);
1408 _outTargetEntry(StringInfo str, const TargetEntry *node)
1410 WRITE_NODE_TYPE("TARGETENTRY");
1412 WRITE_NODE_FIELD(expr);
1413 WRITE_INT_FIELD(resno);
1414 WRITE_STRING_FIELD(resname);
1415 WRITE_UINT_FIELD(ressortgroupref);
1416 WRITE_OID_FIELD(resorigtbl);
1417 WRITE_INT_FIELD(resorigcol);
1418 WRITE_BOOL_FIELD(resjunk);
1422 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1424 WRITE_NODE_TYPE("RANGETBLREF");
1426 WRITE_INT_FIELD(rtindex);
1430 _outJoinExpr(StringInfo str, const JoinExpr *node)
1432 WRITE_NODE_TYPE("JOINEXPR");
1434 WRITE_ENUM_FIELD(jointype, JoinType);
1435 WRITE_BOOL_FIELD(isNatural);
1436 WRITE_NODE_FIELD(larg);
1437 WRITE_NODE_FIELD(rarg);
1438 WRITE_NODE_FIELD(usingClause);
1439 WRITE_NODE_FIELD(quals);
1440 WRITE_NODE_FIELD(alias);
1441 WRITE_INT_FIELD(rtindex);
1445 _outFromExpr(StringInfo str, const FromExpr *node)
1447 WRITE_NODE_TYPE("FROMEXPR");
1449 WRITE_NODE_FIELD(fromlist);
1450 WRITE_NODE_FIELD(quals);
1453 /*****************************************************************************
1455 * Stuff from relation.h.
1457 *****************************************************************************/
1460 * print the basic stuff of all nodes that inherit from Path
1462 * Note we do NOT print the parent, else we'd be in infinite recursion.
1463 * We can print the parent's relids for identification purposes, though.
1464 * We also do not print the whole of param_info, since it's printed by
1465 * _outRelOptInfo; it's sufficient and less cluttering to print just the
1466 * required outer relids.
1469 _outPathInfo(StringInfo str, const Path *node)
1471 WRITE_ENUM_FIELD(pathtype, NodeTag);
1472 appendStringInfo(str, " :parent_relids ");
1473 _outBitmapset(str, node->parent->relids);
1474 appendStringInfo(str, " :required_outer ");
1475 if (node->param_info)
1476 _outBitmapset(str, node->param_info->ppi_req_outer);
1478 _outBitmapset(str, NULL);
1479 WRITE_FLOAT_FIELD(rows, "%.0f");
1480 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1481 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1482 WRITE_NODE_FIELD(pathkeys);
1486 * print the basic stuff of all nodes that inherit from JoinPath
1489 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1491 _outPathInfo(str, (const Path *) node);
1493 WRITE_ENUM_FIELD(jointype, JoinType);
1494 WRITE_NODE_FIELD(outerjoinpath);
1495 WRITE_NODE_FIELD(innerjoinpath);
1496 WRITE_NODE_FIELD(joinrestrictinfo);
1500 _outPath(StringInfo str, const Path *node)
1502 WRITE_NODE_TYPE("PATH");
1504 _outPathInfo(str, (const Path *) node);
1508 _outIndexPath(StringInfo str, const IndexPath *node)
1510 WRITE_NODE_TYPE("INDEXPATH");
1512 _outPathInfo(str, (const Path *) node);
1514 WRITE_NODE_FIELD(indexinfo);
1515 WRITE_NODE_FIELD(indexclauses);
1516 WRITE_NODE_FIELD(indexquals);
1517 WRITE_NODE_FIELD(indexqualcols);
1518 WRITE_NODE_FIELD(indexorderbys);
1519 WRITE_NODE_FIELD(indexorderbycols);
1520 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1521 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1522 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1526 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1528 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1530 _outPathInfo(str, (const Path *) node);
1532 WRITE_NODE_FIELD(bitmapqual);
1536 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1538 WRITE_NODE_TYPE("BITMAPANDPATH");
1540 _outPathInfo(str, (const Path *) node);
1542 WRITE_NODE_FIELD(bitmapquals);
1543 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1547 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1549 WRITE_NODE_TYPE("BITMAPORPATH");
1551 _outPathInfo(str, (const Path *) node);
1553 WRITE_NODE_FIELD(bitmapquals);
1554 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1558 _outTidPath(StringInfo str, const TidPath *node)
1560 WRITE_NODE_TYPE("TIDPATH");
1562 _outPathInfo(str, (const Path *) node);
1564 WRITE_NODE_FIELD(tidquals);
1568 _outForeignPath(StringInfo str, const ForeignPath *node)
1570 WRITE_NODE_TYPE("FOREIGNPATH");
1572 _outPathInfo(str, (const Path *) node);
1574 WRITE_NODE_FIELD(fdw_private);
1578 _outAppendPath(StringInfo str, const AppendPath *node)
1580 WRITE_NODE_TYPE("APPENDPATH");
1582 _outPathInfo(str, (const Path *) node);
1584 WRITE_NODE_FIELD(subpaths);
1588 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1590 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1592 _outPathInfo(str, (const Path *) node);
1594 WRITE_NODE_FIELD(subpaths);
1595 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1599 _outResultPath(StringInfo str, const ResultPath *node)
1601 WRITE_NODE_TYPE("RESULTPATH");
1603 _outPathInfo(str, (const Path *) node);
1605 WRITE_NODE_FIELD(quals);
1609 _outMaterialPath(StringInfo str, const MaterialPath *node)
1611 WRITE_NODE_TYPE("MATERIALPATH");
1613 _outPathInfo(str, (const Path *) node);
1615 WRITE_NODE_FIELD(subpath);
1619 _outUniquePath(StringInfo str, const UniquePath *node)
1621 WRITE_NODE_TYPE("UNIQUEPATH");
1623 _outPathInfo(str, (const Path *) node);
1625 WRITE_NODE_FIELD(subpath);
1626 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1627 WRITE_NODE_FIELD(in_operators);
1628 WRITE_NODE_FIELD(uniq_exprs);
1632 _outNestPath(StringInfo str, const NestPath *node)
1634 WRITE_NODE_TYPE("NESTPATH");
1636 _outJoinPathInfo(str, (const JoinPath *) node);
1640 _outMergePath(StringInfo str, const MergePath *node)
1642 WRITE_NODE_TYPE("MERGEPATH");
1644 _outJoinPathInfo(str, (const JoinPath *) node);
1646 WRITE_NODE_FIELD(path_mergeclauses);
1647 WRITE_NODE_FIELD(outersortkeys);
1648 WRITE_NODE_FIELD(innersortkeys);
1649 WRITE_BOOL_FIELD(materialize_inner);
1653 _outHashPath(StringInfo str, const HashPath *node)
1655 WRITE_NODE_TYPE("HASHPATH");
1657 _outJoinPathInfo(str, (const JoinPath *) node);
1659 WRITE_NODE_FIELD(path_hashclauses);
1660 WRITE_INT_FIELD(num_batches);
1664 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
1666 WRITE_NODE_TYPE("PLANNERGLOBAL");
1668 /* NB: this isn't a complete set of fields */
1669 WRITE_NODE_FIELD(paramlist);
1670 WRITE_NODE_FIELD(subplans);
1671 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1672 WRITE_NODE_FIELD(finalrtable);
1673 WRITE_NODE_FIELD(finalrowmarks);
1674 WRITE_NODE_FIELD(resultRelations);
1675 WRITE_NODE_FIELD(relationOids);
1676 WRITE_NODE_FIELD(invalItems);
1677 WRITE_UINT_FIELD(lastPHId);
1678 WRITE_UINT_FIELD(lastRowMarkId);
1679 WRITE_BOOL_FIELD(transientPlan);
1683 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
1685 WRITE_NODE_TYPE("PLANNERINFO");
1687 /* NB: this isn't a complete set of fields */
1688 WRITE_NODE_FIELD(parse);
1689 WRITE_NODE_FIELD(glob);
1690 WRITE_UINT_FIELD(query_level);
1691 WRITE_BITMAPSET_FIELD(all_baserels);
1692 WRITE_NODE_FIELD(join_rel_list);
1693 WRITE_INT_FIELD(join_cur_level);
1694 WRITE_NODE_FIELD(init_plans);
1695 WRITE_NODE_FIELD(cte_plan_ids);
1696 WRITE_NODE_FIELD(eq_classes);
1697 WRITE_NODE_FIELD(canon_pathkeys);
1698 WRITE_NODE_FIELD(left_join_clauses);
1699 WRITE_NODE_FIELD(right_join_clauses);
1700 WRITE_NODE_FIELD(full_join_clauses);
1701 WRITE_NODE_FIELD(join_info_list);
1702 WRITE_NODE_FIELD(append_rel_list);
1703 WRITE_NODE_FIELD(rowMarks);
1704 WRITE_NODE_FIELD(placeholder_list);
1705 WRITE_NODE_FIELD(query_pathkeys);
1706 WRITE_NODE_FIELD(group_pathkeys);
1707 WRITE_NODE_FIELD(window_pathkeys);
1708 WRITE_NODE_FIELD(distinct_pathkeys);
1709 WRITE_NODE_FIELD(sort_pathkeys);
1710 WRITE_NODE_FIELD(minmax_aggs);
1711 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1712 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1713 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1714 WRITE_BOOL_FIELD(hasInheritedTarget);
1715 WRITE_BOOL_FIELD(hasJoinRTEs);
1716 WRITE_BOOL_FIELD(hasHavingQual);
1717 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1718 WRITE_BOOL_FIELD(hasRecursion);
1719 WRITE_INT_FIELD(wt_param_id);
1720 WRITE_BITMAPSET_FIELD(curOuterRels);
1721 WRITE_NODE_FIELD(curOuterParams);
1725 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
1727 WRITE_NODE_TYPE("RELOPTINFO");
1729 /* NB: this isn't a complete set of fields */
1730 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1731 WRITE_BITMAPSET_FIELD(relids);
1732 WRITE_FLOAT_FIELD(rows, "%.0f");
1733 WRITE_INT_FIELD(width);
1734 WRITE_NODE_FIELD(reltargetlist);
1735 WRITE_NODE_FIELD(pathlist);
1736 WRITE_NODE_FIELD(ppilist);
1737 WRITE_NODE_FIELD(cheapest_startup_path);
1738 WRITE_NODE_FIELD(cheapest_total_path);
1739 WRITE_NODE_FIELD(cheapest_unique_path);
1740 WRITE_NODE_FIELD(cheapest_parameterized_paths);
1741 WRITE_UINT_FIELD(relid);
1742 WRITE_UINT_FIELD(reltablespace);
1743 WRITE_ENUM_FIELD(rtekind, RTEKind);
1744 WRITE_INT_FIELD(min_attr);
1745 WRITE_INT_FIELD(max_attr);
1746 WRITE_NODE_FIELD(indexlist);
1747 WRITE_UINT_FIELD(pages);
1748 WRITE_FLOAT_FIELD(tuples, "%.0f");
1749 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
1750 WRITE_NODE_FIELD(subplan);
1751 WRITE_NODE_FIELD(subroot);
1752 /* we don't try to print fdwroutine or fdw_private */
1753 WRITE_NODE_FIELD(baserestrictinfo);
1754 WRITE_NODE_FIELD(joininfo);
1755 WRITE_BOOL_FIELD(has_eclass_joins);
1759 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
1761 WRITE_NODE_TYPE("INDEXOPTINFO");
1763 /* NB: this isn't a complete set of fields */
1764 WRITE_OID_FIELD(indexoid);
1765 /* Do NOT print rel field, else infinite recursion */
1766 WRITE_UINT_FIELD(pages);
1767 WRITE_FLOAT_FIELD(tuples, "%.0f");
1768 WRITE_INT_FIELD(ncolumns);
1769 WRITE_OID_FIELD(relam);
1770 /* indexprs is redundant since we print indextlist */
1771 WRITE_NODE_FIELD(indpred);
1772 WRITE_NODE_FIELD(indextlist);
1773 WRITE_BOOL_FIELD(predOK);
1774 WRITE_BOOL_FIELD(unique);
1775 WRITE_BOOL_FIELD(immediate);
1776 WRITE_BOOL_FIELD(hypothetical);
1780 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
1783 * To simplify reading, we just chase up to the topmost merged EC and
1784 * print that, without bothering to show the merge-ees separately.
1786 while (node->ec_merged)
1787 node = node->ec_merged;
1789 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1791 WRITE_NODE_FIELD(ec_opfamilies);
1792 WRITE_OID_FIELD(ec_collation);
1793 WRITE_NODE_FIELD(ec_members);
1794 WRITE_NODE_FIELD(ec_sources);
1795 WRITE_NODE_FIELD(ec_derives);
1796 WRITE_BITMAPSET_FIELD(ec_relids);
1797 WRITE_BOOL_FIELD(ec_has_const);
1798 WRITE_BOOL_FIELD(ec_has_volatile);
1799 WRITE_BOOL_FIELD(ec_below_outer_join);
1800 WRITE_BOOL_FIELD(ec_broken);
1801 WRITE_UINT_FIELD(ec_sortref);
1805 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
1807 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1809 WRITE_NODE_FIELD(em_expr);
1810 WRITE_BITMAPSET_FIELD(em_relids);
1811 WRITE_BOOL_FIELD(em_is_const);
1812 WRITE_BOOL_FIELD(em_is_child);
1813 WRITE_OID_FIELD(em_datatype);
1817 _outPathKey(StringInfo str, const PathKey *node)
1819 WRITE_NODE_TYPE("PATHKEY");
1821 WRITE_NODE_FIELD(pk_eclass);
1822 WRITE_OID_FIELD(pk_opfamily);
1823 WRITE_INT_FIELD(pk_strategy);
1824 WRITE_BOOL_FIELD(pk_nulls_first);
1828 _outParamPathInfo(StringInfo str, const ParamPathInfo *node)
1830 WRITE_NODE_TYPE("PARAMPATHINFO");
1832 WRITE_BITMAPSET_FIELD(ppi_req_outer);
1833 WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
1834 WRITE_NODE_FIELD(ppi_clauses);
1838 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
1840 WRITE_NODE_TYPE("RESTRICTINFO");
1842 /* NB: this isn't a complete set of fields */
1843 WRITE_NODE_FIELD(clause);
1844 WRITE_BOOL_FIELD(is_pushed_down);
1845 WRITE_BOOL_FIELD(outerjoin_delayed);
1846 WRITE_BOOL_FIELD(can_join);
1847 WRITE_BOOL_FIELD(pseudoconstant);
1848 WRITE_BITMAPSET_FIELD(clause_relids);
1849 WRITE_BITMAPSET_FIELD(required_relids);
1850 WRITE_BITMAPSET_FIELD(outer_relids);
1851 WRITE_BITMAPSET_FIELD(nullable_relids);
1852 WRITE_BITMAPSET_FIELD(left_relids);
1853 WRITE_BITMAPSET_FIELD(right_relids);
1854 WRITE_NODE_FIELD(orclause);
1855 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1856 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1857 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1858 WRITE_NODE_FIELD(mergeopfamilies);
1859 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1860 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1861 WRITE_NODE_FIELD(left_em);
1862 WRITE_NODE_FIELD(right_em);
1863 WRITE_BOOL_FIELD(outer_is_left);
1864 WRITE_OID_FIELD(hashjoinoperator);
1868 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
1870 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1872 WRITE_NODE_FIELD(phexpr);
1873 WRITE_BITMAPSET_FIELD(phrels);
1874 WRITE_UINT_FIELD(phid);
1875 WRITE_UINT_FIELD(phlevelsup);
1879 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
1881 WRITE_NODE_TYPE("SPECIALJOININFO");
1883 WRITE_BITMAPSET_FIELD(min_lefthand);
1884 WRITE_BITMAPSET_FIELD(min_righthand);
1885 WRITE_BITMAPSET_FIELD(syn_lefthand);
1886 WRITE_BITMAPSET_FIELD(syn_righthand);
1887 WRITE_ENUM_FIELD(jointype, JoinType);
1888 WRITE_BOOL_FIELD(lhs_strict);
1889 WRITE_BOOL_FIELD(delay_upper_joins);
1890 WRITE_NODE_FIELD(join_quals);
1894 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
1896 WRITE_NODE_TYPE("APPENDRELINFO");
1898 WRITE_UINT_FIELD(parent_relid);
1899 WRITE_UINT_FIELD(child_relid);
1900 WRITE_OID_FIELD(parent_reltype);
1901 WRITE_OID_FIELD(child_reltype);
1902 WRITE_NODE_FIELD(translated_vars);
1903 WRITE_OID_FIELD(parent_reloid);
1907 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
1909 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1911 WRITE_UINT_FIELD(phid);
1912 WRITE_NODE_FIELD(ph_var);
1913 WRITE_BITMAPSET_FIELD(ph_eval_at);
1914 WRITE_BITMAPSET_FIELD(ph_needed);
1915 WRITE_BITMAPSET_FIELD(ph_may_need);
1916 WRITE_INT_FIELD(ph_width);
1920 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
1922 WRITE_NODE_TYPE("MINMAXAGGINFO");
1924 WRITE_OID_FIELD(aggfnoid);
1925 WRITE_OID_FIELD(aggsortop);
1926 WRITE_NODE_FIELD(target);
1927 /* We intentionally omit subroot --- too large, not interesting enough */
1928 WRITE_NODE_FIELD(path);
1929 WRITE_FLOAT_FIELD(pathcost, "%.2f");
1930 WRITE_NODE_FIELD(param);
1934 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
1936 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1938 WRITE_NODE_FIELD(item);
1939 WRITE_UINT_FIELD(abslevel);
1942 /*****************************************************************************
1944 * Stuff from parsenodes.h.
1946 *****************************************************************************/
1949 * print the basic stuff of all nodes that inherit from CreateStmt
1952 _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
1954 WRITE_NODE_FIELD(relation);
1955 WRITE_NODE_FIELD(tableElts);
1956 WRITE_NODE_FIELD(inhRelations);
1957 WRITE_NODE_FIELD(ofTypename);
1958 WRITE_NODE_FIELD(constraints);
1959 WRITE_NODE_FIELD(options);
1960 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1961 WRITE_STRING_FIELD(tablespacename);
1962 WRITE_BOOL_FIELD(if_not_exists);
1966 _outCreateStmt(StringInfo str, const CreateStmt *node)
1968 WRITE_NODE_TYPE("CREATESTMT");
1970 _outCreateStmtInfo(str, (const CreateStmt *) node);
1974 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
1976 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
1978 _outCreateStmtInfo(str, (const CreateStmt *) node);
1980 WRITE_STRING_FIELD(servername);
1981 WRITE_NODE_FIELD(options);
1985 _outIndexStmt(StringInfo str, const IndexStmt *node)
1987 WRITE_NODE_TYPE("INDEXSTMT");
1989 WRITE_STRING_FIELD(idxname);
1990 WRITE_NODE_FIELD(relation);
1991 WRITE_STRING_FIELD(accessMethod);
1992 WRITE_STRING_FIELD(tableSpace);
1993 WRITE_NODE_FIELD(indexParams);
1994 WRITE_NODE_FIELD(options);
1995 WRITE_NODE_FIELD(whereClause);
1996 WRITE_NODE_FIELD(excludeOpNames);
1997 WRITE_OID_FIELD(indexOid);
1998 WRITE_OID_FIELD(oldNode);
1999 WRITE_BOOL_FIELD(unique);
2000 WRITE_BOOL_FIELD(primary);
2001 WRITE_BOOL_FIELD(isconstraint);
2002 WRITE_BOOL_FIELD(deferrable);
2003 WRITE_BOOL_FIELD(initdeferred);
2004 WRITE_BOOL_FIELD(concurrent);
2008 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
2010 WRITE_NODE_TYPE("NOTIFY");
2012 WRITE_STRING_FIELD(conditionname);
2013 WRITE_STRING_FIELD(payload);
2017 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2019 WRITE_NODE_TYPE("DECLARECURSOR");
2021 WRITE_STRING_FIELD(portalname);
2022 WRITE_INT_FIELD(options);
2023 WRITE_NODE_FIELD(query);
2027 _outSelectStmt(StringInfo str, const SelectStmt *node)
2029 WRITE_NODE_TYPE("SELECT");
2031 WRITE_NODE_FIELD(distinctClause);
2032 WRITE_NODE_FIELD(intoClause);
2033 WRITE_NODE_FIELD(targetList);
2034 WRITE_NODE_FIELD(fromClause);
2035 WRITE_NODE_FIELD(whereClause);
2036 WRITE_NODE_FIELD(groupClause);
2037 WRITE_NODE_FIELD(havingClause);
2038 WRITE_NODE_FIELD(windowClause);
2039 WRITE_NODE_FIELD(withClause);
2040 WRITE_NODE_FIELD(valuesLists);
2041 WRITE_NODE_FIELD(sortClause);
2042 WRITE_NODE_FIELD(limitOffset);
2043 WRITE_NODE_FIELD(limitCount);
2044 WRITE_NODE_FIELD(lockingClause);
2045 WRITE_ENUM_FIELD(op, SetOperation);
2046 WRITE_BOOL_FIELD(all);
2047 WRITE_NODE_FIELD(larg);
2048 WRITE_NODE_FIELD(rarg);
2052 _outFuncCall(StringInfo str, const FuncCall *node)
2054 WRITE_NODE_TYPE("FUNCCALL");
2056 WRITE_NODE_FIELD(funcname);
2057 WRITE_NODE_FIELD(args);
2058 WRITE_NODE_FIELD(agg_order);
2059 WRITE_BOOL_FIELD(agg_star);
2060 WRITE_BOOL_FIELD(agg_distinct);
2061 WRITE_BOOL_FIELD(func_variadic);
2062 WRITE_NODE_FIELD(over);
2063 WRITE_LOCATION_FIELD(location);
2067 _outDefElem(StringInfo str, const DefElem *node)
2069 WRITE_NODE_TYPE("DEFELEM");
2071 WRITE_STRING_FIELD(defnamespace);
2072 WRITE_STRING_FIELD(defname);
2073 WRITE_NODE_FIELD(arg);
2074 WRITE_ENUM_FIELD(defaction, DefElemAction);
2078 _outTableLikeClause(StringInfo str, const TableLikeClause *node)
2080 WRITE_NODE_TYPE("TABLELIKECLAUSE");
2082 WRITE_NODE_FIELD(relation);
2083 WRITE_UINT_FIELD(options);
2087 _outLockingClause(StringInfo str, const LockingClause *node)
2089 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2091 WRITE_NODE_FIELD(lockedRels);
2092 WRITE_BOOL_FIELD(forUpdate);
2093 WRITE_BOOL_FIELD(noWait);
2097 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2099 WRITE_NODE_TYPE("XMLSERIALIZE");
2101 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2102 WRITE_NODE_FIELD(expr);
2103 WRITE_NODE_FIELD(typeName);
2104 WRITE_LOCATION_FIELD(location);
2108 _outColumnDef(StringInfo str, const ColumnDef *node)
2110 WRITE_NODE_TYPE("COLUMNDEF");
2112 WRITE_STRING_FIELD(colname);
2113 WRITE_NODE_FIELD(typeName);
2114 WRITE_INT_FIELD(inhcount);
2115 WRITE_BOOL_FIELD(is_local);
2116 WRITE_BOOL_FIELD(is_not_null);
2117 WRITE_BOOL_FIELD(is_from_type);
2118 WRITE_CHAR_FIELD(storage);
2119 WRITE_NODE_FIELD(raw_default);
2120 WRITE_NODE_FIELD(cooked_default);
2121 WRITE_NODE_FIELD(collClause);
2122 WRITE_OID_FIELD(collOid);
2123 WRITE_NODE_FIELD(constraints);
2124 WRITE_NODE_FIELD(fdwoptions);
2128 _outTypeName(StringInfo str, const TypeName *node)
2130 WRITE_NODE_TYPE("TYPENAME");
2132 WRITE_NODE_FIELD(names);
2133 WRITE_OID_FIELD(typeOid);
2134 WRITE_BOOL_FIELD(setof);
2135 WRITE_BOOL_FIELD(pct_type);
2136 WRITE_NODE_FIELD(typmods);
2137 WRITE_INT_FIELD(typemod);
2138 WRITE_NODE_FIELD(arrayBounds);
2139 WRITE_LOCATION_FIELD(location);
2143 _outTypeCast(StringInfo str, const TypeCast *node)
2145 WRITE_NODE_TYPE("TYPECAST");
2147 WRITE_NODE_FIELD(arg);
2148 WRITE_NODE_FIELD(typeName);
2149 WRITE_LOCATION_FIELD(location);
2153 _outCollateClause(StringInfo str, const CollateClause *node)
2155 WRITE_NODE_TYPE("COLLATECLAUSE");
2157 WRITE_NODE_FIELD(arg);
2158 WRITE_NODE_FIELD(collname);
2159 WRITE_LOCATION_FIELD(location);
2163 _outIndexElem(StringInfo str, const IndexElem *node)
2165 WRITE_NODE_TYPE("INDEXELEM");
2167 WRITE_STRING_FIELD(name);
2168 WRITE_NODE_FIELD(expr);
2169 WRITE_STRING_FIELD(indexcolname);
2170 WRITE_NODE_FIELD(collation);
2171 WRITE_NODE_FIELD(opclass);
2172 WRITE_ENUM_FIELD(ordering, SortByDir);
2173 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2177 _outQuery(StringInfo str, const Query *node)
2179 WRITE_NODE_TYPE("QUERY");
2181 WRITE_ENUM_FIELD(commandType, CmdType);
2182 WRITE_ENUM_FIELD(querySource, QuerySource);
2183 /* we intentionally do not print the queryId field */
2184 WRITE_BOOL_FIELD(canSetTag);
2187 * Hack to work around missing outfuncs routines for a lot of the
2188 * utility-statement node types. (The only one we actually *need* for
2189 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2190 * for the meantime do this to avoid getting lots of warnings when running
2191 * with debug_print_parse on.
2193 if (node->utilityStmt)
2195 switch (nodeTag(node->utilityStmt))
2200 case T_DeclareCursorStmt:
2201 WRITE_NODE_FIELD(utilityStmt);
2204 appendStringInfo(str, " :utilityStmt ?");
2209 appendStringInfo(str, " :utilityStmt <>");
2211 WRITE_INT_FIELD(resultRelation);
2212 WRITE_BOOL_FIELD(hasAggs);
2213 WRITE_BOOL_FIELD(hasWindowFuncs);
2214 WRITE_BOOL_FIELD(hasSubLinks);
2215 WRITE_BOOL_FIELD(hasDistinctOn);
2216 WRITE_BOOL_FIELD(hasRecursive);
2217 WRITE_BOOL_FIELD(hasModifyingCTE);
2218 WRITE_BOOL_FIELD(hasForUpdate);
2219 WRITE_NODE_FIELD(cteList);
2220 WRITE_NODE_FIELD(rtable);
2221 WRITE_NODE_FIELD(jointree);
2222 WRITE_NODE_FIELD(targetList);
2223 WRITE_NODE_FIELD(returningList);
2224 WRITE_NODE_FIELD(groupClause);
2225 WRITE_NODE_FIELD(havingQual);
2226 WRITE_NODE_FIELD(windowClause);
2227 WRITE_NODE_FIELD(distinctClause);
2228 WRITE_NODE_FIELD(sortClause);
2229 WRITE_NODE_FIELD(limitOffset);
2230 WRITE_NODE_FIELD(limitCount);
2231 WRITE_NODE_FIELD(rowMarks);
2232 WRITE_NODE_FIELD(setOperations);
2233 WRITE_NODE_FIELD(constraintDeps);
2237 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2239 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2241 WRITE_UINT_FIELD(tleSortGroupRef);
2242 WRITE_OID_FIELD(eqop);
2243 WRITE_OID_FIELD(sortop);
2244 WRITE_BOOL_FIELD(nulls_first);
2245 WRITE_BOOL_FIELD(hashable);
2249 _outWindowClause(StringInfo str, const WindowClause *node)
2251 WRITE_NODE_TYPE("WINDOWCLAUSE");
2253 WRITE_STRING_FIELD(name);
2254 WRITE_STRING_FIELD(refname);
2255 WRITE_NODE_FIELD(partitionClause);
2256 WRITE_NODE_FIELD(orderClause);
2257 WRITE_INT_FIELD(frameOptions);
2258 WRITE_NODE_FIELD(startOffset);
2259 WRITE_NODE_FIELD(endOffset);
2260 WRITE_UINT_FIELD(winref);
2261 WRITE_BOOL_FIELD(copiedOrder);
2265 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
2267 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2269 WRITE_UINT_FIELD(rti);
2270 WRITE_BOOL_FIELD(forUpdate);
2271 WRITE_BOOL_FIELD(noWait);
2272 WRITE_BOOL_FIELD(pushedDown);
2276 _outWithClause(StringInfo str, const WithClause *node)
2278 WRITE_NODE_TYPE("WITHCLAUSE");
2280 WRITE_NODE_FIELD(ctes);
2281 WRITE_BOOL_FIELD(recursive);
2282 WRITE_LOCATION_FIELD(location);
2286 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
2288 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2290 WRITE_STRING_FIELD(ctename);
2291 WRITE_NODE_FIELD(aliascolnames);
2292 WRITE_NODE_FIELD(ctequery);
2293 WRITE_LOCATION_FIELD(location);
2294 WRITE_BOOL_FIELD(cterecursive);
2295 WRITE_INT_FIELD(cterefcount);
2296 WRITE_NODE_FIELD(ctecolnames);
2297 WRITE_NODE_FIELD(ctecoltypes);
2298 WRITE_NODE_FIELD(ctecoltypmods);
2299 WRITE_NODE_FIELD(ctecolcollations);
2303 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
2305 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2307 WRITE_ENUM_FIELD(op, SetOperation);
2308 WRITE_BOOL_FIELD(all);
2309 WRITE_NODE_FIELD(larg);
2310 WRITE_NODE_FIELD(rarg);
2311 WRITE_NODE_FIELD(colTypes);
2312 WRITE_NODE_FIELD(colTypmods);
2313 WRITE_NODE_FIELD(colCollations);
2314 WRITE_NODE_FIELD(groupClauses);
2318 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
2320 WRITE_NODE_TYPE("RTE");
2322 /* put alias + eref first to make dump more legible */
2323 WRITE_NODE_FIELD(alias);
2324 WRITE_NODE_FIELD(eref);
2325 WRITE_ENUM_FIELD(rtekind, RTEKind);
2327 switch (node->rtekind)
2330 WRITE_OID_FIELD(relid);
2331 WRITE_CHAR_FIELD(relkind);
2334 WRITE_NODE_FIELD(subquery);
2335 WRITE_BOOL_FIELD(security_barrier);
2338 WRITE_ENUM_FIELD(jointype, JoinType);
2339 WRITE_NODE_FIELD(joinaliasvars);
2342 WRITE_NODE_FIELD(funcexpr);
2343 WRITE_NODE_FIELD(funccoltypes);
2344 WRITE_NODE_FIELD(funccoltypmods);
2345 WRITE_NODE_FIELD(funccolcollations);
2348 WRITE_NODE_FIELD(values_lists);
2349 WRITE_NODE_FIELD(values_collations);
2352 WRITE_STRING_FIELD(ctename);
2353 WRITE_UINT_FIELD(ctelevelsup);
2354 WRITE_BOOL_FIELD(self_reference);
2355 WRITE_NODE_FIELD(ctecoltypes);
2356 WRITE_NODE_FIELD(ctecoltypmods);
2357 WRITE_NODE_FIELD(ctecolcollations);
2360 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2364 WRITE_BOOL_FIELD(inh);
2365 WRITE_BOOL_FIELD(inFromCl);
2366 WRITE_UINT_FIELD(requiredPerms);
2367 WRITE_OID_FIELD(checkAsUser);
2368 WRITE_BITMAPSET_FIELD(selectedCols);
2369 WRITE_BITMAPSET_FIELD(modifiedCols);
2373 _outAExpr(StringInfo str, const A_Expr *node)
2375 WRITE_NODE_TYPE("AEXPR");
2380 appendStringInfo(str, " ");
2381 WRITE_NODE_FIELD(name);
2384 appendStringInfo(str, " AND");
2387 appendStringInfo(str, " OR");
2390 appendStringInfo(str, " NOT");
2393 appendStringInfo(str, " ");
2394 WRITE_NODE_FIELD(name);
2395 appendStringInfo(str, " ANY ");
2398 appendStringInfo(str, " ");
2399 WRITE_NODE_FIELD(name);
2400 appendStringInfo(str, " ALL ");
2402 case AEXPR_DISTINCT:
2403 appendStringInfo(str, " DISTINCT ");
2404 WRITE_NODE_FIELD(name);
2407 appendStringInfo(str, " NULLIF ");
2408 WRITE_NODE_FIELD(name);
2411 appendStringInfo(str, " OF ");
2412 WRITE_NODE_FIELD(name);
2415 appendStringInfo(str, " IN ");
2416 WRITE_NODE_FIELD(name);
2419 appendStringInfo(str, " ??");
2423 WRITE_NODE_FIELD(lexpr);
2424 WRITE_NODE_FIELD(rexpr);
2425 WRITE_LOCATION_FIELD(location);
2429 _outValue(StringInfo str, const Value *value)
2431 switch (value->type)
2434 appendStringInfo(str, "%ld", value->val.ival);
2439 * We assume the value is a valid numeric literal and so does not
2442 appendStringInfoString(str, value->val.str);
2445 appendStringInfoChar(str, '"');
2446 _outToken(str, value->val.str);
2447 appendStringInfoChar(str, '"');
2450 /* internal representation already has leading 'b' */
2451 appendStringInfoString(str, value->val.str);
2454 /* this is seen only within A_Const, not in transformed trees */
2455 appendStringInfoString(str, "NULL");
2458 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2464 _outColumnRef(StringInfo str, const ColumnRef *node)
2466 WRITE_NODE_TYPE("COLUMNREF");
2468 WRITE_NODE_FIELD(fields);
2469 WRITE_LOCATION_FIELD(location);
2473 _outParamRef(StringInfo str, const ParamRef *node)
2475 WRITE_NODE_TYPE("PARAMREF");
2477 WRITE_INT_FIELD(number);
2478 WRITE_LOCATION_FIELD(location);
2482 _outAConst(StringInfo str, const A_Const *node)
2484 WRITE_NODE_TYPE("A_CONST");
2486 appendStringInfo(str, " :val ");
2487 _outValue(str, &(node->val));
2488 WRITE_LOCATION_FIELD(location);
2492 _outA_Star(StringInfo str, const A_Star *node)
2494 WRITE_NODE_TYPE("A_STAR");
2498 _outA_Indices(StringInfo str, const A_Indices *node)
2500 WRITE_NODE_TYPE("A_INDICES");
2502 WRITE_NODE_FIELD(lidx);
2503 WRITE_NODE_FIELD(uidx);
2507 _outA_Indirection(StringInfo str, const A_Indirection *node)
2509 WRITE_NODE_TYPE("A_INDIRECTION");
2511 WRITE_NODE_FIELD(arg);
2512 WRITE_NODE_FIELD(indirection);
2516 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
2518 WRITE_NODE_TYPE("A_ARRAYEXPR");
2520 WRITE_NODE_FIELD(elements);
2521 WRITE_LOCATION_FIELD(location);
2525 _outResTarget(StringInfo str, const ResTarget *node)
2527 WRITE_NODE_TYPE("RESTARGET");
2529 WRITE_STRING_FIELD(name);
2530 WRITE_NODE_FIELD(indirection);
2531 WRITE_NODE_FIELD(val);
2532 WRITE_LOCATION_FIELD(location);
2536 _outSortBy(StringInfo str, const SortBy *node)
2538 WRITE_NODE_TYPE("SORTBY");
2540 WRITE_NODE_FIELD(node);
2541 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2542 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2543 WRITE_NODE_FIELD(useOp);
2544 WRITE_LOCATION_FIELD(location);
2548 _outWindowDef(StringInfo str, const WindowDef *node)
2550 WRITE_NODE_TYPE("WINDOWDEF");
2552 WRITE_STRING_FIELD(name);
2553 WRITE_STRING_FIELD(refname);
2554 WRITE_NODE_FIELD(partitionClause);
2555 WRITE_NODE_FIELD(orderClause);
2556 WRITE_INT_FIELD(frameOptions);
2557 WRITE_NODE_FIELD(startOffset);
2558 WRITE_NODE_FIELD(endOffset);
2559 WRITE_LOCATION_FIELD(location);
2563 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
2565 WRITE_NODE_TYPE("RANGESUBSELECT");
2567 WRITE_NODE_FIELD(subquery);
2568 WRITE_NODE_FIELD(alias);
2572 _outRangeFunction(StringInfo str, const RangeFunction *node)
2574 WRITE_NODE_TYPE("RANGEFUNCTION");
2576 WRITE_NODE_FIELD(funccallnode);
2577 WRITE_NODE_FIELD(alias);
2578 WRITE_NODE_FIELD(coldeflist);
2582 _outConstraint(StringInfo str, const Constraint *node)
2584 WRITE_NODE_TYPE("CONSTRAINT");
2586 WRITE_STRING_FIELD(conname);
2587 WRITE_BOOL_FIELD(deferrable);
2588 WRITE_BOOL_FIELD(initdeferred);
2589 WRITE_LOCATION_FIELD(location);
2591 appendStringInfo(str, " :contype ");
2592 switch (node->contype)
2595 appendStringInfo(str, "NULL");
2598 case CONSTR_NOTNULL:
2599 appendStringInfo(str, "NOT_NULL");
2602 case CONSTR_DEFAULT:
2603 appendStringInfo(str, "DEFAULT");
2604 WRITE_NODE_FIELD(raw_expr);
2605 WRITE_STRING_FIELD(cooked_expr);
2609 appendStringInfo(str, "CHECK");
2610 WRITE_BOOL_FIELD(is_no_inherit);
2611 WRITE_NODE_FIELD(raw_expr);
2612 WRITE_STRING_FIELD(cooked_expr);
2615 case CONSTR_PRIMARY:
2616 appendStringInfo(str, "PRIMARY_KEY");
2617 WRITE_NODE_FIELD(keys);
2618 WRITE_NODE_FIELD(options);
2619 WRITE_STRING_FIELD(indexname);
2620 WRITE_STRING_FIELD(indexspace);
2621 /* access_method and where_clause not currently used */
2625 appendStringInfo(str, "UNIQUE");
2626 WRITE_NODE_FIELD(keys);
2627 WRITE_NODE_FIELD(options);
2628 WRITE_STRING_FIELD(indexname);
2629 WRITE_STRING_FIELD(indexspace);
2630 /* access_method and where_clause not currently used */
2633 case CONSTR_EXCLUSION:
2634 appendStringInfo(str, "EXCLUSION");
2635 WRITE_NODE_FIELD(exclusions);
2636 WRITE_NODE_FIELD(options);
2637 WRITE_STRING_FIELD(indexname);
2638 WRITE_STRING_FIELD(indexspace);
2639 WRITE_STRING_FIELD(access_method);
2640 WRITE_NODE_FIELD(where_clause);
2643 case CONSTR_FOREIGN:
2644 appendStringInfo(str, "FOREIGN_KEY");
2645 WRITE_NODE_FIELD(pktable);
2646 WRITE_NODE_FIELD(fk_attrs);
2647 WRITE_NODE_FIELD(pk_attrs);
2648 WRITE_CHAR_FIELD(fk_matchtype);
2649 WRITE_CHAR_FIELD(fk_upd_action);
2650 WRITE_CHAR_FIELD(fk_del_action);
2651 WRITE_NODE_FIELD(old_conpfeqop);
2652 WRITE_BOOL_FIELD(skip_validation);
2653 WRITE_BOOL_FIELD(initially_valid);
2656 case CONSTR_ATTR_DEFERRABLE:
2657 appendStringInfo(str, "ATTR_DEFERRABLE");
2660 case CONSTR_ATTR_NOT_DEFERRABLE:
2661 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2664 case CONSTR_ATTR_DEFERRED:
2665 appendStringInfo(str, "ATTR_DEFERRED");
2668 case CONSTR_ATTR_IMMEDIATE:
2669 appendStringInfo(str, "ATTR_IMMEDIATE");
2673 appendStringInfo(str, "<unrecognized_constraint %d>",
2674 (int) node->contype);
2682 * converts a Node into ascii string and append it to 'str'
2685 _outNode(StringInfo str, const void *obj)
2688 appendStringInfo(str, "<>");
2689 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2691 else if (IsA(obj, Integer) ||
2694 IsA(obj, BitString))
2696 /* nodeRead does not want to see { } around these! */
2697 _outValue(str, obj);
2701 appendStringInfoChar(str, '{');
2702 switch (nodeTag(obj))
2705 _outPlannedStmt(str, obj);
2711 _outResult(str, obj);
2714 _outModifyTable(str, obj);
2717 _outAppend(str, obj);
2720 _outMergeAppend(str, obj);
2722 case T_RecursiveUnion:
2723 _outRecursiveUnion(str, obj);
2726 _outBitmapAnd(str, obj);
2729 _outBitmapOr(str, obj);
2735 _outSeqScan(str, obj);
2738 _outIndexScan(str, obj);
2740 case T_IndexOnlyScan:
2741 _outIndexOnlyScan(str, obj);
2743 case T_BitmapIndexScan:
2744 _outBitmapIndexScan(str, obj);
2746 case T_BitmapHeapScan:
2747 _outBitmapHeapScan(str, obj);
2750 _outTidScan(str, obj);
2752 case T_SubqueryScan:
2753 _outSubqueryScan(str, obj);
2755 case T_FunctionScan:
2756 _outFunctionScan(str, obj);
2759 _outValuesScan(str, obj);
2762 _outCteScan(str, obj);
2764 case T_WorkTableScan:
2765 _outWorkTableScan(str, obj);
2768 _outForeignScan(str, obj);
2774 _outNestLoop(str, obj);
2777 _outMergeJoin(str, obj);
2780 _outHashJoin(str, obj);
2786 _outWindowAgg(str, obj);
2789 _outGroup(str, obj);
2792 _outMaterial(str, obj);
2798 _outUnique(str, obj);
2804 _outSetOp(str, obj);
2807 _outLockRows(str, obj);
2810 _outLimit(str, obj);
2812 case T_NestLoopParam:
2813 _outNestLoopParam(str, obj);
2816 _outPlanRowMark(str, obj);
2818 case T_PlanInvalItem:
2819 _outPlanInvalItem(str, obj);
2822 _outAlias(str, obj);
2825 _outRangeVar(str, obj);
2828 _outIntoClause(str, obj);
2834 _outConst(str, obj);
2837 _outParam(str, obj);
2840 _outAggref(str, obj);
2843 _outWindowFunc(str, obj);
2846 _outArrayRef(str, obj);
2849 _outFuncExpr(str, obj);
2851 case T_NamedArgExpr:
2852 _outNamedArgExpr(str, obj);
2855 _outOpExpr(str, obj);
2857 case T_DistinctExpr:
2858 _outDistinctExpr(str, obj);
2861 _outNullIfExpr(str, obj);
2863 case T_ScalarArrayOpExpr:
2864 _outScalarArrayOpExpr(str, obj);
2867 _outBoolExpr(str, obj);
2870 _outSubLink(str, obj);
2873 _outSubPlan(str, obj);
2875 case T_AlternativeSubPlan:
2876 _outAlternativeSubPlan(str, obj);
2879 _outFieldSelect(str, obj);
2882 _outFieldStore(str, obj);
2885 _outRelabelType(str, obj);
2888 _outCoerceViaIO(str, obj);
2890 case T_ArrayCoerceExpr:
2891 _outArrayCoerceExpr(str, obj);
2893 case T_ConvertRowtypeExpr:
2894 _outConvertRowtypeExpr(str, obj);
2897 _outCollateExpr(str, obj);
2900 _outCaseExpr(str, obj);
2903 _outCaseWhen(str, obj);
2905 case T_CaseTestExpr:
2906 _outCaseTestExpr(str, obj);
2909 _outArrayExpr(str, obj);
2912 _outRowExpr(str, obj);
2914 case T_RowCompareExpr:
2915 _outRowCompareExpr(str, obj);
2917 case T_CoalesceExpr:
2918 _outCoalesceExpr(str, obj);
2921 _outMinMaxExpr(str, obj);
2924 _outXmlExpr(str, obj);
2927 _outNullTest(str, obj);
2930 _outBooleanTest(str, obj);
2932 case T_CoerceToDomain:
2933 _outCoerceToDomain(str, obj);
2935 case T_CoerceToDomainValue:
2936 _outCoerceToDomainValue(str, obj);
2938 case T_SetToDefault:
2939 _outSetToDefault(str, obj);
2941 case T_CurrentOfExpr:
2942 _outCurrentOfExpr(str, obj);
2945 _outTargetEntry(str, obj);
2948 _outRangeTblRef(str, obj);
2951 _outJoinExpr(str, obj);
2954 _outFromExpr(str, obj);
2961 _outIndexPath(str, obj);
2963 case T_BitmapHeapPath:
2964 _outBitmapHeapPath(str, obj);
2966 case T_BitmapAndPath:
2967 _outBitmapAndPath(str, obj);
2969 case T_BitmapOrPath:
2970 _outBitmapOrPath(str, obj);
2973 _outTidPath(str, obj);
2976 _outForeignPath(str, obj);
2979 _outAppendPath(str, obj);
2981 case T_MergeAppendPath:
2982 _outMergeAppendPath(str, obj);
2985 _outResultPath(str, obj);
2987 case T_MaterialPath:
2988 _outMaterialPath(str, obj);
2991 _outUniquePath(str, obj);
2994 _outNestPath(str, obj);
2997 _outMergePath(str, obj);
3000 _outHashPath(str, obj);
3002 case T_PlannerGlobal:
3003 _outPlannerGlobal(str, obj);
3006 _outPlannerInfo(str, obj);
3009 _outRelOptInfo(str, obj);
3011 case T_IndexOptInfo:
3012 _outIndexOptInfo(str, obj);
3014 case T_EquivalenceClass:
3015 _outEquivalenceClass(str, obj);
3017 case T_EquivalenceMember:
3018 _outEquivalenceMember(str, obj);
3021 _outPathKey(str, obj);
3023 case T_ParamPathInfo:
3024 _outParamPathInfo(str, obj);
3026 case T_RestrictInfo:
3027 _outRestrictInfo(str, obj);
3029 case T_PlaceHolderVar:
3030 _outPlaceHolderVar(str, obj);
3032 case T_SpecialJoinInfo:
3033 _outSpecialJoinInfo(str, obj);
3035 case T_AppendRelInfo:
3036 _outAppendRelInfo(str, obj);
3038 case T_PlaceHolderInfo:
3039 _outPlaceHolderInfo(str, obj);
3041 case T_MinMaxAggInfo:
3042 _outMinMaxAggInfo(str, obj);
3044 case T_PlannerParamItem:
3045 _outPlannerParamItem(str, obj);
3049 _outCreateStmt(str, obj);
3051 case T_CreateForeignTableStmt:
3052 _outCreateForeignTableStmt(str, obj);
3055 _outIndexStmt(str, obj);
3058 _outNotifyStmt(str, obj);
3060 case T_DeclareCursorStmt:
3061 _outDeclareCursorStmt(str, obj);
3064 _outSelectStmt(str, obj);
3067 _outColumnDef(str, obj);
3070 _outTypeName(str, obj);
3073 _outTypeCast(str, obj);
3075 case T_CollateClause:
3076 _outCollateClause(str, obj);
3079 _outIndexElem(str, obj);
3082 _outQuery(str, obj);
3084 case T_SortGroupClause:
3085 _outSortGroupClause(str, obj);
3087 case T_WindowClause:
3088 _outWindowClause(str, obj);
3090 case T_RowMarkClause:
3091 _outRowMarkClause(str, obj);
3094 _outWithClause(str, obj);
3096 case T_CommonTableExpr:
3097 _outCommonTableExpr(str, obj);
3099 case T_SetOperationStmt:
3100 _outSetOperationStmt(str, obj);
3102 case T_RangeTblEntry:
3103 _outRangeTblEntry(str, obj);
3106 _outAExpr(str, obj);
3109 _outColumnRef(str, obj);
3112 _outParamRef(str, obj);
3115 _outAConst(str, obj);
3118 _outA_Star(str, obj);
3121 _outA_Indices(str, obj);
3123 case T_A_Indirection:
3124 _outA_Indirection(str, obj);
3127 _outA_ArrayExpr(str, obj);
3130 _outResTarget(str, obj);
3133 _outSortBy(str, obj);
3136 _outWindowDef(str, obj);
3138 case T_RangeSubselect:
3139 _outRangeSubselect(str, obj);
3141 case T_RangeFunction:
3142 _outRangeFunction(str, obj);
3145 _outConstraint(str, obj);
3148 _outFuncCall(str, obj);
3151 _outDefElem(str, obj);
3153 case T_TableLikeClause:
3154 _outTableLikeClause(str, obj);
3156 case T_LockingClause:
3157 _outLockingClause(str, obj);
3159 case T_XmlSerialize:
3160 _outXmlSerialize(str, obj);
3166 * This should be an ERROR, but it's too useful to be able to
3167 * dump structures that _outNode only understands part of.
3169 elog(WARNING, "could not dump unrecognized node type: %d",
3170 (int) nodeTag(obj));
3173 appendStringInfoChar(str, '}');
3179 * returns the ascii representation of the Node as a palloc'd string
3182 nodeToString(const void *obj)
3186 /* see stringinfo.h for an explanation of this maneuver */
3187 initStringInfo(&str);
3188 _outNode(&str, obj);