1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2015, 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 appendStringInfoString(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)
189 appendStringInfoChar(str, '(');
190 appendStringInfoChar(str, 'b');
192 while ((x = bms_next_member(bms, x)) >= 0)
193 appendStringInfo(str, " %d", x);
194 appendStringInfoChar(str, ')');
198 * Print the value of a Datum given its type.
201 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
207 length = datumGetSize(value, typbyval, typlen);
211 s = (char *) (&value);
212 appendStringInfo(str, "%u [ ", (unsigned int) length);
213 for (i = 0; i < (Size) sizeof(Datum); i++)
214 appendStringInfo(str, "%d ", (int) (s[i]));
215 appendStringInfoChar(str, ']');
219 s = (char *) DatumGetPointer(value);
220 if (!PointerIsValid(s))
221 appendStringInfoString(str, "0 [ ]");
224 appendStringInfo(str, "%u [ ", (unsigned int) length);
225 for (i = 0; i < length; i++)
226 appendStringInfo(str, "%d ", (int) (s[i]));
227 appendStringInfoChar(str, ']');
234 * Stuff from plannodes.h
238 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
240 WRITE_NODE_TYPE("PLANNEDSTMT");
242 WRITE_ENUM_FIELD(commandType, CmdType);
243 WRITE_UINT_FIELD(queryId);
244 WRITE_BOOL_FIELD(hasReturning);
245 WRITE_BOOL_FIELD(hasModifyingCTE);
246 WRITE_BOOL_FIELD(isUpsert);
247 WRITE_BOOL_FIELD(canSetTag);
248 WRITE_BOOL_FIELD(transientPlan);
249 WRITE_NODE_FIELD(planTree);
250 WRITE_NODE_FIELD(rtable);
251 WRITE_NODE_FIELD(resultRelations);
252 WRITE_NODE_FIELD(utilityStmt);
253 WRITE_NODE_FIELD(subplans);
254 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
255 WRITE_NODE_FIELD(rowMarks);
256 WRITE_NODE_FIELD(relationOids);
257 WRITE_NODE_FIELD(invalItems);
258 WRITE_INT_FIELD(nParamExec);
259 WRITE_BOOL_FIELD(hasRowSecurity);
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_UINT_FIELD(nominalRelation);
333 WRITE_NODE_FIELD(resultRelations);
334 WRITE_INT_FIELD(resultRelIndex);
335 WRITE_NODE_FIELD(plans);
336 WRITE_NODE_FIELD(withCheckOptionLists);
337 WRITE_NODE_FIELD(returningLists);
338 WRITE_NODE_FIELD(fdwPrivLists);
339 WRITE_NODE_FIELD(rowMarks);
340 WRITE_INT_FIELD(epqParam);
341 WRITE_ENUM_FIELD(onConflictAction, OnConflictAction);
342 WRITE_NODE_FIELD(arbiterIndexes);
343 WRITE_NODE_FIELD(onConflictSet);
344 WRITE_NODE_FIELD(onConflictWhere);
345 WRITE_INT_FIELD(exclRelRTI);
346 WRITE_NODE_FIELD(exclRelTlist);
350 _outAppend(StringInfo str, const Append *node)
352 WRITE_NODE_TYPE("APPEND");
354 _outPlanInfo(str, (const Plan *) node);
356 WRITE_NODE_FIELD(appendplans);
360 _outMergeAppend(StringInfo str, const MergeAppend *node)
364 WRITE_NODE_TYPE("MERGEAPPEND");
366 _outPlanInfo(str, (const Plan *) node);
368 WRITE_NODE_FIELD(mergeplans);
370 WRITE_INT_FIELD(numCols);
372 appendStringInfoString(str, " :sortColIdx");
373 for (i = 0; i < node->numCols; i++)
374 appendStringInfo(str, " %d", node->sortColIdx[i]);
376 appendStringInfoString(str, " :sortOperators");
377 for (i = 0; i < node->numCols; i++)
378 appendStringInfo(str, " %u", node->sortOperators[i]);
380 appendStringInfoString(str, " :collations");
381 for (i = 0; i < node->numCols; i++)
382 appendStringInfo(str, " %u", node->collations[i]);
384 appendStringInfoString(str, " :nullsFirst");
385 for (i = 0; i < node->numCols; i++)
386 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
390 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
394 WRITE_NODE_TYPE("RECURSIVEUNION");
396 _outPlanInfo(str, (const Plan *) node);
398 WRITE_INT_FIELD(wtParam);
399 WRITE_INT_FIELD(numCols);
401 appendStringInfoString(str, " :dupColIdx");
402 for (i = 0; i < node->numCols; i++)
403 appendStringInfo(str, " %d", node->dupColIdx[i]);
405 appendStringInfoString(str, " :dupOperators");
406 for (i = 0; i < node->numCols; i++)
407 appendStringInfo(str, " %u", node->dupOperators[i]);
409 WRITE_LONG_FIELD(numGroups);
413 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
415 WRITE_NODE_TYPE("BITMAPAND");
417 _outPlanInfo(str, (const Plan *) node);
419 WRITE_NODE_FIELD(bitmapplans);
423 _outBitmapOr(StringInfo str, const BitmapOr *node)
425 WRITE_NODE_TYPE("BITMAPOR");
427 _outPlanInfo(str, (const Plan *) node);
429 WRITE_NODE_FIELD(bitmapplans);
433 _outScan(StringInfo str, const Scan *node)
435 WRITE_NODE_TYPE("SCAN");
437 _outScanInfo(str, node);
441 _outSeqScan(StringInfo str, const SeqScan *node)
443 WRITE_NODE_TYPE("SEQSCAN");
445 _outScanInfo(str, (const Scan *) node);
449 _outIndexScan(StringInfo str, const IndexScan *node)
451 WRITE_NODE_TYPE("INDEXSCAN");
453 _outScanInfo(str, (const Scan *) node);
455 WRITE_OID_FIELD(indexid);
456 WRITE_NODE_FIELD(indexqual);
457 WRITE_NODE_FIELD(indexqualorig);
458 WRITE_NODE_FIELD(indexorderby);
459 WRITE_NODE_FIELD(indexorderbyorig);
460 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
464 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
466 WRITE_NODE_TYPE("INDEXONLYSCAN");
468 _outScanInfo(str, (const Scan *) node);
470 WRITE_OID_FIELD(indexid);
471 WRITE_NODE_FIELD(indexqual);
472 WRITE_NODE_FIELD(indexorderby);
473 WRITE_NODE_FIELD(indextlist);
474 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
478 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
480 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
482 _outScanInfo(str, (const Scan *) node);
484 WRITE_OID_FIELD(indexid);
485 WRITE_NODE_FIELD(indexqual);
486 WRITE_NODE_FIELD(indexqualorig);
490 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
492 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
494 _outScanInfo(str, (const Scan *) node);
496 WRITE_NODE_FIELD(bitmapqualorig);
500 _outTidScan(StringInfo str, const TidScan *node)
502 WRITE_NODE_TYPE("TIDSCAN");
504 _outScanInfo(str, (const Scan *) node);
506 WRITE_NODE_FIELD(tidquals);
510 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
512 WRITE_NODE_TYPE("SUBQUERYSCAN");
514 _outScanInfo(str, (const Scan *) node);
516 WRITE_NODE_FIELD(subplan);
520 _outFunctionScan(StringInfo str, const FunctionScan *node)
522 WRITE_NODE_TYPE("FUNCTIONSCAN");
524 _outScanInfo(str, (const Scan *) node);
526 WRITE_NODE_FIELD(functions);
527 WRITE_BOOL_FIELD(funcordinality);
531 _outValuesScan(StringInfo str, const ValuesScan *node)
533 WRITE_NODE_TYPE("VALUESSCAN");
535 _outScanInfo(str, (const Scan *) node);
537 WRITE_NODE_FIELD(values_lists);
541 _outCteScan(StringInfo str, const CteScan *node)
543 WRITE_NODE_TYPE("CTESCAN");
545 _outScanInfo(str, (const Scan *) node);
547 WRITE_INT_FIELD(ctePlanId);
548 WRITE_INT_FIELD(cteParam);
552 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
554 WRITE_NODE_TYPE("WORKTABLESCAN");
556 _outScanInfo(str, (const Scan *) node);
558 WRITE_INT_FIELD(wtParam);
562 _outForeignScan(StringInfo str, const ForeignScan *node)
564 WRITE_NODE_TYPE("FOREIGNSCAN");
566 _outScanInfo(str, (const Scan *) node);
568 WRITE_OID_FIELD(fs_server);
569 WRITE_NODE_FIELD(fdw_exprs);
570 WRITE_NODE_FIELD(fdw_private);
571 WRITE_NODE_FIELD(fdw_scan_tlist);
572 WRITE_BITMAPSET_FIELD(fs_relids);
573 WRITE_BOOL_FIELD(fsSystemCol);
577 _outCustomScan(StringInfo str, const CustomScan *node)
579 WRITE_NODE_TYPE("CUSTOMSCAN");
581 _outScanInfo(str, (const Scan *) node);
583 WRITE_UINT_FIELD(flags);
584 WRITE_NODE_FIELD(custom_exprs);
585 WRITE_NODE_FIELD(custom_private);
586 WRITE_NODE_FIELD(custom_scan_tlist);
587 WRITE_BITMAPSET_FIELD(custom_relids);
588 appendStringInfoString(str, " :methods ");
589 _outToken(str, node->methods->CustomName);
590 if (node->methods->TextOutCustomScan)
591 node->methods->TextOutCustomScan(str, node);
595 _outSampleScan(StringInfo str, const SampleScan *node)
597 WRITE_NODE_TYPE("SAMPLESCAN");
599 _outScanInfo(str, (const Scan *) node);
603 _outJoin(StringInfo str, const Join *node)
605 WRITE_NODE_TYPE("JOIN");
607 _outJoinPlanInfo(str, (const Join *) node);
611 _outNestLoop(StringInfo str, const NestLoop *node)
613 WRITE_NODE_TYPE("NESTLOOP");
615 _outJoinPlanInfo(str, (const Join *) node);
617 WRITE_NODE_FIELD(nestParams);
621 _outMergeJoin(StringInfo str, const MergeJoin *node)
626 WRITE_NODE_TYPE("MERGEJOIN");
628 _outJoinPlanInfo(str, (const Join *) node);
630 WRITE_NODE_FIELD(mergeclauses);
632 numCols = list_length(node->mergeclauses);
634 appendStringInfoString(str, " :mergeFamilies");
635 for (i = 0; i < numCols; i++)
636 appendStringInfo(str, " %u", node->mergeFamilies[i]);
638 appendStringInfoString(str, " :mergeCollations");
639 for (i = 0; i < numCols; i++)
640 appendStringInfo(str, " %u", node->mergeCollations[i]);
642 appendStringInfoString(str, " :mergeStrategies");
643 for (i = 0; i < numCols; i++)
644 appendStringInfo(str, " %d", node->mergeStrategies[i]);
646 appendStringInfoString(str, " :mergeNullsFirst");
647 for (i = 0; i < numCols; i++)
648 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
652 _outHashJoin(StringInfo str, const HashJoin *node)
654 WRITE_NODE_TYPE("HASHJOIN");
656 _outJoinPlanInfo(str, (const Join *) node);
658 WRITE_NODE_FIELD(hashclauses);
662 _outAgg(StringInfo str, const Agg *node)
666 WRITE_NODE_TYPE("AGG");
668 _outPlanInfo(str, (const Plan *) node);
670 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
671 WRITE_INT_FIELD(numCols);
673 appendStringInfoString(str, " :grpColIdx");
674 for (i = 0; i < node->numCols; i++)
675 appendStringInfo(str, " %d", node->grpColIdx[i]);
677 appendStringInfoString(str, " :grpOperators");
678 for (i = 0; i < node->numCols; i++)
679 appendStringInfo(str, " %u", node->grpOperators[i]);
681 WRITE_LONG_FIELD(numGroups);
685 _outWindowAgg(StringInfo str, const WindowAgg *node)
689 WRITE_NODE_TYPE("WINDOWAGG");
691 _outPlanInfo(str, (const Plan *) node);
693 WRITE_UINT_FIELD(winref);
694 WRITE_INT_FIELD(partNumCols);
696 appendStringInfoString(str, " :partColIdx");
697 for (i = 0; i < node->partNumCols; i++)
698 appendStringInfo(str, " %d", node->partColIdx[i]);
700 appendStringInfoString(str, " :partOperations");
701 for (i = 0; i < node->partNumCols; i++)
702 appendStringInfo(str, " %u", node->partOperators[i]);
704 WRITE_INT_FIELD(ordNumCols);
706 appendStringInfoString(str, " :ordColIdx");
707 for (i = 0; i < node->ordNumCols; i++)
708 appendStringInfo(str, " %d", node->ordColIdx[i]);
710 appendStringInfoString(str, " :ordOperations");
711 for (i = 0; i < node->ordNumCols; i++)
712 appendStringInfo(str, " %u", node->ordOperators[i]);
714 WRITE_INT_FIELD(frameOptions);
715 WRITE_NODE_FIELD(startOffset);
716 WRITE_NODE_FIELD(endOffset);
720 _outGroup(StringInfo str, const Group *node)
724 WRITE_NODE_TYPE("GROUP");
726 _outPlanInfo(str, (const Plan *) node);
728 WRITE_INT_FIELD(numCols);
730 appendStringInfoString(str, " :grpColIdx");
731 for (i = 0; i < node->numCols; i++)
732 appendStringInfo(str, " %d", node->grpColIdx[i]);
734 appendStringInfoString(str, " :grpOperators");
735 for (i = 0; i < node->numCols; i++)
736 appendStringInfo(str, " %u", node->grpOperators[i]);
740 _outMaterial(StringInfo str, const Material *node)
742 WRITE_NODE_TYPE("MATERIAL");
744 _outPlanInfo(str, (const Plan *) node);
748 _outSort(StringInfo str, const Sort *node)
752 WRITE_NODE_TYPE("SORT");
754 _outPlanInfo(str, (const Plan *) node);
756 WRITE_INT_FIELD(numCols);
758 appendStringInfoString(str, " :sortColIdx");
759 for (i = 0; i < node->numCols; i++)
760 appendStringInfo(str, " %d", node->sortColIdx[i]);
762 appendStringInfoString(str, " :sortOperators");
763 for (i = 0; i < node->numCols; i++)
764 appendStringInfo(str, " %u", node->sortOperators[i]);
766 appendStringInfoString(str, " :collations");
767 for (i = 0; i < node->numCols; i++)
768 appendStringInfo(str, " %u", node->collations[i]);
770 appendStringInfoString(str, " :nullsFirst");
771 for (i = 0; i < node->numCols; i++)
772 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
776 _outUnique(StringInfo str, const Unique *node)
780 WRITE_NODE_TYPE("UNIQUE");
782 _outPlanInfo(str, (const Plan *) node);
784 WRITE_INT_FIELD(numCols);
786 appendStringInfoString(str, " :uniqColIdx");
787 for (i = 0; i < node->numCols; i++)
788 appendStringInfo(str, " %d", node->uniqColIdx[i]);
790 appendStringInfoString(str, " :uniqOperators");
791 for (i = 0; i < node->numCols; i++)
792 appendStringInfo(str, " %u", node->uniqOperators[i]);
796 _outHash(StringInfo str, const Hash *node)
798 WRITE_NODE_TYPE("HASH");
800 _outPlanInfo(str, (const Plan *) node);
802 WRITE_OID_FIELD(skewTable);
803 WRITE_INT_FIELD(skewColumn);
804 WRITE_BOOL_FIELD(skewInherit);
805 WRITE_OID_FIELD(skewColType);
806 WRITE_INT_FIELD(skewColTypmod);
810 _outSetOp(StringInfo str, const SetOp *node)
814 WRITE_NODE_TYPE("SETOP");
816 _outPlanInfo(str, (const Plan *) node);
818 WRITE_ENUM_FIELD(cmd, SetOpCmd);
819 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
820 WRITE_INT_FIELD(numCols);
822 appendStringInfoString(str, " :dupColIdx");
823 for (i = 0; i < node->numCols; i++)
824 appendStringInfo(str, " %d", node->dupColIdx[i]);
826 appendStringInfoString(str, " :dupOperators");
827 for (i = 0; i < node->numCols; i++)
828 appendStringInfo(str, " %u", node->dupOperators[i]);
830 WRITE_INT_FIELD(flagColIdx);
831 WRITE_INT_FIELD(firstFlag);
832 WRITE_LONG_FIELD(numGroups);
836 _outLockRows(StringInfo str, const LockRows *node)
838 WRITE_NODE_TYPE("LOCKROWS");
840 _outPlanInfo(str, (const Plan *) node);
842 WRITE_NODE_FIELD(rowMarks);
843 WRITE_INT_FIELD(epqParam);
847 _outLimit(StringInfo str, const Limit *node)
849 WRITE_NODE_TYPE("LIMIT");
851 _outPlanInfo(str, (const Plan *) node);
853 WRITE_NODE_FIELD(limitOffset);
854 WRITE_NODE_FIELD(limitCount);
858 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
860 WRITE_NODE_TYPE("NESTLOOPPARAM");
862 WRITE_INT_FIELD(paramno);
863 WRITE_NODE_FIELD(paramval);
867 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
869 WRITE_NODE_TYPE("PLANROWMARK");
871 WRITE_UINT_FIELD(rti);
872 WRITE_UINT_FIELD(prti);
873 WRITE_UINT_FIELD(rowmarkId);
874 WRITE_ENUM_FIELD(markType, RowMarkType);
875 WRITE_INT_FIELD(allMarkTypes);
876 WRITE_ENUM_FIELD(strength, LockClauseStrength);
877 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
878 WRITE_BOOL_FIELD(isParent);
882 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
884 WRITE_NODE_TYPE("PLANINVALITEM");
886 WRITE_INT_FIELD(cacheId);
887 WRITE_UINT_FIELD(hashValue);
890 /*****************************************************************************
892 * Stuff from primnodes.h.
894 *****************************************************************************/
897 _outAlias(StringInfo str, const Alias *node)
899 WRITE_NODE_TYPE("ALIAS");
901 WRITE_STRING_FIELD(aliasname);
902 WRITE_NODE_FIELD(colnames);
906 _outRangeVar(StringInfo str, const RangeVar *node)
908 WRITE_NODE_TYPE("RANGEVAR");
911 * we deliberately ignore catalogname here, since it is presently not
912 * semantically meaningful
914 WRITE_STRING_FIELD(schemaname);
915 WRITE_STRING_FIELD(relname);
916 WRITE_ENUM_FIELD(inhOpt, InhOption);
917 WRITE_CHAR_FIELD(relpersistence);
918 WRITE_NODE_FIELD(alias);
919 WRITE_LOCATION_FIELD(location);
923 _outIntoClause(StringInfo str, const IntoClause *node)
925 WRITE_NODE_TYPE("INTOCLAUSE");
927 WRITE_NODE_FIELD(rel);
928 WRITE_NODE_FIELD(colNames);
929 WRITE_NODE_FIELD(options);
930 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
931 WRITE_STRING_FIELD(tableSpaceName);
932 WRITE_NODE_FIELD(viewQuery);
933 WRITE_BOOL_FIELD(skipData);
937 _outVar(StringInfo str, const Var *node)
939 WRITE_NODE_TYPE("VAR");
941 WRITE_UINT_FIELD(varno);
942 WRITE_INT_FIELD(varattno);
943 WRITE_OID_FIELD(vartype);
944 WRITE_INT_FIELD(vartypmod);
945 WRITE_OID_FIELD(varcollid);
946 WRITE_UINT_FIELD(varlevelsup);
947 WRITE_UINT_FIELD(varnoold);
948 WRITE_INT_FIELD(varoattno);
949 WRITE_LOCATION_FIELD(location);
953 _outConst(StringInfo str, const Const *node)
955 WRITE_NODE_TYPE("CONST");
957 WRITE_OID_FIELD(consttype);
958 WRITE_INT_FIELD(consttypmod);
959 WRITE_OID_FIELD(constcollid);
960 WRITE_INT_FIELD(constlen);
961 WRITE_BOOL_FIELD(constbyval);
962 WRITE_BOOL_FIELD(constisnull);
963 WRITE_LOCATION_FIELD(location);
965 appendStringInfoString(str, " :constvalue ");
966 if (node->constisnull)
967 appendStringInfoString(str, "<>");
969 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
973 _outParam(StringInfo str, const Param *node)
975 WRITE_NODE_TYPE("PARAM");
977 WRITE_ENUM_FIELD(paramkind, ParamKind);
978 WRITE_INT_FIELD(paramid);
979 WRITE_OID_FIELD(paramtype);
980 WRITE_INT_FIELD(paramtypmod);
981 WRITE_OID_FIELD(paramcollid);
982 WRITE_LOCATION_FIELD(location);
986 _outAggref(StringInfo str, const Aggref *node)
988 WRITE_NODE_TYPE("AGGREF");
990 WRITE_OID_FIELD(aggfnoid);
991 WRITE_OID_FIELD(aggtype);
992 WRITE_OID_FIELD(aggcollid);
993 WRITE_OID_FIELD(inputcollid);
994 WRITE_NODE_FIELD(aggdirectargs);
995 WRITE_NODE_FIELD(args);
996 WRITE_NODE_FIELD(aggorder);
997 WRITE_NODE_FIELD(aggdistinct);
998 WRITE_NODE_FIELD(aggfilter);
999 WRITE_BOOL_FIELD(aggstar);
1000 WRITE_BOOL_FIELD(aggvariadic);
1001 WRITE_CHAR_FIELD(aggkind);
1002 WRITE_UINT_FIELD(agglevelsup);
1003 WRITE_LOCATION_FIELD(location);
1007 _outWindowFunc(StringInfo str, const WindowFunc *node)
1009 WRITE_NODE_TYPE("WINDOWFUNC");
1011 WRITE_OID_FIELD(winfnoid);
1012 WRITE_OID_FIELD(wintype);
1013 WRITE_OID_FIELD(wincollid);
1014 WRITE_OID_FIELD(inputcollid);
1015 WRITE_NODE_FIELD(args);
1016 WRITE_NODE_FIELD(aggfilter);
1017 WRITE_UINT_FIELD(winref);
1018 WRITE_BOOL_FIELD(winstar);
1019 WRITE_BOOL_FIELD(winagg);
1020 WRITE_LOCATION_FIELD(location);
1024 _outArrayRef(StringInfo str, const ArrayRef *node)
1026 WRITE_NODE_TYPE("ARRAYREF");
1028 WRITE_OID_FIELD(refarraytype);
1029 WRITE_OID_FIELD(refelemtype);
1030 WRITE_INT_FIELD(reftypmod);
1031 WRITE_OID_FIELD(refcollid);
1032 WRITE_NODE_FIELD(refupperindexpr);
1033 WRITE_NODE_FIELD(reflowerindexpr);
1034 WRITE_NODE_FIELD(refexpr);
1035 WRITE_NODE_FIELD(refassgnexpr);
1039 _outFuncExpr(StringInfo str, const FuncExpr *node)
1041 WRITE_NODE_TYPE("FUNCEXPR");
1043 WRITE_OID_FIELD(funcid);
1044 WRITE_OID_FIELD(funcresulttype);
1045 WRITE_BOOL_FIELD(funcretset);
1046 WRITE_BOOL_FIELD(funcvariadic);
1047 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1048 WRITE_OID_FIELD(funccollid);
1049 WRITE_OID_FIELD(inputcollid);
1050 WRITE_NODE_FIELD(args);
1051 WRITE_LOCATION_FIELD(location);
1055 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1057 WRITE_NODE_TYPE("NAMEDARGEXPR");
1059 WRITE_NODE_FIELD(arg);
1060 WRITE_STRING_FIELD(name);
1061 WRITE_INT_FIELD(argnumber);
1062 WRITE_LOCATION_FIELD(location);
1066 _outOpExpr(StringInfo str, const OpExpr *node)
1068 WRITE_NODE_TYPE("OPEXPR");
1070 WRITE_OID_FIELD(opno);
1071 WRITE_OID_FIELD(opfuncid);
1072 WRITE_OID_FIELD(opresulttype);
1073 WRITE_BOOL_FIELD(opretset);
1074 WRITE_OID_FIELD(opcollid);
1075 WRITE_OID_FIELD(inputcollid);
1076 WRITE_NODE_FIELD(args);
1077 WRITE_LOCATION_FIELD(location);
1081 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1083 WRITE_NODE_TYPE("DISTINCTEXPR");
1085 WRITE_OID_FIELD(opno);
1086 WRITE_OID_FIELD(opfuncid);
1087 WRITE_OID_FIELD(opresulttype);
1088 WRITE_BOOL_FIELD(opretset);
1089 WRITE_OID_FIELD(opcollid);
1090 WRITE_OID_FIELD(inputcollid);
1091 WRITE_NODE_FIELD(args);
1092 WRITE_LOCATION_FIELD(location);
1096 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1098 WRITE_NODE_TYPE("NULLIFEXPR");
1100 WRITE_OID_FIELD(opno);
1101 WRITE_OID_FIELD(opfuncid);
1102 WRITE_OID_FIELD(opresulttype);
1103 WRITE_BOOL_FIELD(opretset);
1104 WRITE_OID_FIELD(opcollid);
1105 WRITE_OID_FIELD(inputcollid);
1106 WRITE_NODE_FIELD(args);
1107 WRITE_LOCATION_FIELD(location);
1111 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1113 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1115 WRITE_OID_FIELD(opno);
1116 WRITE_OID_FIELD(opfuncid);
1117 WRITE_BOOL_FIELD(useOr);
1118 WRITE_OID_FIELD(inputcollid);
1119 WRITE_NODE_FIELD(args);
1120 WRITE_LOCATION_FIELD(location);
1124 _outBoolExpr(StringInfo str, const BoolExpr *node)
1128 WRITE_NODE_TYPE("BOOLEXPR");
1130 /* do-it-yourself enum representation */
1131 switch (node->boolop)
1143 appendStringInfoString(str, " :boolop ");
1144 _outToken(str, opstr);
1146 WRITE_NODE_FIELD(args);
1147 WRITE_LOCATION_FIELD(location);
1151 _outSubLink(StringInfo str, const SubLink *node)
1153 WRITE_NODE_TYPE("SUBLINK");
1155 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1156 WRITE_INT_FIELD(subLinkId);
1157 WRITE_NODE_FIELD(testexpr);
1158 WRITE_NODE_FIELD(operName);
1159 WRITE_NODE_FIELD(subselect);
1160 WRITE_LOCATION_FIELD(location);
1164 _outSubPlan(StringInfo str, const SubPlan *node)
1166 WRITE_NODE_TYPE("SUBPLAN");
1168 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1169 WRITE_NODE_FIELD(testexpr);
1170 WRITE_NODE_FIELD(paramIds);
1171 WRITE_INT_FIELD(plan_id);
1172 WRITE_STRING_FIELD(plan_name);
1173 WRITE_OID_FIELD(firstColType);
1174 WRITE_INT_FIELD(firstColTypmod);
1175 WRITE_OID_FIELD(firstColCollation);
1176 WRITE_BOOL_FIELD(useHashTable);
1177 WRITE_BOOL_FIELD(unknownEqFalse);
1178 WRITE_NODE_FIELD(setParam);
1179 WRITE_NODE_FIELD(parParam);
1180 WRITE_NODE_FIELD(args);
1181 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1182 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1186 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1188 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1190 WRITE_NODE_FIELD(subplans);
1194 _outFieldSelect(StringInfo str, const FieldSelect *node)
1196 WRITE_NODE_TYPE("FIELDSELECT");
1198 WRITE_NODE_FIELD(arg);
1199 WRITE_INT_FIELD(fieldnum);
1200 WRITE_OID_FIELD(resulttype);
1201 WRITE_INT_FIELD(resulttypmod);
1202 WRITE_OID_FIELD(resultcollid);
1206 _outFieldStore(StringInfo str, const FieldStore *node)
1208 WRITE_NODE_TYPE("FIELDSTORE");
1210 WRITE_NODE_FIELD(arg);
1211 WRITE_NODE_FIELD(newvals);
1212 WRITE_NODE_FIELD(fieldnums);
1213 WRITE_OID_FIELD(resulttype);
1217 _outRelabelType(StringInfo str, const RelabelType *node)
1219 WRITE_NODE_TYPE("RELABELTYPE");
1221 WRITE_NODE_FIELD(arg);
1222 WRITE_OID_FIELD(resulttype);
1223 WRITE_INT_FIELD(resulttypmod);
1224 WRITE_OID_FIELD(resultcollid);
1225 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1226 WRITE_LOCATION_FIELD(location);
1230 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1232 WRITE_NODE_TYPE("COERCEVIAIO");
1234 WRITE_NODE_FIELD(arg);
1235 WRITE_OID_FIELD(resulttype);
1236 WRITE_OID_FIELD(resultcollid);
1237 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1238 WRITE_LOCATION_FIELD(location);
1242 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1244 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1246 WRITE_NODE_FIELD(arg);
1247 WRITE_OID_FIELD(elemfuncid);
1248 WRITE_OID_FIELD(resulttype);
1249 WRITE_INT_FIELD(resulttypmod);
1250 WRITE_OID_FIELD(resultcollid);
1251 WRITE_BOOL_FIELD(isExplicit);
1252 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1253 WRITE_LOCATION_FIELD(location);
1257 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1259 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1261 WRITE_NODE_FIELD(arg);
1262 WRITE_OID_FIELD(resulttype);
1263 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1264 WRITE_LOCATION_FIELD(location);
1268 _outCollateExpr(StringInfo str, const CollateExpr *node)
1270 WRITE_NODE_TYPE("COLLATE");
1272 WRITE_NODE_FIELD(arg);
1273 WRITE_OID_FIELD(collOid);
1274 WRITE_LOCATION_FIELD(location);
1278 _outCaseExpr(StringInfo str, const CaseExpr *node)
1280 WRITE_NODE_TYPE("CASE");
1282 WRITE_OID_FIELD(casetype);
1283 WRITE_OID_FIELD(casecollid);
1284 WRITE_NODE_FIELD(arg);
1285 WRITE_NODE_FIELD(args);
1286 WRITE_NODE_FIELD(defresult);
1287 WRITE_LOCATION_FIELD(location);
1291 _outCaseWhen(StringInfo str, const CaseWhen *node)
1293 WRITE_NODE_TYPE("WHEN");
1295 WRITE_NODE_FIELD(expr);
1296 WRITE_NODE_FIELD(result);
1297 WRITE_LOCATION_FIELD(location);
1301 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1303 WRITE_NODE_TYPE("CASETESTEXPR");
1305 WRITE_OID_FIELD(typeId);
1306 WRITE_INT_FIELD(typeMod);
1307 WRITE_OID_FIELD(collation);
1311 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1313 WRITE_NODE_TYPE("ARRAY");
1315 WRITE_OID_FIELD(array_typeid);
1316 WRITE_OID_FIELD(array_collid);
1317 WRITE_OID_FIELD(element_typeid);
1318 WRITE_NODE_FIELD(elements);
1319 WRITE_BOOL_FIELD(multidims);
1320 WRITE_LOCATION_FIELD(location);
1324 _outRowExpr(StringInfo str, const RowExpr *node)
1326 WRITE_NODE_TYPE("ROW");
1328 WRITE_NODE_FIELD(args);
1329 WRITE_OID_FIELD(row_typeid);
1330 WRITE_ENUM_FIELD(row_format, CoercionForm);
1331 WRITE_NODE_FIELD(colnames);
1332 WRITE_LOCATION_FIELD(location);
1336 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1338 WRITE_NODE_TYPE("ROWCOMPARE");
1340 WRITE_ENUM_FIELD(rctype, RowCompareType);
1341 WRITE_NODE_FIELD(opnos);
1342 WRITE_NODE_FIELD(opfamilies);
1343 WRITE_NODE_FIELD(inputcollids);
1344 WRITE_NODE_FIELD(largs);
1345 WRITE_NODE_FIELD(rargs);
1349 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1351 WRITE_NODE_TYPE("COALESCE");
1353 WRITE_OID_FIELD(coalescetype);
1354 WRITE_OID_FIELD(coalescecollid);
1355 WRITE_NODE_FIELD(args);
1356 WRITE_LOCATION_FIELD(location);
1360 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1362 WRITE_NODE_TYPE("MINMAX");
1364 WRITE_OID_FIELD(minmaxtype);
1365 WRITE_OID_FIELD(minmaxcollid);
1366 WRITE_OID_FIELD(inputcollid);
1367 WRITE_ENUM_FIELD(op, MinMaxOp);
1368 WRITE_NODE_FIELD(args);
1369 WRITE_LOCATION_FIELD(location);
1373 _outXmlExpr(StringInfo str, const XmlExpr *node)
1375 WRITE_NODE_TYPE("XMLEXPR");
1377 WRITE_ENUM_FIELD(op, XmlExprOp);
1378 WRITE_STRING_FIELD(name);
1379 WRITE_NODE_FIELD(named_args);
1380 WRITE_NODE_FIELD(arg_names);
1381 WRITE_NODE_FIELD(args);
1382 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1383 WRITE_OID_FIELD(type);
1384 WRITE_INT_FIELD(typmod);
1385 WRITE_LOCATION_FIELD(location);
1389 _outNullTest(StringInfo str, const NullTest *node)
1391 WRITE_NODE_TYPE("NULLTEST");
1393 WRITE_NODE_FIELD(arg);
1394 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1395 WRITE_BOOL_FIELD(argisrow);
1396 WRITE_LOCATION_FIELD(location);
1400 _outBooleanTest(StringInfo str, const BooleanTest *node)
1402 WRITE_NODE_TYPE("BOOLEANTEST");
1404 WRITE_NODE_FIELD(arg);
1405 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1406 WRITE_LOCATION_FIELD(location);
1410 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1412 WRITE_NODE_TYPE("COERCETODOMAIN");
1414 WRITE_NODE_FIELD(arg);
1415 WRITE_OID_FIELD(resulttype);
1416 WRITE_INT_FIELD(resulttypmod);
1417 WRITE_OID_FIELD(resultcollid);
1418 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1419 WRITE_LOCATION_FIELD(location);
1423 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1425 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1427 WRITE_OID_FIELD(typeId);
1428 WRITE_INT_FIELD(typeMod);
1429 WRITE_OID_FIELD(collation);
1430 WRITE_LOCATION_FIELD(location);
1434 _outSetToDefault(StringInfo str, const SetToDefault *node)
1436 WRITE_NODE_TYPE("SETTODEFAULT");
1438 WRITE_OID_FIELD(typeId);
1439 WRITE_INT_FIELD(typeMod);
1440 WRITE_OID_FIELD(collation);
1441 WRITE_LOCATION_FIELD(location);
1445 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1447 WRITE_NODE_TYPE("CURRENTOFEXPR");
1449 WRITE_UINT_FIELD(cvarno);
1450 WRITE_STRING_FIELD(cursor_name);
1451 WRITE_INT_FIELD(cursor_param);
1455 _outInferenceElem(StringInfo str, const InferenceElem *node)
1457 WRITE_NODE_TYPE("INFERENCEELEM");
1459 WRITE_NODE_FIELD(expr);
1460 WRITE_OID_FIELD(infercollid);
1461 WRITE_OID_FIELD(inferopfamily);
1462 WRITE_OID_FIELD(inferopcinputtype);
1466 _outTargetEntry(StringInfo str, const TargetEntry *node)
1468 WRITE_NODE_TYPE("TARGETENTRY");
1470 WRITE_NODE_FIELD(expr);
1471 WRITE_INT_FIELD(resno);
1472 WRITE_STRING_FIELD(resname);
1473 WRITE_UINT_FIELD(ressortgroupref);
1474 WRITE_OID_FIELD(resorigtbl);
1475 WRITE_INT_FIELD(resorigcol);
1476 WRITE_BOOL_FIELD(resjunk);
1480 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1482 WRITE_NODE_TYPE("RANGETBLREF");
1484 WRITE_INT_FIELD(rtindex);
1488 _outJoinExpr(StringInfo str, const JoinExpr *node)
1490 WRITE_NODE_TYPE("JOINEXPR");
1492 WRITE_ENUM_FIELD(jointype, JoinType);
1493 WRITE_BOOL_FIELD(isNatural);
1494 WRITE_NODE_FIELD(larg);
1495 WRITE_NODE_FIELD(rarg);
1496 WRITE_NODE_FIELD(usingClause);
1497 WRITE_NODE_FIELD(quals);
1498 WRITE_NODE_FIELD(alias);
1499 WRITE_INT_FIELD(rtindex);
1503 _outFromExpr(StringInfo str, const FromExpr *node)
1505 WRITE_NODE_TYPE("FROMEXPR");
1507 WRITE_NODE_FIELD(fromlist);
1508 WRITE_NODE_FIELD(quals);
1512 _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
1514 WRITE_NODE_TYPE("ONCONFLICTEXPR");
1516 WRITE_ENUM_FIELD(action, OnConflictAction);
1517 WRITE_NODE_FIELD(arbiterElems);
1518 WRITE_NODE_FIELD(arbiterWhere);
1519 WRITE_NODE_FIELD(onConflictSet);
1520 WRITE_NODE_FIELD(onConflictWhere);
1521 WRITE_OID_FIELD(constraint);
1522 WRITE_INT_FIELD(exclRelIndex);
1523 WRITE_NODE_FIELD(exclRelTlist);
1526 /*****************************************************************************
1528 * Stuff from relation.h.
1530 *****************************************************************************/
1533 * print the basic stuff of all nodes that inherit from Path
1535 * Note we do NOT print the parent, else we'd be in infinite recursion.
1536 * We can print the parent's relids for identification purposes, though.
1537 * We also do not print the whole of param_info, since it's printed by
1538 * _outRelOptInfo; it's sufficient and less cluttering to print just the
1539 * required outer relids.
1542 _outPathInfo(StringInfo str, const Path *node)
1544 WRITE_ENUM_FIELD(pathtype, NodeTag);
1545 appendStringInfoString(str, " :parent_relids ");
1547 _outBitmapset(str, node->parent->relids);
1549 _outBitmapset(str, NULL);
1550 appendStringInfoString(str, " :required_outer ");
1551 if (node->param_info)
1552 _outBitmapset(str, node->param_info->ppi_req_outer);
1554 _outBitmapset(str, NULL);
1555 WRITE_FLOAT_FIELD(rows, "%.0f");
1556 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1557 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1558 WRITE_NODE_FIELD(pathkeys);
1562 * print the basic stuff of all nodes that inherit from JoinPath
1565 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1567 _outPathInfo(str, (const Path *) node);
1569 WRITE_ENUM_FIELD(jointype, JoinType);
1570 WRITE_NODE_FIELD(outerjoinpath);
1571 WRITE_NODE_FIELD(innerjoinpath);
1572 WRITE_NODE_FIELD(joinrestrictinfo);
1576 _outPath(StringInfo str, const Path *node)
1578 WRITE_NODE_TYPE("PATH");
1580 _outPathInfo(str, (const Path *) node);
1584 _outIndexPath(StringInfo str, const IndexPath *node)
1586 WRITE_NODE_TYPE("INDEXPATH");
1588 _outPathInfo(str, (const Path *) node);
1590 WRITE_NODE_FIELD(indexinfo);
1591 WRITE_NODE_FIELD(indexclauses);
1592 WRITE_NODE_FIELD(indexquals);
1593 WRITE_NODE_FIELD(indexqualcols);
1594 WRITE_NODE_FIELD(indexorderbys);
1595 WRITE_NODE_FIELD(indexorderbycols);
1596 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1597 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1598 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1602 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1604 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1606 _outPathInfo(str, (const Path *) node);
1608 WRITE_NODE_FIELD(bitmapqual);
1612 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1614 WRITE_NODE_TYPE("BITMAPANDPATH");
1616 _outPathInfo(str, (const Path *) node);
1618 WRITE_NODE_FIELD(bitmapquals);
1619 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1623 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1625 WRITE_NODE_TYPE("BITMAPORPATH");
1627 _outPathInfo(str, (const Path *) node);
1629 WRITE_NODE_FIELD(bitmapquals);
1630 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1634 _outTidPath(StringInfo str, const TidPath *node)
1636 WRITE_NODE_TYPE("TIDPATH");
1638 _outPathInfo(str, (const Path *) node);
1640 WRITE_NODE_FIELD(tidquals);
1644 _outForeignPath(StringInfo str, const ForeignPath *node)
1646 WRITE_NODE_TYPE("FOREIGNPATH");
1648 _outPathInfo(str, (const Path *) node);
1650 WRITE_NODE_FIELD(fdw_private);
1654 _outCustomPath(StringInfo str, const CustomPath *node)
1656 WRITE_NODE_TYPE("CUSTOMPATH");
1658 _outPathInfo(str, (const Path *) node);
1660 WRITE_UINT_FIELD(flags);
1661 WRITE_NODE_FIELD(custom_private);
1662 appendStringInfoString(str, " :methods ");
1663 _outToken(str, node->methods->CustomName);
1664 if (node->methods->TextOutCustomPath)
1665 node->methods->TextOutCustomPath(str, node);
1669 _outAppendPath(StringInfo str, const AppendPath *node)
1671 WRITE_NODE_TYPE("APPENDPATH");
1673 _outPathInfo(str, (const Path *) node);
1675 WRITE_NODE_FIELD(subpaths);
1679 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1681 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1683 _outPathInfo(str, (const Path *) node);
1685 WRITE_NODE_FIELD(subpaths);
1686 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1690 _outResultPath(StringInfo str, const ResultPath *node)
1692 WRITE_NODE_TYPE("RESULTPATH");
1694 _outPathInfo(str, (const Path *) node);
1696 WRITE_NODE_FIELD(quals);
1700 _outMaterialPath(StringInfo str, const MaterialPath *node)
1702 WRITE_NODE_TYPE("MATERIALPATH");
1704 _outPathInfo(str, (const Path *) node);
1706 WRITE_NODE_FIELD(subpath);
1710 _outUniquePath(StringInfo str, const UniquePath *node)
1712 WRITE_NODE_TYPE("UNIQUEPATH");
1714 _outPathInfo(str, (const Path *) node);
1716 WRITE_NODE_FIELD(subpath);
1717 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1718 WRITE_NODE_FIELD(in_operators);
1719 WRITE_NODE_FIELD(uniq_exprs);
1723 _outNestPath(StringInfo str, const NestPath *node)
1725 WRITE_NODE_TYPE("NESTPATH");
1727 _outJoinPathInfo(str, (const JoinPath *) node);
1731 _outMergePath(StringInfo str, const MergePath *node)
1733 WRITE_NODE_TYPE("MERGEPATH");
1735 _outJoinPathInfo(str, (const JoinPath *) node);
1737 WRITE_NODE_FIELD(path_mergeclauses);
1738 WRITE_NODE_FIELD(outersortkeys);
1739 WRITE_NODE_FIELD(innersortkeys);
1740 WRITE_BOOL_FIELD(materialize_inner);
1744 _outHashPath(StringInfo str, const HashPath *node)
1746 WRITE_NODE_TYPE("HASHPATH");
1748 _outJoinPathInfo(str, (const JoinPath *) node);
1750 WRITE_NODE_FIELD(path_hashclauses);
1751 WRITE_INT_FIELD(num_batches);
1755 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
1757 WRITE_NODE_TYPE("PLANNERGLOBAL");
1759 /* NB: this isn't a complete set of fields */
1760 WRITE_NODE_FIELD(subplans);
1761 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1762 WRITE_NODE_FIELD(finalrtable);
1763 WRITE_NODE_FIELD(finalrowmarks);
1764 WRITE_NODE_FIELD(resultRelations);
1765 WRITE_NODE_FIELD(relationOids);
1766 WRITE_NODE_FIELD(invalItems);
1767 WRITE_INT_FIELD(nParamExec);
1768 WRITE_UINT_FIELD(lastPHId);
1769 WRITE_UINT_FIELD(lastRowMarkId);
1770 WRITE_BOOL_FIELD(transientPlan);
1771 WRITE_BOOL_FIELD(hasRowSecurity);
1775 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
1777 WRITE_NODE_TYPE("PLANNERINFO");
1779 /* NB: this isn't a complete set of fields */
1780 WRITE_NODE_FIELD(parse);
1781 WRITE_NODE_FIELD(glob);
1782 WRITE_UINT_FIELD(query_level);
1783 WRITE_NODE_FIELD(plan_params);
1784 WRITE_BITMAPSET_FIELD(all_baserels);
1785 WRITE_BITMAPSET_FIELD(nullable_baserels);
1786 WRITE_NODE_FIELD(join_rel_list);
1787 WRITE_INT_FIELD(join_cur_level);
1788 WRITE_NODE_FIELD(init_plans);
1789 WRITE_NODE_FIELD(cte_plan_ids);
1790 WRITE_NODE_FIELD(multiexpr_params);
1791 WRITE_NODE_FIELD(eq_classes);
1792 WRITE_NODE_FIELD(canon_pathkeys);
1793 WRITE_NODE_FIELD(left_join_clauses);
1794 WRITE_NODE_FIELD(right_join_clauses);
1795 WRITE_NODE_FIELD(full_join_clauses);
1796 WRITE_NODE_FIELD(join_info_list);
1797 WRITE_NODE_FIELD(lateral_info_list);
1798 WRITE_NODE_FIELD(append_rel_list);
1799 WRITE_NODE_FIELD(rowMarks);
1800 WRITE_NODE_FIELD(placeholder_list);
1801 WRITE_NODE_FIELD(query_pathkeys);
1802 WRITE_NODE_FIELD(group_pathkeys);
1803 WRITE_NODE_FIELD(window_pathkeys);
1804 WRITE_NODE_FIELD(distinct_pathkeys);
1805 WRITE_NODE_FIELD(sort_pathkeys);
1806 WRITE_NODE_FIELD(minmax_aggs);
1807 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1808 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1809 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1810 WRITE_BOOL_FIELD(hasInheritedTarget);
1811 WRITE_BOOL_FIELD(hasJoinRTEs);
1812 WRITE_BOOL_FIELD(hasLateralRTEs);
1813 WRITE_BOOL_FIELD(hasDeletedRTEs);
1814 WRITE_BOOL_FIELD(hasHavingQual);
1815 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1816 WRITE_BOOL_FIELD(hasRecursion);
1817 WRITE_INT_FIELD(wt_param_id);
1818 WRITE_BITMAPSET_FIELD(curOuterRels);
1819 WRITE_NODE_FIELD(curOuterParams);
1823 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
1825 WRITE_NODE_TYPE("RELOPTINFO");
1827 /* NB: this isn't a complete set of fields */
1828 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1829 WRITE_BITMAPSET_FIELD(relids);
1830 WRITE_FLOAT_FIELD(rows, "%.0f");
1831 WRITE_INT_FIELD(width);
1832 WRITE_BOOL_FIELD(consider_startup);
1833 WRITE_NODE_FIELD(reltargetlist);
1834 WRITE_NODE_FIELD(pathlist);
1835 WRITE_NODE_FIELD(ppilist);
1836 WRITE_NODE_FIELD(cheapest_startup_path);
1837 WRITE_NODE_FIELD(cheapest_total_path);
1838 WRITE_NODE_FIELD(cheapest_unique_path);
1839 WRITE_NODE_FIELD(cheapest_parameterized_paths);
1840 WRITE_UINT_FIELD(relid);
1841 WRITE_OID_FIELD(reltablespace);
1842 WRITE_ENUM_FIELD(rtekind, RTEKind);
1843 WRITE_INT_FIELD(min_attr);
1844 WRITE_INT_FIELD(max_attr);
1845 WRITE_NODE_FIELD(lateral_vars);
1846 WRITE_BITMAPSET_FIELD(lateral_relids);
1847 WRITE_BITMAPSET_FIELD(lateral_referencers);
1848 WRITE_NODE_FIELD(indexlist);
1849 WRITE_UINT_FIELD(pages);
1850 WRITE_FLOAT_FIELD(tuples, "%.0f");
1851 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
1852 WRITE_NODE_FIELD(subplan);
1853 WRITE_NODE_FIELD(subroot);
1854 WRITE_NODE_FIELD(subplan_params);
1855 WRITE_OID_FIELD(serverid);
1856 /* we don't try to print fdwroutine or fdw_private */
1857 WRITE_NODE_FIELD(baserestrictinfo);
1858 WRITE_NODE_FIELD(joininfo);
1859 WRITE_BOOL_FIELD(has_eclass_joins);
1863 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
1865 WRITE_NODE_TYPE("INDEXOPTINFO");
1867 /* NB: this isn't a complete set of fields */
1868 WRITE_OID_FIELD(indexoid);
1869 /* Do NOT print rel field, else infinite recursion */
1870 WRITE_UINT_FIELD(pages);
1871 WRITE_FLOAT_FIELD(tuples, "%.0f");
1872 WRITE_INT_FIELD(tree_height);
1873 WRITE_INT_FIELD(ncolumns);
1874 /* array fields aren't really worth the trouble to print */
1875 WRITE_OID_FIELD(relam);
1876 /* indexprs is redundant since we print indextlist */
1877 WRITE_NODE_FIELD(indpred);
1878 WRITE_NODE_FIELD(indextlist);
1879 WRITE_BOOL_FIELD(predOK);
1880 WRITE_BOOL_FIELD(unique);
1881 WRITE_BOOL_FIELD(immediate);
1882 WRITE_BOOL_FIELD(hypothetical);
1883 /* we don't bother with fields copied from the pg_am entry */
1887 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
1890 * To simplify reading, we just chase up to the topmost merged EC and
1891 * print that, without bothering to show the merge-ees separately.
1893 while (node->ec_merged)
1894 node = node->ec_merged;
1896 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1898 WRITE_NODE_FIELD(ec_opfamilies);
1899 WRITE_OID_FIELD(ec_collation);
1900 WRITE_NODE_FIELD(ec_members);
1901 WRITE_NODE_FIELD(ec_sources);
1902 WRITE_NODE_FIELD(ec_derives);
1903 WRITE_BITMAPSET_FIELD(ec_relids);
1904 WRITE_BOOL_FIELD(ec_has_const);
1905 WRITE_BOOL_FIELD(ec_has_volatile);
1906 WRITE_BOOL_FIELD(ec_below_outer_join);
1907 WRITE_BOOL_FIELD(ec_broken);
1908 WRITE_UINT_FIELD(ec_sortref);
1912 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
1914 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1916 WRITE_NODE_FIELD(em_expr);
1917 WRITE_BITMAPSET_FIELD(em_relids);
1918 WRITE_BITMAPSET_FIELD(em_nullable_relids);
1919 WRITE_BOOL_FIELD(em_is_const);
1920 WRITE_BOOL_FIELD(em_is_child);
1921 WRITE_OID_FIELD(em_datatype);
1925 _outPathKey(StringInfo str, const PathKey *node)
1927 WRITE_NODE_TYPE("PATHKEY");
1929 WRITE_NODE_FIELD(pk_eclass);
1930 WRITE_OID_FIELD(pk_opfamily);
1931 WRITE_INT_FIELD(pk_strategy);
1932 WRITE_BOOL_FIELD(pk_nulls_first);
1936 _outParamPathInfo(StringInfo str, const ParamPathInfo *node)
1938 WRITE_NODE_TYPE("PARAMPATHINFO");
1940 WRITE_BITMAPSET_FIELD(ppi_req_outer);
1941 WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
1942 WRITE_NODE_FIELD(ppi_clauses);
1946 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
1948 WRITE_NODE_TYPE("RESTRICTINFO");
1950 /* NB: this isn't a complete set of fields */
1951 WRITE_NODE_FIELD(clause);
1952 WRITE_BOOL_FIELD(is_pushed_down);
1953 WRITE_BOOL_FIELD(outerjoin_delayed);
1954 WRITE_BOOL_FIELD(can_join);
1955 WRITE_BOOL_FIELD(pseudoconstant);
1956 WRITE_BITMAPSET_FIELD(clause_relids);
1957 WRITE_BITMAPSET_FIELD(required_relids);
1958 WRITE_BITMAPSET_FIELD(outer_relids);
1959 WRITE_BITMAPSET_FIELD(nullable_relids);
1960 WRITE_BITMAPSET_FIELD(left_relids);
1961 WRITE_BITMAPSET_FIELD(right_relids);
1962 WRITE_NODE_FIELD(orclause);
1963 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1964 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1965 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1966 WRITE_NODE_FIELD(mergeopfamilies);
1967 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1968 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1969 WRITE_NODE_FIELD(left_em);
1970 WRITE_NODE_FIELD(right_em);
1971 WRITE_BOOL_FIELD(outer_is_left);
1972 WRITE_OID_FIELD(hashjoinoperator);
1976 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
1978 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1980 WRITE_NODE_FIELD(phexpr);
1981 WRITE_BITMAPSET_FIELD(phrels);
1982 WRITE_UINT_FIELD(phid);
1983 WRITE_UINT_FIELD(phlevelsup);
1987 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
1989 WRITE_NODE_TYPE("SPECIALJOININFO");
1991 WRITE_BITMAPSET_FIELD(min_lefthand);
1992 WRITE_BITMAPSET_FIELD(min_righthand);
1993 WRITE_BITMAPSET_FIELD(syn_lefthand);
1994 WRITE_BITMAPSET_FIELD(syn_righthand);
1995 WRITE_ENUM_FIELD(jointype, JoinType);
1996 WRITE_BOOL_FIELD(lhs_strict);
1997 WRITE_BOOL_FIELD(delay_upper_joins);
1998 WRITE_BOOL_FIELD(semi_can_btree);
1999 WRITE_BOOL_FIELD(semi_can_hash);
2000 WRITE_NODE_FIELD(semi_operators);
2001 WRITE_NODE_FIELD(semi_rhs_exprs);
2005 _outLateralJoinInfo(StringInfo str, const LateralJoinInfo *node)
2007 WRITE_NODE_TYPE("LATERALJOININFO");
2009 WRITE_BITMAPSET_FIELD(lateral_lhs);
2010 WRITE_BITMAPSET_FIELD(lateral_rhs);
2014 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
2016 WRITE_NODE_TYPE("APPENDRELINFO");
2018 WRITE_UINT_FIELD(parent_relid);
2019 WRITE_UINT_FIELD(child_relid);
2020 WRITE_OID_FIELD(parent_reltype);
2021 WRITE_OID_FIELD(child_reltype);
2022 WRITE_NODE_FIELD(translated_vars);
2023 WRITE_OID_FIELD(parent_reloid);
2027 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
2029 WRITE_NODE_TYPE("PLACEHOLDERINFO");
2031 WRITE_UINT_FIELD(phid);
2032 WRITE_NODE_FIELD(ph_var);
2033 WRITE_BITMAPSET_FIELD(ph_eval_at);
2034 WRITE_BITMAPSET_FIELD(ph_lateral);
2035 WRITE_BITMAPSET_FIELD(ph_needed);
2036 WRITE_INT_FIELD(ph_width);
2040 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
2042 WRITE_NODE_TYPE("MINMAXAGGINFO");
2044 WRITE_OID_FIELD(aggfnoid);
2045 WRITE_OID_FIELD(aggsortop);
2046 WRITE_NODE_FIELD(target);
2047 /* We intentionally omit subroot --- too large, not interesting enough */
2048 WRITE_NODE_FIELD(path);
2049 WRITE_FLOAT_FIELD(pathcost, "%.2f");
2050 WRITE_NODE_FIELD(param);
2054 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
2056 WRITE_NODE_TYPE("PLANNERPARAMITEM");
2058 WRITE_NODE_FIELD(item);
2059 WRITE_INT_FIELD(paramId);
2062 /*****************************************************************************
2064 * Stuff from parsenodes.h.
2066 *****************************************************************************/
2069 * print the basic stuff of all nodes that inherit from CreateStmt
2072 _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
2074 WRITE_NODE_FIELD(relation);
2075 WRITE_NODE_FIELD(tableElts);
2076 WRITE_NODE_FIELD(inhRelations);
2077 WRITE_NODE_FIELD(ofTypename);
2078 WRITE_NODE_FIELD(constraints);
2079 WRITE_NODE_FIELD(options);
2080 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
2081 WRITE_STRING_FIELD(tablespacename);
2082 WRITE_BOOL_FIELD(if_not_exists);
2086 _outCreateStmt(StringInfo str, const CreateStmt *node)
2088 WRITE_NODE_TYPE("CREATESTMT");
2090 _outCreateStmtInfo(str, (const CreateStmt *) node);
2094 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
2096 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
2098 _outCreateStmtInfo(str, (const CreateStmt *) node);
2100 WRITE_STRING_FIELD(servername);
2101 WRITE_NODE_FIELD(options);
2105 _outImportForeignSchemaStmt(StringInfo str, const ImportForeignSchemaStmt *node)
2107 WRITE_NODE_TYPE("IMPORTFOREIGNSCHEMASTMT");
2109 WRITE_STRING_FIELD(server_name);
2110 WRITE_STRING_FIELD(remote_schema);
2111 WRITE_STRING_FIELD(local_schema);
2112 WRITE_ENUM_FIELD(list_type, ImportForeignSchemaType);
2113 WRITE_NODE_FIELD(table_list);
2114 WRITE_NODE_FIELD(options);
2118 _outIndexStmt(StringInfo str, const IndexStmt *node)
2120 WRITE_NODE_TYPE("INDEXSTMT");
2122 WRITE_STRING_FIELD(idxname);
2123 WRITE_NODE_FIELD(relation);
2124 WRITE_STRING_FIELD(accessMethod);
2125 WRITE_STRING_FIELD(tableSpace);
2126 WRITE_NODE_FIELD(indexParams);
2127 WRITE_NODE_FIELD(options);
2128 WRITE_NODE_FIELD(whereClause);
2129 WRITE_NODE_FIELD(excludeOpNames);
2130 WRITE_STRING_FIELD(idxcomment);
2131 WRITE_OID_FIELD(indexOid);
2132 WRITE_OID_FIELD(oldNode);
2133 WRITE_BOOL_FIELD(unique);
2134 WRITE_BOOL_FIELD(primary);
2135 WRITE_BOOL_FIELD(isconstraint);
2136 WRITE_BOOL_FIELD(deferrable);
2137 WRITE_BOOL_FIELD(initdeferred);
2138 WRITE_BOOL_FIELD(transformed);
2139 WRITE_BOOL_FIELD(concurrent);
2140 WRITE_BOOL_FIELD(if_not_exists);
2144 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
2146 WRITE_NODE_TYPE("NOTIFY");
2148 WRITE_STRING_FIELD(conditionname);
2149 WRITE_STRING_FIELD(payload);
2153 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2155 WRITE_NODE_TYPE("DECLARECURSOR");
2157 WRITE_STRING_FIELD(portalname);
2158 WRITE_INT_FIELD(options);
2159 WRITE_NODE_FIELD(query);
2163 _outSelectStmt(StringInfo str, const SelectStmt *node)
2165 WRITE_NODE_TYPE("SELECT");
2167 WRITE_NODE_FIELD(distinctClause);
2168 WRITE_NODE_FIELD(intoClause);
2169 WRITE_NODE_FIELD(targetList);
2170 WRITE_NODE_FIELD(fromClause);
2171 WRITE_NODE_FIELD(whereClause);
2172 WRITE_NODE_FIELD(groupClause);
2173 WRITE_NODE_FIELD(havingClause);
2174 WRITE_NODE_FIELD(windowClause);
2175 WRITE_NODE_FIELD(valuesLists);
2176 WRITE_NODE_FIELD(sortClause);
2177 WRITE_NODE_FIELD(limitOffset);
2178 WRITE_NODE_FIELD(limitCount);
2179 WRITE_NODE_FIELD(lockingClause);
2180 WRITE_NODE_FIELD(withClause);
2181 WRITE_ENUM_FIELD(op, SetOperation);
2182 WRITE_BOOL_FIELD(all);
2183 WRITE_NODE_FIELD(larg);
2184 WRITE_NODE_FIELD(rarg);
2188 _outFuncCall(StringInfo str, const FuncCall *node)
2190 WRITE_NODE_TYPE("FUNCCALL");
2192 WRITE_NODE_FIELD(funcname);
2193 WRITE_NODE_FIELD(args);
2194 WRITE_NODE_FIELD(agg_order);
2195 WRITE_NODE_FIELD(agg_filter);
2196 WRITE_BOOL_FIELD(agg_within_group);
2197 WRITE_BOOL_FIELD(agg_star);
2198 WRITE_BOOL_FIELD(agg_distinct);
2199 WRITE_BOOL_FIELD(func_variadic);
2200 WRITE_NODE_FIELD(over);
2201 WRITE_LOCATION_FIELD(location);
2205 _outDefElem(StringInfo str, const DefElem *node)
2207 WRITE_NODE_TYPE("DEFELEM");
2209 WRITE_STRING_FIELD(defnamespace);
2210 WRITE_STRING_FIELD(defname);
2211 WRITE_NODE_FIELD(arg);
2212 WRITE_ENUM_FIELD(defaction, DefElemAction);
2216 _outTableLikeClause(StringInfo str, const TableLikeClause *node)
2218 WRITE_NODE_TYPE("TABLELIKECLAUSE");
2220 WRITE_NODE_FIELD(relation);
2221 WRITE_UINT_FIELD(options);
2225 _outLockingClause(StringInfo str, const LockingClause *node)
2227 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2229 WRITE_NODE_FIELD(lockedRels);
2230 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2231 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2235 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2237 WRITE_NODE_TYPE("XMLSERIALIZE");
2239 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2240 WRITE_NODE_FIELD(expr);
2241 WRITE_NODE_FIELD(typeName);
2242 WRITE_LOCATION_FIELD(location);
2246 _outColumnDef(StringInfo str, const ColumnDef *node)
2248 WRITE_NODE_TYPE("COLUMNDEF");
2250 WRITE_STRING_FIELD(colname);
2251 WRITE_NODE_FIELD(typeName);
2252 WRITE_INT_FIELD(inhcount);
2253 WRITE_BOOL_FIELD(is_local);
2254 WRITE_BOOL_FIELD(is_not_null);
2255 WRITE_BOOL_FIELD(is_from_type);
2256 WRITE_CHAR_FIELD(storage);
2257 WRITE_NODE_FIELD(raw_default);
2258 WRITE_NODE_FIELD(cooked_default);
2259 WRITE_NODE_FIELD(collClause);
2260 WRITE_OID_FIELD(collOid);
2261 WRITE_NODE_FIELD(constraints);
2262 WRITE_NODE_FIELD(fdwoptions);
2263 WRITE_LOCATION_FIELD(location);
2267 _outTypeName(StringInfo str, const TypeName *node)
2269 WRITE_NODE_TYPE("TYPENAME");
2271 WRITE_NODE_FIELD(names);
2272 WRITE_OID_FIELD(typeOid);
2273 WRITE_BOOL_FIELD(setof);
2274 WRITE_BOOL_FIELD(pct_type);
2275 WRITE_NODE_FIELD(typmods);
2276 WRITE_INT_FIELD(typemod);
2277 WRITE_NODE_FIELD(arrayBounds);
2278 WRITE_LOCATION_FIELD(location);
2282 _outTypeCast(StringInfo str, const TypeCast *node)
2284 WRITE_NODE_TYPE("TYPECAST");
2286 WRITE_NODE_FIELD(arg);
2287 WRITE_NODE_FIELD(typeName);
2288 WRITE_LOCATION_FIELD(location);
2292 _outCollateClause(StringInfo str, const CollateClause *node)
2294 WRITE_NODE_TYPE("COLLATECLAUSE");
2296 WRITE_NODE_FIELD(arg);
2297 WRITE_NODE_FIELD(collname);
2298 WRITE_LOCATION_FIELD(location);
2302 _outIndexElem(StringInfo str, const IndexElem *node)
2304 WRITE_NODE_TYPE("INDEXELEM");
2306 WRITE_STRING_FIELD(name);
2307 WRITE_NODE_FIELD(expr);
2308 WRITE_STRING_FIELD(indexcolname);
2309 WRITE_NODE_FIELD(collation);
2310 WRITE_NODE_FIELD(opclass);
2311 WRITE_ENUM_FIELD(ordering, SortByDir);
2312 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2316 _outQuery(StringInfo str, const Query *node)
2318 WRITE_NODE_TYPE("QUERY");
2320 WRITE_ENUM_FIELD(commandType, CmdType);
2321 WRITE_ENUM_FIELD(querySource, QuerySource);
2322 /* we intentionally do not print the queryId field */
2323 WRITE_BOOL_FIELD(canSetTag);
2326 * Hack to work around missing outfuncs routines for a lot of the
2327 * utility-statement node types. (The only one we actually *need* for
2328 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2329 * for the meantime do this to avoid getting lots of warnings when running
2330 * with debug_print_parse on.
2332 if (node->utilityStmt)
2334 switch (nodeTag(node->utilityStmt))
2339 case T_DeclareCursorStmt:
2340 WRITE_NODE_FIELD(utilityStmt);
2343 appendStringInfoString(str, " :utilityStmt ?");
2348 appendStringInfoString(str, " :utilityStmt <>");
2350 WRITE_INT_FIELD(resultRelation);
2351 WRITE_BOOL_FIELD(hasAggs);
2352 WRITE_BOOL_FIELD(hasWindowFuncs);
2353 WRITE_BOOL_FIELD(hasSubLinks);
2354 WRITE_BOOL_FIELD(hasDistinctOn);
2355 WRITE_BOOL_FIELD(hasRecursive);
2356 WRITE_BOOL_FIELD(hasModifyingCTE);
2357 WRITE_BOOL_FIELD(hasForUpdate);
2358 WRITE_BOOL_FIELD(hasRowSecurity);
2359 WRITE_NODE_FIELD(cteList);
2360 WRITE_NODE_FIELD(rtable);
2361 WRITE_NODE_FIELD(jointree);
2362 WRITE_NODE_FIELD(targetList);
2363 WRITE_NODE_FIELD(withCheckOptions);
2364 WRITE_NODE_FIELD(onConflict);
2365 WRITE_NODE_FIELD(returningList);
2366 WRITE_NODE_FIELD(groupClause);
2367 WRITE_NODE_FIELD(havingQual);
2368 WRITE_NODE_FIELD(windowClause);
2369 WRITE_NODE_FIELD(distinctClause);
2370 WRITE_NODE_FIELD(sortClause);
2371 WRITE_NODE_FIELD(limitOffset);
2372 WRITE_NODE_FIELD(limitCount);
2373 WRITE_NODE_FIELD(rowMarks);
2374 WRITE_NODE_FIELD(setOperations);
2375 WRITE_NODE_FIELD(constraintDeps);
2379 _outWithCheckOption(StringInfo str, const WithCheckOption *node)
2381 WRITE_NODE_TYPE("WITHCHECKOPTION");
2383 WRITE_ENUM_FIELD(kind, WCOKind);
2384 WRITE_STRING_FIELD(relname);
2385 WRITE_NODE_FIELD(qual);
2386 WRITE_BOOL_FIELD(cascaded);
2390 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2392 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2394 WRITE_UINT_FIELD(tleSortGroupRef);
2395 WRITE_OID_FIELD(eqop);
2396 WRITE_OID_FIELD(sortop);
2397 WRITE_BOOL_FIELD(nulls_first);
2398 WRITE_BOOL_FIELD(hashable);
2402 _outWindowClause(StringInfo str, const WindowClause *node)
2404 WRITE_NODE_TYPE("WINDOWCLAUSE");
2406 WRITE_STRING_FIELD(name);
2407 WRITE_STRING_FIELD(refname);
2408 WRITE_NODE_FIELD(partitionClause);
2409 WRITE_NODE_FIELD(orderClause);
2410 WRITE_INT_FIELD(frameOptions);
2411 WRITE_NODE_FIELD(startOffset);
2412 WRITE_NODE_FIELD(endOffset);
2413 WRITE_UINT_FIELD(winref);
2414 WRITE_BOOL_FIELD(copiedOrder);
2418 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
2420 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2422 WRITE_UINT_FIELD(rti);
2423 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2424 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2425 WRITE_BOOL_FIELD(pushedDown);
2429 _outWithClause(StringInfo str, const WithClause *node)
2431 WRITE_NODE_TYPE("WITHCLAUSE");
2433 WRITE_NODE_FIELD(ctes);
2434 WRITE_BOOL_FIELD(recursive);
2435 WRITE_LOCATION_FIELD(location);
2439 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
2441 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2443 WRITE_STRING_FIELD(ctename);
2444 WRITE_NODE_FIELD(aliascolnames);
2445 WRITE_NODE_FIELD(ctequery);
2446 WRITE_LOCATION_FIELD(location);
2447 WRITE_BOOL_FIELD(cterecursive);
2448 WRITE_INT_FIELD(cterefcount);
2449 WRITE_NODE_FIELD(ctecolnames);
2450 WRITE_NODE_FIELD(ctecoltypes);
2451 WRITE_NODE_FIELD(ctecoltypmods);
2452 WRITE_NODE_FIELD(ctecolcollations);
2456 _outRangeTableSample(StringInfo str, const RangeTableSample *node)
2458 WRITE_NODE_TYPE("RANGETABLESAMPLE");
2460 WRITE_NODE_FIELD(relation);
2461 WRITE_STRING_FIELD(method);
2462 WRITE_NODE_FIELD(repeatable);
2463 WRITE_NODE_FIELD(args);
2467 _outTableSampleClause(StringInfo str, const TableSampleClause *node)
2469 WRITE_NODE_TYPE("TABLESAMPLECLAUSE");
2471 WRITE_OID_FIELD(tsmid);
2472 WRITE_BOOL_FIELD(tsmseqscan);
2473 WRITE_BOOL_FIELD(tsmpagemode);
2474 WRITE_OID_FIELD(tsminit);
2475 WRITE_OID_FIELD(tsmnextblock);
2476 WRITE_OID_FIELD(tsmnexttuple);
2477 WRITE_OID_FIELD(tsmexaminetuple);
2478 WRITE_OID_FIELD(tsmend);
2479 WRITE_OID_FIELD(tsmreset);
2480 WRITE_OID_FIELD(tsmcost);
2481 WRITE_NODE_FIELD(repeatable);
2482 WRITE_NODE_FIELD(args);
2486 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
2488 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2490 WRITE_ENUM_FIELD(op, SetOperation);
2491 WRITE_BOOL_FIELD(all);
2492 WRITE_NODE_FIELD(larg);
2493 WRITE_NODE_FIELD(rarg);
2494 WRITE_NODE_FIELD(colTypes);
2495 WRITE_NODE_FIELD(colTypmods);
2496 WRITE_NODE_FIELD(colCollations);
2497 WRITE_NODE_FIELD(groupClauses);
2501 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
2503 WRITE_NODE_TYPE("RTE");
2505 /* put alias + eref first to make dump more legible */
2506 WRITE_NODE_FIELD(alias);
2507 WRITE_NODE_FIELD(eref);
2508 WRITE_ENUM_FIELD(rtekind, RTEKind);
2510 switch (node->rtekind)
2513 WRITE_OID_FIELD(relid);
2514 WRITE_CHAR_FIELD(relkind);
2515 WRITE_NODE_FIELD(tablesample);
2518 WRITE_NODE_FIELD(subquery);
2519 WRITE_BOOL_FIELD(security_barrier);
2522 WRITE_ENUM_FIELD(jointype, JoinType);
2523 WRITE_NODE_FIELD(joinaliasvars);
2526 WRITE_NODE_FIELD(functions);
2527 WRITE_BOOL_FIELD(funcordinality);
2530 WRITE_NODE_FIELD(values_lists);
2531 WRITE_NODE_FIELD(values_collations);
2534 WRITE_STRING_FIELD(ctename);
2535 WRITE_UINT_FIELD(ctelevelsup);
2536 WRITE_BOOL_FIELD(self_reference);
2537 WRITE_NODE_FIELD(ctecoltypes);
2538 WRITE_NODE_FIELD(ctecoltypmods);
2539 WRITE_NODE_FIELD(ctecolcollations);
2542 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2546 WRITE_BOOL_FIELD(lateral);
2547 WRITE_BOOL_FIELD(inh);
2548 WRITE_BOOL_FIELD(inFromCl);
2549 WRITE_UINT_FIELD(requiredPerms);
2550 WRITE_OID_FIELD(checkAsUser);
2551 WRITE_BITMAPSET_FIELD(selectedCols);
2552 WRITE_BITMAPSET_FIELD(insertedCols);
2553 WRITE_BITMAPSET_FIELD(updatedCols);
2554 WRITE_NODE_FIELD(securityQuals);
2558 _outRangeTblFunction(StringInfo str, const RangeTblFunction *node)
2560 WRITE_NODE_TYPE("RANGETBLFUNCTION");
2562 WRITE_NODE_FIELD(funcexpr);
2563 WRITE_INT_FIELD(funccolcount);
2564 WRITE_NODE_FIELD(funccolnames);
2565 WRITE_NODE_FIELD(funccoltypes);
2566 WRITE_NODE_FIELD(funccoltypmods);
2567 WRITE_NODE_FIELD(funccolcollations);
2568 WRITE_BITMAPSET_FIELD(funcparams);
2572 _outAExpr(StringInfo str, const A_Expr *node)
2574 WRITE_NODE_TYPE("AEXPR");
2579 appendStringInfoChar(str, ' ');
2580 WRITE_NODE_FIELD(name);
2583 appendStringInfoChar(str, ' ');
2584 WRITE_NODE_FIELD(name);
2585 appendStringInfoString(str, " ANY ");
2588 appendStringInfoChar(str, ' ');
2589 WRITE_NODE_FIELD(name);
2590 appendStringInfoString(str, " ALL ");
2592 case AEXPR_DISTINCT:
2593 appendStringInfoString(str, " DISTINCT ");
2594 WRITE_NODE_FIELD(name);
2597 appendStringInfoString(str, " NULLIF ");
2598 WRITE_NODE_FIELD(name);
2601 appendStringInfoString(str, " OF ");
2602 WRITE_NODE_FIELD(name);
2605 appendStringInfoString(str, " IN ");
2606 WRITE_NODE_FIELD(name);
2609 appendStringInfoString(str, " LIKE ");
2610 WRITE_NODE_FIELD(name);
2613 appendStringInfoString(str, " ILIKE ");
2614 WRITE_NODE_FIELD(name);
2617 appendStringInfoString(str, " SIMILAR ");
2618 WRITE_NODE_FIELD(name);
2621 appendStringInfoString(str, " BETWEEN ");
2622 WRITE_NODE_FIELD(name);
2624 case AEXPR_NOT_BETWEEN:
2625 appendStringInfoString(str, " NOT_BETWEEN ");
2626 WRITE_NODE_FIELD(name);
2628 case AEXPR_BETWEEN_SYM:
2629 appendStringInfoString(str, " BETWEEN_SYM ");
2630 WRITE_NODE_FIELD(name);
2632 case AEXPR_NOT_BETWEEN_SYM:
2633 appendStringInfoString(str, " NOT_BETWEEN_SYM ");
2634 WRITE_NODE_FIELD(name);
2637 appendStringInfoString(str, " PAREN");
2640 appendStringInfoString(str, " ??");
2644 WRITE_NODE_FIELD(lexpr);
2645 WRITE_NODE_FIELD(rexpr);
2646 WRITE_LOCATION_FIELD(location);
2650 _outValue(StringInfo str, const Value *value)
2652 switch (value->type)
2655 appendStringInfo(str, "%ld", value->val.ival);
2660 * We assume the value is a valid numeric literal and so does not
2663 appendStringInfoString(str, value->val.str);
2668 * We use _outToken to provide escaping of the string's content,
2669 * but we don't want it to do anything with an empty string.
2671 appendStringInfoChar(str, '"');
2672 if (value->val.str[0] != '\0')
2673 _outToken(str, value->val.str);
2674 appendStringInfoChar(str, '"');
2677 /* internal representation already has leading 'b' */
2678 appendStringInfoString(str, value->val.str);
2681 /* this is seen only within A_Const, not in transformed trees */
2682 appendStringInfoString(str, "NULL");
2685 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2691 _outColumnRef(StringInfo str, const ColumnRef *node)
2693 WRITE_NODE_TYPE("COLUMNREF");
2695 WRITE_NODE_FIELD(fields);
2696 WRITE_LOCATION_FIELD(location);
2700 _outParamRef(StringInfo str, const ParamRef *node)
2702 WRITE_NODE_TYPE("PARAMREF");
2704 WRITE_INT_FIELD(number);
2705 WRITE_LOCATION_FIELD(location);
2709 _outAConst(StringInfo str, const A_Const *node)
2711 WRITE_NODE_TYPE("A_CONST");
2713 appendStringInfoString(str, " :val ");
2714 _outValue(str, &(node->val));
2715 WRITE_LOCATION_FIELD(location);
2719 _outA_Star(StringInfo str, const A_Star *node)
2721 WRITE_NODE_TYPE("A_STAR");
2725 _outA_Indices(StringInfo str, const A_Indices *node)
2727 WRITE_NODE_TYPE("A_INDICES");
2729 WRITE_NODE_FIELD(lidx);
2730 WRITE_NODE_FIELD(uidx);
2734 _outA_Indirection(StringInfo str, const A_Indirection *node)
2736 WRITE_NODE_TYPE("A_INDIRECTION");
2738 WRITE_NODE_FIELD(arg);
2739 WRITE_NODE_FIELD(indirection);
2743 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
2745 WRITE_NODE_TYPE("A_ARRAYEXPR");
2747 WRITE_NODE_FIELD(elements);
2748 WRITE_LOCATION_FIELD(location);
2752 _outResTarget(StringInfo str, const ResTarget *node)
2754 WRITE_NODE_TYPE("RESTARGET");
2756 WRITE_STRING_FIELD(name);
2757 WRITE_NODE_FIELD(indirection);
2758 WRITE_NODE_FIELD(val);
2759 WRITE_LOCATION_FIELD(location);
2763 _outMultiAssignRef(StringInfo str, const MultiAssignRef *node)
2765 WRITE_NODE_TYPE("MULTIASSIGNREF");
2767 WRITE_NODE_FIELD(source);
2768 WRITE_INT_FIELD(colno);
2769 WRITE_INT_FIELD(ncolumns);
2773 _outSortBy(StringInfo str, const SortBy *node)
2775 WRITE_NODE_TYPE("SORTBY");
2777 WRITE_NODE_FIELD(node);
2778 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2779 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2780 WRITE_NODE_FIELD(useOp);
2781 WRITE_LOCATION_FIELD(location);
2785 _outWindowDef(StringInfo str, const WindowDef *node)
2787 WRITE_NODE_TYPE("WINDOWDEF");
2789 WRITE_STRING_FIELD(name);
2790 WRITE_STRING_FIELD(refname);
2791 WRITE_NODE_FIELD(partitionClause);
2792 WRITE_NODE_FIELD(orderClause);
2793 WRITE_INT_FIELD(frameOptions);
2794 WRITE_NODE_FIELD(startOffset);
2795 WRITE_NODE_FIELD(endOffset);
2796 WRITE_LOCATION_FIELD(location);
2800 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
2802 WRITE_NODE_TYPE("RANGESUBSELECT");
2804 WRITE_BOOL_FIELD(lateral);
2805 WRITE_NODE_FIELD(subquery);
2806 WRITE_NODE_FIELD(alias);
2810 _outRangeFunction(StringInfo str, const RangeFunction *node)
2812 WRITE_NODE_TYPE("RANGEFUNCTION");
2814 WRITE_BOOL_FIELD(lateral);
2815 WRITE_BOOL_FIELD(ordinality);
2816 WRITE_BOOL_FIELD(is_rowsfrom);
2817 WRITE_NODE_FIELD(functions);
2818 WRITE_NODE_FIELD(alias);
2819 WRITE_NODE_FIELD(coldeflist);
2823 _outConstraint(StringInfo str, const Constraint *node)
2825 WRITE_NODE_TYPE("CONSTRAINT");
2827 WRITE_STRING_FIELD(conname);
2828 WRITE_BOOL_FIELD(deferrable);
2829 WRITE_BOOL_FIELD(initdeferred);
2830 WRITE_LOCATION_FIELD(location);
2832 appendStringInfoString(str, " :contype ");
2833 switch (node->contype)
2836 appendStringInfoString(str, "NULL");
2839 case CONSTR_NOTNULL:
2840 appendStringInfoString(str, "NOT_NULL");
2843 case CONSTR_DEFAULT:
2844 appendStringInfoString(str, "DEFAULT");
2845 WRITE_NODE_FIELD(raw_expr);
2846 WRITE_STRING_FIELD(cooked_expr);
2850 appendStringInfoString(str, "CHECK");
2851 WRITE_BOOL_FIELD(is_no_inherit);
2852 WRITE_NODE_FIELD(raw_expr);
2853 WRITE_STRING_FIELD(cooked_expr);
2856 case CONSTR_PRIMARY:
2857 appendStringInfoString(str, "PRIMARY_KEY");
2858 WRITE_NODE_FIELD(keys);
2859 WRITE_NODE_FIELD(options);
2860 WRITE_STRING_FIELD(indexname);
2861 WRITE_STRING_FIELD(indexspace);
2862 /* access_method and where_clause not currently used */
2866 appendStringInfoString(str, "UNIQUE");
2867 WRITE_NODE_FIELD(keys);
2868 WRITE_NODE_FIELD(options);
2869 WRITE_STRING_FIELD(indexname);
2870 WRITE_STRING_FIELD(indexspace);
2871 /* access_method and where_clause not currently used */
2874 case CONSTR_EXCLUSION:
2875 appendStringInfoString(str, "EXCLUSION");
2876 WRITE_NODE_FIELD(exclusions);
2877 WRITE_NODE_FIELD(options);
2878 WRITE_STRING_FIELD(indexname);
2879 WRITE_STRING_FIELD(indexspace);
2880 WRITE_STRING_FIELD(access_method);
2881 WRITE_NODE_FIELD(where_clause);
2884 case CONSTR_FOREIGN:
2885 appendStringInfoString(str, "FOREIGN_KEY");
2886 WRITE_NODE_FIELD(pktable);
2887 WRITE_NODE_FIELD(fk_attrs);
2888 WRITE_NODE_FIELD(pk_attrs);
2889 WRITE_CHAR_FIELD(fk_matchtype);
2890 WRITE_CHAR_FIELD(fk_upd_action);
2891 WRITE_CHAR_FIELD(fk_del_action);
2892 WRITE_NODE_FIELD(old_conpfeqop);
2893 WRITE_OID_FIELD(old_pktable_oid);
2894 WRITE_BOOL_FIELD(skip_validation);
2895 WRITE_BOOL_FIELD(initially_valid);
2898 case CONSTR_ATTR_DEFERRABLE:
2899 appendStringInfoString(str, "ATTR_DEFERRABLE");
2902 case CONSTR_ATTR_NOT_DEFERRABLE:
2903 appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
2906 case CONSTR_ATTR_DEFERRED:
2907 appendStringInfoString(str, "ATTR_DEFERRED");
2910 case CONSTR_ATTR_IMMEDIATE:
2911 appendStringInfoString(str, "ATTR_IMMEDIATE");
2915 appendStringInfo(str, "<unrecognized_constraint %d>",
2916 (int) node->contype);
2924 * converts a Node into ascii string and append it to 'str'
2927 _outNode(StringInfo str, const void *obj)
2930 appendStringInfoString(str, "<>");
2931 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2933 else if (IsA(obj, Integer) ||
2936 IsA(obj, BitString))
2938 /* nodeRead does not want to see { } around these! */
2939 _outValue(str, obj);
2943 appendStringInfoChar(str, '{');
2944 switch (nodeTag(obj))
2947 _outPlannedStmt(str, obj);
2953 _outResult(str, obj);
2956 _outModifyTable(str, obj);
2959 _outAppend(str, obj);
2962 _outMergeAppend(str, obj);
2964 case T_RecursiveUnion:
2965 _outRecursiveUnion(str, obj);
2968 _outBitmapAnd(str, obj);
2971 _outBitmapOr(str, obj);
2977 _outSeqScan(str, obj);
2980 _outIndexScan(str, obj);
2982 case T_IndexOnlyScan:
2983 _outIndexOnlyScan(str, obj);
2985 case T_BitmapIndexScan:
2986 _outBitmapIndexScan(str, obj);
2988 case T_BitmapHeapScan:
2989 _outBitmapHeapScan(str, obj);
2992 _outTidScan(str, obj);
2994 case T_SubqueryScan:
2995 _outSubqueryScan(str, obj);
2997 case T_FunctionScan:
2998 _outFunctionScan(str, obj);
3001 _outValuesScan(str, obj);
3004 _outCteScan(str, obj);
3006 case T_WorkTableScan:
3007 _outWorkTableScan(str, obj);
3010 _outForeignScan(str, obj);
3013 _outCustomScan(str, obj);
3016 _outSampleScan(str, obj);
3022 _outNestLoop(str, obj);
3025 _outMergeJoin(str, obj);
3028 _outHashJoin(str, obj);
3034 _outWindowAgg(str, obj);
3037 _outGroup(str, obj);
3040 _outMaterial(str, obj);
3046 _outUnique(str, obj);
3052 _outSetOp(str, obj);
3055 _outLockRows(str, obj);
3058 _outLimit(str, obj);
3060 case T_NestLoopParam:
3061 _outNestLoopParam(str, obj);
3064 _outPlanRowMark(str, obj);
3066 case T_PlanInvalItem:
3067 _outPlanInvalItem(str, obj);
3070 _outAlias(str, obj);
3073 _outRangeVar(str, obj);
3076 _outIntoClause(str, obj);
3082 _outConst(str, obj);
3085 _outParam(str, obj);
3088 _outAggref(str, obj);
3091 _outWindowFunc(str, obj);
3094 _outArrayRef(str, obj);
3097 _outFuncExpr(str, obj);
3099 case T_NamedArgExpr:
3100 _outNamedArgExpr(str, obj);
3103 _outOpExpr(str, obj);
3105 case T_DistinctExpr:
3106 _outDistinctExpr(str, obj);
3109 _outNullIfExpr(str, obj);
3111 case T_ScalarArrayOpExpr:
3112 _outScalarArrayOpExpr(str, obj);
3115 _outBoolExpr(str, obj);
3118 _outSubLink(str, obj);
3121 _outSubPlan(str, obj);
3123 case T_AlternativeSubPlan:
3124 _outAlternativeSubPlan(str, obj);
3127 _outFieldSelect(str, obj);
3130 _outFieldStore(str, obj);
3133 _outRelabelType(str, obj);
3136 _outCoerceViaIO(str, obj);
3138 case T_ArrayCoerceExpr:
3139 _outArrayCoerceExpr(str, obj);
3141 case T_ConvertRowtypeExpr:
3142 _outConvertRowtypeExpr(str, obj);
3145 _outCollateExpr(str, obj);
3148 _outCaseExpr(str, obj);
3151 _outCaseWhen(str, obj);
3153 case T_CaseTestExpr:
3154 _outCaseTestExpr(str, obj);
3157 _outArrayExpr(str, obj);
3160 _outRowExpr(str, obj);
3162 case T_RowCompareExpr:
3163 _outRowCompareExpr(str, obj);
3165 case T_CoalesceExpr:
3166 _outCoalesceExpr(str, obj);
3169 _outMinMaxExpr(str, obj);
3172 _outXmlExpr(str, obj);
3175 _outNullTest(str, obj);
3178 _outBooleanTest(str, obj);
3180 case T_CoerceToDomain:
3181 _outCoerceToDomain(str, obj);
3183 case T_CoerceToDomainValue:
3184 _outCoerceToDomainValue(str, obj);
3186 case T_SetToDefault:
3187 _outSetToDefault(str, obj);
3189 case T_CurrentOfExpr:
3190 _outCurrentOfExpr(str, obj);
3192 case T_InferenceElem:
3193 _outInferenceElem(str, obj);
3196 _outTargetEntry(str, obj);
3199 _outRangeTblRef(str, obj);
3202 _outJoinExpr(str, obj);
3205 _outFromExpr(str, obj);
3207 case T_OnConflictExpr:
3208 _outOnConflictExpr(str, obj);
3214 _outIndexPath(str, obj);
3216 case T_BitmapHeapPath:
3217 _outBitmapHeapPath(str, obj);
3219 case T_BitmapAndPath:
3220 _outBitmapAndPath(str, obj);
3222 case T_BitmapOrPath:
3223 _outBitmapOrPath(str, obj);
3226 _outTidPath(str, obj);
3229 _outForeignPath(str, obj);
3232 _outCustomPath(str, obj);
3235 _outAppendPath(str, obj);
3237 case T_MergeAppendPath:
3238 _outMergeAppendPath(str, obj);
3241 _outResultPath(str, obj);
3243 case T_MaterialPath:
3244 _outMaterialPath(str, obj);
3247 _outUniquePath(str, obj);
3250 _outNestPath(str, obj);
3253 _outMergePath(str, obj);
3256 _outHashPath(str, obj);
3258 case T_PlannerGlobal:
3259 _outPlannerGlobal(str, obj);
3262 _outPlannerInfo(str, obj);
3265 _outRelOptInfo(str, obj);
3267 case T_IndexOptInfo:
3268 _outIndexOptInfo(str, obj);
3270 case T_EquivalenceClass:
3271 _outEquivalenceClass(str, obj);
3273 case T_EquivalenceMember:
3274 _outEquivalenceMember(str, obj);
3277 _outPathKey(str, obj);
3279 case T_ParamPathInfo:
3280 _outParamPathInfo(str, obj);
3282 case T_RestrictInfo:
3283 _outRestrictInfo(str, obj);
3285 case T_PlaceHolderVar:
3286 _outPlaceHolderVar(str, obj);
3288 case T_SpecialJoinInfo:
3289 _outSpecialJoinInfo(str, obj);
3291 case T_LateralJoinInfo:
3292 _outLateralJoinInfo(str, obj);
3294 case T_AppendRelInfo:
3295 _outAppendRelInfo(str, obj);
3297 case T_PlaceHolderInfo:
3298 _outPlaceHolderInfo(str, obj);
3300 case T_MinMaxAggInfo:
3301 _outMinMaxAggInfo(str, obj);
3303 case T_PlannerParamItem:
3304 _outPlannerParamItem(str, obj);
3308 _outCreateStmt(str, obj);
3310 case T_CreateForeignTableStmt:
3311 _outCreateForeignTableStmt(str, obj);
3313 case T_ImportForeignSchemaStmt:
3314 _outImportForeignSchemaStmt(str, obj);
3317 _outIndexStmt(str, obj);
3320 _outNotifyStmt(str, obj);
3322 case T_DeclareCursorStmt:
3323 _outDeclareCursorStmt(str, obj);
3326 _outSelectStmt(str, obj);
3329 _outColumnDef(str, obj);
3332 _outTypeName(str, obj);
3335 _outTypeCast(str, obj);
3337 case T_CollateClause:
3338 _outCollateClause(str, obj);
3341 _outIndexElem(str, obj);
3344 _outQuery(str, obj);
3346 case T_WithCheckOption:
3347 _outWithCheckOption(str, obj);
3349 case T_SortGroupClause:
3350 _outSortGroupClause(str, obj);
3352 case T_WindowClause:
3353 _outWindowClause(str, obj);
3355 case T_RowMarkClause:
3356 _outRowMarkClause(str, obj);
3359 _outWithClause(str, obj);
3361 case T_CommonTableExpr:
3362 _outCommonTableExpr(str, obj);
3364 case T_RangeTableSample:
3365 _outRangeTableSample(str, obj);
3367 case T_TableSampleClause:
3368 _outTableSampleClause(str, obj);
3370 case T_SetOperationStmt:
3371 _outSetOperationStmt(str, obj);
3373 case T_RangeTblEntry:
3374 _outRangeTblEntry(str, obj);
3376 case T_RangeTblFunction:
3377 _outRangeTblFunction(str, obj);
3380 _outAExpr(str, obj);
3383 _outColumnRef(str, obj);
3386 _outParamRef(str, obj);
3389 _outAConst(str, obj);
3392 _outA_Star(str, obj);
3395 _outA_Indices(str, obj);
3397 case T_A_Indirection:
3398 _outA_Indirection(str, obj);
3401 _outA_ArrayExpr(str, obj);
3404 _outResTarget(str, obj);
3406 case T_MultiAssignRef:
3407 _outMultiAssignRef(str, obj);
3410 _outSortBy(str, obj);
3413 _outWindowDef(str, obj);
3415 case T_RangeSubselect:
3416 _outRangeSubselect(str, obj);
3418 case T_RangeFunction:
3419 _outRangeFunction(str, obj);
3422 _outConstraint(str, obj);
3425 _outFuncCall(str, obj);
3428 _outDefElem(str, obj);
3430 case T_TableLikeClause:
3431 _outTableLikeClause(str, obj);
3433 case T_LockingClause:
3434 _outLockingClause(str, obj);
3436 case T_XmlSerialize:
3437 _outXmlSerialize(str, obj);
3443 * This should be an ERROR, but it's too useful to be able to
3444 * dump structures that _outNode only understands part of.
3446 elog(WARNING, "could not dump unrecognized node type: %d",
3447 (int) nodeTag(obj));
3450 appendStringInfoChar(str, '}');
3456 * returns the ascii representation of the Node as a palloc'd string
3459 nodeToString(const void *obj)
3463 /* see stringinfo.h for an explanation of this maneuver */
3464 initStringInfo(&str);
3465 _outNode(&str, obj);