1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/nodes/outfuncs.c
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify output of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire conventions about the names of the local variables in an Out
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41 appendStringInfoString(str, nodelabel)
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47 /* Write an unsigned integer field (anything written as ":fldname %u") */
48 #define WRITE_UINT_FIELD(fldname) \
49 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
51 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
52 #define WRITE_OID_FIELD(fldname) \
53 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
68 /* Write a float field --- caller must give format to define precision */
69 #define WRITE_FLOAT_FIELD(fldname,format) \
70 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75 booltostr(node->fldname))
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 _outToken(str, node->fldname))
82 /* Write a parse location field (actually same as INT case) */
83 #define WRITE_LOCATION_FIELD(fldname) \
84 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
86 /* Write a Node field */
87 #define WRITE_NODE_FIELD(fldname) \
88 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
89 _outNode(str, node->fldname))
91 /* Write a bitmapset field */
92 #define WRITE_BITMAPSET_FIELD(fldname) \
93 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
94 _outBitmapset(str, node->fldname))
97 #define booltostr(x) ((x) ? "true" : "false")
99 static void _outNode(StringInfo str, const void *obj);
104 * Convert an ordinary string (eg, an identifier) into a form that
105 * will be decoded back to a plain token by read.c's functions.
107 * If a null or empty string is given, it is encoded as "<>".
110 _outToken(StringInfo str, const char *s)
112 if (s == NULL || *s == '\0')
114 appendStringInfoString(str, "<>");
119 * Look for characters or patterns that are treated specially by read.c
120 * (either in pg_strtok() or in nodeRead()), and therefore need a
121 * protective backslash.
123 /* These characters only need to be quoted at the start of the string */
126 isdigit((unsigned char) *s) ||
127 ((*s == '+' || *s == '-') &&
128 (isdigit((unsigned char) s[1]) || s[1] == '.')))
129 appendStringInfoChar(str, '\\');
132 /* These chars must be backslashed anywhere in the string */
133 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
136 appendStringInfoChar(str, '\\');
137 appendStringInfoChar(str, *s++);
142 _outList(StringInfo str, const List *node)
146 appendStringInfoChar(str, '(');
148 if (IsA(node, IntList))
149 appendStringInfoChar(str, 'i');
150 else if (IsA(node, OidList))
151 appendStringInfoChar(str, 'o');
156 * For the sake of backward compatibility, we emit a slightly
157 * different whitespace format for lists of nodes vs. other types of
158 * lists. XXX: is this necessary?
162 _outNode(str, lfirst(lc));
164 appendStringInfoChar(str, ' ');
166 else if (IsA(node, IntList))
167 appendStringInfo(str, " %d", lfirst_int(lc));
168 else if (IsA(node, OidList))
169 appendStringInfo(str, " %u", lfirst_oid(lc));
171 elog(ERROR, "unrecognized list node type: %d",
175 appendStringInfoChar(str, ')');
180 * converts a bitmap set of integers
182 * Note: the output format is "(b int int ...)", similar to an integer List.
185 _outBitmapset(StringInfo str, const Bitmapset *bms)
189 appendStringInfoChar(str, '(');
190 appendStringInfoChar(str, 'b');
192 while ((x = bms_next_member(bms, x)) >= 0)
193 appendStringInfo(str, " %d", x);
194 appendStringInfoChar(str, ')');
198 * Print the value of a Datum given its type.
201 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
207 length = datumGetSize(value, typbyval, typlen);
211 s = (char *) (&value);
212 appendStringInfo(str, "%u [ ", (unsigned int) length);
213 for (i = 0; i < (Size) sizeof(Datum); i++)
214 appendStringInfo(str, "%d ", (int) (s[i]));
215 appendStringInfoChar(str, ']');
219 s = (char *) DatumGetPointer(value);
220 if (!PointerIsValid(s))
221 appendStringInfoString(str, "0 [ ]");
224 appendStringInfo(str, "%u [ ", (unsigned int) length);
225 for (i = 0; i < length; i++)
226 appendStringInfo(str, "%d ", (int) (s[i]));
227 appendStringInfoChar(str, ']');
234 * Stuff from plannodes.h
238 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
240 WRITE_NODE_TYPE("PLANNEDSTMT");
242 WRITE_ENUM_FIELD(commandType, CmdType);
243 WRITE_UINT_FIELD(queryId);
244 WRITE_BOOL_FIELD(hasReturning);
245 WRITE_BOOL_FIELD(hasModifyingCTE);
246 WRITE_BOOL_FIELD(canSetTag);
247 WRITE_BOOL_FIELD(transientPlan);
248 WRITE_NODE_FIELD(planTree);
249 WRITE_NODE_FIELD(rtable);
250 WRITE_NODE_FIELD(resultRelations);
251 WRITE_NODE_FIELD(utilityStmt);
252 WRITE_NODE_FIELD(subplans);
253 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
254 WRITE_NODE_FIELD(rowMarks);
255 WRITE_NODE_FIELD(relationOids);
256 WRITE_NODE_FIELD(invalItems);
257 WRITE_INT_FIELD(nParamExec);
258 WRITE_BOOL_FIELD(hasRowSecurity);
262 * print the basic stuff of all nodes that inherit from Plan
265 _outPlanInfo(StringInfo str, const Plan *node)
267 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
268 WRITE_FLOAT_FIELD(total_cost, "%.2f");
269 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
270 WRITE_INT_FIELD(plan_width);
271 WRITE_NODE_FIELD(targetlist);
272 WRITE_NODE_FIELD(qual);
273 WRITE_NODE_FIELD(lefttree);
274 WRITE_NODE_FIELD(righttree);
275 WRITE_NODE_FIELD(initPlan);
276 WRITE_BITMAPSET_FIELD(extParam);
277 WRITE_BITMAPSET_FIELD(allParam);
281 * print the basic stuff of all nodes that inherit from Scan
284 _outScanInfo(StringInfo str, const Scan *node)
286 _outPlanInfo(str, (const Plan *) node);
288 WRITE_UINT_FIELD(scanrelid);
292 * print the basic stuff of all nodes that inherit from Join
295 _outJoinPlanInfo(StringInfo str, const Join *node)
297 _outPlanInfo(str, (const Plan *) node);
299 WRITE_ENUM_FIELD(jointype, JoinType);
300 WRITE_NODE_FIELD(joinqual);
305 _outPlan(StringInfo str, const Plan *node)
307 WRITE_NODE_TYPE("PLAN");
309 _outPlanInfo(str, (const Plan *) node);
313 _outResult(StringInfo str, const Result *node)
315 WRITE_NODE_TYPE("RESULT");
317 _outPlanInfo(str, (const Plan *) node);
319 WRITE_NODE_FIELD(resconstantqual);
323 _outModifyTable(StringInfo str, const ModifyTable *node)
325 WRITE_NODE_TYPE("MODIFYTABLE");
327 _outPlanInfo(str, (const Plan *) node);
329 WRITE_ENUM_FIELD(operation, CmdType);
330 WRITE_BOOL_FIELD(canSetTag);
331 WRITE_UINT_FIELD(nominalRelation);
332 WRITE_NODE_FIELD(resultRelations);
333 WRITE_INT_FIELD(resultRelIndex);
334 WRITE_NODE_FIELD(plans);
335 WRITE_NODE_FIELD(withCheckOptionLists);
336 WRITE_NODE_FIELD(returningLists);
337 WRITE_NODE_FIELD(fdwPrivLists);
338 WRITE_NODE_FIELD(rowMarks);
339 WRITE_INT_FIELD(epqParam);
340 WRITE_ENUM_FIELD(onConflictAction, OnConflictAction);
341 WRITE_NODE_FIELD(arbiterIndexes);
342 WRITE_NODE_FIELD(onConflictSet);
343 WRITE_NODE_FIELD(onConflictWhere);
344 WRITE_UINT_FIELD(exclRelRTI);
345 WRITE_NODE_FIELD(exclRelTlist);
349 _outAppend(StringInfo str, const Append *node)
351 WRITE_NODE_TYPE("APPEND");
353 _outPlanInfo(str, (const Plan *) node);
355 WRITE_NODE_FIELD(appendplans);
359 _outMergeAppend(StringInfo str, const MergeAppend *node)
363 WRITE_NODE_TYPE("MERGEAPPEND");
365 _outPlanInfo(str, (const Plan *) node);
367 WRITE_NODE_FIELD(mergeplans);
369 WRITE_INT_FIELD(numCols);
371 appendStringInfoString(str, " :sortColIdx");
372 for (i = 0; i < node->numCols; i++)
373 appendStringInfo(str, " %d", node->sortColIdx[i]);
375 appendStringInfoString(str, " :sortOperators");
376 for (i = 0; i < node->numCols; i++)
377 appendStringInfo(str, " %u", node->sortOperators[i]);
379 appendStringInfoString(str, " :collations");
380 for (i = 0; i < node->numCols; i++)
381 appendStringInfo(str, " %u", node->collations[i]);
383 appendStringInfoString(str, " :nullsFirst");
384 for (i = 0; i < node->numCols; i++)
385 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
389 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
393 WRITE_NODE_TYPE("RECURSIVEUNION");
395 _outPlanInfo(str, (const Plan *) node);
397 WRITE_INT_FIELD(wtParam);
398 WRITE_INT_FIELD(numCols);
400 appendStringInfoString(str, " :dupColIdx");
401 for (i = 0; i < node->numCols; i++)
402 appendStringInfo(str, " %d", node->dupColIdx[i]);
404 appendStringInfoString(str, " :dupOperators");
405 for (i = 0; i < node->numCols; i++)
406 appendStringInfo(str, " %u", node->dupOperators[i]);
408 WRITE_LONG_FIELD(numGroups);
412 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
414 WRITE_NODE_TYPE("BITMAPAND");
416 _outPlanInfo(str, (const Plan *) node);
418 WRITE_NODE_FIELD(bitmapplans);
422 _outBitmapOr(StringInfo str, const BitmapOr *node)
424 WRITE_NODE_TYPE("BITMAPOR");
426 _outPlanInfo(str, (const Plan *) node);
428 WRITE_NODE_FIELD(bitmapplans);
432 _outScan(StringInfo str, const Scan *node)
434 WRITE_NODE_TYPE("SCAN");
436 _outScanInfo(str, node);
440 _outSeqScan(StringInfo str, const SeqScan *node)
442 WRITE_NODE_TYPE("SEQSCAN");
444 _outScanInfo(str, (const Scan *) node);
448 _outSampleScan(StringInfo str, const SampleScan *node)
450 WRITE_NODE_TYPE("SAMPLESCAN");
452 _outScanInfo(str, (const Scan *) node);
454 WRITE_NODE_FIELD(tablesample);
458 _outIndexScan(StringInfo str, const IndexScan *node)
460 WRITE_NODE_TYPE("INDEXSCAN");
462 _outScanInfo(str, (const Scan *) node);
464 WRITE_OID_FIELD(indexid);
465 WRITE_NODE_FIELD(indexqual);
466 WRITE_NODE_FIELD(indexqualorig);
467 WRITE_NODE_FIELD(indexorderby);
468 WRITE_NODE_FIELD(indexorderbyorig);
469 WRITE_NODE_FIELD(indexorderbyops);
470 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
474 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
476 WRITE_NODE_TYPE("INDEXONLYSCAN");
478 _outScanInfo(str, (const Scan *) node);
480 WRITE_OID_FIELD(indexid);
481 WRITE_NODE_FIELD(indexqual);
482 WRITE_NODE_FIELD(indexorderby);
483 WRITE_NODE_FIELD(indextlist);
484 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
488 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
490 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
492 _outScanInfo(str, (const Scan *) node);
494 WRITE_OID_FIELD(indexid);
495 WRITE_NODE_FIELD(indexqual);
496 WRITE_NODE_FIELD(indexqualorig);
500 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
502 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
504 _outScanInfo(str, (const Scan *) node);
506 WRITE_NODE_FIELD(bitmapqualorig);
510 _outTidScan(StringInfo str, const TidScan *node)
512 WRITE_NODE_TYPE("TIDSCAN");
514 _outScanInfo(str, (const Scan *) node);
516 WRITE_NODE_FIELD(tidquals);
520 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
522 WRITE_NODE_TYPE("SUBQUERYSCAN");
524 _outScanInfo(str, (const Scan *) node);
526 WRITE_NODE_FIELD(subplan);
530 _outFunctionScan(StringInfo str, const FunctionScan *node)
532 WRITE_NODE_TYPE("FUNCTIONSCAN");
534 _outScanInfo(str, (const Scan *) node);
536 WRITE_NODE_FIELD(functions);
537 WRITE_BOOL_FIELD(funcordinality);
541 _outValuesScan(StringInfo str, const ValuesScan *node)
543 WRITE_NODE_TYPE("VALUESSCAN");
545 _outScanInfo(str, (const Scan *) node);
547 WRITE_NODE_FIELD(values_lists);
551 _outCteScan(StringInfo str, const CteScan *node)
553 WRITE_NODE_TYPE("CTESCAN");
555 _outScanInfo(str, (const Scan *) node);
557 WRITE_INT_FIELD(ctePlanId);
558 WRITE_INT_FIELD(cteParam);
562 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
564 WRITE_NODE_TYPE("WORKTABLESCAN");
566 _outScanInfo(str, (const Scan *) node);
568 WRITE_INT_FIELD(wtParam);
572 _outForeignScan(StringInfo str, const ForeignScan *node)
574 WRITE_NODE_TYPE("FOREIGNSCAN");
576 _outScanInfo(str, (const Scan *) node);
578 WRITE_OID_FIELD(fs_server);
579 WRITE_NODE_FIELD(fdw_exprs);
580 WRITE_NODE_FIELD(fdw_private);
581 WRITE_NODE_FIELD(fdw_scan_tlist);
582 WRITE_BITMAPSET_FIELD(fs_relids);
583 WRITE_BOOL_FIELD(fsSystemCol);
587 _outCustomScan(StringInfo str, const CustomScan *node)
589 WRITE_NODE_TYPE("CUSTOMSCAN");
591 _outScanInfo(str, (const Scan *) node);
593 WRITE_UINT_FIELD(flags);
594 WRITE_NODE_FIELD(custom_plans);
595 WRITE_NODE_FIELD(custom_exprs);
596 WRITE_NODE_FIELD(custom_private);
597 WRITE_NODE_FIELD(custom_scan_tlist);
598 WRITE_BITMAPSET_FIELD(custom_relids);
599 appendStringInfoString(str, " :methods ");
600 _outToken(str, node->methods->CustomName);
601 if (node->methods->TextOutCustomScan)
602 node->methods->TextOutCustomScan(str, node);
606 _outJoin(StringInfo str, const Join *node)
608 WRITE_NODE_TYPE("JOIN");
610 _outJoinPlanInfo(str, (const Join *) node);
614 _outNestLoop(StringInfo str, const NestLoop *node)
616 WRITE_NODE_TYPE("NESTLOOP");
618 _outJoinPlanInfo(str, (const Join *) node);
620 WRITE_NODE_FIELD(nestParams);
624 _outMergeJoin(StringInfo str, const MergeJoin *node)
629 WRITE_NODE_TYPE("MERGEJOIN");
631 _outJoinPlanInfo(str, (const Join *) node);
633 WRITE_NODE_FIELD(mergeclauses);
635 numCols = list_length(node->mergeclauses);
637 appendStringInfoString(str, " :mergeFamilies");
638 for (i = 0; i < numCols; i++)
639 appendStringInfo(str, " %u", node->mergeFamilies[i]);
641 appendStringInfoString(str, " :mergeCollations");
642 for (i = 0; i < numCols; i++)
643 appendStringInfo(str, " %u", node->mergeCollations[i]);
645 appendStringInfoString(str, " :mergeStrategies");
646 for (i = 0; i < numCols; i++)
647 appendStringInfo(str, " %d", node->mergeStrategies[i]);
649 appendStringInfoString(str, " :mergeNullsFirst");
650 for (i = 0; i < numCols; i++)
651 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
655 _outHashJoin(StringInfo str, const HashJoin *node)
657 WRITE_NODE_TYPE("HASHJOIN");
659 _outJoinPlanInfo(str, (const Join *) node);
661 WRITE_NODE_FIELD(hashclauses);
665 _outAgg(StringInfo str, const Agg *node)
669 WRITE_NODE_TYPE("AGG");
671 _outPlanInfo(str, (const Plan *) node);
673 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
674 WRITE_INT_FIELD(numCols);
676 appendStringInfoString(str, " :grpColIdx");
677 for (i = 0; i < node->numCols; i++)
678 appendStringInfo(str, " %d", node->grpColIdx[i]);
680 appendStringInfoString(str, " :grpOperators");
681 for (i = 0; i < node->numCols; i++)
682 appendStringInfo(str, " %u", node->grpOperators[i]);
684 WRITE_LONG_FIELD(numGroups);
686 WRITE_NODE_FIELD(groupingSets);
687 WRITE_NODE_FIELD(chain);
691 _outWindowAgg(StringInfo str, const WindowAgg *node)
695 WRITE_NODE_TYPE("WINDOWAGG");
697 _outPlanInfo(str, (const Plan *) node);
699 WRITE_UINT_FIELD(winref);
700 WRITE_INT_FIELD(partNumCols);
702 appendStringInfoString(str, " :partColIdx");
703 for (i = 0; i < node->partNumCols; i++)
704 appendStringInfo(str, " %d", node->partColIdx[i]);
706 appendStringInfoString(str, " :partOperations");
707 for (i = 0; i < node->partNumCols; i++)
708 appendStringInfo(str, " %u", node->partOperators[i]);
710 WRITE_INT_FIELD(ordNumCols);
712 appendStringInfoString(str, " :ordColIdx");
713 for (i = 0; i < node->ordNumCols; i++)
714 appendStringInfo(str, " %d", node->ordColIdx[i]);
716 appendStringInfoString(str, " :ordOperations");
717 for (i = 0; i < node->ordNumCols; i++)
718 appendStringInfo(str, " %u", node->ordOperators[i]);
720 WRITE_INT_FIELD(frameOptions);
721 WRITE_NODE_FIELD(startOffset);
722 WRITE_NODE_FIELD(endOffset);
726 _outGroup(StringInfo str, const Group *node)
730 WRITE_NODE_TYPE("GROUP");
732 _outPlanInfo(str, (const Plan *) node);
734 WRITE_INT_FIELD(numCols);
736 appendStringInfoString(str, " :grpColIdx");
737 for (i = 0; i < node->numCols; i++)
738 appendStringInfo(str, " %d", node->grpColIdx[i]);
740 appendStringInfoString(str, " :grpOperators");
741 for (i = 0; i < node->numCols; i++)
742 appendStringInfo(str, " %u", node->grpOperators[i]);
746 _outMaterial(StringInfo str, const Material *node)
748 WRITE_NODE_TYPE("MATERIAL");
750 _outPlanInfo(str, (const Plan *) node);
754 _outSort(StringInfo str, const Sort *node)
758 WRITE_NODE_TYPE("SORT");
760 _outPlanInfo(str, (const Plan *) node);
762 WRITE_INT_FIELD(numCols);
764 appendStringInfoString(str, " :sortColIdx");
765 for (i = 0; i < node->numCols; i++)
766 appendStringInfo(str, " %d", node->sortColIdx[i]);
768 appendStringInfoString(str, " :sortOperators");
769 for (i = 0; i < node->numCols; i++)
770 appendStringInfo(str, " %u", node->sortOperators[i]);
772 appendStringInfoString(str, " :collations");
773 for (i = 0; i < node->numCols; i++)
774 appendStringInfo(str, " %u", node->collations[i]);
776 appendStringInfoString(str, " :nullsFirst");
777 for (i = 0; i < node->numCols; i++)
778 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
782 _outUnique(StringInfo str, const Unique *node)
786 WRITE_NODE_TYPE("UNIQUE");
788 _outPlanInfo(str, (const Plan *) node);
790 WRITE_INT_FIELD(numCols);
792 appendStringInfoString(str, " :uniqColIdx");
793 for (i = 0; i < node->numCols; i++)
794 appendStringInfo(str, " %d", node->uniqColIdx[i]);
796 appendStringInfoString(str, " :uniqOperators");
797 for (i = 0; i < node->numCols; i++)
798 appendStringInfo(str, " %u", node->uniqOperators[i]);
802 _outHash(StringInfo str, const Hash *node)
804 WRITE_NODE_TYPE("HASH");
806 _outPlanInfo(str, (const Plan *) node);
808 WRITE_OID_FIELD(skewTable);
809 WRITE_INT_FIELD(skewColumn);
810 WRITE_BOOL_FIELD(skewInherit);
811 WRITE_OID_FIELD(skewColType);
812 WRITE_INT_FIELD(skewColTypmod);
816 _outSetOp(StringInfo str, const SetOp *node)
820 WRITE_NODE_TYPE("SETOP");
822 _outPlanInfo(str, (const Plan *) node);
824 WRITE_ENUM_FIELD(cmd, SetOpCmd);
825 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
826 WRITE_INT_FIELD(numCols);
828 appendStringInfoString(str, " :dupColIdx");
829 for (i = 0; i < node->numCols; i++)
830 appendStringInfo(str, " %d", node->dupColIdx[i]);
832 appendStringInfoString(str, " :dupOperators");
833 for (i = 0; i < node->numCols; i++)
834 appendStringInfo(str, " %u", node->dupOperators[i]);
836 WRITE_INT_FIELD(flagColIdx);
837 WRITE_INT_FIELD(firstFlag);
838 WRITE_LONG_FIELD(numGroups);
842 _outLockRows(StringInfo str, const LockRows *node)
844 WRITE_NODE_TYPE("LOCKROWS");
846 _outPlanInfo(str, (const Plan *) node);
848 WRITE_NODE_FIELD(rowMarks);
849 WRITE_INT_FIELD(epqParam);
853 _outLimit(StringInfo str, const Limit *node)
855 WRITE_NODE_TYPE("LIMIT");
857 _outPlanInfo(str, (const Plan *) node);
859 WRITE_NODE_FIELD(limitOffset);
860 WRITE_NODE_FIELD(limitCount);
864 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
866 WRITE_NODE_TYPE("NESTLOOPPARAM");
868 WRITE_INT_FIELD(paramno);
869 WRITE_NODE_FIELD(paramval);
873 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
875 WRITE_NODE_TYPE("PLANROWMARK");
877 WRITE_UINT_FIELD(rti);
878 WRITE_UINT_FIELD(prti);
879 WRITE_UINT_FIELD(rowmarkId);
880 WRITE_ENUM_FIELD(markType, RowMarkType);
881 WRITE_INT_FIELD(allMarkTypes);
882 WRITE_ENUM_FIELD(strength, LockClauseStrength);
883 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
884 WRITE_BOOL_FIELD(isParent);
888 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
890 WRITE_NODE_TYPE("PLANINVALITEM");
892 WRITE_INT_FIELD(cacheId);
893 WRITE_UINT_FIELD(hashValue);
896 /*****************************************************************************
898 * Stuff from primnodes.h.
900 *****************************************************************************/
903 _outAlias(StringInfo str, const Alias *node)
905 WRITE_NODE_TYPE("ALIAS");
907 WRITE_STRING_FIELD(aliasname);
908 WRITE_NODE_FIELD(colnames);
912 _outRangeVar(StringInfo str, const RangeVar *node)
914 WRITE_NODE_TYPE("RANGEVAR");
917 * we deliberately ignore catalogname here, since it is presently not
918 * semantically meaningful
920 WRITE_STRING_FIELD(schemaname);
921 WRITE_STRING_FIELD(relname);
922 WRITE_ENUM_FIELD(inhOpt, InhOption);
923 WRITE_CHAR_FIELD(relpersistence);
924 WRITE_NODE_FIELD(alias);
925 WRITE_LOCATION_FIELD(location);
929 _outIntoClause(StringInfo str, const IntoClause *node)
931 WRITE_NODE_TYPE("INTOCLAUSE");
933 WRITE_NODE_FIELD(rel);
934 WRITE_NODE_FIELD(colNames);
935 WRITE_NODE_FIELD(options);
936 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
937 WRITE_STRING_FIELD(tableSpaceName);
938 WRITE_NODE_FIELD(viewQuery);
939 WRITE_BOOL_FIELD(skipData);
943 _outVar(StringInfo str, const Var *node)
945 WRITE_NODE_TYPE("VAR");
947 WRITE_UINT_FIELD(varno);
948 WRITE_INT_FIELD(varattno);
949 WRITE_OID_FIELD(vartype);
950 WRITE_INT_FIELD(vartypmod);
951 WRITE_OID_FIELD(varcollid);
952 WRITE_UINT_FIELD(varlevelsup);
953 WRITE_UINT_FIELD(varnoold);
954 WRITE_INT_FIELD(varoattno);
955 WRITE_LOCATION_FIELD(location);
959 _outConst(StringInfo str, const Const *node)
961 WRITE_NODE_TYPE("CONST");
963 WRITE_OID_FIELD(consttype);
964 WRITE_INT_FIELD(consttypmod);
965 WRITE_OID_FIELD(constcollid);
966 WRITE_INT_FIELD(constlen);
967 WRITE_BOOL_FIELD(constbyval);
968 WRITE_BOOL_FIELD(constisnull);
969 WRITE_LOCATION_FIELD(location);
971 appendStringInfoString(str, " :constvalue ");
972 if (node->constisnull)
973 appendStringInfoString(str, "<>");
975 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
979 _outParam(StringInfo str, const Param *node)
981 WRITE_NODE_TYPE("PARAM");
983 WRITE_ENUM_FIELD(paramkind, ParamKind);
984 WRITE_INT_FIELD(paramid);
985 WRITE_OID_FIELD(paramtype);
986 WRITE_INT_FIELD(paramtypmod);
987 WRITE_OID_FIELD(paramcollid);
988 WRITE_LOCATION_FIELD(location);
992 _outAggref(StringInfo str, const Aggref *node)
994 WRITE_NODE_TYPE("AGGREF");
996 WRITE_OID_FIELD(aggfnoid);
997 WRITE_OID_FIELD(aggtype);
998 WRITE_OID_FIELD(aggcollid);
999 WRITE_OID_FIELD(inputcollid);
1000 WRITE_NODE_FIELD(aggdirectargs);
1001 WRITE_NODE_FIELD(args);
1002 WRITE_NODE_FIELD(aggorder);
1003 WRITE_NODE_FIELD(aggdistinct);
1004 WRITE_NODE_FIELD(aggfilter);
1005 WRITE_BOOL_FIELD(aggstar);
1006 WRITE_BOOL_FIELD(aggvariadic);
1007 WRITE_CHAR_FIELD(aggkind);
1008 WRITE_UINT_FIELD(agglevelsup);
1009 WRITE_LOCATION_FIELD(location);
1013 _outGroupingFunc(StringInfo str, const GroupingFunc *node)
1015 WRITE_NODE_TYPE("GROUPINGFUNC");
1017 WRITE_NODE_FIELD(args);
1018 WRITE_NODE_FIELD(refs);
1019 WRITE_NODE_FIELD(cols);
1020 WRITE_UINT_FIELD(agglevelsup);
1021 WRITE_LOCATION_FIELD(location);
1025 _outWindowFunc(StringInfo str, const WindowFunc *node)
1027 WRITE_NODE_TYPE("WINDOWFUNC");
1029 WRITE_OID_FIELD(winfnoid);
1030 WRITE_OID_FIELD(wintype);
1031 WRITE_OID_FIELD(wincollid);
1032 WRITE_OID_FIELD(inputcollid);
1033 WRITE_NODE_FIELD(args);
1034 WRITE_NODE_FIELD(aggfilter);
1035 WRITE_UINT_FIELD(winref);
1036 WRITE_BOOL_FIELD(winstar);
1037 WRITE_BOOL_FIELD(winagg);
1038 WRITE_LOCATION_FIELD(location);
1042 _outArrayRef(StringInfo str, const ArrayRef *node)
1044 WRITE_NODE_TYPE("ARRAYREF");
1046 WRITE_OID_FIELD(refarraytype);
1047 WRITE_OID_FIELD(refelemtype);
1048 WRITE_INT_FIELD(reftypmod);
1049 WRITE_OID_FIELD(refcollid);
1050 WRITE_NODE_FIELD(refupperindexpr);
1051 WRITE_NODE_FIELD(reflowerindexpr);
1052 WRITE_NODE_FIELD(refexpr);
1053 WRITE_NODE_FIELD(refassgnexpr);
1057 _outFuncExpr(StringInfo str, const FuncExpr *node)
1059 WRITE_NODE_TYPE("FUNCEXPR");
1061 WRITE_OID_FIELD(funcid);
1062 WRITE_OID_FIELD(funcresulttype);
1063 WRITE_BOOL_FIELD(funcretset);
1064 WRITE_BOOL_FIELD(funcvariadic);
1065 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1066 WRITE_OID_FIELD(funccollid);
1067 WRITE_OID_FIELD(inputcollid);
1068 WRITE_NODE_FIELD(args);
1069 WRITE_LOCATION_FIELD(location);
1073 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1075 WRITE_NODE_TYPE("NAMEDARGEXPR");
1077 WRITE_NODE_FIELD(arg);
1078 WRITE_STRING_FIELD(name);
1079 WRITE_INT_FIELD(argnumber);
1080 WRITE_LOCATION_FIELD(location);
1084 _outOpExpr(StringInfo str, const OpExpr *node)
1086 WRITE_NODE_TYPE("OPEXPR");
1088 WRITE_OID_FIELD(opno);
1089 WRITE_OID_FIELD(opfuncid);
1090 WRITE_OID_FIELD(opresulttype);
1091 WRITE_BOOL_FIELD(opretset);
1092 WRITE_OID_FIELD(opcollid);
1093 WRITE_OID_FIELD(inputcollid);
1094 WRITE_NODE_FIELD(args);
1095 WRITE_LOCATION_FIELD(location);
1099 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1101 WRITE_NODE_TYPE("DISTINCTEXPR");
1103 WRITE_OID_FIELD(opno);
1104 WRITE_OID_FIELD(opfuncid);
1105 WRITE_OID_FIELD(opresulttype);
1106 WRITE_BOOL_FIELD(opretset);
1107 WRITE_OID_FIELD(opcollid);
1108 WRITE_OID_FIELD(inputcollid);
1109 WRITE_NODE_FIELD(args);
1110 WRITE_LOCATION_FIELD(location);
1114 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1116 WRITE_NODE_TYPE("NULLIFEXPR");
1118 WRITE_OID_FIELD(opno);
1119 WRITE_OID_FIELD(opfuncid);
1120 WRITE_OID_FIELD(opresulttype);
1121 WRITE_BOOL_FIELD(opretset);
1122 WRITE_OID_FIELD(opcollid);
1123 WRITE_OID_FIELD(inputcollid);
1124 WRITE_NODE_FIELD(args);
1125 WRITE_LOCATION_FIELD(location);
1129 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1131 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1133 WRITE_OID_FIELD(opno);
1134 WRITE_OID_FIELD(opfuncid);
1135 WRITE_BOOL_FIELD(useOr);
1136 WRITE_OID_FIELD(inputcollid);
1137 WRITE_NODE_FIELD(args);
1138 WRITE_LOCATION_FIELD(location);
1142 _outBoolExpr(StringInfo str, const BoolExpr *node)
1146 WRITE_NODE_TYPE("BOOLEXPR");
1148 /* do-it-yourself enum representation */
1149 switch (node->boolop)
1161 appendStringInfoString(str, " :boolop ");
1162 _outToken(str, opstr);
1164 WRITE_NODE_FIELD(args);
1165 WRITE_LOCATION_FIELD(location);
1169 _outSubLink(StringInfo str, const SubLink *node)
1171 WRITE_NODE_TYPE("SUBLINK");
1173 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1174 WRITE_INT_FIELD(subLinkId);
1175 WRITE_NODE_FIELD(testexpr);
1176 WRITE_NODE_FIELD(operName);
1177 WRITE_NODE_FIELD(subselect);
1178 WRITE_LOCATION_FIELD(location);
1182 _outSubPlan(StringInfo str, const SubPlan *node)
1184 WRITE_NODE_TYPE("SUBPLAN");
1186 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1187 WRITE_NODE_FIELD(testexpr);
1188 WRITE_NODE_FIELD(paramIds);
1189 WRITE_INT_FIELD(plan_id);
1190 WRITE_STRING_FIELD(plan_name);
1191 WRITE_OID_FIELD(firstColType);
1192 WRITE_INT_FIELD(firstColTypmod);
1193 WRITE_OID_FIELD(firstColCollation);
1194 WRITE_BOOL_FIELD(useHashTable);
1195 WRITE_BOOL_FIELD(unknownEqFalse);
1196 WRITE_NODE_FIELD(setParam);
1197 WRITE_NODE_FIELD(parParam);
1198 WRITE_NODE_FIELD(args);
1199 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1200 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1204 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1206 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1208 WRITE_NODE_FIELD(subplans);
1212 _outFieldSelect(StringInfo str, const FieldSelect *node)
1214 WRITE_NODE_TYPE("FIELDSELECT");
1216 WRITE_NODE_FIELD(arg);
1217 WRITE_INT_FIELD(fieldnum);
1218 WRITE_OID_FIELD(resulttype);
1219 WRITE_INT_FIELD(resulttypmod);
1220 WRITE_OID_FIELD(resultcollid);
1224 _outFieldStore(StringInfo str, const FieldStore *node)
1226 WRITE_NODE_TYPE("FIELDSTORE");
1228 WRITE_NODE_FIELD(arg);
1229 WRITE_NODE_FIELD(newvals);
1230 WRITE_NODE_FIELD(fieldnums);
1231 WRITE_OID_FIELD(resulttype);
1235 _outRelabelType(StringInfo str, const RelabelType *node)
1237 WRITE_NODE_TYPE("RELABELTYPE");
1239 WRITE_NODE_FIELD(arg);
1240 WRITE_OID_FIELD(resulttype);
1241 WRITE_INT_FIELD(resulttypmod);
1242 WRITE_OID_FIELD(resultcollid);
1243 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1244 WRITE_LOCATION_FIELD(location);
1248 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1250 WRITE_NODE_TYPE("COERCEVIAIO");
1252 WRITE_NODE_FIELD(arg);
1253 WRITE_OID_FIELD(resulttype);
1254 WRITE_OID_FIELD(resultcollid);
1255 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1256 WRITE_LOCATION_FIELD(location);
1260 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1262 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1264 WRITE_NODE_FIELD(arg);
1265 WRITE_OID_FIELD(elemfuncid);
1266 WRITE_OID_FIELD(resulttype);
1267 WRITE_INT_FIELD(resulttypmod);
1268 WRITE_OID_FIELD(resultcollid);
1269 WRITE_BOOL_FIELD(isExplicit);
1270 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1271 WRITE_LOCATION_FIELD(location);
1275 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1277 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1279 WRITE_NODE_FIELD(arg);
1280 WRITE_OID_FIELD(resulttype);
1281 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1282 WRITE_LOCATION_FIELD(location);
1286 _outCollateExpr(StringInfo str, const CollateExpr *node)
1288 WRITE_NODE_TYPE("COLLATE");
1290 WRITE_NODE_FIELD(arg);
1291 WRITE_OID_FIELD(collOid);
1292 WRITE_LOCATION_FIELD(location);
1296 _outCaseExpr(StringInfo str, const CaseExpr *node)
1298 WRITE_NODE_TYPE("CASE");
1300 WRITE_OID_FIELD(casetype);
1301 WRITE_OID_FIELD(casecollid);
1302 WRITE_NODE_FIELD(arg);
1303 WRITE_NODE_FIELD(args);
1304 WRITE_NODE_FIELD(defresult);
1305 WRITE_LOCATION_FIELD(location);
1309 _outCaseWhen(StringInfo str, const CaseWhen *node)
1311 WRITE_NODE_TYPE("WHEN");
1313 WRITE_NODE_FIELD(expr);
1314 WRITE_NODE_FIELD(result);
1315 WRITE_LOCATION_FIELD(location);
1319 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1321 WRITE_NODE_TYPE("CASETESTEXPR");
1323 WRITE_OID_FIELD(typeId);
1324 WRITE_INT_FIELD(typeMod);
1325 WRITE_OID_FIELD(collation);
1329 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1331 WRITE_NODE_TYPE("ARRAY");
1333 WRITE_OID_FIELD(array_typeid);
1334 WRITE_OID_FIELD(array_collid);
1335 WRITE_OID_FIELD(element_typeid);
1336 WRITE_NODE_FIELD(elements);
1337 WRITE_BOOL_FIELD(multidims);
1338 WRITE_LOCATION_FIELD(location);
1342 _outRowExpr(StringInfo str, const RowExpr *node)
1344 WRITE_NODE_TYPE("ROW");
1346 WRITE_NODE_FIELD(args);
1347 WRITE_OID_FIELD(row_typeid);
1348 WRITE_ENUM_FIELD(row_format, CoercionForm);
1349 WRITE_NODE_FIELD(colnames);
1350 WRITE_LOCATION_FIELD(location);
1354 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1356 WRITE_NODE_TYPE("ROWCOMPARE");
1358 WRITE_ENUM_FIELD(rctype, RowCompareType);
1359 WRITE_NODE_FIELD(opnos);
1360 WRITE_NODE_FIELD(opfamilies);
1361 WRITE_NODE_FIELD(inputcollids);
1362 WRITE_NODE_FIELD(largs);
1363 WRITE_NODE_FIELD(rargs);
1367 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1369 WRITE_NODE_TYPE("COALESCE");
1371 WRITE_OID_FIELD(coalescetype);
1372 WRITE_OID_FIELD(coalescecollid);
1373 WRITE_NODE_FIELD(args);
1374 WRITE_LOCATION_FIELD(location);
1378 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1380 WRITE_NODE_TYPE("MINMAX");
1382 WRITE_OID_FIELD(minmaxtype);
1383 WRITE_OID_FIELD(minmaxcollid);
1384 WRITE_OID_FIELD(inputcollid);
1385 WRITE_ENUM_FIELD(op, MinMaxOp);
1386 WRITE_NODE_FIELD(args);
1387 WRITE_LOCATION_FIELD(location);
1391 _outXmlExpr(StringInfo str, const XmlExpr *node)
1393 WRITE_NODE_TYPE("XMLEXPR");
1395 WRITE_ENUM_FIELD(op, XmlExprOp);
1396 WRITE_STRING_FIELD(name);
1397 WRITE_NODE_FIELD(named_args);
1398 WRITE_NODE_FIELD(arg_names);
1399 WRITE_NODE_FIELD(args);
1400 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1401 WRITE_OID_FIELD(type);
1402 WRITE_INT_FIELD(typmod);
1403 WRITE_LOCATION_FIELD(location);
1407 _outNullTest(StringInfo str, const NullTest *node)
1409 WRITE_NODE_TYPE("NULLTEST");
1411 WRITE_NODE_FIELD(arg);
1412 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1413 WRITE_BOOL_FIELD(argisrow);
1414 WRITE_LOCATION_FIELD(location);
1418 _outBooleanTest(StringInfo str, const BooleanTest *node)
1420 WRITE_NODE_TYPE("BOOLEANTEST");
1422 WRITE_NODE_FIELD(arg);
1423 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1424 WRITE_LOCATION_FIELD(location);
1428 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1430 WRITE_NODE_TYPE("COERCETODOMAIN");
1432 WRITE_NODE_FIELD(arg);
1433 WRITE_OID_FIELD(resulttype);
1434 WRITE_INT_FIELD(resulttypmod);
1435 WRITE_OID_FIELD(resultcollid);
1436 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1437 WRITE_LOCATION_FIELD(location);
1441 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1443 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1445 WRITE_OID_FIELD(typeId);
1446 WRITE_INT_FIELD(typeMod);
1447 WRITE_OID_FIELD(collation);
1448 WRITE_LOCATION_FIELD(location);
1452 _outSetToDefault(StringInfo str, const SetToDefault *node)
1454 WRITE_NODE_TYPE("SETTODEFAULT");
1456 WRITE_OID_FIELD(typeId);
1457 WRITE_INT_FIELD(typeMod);
1458 WRITE_OID_FIELD(collation);
1459 WRITE_LOCATION_FIELD(location);
1463 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1465 WRITE_NODE_TYPE("CURRENTOFEXPR");
1467 WRITE_UINT_FIELD(cvarno);
1468 WRITE_STRING_FIELD(cursor_name);
1469 WRITE_INT_FIELD(cursor_param);
1473 _outInferenceElem(StringInfo str, const InferenceElem *node)
1475 WRITE_NODE_TYPE("INFERENCEELEM");
1477 WRITE_NODE_FIELD(expr);
1478 WRITE_OID_FIELD(infercollid);
1479 WRITE_OID_FIELD(inferopclass);
1483 _outTargetEntry(StringInfo str, const TargetEntry *node)
1485 WRITE_NODE_TYPE("TARGETENTRY");
1487 WRITE_NODE_FIELD(expr);
1488 WRITE_INT_FIELD(resno);
1489 WRITE_STRING_FIELD(resname);
1490 WRITE_UINT_FIELD(ressortgroupref);
1491 WRITE_OID_FIELD(resorigtbl);
1492 WRITE_INT_FIELD(resorigcol);
1493 WRITE_BOOL_FIELD(resjunk);
1497 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1499 WRITE_NODE_TYPE("RANGETBLREF");
1501 WRITE_INT_FIELD(rtindex);
1505 _outJoinExpr(StringInfo str, const JoinExpr *node)
1507 WRITE_NODE_TYPE("JOINEXPR");
1509 WRITE_ENUM_FIELD(jointype, JoinType);
1510 WRITE_BOOL_FIELD(isNatural);
1511 WRITE_NODE_FIELD(larg);
1512 WRITE_NODE_FIELD(rarg);
1513 WRITE_NODE_FIELD(usingClause);
1514 WRITE_NODE_FIELD(quals);
1515 WRITE_NODE_FIELD(alias);
1516 WRITE_INT_FIELD(rtindex);
1520 _outFromExpr(StringInfo str, const FromExpr *node)
1522 WRITE_NODE_TYPE("FROMEXPR");
1524 WRITE_NODE_FIELD(fromlist);
1525 WRITE_NODE_FIELD(quals);
1529 _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
1531 WRITE_NODE_TYPE("ONCONFLICTEXPR");
1533 WRITE_ENUM_FIELD(action, OnConflictAction);
1534 WRITE_NODE_FIELD(arbiterElems);
1535 WRITE_NODE_FIELD(arbiterWhere);
1536 WRITE_OID_FIELD(constraint);
1537 WRITE_NODE_FIELD(onConflictSet);
1538 WRITE_NODE_FIELD(onConflictWhere);
1539 WRITE_INT_FIELD(exclRelIndex);
1540 WRITE_NODE_FIELD(exclRelTlist);
1543 /*****************************************************************************
1545 * Stuff from relation.h.
1547 *****************************************************************************/
1550 * print the basic stuff of all nodes that inherit from Path
1552 * Note we do NOT print the parent, else we'd be in infinite recursion.
1553 * We can print the parent's relids for identification purposes, though.
1554 * We also do not print the whole of param_info, since it's printed by
1555 * _outRelOptInfo; it's sufficient and less cluttering to print just the
1556 * required outer relids.
1559 _outPathInfo(StringInfo str, const Path *node)
1561 WRITE_ENUM_FIELD(pathtype, NodeTag);
1562 appendStringInfoString(str, " :parent_relids ");
1564 _outBitmapset(str, node->parent->relids);
1566 _outBitmapset(str, NULL);
1567 appendStringInfoString(str, " :required_outer ");
1568 if (node->param_info)
1569 _outBitmapset(str, node->param_info->ppi_req_outer);
1571 _outBitmapset(str, NULL);
1572 WRITE_FLOAT_FIELD(rows, "%.0f");
1573 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1574 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1575 WRITE_NODE_FIELD(pathkeys);
1579 * print the basic stuff of all nodes that inherit from JoinPath
1582 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1584 _outPathInfo(str, (const Path *) node);
1586 WRITE_ENUM_FIELD(jointype, JoinType);
1587 WRITE_NODE_FIELD(outerjoinpath);
1588 WRITE_NODE_FIELD(innerjoinpath);
1589 WRITE_NODE_FIELD(joinrestrictinfo);
1593 _outPath(StringInfo str, const Path *node)
1595 WRITE_NODE_TYPE("PATH");
1597 _outPathInfo(str, (const Path *) node);
1601 _outIndexPath(StringInfo str, const IndexPath *node)
1603 WRITE_NODE_TYPE("INDEXPATH");
1605 _outPathInfo(str, (const Path *) node);
1607 WRITE_NODE_FIELD(indexinfo);
1608 WRITE_NODE_FIELD(indexclauses);
1609 WRITE_NODE_FIELD(indexquals);
1610 WRITE_NODE_FIELD(indexqualcols);
1611 WRITE_NODE_FIELD(indexorderbys);
1612 WRITE_NODE_FIELD(indexorderbycols);
1613 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1614 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1615 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1619 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1621 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1623 _outPathInfo(str, (const Path *) node);
1625 WRITE_NODE_FIELD(bitmapqual);
1629 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1631 WRITE_NODE_TYPE("BITMAPANDPATH");
1633 _outPathInfo(str, (const Path *) node);
1635 WRITE_NODE_FIELD(bitmapquals);
1636 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1640 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1642 WRITE_NODE_TYPE("BITMAPORPATH");
1644 _outPathInfo(str, (const Path *) node);
1646 WRITE_NODE_FIELD(bitmapquals);
1647 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1651 _outTidPath(StringInfo str, const TidPath *node)
1653 WRITE_NODE_TYPE("TIDPATH");
1655 _outPathInfo(str, (const Path *) node);
1657 WRITE_NODE_FIELD(tidquals);
1661 _outForeignPath(StringInfo str, const ForeignPath *node)
1663 WRITE_NODE_TYPE("FOREIGNPATH");
1665 _outPathInfo(str, (const Path *) node);
1667 WRITE_NODE_FIELD(fdw_private);
1671 _outCustomPath(StringInfo str, const CustomPath *node)
1673 WRITE_NODE_TYPE("CUSTOMPATH");
1675 _outPathInfo(str, (const Path *) node);
1677 WRITE_UINT_FIELD(flags);
1678 WRITE_NODE_FIELD(custom_paths);
1679 WRITE_NODE_FIELD(custom_private);
1680 appendStringInfoString(str, " :methods ");
1681 _outToken(str, node->methods->CustomName);
1682 if (node->methods->TextOutCustomPath)
1683 node->methods->TextOutCustomPath(str, node);
1687 _outAppendPath(StringInfo str, const AppendPath *node)
1689 WRITE_NODE_TYPE("APPENDPATH");
1691 _outPathInfo(str, (const Path *) node);
1693 WRITE_NODE_FIELD(subpaths);
1697 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1699 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1701 _outPathInfo(str, (const Path *) node);
1703 WRITE_NODE_FIELD(subpaths);
1704 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1708 _outResultPath(StringInfo str, const ResultPath *node)
1710 WRITE_NODE_TYPE("RESULTPATH");
1712 _outPathInfo(str, (const Path *) node);
1714 WRITE_NODE_FIELD(quals);
1718 _outMaterialPath(StringInfo str, const MaterialPath *node)
1720 WRITE_NODE_TYPE("MATERIALPATH");
1722 _outPathInfo(str, (const Path *) node);
1724 WRITE_NODE_FIELD(subpath);
1728 _outUniquePath(StringInfo str, const UniquePath *node)
1730 WRITE_NODE_TYPE("UNIQUEPATH");
1732 _outPathInfo(str, (const Path *) node);
1734 WRITE_NODE_FIELD(subpath);
1735 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1736 WRITE_NODE_FIELD(in_operators);
1737 WRITE_NODE_FIELD(uniq_exprs);
1741 _outNestPath(StringInfo str, const NestPath *node)
1743 WRITE_NODE_TYPE("NESTPATH");
1745 _outJoinPathInfo(str, (const JoinPath *) node);
1749 _outMergePath(StringInfo str, const MergePath *node)
1751 WRITE_NODE_TYPE("MERGEPATH");
1753 _outJoinPathInfo(str, (const JoinPath *) node);
1755 WRITE_NODE_FIELD(path_mergeclauses);
1756 WRITE_NODE_FIELD(outersortkeys);
1757 WRITE_NODE_FIELD(innersortkeys);
1758 WRITE_BOOL_FIELD(materialize_inner);
1762 _outHashPath(StringInfo str, const HashPath *node)
1764 WRITE_NODE_TYPE("HASHPATH");
1766 _outJoinPathInfo(str, (const JoinPath *) node);
1768 WRITE_NODE_FIELD(path_hashclauses);
1769 WRITE_INT_FIELD(num_batches);
1773 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
1775 WRITE_NODE_TYPE("PLANNERGLOBAL");
1777 /* NB: this isn't a complete set of fields */
1778 WRITE_NODE_FIELD(subplans);
1779 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1780 WRITE_NODE_FIELD(finalrtable);
1781 WRITE_NODE_FIELD(finalrowmarks);
1782 WRITE_NODE_FIELD(resultRelations);
1783 WRITE_NODE_FIELD(relationOids);
1784 WRITE_NODE_FIELD(invalItems);
1785 WRITE_INT_FIELD(nParamExec);
1786 WRITE_UINT_FIELD(lastPHId);
1787 WRITE_UINT_FIELD(lastRowMarkId);
1788 WRITE_BOOL_FIELD(transientPlan);
1789 WRITE_BOOL_FIELD(hasRowSecurity);
1793 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
1795 WRITE_NODE_TYPE("PLANNERINFO");
1797 /* NB: this isn't a complete set of fields */
1798 WRITE_NODE_FIELD(parse);
1799 WRITE_NODE_FIELD(glob);
1800 WRITE_UINT_FIELD(query_level);
1801 WRITE_NODE_FIELD(plan_params);
1802 WRITE_BITMAPSET_FIELD(outer_params);
1803 WRITE_BITMAPSET_FIELD(all_baserels);
1804 WRITE_BITMAPSET_FIELD(nullable_baserels);
1805 WRITE_NODE_FIELD(join_rel_list);
1806 WRITE_INT_FIELD(join_cur_level);
1807 WRITE_NODE_FIELD(init_plans);
1808 WRITE_NODE_FIELD(cte_plan_ids);
1809 WRITE_NODE_FIELD(multiexpr_params);
1810 WRITE_NODE_FIELD(eq_classes);
1811 WRITE_NODE_FIELD(canon_pathkeys);
1812 WRITE_NODE_FIELD(left_join_clauses);
1813 WRITE_NODE_FIELD(right_join_clauses);
1814 WRITE_NODE_FIELD(full_join_clauses);
1815 WRITE_NODE_FIELD(join_info_list);
1816 WRITE_NODE_FIELD(lateral_info_list);
1817 WRITE_NODE_FIELD(append_rel_list);
1818 WRITE_NODE_FIELD(rowMarks);
1819 WRITE_NODE_FIELD(placeholder_list);
1820 WRITE_NODE_FIELD(query_pathkeys);
1821 WRITE_NODE_FIELD(group_pathkeys);
1822 WRITE_NODE_FIELD(window_pathkeys);
1823 WRITE_NODE_FIELD(distinct_pathkeys);
1824 WRITE_NODE_FIELD(sort_pathkeys);
1825 WRITE_NODE_FIELD(minmax_aggs);
1826 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1827 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1828 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1829 WRITE_BOOL_FIELD(hasInheritedTarget);
1830 WRITE_BOOL_FIELD(hasJoinRTEs);
1831 WRITE_BOOL_FIELD(hasLateralRTEs);
1832 WRITE_BOOL_FIELD(hasDeletedRTEs);
1833 WRITE_BOOL_FIELD(hasHavingQual);
1834 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1835 WRITE_BOOL_FIELD(hasRecursion);
1836 WRITE_INT_FIELD(wt_param_id);
1837 WRITE_BITMAPSET_FIELD(curOuterRels);
1838 WRITE_NODE_FIELD(curOuterParams);
1842 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
1844 WRITE_NODE_TYPE("RELOPTINFO");
1846 /* NB: this isn't a complete set of fields */
1847 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1848 WRITE_BITMAPSET_FIELD(relids);
1849 WRITE_FLOAT_FIELD(rows, "%.0f");
1850 WRITE_INT_FIELD(width);
1851 WRITE_BOOL_FIELD(consider_startup);
1852 WRITE_BOOL_FIELD(consider_param_startup);
1853 WRITE_NODE_FIELD(reltargetlist);
1854 WRITE_NODE_FIELD(pathlist);
1855 WRITE_NODE_FIELD(ppilist);
1856 WRITE_NODE_FIELD(cheapest_startup_path);
1857 WRITE_NODE_FIELD(cheapest_total_path);
1858 WRITE_NODE_FIELD(cheapest_unique_path);
1859 WRITE_NODE_FIELD(cheapest_parameterized_paths);
1860 WRITE_UINT_FIELD(relid);
1861 WRITE_OID_FIELD(reltablespace);
1862 WRITE_ENUM_FIELD(rtekind, RTEKind);
1863 WRITE_INT_FIELD(min_attr);
1864 WRITE_INT_FIELD(max_attr);
1865 WRITE_NODE_FIELD(lateral_vars);
1866 WRITE_BITMAPSET_FIELD(lateral_relids);
1867 WRITE_BITMAPSET_FIELD(lateral_referencers);
1868 WRITE_NODE_FIELD(indexlist);
1869 WRITE_UINT_FIELD(pages);
1870 WRITE_FLOAT_FIELD(tuples, "%.0f");
1871 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
1872 WRITE_NODE_FIELD(subplan);
1873 WRITE_NODE_FIELD(subroot);
1874 WRITE_NODE_FIELD(subplan_params);
1875 WRITE_OID_FIELD(serverid);
1876 /* we don't try to print fdwroutine or fdw_private */
1877 WRITE_NODE_FIELD(baserestrictinfo);
1878 WRITE_NODE_FIELD(joininfo);
1879 WRITE_BOOL_FIELD(has_eclass_joins);
1883 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
1885 WRITE_NODE_TYPE("INDEXOPTINFO");
1887 /* NB: this isn't a complete set of fields */
1888 WRITE_OID_FIELD(indexoid);
1889 /* Do NOT print rel field, else infinite recursion */
1890 WRITE_UINT_FIELD(pages);
1891 WRITE_FLOAT_FIELD(tuples, "%.0f");
1892 WRITE_INT_FIELD(tree_height);
1893 WRITE_INT_FIELD(ncolumns);
1894 /* array fields aren't really worth the trouble to print */
1895 WRITE_OID_FIELD(relam);
1896 /* indexprs is redundant since we print indextlist */
1897 WRITE_NODE_FIELD(indpred);
1898 WRITE_NODE_FIELD(indextlist);
1899 WRITE_BOOL_FIELD(predOK);
1900 WRITE_BOOL_FIELD(unique);
1901 WRITE_BOOL_FIELD(immediate);
1902 WRITE_BOOL_FIELD(hypothetical);
1903 /* we don't bother with fields copied from the pg_am entry */
1907 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
1910 * To simplify reading, we just chase up to the topmost merged EC and
1911 * print that, without bothering to show the merge-ees separately.
1913 while (node->ec_merged)
1914 node = node->ec_merged;
1916 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1918 WRITE_NODE_FIELD(ec_opfamilies);
1919 WRITE_OID_FIELD(ec_collation);
1920 WRITE_NODE_FIELD(ec_members);
1921 WRITE_NODE_FIELD(ec_sources);
1922 WRITE_NODE_FIELD(ec_derives);
1923 WRITE_BITMAPSET_FIELD(ec_relids);
1924 WRITE_BOOL_FIELD(ec_has_const);
1925 WRITE_BOOL_FIELD(ec_has_volatile);
1926 WRITE_BOOL_FIELD(ec_below_outer_join);
1927 WRITE_BOOL_FIELD(ec_broken);
1928 WRITE_UINT_FIELD(ec_sortref);
1932 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
1934 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1936 WRITE_NODE_FIELD(em_expr);
1937 WRITE_BITMAPSET_FIELD(em_relids);
1938 WRITE_BITMAPSET_FIELD(em_nullable_relids);
1939 WRITE_BOOL_FIELD(em_is_const);
1940 WRITE_BOOL_FIELD(em_is_child);
1941 WRITE_OID_FIELD(em_datatype);
1945 _outPathKey(StringInfo str, const PathKey *node)
1947 WRITE_NODE_TYPE("PATHKEY");
1949 WRITE_NODE_FIELD(pk_eclass);
1950 WRITE_OID_FIELD(pk_opfamily);
1951 WRITE_INT_FIELD(pk_strategy);
1952 WRITE_BOOL_FIELD(pk_nulls_first);
1956 _outParamPathInfo(StringInfo str, const ParamPathInfo *node)
1958 WRITE_NODE_TYPE("PARAMPATHINFO");
1960 WRITE_BITMAPSET_FIELD(ppi_req_outer);
1961 WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
1962 WRITE_NODE_FIELD(ppi_clauses);
1966 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
1968 WRITE_NODE_TYPE("RESTRICTINFO");
1970 /* NB: this isn't a complete set of fields */
1971 WRITE_NODE_FIELD(clause);
1972 WRITE_BOOL_FIELD(is_pushed_down);
1973 WRITE_BOOL_FIELD(outerjoin_delayed);
1974 WRITE_BOOL_FIELD(can_join);
1975 WRITE_BOOL_FIELD(pseudoconstant);
1976 WRITE_BITMAPSET_FIELD(clause_relids);
1977 WRITE_BITMAPSET_FIELD(required_relids);
1978 WRITE_BITMAPSET_FIELD(outer_relids);
1979 WRITE_BITMAPSET_FIELD(nullable_relids);
1980 WRITE_BITMAPSET_FIELD(left_relids);
1981 WRITE_BITMAPSET_FIELD(right_relids);
1982 WRITE_NODE_FIELD(orclause);
1983 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1984 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1985 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1986 WRITE_NODE_FIELD(mergeopfamilies);
1987 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1988 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1989 WRITE_NODE_FIELD(left_em);
1990 WRITE_NODE_FIELD(right_em);
1991 WRITE_BOOL_FIELD(outer_is_left);
1992 WRITE_OID_FIELD(hashjoinoperator);
1996 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
1998 WRITE_NODE_TYPE("PLACEHOLDERVAR");
2000 WRITE_NODE_FIELD(phexpr);
2001 WRITE_BITMAPSET_FIELD(phrels);
2002 WRITE_UINT_FIELD(phid);
2003 WRITE_UINT_FIELD(phlevelsup);
2007 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
2009 WRITE_NODE_TYPE("SPECIALJOININFO");
2011 WRITE_BITMAPSET_FIELD(min_lefthand);
2012 WRITE_BITMAPSET_FIELD(min_righthand);
2013 WRITE_BITMAPSET_FIELD(syn_lefthand);
2014 WRITE_BITMAPSET_FIELD(syn_righthand);
2015 WRITE_ENUM_FIELD(jointype, JoinType);
2016 WRITE_BOOL_FIELD(lhs_strict);
2017 WRITE_BOOL_FIELD(delay_upper_joins);
2018 WRITE_BOOL_FIELD(semi_can_btree);
2019 WRITE_BOOL_FIELD(semi_can_hash);
2020 WRITE_NODE_FIELD(semi_operators);
2021 WRITE_NODE_FIELD(semi_rhs_exprs);
2025 _outLateralJoinInfo(StringInfo str, const LateralJoinInfo *node)
2027 WRITE_NODE_TYPE("LATERALJOININFO");
2029 WRITE_BITMAPSET_FIELD(lateral_lhs);
2030 WRITE_BITMAPSET_FIELD(lateral_rhs);
2034 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
2036 WRITE_NODE_TYPE("APPENDRELINFO");
2038 WRITE_UINT_FIELD(parent_relid);
2039 WRITE_UINT_FIELD(child_relid);
2040 WRITE_OID_FIELD(parent_reltype);
2041 WRITE_OID_FIELD(child_reltype);
2042 WRITE_NODE_FIELD(translated_vars);
2043 WRITE_OID_FIELD(parent_reloid);
2047 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
2049 WRITE_NODE_TYPE("PLACEHOLDERINFO");
2051 WRITE_UINT_FIELD(phid);
2052 WRITE_NODE_FIELD(ph_var);
2053 WRITE_BITMAPSET_FIELD(ph_eval_at);
2054 WRITE_BITMAPSET_FIELD(ph_lateral);
2055 WRITE_BITMAPSET_FIELD(ph_needed);
2056 WRITE_INT_FIELD(ph_width);
2060 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
2062 WRITE_NODE_TYPE("MINMAXAGGINFO");
2064 WRITE_OID_FIELD(aggfnoid);
2065 WRITE_OID_FIELD(aggsortop);
2066 WRITE_NODE_FIELD(target);
2067 /* We intentionally omit subroot --- too large, not interesting enough */
2068 WRITE_NODE_FIELD(path);
2069 WRITE_FLOAT_FIELD(pathcost, "%.2f");
2070 WRITE_NODE_FIELD(param);
2074 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
2076 WRITE_NODE_TYPE("PLANNERPARAMITEM");
2078 WRITE_NODE_FIELD(item);
2079 WRITE_INT_FIELD(paramId);
2082 /*****************************************************************************
2084 * Stuff from parsenodes.h.
2086 *****************************************************************************/
2089 * print the basic stuff of all nodes that inherit from CreateStmt
2092 _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
2094 WRITE_NODE_FIELD(relation);
2095 WRITE_NODE_FIELD(tableElts);
2096 WRITE_NODE_FIELD(inhRelations);
2097 WRITE_NODE_FIELD(ofTypename);
2098 WRITE_NODE_FIELD(constraints);
2099 WRITE_NODE_FIELD(options);
2100 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
2101 WRITE_STRING_FIELD(tablespacename);
2102 WRITE_BOOL_FIELD(if_not_exists);
2106 _outCreateStmt(StringInfo str, const CreateStmt *node)
2108 WRITE_NODE_TYPE("CREATESTMT");
2110 _outCreateStmtInfo(str, (const CreateStmt *) node);
2114 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
2116 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
2118 _outCreateStmtInfo(str, (const CreateStmt *) node);
2120 WRITE_STRING_FIELD(servername);
2121 WRITE_NODE_FIELD(options);
2125 _outImportForeignSchemaStmt(StringInfo str, const ImportForeignSchemaStmt *node)
2127 WRITE_NODE_TYPE("IMPORTFOREIGNSCHEMASTMT");
2129 WRITE_STRING_FIELD(server_name);
2130 WRITE_STRING_FIELD(remote_schema);
2131 WRITE_STRING_FIELD(local_schema);
2132 WRITE_ENUM_FIELD(list_type, ImportForeignSchemaType);
2133 WRITE_NODE_FIELD(table_list);
2134 WRITE_NODE_FIELD(options);
2138 _outIndexStmt(StringInfo str, const IndexStmt *node)
2140 WRITE_NODE_TYPE("INDEXSTMT");
2142 WRITE_STRING_FIELD(idxname);
2143 WRITE_NODE_FIELD(relation);
2144 WRITE_STRING_FIELD(accessMethod);
2145 WRITE_STRING_FIELD(tableSpace);
2146 WRITE_NODE_FIELD(indexParams);
2147 WRITE_NODE_FIELD(options);
2148 WRITE_NODE_FIELD(whereClause);
2149 WRITE_NODE_FIELD(excludeOpNames);
2150 WRITE_STRING_FIELD(idxcomment);
2151 WRITE_OID_FIELD(indexOid);
2152 WRITE_OID_FIELD(oldNode);
2153 WRITE_BOOL_FIELD(unique);
2154 WRITE_BOOL_FIELD(primary);
2155 WRITE_BOOL_FIELD(isconstraint);
2156 WRITE_BOOL_FIELD(deferrable);
2157 WRITE_BOOL_FIELD(initdeferred);
2158 WRITE_BOOL_FIELD(transformed);
2159 WRITE_BOOL_FIELD(concurrent);
2160 WRITE_BOOL_FIELD(if_not_exists);
2164 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
2166 WRITE_NODE_TYPE("NOTIFY");
2168 WRITE_STRING_FIELD(conditionname);
2169 WRITE_STRING_FIELD(payload);
2173 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2175 WRITE_NODE_TYPE("DECLARECURSOR");
2177 WRITE_STRING_FIELD(portalname);
2178 WRITE_INT_FIELD(options);
2179 WRITE_NODE_FIELD(query);
2183 _outSelectStmt(StringInfo str, const SelectStmt *node)
2185 WRITE_NODE_TYPE("SELECT");
2187 WRITE_NODE_FIELD(distinctClause);
2188 WRITE_NODE_FIELD(intoClause);
2189 WRITE_NODE_FIELD(targetList);
2190 WRITE_NODE_FIELD(fromClause);
2191 WRITE_NODE_FIELD(whereClause);
2192 WRITE_NODE_FIELD(groupClause);
2193 WRITE_NODE_FIELD(havingClause);
2194 WRITE_NODE_FIELD(windowClause);
2195 WRITE_NODE_FIELD(valuesLists);
2196 WRITE_NODE_FIELD(sortClause);
2197 WRITE_NODE_FIELD(limitOffset);
2198 WRITE_NODE_FIELD(limitCount);
2199 WRITE_NODE_FIELD(lockingClause);
2200 WRITE_NODE_FIELD(withClause);
2201 WRITE_ENUM_FIELD(op, SetOperation);
2202 WRITE_BOOL_FIELD(all);
2203 WRITE_NODE_FIELD(larg);
2204 WRITE_NODE_FIELD(rarg);
2208 _outFuncCall(StringInfo str, const FuncCall *node)
2210 WRITE_NODE_TYPE("FUNCCALL");
2212 WRITE_NODE_FIELD(funcname);
2213 WRITE_NODE_FIELD(args);
2214 WRITE_NODE_FIELD(agg_order);
2215 WRITE_NODE_FIELD(agg_filter);
2216 WRITE_BOOL_FIELD(agg_within_group);
2217 WRITE_BOOL_FIELD(agg_star);
2218 WRITE_BOOL_FIELD(agg_distinct);
2219 WRITE_BOOL_FIELD(func_variadic);
2220 WRITE_NODE_FIELD(over);
2221 WRITE_LOCATION_FIELD(location);
2225 _outDefElem(StringInfo str, const DefElem *node)
2227 WRITE_NODE_TYPE("DEFELEM");
2229 WRITE_STRING_FIELD(defnamespace);
2230 WRITE_STRING_FIELD(defname);
2231 WRITE_NODE_FIELD(arg);
2232 WRITE_ENUM_FIELD(defaction, DefElemAction);
2236 _outTableLikeClause(StringInfo str, const TableLikeClause *node)
2238 WRITE_NODE_TYPE("TABLELIKECLAUSE");
2240 WRITE_NODE_FIELD(relation);
2241 WRITE_UINT_FIELD(options);
2245 _outLockingClause(StringInfo str, const LockingClause *node)
2247 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2249 WRITE_NODE_FIELD(lockedRels);
2250 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2251 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2255 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2257 WRITE_NODE_TYPE("XMLSERIALIZE");
2259 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2260 WRITE_NODE_FIELD(expr);
2261 WRITE_NODE_FIELD(typeName);
2262 WRITE_LOCATION_FIELD(location);
2266 _outColumnDef(StringInfo str, const ColumnDef *node)
2268 WRITE_NODE_TYPE("COLUMNDEF");
2270 WRITE_STRING_FIELD(colname);
2271 WRITE_NODE_FIELD(typeName);
2272 WRITE_INT_FIELD(inhcount);
2273 WRITE_BOOL_FIELD(is_local);
2274 WRITE_BOOL_FIELD(is_not_null);
2275 WRITE_BOOL_FIELD(is_from_type);
2276 WRITE_CHAR_FIELD(storage);
2277 WRITE_NODE_FIELD(raw_default);
2278 WRITE_NODE_FIELD(cooked_default);
2279 WRITE_NODE_FIELD(collClause);
2280 WRITE_OID_FIELD(collOid);
2281 WRITE_NODE_FIELD(constraints);
2282 WRITE_NODE_FIELD(fdwoptions);
2283 WRITE_LOCATION_FIELD(location);
2287 _outTypeName(StringInfo str, const TypeName *node)
2289 WRITE_NODE_TYPE("TYPENAME");
2291 WRITE_NODE_FIELD(names);
2292 WRITE_OID_FIELD(typeOid);
2293 WRITE_BOOL_FIELD(setof);
2294 WRITE_BOOL_FIELD(pct_type);
2295 WRITE_NODE_FIELD(typmods);
2296 WRITE_INT_FIELD(typemod);
2297 WRITE_NODE_FIELD(arrayBounds);
2298 WRITE_LOCATION_FIELD(location);
2302 _outTypeCast(StringInfo str, const TypeCast *node)
2304 WRITE_NODE_TYPE("TYPECAST");
2306 WRITE_NODE_FIELD(arg);
2307 WRITE_NODE_FIELD(typeName);
2308 WRITE_LOCATION_FIELD(location);
2312 _outCollateClause(StringInfo str, const CollateClause *node)
2314 WRITE_NODE_TYPE("COLLATECLAUSE");
2316 WRITE_NODE_FIELD(arg);
2317 WRITE_NODE_FIELD(collname);
2318 WRITE_LOCATION_FIELD(location);
2322 _outIndexElem(StringInfo str, const IndexElem *node)
2324 WRITE_NODE_TYPE("INDEXELEM");
2326 WRITE_STRING_FIELD(name);
2327 WRITE_NODE_FIELD(expr);
2328 WRITE_STRING_FIELD(indexcolname);
2329 WRITE_NODE_FIELD(collation);
2330 WRITE_NODE_FIELD(opclass);
2331 WRITE_ENUM_FIELD(ordering, SortByDir);
2332 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2336 _outQuery(StringInfo str, const Query *node)
2338 WRITE_NODE_TYPE("QUERY");
2340 WRITE_ENUM_FIELD(commandType, CmdType);
2341 WRITE_ENUM_FIELD(querySource, QuerySource);
2342 /* we intentionally do not print the queryId field */
2343 WRITE_BOOL_FIELD(canSetTag);
2346 * Hack to work around missing outfuncs routines for a lot of the
2347 * utility-statement node types. (The only one we actually *need* for
2348 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2349 * for the meantime do this to avoid getting lots of warnings when running
2350 * with debug_print_parse on.
2352 if (node->utilityStmt)
2354 switch (nodeTag(node->utilityStmt))
2359 case T_DeclareCursorStmt:
2360 WRITE_NODE_FIELD(utilityStmt);
2363 appendStringInfoString(str, " :utilityStmt ?");
2368 appendStringInfoString(str, " :utilityStmt <>");
2370 WRITE_INT_FIELD(resultRelation);
2371 WRITE_BOOL_FIELD(hasAggs);
2372 WRITE_BOOL_FIELD(hasWindowFuncs);
2373 WRITE_BOOL_FIELD(hasSubLinks);
2374 WRITE_BOOL_FIELD(hasDistinctOn);
2375 WRITE_BOOL_FIELD(hasRecursive);
2376 WRITE_BOOL_FIELD(hasModifyingCTE);
2377 WRITE_BOOL_FIELD(hasForUpdate);
2378 WRITE_BOOL_FIELD(hasRowSecurity);
2379 WRITE_NODE_FIELD(cteList);
2380 WRITE_NODE_FIELD(rtable);
2381 WRITE_NODE_FIELD(jointree);
2382 WRITE_NODE_FIELD(targetList);
2383 WRITE_NODE_FIELD(withCheckOptions);
2384 WRITE_NODE_FIELD(onConflict);
2385 WRITE_NODE_FIELD(returningList);
2386 WRITE_NODE_FIELD(groupClause);
2387 WRITE_NODE_FIELD(groupingSets);
2388 WRITE_NODE_FIELD(havingQual);
2389 WRITE_NODE_FIELD(windowClause);
2390 WRITE_NODE_FIELD(distinctClause);
2391 WRITE_NODE_FIELD(sortClause);
2392 WRITE_NODE_FIELD(limitOffset);
2393 WRITE_NODE_FIELD(limitCount);
2394 WRITE_NODE_FIELD(rowMarks);
2395 WRITE_NODE_FIELD(setOperations);
2396 WRITE_NODE_FIELD(constraintDeps);
2400 _outWithCheckOption(StringInfo str, const WithCheckOption *node)
2402 WRITE_NODE_TYPE("WITHCHECKOPTION");
2404 WRITE_ENUM_FIELD(kind, WCOKind);
2405 WRITE_STRING_FIELD(relname);
2406 WRITE_STRING_FIELD(polname);
2407 WRITE_NODE_FIELD(qual);
2408 WRITE_BOOL_FIELD(cascaded);
2412 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2414 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2416 WRITE_UINT_FIELD(tleSortGroupRef);
2417 WRITE_OID_FIELD(eqop);
2418 WRITE_OID_FIELD(sortop);
2419 WRITE_BOOL_FIELD(nulls_first);
2420 WRITE_BOOL_FIELD(hashable);
2424 _outGroupingSet(StringInfo str, const GroupingSet *node)
2426 WRITE_NODE_TYPE("GROUPINGSET");
2428 WRITE_ENUM_FIELD(kind, GroupingSetKind);
2429 WRITE_NODE_FIELD(content);
2430 WRITE_LOCATION_FIELD(location);
2434 _outWindowClause(StringInfo str, const WindowClause *node)
2436 WRITE_NODE_TYPE("WINDOWCLAUSE");
2438 WRITE_STRING_FIELD(name);
2439 WRITE_STRING_FIELD(refname);
2440 WRITE_NODE_FIELD(partitionClause);
2441 WRITE_NODE_FIELD(orderClause);
2442 WRITE_INT_FIELD(frameOptions);
2443 WRITE_NODE_FIELD(startOffset);
2444 WRITE_NODE_FIELD(endOffset);
2445 WRITE_UINT_FIELD(winref);
2446 WRITE_BOOL_FIELD(copiedOrder);
2450 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
2452 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2454 WRITE_UINT_FIELD(rti);
2455 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2456 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2457 WRITE_BOOL_FIELD(pushedDown);
2461 _outWithClause(StringInfo str, const WithClause *node)
2463 WRITE_NODE_TYPE("WITHCLAUSE");
2465 WRITE_NODE_FIELD(ctes);
2466 WRITE_BOOL_FIELD(recursive);
2467 WRITE_LOCATION_FIELD(location);
2471 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
2473 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2475 WRITE_STRING_FIELD(ctename);
2476 WRITE_NODE_FIELD(aliascolnames);
2477 WRITE_NODE_FIELD(ctequery);
2478 WRITE_LOCATION_FIELD(location);
2479 WRITE_BOOL_FIELD(cterecursive);
2480 WRITE_INT_FIELD(cterefcount);
2481 WRITE_NODE_FIELD(ctecolnames);
2482 WRITE_NODE_FIELD(ctecoltypes);
2483 WRITE_NODE_FIELD(ctecoltypmods);
2484 WRITE_NODE_FIELD(ctecolcollations);
2488 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
2490 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2492 WRITE_ENUM_FIELD(op, SetOperation);
2493 WRITE_BOOL_FIELD(all);
2494 WRITE_NODE_FIELD(larg);
2495 WRITE_NODE_FIELD(rarg);
2496 WRITE_NODE_FIELD(colTypes);
2497 WRITE_NODE_FIELD(colTypmods);
2498 WRITE_NODE_FIELD(colCollations);
2499 WRITE_NODE_FIELD(groupClauses);
2503 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
2505 WRITE_NODE_TYPE("RTE");
2507 /* put alias + eref first to make dump more legible */
2508 WRITE_NODE_FIELD(alias);
2509 WRITE_NODE_FIELD(eref);
2510 WRITE_ENUM_FIELD(rtekind, RTEKind);
2512 switch (node->rtekind)
2515 WRITE_OID_FIELD(relid);
2516 WRITE_CHAR_FIELD(relkind);
2517 WRITE_NODE_FIELD(tablesample);
2520 WRITE_NODE_FIELD(subquery);
2521 WRITE_BOOL_FIELD(security_barrier);
2524 WRITE_ENUM_FIELD(jointype, JoinType);
2525 WRITE_NODE_FIELD(joinaliasvars);
2528 WRITE_NODE_FIELD(functions);
2529 WRITE_BOOL_FIELD(funcordinality);
2532 WRITE_NODE_FIELD(values_lists);
2533 WRITE_NODE_FIELD(values_collations);
2536 WRITE_STRING_FIELD(ctename);
2537 WRITE_UINT_FIELD(ctelevelsup);
2538 WRITE_BOOL_FIELD(self_reference);
2539 WRITE_NODE_FIELD(ctecoltypes);
2540 WRITE_NODE_FIELD(ctecoltypmods);
2541 WRITE_NODE_FIELD(ctecolcollations);
2544 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2548 WRITE_BOOL_FIELD(lateral);
2549 WRITE_BOOL_FIELD(inh);
2550 WRITE_BOOL_FIELD(inFromCl);
2551 WRITE_UINT_FIELD(requiredPerms);
2552 WRITE_OID_FIELD(checkAsUser);
2553 WRITE_BITMAPSET_FIELD(selectedCols);
2554 WRITE_BITMAPSET_FIELD(insertedCols);
2555 WRITE_BITMAPSET_FIELD(updatedCols);
2556 WRITE_NODE_FIELD(securityQuals);
2560 _outRangeTblFunction(StringInfo str, const RangeTblFunction *node)
2562 WRITE_NODE_TYPE("RANGETBLFUNCTION");
2564 WRITE_NODE_FIELD(funcexpr);
2565 WRITE_INT_FIELD(funccolcount);
2566 WRITE_NODE_FIELD(funccolnames);
2567 WRITE_NODE_FIELD(funccoltypes);
2568 WRITE_NODE_FIELD(funccoltypmods);
2569 WRITE_NODE_FIELD(funccolcollations);
2570 WRITE_BITMAPSET_FIELD(funcparams);
2574 _outTableSampleClause(StringInfo str, const TableSampleClause *node)
2576 WRITE_NODE_TYPE("TABLESAMPLECLAUSE");
2578 WRITE_OID_FIELD(tsmhandler);
2579 WRITE_NODE_FIELD(args);
2580 WRITE_NODE_FIELD(repeatable);
2584 _outAExpr(StringInfo str, const A_Expr *node)
2586 WRITE_NODE_TYPE("AEXPR");
2591 appendStringInfoChar(str, ' ');
2592 WRITE_NODE_FIELD(name);
2595 appendStringInfoChar(str, ' ');
2596 WRITE_NODE_FIELD(name);
2597 appendStringInfoString(str, " ANY ");
2600 appendStringInfoChar(str, ' ');
2601 WRITE_NODE_FIELD(name);
2602 appendStringInfoString(str, " ALL ");
2604 case AEXPR_DISTINCT:
2605 appendStringInfoString(str, " DISTINCT ");
2606 WRITE_NODE_FIELD(name);
2609 appendStringInfoString(str, " NULLIF ");
2610 WRITE_NODE_FIELD(name);
2613 appendStringInfoString(str, " OF ");
2614 WRITE_NODE_FIELD(name);
2617 appendStringInfoString(str, " IN ");
2618 WRITE_NODE_FIELD(name);
2621 appendStringInfoString(str, " LIKE ");
2622 WRITE_NODE_FIELD(name);
2625 appendStringInfoString(str, " ILIKE ");
2626 WRITE_NODE_FIELD(name);
2629 appendStringInfoString(str, " SIMILAR ");
2630 WRITE_NODE_FIELD(name);
2633 appendStringInfoString(str, " BETWEEN ");
2634 WRITE_NODE_FIELD(name);
2636 case AEXPR_NOT_BETWEEN:
2637 appendStringInfoString(str, " NOT_BETWEEN ");
2638 WRITE_NODE_FIELD(name);
2640 case AEXPR_BETWEEN_SYM:
2641 appendStringInfoString(str, " BETWEEN_SYM ");
2642 WRITE_NODE_FIELD(name);
2644 case AEXPR_NOT_BETWEEN_SYM:
2645 appendStringInfoString(str, " NOT_BETWEEN_SYM ");
2646 WRITE_NODE_FIELD(name);
2649 appendStringInfoString(str, " PAREN");
2652 appendStringInfoString(str, " ??");
2656 WRITE_NODE_FIELD(lexpr);
2657 WRITE_NODE_FIELD(rexpr);
2658 WRITE_LOCATION_FIELD(location);
2662 _outValue(StringInfo str, const Value *value)
2664 switch (value->type)
2667 appendStringInfo(str, "%ld", value->val.ival);
2672 * We assume the value is a valid numeric literal and so does not
2675 appendStringInfoString(str, value->val.str);
2680 * We use _outToken to provide escaping of the string's content,
2681 * but we don't want it to do anything with an empty string.
2683 appendStringInfoChar(str, '"');
2684 if (value->val.str[0] != '\0')
2685 _outToken(str, value->val.str);
2686 appendStringInfoChar(str, '"');
2689 /* internal representation already has leading 'b' */
2690 appendStringInfoString(str, value->val.str);
2693 /* this is seen only within A_Const, not in transformed trees */
2694 appendStringInfoString(str, "NULL");
2697 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2703 _outColumnRef(StringInfo str, const ColumnRef *node)
2705 WRITE_NODE_TYPE("COLUMNREF");
2707 WRITE_NODE_FIELD(fields);
2708 WRITE_LOCATION_FIELD(location);
2712 _outParamRef(StringInfo str, const ParamRef *node)
2714 WRITE_NODE_TYPE("PARAMREF");
2716 WRITE_INT_FIELD(number);
2717 WRITE_LOCATION_FIELD(location);
2721 _outAConst(StringInfo str, const A_Const *node)
2723 WRITE_NODE_TYPE("A_CONST");
2725 appendStringInfoString(str, " :val ");
2726 _outValue(str, &(node->val));
2727 WRITE_LOCATION_FIELD(location);
2731 _outA_Star(StringInfo str, const A_Star *node)
2733 WRITE_NODE_TYPE("A_STAR");
2737 _outA_Indices(StringInfo str, const A_Indices *node)
2739 WRITE_NODE_TYPE("A_INDICES");
2741 WRITE_NODE_FIELD(lidx);
2742 WRITE_NODE_FIELD(uidx);
2746 _outA_Indirection(StringInfo str, const A_Indirection *node)
2748 WRITE_NODE_TYPE("A_INDIRECTION");
2750 WRITE_NODE_FIELD(arg);
2751 WRITE_NODE_FIELD(indirection);
2755 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
2757 WRITE_NODE_TYPE("A_ARRAYEXPR");
2759 WRITE_NODE_FIELD(elements);
2760 WRITE_LOCATION_FIELD(location);
2764 _outResTarget(StringInfo str, const ResTarget *node)
2766 WRITE_NODE_TYPE("RESTARGET");
2768 WRITE_STRING_FIELD(name);
2769 WRITE_NODE_FIELD(indirection);
2770 WRITE_NODE_FIELD(val);
2771 WRITE_LOCATION_FIELD(location);
2775 _outMultiAssignRef(StringInfo str, const MultiAssignRef *node)
2777 WRITE_NODE_TYPE("MULTIASSIGNREF");
2779 WRITE_NODE_FIELD(source);
2780 WRITE_INT_FIELD(colno);
2781 WRITE_INT_FIELD(ncolumns);
2785 _outSortBy(StringInfo str, const SortBy *node)
2787 WRITE_NODE_TYPE("SORTBY");
2789 WRITE_NODE_FIELD(node);
2790 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2791 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2792 WRITE_NODE_FIELD(useOp);
2793 WRITE_LOCATION_FIELD(location);
2797 _outWindowDef(StringInfo str, const WindowDef *node)
2799 WRITE_NODE_TYPE("WINDOWDEF");
2801 WRITE_STRING_FIELD(name);
2802 WRITE_STRING_FIELD(refname);
2803 WRITE_NODE_FIELD(partitionClause);
2804 WRITE_NODE_FIELD(orderClause);
2805 WRITE_INT_FIELD(frameOptions);
2806 WRITE_NODE_FIELD(startOffset);
2807 WRITE_NODE_FIELD(endOffset);
2808 WRITE_LOCATION_FIELD(location);
2812 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
2814 WRITE_NODE_TYPE("RANGESUBSELECT");
2816 WRITE_BOOL_FIELD(lateral);
2817 WRITE_NODE_FIELD(subquery);
2818 WRITE_NODE_FIELD(alias);
2822 _outRangeFunction(StringInfo str, const RangeFunction *node)
2824 WRITE_NODE_TYPE("RANGEFUNCTION");
2826 WRITE_BOOL_FIELD(lateral);
2827 WRITE_BOOL_FIELD(ordinality);
2828 WRITE_BOOL_FIELD(is_rowsfrom);
2829 WRITE_NODE_FIELD(functions);
2830 WRITE_NODE_FIELD(alias);
2831 WRITE_NODE_FIELD(coldeflist);
2835 _outRangeTableSample(StringInfo str, const RangeTableSample *node)
2837 WRITE_NODE_TYPE("RANGETABLESAMPLE");
2839 WRITE_NODE_FIELD(relation);
2840 WRITE_NODE_FIELD(method);
2841 WRITE_NODE_FIELD(args);
2842 WRITE_NODE_FIELD(repeatable);
2843 WRITE_LOCATION_FIELD(location);
2847 _outConstraint(StringInfo str, const Constraint *node)
2849 WRITE_NODE_TYPE("CONSTRAINT");
2851 WRITE_STRING_FIELD(conname);
2852 WRITE_BOOL_FIELD(deferrable);
2853 WRITE_BOOL_FIELD(initdeferred);
2854 WRITE_LOCATION_FIELD(location);
2856 appendStringInfoString(str, " :contype ");
2857 switch (node->contype)
2860 appendStringInfoString(str, "NULL");
2863 case CONSTR_NOTNULL:
2864 appendStringInfoString(str, "NOT_NULL");
2867 case CONSTR_DEFAULT:
2868 appendStringInfoString(str, "DEFAULT");
2869 WRITE_NODE_FIELD(raw_expr);
2870 WRITE_STRING_FIELD(cooked_expr);
2874 appendStringInfoString(str, "CHECK");
2875 WRITE_BOOL_FIELD(is_no_inherit);
2876 WRITE_NODE_FIELD(raw_expr);
2877 WRITE_STRING_FIELD(cooked_expr);
2880 case CONSTR_PRIMARY:
2881 appendStringInfoString(str, "PRIMARY_KEY");
2882 WRITE_NODE_FIELD(keys);
2883 WRITE_NODE_FIELD(options);
2884 WRITE_STRING_FIELD(indexname);
2885 WRITE_STRING_FIELD(indexspace);
2886 /* access_method and where_clause not currently used */
2890 appendStringInfoString(str, "UNIQUE");
2891 WRITE_NODE_FIELD(keys);
2892 WRITE_NODE_FIELD(options);
2893 WRITE_STRING_FIELD(indexname);
2894 WRITE_STRING_FIELD(indexspace);
2895 /* access_method and where_clause not currently used */
2898 case CONSTR_EXCLUSION:
2899 appendStringInfoString(str, "EXCLUSION");
2900 WRITE_NODE_FIELD(exclusions);
2901 WRITE_NODE_FIELD(options);
2902 WRITE_STRING_FIELD(indexname);
2903 WRITE_STRING_FIELD(indexspace);
2904 WRITE_STRING_FIELD(access_method);
2905 WRITE_NODE_FIELD(where_clause);
2908 case CONSTR_FOREIGN:
2909 appendStringInfoString(str, "FOREIGN_KEY");
2910 WRITE_NODE_FIELD(pktable);
2911 WRITE_NODE_FIELD(fk_attrs);
2912 WRITE_NODE_FIELD(pk_attrs);
2913 WRITE_CHAR_FIELD(fk_matchtype);
2914 WRITE_CHAR_FIELD(fk_upd_action);
2915 WRITE_CHAR_FIELD(fk_del_action);
2916 WRITE_NODE_FIELD(old_conpfeqop);
2917 WRITE_OID_FIELD(old_pktable_oid);
2918 WRITE_BOOL_FIELD(skip_validation);
2919 WRITE_BOOL_FIELD(initially_valid);
2922 case CONSTR_ATTR_DEFERRABLE:
2923 appendStringInfoString(str, "ATTR_DEFERRABLE");
2926 case CONSTR_ATTR_NOT_DEFERRABLE:
2927 appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
2930 case CONSTR_ATTR_DEFERRED:
2931 appendStringInfoString(str, "ATTR_DEFERRED");
2934 case CONSTR_ATTR_IMMEDIATE:
2935 appendStringInfoString(str, "ATTR_IMMEDIATE");
2939 appendStringInfo(str, "<unrecognized_constraint %d>",
2940 (int) node->contype);
2948 * converts a Node into ascii string and append it to 'str'
2951 _outNode(StringInfo str, const void *obj)
2954 appendStringInfoString(str, "<>");
2955 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2957 else if (IsA(obj, Integer) ||
2960 IsA(obj, BitString))
2962 /* nodeRead does not want to see { } around these! */
2963 _outValue(str, obj);
2967 appendStringInfoChar(str, '{');
2968 switch (nodeTag(obj))
2971 _outPlannedStmt(str, obj);
2977 _outResult(str, obj);
2980 _outModifyTable(str, obj);
2983 _outAppend(str, obj);
2986 _outMergeAppend(str, obj);
2988 case T_RecursiveUnion:
2989 _outRecursiveUnion(str, obj);
2992 _outBitmapAnd(str, obj);
2995 _outBitmapOr(str, obj);
3001 _outSeqScan(str, obj);
3004 _outSampleScan(str, obj);
3007 _outIndexScan(str, obj);
3009 case T_IndexOnlyScan:
3010 _outIndexOnlyScan(str, obj);
3012 case T_BitmapIndexScan:
3013 _outBitmapIndexScan(str, obj);
3015 case T_BitmapHeapScan:
3016 _outBitmapHeapScan(str, obj);
3019 _outTidScan(str, obj);
3021 case T_SubqueryScan:
3022 _outSubqueryScan(str, obj);
3024 case T_FunctionScan:
3025 _outFunctionScan(str, obj);
3028 _outValuesScan(str, obj);
3031 _outCteScan(str, obj);
3033 case T_WorkTableScan:
3034 _outWorkTableScan(str, obj);
3037 _outForeignScan(str, obj);
3040 _outCustomScan(str, obj);
3046 _outNestLoop(str, obj);
3049 _outMergeJoin(str, obj);
3052 _outHashJoin(str, obj);
3058 _outWindowAgg(str, obj);
3061 _outGroup(str, obj);
3064 _outMaterial(str, obj);
3070 _outUnique(str, obj);
3076 _outSetOp(str, obj);
3079 _outLockRows(str, obj);
3082 _outLimit(str, obj);
3084 case T_NestLoopParam:
3085 _outNestLoopParam(str, obj);
3088 _outPlanRowMark(str, obj);
3090 case T_PlanInvalItem:
3091 _outPlanInvalItem(str, obj);
3094 _outAlias(str, obj);
3097 _outRangeVar(str, obj);
3100 _outIntoClause(str, obj);
3106 _outConst(str, obj);
3109 _outParam(str, obj);
3112 _outAggref(str, obj);
3114 case T_GroupingFunc:
3115 _outGroupingFunc(str, obj);
3118 _outWindowFunc(str, obj);
3121 _outArrayRef(str, obj);
3124 _outFuncExpr(str, obj);
3126 case T_NamedArgExpr:
3127 _outNamedArgExpr(str, obj);
3130 _outOpExpr(str, obj);
3132 case T_DistinctExpr:
3133 _outDistinctExpr(str, obj);
3136 _outNullIfExpr(str, obj);
3138 case T_ScalarArrayOpExpr:
3139 _outScalarArrayOpExpr(str, obj);
3142 _outBoolExpr(str, obj);
3145 _outSubLink(str, obj);
3148 _outSubPlan(str, obj);
3150 case T_AlternativeSubPlan:
3151 _outAlternativeSubPlan(str, obj);
3154 _outFieldSelect(str, obj);
3157 _outFieldStore(str, obj);
3160 _outRelabelType(str, obj);
3163 _outCoerceViaIO(str, obj);
3165 case T_ArrayCoerceExpr:
3166 _outArrayCoerceExpr(str, obj);
3168 case T_ConvertRowtypeExpr:
3169 _outConvertRowtypeExpr(str, obj);
3172 _outCollateExpr(str, obj);
3175 _outCaseExpr(str, obj);
3178 _outCaseWhen(str, obj);
3180 case T_CaseTestExpr:
3181 _outCaseTestExpr(str, obj);
3184 _outArrayExpr(str, obj);
3187 _outRowExpr(str, obj);
3189 case T_RowCompareExpr:
3190 _outRowCompareExpr(str, obj);
3192 case T_CoalesceExpr:
3193 _outCoalesceExpr(str, obj);
3196 _outMinMaxExpr(str, obj);
3199 _outXmlExpr(str, obj);
3202 _outNullTest(str, obj);
3205 _outBooleanTest(str, obj);
3207 case T_CoerceToDomain:
3208 _outCoerceToDomain(str, obj);
3210 case T_CoerceToDomainValue:
3211 _outCoerceToDomainValue(str, obj);
3213 case T_SetToDefault:
3214 _outSetToDefault(str, obj);
3216 case T_CurrentOfExpr:
3217 _outCurrentOfExpr(str, obj);
3219 case T_InferenceElem:
3220 _outInferenceElem(str, obj);
3223 _outTargetEntry(str, obj);
3226 _outRangeTblRef(str, obj);
3229 _outJoinExpr(str, obj);
3232 _outFromExpr(str, obj);
3234 case T_OnConflictExpr:
3235 _outOnConflictExpr(str, obj);
3241 _outIndexPath(str, obj);
3243 case T_BitmapHeapPath:
3244 _outBitmapHeapPath(str, obj);
3246 case T_BitmapAndPath:
3247 _outBitmapAndPath(str, obj);
3249 case T_BitmapOrPath:
3250 _outBitmapOrPath(str, obj);
3253 _outTidPath(str, obj);
3256 _outForeignPath(str, obj);
3259 _outCustomPath(str, obj);
3262 _outAppendPath(str, obj);
3264 case T_MergeAppendPath:
3265 _outMergeAppendPath(str, obj);
3268 _outResultPath(str, obj);
3270 case T_MaterialPath:
3271 _outMaterialPath(str, obj);
3274 _outUniquePath(str, obj);
3277 _outNestPath(str, obj);
3280 _outMergePath(str, obj);
3283 _outHashPath(str, obj);
3285 case T_PlannerGlobal:
3286 _outPlannerGlobal(str, obj);
3289 _outPlannerInfo(str, obj);
3292 _outRelOptInfo(str, obj);
3294 case T_IndexOptInfo:
3295 _outIndexOptInfo(str, obj);
3297 case T_EquivalenceClass:
3298 _outEquivalenceClass(str, obj);
3300 case T_EquivalenceMember:
3301 _outEquivalenceMember(str, obj);
3304 _outPathKey(str, obj);
3306 case T_ParamPathInfo:
3307 _outParamPathInfo(str, obj);
3309 case T_RestrictInfo:
3310 _outRestrictInfo(str, obj);
3312 case T_PlaceHolderVar:
3313 _outPlaceHolderVar(str, obj);
3315 case T_SpecialJoinInfo:
3316 _outSpecialJoinInfo(str, obj);
3318 case T_LateralJoinInfo:
3319 _outLateralJoinInfo(str, obj);
3321 case T_AppendRelInfo:
3322 _outAppendRelInfo(str, obj);
3324 case T_PlaceHolderInfo:
3325 _outPlaceHolderInfo(str, obj);
3327 case T_MinMaxAggInfo:
3328 _outMinMaxAggInfo(str, obj);
3330 case T_PlannerParamItem:
3331 _outPlannerParamItem(str, obj);
3335 _outCreateStmt(str, obj);
3337 case T_CreateForeignTableStmt:
3338 _outCreateForeignTableStmt(str, obj);
3340 case T_ImportForeignSchemaStmt:
3341 _outImportForeignSchemaStmt(str, obj);
3344 _outIndexStmt(str, obj);
3347 _outNotifyStmt(str, obj);
3349 case T_DeclareCursorStmt:
3350 _outDeclareCursorStmt(str, obj);
3353 _outSelectStmt(str, obj);
3356 _outColumnDef(str, obj);
3359 _outTypeName(str, obj);
3362 _outTypeCast(str, obj);
3364 case T_CollateClause:
3365 _outCollateClause(str, obj);
3368 _outIndexElem(str, obj);
3371 _outQuery(str, obj);
3373 case T_WithCheckOption:
3374 _outWithCheckOption(str, obj);
3376 case T_SortGroupClause:
3377 _outSortGroupClause(str, obj);
3380 _outGroupingSet(str, obj);
3382 case T_WindowClause:
3383 _outWindowClause(str, obj);
3385 case T_RowMarkClause:
3386 _outRowMarkClause(str, obj);
3389 _outWithClause(str, obj);
3391 case T_CommonTableExpr:
3392 _outCommonTableExpr(str, obj);
3394 case T_SetOperationStmt:
3395 _outSetOperationStmt(str, obj);
3397 case T_RangeTblEntry:
3398 _outRangeTblEntry(str, obj);
3400 case T_RangeTblFunction:
3401 _outRangeTblFunction(str, obj);
3403 case T_TableSampleClause:
3404 _outTableSampleClause(str, obj);
3407 _outAExpr(str, obj);
3410 _outColumnRef(str, obj);
3413 _outParamRef(str, obj);
3416 _outAConst(str, obj);
3419 _outA_Star(str, obj);
3422 _outA_Indices(str, obj);
3424 case T_A_Indirection:
3425 _outA_Indirection(str, obj);
3428 _outA_ArrayExpr(str, obj);
3431 _outResTarget(str, obj);
3433 case T_MultiAssignRef:
3434 _outMultiAssignRef(str, obj);
3437 _outSortBy(str, obj);
3440 _outWindowDef(str, obj);
3442 case T_RangeSubselect:
3443 _outRangeSubselect(str, obj);
3445 case T_RangeFunction:
3446 _outRangeFunction(str, obj);
3448 case T_RangeTableSample:
3449 _outRangeTableSample(str, obj);
3452 _outConstraint(str, obj);
3455 _outFuncCall(str, obj);
3458 _outDefElem(str, obj);
3460 case T_TableLikeClause:
3461 _outTableLikeClause(str, obj);
3463 case T_LockingClause:
3464 _outLockingClause(str, obj);
3466 case T_XmlSerialize:
3467 _outXmlSerialize(str, obj);
3473 * This should be an ERROR, but it's too useful to be able to
3474 * dump structures that _outNode only understands part of.
3476 elog(WARNING, "could not dump unrecognized node type: %d",
3477 (int) nodeTag(obj));
3480 appendStringInfoChar(str, '}');
3486 * returns the ascii representation of the Node as a palloc'd string
3489 nodeToString(const void *obj)
3493 /* see stringinfo.h for an explanation of this maneuver */
3494 initStringInfo(&str);
3495 _outNode(&str, obj);