1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2018, 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). In addition, plan nodes should have input and
17 * output functions so that they can be sent to parallel workers.
18 * For use in debugging, we also provide output functions for nodes
19 * that appear in raw parsetrees and path. These nodes however need
20 * not have input functions.
22 *-------------------------------------------------------------------------
28 #include "lib/stringinfo.h"
29 #include "nodes/extensible.h"
30 #include "nodes/plannodes.h"
31 #include "nodes/relation.h"
32 #include "utils/datum.h"
33 #include "utils/rel.h"
35 static void outChar(StringInfo str, char c);
39 * Macros to simplify output of different kinds of fields. Use these
40 * wherever possible to reduce the chance for silly typos. Note that these
41 * hard-wire conventions about the names of the local variables in an Out
45 /* Write the label for the node type */
46 #define WRITE_NODE_TYPE(nodelabel) \
47 appendStringInfoString(str, nodelabel)
49 /* Write an integer field (anything written as ":fldname %d") */
50 #define WRITE_INT_FIELD(fldname) \
51 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
53 /* Write an unsigned integer field (anything written as ":fldname %u") */
54 #define WRITE_UINT_FIELD(fldname) \
55 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
57 /* Write an unsigned integer field (anything written with UINT64_FORMAT) */
58 #define WRITE_UINT64_FIELD(fldname) \
59 appendStringInfo(str, " :" CppAsString(fldname) " " UINT64_FORMAT, \
62 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
63 #define WRITE_OID_FIELD(fldname) \
64 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
66 /* Write a long-integer field */
67 #define WRITE_LONG_FIELD(fldname) \
68 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
70 /* Write a char field (ie, one ascii character) */
71 #define WRITE_CHAR_FIELD(fldname) \
72 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
73 outChar(str, node->fldname))
75 /* Write an enumerated-type field as an integer code */
76 #define WRITE_ENUM_FIELD(fldname, enumtype) \
77 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
80 /* Write a float field --- caller must give format to define precision */
81 #define WRITE_FLOAT_FIELD(fldname,format) \
82 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
84 /* Write a boolean field */
85 #define WRITE_BOOL_FIELD(fldname) \
86 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
87 booltostr(node->fldname))
89 /* Write a character-string (possibly NULL) field */
90 #define WRITE_STRING_FIELD(fldname) \
91 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
92 outToken(str, node->fldname))
94 /* Write a parse location field (actually same as INT case) */
95 #define WRITE_LOCATION_FIELD(fldname) \
96 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
98 /* Write a Node field */
99 #define WRITE_NODE_FIELD(fldname) \
100 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
101 outNode(str, node->fldname))
103 /* Write a bitmapset field */
104 #define WRITE_BITMAPSET_FIELD(fldname) \
105 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
106 outBitmapset(str, node->fldname))
109 #define booltostr(x) ((x) ? "true" : "false")
114 * Convert an ordinary string (eg, an identifier) into a form that
115 * will be decoded back to a plain token by read.c's functions.
117 * If a null or empty string is given, it is encoded as "<>".
120 outToken(StringInfo str, const char *s)
122 if (s == NULL || *s == '\0')
124 appendStringInfoString(str, "<>");
129 * Look for characters or patterns that are treated specially by read.c
130 * (either in pg_strtok() or in nodeRead()), and therefore need a
131 * protective backslash.
133 /* These characters only need to be quoted at the start of the string */
136 isdigit((unsigned char) *s) ||
137 ((*s == '+' || *s == '-') &&
138 (isdigit((unsigned char) s[1]) || s[1] == '.')))
139 appendStringInfoChar(str, '\\');
142 /* These chars must be backslashed anywhere in the string */
143 if (*s == ' ' || *s == '\n' || *s == '\t' ||
144 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
146 appendStringInfoChar(str, '\\');
147 appendStringInfoChar(str, *s++);
152 * Convert one char. Goes through outToken() so that special characters are
156 outChar(StringInfo str, char c)
167 _outList(StringInfo str, const List *node)
171 appendStringInfoChar(str, '(');
173 if (IsA(node, IntList))
174 appendStringInfoChar(str, 'i');
175 else if (IsA(node, OidList))
176 appendStringInfoChar(str, 'o');
181 * For the sake of backward compatibility, we emit a slightly
182 * different whitespace format for lists of nodes vs. other types of
183 * lists. XXX: is this necessary?
187 outNode(str, lfirst(lc));
189 appendStringInfoChar(str, ' ');
191 else if (IsA(node, IntList))
192 appendStringInfo(str, " %d", lfirst_int(lc));
193 else if (IsA(node, OidList))
194 appendStringInfo(str, " %u", lfirst_oid(lc));
196 elog(ERROR, "unrecognized list node type: %d",
200 appendStringInfoChar(str, ')');
205 * converts a bitmap set of integers
207 * Note: the output format is "(b int int ...)", similar to an integer List.
210 outBitmapset(StringInfo str, const Bitmapset *bms)
214 appendStringInfoChar(str, '(');
215 appendStringInfoChar(str, 'b');
217 while ((x = bms_next_member(bms, x)) >= 0)
218 appendStringInfo(str, " %d", x);
219 appendStringInfoChar(str, ')');
223 * Print the value of a Datum given its type.
226 outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
232 length = datumGetSize(value, typbyval, typlen);
236 s = (char *) (&value);
237 appendStringInfo(str, "%u [ ", (unsigned int) length);
238 for (i = 0; i < (Size) sizeof(Datum); i++)
239 appendStringInfo(str, "%d ", (int) (s[i]));
240 appendStringInfoChar(str, ']');
244 s = (char *) DatumGetPointer(value);
245 if (!PointerIsValid(s))
246 appendStringInfoString(str, "0 [ ]");
249 appendStringInfo(str, "%u [ ", (unsigned int) length);
250 for (i = 0; i < length; i++)
251 appendStringInfo(str, "%d ", (int) (s[i]));
252 appendStringInfoChar(str, ']');
259 * Stuff from plannodes.h
263 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
265 WRITE_NODE_TYPE("PLANNEDSTMT");
267 WRITE_ENUM_FIELD(commandType, CmdType);
268 WRITE_UINT64_FIELD(queryId);
269 WRITE_BOOL_FIELD(hasReturning);
270 WRITE_BOOL_FIELD(hasModifyingCTE);
271 WRITE_BOOL_FIELD(canSetTag);
272 WRITE_BOOL_FIELD(transientPlan);
273 WRITE_BOOL_FIELD(dependsOnRole);
274 WRITE_BOOL_FIELD(parallelModeNeeded);
275 WRITE_BOOL_FIELD(jitFlags);
276 WRITE_NODE_FIELD(planTree);
277 WRITE_NODE_FIELD(rtable);
278 WRITE_NODE_FIELD(resultRelations);
279 WRITE_NODE_FIELD(nonleafResultRelations);
280 WRITE_NODE_FIELD(rootResultRelations);
281 WRITE_NODE_FIELD(subplans);
282 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
283 WRITE_NODE_FIELD(rowMarks);
284 WRITE_NODE_FIELD(relationOids);
285 WRITE_NODE_FIELD(invalItems);
286 WRITE_NODE_FIELD(paramExecTypes);
287 WRITE_NODE_FIELD(utilityStmt);
288 WRITE_LOCATION_FIELD(stmt_location);
289 WRITE_LOCATION_FIELD(stmt_len);
293 * print the basic stuff of all nodes that inherit from Plan
296 _outPlanInfo(StringInfo str, const Plan *node)
298 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
299 WRITE_FLOAT_FIELD(total_cost, "%.2f");
300 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
301 WRITE_INT_FIELD(plan_width);
302 WRITE_BOOL_FIELD(parallel_aware);
303 WRITE_BOOL_FIELD(parallel_safe);
304 WRITE_INT_FIELD(plan_node_id);
305 WRITE_NODE_FIELD(targetlist);
306 WRITE_NODE_FIELD(qual);
307 WRITE_NODE_FIELD(lefttree);
308 WRITE_NODE_FIELD(righttree);
309 WRITE_NODE_FIELD(initPlan);
310 WRITE_BITMAPSET_FIELD(extParam);
311 WRITE_BITMAPSET_FIELD(allParam);
315 * print the basic stuff of all nodes that inherit from Scan
318 _outScanInfo(StringInfo str, const Scan *node)
320 _outPlanInfo(str, (const Plan *) node);
322 WRITE_UINT_FIELD(scanrelid);
326 * print the basic stuff of all nodes that inherit from Join
329 _outJoinPlanInfo(StringInfo str, const Join *node)
331 _outPlanInfo(str, (const Plan *) node);
333 WRITE_ENUM_FIELD(jointype, JoinType);
334 WRITE_BOOL_FIELD(inner_unique);
335 WRITE_NODE_FIELD(joinqual);
340 _outPlan(StringInfo str, const Plan *node)
342 WRITE_NODE_TYPE("PLAN");
344 _outPlanInfo(str, (const Plan *) node);
348 _outResult(StringInfo str, const Result *node)
350 WRITE_NODE_TYPE("RESULT");
352 _outPlanInfo(str, (const Plan *) node);
354 WRITE_NODE_FIELD(resconstantqual);
358 _outProjectSet(StringInfo str, const ProjectSet *node)
360 WRITE_NODE_TYPE("PROJECTSET");
362 _outPlanInfo(str, (const Plan *) node);
366 _outModifyTable(StringInfo str, const ModifyTable *node)
368 WRITE_NODE_TYPE("MODIFYTABLE");
370 _outPlanInfo(str, (const Plan *) node);
372 WRITE_ENUM_FIELD(operation, CmdType);
373 WRITE_BOOL_FIELD(canSetTag);
374 WRITE_UINT_FIELD(nominalRelation);
375 WRITE_NODE_FIELD(partitioned_rels);
376 WRITE_BOOL_FIELD(partColsUpdated);
377 WRITE_NODE_FIELD(resultRelations);
378 WRITE_INT_FIELD(mergeTargetRelation);
379 WRITE_INT_FIELD(resultRelIndex);
380 WRITE_INT_FIELD(rootResultRelIndex);
381 WRITE_NODE_FIELD(plans);
382 WRITE_NODE_FIELD(withCheckOptionLists);
383 WRITE_NODE_FIELD(returningLists);
384 WRITE_NODE_FIELD(fdwPrivLists);
385 WRITE_BITMAPSET_FIELD(fdwDirectModifyPlans);
386 WRITE_NODE_FIELD(rowMarks);
387 WRITE_INT_FIELD(epqParam);
388 WRITE_ENUM_FIELD(onConflictAction, OnConflictAction);
389 WRITE_NODE_FIELD(arbiterIndexes);
390 WRITE_NODE_FIELD(onConflictSet);
391 WRITE_NODE_FIELD(onConflictWhere);
392 WRITE_UINT_FIELD(exclRelRTI);
393 WRITE_NODE_FIELD(exclRelTlist);
394 WRITE_NODE_FIELD(mergeSourceTargetList);
395 WRITE_NODE_FIELD(mergeActionList);
399 _outMergeWhenClause(StringInfo str, const MergeWhenClause *node)
401 WRITE_NODE_TYPE("MERGEWHENCLAUSE");
403 WRITE_BOOL_FIELD(matched);
404 WRITE_ENUM_FIELD(commandType, CmdType);
405 WRITE_NODE_FIELD(condition);
406 WRITE_NODE_FIELD(targetList);
407 WRITE_NODE_FIELD(cols);
408 WRITE_NODE_FIELD(values);
409 WRITE_ENUM_FIELD(override, OverridingKind);
413 _outAppend(StringInfo str, const Append *node)
415 WRITE_NODE_TYPE("APPEND");
417 _outPlanInfo(str, (const Plan *) node);
419 WRITE_NODE_FIELD(partitioned_rels);
420 WRITE_NODE_FIELD(appendplans);
421 WRITE_INT_FIELD(first_partial_plan);
425 _outMergeAppend(StringInfo str, const MergeAppend *node)
429 WRITE_NODE_TYPE("MERGEAPPEND");
431 _outPlanInfo(str, (const Plan *) node);
433 WRITE_NODE_FIELD(partitioned_rels);
434 WRITE_NODE_FIELD(mergeplans);
436 WRITE_INT_FIELD(numCols);
438 appendStringInfoString(str, " :sortColIdx");
439 for (i = 0; i < node->numCols; i++)
440 appendStringInfo(str, " %d", node->sortColIdx[i]);
442 appendStringInfoString(str, " :sortOperators");
443 for (i = 0; i < node->numCols; i++)
444 appendStringInfo(str, " %u", node->sortOperators[i]);
446 appendStringInfoString(str, " :collations");
447 for (i = 0; i < node->numCols; i++)
448 appendStringInfo(str, " %u", node->collations[i]);
450 appendStringInfoString(str, " :nullsFirst");
451 for (i = 0; i < node->numCols; i++)
452 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
456 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
460 WRITE_NODE_TYPE("RECURSIVEUNION");
462 _outPlanInfo(str, (const Plan *) node);
464 WRITE_INT_FIELD(wtParam);
465 WRITE_INT_FIELD(numCols);
467 appendStringInfoString(str, " :dupColIdx");
468 for (i = 0; i < node->numCols; i++)
469 appendStringInfo(str, " %d", node->dupColIdx[i]);
471 appendStringInfoString(str, " :dupOperators");
472 for (i = 0; i < node->numCols; i++)
473 appendStringInfo(str, " %u", node->dupOperators[i]);
475 WRITE_LONG_FIELD(numGroups);
479 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
481 WRITE_NODE_TYPE("BITMAPAND");
483 _outPlanInfo(str, (const Plan *) node);
485 WRITE_NODE_FIELD(bitmapplans);
489 _outBitmapOr(StringInfo str, const BitmapOr *node)
491 WRITE_NODE_TYPE("BITMAPOR");
493 _outPlanInfo(str, (const Plan *) node);
495 WRITE_BOOL_FIELD(isshared);
496 WRITE_NODE_FIELD(bitmapplans);
500 _outGather(StringInfo str, const Gather *node)
502 WRITE_NODE_TYPE("GATHER");
504 _outPlanInfo(str, (const Plan *) node);
506 WRITE_INT_FIELD(num_workers);
507 WRITE_INT_FIELD(rescan_param);
508 WRITE_BOOL_FIELD(single_copy);
509 WRITE_BOOL_FIELD(invisible);
510 WRITE_BITMAPSET_FIELD(initParam);
514 _outGatherMerge(StringInfo str, const GatherMerge *node)
518 WRITE_NODE_TYPE("GATHERMERGE");
520 _outPlanInfo(str, (const Plan *) node);
522 WRITE_INT_FIELD(num_workers);
523 WRITE_INT_FIELD(rescan_param);
524 WRITE_INT_FIELD(numCols);
526 appendStringInfoString(str, " :sortColIdx");
527 for (i = 0; i < node->numCols; i++)
528 appendStringInfo(str, " %d", node->sortColIdx[i]);
530 appendStringInfoString(str, " :sortOperators");
531 for (i = 0; i < node->numCols; i++)
532 appendStringInfo(str, " %u", node->sortOperators[i]);
534 appendStringInfoString(str, " :collations");
535 for (i = 0; i < node->numCols; i++)
536 appendStringInfo(str, " %u", node->collations[i]);
538 appendStringInfoString(str, " :nullsFirst");
539 for (i = 0; i < node->numCols; i++)
540 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
542 WRITE_BITMAPSET_FIELD(initParam);
546 _outScan(StringInfo str, const Scan *node)
548 WRITE_NODE_TYPE("SCAN");
550 _outScanInfo(str, node);
554 _outSeqScan(StringInfo str, const SeqScan *node)
556 WRITE_NODE_TYPE("SEQSCAN");
558 _outScanInfo(str, (const Scan *) node);
562 _outSampleScan(StringInfo str, const SampleScan *node)
564 WRITE_NODE_TYPE("SAMPLESCAN");
566 _outScanInfo(str, (const Scan *) node);
568 WRITE_NODE_FIELD(tablesample);
572 _outIndexScan(StringInfo str, const IndexScan *node)
574 WRITE_NODE_TYPE("INDEXSCAN");
576 _outScanInfo(str, (const Scan *) node);
578 WRITE_OID_FIELD(indexid);
579 WRITE_NODE_FIELD(indexqual);
580 WRITE_NODE_FIELD(indexqualorig);
581 WRITE_NODE_FIELD(indexorderby);
582 WRITE_NODE_FIELD(indexorderbyorig);
583 WRITE_NODE_FIELD(indexorderbyops);
584 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
588 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
590 WRITE_NODE_TYPE("INDEXONLYSCAN");
592 _outScanInfo(str, (const Scan *) node);
594 WRITE_OID_FIELD(indexid);
595 WRITE_NODE_FIELD(indexqual);
596 WRITE_NODE_FIELD(indexorderby);
597 WRITE_NODE_FIELD(indextlist);
598 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
602 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
604 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
606 _outScanInfo(str, (const Scan *) node);
608 WRITE_OID_FIELD(indexid);
609 WRITE_BOOL_FIELD(isshared);
610 WRITE_NODE_FIELD(indexqual);
611 WRITE_NODE_FIELD(indexqualorig);
615 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
617 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
619 _outScanInfo(str, (const Scan *) node);
621 WRITE_NODE_FIELD(bitmapqualorig);
625 _outTidScan(StringInfo str, const TidScan *node)
627 WRITE_NODE_TYPE("TIDSCAN");
629 _outScanInfo(str, (const Scan *) node);
631 WRITE_NODE_FIELD(tidquals);
635 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
637 WRITE_NODE_TYPE("SUBQUERYSCAN");
639 _outScanInfo(str, (const Scan *) node);
641 WRITE_NODE_FIELD(subplan);
645 _outFunctionScan(StringInfo str, const FunctionScan *node)
647 WRITE_NODE_TYPE("FUNCTIONSCAN");
649 _outScanInfo(str, (const Scan *) node);
651 WRITE_NODE_FIELD(functions);
652 WRITE_BOOL_FIELD(funcordinality);
656 _outTableFuncScan(StringInfo str, const TableFuncScan *node)
658 WRITE_NODE_TYPE("TABLEFUNCSCAN");
660 _outScanInfo(str, (const Scan *) node);
662 WRITE_NODE_FIELD(tablefunc);
666 _outValuesScan(StringInfo str, const ValuesScan *node)
668 WRITE_NODE_TYPE("VALUESSCAN");
670 _outScanInfo(str, (const Scan *) node);
672 WRITE_NODE_FIELD(values_lists);
676 _outCteScan(StringInfo str, const CteScan *node)
678 WRITE_NODE_TYPE("CTESCAN");
680 _outScanInfo(str, (const Scan *) node);
682 WRITE_INT_FIELD(ctePlanId);
683 WRITE_INT_FIELD(cteParam);
687 _outNamedTuplestoreScan(StringInfo str, const NamedTuplestoreScan *node)
689 WRITE_NODE_TYPE("NAMEDTUPLESTORESCAN");
691 _outScanInfo(str, (const Scan *) node);
693 WRITE_STRING_FIELD(enrname);
697 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
699 WRITE_NODE_TYPE("WORKTABLESCAN");
701 _outScanInfo(str, (const Scan *) node);
703 WRITE_INT_FIELD(wtParam);
707 _outForeignScan(StringInfo str, const ForeignScan *node)
709 WRITE_NODE_TYPE("FOREIGNSCAN");
711 _outScanInfo(str, (const Scan *) node);
713 WRITE_ENUM_FIELD(operation, CmdType);
714 WRITE_OID_FIELD(fs_server);
715 WRITE_NODE_FIELD(fdw_exprs);
716 WRITE_NODE_FIELD(fdw_private);
717 WRITE_NODE_FIELD(fdw_scan_tlist);
718 WRITE_NODE_FIELD(fdw_recheck_quals);
719 WRITE_BITMAPSET_FIELD(fs_relids);
720 WRITE_BOOL_FIELD(fsSystemCol);
724 _outCustomScan(StringInfo str, const CustomScan *node)
726 WRITE_NODE_TYPE("CUSTOMSCAN");
728 _outScanInfo(str, (const Scan *) node);
730 WRITE_UINT_FIELD(flags);
731 WRITE_NODE_FIELD(custom_plans);
732 WRITE_NODE_FIELD(custom_exprs);
733 WRITE_NODE_FIELD(custom_private);
734 WRITE_NODE_FIELD(custom_scan_tlist);
735 WRITE_BITMAPSET_FIELD(custom_relids);
736 /* CustomName is a key to lookup CustomScanMethods */
737 appendStringInfoString(str, " :methods ");
738 outToken(str, node->methods->CustomName);
742 _outJoin(StringInfo str, const Join *node)
744 WRITE_NODE_TYPE("JOIN");
746 _outJoinPlanInfo(str, (const Join *) node);
750 _outNestLoop(StringInfo str, const NestLoop *node)
752 WRITE_NODE_TYPE("NESTLOOP");
754 _outJoinPlanInfo(str, (const Join *) node);
756 WRITE_NODE_FIELD(nestParams);
760 _outMergeJoin(StringInfo str, const MergeJoin *node)
765 WRITE_NODE_TYPE("MERGEJOIN");
767 _outJoinPlanInfo(str, (const Join *) node);
769 WRITE_BOOL_FIELD(skip_mark_restore);
770 WRITE_NODE_FIELD(mergeclauses);
772 numCols = list_length(node->mergeclauses);
774 appendStringInfoString(str, " :mergeFamilies");
775 for (i = 0; i < numCols; i++)
776 appendStringInfo(str, " %u", node->mergeFamilies[i]);
778 appendStringInfoString(str, " :mergeCollations");
779 for (i = 0; i < numCols; i++)
780 appendStringInfo(str, " %u", node->mergeCollations[i]);
782 appendStringInfoString(str, " :mergeStrategies");
783 for (i = 0; i < numCols; i++)
784 appendStringInfo(str, " %d", node->mergeStrategies[i]);
786 appendStringInfoString(str, " :mergeNullsFirst");
787 for (i = 0; i < numCols; i++)
788 appendStringInfo(str, " %s", booltostr(node->mergeNullsFirst[i]));
792 _outHashJoin(StringInfo str, const HashJoin *node)
794 WRITE_NODE_TYPE("HASHJOIN");
796 _outJoinPlanInfo(str, (const Join *) node);
798 WRITE_NODE_FIELD(hashclauses);
802 _outAgg(StringInfo str, const Agg *node)
806 WRITE_NODE_TYPE("AGG");
808 _outPlanInfo(str, (const Plan *) node);
810 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
811 WRITE_ENUM_FIELD(aggsplit, AggSplit);
812 WRITE_INT_FIELD(numCols);
814 appendStringInfoString(str, " :grpColIdx");
815 for (i = 0; i < node->numCols; i++)
816 appendStringInfo(str, " %d", node->grpColIdx[i]);
818 appendStringInfoString(str, " :grpOperators");
819 for (i = 0; i < node->numCols; i++)
820 appendStringInfo(str, " %u", node->grpOperators[i]);
822 WRITE_LONG_FIELD(numGroups);
823 WRITE_BITMAPSET_FIELD(aggParams);
824 WRITE_NODE_FIELD(groupingSets);
825 WRITE_NODE_FIELD(chain);
829 _outWindowAgg(StringInfo str, const WindowAgg *node)
833 WRITE_NODE_TYPE("WINDOWAGG");
835 _outPlanInfo(str, (const Plan *) node);
837 WRITE_UINT_FIELD(winref);
838 WRITE_INT_FIELD(partNumCols);
840 appendStringInfoString(str, " :partColIdx");
841 for (i = 0; i < node->partNumCols; i++)
842 appendStringInfo(str, " %d", node->partColIdx[i]);
844 appendStringInfoString(str, " :partOperations");
845 for (i = 0; i < node->partNumCols; i++)
846 appendStringInfo(str, " %u", node->partOperators[i]);
848 WRITE_INT_FIELD(ordNumCols);
850 appendStringInfoString(str, " :ordColIdx");
851 for (i = 0; i < node->ordNumCols; i++)
852 appendStringInfo(str, " %d", node->ordColIdx[i]);
854 appendStringInfoString(str, " :ordOperations");
855 for (i = 0; i < node->ordNumCols; i++)
856 appendStringInfo(str, " %u", node->ordOperators[i]);
858 WRITE_INT_FIELD(frameOptions);
859 WRITE_NODE_FIELD(startOffset);
860 WRITE_NODE_FIELD(endOffset);
861 WRITE_OID_FIELD(startInRangeFunc);
862 WRITE_OID_FIELD(endInRangeFunc);
863 WRITE_OID_FIELD(inRangeColl);
864 WRITE_BOOL_FIELD(inRangeAsc);
865 WRITE_BOOL_FIELD(inRangeNullsFirst);
869 _outGroup(StringInfo str, const Group *node)
873 WRITE_NODE_TYPE("GROUP");
875 _outPlanInfo(str, (const Plan *) node);
877 WRITE_INT_FIELD(numCols);
879 appendStringInfoString(str, " :grpColIdx");
880 for (i = 0; i < node->numCols; i++)
881 appendStringInfo(str, " %d", node->grpColIdx[i]);
883 appendStringInfoString(str, " :grpOperators");
884 for (i = 0; i < node->numCols; i++)
885 appendStringInfo(str, " %u", node->grpOperators[i]);
889 _outMaterial(StringInfo str, const Material *node)
891 WRITE_NODE_TYPE("MATERIAL");
893 _outPlanInfo(str, (const Plan *) node);
897 _outSort(StringInfo str, const Sort *node)
901 WRITE_NODE_TYPE("SORT");
903 _outPlanInfo(str, (const Plan *) node);
905 WRITE_INT_FIELD(numCols);
907 appendStringInfoString(str, " :sortColIdx");
908 for (i = 0; i < node->numCols; i++)
909 appendStringInfo(str, " %d", node->sortColIdx[i]);
911 appendStringInfoString(str, " :sortOperators");
912 for (i = 0; i < node->numCols; i++)
913 appendStringInfo(str, " %u", node->sortOperators[i]);
915 appendStringInfoString(str, " :collations");
916 for (i = 0; i < node->numCols; i++)
917 appendStringInfo(str, " %u", node->collations[i]);
919 appendStringInfoString(str, " :nullsFirst");
920 for (i = 0; i < node->numCols; i++)
921 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
925 _outUnique(StringInfo str, const Unique *node)
929 WRITE_NODE_TYPE("UNIQUE");
931 _outPlanInfo(str, (const Plan *) node);
933 WRITE_INT_FIELD(numCols);
935 appendStringInfoString(str, " :uniqColIdx");
936 for (i = 0; i < node->numCols; i++)
937 appendStringInfo(str, " %d", node->uniqColIdx[i]);
939 appendStringInfoString(str, " :uniqOperators");
940 for (i = 0; i < node->numCols; i++)
941 appendStringInfo(str, " %u", node->uniqOperators[i]);
945 _outHash(StringInfo str, const Hash *node)
947 WRITE_NODE_TYPE("HASH");
949 _outPlanInfo(str, (const Plan *) node);
951 WRITE_OID_FIELD(skewTable);
952 WRITE_INT_FIELD(skewColumn);
953 WRITE_BOOL_FIELD(skewInherit);
954 WRITE_FLOAT_FIELD(rows_total, "%.0f");
958 _outSetOp(StringInfo str, const SetOp *node)
962 WRITE_NODE_TYPE("SETOP");
964 _outPlanInfo(str, (const Plan *) node);
966 WRITE_ENUM_FIELD(cmd, SetOpCmd);
967 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
968 WRITE_INT_FIELD(numCols);
970 appendStringInfoString(str, " :dupColIdx");
971 for (i = 0; i < node->numCols; i++)
972 appendStringInfo(str, " %d", node->dupColIdx[i]);
974 appendStringInfoString(str, " :dupOperators");
975 for (i = 0; i < node->numCols; i++)
976 appendStringInfo(str, " %u", node->dupOperators[i]);
978 WRITE_INT_FIELD(flagColIdx);
979 WRITE_INT_FIELD(firstFlag);
980 WRITE_LONG_FIELD(numGroups);
984 _outLockRows(StringInfo str, const LockRows *node)
986 WRITE_NODE_TYPE("LOCKROWS");
988 _outPlanInfo(str, (const Plan *) node);
990 WRITE_NODE_FIELD(rowMarks);
991 WRITE_INT_FIELD(epqParam);
995 _outLimit(StringInfo str, const Limit *node)
997 WRITE_NODE_TYPE("LIMIT");
999 _outPlanInfo(str, (const Plan *) node);
1001 WRITE_NODE_FIELD(limitOffset);
1002 WRITE_NODE_FIELD(limitCount);
1006 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
1008 WRITE_NODE_TYPE("NESTLOOPPARAM");
1010 WRITE_INT_FIELD(paramno);
1011 WRITE_NODE_FIELD(paramval);
1015 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
1017 WRITE_NODE_TYPE("PLANROWMARK");
1019 WRITE_UINT_FIELD(rti);
1020 WRITE_UINT_FIELD(prti);
1021 WRITE_UINT_FIELD(rowmarkId);
1022 WRITE_ENUM_FIELD(markType, RowMarkType);
1023 WRITE_INT_FIELD(allMarkTypes);
1024 WRITE_ENUM_FIELD(strength, LockClauseStrength);
1025 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
1026 WRITE_BOOL_FIELD(isParent);
1030 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
1032 WRITE_NODE_TYPE("PLANINVALITEM");
1034 WRITE_INT_FIELD(cacheId);
1035 WRITE_UINT_FIELD(hashValue);
1038 /*****************************************************************************
1040 * Stuff from primnodes.h.
1042 *****************************************************************************/
1045 _outAlias(StringInfo str, const Alias *node)
1047 WRITE_NODE_TYPE("ALIAS");
1049 WRITE_STRING_FIELD(aliasname);
1050 WRITE_NODE_FIELD(colnames);
1054 _outRangeVar(StringInfo str, const RangeVar *node)
1056 WRITE_NODE_TYPE("RANGEVAR");
1059 * we deliberately ignore catalogname here, since it is presently not
1060 * semantically meaningful
1062 WRITE_STRING_FIELD(schemaname);
1063 WRITE_STRING_FIELD(relname);
1064 WRITE_BOOL_FIELD(inh);
1065 WRITE_CHAR_FIELD(relpersistence);
1066 WRITE_NODE_FIELD(alias);
1067 WRITE_LOCATION_FIELD(location);
1071 _outTableFunc(StringInfo str, const TableFunc *node)
1073 WRITE_NODE_TYPE("TABLEFUNC");
1075 WRITE_NODE_FIELD(ns_uris);
1076 WRITE_NODE_FIELD(ns_names);
1077 WRITE_NODE_FIELD(docexpr);
1078 WRITE_NODE_FIELD(rowexpr);
1079 WRITE_NODE_FIELD(colnames);
1080 WRITE_NODE_FIELD(coltypes);
1081 WRITE_NODE_FIELD(coltypmods);
1082 WRITE_NODE_FIELD(colcollations);
1083 WRITE_NODE_FIELD(colexprs);
1084 WRITE_NODE_FIELD(coldefexprs);
1085 WRITE_BITMAPSET_FIELD(notnulls);
1086 WRITE_INT_FIELD(ordinalitycol);
1087 WRITE_LOCATION_FIELD(location);
1091 _outIntoClause(StringInfo str, const IntoClause *node)
1093 WRITE_NODE_TYPE("INTOCLAUSE");
1095 WRITE_NODE_FIELD(rel);
1096 WRITE_NODE_FIELD(colNames);
1097 WRITE_NODE_FIELD(options);
1098 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
1099 WRITE_STRING_FIELD(tableSpaceName);
1100 WRITE_NODE_FIELD(viewQuery);
1101 WRITE_BOOL_FIELD(skipData);
1105 _outVar(StringInfo str, const Var *node)
1107 WRITE_NODE_TYPE("VAR");
1109 WRITE_UINT_FIELD(varno);
1110 WRITE_INT_FIELD(varattno);
1111 WRITE_OID_FIELD(vartype);
1112 WRITE_INT_FIELD(vartypmod);
1113 WRITE_OID_FIELD(varcollid);
1114 WRITE_UINT_FIELD(varlevelsup);
1115 WRITE_UINT_FIELD(varnoold);
1116 WRITE_INT_FIELD(varoattno);
1117 WRITE_LOCATION_FIELD(location);
1121 _outConst(StringInfo str, const Const *node)
1123 WRITE_NODE_TYPE("CONST");
1125 WRITE_OID_FIELD(consttype);
1126 WRITE_INT_FIELD(consttypmod);
1127 WRITE_OID_FIELD(constcollid);
1128 WRITE_INT_FIELD(constlen);
1129 WRITE_BOOL_FIELD(constbyval);
1130 WRITE_BOOL_FIELD(constisnull);
1131 WRITE_LOCATION_FIELD(location);
1133 appendStringInfoString(str, " :constvalue ");
1134 if (node->constisnull)
1135 appendStringInfoString(str, "<>");
1137 outDatum(str, node->constvalue, node->constlen, node->constbyval);
1141 _outParam(StringInfo str, const Param *node)
1143 WRITE_NODE_TYPE("PARAM");
1145 WRITE_ENUM_FIELD(paramkind, ParamKind);
1146 WRITE_INT_FIELD(paramid);
1147 WRITE_OID_FIELD(paramtype);
1148 WRITE_INT_FIELD(paramtypmod);
1149 WRITE_OID_FIELD(paramcollid);
1150 WRITE_LOCATION_FIELD(location);
1154 _outAggref(StringInfo str, const Aggref *node)
1156 WRITE_NODE_TYPE("AGGREF");
1158 WRITE_OID_FIELD(aggfnoid);
1159 WRITE_OID_FIELD(aggtype);
1160 WRITE_OID_FIELD(aggcollid);
1161 WRITE_OID_FIELD(inputcollid);
1162 WRITE_OID_FIELD(aggtranstype);
1163 WRITE_NODE_FIELD(aggargtypes);
1164 WRITE_NODE_FIELD(aggdirectargs);
1165 WRITE_NODE_FIELD(args);
1166 WRITE_NODE_FIELD(aggorder);
1167 WRITE_NODE_FIELD(aggdistinct);
1168 WRITE_NODE_FIELD(aggfilter);
1169 WRITE_BOOL_FIELD(aggstar);
1170 WRITE_BOOL_FIELD(aggvariadic);
1171 WRITE_CHAR_FIELD(aggkind);
1172 WRITE_UINT_FIELD(agglevelsup);
1173 WRITE_ENUM_FIELD(aggsplit, AggSplit);
1174 WRITE_LOCATION_FIELD(location);
1178 _outGroupingFunc(StringInfo str, const GroupingFunc *node)
1180 WRITE_NODE_TYPE("GROUPINGFUNC");
1182 WRITE_NODE_FIELD(args);
1183 WRITE_NODE_FIELD(refs);
1184 WRITE_NODE_FIELD(cols);
1185 WRITE_UINT_FIELD(agglevelsup);
1186 WRITE_LOCATION_FIELD(location);
1190 _outWindowFunc(StringInfo str, const WindowFunc *node)
1192 WRITE_NODE_TYPE("WINDOWFUNC");
1194 WRITE_OID_FIELD(winfnoid);
1195 WRITE_OID_FIELD(wintype);
1196 WRITE_OID_FIELD(wincollid);
1197 WRITE_OID_FIELD(inputcollid);
1198 WRITE_NODE_FIELD(args);
1199 WRITE_NODE_FIELD(aggfilter);
1200 WRITE_UINT_FIELD(winref);
1201 WRITE_BOOL_FIELD(winstar);
1202 WRITE_BOOL_FIELD(winagg);
1203 WRITE_LOCATION_FIELD(location);
1207 _outArrayRef(StringInfo str, const ArrayRef *node)
1209 WRITE_NODE_TYPE("ARRAYREF");
1211 WRITE_OID_FIELD(refarraytype);
1212 WRITE_OID_FIELD(refelemtype);
1213 WRITE_INT_FIELD(reftypmod);
1214 WRITE_OID_FIELD(refcollid);
1215 WRITE_NODE_FIELD(refupperindexpr);
1216 WRITE_NODE_FIELD(reflowerindexpr);
1217 WRITE_NODE_FIELD(refexpr);
1218 WRITE_NODE_FIELD(refassgnexpr);
1222 _outFuncExpr(StringInfo str, const FuncExpr *node)
1224 WRITE_NODE_TYPE("FUNCEXPR");
1226 WRITE_OID_FIELD(funcid);
1227 WRITE_OID_FIELD(funcresulttype);
1228 WRITE_BOOL_FIELD(funcretset);
1229 WRITE_BOOL_FIELD(funcvariadic);
1230 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1231 WRITE_OID_FIELD(funccollid);
1232 WRITE_OID_FIELD(inputcollid);
1233 WRITE_NODE_FIELD(args);
1234 WRITE_LOCATION_FIELD(location);
1238 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1240 WRITE_NODE_TYPE("NAMEDARGEXPR");
1242 WRITE_NODE_FIELD(arg);
1243 WRITE_STRING_FIELD(name);
1244 WRITE_INT_FIELD(argnumber);
1245 WRITE_LOCATION_FIELD(location);
1249 _outOpExpr(StringInfo str, const OpExpr *node)
1251 WRITE_NODE_TYPE("OPEXPR");
1253 WRITE_OID_FIELD(opno);
1254 WRITE_OID_FIELD(opfuncid);
1255 WRITE_OID_FIELD(opresulttype);
1256 WRITE_BOOL_FIELD(opretset);
1257 WRITE_OID_FIELD(opcollid);
1258 WRITE_OID_FIELD(inputcollid);
1259 WRITE_NODE_FIELD(args);
1260 WRITE_LOCATION_FIELD(location);
1264 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1266 WRITE_NODE_TYPE("DISTINCTEXPR");
1268 WRITE_OID_FIELD(opno);
1269 WRITE_OID_FIELD(opfuncid);
1270 WRITE_OID_FIELD(opresulttype);
1271 WRITE_BOOL_FIELD(opretset);
1272 WRITE_OID_FIELD(opcollid);
1273 WRITE_OID_FIELD(inputcollid);
1274 WRITE_NODE_FIELD(args);
1275 WRITE_LOCATION_FIELD(location);
1279 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1281 WRITE_NODE_TYPE("NULLIFEXPR");
1283 WRITE_OID_FIELD(opno);
1284 WRITE_OID_FIELD(opfuncid);
1285 WRITE_OID_FIELD(opresulttype);
1286 WRITE_BOOL_FIELD(opretset);
1287 WRITE_OID_FIELD(opcollid);
1288 WRITE_OID_FIELD(inputcollid);
1289 WRITE_NODE_FIELD(args);
1290 WRITE_LOCATION_FIELD(location);
1294 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1296 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1298 WRITE_OID_FIELD(opno);
1299 WRITE_OID_FIELD(opfuncid);
1300 WRITE_BOOL_FIELD(useOr);
1301 WRITE_OID_FIELD(inputcollid);
1302 WRITE_NODE_FIELD(args);
1303 WRITE_LOCATION_FIELD(location);
1307 _outBoolExpr(StringInfo str, const BoolExpr *node)
1311 WRITE_NODE_TYPE("BOOLEXPR");
1313 /* do-it-yourself enum representation */
1314 switch (node->boolop)
1326 appendStringInfoString(str, " :boolop ");
1327 outToken(str, opstr);
1329 WRITE_NODE_FIELD(args);
1330 WRITE_LOCATION_FIELD(location);
1334 _outSubLink(StringInfo str, const SubLink *node)
1336 WRITE_NODE_TYPE("SUBLINK");
1338 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1339 WRITE_INT_FIELD(subLinkId);
1340 WRITE_NODE_FIELD(testexpr);
1341 WRITE_NODE_FIELD(operName);
1342 WRITE_NODE_FIELD(subselect);
1343 WRITE_LOCATION_FIELD(location);
1347 _outSubPlan(StringInfo str, const SubPlan *node)
1349 WRITE_NODE_TYPE("SUBPLAN");
1351 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1352 WRITE_NODE_FIELD(testexpr);
1353 WRITE_NODE_FIELD(paramIds);
1354 WRITE_INT_FIELD(plan_id);
1355 WRITE_STRING_FIELD(plan_name);
1356 WRITE_OID_FIELD(firstColType);
1357 WRITE_INT_FIELD(firstColTypmod);
1358 WRITE_OID_FIELD(firstColCollation);
1359 WRITE_BOOL_FIELD(useHashTable);
1360 WRITE_BOOL_FIELD(unknownEqFalse);
1361 WRITE_BOOL_FIELD(parallel_safe);
1362 WRITE_NODE_FIELD(setParam);
1363 WRITE_NODE_FIELD(parParam);
1364 WRITE_NODE_FIELD(args);
1365 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1366 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1370 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1372 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1374 WRITE_NODE_FIELD(subplans);
1378 _outFieldSelect(StringInfo str, const FieldSelect *node)
1380 WRITE_NODE_TYPE("FIELDSELECT");
1382 WRITE_NODE_FIELD(arg);
1383 WRITE_INT_FIELD(fieldnum);
1384 WRITE_OID_FIELD(resulttype);
1385 WRITE_INT_FIELD(resulttypmod);
1386 WRITE_OID_FIELD(resultcollid);
1390 _outFieldStore(StringInfo str, const FieldStore *node)
1392 WRITE_NODE_TYPE("FIELDSTORE");
1394 WRITE_NODE_FIELD(arg);
1395 WRITE_NODE_FIELD(newvals);
1396 WRITE_NODE_FIELD(fieldnums);
1397 WRITE_OID_FIELD(resulttype);
1401 _outRelabelType(StringInfo str, const RelabelType *node)
1403 WRITE_NODE_TYPE("RELABELTYPE");
1405 WRITE_NODE_FIELD(arg);
1406 WRITE_OID_FIELD(resulttype);
1407 WRITE_INT_FIELD(resulttypmod);
1408 WRITE_OID_FIELD(resultcollid);
1409 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1410 WRITE_LOCATION_FIELD(location);
1414 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1416 WRITE_NODE_TYPE("COERCEVIAIO");
1418 WRITE_NODE_FIELD(arg);
1419 WRITE_OID_FIELD(resulttype);
1420 WRITE_OID_FIELD(resultcollid);
1421 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1422 WRITE_LOCATION_FIELD(location);
1426 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1428 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1430 WRITE_NODE_FIELD(arg);
1431 WRITE_NODE_FIELD(elemexpr);
1432 WRITE_OID_FIELD(resulttype);
1433 WRITE_INT_FIELD(resulttypmod);
1434 WRITE_OID_FIELD(resultcollid);
1435 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1436 WRITE_LOCATION_FIELD(location);
1440 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1442 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1444 WRITE_NODE_FIELD(arg);
1445 WRITE_OID_FIELD(resulttype);
1446 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1447 WRITE_LOCATION_FIELD(location);
1451 _outCollateExpr(StringInfo str, const CollateExpr *node)
1453 WRITE_NODE_TYPE("COLLATE");
1455 WRITE_NODE_FIELD(arg);
1456 WRITE_OID_FIELD(collOid);
1457 WRITE_LOCATION_FIELD(location);
1461 _outCaseExpr(StringInfo str, const CaseExpr *node)
1463 WRITE_NODE_TYPE("CASE");
1465 WRITE_OID_FIELD(casetype);
1466 WRITE_OID_FIELD(casecollid);
1467 WRITE_NODE_FIELD(arg);
1468 WRITE_NODE_FIELD(args);
1469 WRITE_NODE_FIELD(defresult);
1470 WRITE_LOCATION_FIELD(location);
1474 _outCaseWhen(StringInfo str, const CaseWhen *node)
1476 WRITE_NODE_TYPE("WHEN");
1478 WRITE_NODE_FIELD(expr);
1479 WRITE_NODE_FIELD(result);
1480 WRITE_LOCATION_FIELD(location);
1484 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1486 WRITE_NODE_TYPE("CASETESTEXPR");
1488 WRITE_OID_FIELD(typeId);
1489 WRITE_INT_FIELD(typeMod);
1490 WRITE_OID_FIELD(collation);
1494 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1496 WRITE_NODE_TYPE("ARRAY");
1498 WRITE_OID_FIELD(array_typeid);
1499 WRITE_OID_FIELD(array_collid);
1500 WRITE_OID_FIELD(element_typeid);
1501 WRITE_NODE_FIELD(elements);
1502 WRITE_BOOL_FIELD(multidims);
1503 WRITE_LOCATION_FIELD(location);
1507 _outRowExpr(StringInfo str, const RowExpr *node)
1509 WRITE_NODE_TYPE("ROW");
1511 WRITE_NODE_FIELD(args);
1512 WRITE_OID_FIELD(row_typeid);
1513 WRITE_ENUM_FIELD(row_format, CoercionForm);
1514 WRITE_NODE_FIELD(colnames);
1515 WRITE_LOCATION_FIELD(location);
1519 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1521 WRITE_NODE_TYPE("ROWCOMPARE");
1523 WRITE_ENUM_FIELD(rctype, RowCompareType);
1524 WRITE_NODE_FIELD(opnos);
1525 WRITE_NODE_FIELD(opfamilies);
1526 WRITE_NODE_FIELD(inputcollids);
1527 WRITE_NODE_FIELD(largs);
1528 WRITE_NODE_FIELD(rargs);
1532 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1534 WRITE_NODE_TYPE("COALESCE");
1536 WRITE_OID_FIELD(coalescetype);
1537 WRITE_OID_FIELD(coalescecollid);
1538 WRITE_NODE_FIELD(args);
1539 WRITE_LOCATION_FIELD(location);
1543 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1545 WRITE_NODE_TYPE("MINMAX");
1547 WRITE_OID_FIELD(minmaxtype);
1548 WRITE_OID_FIELD(minmaxcollid);
1549 WRITE_OID_FIELD(inputcollid);
1550 WRITE_ENUM_FIELD(op, MinMaxOp);
1551 WRITE_NODE_FIELD(args);
1552 WRITE_LOCATION_FIELD(location);
1556 _outSQLValueFunction(StringInfo str, const SQLValueFunction *node)
1558 WRITE_NODE_TYPE("SQLVALUEFUNCTION");
1560 WRITE_ENUM_FIELD(op, SQLValueFunctionOp);
1561 WRITE_OID_FIELD(type);
1562 WRITE_INT_FIELD(typmod);
1563 WRITE_LOCATION_FIELD(location);
1567 _outXmlExpr(StringInfo str, const XmlExpr *node)
1569 WRITE_NODE_TYPE("XMLEXPR");
1571 WRITE_ENUM_FIELD(op, XmlExprOp);
1572 WRITE_STRING_FIELD(name);
1573 WRITE_NODE_FIELD(named_args);
1574 WRITE_NODE_FIELD(arg_names);
1575 WRITE_NODE_FIELD(args);
1576 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1577 WRITE_OID_FIELD(type);
1578 WRITE_INT_FIELD(typmod);
1579 WRITE_LOCATION_FIELD(location);
1583 _outNullTest(StringInfo str, const NullTest *node)
1585 WRITE_NODE_TYPE("NULLTEST");
1587 WRITE_NODE_FIELD(arg);
1588 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1589 WRITE_BOOL_FIELD(argisrow);
1590 WRITE_LOCATION_FIELD(location);
1594 _outBooleanTest(StringInfo str, const BooleanTest *node)
1596 WRITE_NODE_TYPE("BOOLEANTEST");
1598 WRITE_NODE_FIELD(arg);
1599 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1600 WRITE_LOCATION_FIELD(location);
1604 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1606 WRITE_NODE_TYPE("COERCETODOMAIN");
1608 WRITE_NODE_FIELD(arg);
1609 WRITE_OID_FIELD(resulttype);
1610 WRITE_INT_FIELD(resulttypmod);
1611 WRITE_OID_FIELD(resultcollid);
1612 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1613 WRITE_LOCATION_FIELD(location);
1617 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1619 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1621 WRITE_OID_FIELD(typeId);
1622 WRITE_INT_FIELD(typeMod);
1623 WRITE_OID_FIELD(collation);
1624 WRITE_LOCATION_FIELD(location);
1628 _outSetToDefault(StringInfo str, const SetToDefault *node)
1630 WRITE_NODE_TYPE("SETTODEFAULT");
1632 WRITE_OID_FIELD(typeId);
1633 WRITE_INT_FIELD(typeMod);
1634 WRITE_OID_FIELD(collation);
1635 WRITE_LOCATION_FIELD(location);
1639 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1641 WRITE_NODE_TYPE("CURRENTOFEXPR");
1643 WRITE_UINT_FIELD(cvarno);
1644 WRITE_STRING_FIELD(cursor_name);
1645 WRITE_INT_FIELD(cursor_param);
1649 _outNextValueExpr(StringInfo str, const NextValueExpr *node)
1651 WRITE_NODE_TYPE("NEXTVALUEEXPR");
1653 WRITE_OID_FIELD(seqid);
1654 WRITE_OID_FIELD(typeId);
1658 _outInferenceElem(StringInfo str, const InferenceElem *node)
1660 WRITE_NODE_TYPE("INFERENCEELEM");
1662 WRITE_NODE_FIELD(expr);
1663 WRITE_OID_FIELD(infercollid);
1664 WRITE_OID_FIELD(inferopclass);
1668 _outTargetEntry(StringInfo str, const TargetEntry *node)
1670 WRITE_NODE_TYPE("TARGETENTRY");
1672 WRITE_NODE_FIELD(expr);
1673 WRITE_INT_FIELD(resno);
1674 WRITE_STRING_FIELD(resname);
1675 WRITE_UINT_FIELD(ressortgroupref);
1676 WRITE_OID_FIELD(resorigtbl);
1677 WRITE_INT_FIELD(resorigcol);
1678 WRITE_BOOL_FIELD(resjunk);
1682 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1684 WRITE_NODE_TYPE("RANGETBLREF");
1686 WRITE_INT_FIELD(rtindex);
1690 _outJoinExpr(StringInfo str, const JoinExpr *node)
1692 WRITE_NODE_TYPE("JOINEXPR");
1694 WRITE_ENUM_FIELD(jointype, JoinType);
1695 WRITE_BOOL_FIELD(isNatural);
1696 WRITE_NODE_FIELD(larg);
1697 WRITE_NODE_FIELD(rarg);
1698 WRITE_NODE_FIELD(usingClause);
1699 WRITE_NODE_FIELD(quals);
1700 WRITE_NODE_FIELD(alias);
1701 WRITE_INT_FIELD(rtindex);
1705 _outFromExpr(StringInfo str, const FromExpr *node)
1707 WRITE_NODE_TYPE("FROMEXPR");
1709 WRITE_NODE_FIELD(fromlist);
1710 WRITE_NODE_FIELD(quals);
1714 _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
1716 WRITE_NODE_TYPE("ONCONFLICTEXPR");
1718 WRITE_ENUM_FIELD(action, OnConflictAction);
1719 WRITE_NODE_FIELD(arbiterElems);
1720 WRITE_NODE_FIELD(arbiterWhere);
1721 WRITE_OID_FIELD(constraint);
1722 WRITE_NODE_FIELD(onConflictSet);
1723 WRITE_NODE_FIELD(onConflictWhere);
1724 WRITE_INT_FIELD(exclRelIndex);
1725 WRITE_NODE_FIELD(exclRelTlist);
1729 _outMergeAction(StringInfo str, const MergeAction *node)
1731 WRITE_NODE_TYPE("MERGEACTION");
1733 WRITE_BOOL_FIELD(matched);
1734 WRITE_ENUM_FIELD(commandType, CmdType);
1735 WRITE_NODE_FIELD(qual);
1736 WRITE_NODE_FIELD(targetList);
1739 /*****************************************************************************
1741 * Stuff from relation.h.
1743 *****************************************************************************/
1746 * print the basic stuff of all nodes that inherit from Path
1748 * Note we do NOT print the parent, else we'd be in infinite recursion.
1749 * We can print the parent's relids for identification purposes, though.
1750 * We print the pathtarget only if it's not the default one for the rel.
1751 * We also do not print the whole of param_info, since it's printed by
1752 * _outRelOptInfo; it's sufficient and less cluttering to print just the
1753 * required outer relids.
1756 _outPathInfo(StringInfo str, const Path *node)
1758 WRITE_ENUM_FIELD(pathtype, NodeTag);
1759 appendStringInfoString(str, " :parent_relids ");
1760 outBitmapset(str, node->parent->relids);
1761 if (node->pathtarget != node->parent->reltarget)
1762 WRITE_NODE_FIELD(pathtarget);
1763 appendStringInfoString(str, " :required_outer ");
1764 if (node->param_info)
1765 outBitmapset(str, node->param_info->ppi_req_outer);
1767 outBitmapset(str, NULL);
1768 WRITE_BOOL_FIELD(parallel_aware);
1769 WRITE_BOOL_FIELD(parallel_safe);
1770 WRITE_INT_FIELD(parallel_workers);
1771 WRITE_FLOAT_FIELD(rows, "%.0f");
1772 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1773 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1774 WRITE_NODE_FIELD(pathkeys);
1778 * print the basic stuff of all nodes that inherit from JoinPath
1781 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1783 _outPathInfo(str, (const Path *) node);
1785 WRITE_ENUM_FIELD(jointype, JoinType);
1786 WRITE_BOOL_FIELD(inner_unique);
1787 WRITE_NODE_FIELD(outerjoinpath);
1788 WRITE_NODE_FIELD(innerjoinpath);
1789 WRITE_NODE_FIELD(joinrestrictinfo);
1793 _outPath(StringInfo str, const Path *node)
1795 WRITE_NODE_TYPE("PATH");
1797 _outPathInfo(str, (const Path *) node);
1801 _outIndexPath(StringInfo str, const IndexPath *node)
1803 WRITE_NODE_TYPE("INDEXPATH");
1805 _outPathInfo(str, (const Path *) node);
1807 WRITE_NODE_FIELD(indexinfo);
1808 WRITE_NODE_FIELD(indexclauses);
1809 WRITE_NODE_FIELD(indexquals);
1810 WRITE_NODE_FIELD(indexqualcols);
1811 WRITE_NODE_FIELD(indexorderbys);
1812 WRITE_NODE_FIELD(indexorderbycols);
1813 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1814 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1815 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1819 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1821 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1823 _outPathInfo(str, (const Path *) node);
1825 WRITE_NODE_FIELD(bitmapqual);
1829 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1831 WRITE_NODE_TYPE("BITMAPANDPATH");
1833 _outPathInfo(str, (const Path *) node);
1835 WRITE_NODE_FIELD(bitmapquals);
1836 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1840 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1842 WRITE_NODE_TYPE("BITMAPORPATH");
1844 _outPathInfo(str, (const Path *) node);
1846 WRITE_NODE_FIELD(bitmapquals);
1847 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1851 _outTidPath(StringInfo str, const TidPath *node)
1853 WRITE_NODE_TYPE("TIDPATH");
1855 _outPathInfo(str, (const Path *) node);
1857 WRITE_NODE_FIELD(tidquals);
1861 _outSubqueryScanPath(StringInfo str, const SubqueryScanPath *node)
1863 WRITE_NODE_TYPE("SUBQUERYSCANPATH");
1865 _outPathInfo(str, (const Path *) node);
1867 WRITE_NODE_FIELD(subpath);
1871 _outForeignPath(StringInfo str, const ForeignPath *node)
1873 WRITE_NODE_TYPE("FOREIGNPATH");
1875 _outPathInfo(str, (const Path *) node);
1877 WRITE_NODE_FIELD(fdw_outerpath);
1878 WRITE_NODE_FIELD(fdw_private);
1882 _outCustomPath(StringInfo str, const CustomPath *node)
1884 WRITE_NODE_TYPE("CUSTOMPATH");
1886 _outPathInfo(str, (const Path *) node);
1888 WRITE_UINT_FIELD(flags);
1889 WRITE_NODE_FIELD(custom_paths);
1890 WRITE_NODE_FIELD(custom_private);
1891 appendStringInfoString(str, " :methods ");
1892 outToken(str, node->methods->CustomName);
1896 _outAppendPath(StringInfo str, const AppendPath *node)
1898 WRITE_NODE_TYPE("APPENDPATH");
1900 _outPathInfo(str, (const Path *) node);
1902 WRITE_NODE_FIELD(partitioned_rels);
1903 WRITE_NODE_FIELD(subpaths);
1907 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1909 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1911 _outPathInfo(str, (const Path *) node);
1913 WRITE_NODE_FIELD(partitioned_rels);
1914 WRITE_NODE_FIELD(subpaths);
1915 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1919 _outResultPath(StringInfo str, const ResultPath *node)
1921 WRITE_NODE_TYPE("RESULTPATH");
1923 _outPathInfo(str, (const Path *) node);
1925 WRITE_NODE_FIELD(quals);
1929 _outMaterialPath(StringInfo str, const MaterialPath *node)
1931 WRITE_NODE_TYPE("MATERIALPATH");
1933 _outPathInfo(str, (const Path *) node);
1935 WRITE_NODE_FIELD(subpath);
1939 _outUniquePath(StringInfo str, const UniquePath *node)
1941 WRITE_NODE_TYPE("UNIQUEPATH");
1943 _outPathInfo(str, (const Path *) node);
1945 WRITE_NODE_FIELD(subpath);
1946 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1947 WRITE_NODE_FIELD(in_operators);
1948 WRITE_NODE_FIELD(uniq_exprs);
1952 _outGatherPath(StringInfo str, const GatherPath *node)
1954 WRITE_NODE_TYPE("GATHERPATH");
1956 _outPathInfo(str, (const Path *) node);
1958 WRITE_NODE_FIELD(subpath);
1959 WRITE_BOOL_FIELD(single_copy);
1960 WRITE_INT_FIELD(num_workers);
1964 _outProjectionPath(StringInfo str, const ProjectionPath *node)
1966 WRITE_NODE_TYPE("PROJECTIONPATH");
1968 _outPathInfo(str, (const Path *) node);
1970 WRITE_NODE_FIELD(subpath);
1971 WRITE_BOOL_FIELD(dummypp);
1975 _outProjectSetPath(StringInfo str, const ProjectSetPath *node)
1977 WRITE_NODE_TYPE("PROJECTSETPATH");
1979 _outPathInfo(str, (const Path *) node);
1981 WRITE_NODE_FIELD(subpath);
1985 _outSortPath(StringInfo str, const SortPath *node)
1987 WRITE_NODE_TYPE("SORTPATH");
1989 _outPathInfo(str, (const Path *) node);
1991 WRITE_NODE_FIELD(subpath);
1995 _outGroupPath(StringInfo str, const GroupPath *node)
1997 WRITE_NODE_TYPE("GROUPPATH");
1999 _outPathInfo(str, (const Path *) node);
2001 WRITE_NODE_FIELD(subpath);
2002 WRITE_NODE_FIELD(groupClause);
2003 WRITE_NODE_FIELD(qual);
2007 _outUpperUniquePath(StringInfo str, const UpperUniquePath *node)
2009 WRITE_NODE_TYPE("UPPERUNIQUEPATH");
2011 _outPathInfo(str, (const Path *) node);
2013 WRITE_NODE_FIELD(subpath);
2014 WRITE_INT_FIELD(numkeys);
2018 _outAggPath(StringInfo str, const AggPath *node)
2020 WRITE_NODE_TYPE("AGGPATH");
2022 _outPathInfo(str, (const Path *) node);
2024 WRITE_NODE_FIELD(subpath);
2025 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
2026 WRITE_ENUM_FIELD(aggsplit, AggSplit);
2027 WRITE_FLOAT_FIELD(numGroups, "%.0f");
2028 WRITE_NODE_FIELD(groupClause);
2029 WRITE_NODE_FIELD(qual);
2033 _outRollupData(StringInfo str, const RollupData *node)
2035 WRITE_NODE_TYPE("ROLLUP");
2037 WRITE_NODE_FIELD(groupClause);
2038 WRITE_NODE_FIELD(gsets);
2039 WRITE_NODE_FIELD(gsets_data);
2040 WRITE_FLOAT_FIELD(numGroups, "%.0f");
2041 WRITE_BOOL_FIELD(hashable);
2042 WRITE_BOOL_FIELD(is_hashed);
2046 _outGroupingSetData(StringInfo str, const GroupingSetData *node)
2048 WRITE_NODE_TYPE("GSDATA");
2050 WRITE_NODE_FIELD(set);
2051 WRITE_FLOAT_FIELD(numGroups, "%.0f");
2055 _outGroupingSetsPath(StringInfo str, const GroupingSetsPath *node)
2057 WRITE_NODE_TYPE("GROUPINGSETSPATH");
2059 _outPathInfo(str, (const Path *) node);
2061 WRITE_NODE_FIELD(subpath);
2062 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
2063 WRITE_NODE_FIELD(rollups);
2064 WRITE_NODE_FIELD(qual);
2068 _outMinMaxAggPath(StringInfo str, const MinMaxAggPath *node)
2070 WRITE_NODE_TYPE("MINMAXAGGPATH");
2072 _outPathInfo(str, (const Path *) node);
2074 WRITE_NODE_FIELD(mmaggregates);
2075 WRITE_NODE_FIELD(quals);
2079 _outWindowAggPath(StringInfo str, const WindowAggPath *node)
2081 WRITE_NODE_TYPE("WINDOWAGGPATH");
2083 _outPathInfo(str, (const Path *) node);
2085 WRITE_NODE_FIELD(subpath);
2086 WRITE_NODE_FIELD(winclause);
2087 WRITE_NODE_FIELD(winpathkeys);
2091 _outSetOpPath(StringInfo str, const SetOpPath *node)
2093 WRITE_NODE_TYPE("SETOPPATH");
2095 _outPathInfo(str, (const Path *) node);
2097 WRITE_NODE_FIELD(subpath);
2098 WRITE_ENUM_FIELD(cmd, SetOpCmd);
2099 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
2100 WRITE_NODE_FIELD(distinctList);
2101 WRITE_INT_FIELD(flagColIdx);
2102 WRITE_INT_FIELD(firstFlag);
2103 WRITE_FLOAT_FIELD(numGroups, "%.0f");
2107 _outRecursiveUnionPath(StringInfo str, const RecursiveUnionPath *node)
2109 WRITE_NODE_TYPE("RECURSIVEUNIONPATH");
2111 _outPathInfo(str, (const Path *) node);
2113 WRITE_NODE_FIELD(leftpath);
2114 WRITE_NODE_FIELD(rightpath);
2115 WRITE_NODE_FIELD(distinctList);
2116 WRITE_INT_FIELD(wtParam);
2117 WRITE_FLOAT_FIELD(numGroups, "%.0f");
2121 _outLockRowsPath(StringInfo str, const LockRowsPath *node)
2123 WRITE_NODE_TYPE("LOCKROWSPATH");
2125 _outPathInfo(str, (const Path *) node);
2127 WRITE_NODE_FIELD(subpath);
2128 WRITE_NODE_FIELD(rowMarks);
2129 WRITE_INT_FIELD(epqParam);
2133 _outModifyTablePath(StringInfo str, const ModifyTablePath *node)
2135 WRITE_NODE_TYPE("MODIFYTABLEPATH");
2137 _outPathInfo(str, (const Path *) node);
2139 WRITE_ENUM_FIELD(operation, CmdType);
2140 WRITE_BOOL_FIELD(canSetTag);
2141 WRITE_UINT_FIELD(nominalRelation);
2142 WRITE_NODE_FIELD(partitioned_rels);
2143 WRITE_BOOL_FIELD(partColsUpdated);
2144 WRITE_NODE_FIELD(resultRelations);
2145 WRITE_INT_FIELD(mergeTargetRelation);
2146 WRITE_NODE_FIELD(subpaths);
2147 WRITE_NODE_FIELD(subroots);
2148 WRITE_NODE_FIELD(withCheckOptionLists);
2149 WRITE_NODE_FIELD(returningLists);
2150 WRITE_NODE_FIELD(rowMarks);
2151 WRITE_NODE_FIELD(onconflict);
2152 WRITE_INT_FIELD(epqParam);
2153 WRITE_NODE_FIELD(mergeSourceTargetList);
2154 WRITE_NODE_FIELD(mergeActionList);
2158 _outLimitPath(StringInfo str, const LimitPath *node)
2160 WRITE_NODE_TYPE("LIMITPATH");
2162 _outPathInfo(str, (const Path *) node);
2164 WRITE_NODE_FIELD(subpath);
2165 WRITE_NODE_FIELD(limitOffset);
2166 WRITE_NODE_FIELD(limitCount);
2170 _outGatherMergePath(StringInfo str, const GatherMergePath *node)
2172 WRITE_NODE_TYPE("GATHERMERGEPATH");
2174 _outPathInfo(str, (const Path *) node);
2176 WRITE_NODE_FIELD(subpath);
2177 WRITE_INT_FIELD(num_workers);
2181 _outNestPath(StringInfo str, const NestPath *node)
2183 WRITE_NODE_TYPE("NESTPATH");
2185 _outJoinPathInfo(str, (const JoinPath *) node);
2189 _outMergePath(StringInfo str, const MergePath *node)
2191 WRITE_NODE_TYPE("MERGEPATH");
2193 _outJoinPathInfo(str, (const JoinPath *) node);
2195 WRITE_NODE_FIELD(path_mergeclauses);
2196 WRITE_NODE_FIELD(outersortkeys);
2197 WRITE_NODE_FIELD(innersortkeys);
2198 WRITE_BOOL_FIELD(skip_mark_restore);
2199 WRITE_BOOL_FIELD(materialize_inner);
2203 _outHashPath(StringInfo str, const HashPath *node)
2205 WRITE_NODE_TYPE("HASHPATH");
2207 _outJoinPathInfo(str, (const JoinPath *) node);
2209 WRITE_NODE_FIELD(path_hashclauses);
2210 WRITE_INT_FIELD(num_batches);
2214 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
2216 WRITE_NODE_TYPE("PLANNERGLOBAL");
2218 /* NB: this isn't a complete set of fields */
2219 WRITE_NODE_FIELD(subplans);
2220 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
2221 WRITE_NODE_FIELD(finalrtable);
2222 WRITE_NODE_FIELD(finalrowmarks);
2223 WRITE_NODE_FIELD(resultRelations);
2224 WRITE_NODE_FIELD(nonleafResultRelations);
2225 WRITE_NODE_FIELD(rootResultRelations);
2226 WRITE_NODE_FIELD(relationOids);
2227 WRITE_NODE_FIELD(invalItems);
2228 WRITE_NODE_FIELD(paramExecTypes);
2229 WRITE_UINT_FIELD(lastPHId);
2230 WRITE_UINT_FIELD(lastRowMarkId);
2231 WRITE_INT_FIELD(lastPlanNodeId);
2232 WRITE_BOOL_FIELD(transientPlan);
2233 WRITE_BOOL_FIELD(dependsOnRole);
2234 WRITE_BOOL_FIELD(parallelModeOK);
2235 WRITE_BOOL_FIELD(parallelModeNeeded);
2236 WRITE_CHAR_FIELD(maxParallelHazard);
2240 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
2242 WRITE_NODE_TYPE("PLANNERINFO");
2244 /* NB: this isn't a complete set of fields */
2245 WRITE_NODE_FIELD(parse);
2246 WRITE_NODE_FIELD(glob);
2247 WRITE_UINT_FIELD(query_level);
2248 WRITE_NODE_FIELD(plan_params);
2249 WRITE_BITMAPSET_FIELD(outer_params);
2250 WRITE_BITMAPSET_FIELD(all_baserels);
2251 WRITE_BITMAPSET_FIELD(nullable_baserels);
2252 WRITE_NODE_FIELD(join_rel_list);
2253 WRITE_INT_FIELD(join_cur_level);
2254 WRITE_NODE_FIELD(init_plans);
2255 WRITE_NODE_FIELD(cte_plan_ids);
2256 WRITE_NODE_FIELD(multiexpr_params);
2257 WRITE_NODE_FIELD(eq_classes);
2258 WRITE_NODE_FIELD(canon_pathkeys);
2259 WRITE_NODE_FIELD(left_join_clauses);
2260 WRITE_NODE_FIELD(right_join_clauses);
2261 WRITE_NODE_FIELD(full_join_clauses);
2262 WRITE_NODE_FIELD(join_info_list);
2263 WRITE_NODE_FIELD(append_rel_list);
2264 WRITE_NODE_FIELD(pcinfo_list);
2265 WRITE_NODE_FIELD(rowMarks);
2266 WRITE_NODE_FIELD(placeholder_list);
2267 WRITE_NODE_FIELD(fkey_list);
2268 WRITE_NODE_FIELD(query_pathkeys);
2269 WRITE_NODE_FIELD(group_pathkeys);
2270 WRITE_NODE_FIELD(window_pathkeys);
2271 WRITE_NODE_FIELD(distinct_pathkeys);
2272 WRITE_NODE_FIELD(sort_pathkeys);
2273 WRITE_NODE_FIELD(processed_tlist);
2274 WRITE_NODE_FIELD(minmax_aggs);
2275 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
2276 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
2277 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
2278 WRITE_UINT_FIELD(qual_security_level);
2279 WRITE_BOOL_FIELD(hasInheritedTarget);
2280 WRITE_BOOL_FIELD(hasJoinRTEs);
2281 WRITE_BOOL_FIELD(hasLateralRTEs);
2282 WRITE_BOOL_FIELD(hasDeletedRTEs);
2283 WRITE_BOOL_FIELD(hasHavingQual);
2284 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
2285 WRITE_BOOL_FIELD(hasRecursion);
2286 WRITE_INT_FIELD(wt_param_id);
2287 WRITE_BITMAPSET_FIELD(curOuterRels);
2288 WRITE_NODE_FIELD(curOuterParams);
2292 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
2294 WRITE_NODE_TYPE("RELOPTINFO");
2296 /* NB: this isn't a complete set of fields */
2297 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
2298 WRITE_BITMAPSET_FIELD(relids);
2299 WRITE_FLOAT_FIELD(rows, "%.0f");
2300 WRITE_BOOL_FIELD(consider_startup);
2301 WRITE_BOOL_FIELD(consider_param_startup);
2302 WRITE_BOOL_FIELD(consider_parallel);
2303 WRITE_NODE_FIELD(reltarget);
2304 WRITE_NODE_FIELD(pathlist);
2305 WRITE_NODE_FIELD(ppilist);
2306 WRITE_NODE_FIELD(partial_pathlist);
2307 WRITE_NODE_FIELD(cheapest_startup_path);
2308 WRITE_NODE_FIELD(cheapest_total_path);
2309 WRITE_NODE_FIELD(cheapest_unique_path);
2310 WRITE_NODE_FIELD(cheapest_parameterized_paths);
2311 WRITE_BITMAPSET_FIELD(direct_lateral_relids);
2312 WRITE_BITMAPSET_FIELD(lateral_relids);
2313 WRITE_UINT_FIELD(relid);
2314 WRITE_OID_FIELD(reltablespace);
2315 WRITE_ENUM_FIELD(rtekind, RTEKind);
2316 WRITE_INT_FIELD(min_attr);
2317 WRITE_INT_FIELD(max_attr);
2318 WRITE_NODE_FIELD(lateral_vars);
2319 WRITE_BITMAPSET_FIELD(lateral_referencers);
2320 WRITE_NODE_FIELD(indexlist);
2321 WRITE_NODE_FIELD(statlist);
2322 WRITE_UINT_FIELD(pages);
2323 WRITE_FLOAT_FIELD(tuples, "%.0f");
2324 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
2325 WRITE_NODE_FIELD(subroot);
2326 WRITE_NODE_FIELD(subplan_params);
2327 WRITE_INT_FIELD(rel_parallel_workers);
2328 WRITE_OID_FIELD(serverid);
2329 WRITE_OID_FIELD(userid);
2330 WRITE_BOOL_FIELD(useridiscurrent);
2331 /* we don't try to print fdwroutine or fdw_private */
2332 /* can't print unique_for_rels/non_unique_for_rels; BMSes aren't Nodes */
2333 WRITE_NODE_FIELD(baserestrictinfo);
2334 WRITE_UINT_FIELD(baserestrict_min_security);
2335 WRITE_NODE_FIELD(joininfo);
2336 WRITE_BOOL_FIELD(has_eclass_joins);
2337 WRITE_BITMAPSET_FIELD(top_parent_relids);
2341 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
2343 WRITE_NODE_TYPE("INDEXOPTINFO");
2345 /* NB: this isn't a complete set of fields */
2346 WRITE_OID_FIELD(indexoid);
2347 /* Do NOT print rel field, else infinite recursion */
2348 WRITE_UINT_FIELD(pages);
2349 WRITE_FLOAT_FIELD(tuples, "%.0f");
2350 WRITE_INT_FIELD(tree_height);
2351 WRITE_INT_FIELD(ncolumns);
2352 /* array fields aren't really worth the trouble to print */
2353 WRITE_OID_FIELD(relam);
2354 /* indexprs is redundant since we print indextlist */
2355 WRITE_NODE_FIELD(indpred);
2356 WRITE_NODE_FIELD(indextlist);
2357 WRITE_NODE_FIELD(indrestrictinfo);
2358 WRITE_BOOL_FIELD(predOK);
2359 WRITE_BOOL_FIELD(unique);
2360 WRITE_BOOL_FIELD(immediate);
2361 WRITE_BOOL_FIELD(hypothetical);
2362 /* we don't bother with fields copied from the index AM's API struct */
2366 _outForeignKeyOptInfo(StringInfo str, const ForeignKeyOptInfo *node)
2370 WRITE_NODE_TYPE("FOREIGNKEYOPTINFO");
2372 WRITE_UINT_FIELD(con_relid);
2373 WRITE_UINT_FIELD(ref_relid);
2374 WRITE_INT_FIELD(nkeys);
2375 appendStringInfoString(str, " :conkey");
2376 for (i = 0; i < node->nkeys; i++)
2377 appendStringInfo(str, " %d", node->conkey[i]);
2378 appendStringInfoString(str, " :confkey");
2379 for (i = 0; i < node->nkeys; i++)
2380 appendStringInfo(str, " %d", node->confkey[i]);
2381 appendStringInfoString(str, " :conpfeqop");
2382 for (i = 0; i < node->nkeys; i++)
2383 appendStringInfo(str, " %u", node->conpfeqop[i]);
2384 WRITE_INT_FIELD(nmatched_ec);
2385 WRITE_INT_FIELD(nmatched_rcols);
2386 WRITE_INT_FIELD(nmatched_ri);
2387 /* for compactness, just print the number of matches per column: */
2388 appendStringInfoString(str, " :eclass");
2389 for (i = 0; i < node->nkeys; i++)
2390 appendStringInfo(str, " %d", (node->eclass[i] != NULL));
2391 appendStringInfoString(str, " :rinfos");
2392 for (i = 0; i < node->nkeys; i++)
2393 appendStringInfo(str, " %d", list_length(node->rinfos[i]));
2397 _outStatisticExtInfo(StringInfo str, const StatisticExtInfo *node)
2399 WRITE_NODE_TYPE("STATISTICEXTINFO");
2401 /* NB: this isn't a complete set of fields */
2402 WRITE_OID_FIELD(statOid);
2403 /* don't write rel, leads to infinite recursion in plan tree dump */
2404 WRITE_CHAR_FIELD(kind);
2405 WRITE_BITMAPSET_FIELD(keys);
2409 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
2412 * To simplify reading, we just chase up to the topmost merged EC and
2413 * print that, without bothering to show the merge-ees separately.
2415 while (node->ec_merged)
2416 node = node->ec_merged;
2418 WRITE_NODE_TYPE("EQUIVALENCECLASS");
2420 WRITE_NODE_FIELD(ec_opfamilies);
2421 WRITE_OID_FIELD(ec_collation);
2422 WRITE_NODE_FIELD(ec_members);
2423 WRITE_NODE_FIELD(ec_sources);
2424 WRITE_NODE_FIELD(ec_derives);
2425 WRITE_BITMAPSET_FIELD(ec_relids);
2426 WRITE_BOOL_FIELD(ec_has_const);
2427 WRITE_BOOL_FIELD(ec_has_volatile);
2428 WRITE_BOOL_FIELD(ec_below_outer_join);
2429 WRITE_BOOL_FIELD(ec_broken);
2430 WRITE_UINT_FIELD(ec_sortref);
2431 WRITE_UINT_FIELD(ec_min_security);
2432 WRITE_UINT_FIELD(ec_max_security);
2436 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
2438 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
2440 WRITE_NODE_FIELD(em_expr);
2441 WRITE_BITMAPSET_FIELD(em_relids);
2442 WRITE_BITMAPSET_FIELD(em_nullable_relids);
2443 WRITE_BOOL_FIELD(em_is_const);
2444 WRITE_BOOL_FIELD(em_is_child);
2445 WRITE_OID_FIELD(em_datatype);
2449 _outPathKey(StringInfo str, const PathKey *node)
2451 WRITE_NODE_TYPE("PATHKEY");
2453 WRITE_NODE_FIELD(pk_eclass);
2454 WRITE_OID_FIELD(pk_opfamily);
2455 WRITE_INT_FIELD(pk_strategy);
2456 WRITE_BOOL_FIELD(pk_nulls_first);
2460 _outPathTarget(StringInfo str, const PathTarget *node)
2462 WRITE_NODE_TYPE("PATHTARGET");
2464 WRITE_NODE_FIELD(exprs);
2465 if (node->sortgrouprefs)
2469 appendStringInfoString(str, " :sortgrouprefs");
2470 for (i = 0; i < list_length(node->exprs); i++)
2471 appendStringInfo(str, " %u", node->sortgrouprefs[i]);
2473 WRITE_FLOAT_FIELD(cost.startup, "%.2f");
2474 WRITE_FLOAT_FIELD(cost.per_tuple, "%.2f");
2475 WRITE_INT_FIELD(width);
2479 _outParamPathInfo(StringInfo str, const ParamPathInfo *node)
2481 WRITE_NODE_TYPE("PARAMPATHINFO");
2483 WRITE_BITMAPSET_FIELD(ppi_req_outer);
2484 WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
2485 WRITE_NODE_FIELD(ppi_clauses);
2489 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
2491 WRITE_NODE_TYPE("RESTRICTINFO");
2493 /* NB: this isn't a complete set of fields */
2494 WRITE_NODE_FIELD(clause);
2495 WRITE_BOOL_FIELD(is_pushed_down);
2496 WRITE_BOOL_FIELD(outerjoin_delayed);
2497 WRITE_BOOL_FIELD(can_join);
2498 WRITE_BOOL_FIELD(pseudoconstant);
2499 WRITE_BOOL_FIELD(leakproof);
2500 WRITE_UINT_FIELD(security_level);
2501 WRITE_BITMAPSET_FIELD(clause_relids);
2502 WRITE_BITMAPSET_FIELD(required_relids);
2503 WRITE_BITMAPSET_FIELD(outer_relids);
2504 WRITE_BITMAPSET_FIELD(nullable_relids);
2505 WRITE_BITMAPSET_FIELD(left_relids);
2506 WRITE_BITMAPSET_FIELD(right_relids);
2507 WRITE_NODE_FIELD(orclause);
2508 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
2509 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
2510 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
2511 WRITE_NODE_FIELD(mergeopfamilies);
2512 /* don't write left_ec, leads to infinite recursion in plan tree dump */
2513 /* don't write right_ec, leads to infinite recursion in plan tree dump */
2514 WRITE_NODE_FIELD(left_em);
2515 WRITE_NODE_FIELD(right_em);
2516 WRITE_BOOL_FIELD(outer_is_left);
2517 WRITE_OID_FIELD(hashjoinoperator);
2521 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
2523 WRITE_NODE_TYPE("PLACEHOLDERVAR");
2525 WRITE_NODE_FIELD(phexpr);
2526 WRITE_BITMAPSET_FIELD(phrels);
2527 WRITE_UINT_FIELD(phid);
2528 WRITE_UINT_FIELD(phlevelsup);
2532 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
2534 WRITE_NODE_TYPE("SPECIALJOININFO");
2536 WRITE_BITMAPSET_FIELD(min_lefthand);
2537 WRITE_BITMAPSET_FIELD(min_righthand);
2538 WRITE_BITMAPSET_FIELD(syn_lefthand);
2539 WRITE_BITMAPSET_FIELD(syn_righthand);
2540 WRITE_ENUM_FIELD(jointype, JoinType);
2541 WRITE_BOOL_FIELD(lhs_strict);
2542 WRITE_BOOL_FIELD(delay_upper_joins);
2543 WRITE_BOOL_FIELD(semi_can_btree);
2544 WRITE_BOOL_FIELD(semi_can_hash);
2545 WRITE_NODE_FIELD(semi_operators);
2546 WRITE_NODE_FIELD(semi_rhs_exprs);
2550 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
2552 WRITE_NODE_TYPE("APPENDRELINFO");
2554 WRITE_UINT_FIELD(parent_relid);
2555 WRITE_UINT_FIELD(child_relid);
2556 WRITE_OID_FIELD(parent_reltype);
2557 WRITE_OID_FIELD(child_reltype);
2558 WRITE_NODE_FIELD(translated_vars);
2559 WRITE_OID_FIELD(parent_reloid);
2563 _outPartitionedChildRelInfo(StringInfo str, const PartitionedChildRelInfo *node)
2565 WRITE_NODE_TYPE("PARTITIONEDCHILDRELINFO");
2567 WRITE_UINT_FIELD(parent_relid);
2568 WRITE_NODE_FIELD(child_rels);
2569 WRITE_BOOL_FIELD(part_cols_updated);
2573 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
2575 WRITE_NODE_TYPE("PLACEHOLDERINFO");
2577 WRITE_UINT_FIELD(phid);
2578 WRITE_NODE_FIELD(ph_var);
2579 WRITE_BITMAPSET_FIELD(ph_eval_at);
2580 WRITE_BITMAPSET_FIELD(ph_lateral);
2581 WRITE_BITMAPSET_FIELD(ph_needed);
2582 WRITE_INT_FIELD(ph_width);
2586 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
2588 WRITE_NODE_TYPE("MINMAXAGGINFO");
2590 WRITE_OID_FIELD(aggfnoid);
2591 WRITE_OID_FIELD(aggsortop);
2592 WRITE_NODE_FIELD(target);
2593 /* We intentionally omit subroot --- too large, not interesting enough */
2594 WRITE_NODE_FIELD(path);
2595 WRITE_FLOAT_FIELD(pathcost, "%.2f");
2596 WRITE_NODE_FIELD(param);
2600 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
2602 WRITE_NODE_TYPE("PLANNERPARAMITEM");
2604 WRITE_NODE_FIELD(item);
2605 WRITE_INT_FIELD(paramId);
2608 /*****************************************************************************
2610 * Stuff from extensible.h
2612 *****************************************************************************/
2615 _outExtensibleNode(StringInfo str, const ExtensibleNode *node)
2617 const ExtensibleNodeMethods *methods;
2619 methods = GetExtensibleNodeMethods(node->extnodename, false);
2621 WRITE_NODE_TYPE("EXTENSIBLENODE");
2623 WRITE_STRING_FIELD(extnodename);
2625 /* serialize the private fields */
2626 methods->nodeOut(str, node);
2629 /*****************************************************************************
2631 * Stuff from parsenodes.h.
2633 *****************************************************************************/
2636 * print the basic stuff of all nodes that inherit from CreateStmt
2639 _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
2641 WRITE_NODE_FIELD(relation);
2642 WRITE_NODE_FIELD(tableElts);
2643 WRITE_NODE_FIELD(inhRelations);
2644 WRITE_NODE_FIELD(partspec);
2645 WRITE_NODE_FIELD(partbound);
2646 WRITE_NODE_FIELD(ofTypename);
2647 WRITE_NODE_FIELD(constraints);
2648 WRITE_NODE_FIELD(options);
2649 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
2650 WRITE_STRING_FIELD(tablespacename);
2651 WRITE_BOOL_FIELD(if_not_exists);
2655 _outCreateStmt(StringInfo str, const CreateStmt *node)
2657 WRITE_NODE_TYPE("CREATESTMT");
2659 _outCreateStmtInfo(str, (const CreateStmt *) node);
2663 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
2665 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
2667 _outCreateStmtInfo(str, (const CreateStmt *) node);
2669 WRITE_STRING_FIELD(servername);
2670 WRITE_NODE_FIELD(options);
2674 _outImportForeignSchemaStmt(StringInfo str, const ImportForeignSchemaStmt *node)
2676 WRITE_NODE_TYPE("IMPORTFOREIGNSCHEMASTMT");
2678 WRITE_STRING_FIELD(server_name);
2679 WRITE_STRING_FIELD(remote_schema);
2680 WRITE_STRING_FIELD(local_schema);
2681 WRITE_ENUM_FIELD(list_type, ImportForeignSchemaType);
2682 WRITE_NODE_FIELD(table_list);
2683 WRITE_NODE_FIELD(options);
2687 _outIndexStmt(StringInfo str, const IndexStmt *node)
2689 WRITE_NODE_TYPE("INDEXSTMT");
2691 WRITE_STRING_FIELD(idxname);
2692 WRITE_NODE_FIELD(relation);
2693 WRITE_OID_FIELD(relationId);
2694 WRITE_STRING_FIELD(accessMethod);
2695 WRITE_STRING_FIELD(tableSpace);
2696 WRITE_NODE_FIELD(indexParams);
2697 WRITE_NODE_FIELD(options);
2698 WRITE_NODE_FIELD(whereClause);
2699 WRITE_NODE_FIELD(excludeOpNames);
2700 WRITE_STRING_FIELD(idxcomment);
2701 WRITE_OID_FIELD(indexOid);
2702 WRITE_OID_FIELD(oldNode);
2703 WRITE_BOOL_FIELD(unique);
2704 WRITE_BOOL_FIELD(primary);
2705 WRITE_BOOL_FIELD(isconstraint);
2706 WRITE_BOOL_FIELD(deferrable);
2707 WRITE_BOOL_FIELD(initdeferred);
2708 WRITE_BOOL_FIELD(transformed);
2709 WRITE_BOOL_FIELD(concurrent);
2710 WRITE_BOOL_FIELD(if_not_exists);
2714 _outCreateStatsStmt(StringInfo str, const CreateStatsStmt *node)
2716 WRITE_NODE_TYPE("CREATESTATSSTMT");
2718 WRITE_NODE_FIELD(defnames);
2719 WRITE_NODE_FIELD(stat_types);
2720 WRITE_NODE_FIELD(exprs);
2721 WRITE_NODE_FIELD(relations);
2722 WRITE_STRING_FIELD(stxcomment);
2723 WRITE_BOOL_FIELD(if_not_exists);
2727 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
2729 WRITE_NODE_TYPE("NOTIFY");
2731 WRITE_STRING_FIELD(conditionname);
2732 WRITE_STRING_FIELD(payload);
2736 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2738 WRITE_NODE_TYPE("DECLARECURSOR");
2740 WRITE_STRING_FIELD(portalname);
2741 WRITE_INT_FIELD(options);
2742 WRITE_NODE_FIELD(query);
2746 _outSelectStmt(StringInfo str, const SelectStmt *node)
2748 WRITE_NODE_TYPE("SELECT");
2750 WRITE_NODE_FIELD(distinctClause);
2751 WRITE_NODE_FIELD(intoClause);
2752 WRITE_NODE_FIELD(targetList);
2753 WRITE_NODE_FIELD(fromClause);
2754 WRITE_NODE_FIELD(whereClause);
2755 WRITE_NODE_FIELD(groupClause);
2756 WRITE_NODE_FIELD(havingClause);
2757 WRITE_NODE_FIELD(windowClause);
2758 WRITE_NODE_FIELD(valuesLists);
2759 WRITE_NODE_FIELD(sortClause);
2760 WRITE_NODE_FIELD(limitOffset);
2761 WRITE_NODE_FIELD(limitCount);
2762 WRITE_NODE_FIELD(lockingClause);
2763 WRITE_NODE_FIELD(withClause);
2764 WRITE_ENUM_FIELD(op, SetOperation);
2765 WRITE_BOOL_FIELD(all);
2766 WRITE_NODE_FIELD(larg);
2767 WRITE_NODE_FIELD(rarg);
2771 _outFuncCall(StringInfo str, const FuncCall *node)
2773 WRITE_NODE_TYPE("FUNCCALL");
2775 WRITE_NODE_FIELD(funcname);
2776 WRITE_NODE_FIELD(args);
2777 WRITE_NODE_FIELD(agg_order);
2778 WRITE_NODE_FIELD(agg_filter);
2779 WRITE_BOOL_FIELD(agg_within_group);
2780 WRITE_BOOL_FIELD(agg_star);
2781 WRITE_BOOL_FIELD(agg_distinct);
2782 WRITE_BOOL_FIELD(func_variadic);
2783 WRITE_NODE_FIELD(over);
2784 WRITE_LOCATION_FIELD(location);
2788 _outDefElem(StringInfo str, const DefElem *node)
2790 WRITE_NODE_TYPE("DEFELEM");
2792 WRITE_STRING_FIELD(defnamespace);
2793 WRITE_STRING_FIELD(defname);
2794 WRITE_NODE_FIELD(arg);
2795 WRITE_ENUM_FIELD(defaction, DefElemAction);
2796 WRITE_LOCATION_FIELD(location);
2800 _outTableLikeClause(StringInfo str, const TableLikeClause *node)
2802 WRITE_NODE_TYPE("TABLELIKECLAUSE");
2804 WRITE_NODE_FIELD(relation);
2805 WRITE_UINT_FIELD(options);
2809 _outLockingClause(StringInfo str, const LockingClause *node)
2811 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2813 WRITE_NODE_FIELD(lockedRels);
2814 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2815 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2819 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2821 WRITE_NODE_TYPE("XMLSERIALIZE");
2823 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2824 WRITE_NODE_FIELD(expr);
2825 WRITE_NODE_FIELD(typeName);
2826 WRITE_LOCATION_FIELD(location);
2830 _outTriggerTransition(StringInfo str, const TriggerTransition *node)
2832 WRITE_NODE_TYPE("TRIGGERTRANSITION");
2834 WRITE_STRING_FIELD(name);
2835 WRITE_BOOL_FIELD(isNew);
2836 WRITE_BOOL_FIELD(isTable);
2840 _outColumnDef(StringInfo str, const ColumnDef *node)
2842 WRITE_NODE_TYPE("COLUMNDEF");
2844 WRITE_STRING_FIELD(colname);
2845 WRITE_NODE_FIELD(typeName);
2846 WRITE_INT_FIELD(inhcount);
2847 WRITE_BOOL_FIELD(is_local);
2848 WRITE_BOOL_FIELD(is_not_null);
2849 WRITE_BOOL_FIELD(is_from_type);
2850 WRITE_BOOL_FIELD(is_from_parent);
2851 WRITE_CHAR_FIELD(storage);
2852 WRITE_NODE_FIELD(raw_default);
2853 WRITE_NODE_FIELD(cooked_default);
2854 WRITE_CHAR_FIELD(identity);
2855 WRITE_NODE_FIELD(identitySequence);
2856 WRITE_NODE_FIELD(collClause);
2857 WRITE_OID_FIELD(collOid);
2858 WRITE_NODE_FIELD(constraints);
2859 WRITE_NODE_FIELD(fdwoptions);
2860 WRITE_LOCATION_FIELD(location);
2864 _outTypeName(StringInfo str, const TypeName *node)
2866 WRITE_NODE_TYPE("TYPENAME");
2868 WRITE_NODE_FIELD(names);
2869 WRITE_OID_FIELD(typeOid);
2870 WRITE_BOOL_FIELD(setof);
2871 WRITE_BOOL_FIELD(pct_type);
2872 WRITE_NODE_FIELD(typmods);
2873 WRITE_INT_FIELD(typemod);
2874 WRITE_NODE_FIELD(arrayBounds);
2875 WRITE_LOCATION_FIELD(location);
2879 _outTypeCast(StringInfo str, const TypeCast *node)
2881 WRITE_NODE_TYPE("TYPECAST");
2883 WRITE_NODE_FIELD(arg);
2884 WRITE_NODE_FIELD(typeName);
2885 WRITE_LOCATION_FIELD(location);
2889 _outCollateClause(StringInfo str, const CollateClause *node)
2891 WRITE_NODE_TYPE("COLLATECLAUSE");
2893 WRITE_NODE_FIELD(arg);
2894 WRITE_NODE_FIELD(collname);
2895 WRITE_LOCATION_FIELD(location);
2899 _outIndexElem(StringInfo str, const IndexElem *node)
2901 WRITE_NODE_TYPE("INDEXELEM");
2903 WRITE_STRING_FIELD(name);
2904 WRITE_NODE_FIELD(expr);
2905 WRITE_STRING_FIELD(indexcolname);
2906 WRITE_NODE_FIELD(collation);
2907 WRITE_NODE_FIELD(opclass);
2908 WRITE_ENUM_FIELD(ordering, SortByDir);
2909 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2913 _outQuery(StringInfo str, const Query *node)
2915 WRITE_NODE_TYPE("QUERY");
2917 WRITE_ENUM_FIELD(commandType, CmdType);
2918 WRITE_ENUM_FIELD(querySource, QuerySource);
2919 /* we intentionally do not print the queryId field */
2920 WRITE_BOOL_FIELD(canSetTag);
2923 * Hack to work around missing outfuncs routines for a lot of the
2924 * utility-statement node types. (The only one we actually *need* for
2925 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2926 * for the meantime do this to avoid getting lots of warnings when running
2927 * with debug_print_parse on.
2929 if (node->utilityStmt)
2931 switch (nodeTag(node->utilityStmt))
2936 case T_DeclareCursorStmt:
2937 WRITE_NODE_FIELD(utilityStmt);
2940 appendStringInfoString(str, " :utilityStmt ?");
2945 appendStringInfoString(str, " :utilityStmt <>");
2947 WRITE_INT_FIELD(resultRelation);
2948 WRITE_BOOL_FIELD(hasAggs);
2949 WRITE_BOOL_FIELD(hasWindowFuncs);
2950 WRITE_BOOL_FIELD(hasTargetSRFs);
2951 WRITE_BOOL_FIELD(hasSubLinks);
2952 WRITE_BOOL_FIELD(hasDistinctOn);
2953 WRITE_BOOL_FIELD(hasRecursive);
2954 WRITE_BOOL_FIELD(hasModifyingCTE);
2955 WRITE_BOOL_FIELD(hasForUpdate);
2956 WRITE_BOOL_FIELD(hasRowSecurity);
2957 WRITE_NODE_FIELD(cteList);
2958 WRITE_NODE_FIELD(rtable);
2959 WRITE_NODE_FIELD(jointree);
2960 WRITE_NODE_FIELD(targetList);
2961 WRITE_ENUM_FIELD(override, OverridingKind);
2962 WRITE_NODE_FIELD(onConflict);
2963 WRITE_NODE_FIELD(returningList);
2964 WRITE_NODE_FIELD(groupClause);
2965 WRITE_NODE_FIELD(groupingSets);
2966 WRITE_NODE_FIELD(havingQual);
2967 WRITE_NODE_FIELD(windowClause);
2968 WRITE_NODE_FIELD(distinctClause);
2969 WRITE_NODE_FIELD(sortClause);
2970 WRITE_NODE_FIELD(limitOffset);
2971 WRITE_NODE_FIELD(limitCount);
2972 WRITE_NODE_FIELD(rowMarks);
2973 WRITE_NODE_FIELD(setOperations);
2974 WRITE_NODE_FIELD(constraintDeps);
2975 /* withCheckOptions intentionally omitted, see comment in parsenodes.h */
2976 WRITE_INT_FIELD(mergeTarget_relation);
2977 WRITE_NODE_FIELD(mergeSourceTargetList);
2978 WRITE_NODE_FIELD(mergeActionList);
2979 WRITE_LOCATION_FIELD(stmt_location);
2980 WRITE_LOCATION_FIELD(stmt_len);
2984 _outWithCheckOption(StringInfo str, const WithCheckOption *node)
2986 WRITE_NODE_TYPE("WITHCHECKOPTION");
2988 WRITE_ENUM_FIELD(kind, WCOKind);
2989 WRITE_STRING_FIELD(relname);
2990 WRITE_STRING_FIELD(polname);
2991 WRITE_NODE_FIELD(qual);
2992 WRITE_BOOL_FIELD(cascaded);
2996 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2998 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
3000 WRITE_UINT_FIELD(tleSortGroupRef);
3001 WRITE_OID_FIELD(eqop);
3002 WRITE_OID_FIELD(sortop);
3003 WRITE_BOOL_FIELD(nulls_first);
3004 WRITE_BOOL_FIELD(hashable);
3008 _outGroupingSet(StringInfo str, const GroupingSet *node)
3010 WRITE_NODE_TYPE("GROUPINGSET");
3012 WRITE_ENUM_FIELD(kind, GroupingSetKind);
3013 WRITE_NODE_FIELD(content);
3014 WRITE_LOCATION_FIELD(location);
3018 _outWindowClause(StringInfo str, const WindowClause *node)
3020 WRITE_NODE_TYPE("WINDOWCLAUSE");
3022 WRITE_STRING_FIELD(name);
3023 WRITE_STRING_FIELD(refname);
3024 WRITE_NODE_FIELD(partitionClause);
3025 WRITE_NODE_FIELD(orderClause);
3026 WRITE_INT_FIELD(frameOptions);
3027 WRITE_NODE_FIELD(startOffset);
3028 WRITE_NODE_FIELD(endOffset);
3029 WRITE_OID_FIELD(startInRangeFunc);
3030 WRITE_OID_FIELD(endInRangeFunc);
3031 WRITE_OID_FIELD(inRangeColl);
3032 WRITE_BOOL_FIELD(inRangeAsc);
3033 WRITE_BOOL_FIELD(inRangeNullsFirst);
3034 WRITE_UINT_FIELD(winref);
3035 WRITE_BOOL_FIELD(copiedOrder);
3039 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
3041 WRITE_NODE_TYPE("ROWMARKCLAUSE");
3043 WRITE_UINT_FIELD(rti);
3044 WRITE_ENUM_FIELD(strength, LockClauseStrength);
3045 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
3046 WRITE_BOOL_FIELD(pushedDown);
3050 _outWithClause(StringInfo str, const WithClause *node)
3052 WRITE_NODE_TYPE("WITHCLAUSE");
3054 WRITE_NODE_FIELD(ctes);
3055 WRITE_BOOL_FIELD(recursive);
3056 WRITE_LOCATION_FIELD(location);
3060 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
3062 WRITE_NODE_TYPE("COMMONTABLEEXPR");
3064 WRITE_STRING_FIELD(ctename);
3065 WRITE_NODE_FIELD(aliascolnames);
3066 WRITE_NODE_FIELD(ctequery);
3067 WRITE_LOCATION_FIELD(location);
3068 WRITE_BOOL_FIELD(cterecursive);
3069 WRITE_INT_FIELD(cterefcount);
3070 WRITE_NODE_FIELD(ctecolnames);
3071 WRITE_NODE_FIELD(ctecoltypes);
3072 WRITE_NODE_FIELD(ctecoltypmods);
3073 WRITE_NODE_FIELD(ctecolcollations);
3077 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
3079 WRITE_NODE_TYPE("SETOPERATIONSTMT");
3081 WRITE_ENUM_FIELD(op, SetOperation);
3082 WRITE_BOOL_FIELD(all);
3083 WRITE_NODE_FIELD(larg);
3084 WRITE_NODE_FIELD(rarg);
3085 WRITE_NODE_FIELD(colTypes);
3086 WRITE_NODE_FIELD(colTypmods);
3087 WRITE_NODE_FIELD(colCollations);
3088 WRITE_NODE_FIELD(groupClauses);
3092 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
3094 WRITE_NODE_TYPE("RTE");
3096 /* put alias + eref first to make dump more legible */
3097 WRITE_NODE_FIELD(alias);
3098 WRITE_NODE_FIELD(eref);
3099 WRITE_ENUM_FIELD(rtekind, RTEKind);
3101 switch (node->rtekind)
3104 WRITE_OID_FIELD(relid);
3105 WRITE_CHAR_FIELD(relkind);
3106 WRITE_NODE_FIELD(tablesample);
3109 WRITE_NODE_FIELD(subquery);
3110 WRITE_BOOL_FIELD(security_barrier);
3113 WRITE_ENUM_FIELD(jointype, JoinType);
3114 WRITE_NODE_FIELD(joinaliasvars);
3117 WRITE_NODE_FIELD(functions);
3118 WRITE_BOOL_FIELD(funcordinality);
3121 WRITE_NODE_FIELD(tablefunc);
3124 WRITE_NODE_FIELD(values_lists);
3125 WRITE_NODE_FIELD(coltypes);
3126 WRITE_NODE_FIELD(coltypmods);
3127 WRITE_NODE_FIELD(colcollations);
3130 WRITE_STRING_FIELD(ctename);
3131 WRITE_UINT_FIELD(ctelevelsup);
3132 WRITE_BOOL_FIELD(self_reference);
3133 WRITE_NODE_FIELD(coltypes);
3134 WRITE_NODE_FIELD(coltypmods);
3135 WRITE_NODE_FIELD(colcollations);
3137 case RTE_NAMEDTUPLESTORE:
3138 WRITE_STRING_FIELD(enrname);
3139 WRITE_FLOAT_FIELD(enrtuples, "%.0f");
3140 WRITE_OID_FIELD(relid);
3141 WRITE_NODE_FIELD(coltypes);
3142 WRITE_NODE_FIELD(coltypmods);
3143 WRITE_NODE_FIELD(colcollations);
3146 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
3150 WRITE_BOOL_FIELD(lateral);
3151 WRITE_BOOL_FIELD(inh);
3152 WRITE_BOOL_FIELD(inFromCl);
3153 WRITE_UINT_FIELD(requiredPerms);
3154 WRITE_OID_FIELD(checkAsUser);
3155 WRITE_BITMAPSET_FIELD(selectedCols);
3156 WRITE_BITMAPSET_FIELD(insertedCols);
3157 WRITE_BITMAPSET_FIELD(updatedCols);
3158 WRITE_NODE_FIELD(securityQuals);
3162 _outRangeTblFunction(StringInfo str, const RangeTblFunction *node)
3164 WRITE_NODE_TYPE("RANGETBLFUNCTION");
3166 WRITE_NODE_FIELD(funcexpr);
3167 WRITE_INT_FIELD(funccolcount);
3168 WRITE_NODE_FIELD(funccolnames);
3169 WRITE_NODE_FIELD(funccoltypes);
3170 WRITE_NODE_FIELD(funccoltypmods);
3171 WRITE_NODE_FIELD(funccolcollations);
3172 WRITE_BITMAPSET_FIELD(funcparams);
3176 _outTableSampleClause(StringInfo str, const TableSampleClause *node)
3178 WRITE_NODE_TYPE("TABLESAMPLECLAUSE");
3180 WRITE_OID_FIELD(tsmhandler);
3181 WRITE_NODE_FIELD(args);
3182 WRITE_NODE_FIELD(repeatable);
3186 _outAExpr(StringInfo str, const A_Expr *node)
3188 WRITE_NODE_TYPE("AEXPR");
3193 appendStringInfoChar(str, ' ');
3194 WRITE_NODE_FIELD(name);
3197 appendStringInfoChar(str, ' ');
3198 WRITE_NODE_FIELD(name);
3199 appendStringInfoString(str, " ANY ");
3202 appendStringInfoChar(str, ' ');
3203 WRITE_NODE_FIELD(name);
3204 appendStringInfoString(str, " ALL ");
3206 case AEXPR_DISTINCT:
3207 appendStringInfoString(str, " DISTINCT ");
3208 WRITE_NODE_FIELD(name);
3210 case AEXPR_NOT_DISTINCT:
3211 appendStringInfoString(str, " NOT_DISTINCT ");
3212 WRITE_NODE_FIELD(name);
3215 appendStringInfoString(str, " NULLIF ");
3216 WRITE_NODE_FIELD(name);
3219 appendStringInfoString(str, " OF ");
3220 WRITE_NODE_FIELD(name);
3223 appendStringInfoString(str, " IN ");
3224 WRITE_NODE_FIELD(name);
3227 appendStringInfoString(str, " LIKE ");
3228 WRITE_NODE_FIELD(name);
3231 appendStringInfoString(str, " ILIKE ");
3232 WRITE_NODE_FIELD(name);
3235 appendStringInfoString(str, " SIMILAR ");
3236 WRITE_NODE_FIELD(name);
3239 appendStringInfoString(str, " BETWEEN ");
3240 WRITE_NODE_FIELD(name);
3242 case AEXPR_NOT_BETWEEN:
3243 appendStringInfoString(str, " NOT_BETWEEN ");
3244 WRITE_NODE_FIELD(name);
3246 case AEXPR_BETWEEN_SYM:
3247 appendStringInfoString(str, " BETWEEN_SYM ");
3248 WRITE_NODE_FIELD(name);
3250 case AEXPR_NOT_BETWEEN_SYM:
3251 appendStringInfoString(str, " NOT_BETWEEN_SYM ");
3252 WRITE_NODE_FIELD(name);
3255 appendStringInfoString(str, " PAREN");
3258 appendStringInfoString(str, " ??");
3262 WRITE_NODE_FIELD(lexpr);
3263 WRITE_NODE_FIELD(rexpr);
3264 WRITE_LOCATION_FIELD(location);
3268 _outValue(StringInfo str, const Value *value)
3270 switch (value->type)
3273 appendStringInfo(str, "%d", value->val.ival);
3278 * We assume the value is a valid numeric literal and so does not
3281 appendStringInfoString(str, value->val.str);
3286 * We use outToken to provide escaping of the string's content,
3287 * but we don't want it to do anything with an empty string.
3289 appendStringInfoChar(str, '"');
3290 if (value->val.str[0] != '\0')
3291 outToken(str, value->val.str);
3292 appendStringInfoChar(str, '"');
3295 /* internal representation already has leading 'b' */
3296 appendStringInfoString(str, value->val.str);
3299 /* this is seen only within A_Const, not in transformed trees */
3300 appendStringInfoString(str, "NULL");
3303 elog(ERROR, "unrecognized node type: %d", (int) value->type);
3309 _outColumnRef(StringInfo str, const ColumnRef *node)
3311 WRITE_NODE_TYPE("COLUMNREF");
3313 WRITE_NODE_FIELD(fields);
3314 WRITE_LOCATION_FIELD(location);
3318 _outParamRef(StringInfo str, const ParamRef *node)
3320 WRITE_NODE_TYPE("PARAMREF");
3322 WRITE_INT_FIELD(number);
3323 WRITE_LOCATION_FIELD(location);
3327 _outAConst(StringInfo str, const A_Const *node)
3329 WRITE_NODE_TYPE("A_CONST");
3331 appendStringInfoString(str, " :val ");
3332 _outValue(str, &(node->val));
3333 WRITE_LOCATION_FIELD(location);
3337 _outA_Star(StringInfo str, const A_Star *node)
3339 WRITE_NODE_TYPE("A_STAR");
3343 _outA_Indices(StringInfo str, const A_Indices *node)
3345 WRITE_NODE_TYPE("A_INDICES");
3347 WRITE_BOOL_FIELD(is_slice);
3348 WRITE_NODE_FIELD(lidx);
3349 WRITE_NODE_FIELD(uidx);
3353 _outA_Indirection(StringInfo str, const A_Indirection *node)
3355 WRITE_NODE_TYPE("A_INDIRECTION");
3357 WRITE_NODE_FIELD(arg);
3358 WRITE_NODE_FIELD(indirection);
3362 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
3364 WRITE_NODE_TYPE("A_ARRAYEXPR");
3366 WRITE_NODE_FIELD(elements);
3367 WRITE_LOCATION_FIELD(location);
3371 _outResTarget(StringInfo str, const ResTarget *node)
3373 WRITE_NODE_TYPE("RESTARGET");
3375 WRITE_STRING_FIELD(name);
3376 WRITE_NODE_FIELD(indirection);
3377 WRITE_NODE_FIELD(val);
3378 WRITE_LOCATION_FIELD(location);
3382 _outMultiAssignRef(StringInfo str, const MultiAssignRef *node)
3384 WRITE_NODE_TYPE("MULTIASSIGNREF");
3386 WRITE_NODE_FIELD(source);
3387 WRITE_INT_FIELD(colno);
3388 WRITE_INT_FIELD(ncolumns);
3392 _outSortBy(StringInfo str, const SortBy *node)
3394 WRITE_NODE_TYPE("SORTBY");
3396 WRITE_NODE_FIELD(node);
3397 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
3398 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
3399 WRITE_NODE_FIELD(useOp);
3400 WRITE_LOCATION_FIELD(location);
3404 _outWindowDef(StringInfo str, const WindowDef *node)
3406 WRITE_NODE_TYPE("WINDOWDEF");
3408 WRITE_STRING_FIELD(name);
3409 WRITE_STRING_FIELD(refname);
3410 WRITE_NODE_FIELD(partitionClause);
3411 WRITE_NODE_FIELD(orderClause);
3412 WRITE_INT_FIELD(frameOptions);
3413 WRITE_NODE_FIELD(startOffset);
3414 WRITE_NODE_FIELD(endOffset);
3415 WRITE_LOCATION_FIELD(location);
3419 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
3421 WRITE_NODE_TYPE("RANGESUBSELECT");
3423 WRITE_BOOL_FIELD(lateral);
3424 WRITE_NODE_FIELD(subquery);
3425 WRITE_NODE_FIELD(alias);
3429 _outRangeFunction(StringInfo str, const RangeFunction *node)
3431 WRITE_NODE_TYPE("RANGEFUNCTION");
3433 WRITE_BOOL_FIELD(lateral);
3434 WRITE_BOOL_FIELD(ordinality);
3435 WRITE_BOOL_FIELD(is_rowsfrom);
3436 WRITE_NODE_FIELD(functions);
3437 WRITE_NODE_FIELD(alias);
3438 WRITE_NODE_FIELD(coldeflist);
3442 _outRangeTableSample(StringInfo str, const RangeTableSample *node)
3444 WRITE_NODE_TYPE("RANGETABLESAMPLE");
3446 WRITE_NODE_FIELD(relation);
3447 WRITE_NODE_FIELD(method);
3448 WRITE_NODE_FIELD(args);
3449 WRITE_NODE_FIELD(repeatable);
3450 WRITE_LOCATION_FIELD(location);
3454 _outRangeTableFunc(StringInfo str, const RangeTableFunc *node)
3456 WRITE_NODE_TYPE("RANGETABLEFUNC");
3458 WRITE_BOOL_FIELD(lateral);
3459 WRITE_NODE_FIELD(docexpr);
3460 WRITE_NODE_FIELD(rowexpr);
3461 WRITE_NODE_FIELD(namespaces);
3462 WRITE_NODE_FIELD(columns);
3463 WRITE_NODE_FIELD(alias);
3464 WRITE_LOCATION_FIELD(location);
3468 _outRangeTableFuncCol(StringInfo str, const RangeTableFuncCol *node)
3470 WRITE_NODE_TYPE("RANGETABLEFUNCCOL");
3472 WRITE_STRING_FIELD(colname);
3473 WRITE_NODE_FIELD(typeName);
3474 WRITE_BOOL_FIELD(for_ordinality);
3475 WRITE_BOOL_FIELD(is_not_null);
3476 WRITE_NODE_FIELD(colexpr);
3477 WRITE_NODE_FIELD(coldefexpr);
3478 WRITE_LOCATION_FIELD(location);
3482 _outConstraint(StringInfo str, const Constraint *node)
3484 WRITE_NODE_TYPE("CONSTRAINT");
3486 WRITE_STRING_FIELD(conname);
3487 WRITE_BOOL_FIELD(deferrable);
3488 WRITE_BOOL_FIELD(initdeferred);
3489 WRITE_LOCATION_FIELD(location);
3491 appendStringInfoString(str, " :contype ");
3492 switch (node->contype)
3495 appendStringInfoString(str, "NULL");
3498 case CONSTR_NOTNULL:
3499 appendStringInfoString(str, "NOT_NULL");
3502 case CONSTR_DEFAULT:
3503 appendStringInfoString(str, "DEFAULT");
3504 WRITE_NODE_FIELD(raw_expr);
3505 WRITE_STRING_FIELD(cooked_expr);
3508 case CONSTR_IDENTITY:
3509 appendStringInfoString(str, "IDENTITY");
3510 WRITE_NODE_FIELD(raw_expr);
3511 WRITE_STRING_FIELD(cooked_expr);
3512 WRITE_CHAR_FIELD(generated_when);
3516 appendStringInfoString(str, "CHECK");
3517 WRITE_BOOL_FIELD(is_no_inherit);
3518 WRITE_NODE_FIELD(raw_expr);
3519 WRITE_STRING_FIELD(cooked_expr);
3522 case CONSTR_PRIMARY:
3523 appendStringInfoString(str, "PRIMARY_KEY");
3524 WRITE_NODE_FIELD(keys);
3525 WRITE_NODE_FIELD(options);
3526 WRITE_STRING_FIELD(indexname);
3527 WRITE_STRING_FIELD(indexspace);
3528 /* access_method and where_clause not currently used */
3532 appendStringInfoString(str, "UNIQUE");
3533 WRITE_NODE_FIELD(keys);
3534 WRITE_NODE_FIELD(options);
3535 WRITE_STRING_FIELD(indexname);
3536 WRITE_STRING_FIELD(indexspace);
3537 /* access_method and where_clause not currently used */
3540 case CONSTR_EXCLUSION:
3541 appendStringInfoString(str, "EXCLUSION");
3542 WRITE_NODE_FIELD(exclusions);
3543 WRITE_NODE_FIELD(options);
3544 WRITE_STRING_FIELD(indexname);
3545 WRITE_STRING_FIELD(indexspace);
3546 WRITE_STRING_FIELD(access_method);
3547 WRITE_NODE_FIELD(where_clause);
3550 case CONSTR_FOREIGN:
3551 appendStringInfoString(str, "FOREIGN_KEY");
3552 WRITE_NODE_FIELD(pktable);
3553 WRITE_NODE_FIELD(fk_attrs);
3554 WRITE_NODE_FIELD(pk_attrs);
3555 WRITE_CHAR_FIELD(fk_matchtype);
3556 WRITE_CHAR_FIELD(fk_upd_action);
3557 WRITE_CHAR_FIELD(fk_del_action);
3558 WRITE_NODE_FIELD(old_conpfeqop);
3559 WRITE_OID_FIELD(old_pktable_oid);
3560 WRITE_BOOL_FIELD(skip_validation);
3561 WRITE_BOOL_FIELD(initially_valid);
3564 case CONSTR_ATTR_DEFERRABLE:
3565 appendStringInfoString(str, "ATTR_DEFERRABLE");
3568 case CONSTR_ATTR_NOT_DEFERRABLE:
3569 appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
3572 case CONSTR_ATTR_DEFERRED:
3573 appendStringInfoString(str, "ATTR_DEFERRED");
3576 case CONSTR_ATTR_IMMEDIATE:
3577 appendStringInfoString(str, "ATTR_IMMEDIATE");
3581 appendStringInfo(str, "<unrecognized_constraint %d>",
3582 (int) node->contype);
3588 _outForeignKeyCacheInfo(StringInfo str, const ForeignKeyCacheInfo *node)
3592 WRITE_NODE_TYPE("FOREIGNKEYCACHEINFO");
3594 WRITE_OID_FIELD(conrelid);
3595 WRITE_OID_FIELD(confrelid);
3596 WRITE_INT_FIELD(nkeys);
3597 appendStringInfoString(str, " :conkey");
3598 for (i = 0; i < node->nkeys; i++)
3599 appendStringInfo(str, " %d", node->conkey[i]);
3600 appendStringInfoString(str, " :confkey");
3601 for (i = 0; i < node->nkeys; i++)
3602 appendStringInfo(str, " %d", node->confkey[i]);
3603 appendStringInfoString(str, " :conpfeqop");
3604 for (i = 0; i < node->nkeys; i++)
3605 appendStringInfo(str, " %u", node->conpfeqop[i]);
3609 _outPartitionElem(StringInfo str, const PartitionElem *node)
3611 WRITE_NODE_TYPE("PARTITIONELEM");
3613 WRITE_STRING_FIELD(name);
3614 WRITE_NODE_FIELD(expr);
3615 WRITE_NODE_FIELD(collation);
3616 WRITE_NODE_FIELD(opclass);
3617 WRITE_LOCATION_FIELD(location);
3621 _outPartitionSpec(StringInfo str, const PartitionSpec *node)
3623 WRITE_NODE_TYPE("PARTITIONSPEC");
3625 WRITE_STRING_FIELD(strategy);
3626 WRITE_NODE_FIELD(partParams);
3627 WRITE_LOCATION_FIELD(location);
3631 _outPartitionBoundSpec(StringInfo str, const PartitionBoundSpec *node)
3633 WRITE_NODE_TYPE("PARTITIONBOUNDSPEC");
3635 WRITE_CHAR_FIELD(strategy);
3636 WRITE_BOOL_FIELD(is_default);
3637 WRITE_INT_FIELD(modulus);
3638 WRITE_INT_FIELD(remainder);
3639 WRITE_NODE_FIELD(listdatums);
3640 WRITE_NODE_FIELD(lowerdatums);
3641 WRITE_NODE_FIELD(upperdatums);
3642 WRITE_LOCATION_FIELD(location);
3646 _outPartitionRangeDatum(StringInfo str, const PartitionRangeDatum *node)
3648 WRITE_NODE_TYPE("PARTITIONRANGEDATUM");
3650 WRITE_ENUM_FIELD(kind, PartitionRangeDatumKind);
3651 WRITE_NODE_FIELD(value);
3652 WRITE_LOCATION_FIELD(location);
3657 * converts a Node into ascii string and append it to 'str'
3660 outNode(StringInfo str, const void *obj)
3663 appendStringInfoString(str, "<>");
3664 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
3666 else if (IsA(obj, Integer) ||
3669 IsA(obj, BitString))
3671 /* nodeRead does not want to see { } around these! */
3672 _outValue(str, obj);
3676 appendStringInfoChar(str, '{');
3677 switch (nodeTag(obj))
3680 _outPlannedStmt(str, obj);
3686 _outResult(str, obj);
3689 _outProjectSet(str, obj);
3692 _outModifyTable(str, obj);
3694 case T_MergeWhenClause:
3695 _outMergeWhenClause(str, obj);
3698 _outAppend(str, obj);
3701 _outMergeAppend(str, obj);
3703 case T_RecursiveUnion:
3704 _outRecursiveUnion(str, obj);
3707 _outBitmapAnd(str, obj);
3710 _outBitmapOr(str, obj);
3713 _outGather(str, obj);
3716 _outGatherMerge(str, obj);
3722 _outSeqScan(str, obj);
3725 _outSampleScan(str, obj);
3728 _outIndexScan(str, obj);
3730 case T_IndexOnlyScan:
3731 _outIndexOnlyScan(str, obj);
3733 case T_BitmapIndexScan:
3734 _outBitmapIndexScan(str, obj);
3736 case T_BitmapHeapScan:
3737 _outBitmapHeapScan(str, obj);
3740 _outTidScan(str, obj);
3742 case T_SubqueryScan:
3743 _outSubqueryScan(str, obj);
3745 case T_FunctionScan:
3746 _outFunctionScan(str, obj);
3748 case T_TableFuncScan:
3749 _outTableFuncScan(str, obj);
3752 _outValuesScan(str, obj);
3755 _outCteScan(str, obj);
3757 case T_NamedTuplestoreScan:
3758 _outNamedTuplestoreScan(str, obj);
3760 case T_WorkTableScan:
3761 _outWorkTableScan(str, obj);
3764 _outForeignScan(str, obj);
3767 _outCustomScan(str, obj);
3773 _outNestLoop(str, obj);
3776 _outMergeJoin(str, obj);
3779 _outHashJoin(str, obj);
3785 _outWindowAgg(str, obj);
3788 _outGroup(str, obj);
3791 _outMaterial(str, obj);
3797 _outUnique(str, obj);
3803 _outSetOp(str, obj);
3806 _outLockRows(str, obj);
3809 _outLimit(str, obj);
3811 case T_NestLoopParam:
3812 _outNestLoopParam(str, obj);
3815 _outPlanRowMark(str, obj);
3817 case T_PlanInvalItem:
3818 _outPlanInvalItem(str, obj);
3821 _outAlias(str, obj);
3824 _outRangeVar(str, obj);
3827 _outTableFunc(str, obj);
3830 _outIntoClause(str, obj);
3836 _outConst(str, obj);
3839 _outParam(str, obj);
3842 _outAggref(str, obj);
3844 case T_GroupingFunc:
3845 _outGroupingFunc(str, obj);
3848 _outWindowFunc(str, obj);
3851 _outArrayRef(str, obj);
3854 _outFuncExpr(str, obj);
3856 case T_NamedArgExpr:
3857 _outNamedArgExpr(str, obj);
3860 _outOpExpr(str, obj);
3862 case T_DistinctExpr:
3863 _outDistinctExpr(str, obj);
3866 _outNullIfExpr(str, obj);
3868 case T_ScalarArrayOpExpr:
3869 _outScalarArrayOpExpr(str, obj);
3872 _outBoolExpr(str, obj);
3875 _outSubLink(str, obj);
3878 _outSubPlan(str, obj);
3880 case T_AlternativeSubPlan:
3881 _outAlternativeSubPlan(str, obj);
3884 _outFieldSelect(str, obj);
3887 _outFieldStore(str, obj);
3890 _outRelabelType(str, obj);
3893 _outCoerceViaIO(str, obj);
3895 case T_ArrayCoerceExpr:
3896 _outArrayCoerceExpr(str, obj);
3898 case T_ConvertRowtypeExpr:
3899 _outConvertRowtypeExpr(str, obj);
3902 _outCollateExpr(str, obj);
3905 _outCaseExpr(str, obj);
3908 _outCaseWhen(str, obj);
3910 case T_CaseTestExpr:
3911 _outCaseTestExpr(str, obj);
3914 _outArrayExpr(str, obj);
3917 _outRowExpr(str, obj);
3919 case T_RowCompareExpr:
3920 _outRowCompareExpr(str, obj);
3922 case T_CoalesceExpr:
3923 _outCoalesceExpr(str, obj);
3926 _outMinMaxExpr(str, obj);
3928 case T_SQLValueFunction:
3929 _outSQLValueFunction(str, obj);
3932 _outXmlExpr(str, obj);
3935 _outNullTest(str, obj);
3938 _outBooleanTest(str, obj);
3940 case T_CoerceToDomain:
3941 _outCoerceToDomain(str, obj);
3943 case T_CoerceToDomainValue:
3944 _outCoerceToDomainValue(str, obj);
3946 case T_SetToDefault:
3947 _outSetToDefault(str, obj);
3949 case T_CurrentOfExpr:
3950 _outCurrentOfExpr(str, obj);
3952 case T_NextValueExpr:
3953 _outNextValueExpr(str, obj);
3955 case T_InferenceElem:
3956 _outInferenceElem(str, obj);
3959 _outTargetEntry(str, obj);
3962 _outRangeTblRef(str, obj);
3965 _outJoinExpr(str, obj);
3968 _outFromExpr(str, obj);
3970 case T_OnConflictExpr:
3971 _outOnConflictExpr(str, obj);
3974 _outMergeAction(str, obj);
3980 _outIndexPath(str, obj);
3982 case T_BitmapHeapPath:
3983 _outBitmapHeapPath(str, obj);
3985 case T_BitmapAndPath:
3986 _outBitmapAndPath(str, obj);
3988 case T_BitmapOrPath:
3989 _outBitmapOrPath(str, obj);
3992 _outTidPath(str, obj);
3994 case T_SubqueryScanPath:
3995 _outSubqueryScanPath(str, obj);
3998 _outForeignPath(str, obj);
4001 _outCustomPath(str, obj);
4004 _outAppendPath(str, obj);
4006 case T_MergeAppendPath:
4007 _outMergeAppendPath(str, obj);
4010 _outResultPath(str, obj);
4012 case T_MaterialPath:
4013 _outMaterialPath(str, obj);
4016 _outUniquePath(str, obj);
4019 _outGatherPath(str, obj);
4021 case T_ProjectionPath:
4022 _outProjectionPath(str, obj);
4024 case T_ProjectSetPath:
4025 _outProjectSetPath(str, obj);
4028 _outSortPath(str, obj);
4031 _outGroupPath(str, obj);
4033 case T_UpperUniquePath:
4034 _outUpperUniquePath(str, obj);
4037 _outAggPath(str, obj);
4039 case T_GroupingSetsPath:
4040 _outGroupingSetsPath(str, obj);
4042 case T_MinMaxAggPath:
4043 _outMinMaxAggPath(str, obj);
4045 case T_WindowAggPath:
4046 _outWindowAggPath(str, obj);
4049 _outSetOpPath(str, obj);
4051 case T_RecursiveUnionPath:
4052 _outRecursiveUnionPath(str, obj);
4054 case T_LockRowsPath:
4055 _outLockRowsPath(str, obj);
4057 case T_ModifyTablePath:
4058 _outModifyTablePath(str, obj);
4061 _outLimitPath(str, obj);
4063 case T_GatherMergePath:
4064 _outGatherMergePath(str, obj);
4067 _outNestPath(str, obj);
4070 _outMergePath(str, obj);
4073 _outHashPath(str, obj);
4075 case T_PlannerGlobal:
4076 _outPlannerGlobal(str, obj);
4079 _outPlannerInfo(str, obj);
4082 _outRelOptInfo(str, obj);
4084 case T_IndexOptInfo:
4085 _outIndexOptInfo(str, obj);
4087 case T_ForeignKeyOptInfo:
4088 _outForeignKeyOptInfo(str, obj);
4090 case T_EquivalenceClass:
4091 _outEquivalenceClass(str, obj);
4093 case T_EquivalenceMember:
4094 _outEquivalenceMember(str, obj);
4097 _outPathKey(str, obj);
4100 _outPathTarget(str, obj);
4102 case T_ParamPathInfo:
4103 _outParamPathInfo(str, obj);
4105 case T_RestrictInfo:
4106 _outRestrictInfo(str, obj);
4108 case T_PlaceHolderVar:
4109 _outPlaceHolderVar(str, obj);
4111 case T_SpecialJoinInfo:
4112 _outSpecialJoinInfo(str, obj);
4114 case T_AppendRelInfo:
4115 _outAppendRelInfo(str, obj);
4117 case T_PartitionedChildRelInfo:
4118 _outPartitionedChildRelInfo(str, obj);
4120 case T_PlaceHolderInfo:
4121 _outPlaceHolderInfo(str, obj);
4123 case T_MinMaxAggInfo:
4124 _outMinMaxAggInfo(str, obj);
4126 case T_PlannerParamItem:
4127 _outPlannerParamItem(str, obj);
4130 _outRollupData(str, obj);
4132 case T_GroupingSetData:
4133 _outGroupingSetData(str, obj);
4135 case T_StatisticExtInfo:
4136 _outStatisticExtInfo(str, obj);
4138 case T_ExtensibleNode:
4139 _outExtensibleNode(str, obj);
4142 _outCreateStmt(str, obj);
4144 case T_CreateForeignTableStmt:
4145 _outCreateForeignTableStmt(str, obj);
4147 case T_ImportForeignSchemaStmt:
4148 _outImportForeignSchemaStmt(str, obj);
4151 _outIndexStmt(str, obj);
4153 case T_CreateStatsStmt:
4154 _outCreateStatsStmt(str, obj);
4157 _outNotifyStmt(str, obj);
4159 case T_DeclareCursorStmt:
4160 _outDeclareCursorStmt(str, obj);
4163 _outSelectStmt(str, obj);
4166 _outColumnDef(str, obj);
4169 _outTypeName(str, obj);
4172 _outTypeCast(str, obj);
4174 case T_CollateClause:
4175 _outCollateClause(str, obj);
4178 _outIndexElem(str, obj);
4181 _outQuery(str, obj);
4183 case T_WithCheckOption:
4184 _outWithCheckOption(str, obj);
4186 case T_SortGroupClause:
4187 _outSortGroupClause(str, obj);
4190 _outGroupingSet(str, obj);
4192 case T_WindowClause:
4193 _outWindowClause(str, obj);
4195 case T_RowMarkClause:
4196 _outRowMarkClause(str, obj);
4199 _outWithClause(str, obj);
4201 case T_CommonTableExpr:
4202 _outCommonTableExpr(str, obj);
4204 case T_SetOperationStmt:
4205 _outSetOperationStmt(str, obj);
4207 case T_RangeTblEntry:
4208 _outRangeTblEntry(str, obj);
4210 case T_RangeTblFunction:
4211 _outRangeTblFunction(str, obj);
4213 case T_TableSampleClause:
4214 _outTableSampleClause(str, obj);
4217 _outAExpr(str, obj);
4220 _outColumnRef(str, obj);
4223 _outParamRef(str, obj);
4226 _outAConst(str, obj);
4229 _outA_Star(str, obj);
4232 _outA_Indices(str, obj);
4234 case T_A_Indirection:
4235 _outA_Indirection(str, obj);
4238 _outA_ArrayExpr(str, obj);
4241 _outResTarget(str, obj);
4243 case T_MultiAssignRef:
4244 _outMultiAssignRef(str, obj);
4247 _outSortBy(str, obj);
4250 _outWindowDef(str, obj);
4252 case T_RangeSubselect:
4253 _outRangeSubselect(str, obj);
4255 case T_RangeFunction:
4256 _outRangeFunction(str, obj);
4258 case T_RangeTableSample:
4259 _outRangeTableSample(str, obj);
4261 case T_RangeTableFunc:
4262 _outRangeTableFunc(str, obj);
4264 case T_RangeTableFuncCol:
4265 _outRangeTableFuncCol(str, obj);
4268 _outConstraint(str, obj);
4271 _outFuncCall(str, obj);
4274 _outDefElem(str, obj);
4276 case T_TableLikeClause:
4277 _outTableLikeClause(str, obj);
4279 case T_LockingClause:
4280 _outLockingClause(str, obj);
4282 case T_XmlSerialize:
4283 _outXmlSerialize(str, obj);
4285 case T_ForeignKeyCacheInfo:
4286 _outForeignKeyCacheInfo(str, obj);
4288 case T_TriggerTransition:
4289 _outTriggerTransition(str, obj);
4291 case T_PartitionElem:
4292 _outPartitionElem(str, obj);
4294 case T_PartitionSpec:
4295 _outPartitionSpec(str, obj);
4297 case T_PartitionBoundSpec:
4298 _outPartitionBoundSpec(str, obj);
4300 case T_PartitionRangeDatum:
4301 _outPartitionRangeDatum(str, obj);
4307 * This should be an ERROR, but it's too useful to be able to
4308 * dump structures that outNode only understands part of.
4310 elog(WARNING, "could not dump unrecognized node type: %d",
4311 (int) nodeTag(obj));
4314 appendStringInfoChar(str, '}');
4320 * returns the ascii representation of the Node as a palloc'd string
4323 nodeToString(const void *obj)
4327 /* see stringinfo.h for an explanation of this maneuver */
4328 initStringInfo(&str);
4335 * returns the ascii representation of the Bitmapset as a palloc'd string
4338 bmsToString(const Bitmapset *bms)
4342 /* see stringinfo.h for an explanation of this maneuver */
4343 initStringInfo(&str);
4344 outBitmapset(&str, bms);