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). 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/plannodes.h"
30 #include "nodes/relation.h"
31 #include "utils/datum.h"
35 * Macros to simplify output of different kinds of fields. Use these
36 * wherever possible to reduce the chance for silly typos. Note that these
37 * hard-wire conventions about the names of the local variables in an Out
41 /* Write the label for the node type */
42 #define WRITE_NODE_TYPE(nodelabel) \
43 appendStringInfoString(str, nodelabel)
45 /* Write an integer field (anything written as ":fldname %d") */
46 #define WRITE_INT_FIELD(fldname) \
47 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
49 /* Write an unsigned integer field (anything written as ":fldname %u") */
50 #define WRITE_UINT_FIELD(fldname) \
51 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
53 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
54 #define WRITE_OID_FIELD(fldname) \
55 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
57 /* Write a long-integer field */
58 #define WRITE_LONG_FIELD(fldname) \
59 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
61 /* Write a char field (ie, one ascii character) */
62 #define WRITE_CHAR_FIELD(fldname) \
63 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
65 /* Write an enumerated-type field as an integer code */
66 #define WRITE_ENUM_FIELD(fldname, enumtype) \
67 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
70 /* Write a float field --- caller must give format to define precision */
71 #define WRITE_FLOAT_FIELD(fldname,format) \
72 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
74 /* Write a boolean field */
75 #define WRITE_BOOL_FIELD(fldname) \
76 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
77 booltostr(node->fldname))
79 /* Write a character-string (possibly NULL) field */
80 #define WRITE_STRING_FIELD(fldname) \
81 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
82 _outToken(str, node->fldname))
84 /* Write a parse location field (actually same as INT case) */
85 #define WRITE_LOCATION_FIELD(fldname) \
86 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
88 /* Write a Node field */
89 #define WRITE_NODE_FIELD(fldname) \
90 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
91 _outNode(str, node->fldname))
93 /* Write a bitmapset field */
94 #define WRITE_BITMAPSET_FIELD(fldname) \
95 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
96 _outBitmapset(str, node->fldname))
99 #define booltostr(x) ((x) ? "true" : "false")
101 static void _outNode(StringInfo str, const void *obj);
106 * Convert an ordinary string (eg, an identifier) into a form that
107 * will be decoded back to a plain token by read.c's functions.
109 * If a null or empty string is given, it is encoded as "<>".
112 _outToken(StringInfo str, const char *s)
114 if (s == NULL || *s == '\0')
116 appendStringInfoString(str, "<>");
121 * Look for characters or patterns that are treated specially by read.c
122 * (either in pg_strtok() or in nodeRead()), and therefore need a
123 * protective backslash.
125 /* These characters only need to be quoted at the start of the string */
128 isdigit((unsigned char) *s) ||
129 ((*s == '+' || *s == '-') &&
130 (isdigit((unsigned char) s[1]) || s[1] == '.')))
131 appendStringInfoChar(str, '\\');
134 /* These chars must be backslashed anywhere in the string */
135 if (*s == ' ' || *s == '\n' || *s == '\t' ||
136 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
138 appendStringInfoChar(str, '\\');
139 appendStringInfoChar(str, *s++);
144 _outList(StringInfo str, const List *node)
148 appendStringInfoChar(str, '(');
150 if (IsA(node, IntList))
151 appendStringInfoChar(str, 'i');
152 else if (IsA(node, OidList))
153 appendStringInfoChar(str, 'o');
158 * For the sake of backward compatibility, we emit a slightly
159 * different whitespace format for lists of nodes vs. other types of
160 * lists. XXX: is this necessary?
164 _outNode(str, lfirst(lc));
166 appendStringInfoChar(str, ' ');
168 else if (IsA(node, IntList))
169 appendStringInfo(str, " %d", lfirst_int(lc));
170 else if (IsA(node, OidList))
171 appendStringInfo(str, " %u", lfirst_oid(lc));
173 elog(ERROR, "unrecognized list node type: %d",
177 appendStringInfoChar(str, ')');
182 * converts a bitmap set of integers
184 * Note: the output format is "(b int int ...)", similar to an integer List.
187 _outBitmapset(StringInfo str, const Bitmapset *bms)
191 appendStringInfoChar(str, '(');
192 appendStringInfoChar(str, 'b');
194 while ((x = bms_next_member(bms, x)) >= 0)
195 appendStringInfo(str, " %d", x);
196 appendStringInfoChar(str, ')');
200 * Print the value of a Datum given its type.
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
209 length = datumGetSize(value, typbyval, typlen);
213 s = (char *) (&value);
214 appendStringInfo(str, "%u [ ", (unsigned int) length);
215 for (i = 0; i < (Size) sizeof(Datum); i++)
216 appendStringInfo(str, "%d ", (int) (s[i]));
217 appendStringInfoChar(str, ']');
221 s = (char *) DatumGetPointer(value);
222 if (!PointerIsValid(s))
223 appendStringInfoString(str, "0 [ ]");
226 appendStringInfo(str, "%u [ ", (unsigned int) length);
227 for (i = 0; i < length; i++)
228 appendStringInfo(str, "%d ", (int) (s[i]));
229 appendStringInfoChar(str, ']');
236 * Stuff from plannodes.h
240 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
242 WRITE_NODE_TYPE("PLANNEDSTMT");
244 WRITE_ENUM_FIELD(commandType, CmdType);
245 WRITE_UINT_FIELD(queryId);
246 WRITE_BOOL_FIELD(hasReturning);
247 WRITE_BOOL_FIELD(hasModifyingCTE);
248 WRITE_BOOL_FIELD(canSetTag);
249 WRITE_BOOL_FIELD(transientPlan);
250 WRITE_NODE_FIELD(planTree);
251 WRITE_NODE_FIELD(rtable);
252 WRITE_NODE_FIELD(resultRelations);
253 WRITE_NODE_FIELD(utilityStmt);
254 WRITE_NODE_FIELD(subplans);
255 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
256 WRITE_NODE_FIELD(rowMarks);
257 WRITE_NODE_FIELD(relationOids);
258 WRITE_NODE_FIELD(invalItems);
259 WRITE_INT_FIELD(nParamExec);
260 WRITE_BOOL_FIELD(hasRowSecurity);
261 WRITE_BOOL_FIELD(parallelModeNeeded);
265 * print the basic stuff of all nodes that inherit from Plan
268 _outPlanInfo(StringInfo str, const Plan *node)
270 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
271 WRITE_FLOAT_FIELD(total_cost, "%.2f");
272 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
273 WRITE_INT_FIELD(plan_width);
274 WRITE_INT_FIELD(plan_node_id);
275 WRITE_NODE_FIELD(targetlist);
276 WRITE_NODE_FIELD(qual);
277 WRITE_NODE_FIELD(lefttree);
278 WRITE_NODE_FIELD(righttree);
279 WRITE_NODE_FIELD(initPlan);
280 WRITE_BITMAPSET_FIELD(extParam);
281 WRITE_BITMAPSET_FIELD(allParam);
285 * print the basic stuff of all nodes that inherit from Scan
288 _outScanInfo(StringInfo str, const Scan *node)
290 _outPlanInfo(str, (const Plan *) node);
292 WRITE_UINT_FIELD(scanrelid);
296 * print the basic stuff of all nodes that inherit from Join
299 _outJoinPlanInfo(StringInfo str, const Join *node)
301 _outPlanInfo(str, (const Plan *) node);
303 WRITE_ENUM_FIELD(jointype, JoinType);
304 WRITE_NODE_FIELD(joinqual);
309 _outPlan(StringInfo str, const Plan *node)
311 WRITE_NODE_TYPE("PLAN");
313 _outPlanInfo(str, (const Plan *) node);
317 _outResult(StringInfo str, const Result *node)
319 WRITE_NODE_TYPE("RESULT");
321 _outPlanInfo(str, (const Plan *) node);
323 WRITE_NODE_FIELD(resconstantqual);
327 _outModifyTable(StringInfo str, const ModifyTable *node)
329 WRITE_NODE_TYPE("MODIFYTABLE");
331 _outPlanInfo(str, (const Plan *) node);
333 WRITE_ENUM_FIELD(operation, CmdType);
334 WRITE_BOOL_FIELD(canSetTag);
335 WRITE_UINT_FIELD(nominalRelation);
336 WRITE_NODE_FIELD(resultRelations);
337 WRITE_INT_FIELD(resultRelIndex);
338 WRITE_NODE_FIELD(plans);
339 WRITE_NODE_FIELD(withCheckOptionLists);
340 WRITE_NODE_FIELD(returningLists);
341 WRITE_NODE_FIELD(fdwPrivLists);
342 WRITE_NODE_FIELD(rowMarks);
343 WRITE_INT_FIELD(epqParam);
344 WRITE_ENUM_FIELD(onConflictAction, OnConflictAction);
345 WRITE_NODE_FIELD(arbiterIndexes);
346 WRITE_NODE_FIELD(onConflictSet);
347 WRITE_NODE_FIELD(onConflictWhere);
348 WRITE_UINT_FIELD(exclRelRTI);
349 WRITE_NODE_FIELD(exclRelTlist);
353 _outAppend(StringInfo str, const Append *node)
355 WRITE_NODE_TYPE("APPEND");
357 _outPlanInfo(str, (const Plan *) node);
359 WRITE_NODE_FIELD(appendplans);
363 _outMergeAppend(StringInfo str, const MergeAppend *node)
367 WRITE_NODE_TYPE("MERGEAPPEND");
369 _outPlanInfo(str, (const Plan *) node);
371 WRITE_NODE_FIELD(mergeplans);
373 WRITE_INT_FIELD(numCols);
375 appendStringInfoString(str, " :sortColIdx");
376 for (i = 0; i < node->numCols; i++)
377 appendStringInfo(str, " %d", node->sortColIdx[i]);
379 appendStringInfoString(str, " :sortOperators");
380 for (i = 0; i < node->numCols; i++)
381 appendStringInfo(str, " %u", node->sortOperators[i]);
383 appendStringInfoString(str, " :collations");
384 for (i = 0; i < node->numCols; i++)
385 appendStringInfo(str, " %u", node->collations[i]);
387 appendStringInfoString(str, " :nullsFirst");
388 for (i = 0; i < node->numCols; i++)
389 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
393 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
397 WRITE_NODE_TYPE("RECURSIVEUNION");
399 _outPlanInfo(str, (const Plan *) node);
401 WRITE_INT_FIELD(wtParam);
402 WRITE_INT_FIELD(numCols);
404 appendStringInfoString(str, " :dupColIdx");
405 for (i = 0; i < node->numCols; i++)
406 appendStringInfo(str, " %d", node->dupColIdx[i]);
408 appendStringInfoString(str, " :dupOperators");
409 for (i = 0; i < node->numCols; i++)
410 appendStringInfo(str, " %u", node->dupOperators[i]);
412 WRITE_LONG_FIELD(numGroups);
416 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
418 WRITE_NODE_TYPE("BITMAPAND");
420 _outPlanInfo(str, (const Plan *) node);
422 WRITE_NODE_FIELD(bitmapplans);
426 _outBitmapOr(StringInfo str, const BitmapOr *node)
428 WRITE_NODE_TYPE("BITMAPOR");
430 _outPlanInfo(str, (const Plan *) node);
432 WRITE_NODE_FIELD(bitmapplans);
436 _outGather(StringInfo str, const Gather *node)
438 WRITE_NODE_TYPE("GATHER");
440 _outPlanInfo(str, (const Plan *) node);
442 WRITE_UINT_FIELD(num_workers);
443 WRITE_UINT_FIELD(single_copy);
447 _outScan(StringInfo str, const Scan *node)
449 WRITE_NODE_TYPE("SCAN");
451 _outScanInfo(str, node);
455 _outSeqScan(StringInfo str, const SeqScan *node)
457 WRITE_NODE_TYPE("SEQSCAN");
459 _outScanInfo(str, (const Scan *) node);
463 _outSampleScan(StringInfo str, const SampleScan *node)
465 WRITE_NODE_TYPE("SAMPLESCAN");
467 _outScanInfo(str, (const Scan *) node);
469 WRITE_NODE_FIELD(tablesample);
473 _outIndexScan(StringInfo str, const IndexScan *node)
475 WRITE_NODE_TYPE("INDEXSCAN");
477 _outScanInfo(str, (const Scan *) node);
479 WRITE_OID_FIELD(indexid);
480 WRITE_NODE_FIELD(indexqual);
481 WRITE_NODE_FIELD(indexqualorig);
482 WRITE_NODE_FIELD(indexorderby);
483 WRITE_NODE_FIELD(indexorderbyorig);
484 WRITE_NODE_FIELD(indexorderbyops);
485 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
489 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
491 WRITE_NODE_TYPE("INDEXONLYSCAN");
493 _outScanInfo(str, (const Scan *) node);
495 WRITE_OID_FIELD(indexid);
496 WRITE_NODE_FIELD(indexqual);
497 WRITE_NODE_FIELD(indexorderby);
498 WRITE_NODE_FIELD(indextlist);
499 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
503 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
505 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
507 _outScanInfo(str, (const Scan *) node);
509 WRITE_OID_FIELD(indexid);
510 WRITE_NODE_FIELD(indexqual);
511 WRITE_NODE_FIELD(indexqualorig);
515 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
517 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
519 _outScanInfo(str, (const Scan *) node);
521 WRITE_NODE_FIELD(bitmapqualorig);
525 _outTidScan(StringInfo str, const TidScan *node)
527 WRITE_NODE_TYPE("TIDSCAN");
529 _outScanInfo(str, (const Scan *) node);
531 WRITE_NODE_FIELD(tidquals);
535 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
537 WRITE_NODE_TYPE("SUBQUERYSCAN");
539 _outScanInfo(str, (const Scan *) node);
541 WRITE_NODE_FIELD(subplan);
545 _outFunctionScan(StringInfo str, const FunctionScan *node)
547 WRITE_NODE_TYPE("FUNCTIONSCAN");
549 _outScanInfo(str, (const Scan *) node);
551 WRITE_NODE_FIELD(functions);
552 WRITE_BOOL_FIELD(funcordinality);
556 _outValuesScan(StringInfo str, const ValuesScan *node)
558 WRITE_NODE_TYPE("VALUESSCAN");
560 _outScanInfo(str, (const Scan *) node);
562 WRITE_NODE_FIELD(values_lists);
566 _outCteScan(StringInfo str, const CteScan *node)
568 WRITE_NODE_TYPE("CTESCAN");
570 _outScanInfo(str, (const Scan *) node);
572 WRITE_INT_FIELD(ctePlanId);
573 WRITE_INT_FIELD(cteParam);
577 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
579 WRITE_NODE_TYPE("WORKTABLESCAN");
581 _outScanInfo(str, (const Scan *) node);
583 WRITE_INT_FIELD(wtParam);
587 _outForeignScan(StringInfo str, const ForeignScan *node)
589 WRITE_NODE_TYPE("FOREIGNSCAN");
591 _outScanInfo(str, (const Scan *) node);
593 WRITE_OID_FIELD(fs_server);
594 WRITE_NODE_FIELD(fdw_exprs);
595 WRITE_NODE_FIELD(fdw_private);
596 WRITE_NODE_FIELD(fdw_scan_tlist);
597 WRITE_BITMAPSET_FIELD(fs_relids);
598 WRITE_BOOL_FIELD(fsSystemCol);
602 _outCustomScan(StringInfo str, const CustomScan *node)
604 WRITE_NODE_TYPE("CUSTOMSCAN");
606 _outScanInfo(str, (const Scan *) node);
608 WRITE_UINT_FIELD(flags);
609 WRITE_NODE_FIELD(custom_plans);
610 WRITE_NODE_FIELD(custom_exprs);
611 WRITE_NODE_FIELD(custom_private);
612 WRITE_NODE_FIELD(custom_scan_tlist);
613 WRITE_BITMAPSET_FIELD(custom_relids);
614 appendStringInfoString(str, " :methods ");
615 _outToken(str, node->methods->CustomName);
616 if (node->methods->TextOutCustomScan)
617 node->methods->TextOutCustomScan(str, node);
621 _outJoin(StringInfo str, const Join *node)
623 WRITE_NODE_TYPE("JOIN");
625 _outJoinPlanInfo(str, (const Join *) node);
629 _outNestLoop(StringInfo str, const NestLoop *node)
631 WRITE_NODE_TYPE("NESTLOOP");
633 _outJoinPlanInfo(str, (const Join *) node);
635 WRITE_NODE_FIELD(nestParams);
639 _outMergeJoin(StringInfo str, const MergeJoin *node)
644 WRITE_NODE_TYPE("MERGEJOIN");
646 _outJoinPlanInfo(str, (const Join *) node);
648 WRITE_NODE_FIELD(mergeclauses);
650 numCols = list_length(node->mergeclauses);
652 appendStringInfoString(str, " :mergeFamilies");
653 for (i = 0; i < numCols; i++)
654 appendStringInfo(str, " %u", node->mergeFamilies[i]);
656 appendStringInfoString(str, " :mergeCollations");
657 for (i = 0; i < numCols; i++)
658 appendStringInfo(str, " %u", node->mergeCollations[i]);
660 appendStringInfoString(str, " :mergeStrategies");
661 for (i = 0; i < numCols; i++)
662 appendStringInfo(str, " %d", node->mergeStrategies[i]);
664 appendStringInfoString(str, " :mergeNullsFirst");
665 for (i = 0; i < numCols; i++)
666 appendStringInfo(str, " %s", booltostr(node->mergeNullsFirst[i]));
670 _outHashJoin(StringInfo str, const HashJoin *node)
672 WRITE_NODE_TYPE("HASHJOIN");
674 _outJoinPlanInfo(str, (const Join *) node);
676 WRITE_NODE_FIELD(hashclauses);
680 _outAgg(StringInfo str, const Agg *node)
684 WRITE_NODE_TYPE("AGG");
686 _outPlanInfo(str, (const Plan *) node);
688 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
689 WRITE_INT_FIELD(numCols);
691 appendStringInfoString(str, " :grpColIdx");
692 for (i = 0; i < node->numCols; i++)
693 appendStringInfo(str, " %d", node->grpColIdx[i]);
695 appendStringInfoString(str, " :grpOperators");
696 for (i = 0; i < node->numCols; i++)
697 appendStringInfo(str, " %u", node->grpOperators[i]);
699 WRITE_LONG_FIELD(numGroups);
701 WRITE_NODE_FIELD(groupingSets);
702 WRITE_NODE_FIELD(chain);
706 _outWindowAgg(StringInfo str, const WindowAgg *node)
710 WRITE_NODE_TYPE("WINDOWAGG");
712 _outPlanInfo(str, (const Plan *) node);
714 WRITE_UINT_FIELD(winref);
715 WRITE_INT_FIELD(partNumCols);
717 appendStringInfoString(str, " :partColIdx");
718 for (i = 0; i < node->partNumCols; i++)
719 appendStringInfo(str, " %d", node->partColIdx[i]);
721 appendStringInfoString(str, " :partOperations");
722 for (i = 0; i < node->partNumCols; i++)
723 appendStringInfo(str, " %u", node->partOperators[i]);
725 WRITE_INT_FIELD(ordNumCols);
727 appendStringInfoString(str, " :ordColIdx");
728 for (i = 0; i < node->ordNumCols; i++)
729 appendStringInfo(str, " %d", node->ordColIdx[i]);
731 appendStringInfoString(str, " :ordOperations");
732 for (i = 0; i < node->ordNumCols; i++)
733 appendStringInfo(str, " %u", node->ordOperators[i]);
735 WRITE_INT_FIELD(frameOptions);
736 WRITE_NODE_FIELD(startOffset);
737 WRITE_NODE_FIELD(endOffset);
741 _outGroup(StringInfo str, const Group *node)
745 WRITE_NODE_TYPE("GROUP");
747 _outPlanInfo(str, (const Plan *) node);
749 WRITE_INT_FIELD(numCols);
751 appendStringInfoString(str, " :grpColIdx");
752 for (i = 0; i < node->numCols; i++)
753 appendStringInfo(str, " %d", node->grpColIdx[i]);
755 appendStringInfoString(str, " :grpOperators");
756 for (i = 0; i < node->numCols; i++)
757 appendStringInfo(str, " %u", node->grpOperators[i]);
761 _outMaterial(StringInfo str, const Material *node)
763 WRITE_NODE_TYPE("MATERIAL");
765 _outPlanInfo(str, (const Plan *) node);
769 _outSort(StringInfo str, const Sort *node)
773 WRITE_NODE_TYPE("SORT");
775 _outPlanInfo(str, (const Plan *) node);
777 WRITE_INT_FIELD(numCols);
779 appendStringInfoString(str, " :sortColIdx");
780 for (i = 0; i < node->numCols; i++)
781 appendStringInfo(str, " %d", node->sortColIdx[i]);
783 appendStringInfoString(str, " :sortOperators");
784 for (i = 0; i < node->numCols; i++)
785 appendStringInfo(str, " %u", node->sortOperators[i]);
787 appendStringInfoString(str, " :collations");
788 for (i = 0; i < node->numCols; i++)
789 appendStringInfo(str, " %u", node->collations[i]);
791 appendStringInfoString(str, " :nullsFirst");
792 for (i = 0; i < node->numCols; i++)
793 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
797 _outUnique(StringInfo str, const Unique *node)
801 WRITE_NODE_TYPE("UNIQUE");
803 _outPlanInfo(str, (const Plan *) node);
805 WRITE_INT_FIELD(numCols);
807 appendStringInfoString(str, " :uniqColIdx");
808 for (i = 0; i < node->numCols; i++)
809 appendStringInfo(str, " %d", node->uniqColIdx[i]);
811 appendStringInfoString(str, " :uniqOperators");
812 for (i = 0; i < node->numCols; i++)
813 appendStringInfo(str, " %u", node->uniqOperators[i]);
817 _outHash(StringInfo str, const Hash *node)
819 WRITE_NODE_TYPE("HASH");
821 _outPlanInfo(str, (const Plan *) node);
823 WRITE_OID_FIELD(skewTable);
824 WRITE_INT_FIELD(skewColumn);
825 WRITE_BOOL_FIELD(skewInherit);
826 WRITE_OID_FIELD(skewColType);
827 WRITE_INT_FIELD(skewColTypmod);
831 _outSetOp(StringInfo str, const SetOp *node)
835 WRITE_NODE_TYPE("SETOP");
837 _outPlanInfo(str, (const Plan *) node);
839 WRITE_ENUM_FIELD(cmd, SetOpCmd);
840 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
841 WRITE_INT_FIELD(numCols);
843 appendStringInfoString(str, " :dupColIdx");
844 for (i = 0; i < node->numCols; i++)
845 appendStringInfo(str, " %d", node->dupColIdx[i]);
847 appendStringInfoString(str, " :dupOperators");
848 for (i = 0; i < node->numCols; i++)
849 appendStringInfo(str, " %u", node->dupOperators[i]);
851 WRITE_INT_FIELD(flagColIdx);
852 WRITE_INT_FIELD(firstFlag);
853 WRITE_LONG_FIELD(numGroups);
857 _outLockRows(StringInfo str, const LockRows *node)
859 WRITE_NODE_TYPE("LOCKROWS");
861 _outPlanInfo(str, (const Plan *) node);
863 WRITE_NODE_FIELD(rowMarks);
864 WRITE_INT_FIELD(epqParam);
868 _outLimit(StringInfo str, const Limit *node)
870 WRITE_NODE_TYPE("LIMIT");
872 _outPlanInfo(str, (const Plan *) node);
874 WRITE_NODE_FIELD(limitOffset);
875 WRITE_NODE_FIELD(limitCount);
879 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
881 WRITE_NODE_TYPE("NESTLOOPPARAM");
883 WRITE_INT_FIELD(paramno);
884 WRITE_NODE_FIELD(paramval);
888 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
890 WRITE_NODE_TYPE("PLANROWMARK");
892 WRITE_UINT_FIELD(rti);
893 WRITE_UINT_FIELD(prti);
894 WRITE_UINT_FIELD(rowmarkId);
895 WRITE_ENUM_FIELD(markType, RowMarkType);
896 WRITE_INT_FIELD(allMarkTypes);
897 WRITE_ENUM_FIELD(strength, LockClauseStrength);
898 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
899 WRITE_BOOL_FIELD(isParent);
903 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
905 WRITE_NODE_TYPE("PLANINVALITEM");
907 WRITE_INT_FIELD(cacheId);
908 WRITE_UINT_FIELD(hashValue);
911 /*****************************************************************************
913 * Stuff from primnodes.h.
915 *****************************************************************************/
918 _outAlias(StringInfo str, const Alias *node)
920 WRITE_NODE_TYPE("ALIAS");
922 WRITE_STRING_FIELD(aliasname);
923 WRITE_NODE_FIELD(colnames);
927 _outRangeVar(StringInfo str, const RangeVar *node)
929 WRITE_NODE_TYPE("RANGEVAR");
932 * we deliberately ignore catalogname here, since it is presently not
933 * semantically meaningful
935 WRITE_STRING_FIELD(schemaname);
936 WRITE_STRING_FIELD(relname);
937 WRITE_ENUM_FIELD(inhOpt, InhOption);
938 WRITE_CHAR_FIELD(relpersistence);
939 WRITE_NODE_FIELD(alias);
940 WRITE_LOCATION_FIELD(location);
944 _outIntoClause(StringInfo str, const IntoClause *node)
946 WRITE_NODE_TYPE("INTOCLAUSE");
948 WRITE_NODE_FIELD(rel);
949 WRITE_NODE_FIELD(colNames);
950 WRITE_NODE_FIELD(options);
951 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
952 WRITE_STRING_FIELD(tableSpaceName);
953 WRITE_NODE_FIELD(viewQuery);
954 WRITE_BOOL_FIELD(skipData);
958 _outVar(StringInfo str, const Var *node)
960 WRITE_NODE_TYPE("VAR");
962 WRITE_UINT_FIELD(varno);
963 WRITE_INT_FIELD(varattno);
964 WRITE_OID_FIELD(vartype);
965 WRITE_INT_FIELD(vartypmod);
966 WRITE_OID_FIELD(varcollid);
967 WRITE_UINT_FIELD(varlevelsup);
968 WRITE_UINT_FIELD(varnoold);
969 WRITE_INT_FIELD(varoattno);
970 WRITE_LOCATION_FIELD(location);
974 _outConst(StringInfo str, const Const *node)
976 WRITE_NODE_TYPE("CONST");
978 WRITE_OID_FIELD(consttype);
979 WRITE_INT_FIELD(consttypmod);
980 WRITE_OID_FIELD(constcollid);
981 WRITE_INT_FIELD(constlen);
982 WRITE_BOOL_FIELD(constbyval);
983 WRITE_BOOL_FIELD(constisnull);
984 WRITE_LOCATION_FIELD(location);
986 appendStringInfoString(str, " :constvalue ");
987 if (node->constisnull)
988 appendStringInfoString(str, "<>");
990 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
994 _outParam(StringInfo str, const Param *node)
996 WRITE_NODE_TYPE("PARAM");
998 WRITE_ENUM_FIELD(paramkind, ParamKind);
999 WRITE_INT_FIELD(paramid);
1000 WRITE_OID_FIELD(paramtype);
1001 WRITE_INT_FIELD(paramtypmod);
1002 WRITE_OID_FIELD(paramcollid);
1003 WRITE_LOCATION_FIELD(location);
1007 _outAggref(StringInfo str, const Aggref *node)
1009 WRITE_NODE_TYPE("AGGREF");
1011 WRITE_OID_FIELD(aggfnoid);
1012 WRITE_OID_FIELD(aggtype);
1013 WRITE_OID_FIELD(aggcollid);
1014 WRITE_OID_FIELD(inputcollid);
1015 WRITE_NODE_FIELD(aggdirectargs);
1016 WRITE_NODE_FIELD(args);
1017 WRITE_NODE_FIELD(aggorder);
1018 WRITE_NODE_FIELD(aggdistinct);
1019 WRITE_NODE_FIELD(aggfilter);
1020 WRITE_BOOL_FIELD(aggstar);
1021 WRITE_BOOL_FIELD(aggvariadic);
1022 WRITE_CHAR_FIELD(aggkind);
1023 WRITE_UINT_FIELD(agglevelsup);
1024 WRITE_LOCATION_FIELD(location);
1028 _outGroupingFunc(StringInfo str, const GroupingFunc *node)
1030 WRITE_NODE_TYPE("GROUPINGFUNC");
1032 WRITE_NODE_FIELD(args);
1033 WRITE_NODE_FIELD(refs);
1034 WRITE_NODE_FIELD(cols);
1035 WRITE_UINT_FIELD(agglevelsup);
1036 WRITE_LOCATION_FIELD(location);
1040 _outWindowFunc(StringInfo str, const WindowFunc *node)
1042 WRITE_NODE_TYPE("WINDOWFUNC");
1044 WRITE_OID_FIELD(winfnoid);
1045 WRITE_OID_FIELD(wintype);
1046 WRITE_OID_FIELD(wincollid);
1047 WRITE_OID_FIELD(inputcollid);
1048 WRITE_NODE_FIELD(args);
1049 WRITE_NODE_FIELD(aggfilter);
1050 WRITE_UINT_FIELD(winref);
1051 WRITE_BOOL_FIELD(winstar);
1052 WRITE_BOOL_FIELD(winagg);
1053 WRITE_LOCATION_FIELD(location);
1057 _outArrayRef(StringInfo str, const ArrayRef *node)
1059 WRITE_NODE_TYPE("ARRAYREF");
1061 WRITE_OID_FIELD(refarraytype);
1062 WRITE_OID_FIELD(refelemtype);
1063 WRITE_INT_FIELD(reftypmod);
1064 WRITE_OID_FIELD(refcollid);
1065 WRITE_NODE_FIELD(refupperindexpr);
1066 WRITE_NODE_FIELD(reflowerindexpr);
1067 WRITE_NODE_FIELD(refexpr);
1068 WRITE_NODE_FIELD(refassgnexpr);
1072 _outFuncExpr(StringInfo str, const FuncExpr *node)
1074 WRITE_NODE_TYPE("FUNCEXPR");
1076 WRITE_OID_FIELD(funcid);
1077 WRITE_OID_FIELD(funcresulttype);
1078 WRITE_BOOL_FIELD(funcretset);
1079 WRITE_BOOL_FIELD(funcvariadic);
1080 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1081 WRITE_OID_FIELD(funccollid);
1082 WRITE_OID_FIELD(inputcollid);
1083 WRITE_NODE_FIELD(args);
1084 WRITE_LOCATION_FIELD(location);
1088 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1090 WRITE_NODE_TYPE("NAMEDARGEXPR");
1092 WRITE_NODE_FIELD(arg);
1093 WRITE_STRING_FIELD(name);
1094 WRITE_INT_FIELD(argnumber);
1095 WRITE_LOCATION_FIELD(location);
1099 _outOpExpr(StringInfo str, const OpExpr *node)
1101 WRITE_NODE_TYPE("OPEXPR");
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 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1116 WRITE_NODE_TYPE("DISTINCTEXPR");
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 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1131 WRITE_NODE_TYPE("NULLIFEXPR");
1133 WRITE_OID_FIELD(opno);
1134 WRITE_OID_FIELD(opfuncid);
1135 WRITE_OID_FIELD(opresulttype);
1136 WRITE_BOOL_FIELD(opretset);
1137 WRITE_OID_FIELD(opcollid);
1138 WRITE_OID_FIELD(inputcollid);
1139 WRITE_NODE_FIELD(args);
1140 WRITE_LOCATION_FIELD(location);
1144 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1146 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1148 WRITE_OID_FIELD(opno);
1149 WRITE_OID_FIELD(opfuncid);
1150 WRITE_BOOL_FIELD(useOr);
1151 WRITE_OID_FIELD(inputcollid);
1152 WRITE_NODE_FIELD(args);
1153 WRITE_LOCATION_FIELD(location);
1157 _outBoolExpr(StringInfo str, const BoolExpr *node)
1161 WRITE_NODE_TYPE("BOOLEXPR");
1163 /* do-it-yourself enum representation */
1164 switch (node->boolop)
1176 appendStringInfoString(str, " :boolop ");
1177 _outToken(str, opstr);
1179 WRITE_NODE_FIELD(args);
1180 WRITE_LOCATION_FIELD(location);
1184 _outSubLink(StringInfo str, const SubLink *node)
1186 WRITE_NODE_TYPE("SUBLINK");
1188 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1189 WRITE_INT_FIELD(subLinkId);
1190 WRITE_NODE_FIELD(testexpr);
1191 WRITE_NODE_FIELD(operName);
1192 WRITE_NODE_FIELD(subselect);
1193 WRITE_LOCATION_FIELD(location);
1197 _outSubPlan(StringInfo str, const SubPlan *node)
1199 WRITE_NODE_TYPE("SUBPLAN");
1201 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1202 WRITE_NODE_FIELD(testexpr);
1203 WRITE_NODE_FIELD(paramIds);
1204 WRITE_INT_FIELD(plan_id);
1205 WRITE_STRING_FIELD(plan_name);
1206 WRITE_OID_FIELD(firstColType);
1207 WRITE_INT_FIELD(firstColTypmod);
1208 WRITE_OID_FIELD(firstColCollation);
1209 WRITE_BOOL_FIELD(useHashTable);
1210 WRITE_BOOL_FIELD(unknownEqFalse);
1211 WRITE_NODE_FIELD(setParam);
1212 WRITE_NODE_FIELD(parParam);
1213 WRITE_NODE_FIELD(args);
1214 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1215 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1219 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1221 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1223 WRITE_NODE_FIELD(subplans);
1227 _outFieldSelect(StringInfo str, const FieldSelect *node)
1229 WRITE_NODE_TYPE("FIELDSELECT");
1231 WRITE_NODE_FIELD(arg);
1232 WRITE_INT_FIELD(fieldnum);
1233 WRITE_OID_FIELD(resulttype);
1234 WRITE_INT_FIELD(resulttypmod);
1235 WRITE_OID_FIELD(resultcollid);
1239 _outFieldStore(StringInfo str, const FieldStore *node)
1241 WRITE_NODE_TYPE("FIELDSTORE");
1243 WRITE_NODE_FIELD(arg);
1244 WRITE_NODE_FIELD(newvals);
1245 WRITE_NODE_FIELD(fieldnums);
1246 WRITE_OID_FIELD(resulttype);
1250 _outRelabelType(StringInfo str, const RelabelType *node)
1252 WRITE_NODE_TYPE("RELABELTYPE");
1254 WRITE_NODE_FIELD(arg);
1255 WRITE_OID_FIELD(resulttype);
1256 WRITE_INT_FIELD(resulttypmod);
1257 WRITE_OID_FIELD(resultcollid);
1258 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1259 WRITE_LOCATION_FIELD(location);
1263 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1265 WRITE_NODE_TYPE("COERCEVIAIO");
1267 WRITE_NODE_FIELD(arg);
1268 WRITE_OID_FIELD(resulttype);
1269 WRITE_OID_FIELD(resultcollid);
1270 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1271 WRITE_LOCATION_FIELD(location);
1275 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1277 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1279 WRITE_NODE_FIELD(arg);
1280 WRITE_OID_FIELD(elemfuncid);
1281 WRITE_OID_FIELD(resulttype);
1282 WRITE_INT_FIELD(resulttypmod);
1283 WRITE_OID_FIELD(resultcollid);
1284 WRITE_BOOL_FIELD(isExplicit);
1285 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1286 WRITE_LOCATION_FIELD(location);
1290 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1292 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1294 WRITE_NODE_FIELD(arg);
1295 WRITE_OID_FIELD(resulttype);
1296 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1297 WRITE_LOCATION_FIELD(location);
1301 _outCollateExpr(StringInfo str, const CollateExpr *node)
1303 WRITE_NODE_TYPE("COLLATE");
1305 WRITE_NODE_FIELD(arg);
1306 WRITE_OID_FIELD(collOid);
1307 WRITE_LOCATION_FIELD(location);
1311 _outCaseExpr(StringInfo str, const CaseExpr *node)
1313 WRITE_NODE_TYPE("CASE");
1315 WRITE_OID_FIELD(casetype);
1316 WRITE_OID_FIELD(casecollid);
1317 WRITE_NODE_FIELD(arg);
1318 WRITE_NODE_FIELD(args);
1319 WRITE_NODE_FIELD(defresult);
1320 WRITE_LOCATION_FIELD(location);
1324 _outCaseWhen(StringInfo str, const CaseWhen *node)
1326 WRITE_NODE_TYPE("WHEN");
1328 WRITE_NODE_FIELD(expr);
1329 WRITE_NODE_FIELD(result);
1330 WRITE_LOCATION_FIELD(location);
1334 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1336 WRITE_NODE_TYPE("CASETESTEXPR");
1338 WRITE_OID_FIELD(typeId);
1339 WRITE_INT_FIELD(typeMod);
1340 WRITE_OID_FIELD(collation);
1344 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1346 WRITE_NODE_TYPE("ARRAY");
1348 WRITE_OID_FIELD(array_typeid);
1349 WRITE_OID_FIELD(array_collid);
1350 WRITE_OID_FIELD(element_typeid);
1351 WRITE_NODE_FIELD(elements);
1352 WRITE_BOOL_FIELD(multidims);
1353 WRITE_LOCATION_FIELD(location);
1357 _outRowExpr(StringInfo str, const RowExpr *node)
1359 WRITE_NODE_TYPE("ROW");
1361 WRITE_NODE_FIELD(args);
1362 WRITE_OID_FIELD(row_typeid);
1363 WRITE_ENUM_FIELD(row_format, CoercionForm);
1364 WRITE_NODE_FIELD(colnames);
1365 WRITE_LOCATION_FIELD(location);
1369 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1371 WRITE_NODE_TYPE("ROWCOMPARE");
1373 WRITE_ENUM_FIELD(rctype, RowCompareType);
1374 WRITE_NODE_FIELD(opnos);
1375 WRITE_NODE_FIELD(opfamilies);
1376 WRITE_NODE_FIELD(inputcollids);
1377 WRITE_NODE_FIELD(largs);
1378 WRITE_NODE_FIELD(rargs);
1382 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1384 WRITE_NODE_TYPE("COALESCE");
1386 WRITE_OID_FIELD(coalescetype);
1387 WRITE_OID_FIELD(coalescecollid);
1388 WRITE_NODE_FIELD(args);
1389 WRITE_LOCATION_FIELD(location);
1393 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1395 WRITE_NODE_TYPE("MINMAX");
1397 WRITE_OID_FIELD(minmaxtype);
1398 WRITE_OID_FIELD(minmaxcollid);
1399 WRITE_OID_FIELD(inputcollid);
1400 WRITE_ENUM_FIELD(op, MinMaxOp);
1401 WRITE_NODE_FIELD(args);
1402 WRITE_LOCATION_FIELD(location);
1406 _outXmlExpr(StringInfo str, const XmlExpr *node)
1408 WRITE_NODE_TYPE("XMLEXPR");
1410 WRITE_ENUM_FIELD(op, XmlExprOp);
1411 WRITE_STRING_FIELD(name);
1412 WRITE_NODE_FIELD(named_args);
1413 WRITE_NODE_FIELD(arg_names);
1414 WRITE_NODE_FIELD(args);
1415 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1416 WRITE_OID_FIELD(type);
1417 WRITE_INT_FIELD(typmod);
1418 WRITE_LOCATION_FIELD(location);
1422 _outNullTest(StringInfo str, const NullTest *node)
1424 WRITE_NODE_TYPE("NULLTEST");
1426 WRITE_NODE_FIELD(arg);
1427 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1428 WRITE_BOOL_FIELD(argisrow);
1429 WRITE_LOCATION_FIELD(location);
1433 _outBooleanTest(StringInfo str, const BooleanTest *node)
1435 WRITE_NODE_TYPE("BOOLEANTEST");
1437 WRITE_NODE_FIELD(arg);
1438 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1439 WRITE_LOCATION_FIELD(location);
1443 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1445 WRITE_NODE_TYPE("COERCETODOMAIN");
1447 WRITE_NODE_FIELD(arg);
1448 WRITE_OID_FIELD(resulttype);
1449 WRITE_INT_FIELD(resulttypmod);
1450 WRITE_OID_FIELD(resultcollid);
1451 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1452 WRITE_LOCATION_FIELD(location);
1456 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1458 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1460 WRITE_OID_FIELD(typeId);
1461 WRITE_INT_FIELD(typeMod);
1462 WRITE_OID_FIELD(collation);
1463 WRITE_LOCATION_FIELD(location);
1467 _outSetToDefault(StringInfo str, const SetToDefault *node)
1469 WRITE_NODE_TYPE("SETTODEFAULT");
1471 WRITE_OID_FIELD(typeId);
1472 WRITE_INT_FIELD(typeMod);
1473 WRITE_OID_FIELD(collation);
1474 WRITE_LOCATION_FIELD(location);
1478 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1480 WRITE_NODE_TYPE("CURRENTOFEXPR");
1482 WRITE_UINT_FIELD(cvarno);
1483 WRITE_STRING_FIELD(cursor_name);
1484 WRITE_INT_FIELD(cursor_param);
1488 _outInferenceElem(StringInfo str, const InferenceElem *node)
1490 WRITE_NODE_TYPE("INFERENCEELEM");
1492 WRITE_NODE_FIELD(expr);
1493 WRITE_OID_FIELD(infercollid);
1494 WRITE_OID_FIELD(inferopclass);
1498 _outTargetEntry(StringInfo str, const TargetEntry *node)
1500 WRITE_NODE_TYPE("TARGETENTRY");
1502 WRITE_NODE_FIELD(expr);
1503 WRITE_INT_FIELD(resno);
1504 WRITE_STRING_FIELD(resname);
1505 WRITE_UINT_FIELD(ressortgroupref);
1506 WRITE_OID_FIELD(resorigtbl);
1507 WRITE_INT_FIELD(resorigcol);
1508 WRITE_BOOL_FIELD(resjunk);
1512 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1514 WRITE_NODE_TYPE("RANGETBLREF");
1516 WRITE_INT_FIELD(rtindex);
1520 _outJoinExpr(StringInfo str, const JoinExpr *node)
1522 WRITE_NODE_TYPE("JOINEXPR");
1524 WRITE_ENUM_FIELD(jointype, JoinType);
1525 WRITE_BOOL_FIELD(isNatural);
1526 WRITE_NODE_FIELD(larg);
1527 WRITE_NODE_FIELD(rarg);
1528 WRITE_NODE_FIELD(usingClause);
1529 WRITE_NODE_FIELD(quals);
1530 WRITE_NODE_FIELD(alias);
1531 WRITE_INT_FIELD(rtindex);
1535 _outFromExpr(StringInfo str, const FromExpr *node)
1537 WRITE_NODE_TYPE("FROMEXPR");
1539 WRITE_NODE_FIELD(fromlist);
1540 WRITE_NODE_FIELD(quals);
1544 _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
1546 WRITE_NODE_TYPE("ONCONFLICTEXPR");
1548 WRITE_ENUM_FIELD(action, OnConflictAction);
1549 WRITE_NODE_FIELD(arbiterElems);
1550 WRITE_NODE_FIELD(arbiterWhere);
1551 WRITE_OID_FIELD(constraint);
1552 WRITE_NODE_FIELD(onConflictSet);
1553 WRITE_NODE_FIELD(onConflictWhere);
1554 WRITE_INT_FIELD(exclRelIndex);
1555 WRITE_NODE_FIELD(exclRelTlist);
1558 /*****************************************************************************
1560 * Stuff from relation.h.
1562 *****************************************************************************/
1565 * print the basic stuff of all nodes that inherit from Path
1567 * Note we do NOT print the parent, else we'd be in infinite recursion.
1568 * We can print the parent's relids for identification purposes, though.
1569 * We also do not print the whole of param_info, since it's printed by
1570 * _outRelOptInfo; it's sufficient and less cluttering to print just the
1571 * required outer relids.
1574 _outPathInfo(StringInfo str, const Path *node)
1576 WRITE_ENUM_FIELD(pathtype, NodeTag);
1577 appendStringInfoString(str, " :parent_relids ");
1579 _outBitmapset(str, node->parent->relids);
1581 _outBitmapset(str, NULL);
1582 appendStringInfoString(str, " :required_outer ");
1583 if (node->param_info)
1584 _outBitmapset(str, node->param_info->ppi_req_outer);
1586 _outBitmapset(str, NULL);
1587 WRITE_FLOAT_FIELD(rows, "%.0f");
1588 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1589 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1590 WRITE_NODE_FIELD(pathkeys);
1594 * print the basic stuff of all nodes that inherit from JoinPath
1597 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1599 _outPathInfo(str, (const Path *) node);
1601 WRITE_ENUM_FIELD(jointype, JoinType);
1602 WRITE_NODE_FIELD(outerjoinpath);
1603 WRITE_NODE_FIELD(innerjoinpath);
1604 WRITE_NODE_FIELD(joinrestrictinfo);
1608 _outPath(StringInfo str, const Path *node)
1610 WRITE_NODE_TYPE("PATH");
1612 _outPathInfo(str, (const Path *) node);
1616 _outIndexPath(StringInfo str, const IndexPath *node)
1618 WRITE_NODE_TYPE("INDEXPATH");
1620 _outPathInfo(str, (const Path *) node);
1622 WRITE_NODE_FIELD(indexinfo);
1623 WRITE_NODE_FIELD(indexclauses);
1624 WRITE_NODE_FIELD(indexquals);
1625 WRITE_NODE_FIELD(indexqualcols);
1626 WRITE_NODE_FIELD(indexorderbys);
1627 WRITE_NODE_FIELD(indexorderbycols);
1628 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1629 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1630 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1634 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1636 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1638 _outPathInfo(str, (const Path *) node);
1640 WRITE_NODE_FIELD(bitmapqual);
1644 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1646 WRITE_NODE_TYPE("BITMAPANDPATH");
1648 _outPathInfo(str, (const Path *) node);
1650 WRITE_NODE_FIELD(bitmapquals);
1651 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1655 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1657 WRITE_NODE_TYPE("BITMAPORPATH");
1659 _outPathInfo(str, (const Path *) node);
1661 WRITE_NODE_FIELD(bitmapquals);
1662 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1666 _outTidPath(StringInfo str, const TidPath *node)
1668 WRITE_NODE_TYPE("TIDPATH");
1670 _outPathInfo(str, (const Path *) node);
1672 WRITE_NODE_FIELD(tidquals);
1676 _outForeignPath(StringInfo str, const ForeignPath *node)
1678 WRITE_NODE_TYPE("FOREIGNPATH");
1680 _outPathInfo(str, (const Path *) node);
1682 WRITE_NODE_FIELD(fdw_private);
1686 _outCustomPath(StringInfo str, const CustomPath *node)
1688 WRITE_NODE_TYPE("CUSTOMPATH");
1690 _outPathInfo(str, (const Path *) node);
1692 WRITE_UINT_FIELD(flags);
1693 WRITE_NODE_FIELD(custom_paths);
1694 WRITE_NODE_FIELD(custom_private);
1695 appendStringInfoString(str, " :methods ");
1696 _outToken(str, node->methods->CustomName);
1697 if (node->methods->TextOutCustomPath)
1698 node->methods->TextOutCustomPath(str, node);
1702 _outAppendPath(StringInfo str, const AppendPath *node)
1704 WRITE_NODE_TYPE("APPENDPATH");
1706 _outPathInfo(str, (const Path *) node);
1708 WRITE_NODE_FIELD(subpaths);
1712 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1714 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1716 _outPathInfo(str, (const Path *) node);
1718 WRITE_NODE_FIELD(subpaths);
1719 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1723 _outResultPath(StringInfo str, const ResultPath *node)
1725 WRITE_NODE_TYPE("RESULTPATH");
1727 _outPathInfo(str, (const Path *) node);
1729 WRITE_NODE_FIELD(quals);
1733 _outMaterialPath(StringInfo str, const MaterialPath *node)
1735 WRITE_NODE_TYPE("MATERIALPATH");
1737 _outPathInfo(str, (const Path *) node);
1739 WRITE_NODE_FIELD(subpath);
1743 _outUniquePath(StringInfo str, const UniquePath *node)
1745 WRITE_NODE_TYPE("UNIQUEPATH");
1747 _outPathInfo(str, (const Path *) node);
1749 WRITE_NODE_FIELD(subpath);
1750 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1751 WRITE_NODE_FIELD(in_operators);
1752 WRITE_NODE_FIELD(uniq_exprs);
1756 _outNestPath(StringInfo str, const NestPath *node)
1758 WRITE_NODE_TYPE("NESTPATH");
1760 _outJoinPathInfo(str, (const JoinPath *) node);
1764 _outMergePath(StringInfo str, const MergePath *node)
1766 WRITE_NODE_TYPE("MERGEPATH");
1768 _outJoinPathInfo(str, (const JoinPath *) node);
1770 WRITE_NODE_FIELD(path_mergeclauses);
1771 WRITE_NODE_FIELD(outersortkeys);
1772 WRITE_NODE_FIELD(innersortkeys);
1773 WRITE_BOOL_FIELD(materialize_inner);
1777 _outHashPath(StringInfo str, const HashPath *node)
1779 WRITE_NODE_TYPE("HASHPATH");
1781 _outJoinPathInfo(str, (const JoinPath *) node);
1783 WRITE_NODE_FIELD(path_hashclauses);
1784 WRITE_INT_FIELD(num_batches);
1788 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
1790 WRITE_NODE_TYPE("PLANNERGLOBAL");
1792 /* NB: this isn't a complete set of fields */
1793 WRITE_NODE_FIELD(subplans);
1794 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1795 WRITE_NODE_FIELD(finalrtable);
1796 WRITE_NODE_FIELD(finalrowmarks);
1797 WRITE_NODE_FIELD(resultRelations);
1798 WRITE_NODE_FIELD(relationOids);
1799 WRITE_NODE_FIELD(invalItems);
1800 WRITE_INT_FIELD(nParamExec);
1801 WRITE_UINT_FIELD(lastPHId);
1802 WRITE_UINT_FIELD(lastRowMarkId);
1803 WRITE_BOOL_FIELD(transientPlan);
1804 WRITE_BOOL_FIELD(hasRowSecurity);
1805 WRITE_BOOL_FIELD(parallelModeOK);
1806 WRITE_BOOL_FIELD(parallelModeNeeded);
1810 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
1812 WRITE_NODE_TYPE("PLANNERINFO");
1814 /* NB: this isn't a complete set of fields */
1815 WRITE_NODE_FIELD(parse);
1816 WRITE_NODE_FIELD(glob);
1817 WRITE_UINT_FIELD(query_level);
1818 WRITE_NODE_FIELD(plan_params);
1819 WRITE_BITMAPSET_FIELD(outer_params);
1820 WRITE_BITMAPSET_FIELD(all_baserels);
1821 WRITE_BITMAPSET_FIELD(nullable_baserels);
1822 WRITE_NODE_FIELD(join_rel_list);
1823 WRITE_INT_FIELD(join_cur_level);
1824 WRITE_NODE_FIELD(init_plans);
1825 WRITE_NODE_FIELD(cte_plan_ids);
1826 WRITE_NODE_FIELD(multiexpr_params);
1827 WRITE_NODE_FIELD(eq_classes);
1828 WRITE_NODE_FIELD(canon_pathkeys);
1829 WRITE_NODE_FIELD(left_join_clauses);
1830 WRITE_NODE_FIELD(right_join_clauses);
1831 WRITE_NODE_FIELD(full_join_clauses);
1832 WRITE_NODE_FIELD(join_info_list);
1833 WRITE_NODE_FIELD(lateral_info_list);
1834 WRITE_NODE_FIELD(append_rel_list);
1835 WRITE_NODE_FIELD(rowMarks);
1836 WRITE_NODE_FIELD(placeholder_list);
1837 WRITE_NODE_FIELD(query_pathkeys);
1838 WRITE_NODE_FIELD(group_pathkeys);
1839 WRITE_NODE_FIELD(window_pathkeys);
1840 WRITE_NODE_FIELD(distinct_pathkeys);
1841 WRITE_NODE_FIELD(sort_pathkeys);
1842 WRITE_NODE_FIELD(minmax_aggs);
1843 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1844 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1845 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1846 WRITE_BOOL_FIELD(hasInheritedTarget);
1847 WRITE_BOOL_FIELD(hasJoinRTEs);
1848 WRITE_BOOL_FIELD(hasLateralRTEs);
1849 WRITE_BOOL_FIELD(hasDeletedRTEs);
1850 WRITE_BOOL_FIELD(hasHavingQual);
1851 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1852 WRITE_BOOL_FIELD(hasRecursion);
1853 WRITE_INT_FIELD(wt_param_id);
1854 WRITE_BITMAPSET_FIELD(curOuterRels);
1855 WRITE_NODE_FIELD(curOuterParams);
1859 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
1861 WRITE_NODE_TYPE("RELOPTINFO");
1863 /* NB: this isn't a complete set of fields */
1864 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1865 WRITE_BITMAPSET_FIELD(relids);
1866 WRITE_FLOAT_FIELD(rows, "%.0f");
1867 WRITE_INT_FIELD(width);
1868 WRITE_BOOL_FIELD(consider_startup);
1869 WRITE_BOOL_FIELD(consider_param_startup);
1870 WRITE_NODE_FIELD(reltargetlist);
1871 WRITE_NODE_FIELD(pathlist);
1872 WRITE_NODE_FIELD(ppilist);
1873 WRITE_NODE_FIELD(cheapest_startup_path);
1874 WRITE_NODE_FIELD(cheapest_total_path);
1875 WRITE_NODE_FIELD(cheapest_unique_path);
1876 WRITE_NODE_FIELD(cheapest_parameterized_paths);
1877 WRITE_UINT_FIELD(relid);
1878 WRITE_OID_FIELD(reltablespace);
1879 WRITE_ENUM_FIELD(rtekind, RTEKind);
1880 WRITE_INT_FIELD(min_attr);
1881 WRITE_INT_FIELD(max_attr);
1882 WRITE_NODE_FIELD(lateral_vars);
1883 WRITE_BITMAPSET_FIELD(lateral_relids);
1884 WRITE_BITMAPSET_FIELD(lateral_referencers);
1885 WRITE_NODE_FIELD(indexlist);
1886 WRITE_UINT_FIELD(pages);
1887 WRITE_FLOAT_FIELD(tuples, "%.0f");
1888 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
1889 WRITE_NODE_FIELD(subplan);
1890 WRITE_NODE_FIELD(subroot);
1891 WRITE_NODE_FIELD(subplan_params);
1892 WRITE_OID_FIELD(serverid);
1893 /* we don't try to print fdwroutine or fdw_private */
1894 WRITE_NODE_FIELD(baserestrictinfo);
1895 WRITE_NODE_FIELD(joininfo);
1896 WRITE_BOOL_FIELD(has_eclass_joins);
1900 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
1902 WRITE_NODE_TYPE("INDEXOPTINFO");
1904 /* NB: this isn't a complete set of fields */
1905 WRITE_OID_FIELD(indexoid);
1906 /* Do NOT print rel field, else infinite recursion */
1907 WRITE_UINT_FIELD(pages);
1908 WRITE_FLOAT_FIELD(tuples, "%.0f");
1909 WRITE_INT_FIELD(tree_height);
1910 WRITE_INT_FIELD(ncolumns);
1911 /* array fields aren't really worth the trouble to print */
1912 WRITE_OID_FIELD(relam);
1913 /* indexprs is redundant since we print indextlist */
1914 WRITE_NODE_FIELD(indpred);
1915 WRITE_NODE_FIELD(indextlist);
1916 WRITE_BOOL_FIELD(predOK);
1917 WRITE_BOOL_FIELD(unique);
1918 WRITE_BOOL_FIELD(immediate);
1919 WRITE_BOOL_FIELD(hypothetical);
1920 /* we don't bother with fields copied from the pg_am entry */
1924 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
1927 * To simplify reading, we just chase up to the topmost merged EC and
1928 * print that, without bothering to show the merge-ees separately.
1930 while (node->ec_merged)
1931 node = node->ec_merged;
1933 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1935 WRITE_NODE_FIELD(ec_opfamilies);
1936 WRITE_OID_FIELD(ec_collation);
1937 WRITE_NODE_FIELD(ec_members);
1938 WRITE_NODE_FIELD(ec_sources);
1939 WRITE_NODE_FIELD(ec_derives);
1940 WRITE_BITMAPSET_FIELD(ec_relids);
1941 WRITE_BOOL_FIELD(ec_has_const);
1942 WRITE_BOOL_FIELD(ec_has_volatile);
1943 WRITE_BOOL_FIELD(ec_below_outer_join);
1944 WRITE_BOOL_FIELD(ec_broken);
1945 WRITE_UINT_FIELD(ec_sortref);
1949 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
1951 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1953 WRITE_NODE_FIELD(em_expr);
1954 WRITE_BITMAPSET_FIELD(em_relids);
1955 WRITE_BITMAPSET_FIELD(em_nullable_relids);
1956 WRITE_BOOL_FIELD(em_is_const);
1957 WRITE_BOOL_FIELD(em_is_child);
1958 WRITE_OID_FIELD(em_datatype);
1962 _outPathKey(StringInfo str, const PathKey *node)
1964 WRITE_NODE_TYPE("PATHKEY");
1966 WRITE_NODE_FIELD(pk_eclass);
1967 WRITE_OID_FIELD(pk_opfamily);
1968 WRITE_INT_FIELD(pk_strategy);
1969 WRITE_BOOL_FIELD(pk_nulls_first);
1973 _outParamPathInfo(StringInfo str, const ParamPathInfo *node)
1975 WRITE_NODE_TYPE("PARAMPATHINFO");
1977 WRITE_BITMAPSET_FIELD(ppi_req_outer);
1978 WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
1979 WRITE_NODE_FIELD(ppi_clauses);
1983 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
1985 WRITE_NODE_TYPE("RESTRICTINFO");
1987 /* NB: this isn't a complete set of fields */
1988 WRITE_NODE_FIELD(clause);
1989 WRITE_BOOL_FIELD(is_pushed_down);
1990 WRITE_BOOL_FIELD(outerjoin_delayed);
1991 WRITE_BOOL_FIELD(can_join);
1992 WRITE_BOOL_FIELD(pseudoconstant);
1993 WRITE_BITMAPSET_FIELD(clause_relids);
1994 WRITE_BITMAPSET_FIELD(required_relids);
1995 WRITE_BITMAPSET_FIELD(outer_relids);
1996 WRITE_BITMAPSET_FIELD(nullable_relids);
1997 WRITE_BITMAPSET_FIELD(left_relids);
1998 WRITE_BITMAPSET_FIELD(right_relids);
1999 WRITE_NODE_FIELD(orclause);
2000 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
2001 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
2002 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
2003 WRITE_NODE_FIELD(mergeopfamilies);
2004 /* don't write left_ec, leads to infinite recursion in plan tree dump */
2005 /* don't write right_ec, leads to infinite recursion in plan tree dump */
2006 WRITE_NODE_FIELD(left_em);
2007 WRITE_NODE_FIELD(right_em);
2008 WRITE_BOOL_FIELD(outer_is_left);
2009 WRITE_OID_FIELD(hashjoinoperator);
2013 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
2015 WRITE_NODE_TYPE("PLACEHOLDERVAR");
2017 WRITE_NODE_FIELD(phexpr);
2018 WRITE_BITMAPSET_FIELD(phrels);
2019 WRITE_UINT_FIELD(phid);
2020 WRITE_UINT_FIELD(phlevelsup);
2024 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
2026 WRITE_NODE_TYPE("SPECIALJOININFO");
2028 WRITE_BITMAPSET_FIELD(min_lefthand);
2029 WRITE_BITMAPSET_FIELD(min_righthand);
2030 WRITE_BITMAPSET_FIELD(syn_lefthand);
2031 WRITE_BITMAPSET_FIELD(syn_righthand);
2032 WRITE_ENUM_FIELD(jointype, JoinType);
2033 WRITE_BOOL_FIELD(lhs_strict);
2034 WRITE_BOOL_FIELD(delay_upper_joins);
2035 WRITE_BOOL_FIELD(semi_can_btree);
2036 WRITE_BOOL_FIELD(semi_can_hash);
2037 WRITE_NODE_FIELD(semi_operators);
2038 WRITE_NODE_FIELD(semi_rhs_exprs);
2042 _outLateralJoinInfo(StringInfo str, const LateralJoinInfo *node)
2044 WRITE_NODE_TYPE("LATERALJOININFO");
2046 WRITE_BITMAPSET_FIELD(lateral_lhs);
2047 WRITE_BITMAPSET_FIELD(lateral_rhs);
2051 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
2053 WRITE_NODE_TYPE("APPENDRELINFO");
2055 WRITE_UINT_FIELD(parent_relid);
2056 WRITE_UINT_FIELD(child_relid);
2057 WRITE_OID_FIELD(parent_reltype);
2058 WRITE_OID_FIELD(child_reltype);
2059 WRITE_NODE_FIELD(translated_vars);
2060 WRITE_OID_FIELD(parent_reloid);
2064 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
2066 WRITE_NODE_TYPE("PLACEHOLDERINFO");
2068 WRITE_UINT_FIELD(phid);
2069 WRITE_NODE_FIELD(ph_var);
2070 WRITE_BITMAPSET_FIELD(ph_eval_at);
2071 WRITE_BITMAPSET_FIELD(ph_lateral);
2072 WRITE_BITMAPSET_FIELD(ph_needed);
2073 WRITE_INT_FIELD(ph_width);
2077 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
2079 WRITE_NODE_TYPE("MINMAXAGGINFO");
2081 WRITE_OID_FIELD(aggfnoid);
2082 WRITE_OID_FIELD(aggsortop);
2083 WRITE_NODE_FIELD(target);
2084 /* We intentionally omit subroot --- too large, not interesting enough */
2085 WRITE_NODE_FIELD(path);
2086 WRITE_FLOAT_FIELD(pathcost, "%.2f");
2087 WRITE_NODE_FIELD(param);
2091 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
2093 WRITE_NODE_TYPE("PLANNERPARAMITEM");
2095 WRITE_NODE_FIELD(item);
2096 WRITE_INT_FIELD(paramId);
2099 /*****************************************************************************
2101 * Stuff from parsenodes.h.
2103 *****************************************************************************/
2106 * print the basic stuff of all nodes that inherit from CreateStmt
2109 _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
2111 WRITE_NODE_FIELD(relation);
2112 WRITE_NODE_FIELD(tableElts);
2113 WRITE_NODE_FIELD(inhRelations);
2114 WRITE_NODE_FIELD(ofTypename);
2115 WRITE_NODE_FIELD(constraints);
2116 WRITE_NODE_FIELD(options);
2117 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
2118 WRITE_STRING_FIELD(tablespacename);
2119 WRITE_BOOL_FIELD(if_not_exists);
2123 _outCreateStmt(StringInfo str, const CreateStmt *node)
2125 WRITE_NODE_TYPE("CREATESTMT");
2127 _outCreateStmtInfo(str, (const CreateStmt *) node);
2131 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
2133 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
2135 _outCreateStmtInfo(str, (const CreateStmt *) node);
2137 WRITE_STRING_FIELD(servername);
2138 WRITE_NODE_FIELD(options);
2142 _outImportForeignSchemaStmt(StringInfo str, const ImportForeignSchemaStmt *node)
2144 WRITE_NODE_TYPE("IMPORTFOREIGNSCHEMASTMT");
2146 WRITE_STRING_FIELD(server_name);
2147 WRITE_STRING_FIELD(remote_schema);
2148 WRITE_STRING_FIELD(local_schema);
2149 WRITE_ENUM_FIELD(list_type, ImportForeignSchemaType);
2150 WRITE_NODE_FIELD(table_list);
2151 WRITE_NODE_FIELD(options);
2155 _outIndexStmt(StringInfo str, const IndexStmt *node)
2157 WRITE_NODE_TYPE("INDEXSTMT");
2159 WRITE_STRING_FIELD(idxname);
2160 WRITE_NODE_FIELD(relation);
2161 WRITE_STRING_FIELD(accessMethod);
2162 WRITE_STRING_FIELD(tableSpace);
2163 WRITE_NODE_FIELD(indexParams);
2164 WRITE_NODE_FIELD(options);
2165 WRITE_NODE_FIELD(whereClause);
2166 WRITE_NODE_FIELD(excludeOpNames);
2167 WRITE_STRING_FIELD(idxcomment);
2168 WRITE_OID_FIELD(indexOid);
2169 WRITE_OID_FIELD(oldNode);
2170 WRITE_BOOL_FIELD(unique);
2171 WRITE_BOOL_FIELD(primary);
2172 WRITE_BOOL_FIELD(isconstraint);
2173 WRITE_BOOL_FIELD(deferrable);
2174 WRITE_BOOL_FIELD(initdeferred);
2175 WRITE_BOOL_FIELD(transformed);
2176 WRITE_BOOL_FIELD(concurrent);
2177 WRITE_BOOL_FIELD(if_not_exists);
2181 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
2183 WRITE_NODE_TYPE("NOTIFY");
2185 WRITE_STRING_FIELD(conditionname);
2186 WRITE_STRING_FIELD(payload);
2190 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2192 WRITE_NODE_TYPE("DECLARECURSOR");
2194 WRITE_STRING_FIELD(portalname);
2195 WRITE_INT_FIELD(options);
2196 WRITE_NODE_FIELD(query);
2200 _outSelectStmt(StringInfo str, const SelectStmt *node)
2202 WRITE_NODE_TYPE("SELECT");
2204 WRITE_NODE_FIELD(distinctClause);
2205 WRITE_NODE_FIELD(intoClause);
2206 WRITE_NODE_FIELD(targetList);
2207 WRITE_NODE_FIELD(fromClause);
2208 WRITE_NODE_FIELD(whereClause);
2209 WRITE_NODE_FIELD(groupClause);
2210 WRITE_NODE_FIELD(havingClause);
2211 WRITE_NODE_FIELD(windowClause);
2212 WRITE_NODE_FIELD(valuesLists);
2213 WRITE_NODE_FIELD(sortClause);
2214 WRITE_NODE_FIELD(limitOffset);
2215 WRITE_NODE_FIELD(limitCount);
2216 WRITE_NODE_FIELD(lockingClause);
2217 WRITE_NODE_FIELD(withClause);
2218 WRITE_ENUM_FIELD(op, SetOperation);
2219 WRITE_BOOL_FIELD(all);
2220 WRITE_NODE_FIELD(larg);
2221 WRITE_NODE_FIELD(rarg);
2225 _outFuncCall(StringInfo str, const FuncCall *node)
2227 WRITE_NODE_TYPE("FUNCCALL");
2229 WRITE_NODE_FIELD(funcname);
2230 WRITE_NODE_FIELD(args);
2231 WRITE_NODE_FIELD(agg_order);
2232 WRITE_NODE_FIELD(agg_filter);
2233 WRITE_BOOL_FIELD(agg_within_group);
2234 WRITE_BOOL_FIELD(agg_star);
2235 WRITE_BOOL_FIELD(agg_distinct);
2236 WRITE_BOOL_FIELD(func_variadic);
2237 WRITE_NODE_FIELD(over);
2238 WRITE_LOCATION_FIELD(location);
2242 _outDefElem(StringInfo str, const DefElem *node)
2244 WRITE_NODE_TYPE("DEFELEM");
2246 WRITE_STRING_FIELD(defnamespace);
2247 WRITE_STRING_FIELD(defname);
2248 WRITE_NODE_FIELD(arg);
2249 WRITE_ENUM_FIELD(defaction, DefElemAction);
2253 _outTableLikeClause(StringInfo str, const TableLikeClause *node)
2255 WRITE_NODE_TYPE("TABLELIKECLAUSE");
2257 WRITE_NODE_FIELD(relation);
2258 WRITE_UINT_FIELD(options);
2262 _outLockingClause(StringInfo str, const LockingClause *node)
2264 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2266 WRITE_NODE_FIELD(lockedRels);
2267 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2268 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2272 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2274 WRITE_NODE_TYPE("XMLSERIALIZE");
2276 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2277 WRITE_NODE_FIELD(expr);
2278 WRITE_NODE_FIELD(typeName);
2279 WRITE_LOCATION_FIELD(location);
2283 _outColumnDef(StringInfo str, const ColumnDef *node)
2285 WRITE_NODE_TYPE("COLUMNDEF");
2287 WRITE_STRING_FIELD(colname);
2288 WRITE_NODE_FIELD(typeName);
2289 WRITE_INT_FIELD(inhcount);
2290 WRITE_BOOL_FIELD(is_local);
2291 WRITE_BOOL_FIELD(is_not_null);
2292 WRITE_BOOL_FIELD(is_from_type);
2293 WRITE_CHAR_FIELD(storage);
2294 WRITE_NODE_FIELD(raw_default);
2295 WRITE_NODE_FIELD(cooked_default);
2296 WRITE_NODE_FIELD(collClause);
2297 WRITE_OID_FIELD(collOid);
2298 WRITE_NODE_FIELD(constraints);
2299 WRITE_NODE_FIELD(fdwoptions);
2300 WRITE_LOCATION_FIELD(location);
2304 _outTypeName(StringInfo str, const TypeName *node)
2306 WRITE_NODE_TYPE("TYPENAME");
2308 WRITE_NODE_FIELD(names);
2309 WRITE_OID_FIELD(typeOid);
2310 WRITE_BOOL_FIELD(setof);
2311 WRITE_BOOL_FIELD(pct_type);
2312 WRITE_NODE_FIELD(typmods);
2313 WRITE_INT_FIELD(typemod);
2314 WRITE_NODE_FIELD(arrayBounds);
2315 WRITE_LOCATION_FIELD(location);
2319 _outTypeCast(StringInfo str, const TypeCast *node)
2321 WRITE_NODE_TYPE("TYPECAST");
2323 WRITE_NODE_FIELD(arg);
2324 WRITE_NODE_FIELD(typeName);
2325 WRITE_LOCATION_FIELD(location);
2329 _outCollateClause(StringInfo str, const CollateClause *node)
2331 WRITE_NODE_TYPE("COLLATECLAUSE");
2333 WRITE_NODE_FIELD(arg);
2334 WRITE_NODE_FIELD(collname);
2335 WRITE_LOCATION_FIELD(location);
2339 _outIndexElem(StringInfo str, const IndexElem *node)
2341 WRITE_NODE_TYPE("INDEXELEM");
2343 WRITE_STRING_FIELD(name);
2344 WRITE_NODE_FIELD(expr);
2345 WRITE_STRING_FIELD(indexcolname);
2346 WRITE_NODE_FIELD(collation);
2347 WRITE_NODE_FIELD(opclass);
2348 WRITE_ENUM_FIELD(ordering, SortByDir);
2349 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2353 _outQuery(StringInfo str, const Query *node)
2355 WRITE_NODE_TYPE("QUERY");
2357 WRITE_ENUM_FIELD(commandType, CmdType);
2358 WRITE_ENUM_FIELD(querySource, QuerySource);
2359 /* we intentionally do not print the queryId field */
2360 WRITE_BOOL_FIELD(canSetTag);
2363 * Hack to work around missing outfuncs routines for a lot of the
2364 * utility-statement node types. (The only one we actually *need* for
2365 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2366 * for the meantime do this to avoid getting lots of warnings when running
2367 * with debug_print_parse on.
2369 if (node->utilityStmt)
2371 switch (nodeTag(node->utilityStmt))
2376 case T_DeclareCursorStmt:
2377 WRITE_NODE_FIELD(utilityStmt);
2380 appendStringInfoString(str, " :utilityStmt ?");
2385 appendStringInfoString(str, " :utilityStmt <>");
2387 WRITE_INT_FIELD(resultRelation);
2388 WRITE_BOOL_FIELD(hasAggs);
2389 WRITE_BOOL_FIELD(hasWindowFuncs);
2390 WRITE_BOOL_FIELD(hasSubLinks);
2391 WRITE_BOOL_FIELD(hasDistinctOn);
2392 WRITE_BOOL_FIELD(hasRecursive);
2393 WRITE_BOOL_FIELD(hasModifyingCTE);
2394 WRITE_BOOL_FIELD(hasForUpdate);
2395 WRITE_BOOL_FIELD(hasRowSecurity);
2396 WRITE_NODE_FIELD(cteList);
2397 WRITE_NODE_FIELD(rtable);
2398 WRITE_NODE_FIELD(jointree);
2399 WRITE_NODE_FIELD(targetList);
2400 WRITE_NODE_FIELD(withCheckOptions);
2401 WRITE_NODE_FIELD(onConflict);
2402 WRITE_NODE_FIELD(returningList);
2403 WRITE_NODE_FIELD(groupClause);
2404 WRITE_NODE_FIELD(groupingSets);
2405 WRITE_NODE_FIELD(havingQual);
2406 WRITE_NODE_FIELD(windowClause);
2407 WRITE_NODE_FIELD(distinctClause);
2408 WRITE_NODE_FIELD(sortClause);
2409 WRITE_NODE_FIELD(limitOffset);
2410 WRITE_NODE_FIELD(limitCount);
2411 WRITE_NODE_FIELD(rowMarks);
2412 WRITE_NODE_FIELD(setOperations);
2413 WRITE_NODE_FIELD(constraintDeps);
2417 _outWithCheckOption(StringInfo str, const WithCheckOption *node)
2419 WRITE_NODE_TYPE("WITHCHECKOPTION");
2421 WRITE_ENUM_FIELD(kind, WCOKind);
2422 WRITE_STRING_FIELD(relname);
2423 WRITE_STRING_FIELD(polname);
2424 WRITE_NODE_FIELD(qual);
2425 WRITE_BOOL_FIELD(cascaded);
2429 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2431 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2433 WRITE_UINT_FIELD(tleSortGroupRef);
2434 WRITE_OID_FIELD(eqop);
2435 WRITE_OID_FIELD(sortop);
2436 WRITE_BOOL_FIELD(nulls_first);
2437 WRITE_BOOL_FIELD(hashable);
2441 _outGroupingSet(StringInfo str, const GroupingSet *node)
2443 WRITE_NODE_TYPE("GROUPINGSET");
2445 WRITE_ENUM_FIELD(kind, GroupingSetKind);
2446 WRITE_NODE_FIELD(content);
2447 WRITE_LOCATION_FIELD(location);
2451 _outWindowClause(StringInfo str, const WindowClause *node)
2453 WRITE_NODE_TYPE("WINDOWCLAUSE");
2455 WRITE_STRING_FIELD(name);
2456 WRITE_STRING_FIELD(refname);
2457 WRITE_NODE_FIELD(partitionClause);
2458 WRITE_NODE_FIELD(orderClause);
2459 WRITE_INT_FIELD(frameOptions);
2460 WRITE_NODE_FIELD(startOffset);
2461 WRITE_NODE_FIELD(endOffset);
2462 WRITE_UINT_FIELD(winref);
2463 WRITE_BOOL_FIELD(copiedOrder);
2467 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
2469 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2471 WRITE_UINT_FIELD(rti);
2472 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2473 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2474 WRITE_BOOL_FIELD(pushedDown);
2478 _outWithClause(StringInfo str, const WithClause *node)
2480 WRITE_NODE_TYPE("WITHCLAUSE");
2482 WRITE_NODE_FIELD(ctes);
2483 WRITE_BOOL_FIELD(recursive);
2484 WRITE_LOCATION_FIELD(location);
2488 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
2490 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2492 WRITE_STRING_FIELD(ctename);
2493 WRITE_NODE_FIELD(aliascolnames);
2494 WRITE_NODE_FIELD(ctequery);
2495 WRITE_LOCATION_FIELD(location);
2496 WRITE_BOOL_FIELD(cterecursive);
2497 WRITE_INT_FIELD(cterefcount);
2498 WRITE_NODE_FIELD(ctecolnames);
2499 WRITE_NODE_FIELD(ctecoltypes);
2500 WRITE_NODE_FIELD(ctecoltypmods);
2501 WRITE_NODE_FIELD(ctecolcollations);
2505 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
2507 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2509 WRITE_ENUM_FIELD(op, SetOperation);
2510 WRITE_BOOL_FIELD(all);
2511 WRITE_NODE_FIELD(larg);
2512 WRITE_NODE_FIELD(rarg);
2513 WRITE_NODE_FIELD(colTypes);
2514 WRITE_NODE_FIELD(colTypmods);
2515 WRITE_NODE_FIELD(colCollations);
2516 WRITE_NODE_FIELD(groupClauses);
2520 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
2522 WRITE_NODE_TYPE("RTE");
2524 /* put alias + eref first to make dump more legible */
2525 WRITE_NODE_FIELD(alias);
2526 WRITE_NODE_FIELD(eref);
2527 WRITE_ENUM_FIELD(rtekind, RTEKind);
2529 switch (node->rtekind)
2532 WRITE_OID_FIELD(relid);
2533 WRITE_CHAR_FIELD(relkind);
2534 WRITE_NODE_FIELD(tablesample);
2537 WRITE_NODE_FIELD(subquery);
2538 WRITE_BOOL_FIELD(security_barrier);
2541 WRITE_ENUM_FIELD(jointype, JoinType);
2542 WRITE_NODE_FIELD(joinaliasvars);
2545 WRITE_NODE_FIELD(functions);
2546 WRITE_BOOL_FIELD(funcordinality);
2549 WRITE_NODE_FIELD(values_lists);
2550 WRITE_NODE_FIELD(values_collations);
2553 WRITE_STRING_FIELD(ctename);
2554 WRITE_UINT_FIELD(ctelevelsup);
2555 WRITE_BOOL_FIELD(self_reference);
2556 WRITE_NODE_FIELD(ctecoltypes);
2557 WRITE_NODE_FIELD(ctecoltypmods);
2558 WRITE_NODE_FIELD(ctecolcollations);
2561 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2565 WRITE_BOOL_FIELD(lateral);
2566 WRITE_BOOL_FIELD(inh);
2567 WRITE_BOOL_FIELD(inFromCl);
2568 WRITE_UINT_FIELD(requiredPerms);
2569 WRITE_OID_FIELD(checkAsUser);
2570 WRITE_BITMAPSET_FIELD(selectedCols);
2571 WRITE_BITMAPSET_FIELD(insertedCols);
2572 WRITE_BITMAPSET_FIELD(updatedCols);
2573 WRITE_NODE_FIELD(securityQuals);
2577 _outRangeTblFunction(StringInfo str, const RangeTblFunction *node)
2579 WRITE_NODE_TYPE("RANGETBLFUNCTION");
2581 WRITE_NODE_FIELD(funcexpr);
2582 WRITE_INT_FIELD(funccolcount);
2583 WRITE_NODE_FIELD(funccolnames);
2584 WRITE_NODE_FIELD(funccoltypes);
2585 WRITE_NODE_FIELD(funccoltypmods);
2586 WRITE_NODE_FIELD(funccolcollations);
2587 WRITE_BITMAPSET_FIELD(funcparams);
2591 _outTableSampleClause(StringInfo str, const TableSampleClause *node)
2593 WRITE_NODE_TYPE("TABLESAMPLECLAUSE");
2595 WRITE_OID_FIELD(tsmhandler);
2596 WRITE_NODE_FIELD(args);
2597 WRITE_NODE_FIELD(repeatable);
2601 _outAExpr(StringInfo str, const A_Expr *node)
2603 WRITE_NODE_TYPE("AEXPR");
2608 appendStringInfoChar(str, ' ');
2609 WRITE_NODE_FIELD(name);
2612 appendStringInfoChar(str, ' ');
2613 WRITE_NODE_FIELD(name);
2614 appendStringInfoString(str, " ANY ");
2617 appendStringInfoChar(str, ' ');
2618 WRITE_NODE_FIELD(name);
2619 appendStringInfoString(str, " ALL ");
2621 case AEXPR_DISTINCT:
2622 appendStringInfoString(str, " DISTINCT ");
2623 WRITE_NODE_FIELD(name);
2626 appendStringInfoString(str, " NULLIF ");
2627 WRITE_NODE_FIELD(name);
2630 appendStringInfoString(str, " OF ");
2631 WRITE_NODE_FIELD(name);
2634 appendStringInfoString(str, " IN ");
2635 WRITE_NODE_FIELD(name);
2638 appendStringInfoString(str, " LIKE ");
2639 WRITE_NODE_FIELD(name);
2642 appendStringInfoString(str, " ILIKE ");
2643 WRITE_NODE_FIELD(name);
2646 appendStringInfoString(str, " SIMILAR ");
2647 WRITE_NODE_FIELD(name);
2650 appendStringInfoString(str, " BETWEEN ");
2651 WRITE_NODE_FIELD(name);
2653 case AEXPR_NOT_BETWEEN:
2654 appendStringInfoString(str, " NOT_BETWEEN ");
2655 WRITE_NODE_FIELD(name);
2657 case AEXPR_BETWEEN_SYM:
2658 appendStringInfoString(str, " BETWEEN_SYM ");
2659 WRITE_NODE_FIELD(name);
2661 case AEXPR_NOT_BETWEEN_SYM:
2662 appendStringInfoString(str, " NOT_BETWEEN_SYM ");
2663 WRITE_NODE_FIELD(name);
2666 appendStringInfoString(str, " PAREN");
2669 appendStringInfoString(str, " ??");
2673 WRITE_NODE_FIELD(lexpr);
2674 WRITE_NODE_FIELD(rexpr);
2675 WRITE_LOCATION_FIELD(location);
2679 _outValue(StringInfo str, const Value *value)
2681 switch (value->type)
2684 appendStringInfo(str, "%ld", value->val.ival);
2689 * We assume the value is a valid numeric literal and so does not
2692 appendStringInfoString(str, value->val.str);
2697 * We use _outToken to provide escaping of the string's content,
2698 * but we don't want it to do anything with an empty string.
2700 appendStringInfoChar(str, '"');
2701 if (value->val.str[0] != '\0')
2702 _outToken(str, value->val.str);
2703 appendStringInfoChar(str, '"');
2706 /* internal representation already has leading 'b' */
2707 appendStringInfoString(str, value->val.str);
2710 /* this is seen only within A_Const, not in transformed trees */
2711 appendStringInfoString(str, "NULL");
2714 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2720 _outColumnRef(StringInfo str, const ColumnRef *node)
2722 WRITE_NODE_TYPE("COLUMNREF");
2724 WRITE_NODE_FIELD(fields);
2725 WRITE_LOCATION_FIELD(location);
2729 _outParamRef(StringInfo str, const ParamRef *node)
2731 WRITE_NODE_TYPE("PARAMREF");
2733 WRITE_INT_FIELD(number);
2734 WRITE_LOCATION_FIELD(location);
2738 _outAConst(StringInfo str, const A_Const *node)
2740 WRITE_NODE_TYPE("A_CONST");
2742 appendStringInfoString(str, " :val ");
2743 _outValue(str, &(node->val));
2744 WRITE_LOCATION_FIELD(location);
2748 _outA_Star(StringInfo str, const A_Star *node)
2750 WRITE_NODE_TYPE("A_STAR");
2754 _outA_Indices(StringInfo str, const A_Indices *node)
2756 WRITE_NODE_TYPE("A_INDICES");
2758 WRITE_NODE_FIELD(lidx);
2759 WRITE_NODE_FIELD(uidx);
2763 _outA_Indirection(StringInfo str, const A_Indirection *node)
2765 WRITE_NODE_TYPE("A_INDIRECTION");
2767 WRITE_NODE_FIELD(arg);
2768 WRITE_NODE_FIELD(indirection);
2772 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
2774 WRITE_NODE_TYPE("A_ARRAYEXPR");
2776 WRITE_NODE_FIELD(elements);
2777 WRITE_LOCATION_FIELD(location);
2781 _outResTarget(StringInfo str, const ResTarget *node)
2783 WRITE_NODE_TYPE("RESTARGET");
2785 WRITE_STRING_FIELD(name);
2786 WRITE_NODE_FIELD(indirection);
2787 WRITE_NODE_FIELD(val);
2788 WRITE_LOCATION_FIELD(location);
2792 _outMultiAssignRef(StringInfo str, const MultiAssignRef *node)
2794 WRITE_NODE_TYPE("MULTIASSIGNREF");
2796 WRITE_NODE_FIELD(source);
2797 WRITE_INT_FIELD(colno);
2798 WRITE_INT_FIELD(ncolumns);
2802 _outSortBy(StringInfo str, const SortBy *node)
2804 WRITE_NODE_TYPE("SORTBY");
2806 WRITE_NODE_FIELD(node);
2807 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2808 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2809 WRITE_NODE_FIELD(useOp);
2810 WRITE_LOCATION_FIELD(location);
2814 _outWindowDef(StringInfo str, const WindowDef *node)
2816 WRITE_NODE_TYPE("WINDOWDEF");
2818 WRITE_STRING_FIELD(name);
2819 WRITE_STRING_FIELD(refname);
2820 WRITE_NODE_FIELD(partitionClause);
2821 WRITE_NODE_FIELD(orderClause);
2822 WRITE_INT_FIELD(frameOptions);
2823 WRITE_NODE_FIELD(startOffset);
2824 WRITE_NODE_FIELD(endOffset);
2825 WRITE_LOCATION_FIELD(location);
2829 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
2831 WRITE_NODE_TYPE("RANGESUBSELECT");
2833 WRITE_BOOL_FIELD(lateral);
2834 WRITE_NODE_FIELD(subquery);
2835 WRITE_NODE_FIELD(alias);
2839 _outRangeFunction(StringInfo str, const RangeFunction *node)
2841 WRITE_NODE_TYPE("RANGEFUNCTION");
2843 WRITE_BOOL_FIELD(lateral);
2844 WRITE_BOOL_FIELD(ordinality);
2845 WRITE_BOOL_FIELD(is_rowsfrom);
2846 WRITE_NODE_FIELD(functions);
2847 WRITE_NODE_FIELD(alias);
2848 WRITE_NODE_FIELD(coldeflist);
2852 _outRangeTableSample(StringInfo str, const RangeTableSample *node)
2854 WRITE_NODE_TYPE("RANGETABLESAMPLE");
2856 WRITE_NODE_FIELD(relation);
2857 WRITE_NODE_FIELD(method);
2858 WRITE_NODE_FIELD(args);
2859 WRITE_NODE_FIELD(repeatable);
2860 WRITE_LOCATION_FIELD(location);
2864 _outConstraint(StringInfo str, const Constraint *node)
2866 WRITE_NODE_TYPE("CONSTRAINT");
2868 WRITE_STRING_FIELD(conname);
2869 WRITE_BOOL_FIELD(deferrable);
2870 WRITE_BOOL_FIELD(initdeferred);
2871 WRITE_LOCATION_FIELD(location);
2873 appendStringInfoString(str, " :contype ");
2874 switch (node->contype)
2877 appendStringInfoString(str, "NULL");
2880 case CONSTR_NOTNULL:
2881 appendStringInfoString(str, "NOT_NULL");
2884 case CONSTR_DEFAULT:
2885 appendStringInfoString(str, "DEFAULT");
2886 WRITE_NODE_FIELD(raw_expr);
2887 WRITE_STRING_FIELD(cooked_expr);
2891 appendStringInfoString(str, "CHECK");
2892 WRITE_BOOL_FIELD(is_no_inherit);
2893 WRITE_NODE_FIELD(raw_expr);
2894 WRITE_STRING_FIELD(cooked_expr);
2897 case CONSTR_PRIMARY:
2898 appendStringInfoString(str, "PRIMARY_KEY");
2899 WRITE_NODE_FIELD(keys);
2900 WRITE_NODE_FIELD(options);
2901 WRITE_STRING_FIELD(indexname);
2902 WRITE_STRING_FIELD(indexspace);
2903 /* access_method and where_clause not currently used */
2907 appendStringInfoString(str, "UNIQUE");
2908 WRITE_NODE_FIELD(keys);
2909 WRITE_NODE_FIELD(options);
2910 WRITE_STRING_FIELD(indexname);
2911 WRITE_STRING_FIELD(indexspace);
2912 /* access_method and where_clause not currently used */
2915 case CONSTR_EXCLUSION:
2916 appendStringInfoString(str, "EXCLUSION");
2917 WRITE_NODE_FIELD(exclusions);
2918 WRITE_NODE_FIELD(options);
2919 WRITE_STRING_FIELD(indexname);
2920 WRITE_STRING_FIELD(indexspace);
2921 WRITE_STRING_FIELD(access_method);
2922 WRITE_NODE_FIELD(where_clause);
2925 case CONSTR_FOREIGN:
2926 appendStringInfoString(str, "FOREIGN_KEY");
2927 WRITE_NODE_FIELD(pktable);
2928 WRITE_NODE_FIELD(fk_attrs);
2929 WRITE_NODE_FIELD(pk_attrs);
2930 WRITE_CHAR_FIELD(fk_matchtype);
2931 WRITE_CHAR_FIELD(fk_upd_action);
2932 WRITE_CHAR_FIELD(fk_del_action);
2933 WRITE_NODE_FIELD(old_conpfeqop);
2934 WRITE_OID_FIELD(old_pktable_oid);
2935 WRITE_BOOL_FIELD(skip_validation);
2936 WRITE_BOOL_FIELD(initially_valid);
2939 case CONSTR_ATTR_DEFERRABLE:
2940 appendStringInfoString(str, "ATTR_DEFERRABLE");
2943 case CONSTR_ATTR_NOT_DEFERRABLE:
2944 appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
2947 case CONSTR_ATTR_DEFERRED:
2948 appendStringInfoString(str, "ATTR_DEFERRED");
2951 case CONSTR_ATTR_IMMEDIATE:
2952 appendStringInfoString(str, "ATTR_IMMEDIATE");
2956 appendStringInfo(str, "<unrecognized_constraint %d>",
2957 (int) node->contype);
2965 * converts a Node into ascii string and append it to 'str'
2968 _outNode(StringInfo str, const void *obj)
2971 appendStringInfoString(str, "<>");
2972 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2974 else if (IsA(obj, Integer) ||
2977 IsA(obj, BitString))
2979 /* nodeRead does not want to see { } around these! */
2980 _outValue(str, obj);
2984 appendStringInfoChar(str, '{');
2985 switch (nodeTag(obj))
2988 _outPlannedStmt(str, obj);
2994 _outResult(str, obj);
2997 _outModifyTable(str, obj);
3000 _outAppend(str, obj);
3003 _outMergeAppend(str, obj);
3005 case T_RecursiveUnion:
3006 _outRecursiveUnion(str, obj);
3009 _outBitmapAnd(str, obj);
3012 _outBitmapOr(str, obj);
3015 _outGather(str, obj);
3021 _outSeqScan(str, obj);
3024 _outSampleScan(str, obj);
3027 _outIndexScan(str, obj);
3029 case T_IndexOnlyScan:
3030 _outIndexOnlyScan(str, obj);
3032 case T_BitmapIndexScan:
3033 _outBitmapIndexScan(str, obj);
3035 case T_BitmapHeapScan:
3036 _outBitmapHeapScan(str, obj);
3039 _outTidScan(str, obj);
3041 case T_SubqueryScan:
3042 _outSubqueryScan(str, obj);
3044 case T_FunctionScan:
3045 _outFunctionScan(str, obj);
3048 _outValuesScan(str, obj);
3051 _outCteScan(str, obj);
3053 case T_WorkTableScan:
3054 _outWorkTableScan(str, obj);
3057 _outForeignScan(str, obj);
3060 _outCustomScan(str, obj);
3066 _outNestLoop(str, obj);
3069 _outMergeJoin(str, obj);
3072 _outHashJoin(str, obj);
3078 _outWindowAgg(str, obj);
3081 _outGroup(str, obj);
3084 _outMaterial(str, obj);
3090 _outUnique(str, obj);
3096 _outSetOp(str, obj);
3099 _outLockRows(str, obj);
3102 _outLimit(str, obj);
3104 case T_NestLoopParam:
3105 _outNestLoopParam(str, obj);
3108 _outPlanRowMark(str, obj);
3110 case T_PlanInvalItem:
3111 _outPlanInvalItem(str, obj);
3114 _outAlias(str, obj);
3117 _outRangeVar(str, obj);
3120 _outIntoClause(str, obj);
3126 _outConst(str, obj);
3129 _outParam(str, obj);
3132 _outAggref(str, obj);
3134 case T_GroupingFunc:
3135 _outGroupingFunc(str, obj);
3138 _outWindowFunc(str, obj);
3141 _outArrayRef(str, obj);
3144 _outFuncExpr(str, obj);
3146 case T_NamedArgExpr:
3147 _outNamedArgExpr(str, obj);
3150 _outOpExpr(str, obj);
3152 case T_DistinctExpr:
3153 _outDistinctExpr(str, obj);
3156 _outNullIfExpr(str, obj);
3158 case T_ScalarArrayOpExpr:
3159 _outScalarArrayOpExpr(str, obj);
3162 _outBoolExpr(str, obj);
3165 _outSubLink(str, obj);
3168 _outSubPlan(str, obj);
3170 case T_AlternativeSubPlan:
3171 _outAlternativeSubPlan(str, obj);
3174 _outFieldSelect(str, obj);
3177 _outFieldStore(str, obj);
3180 _outRelabelType(str, obj);
3183 _outCoerceViaIO(str, obj);
3185 case T_ArrayCoerceExpr:
3186 _outArrayCoerceExpr(str, obj);
3188 case T_ConvertRowtypeExpr:
3189 _outConvertRowtypeExpr(str, obj);
3192 _outCollateExpr(str, obj);
3195 _outCaseExpr(str, obj);
3198 _outCaseWhen(str, obj);
3200 case T_CaseTestExpr:
3201 _outCaseTestExpr(str, obj);
3204 _outArrayExpr(str, obj);
3207 _outRowExpr(str, obj);
3209 case T_RowCompareExpr:
3210 _outRowCompareExpr(str, obj);
3212 case T_CoalesceExpr:
3213 _outCoalesceExpr(str, obj);
3216 _outMinMaxExpr(str, obj);
3219 _outXmlExpr(str, obj);
3222 _outNullTest(str, obj);
3225 _outBooleanTest(str, obj);
3227 case T_CoerceToDomain:
3228 _outCoerceToDomain(str, obj);
3230 case T_CoerceToDomainValue:
3231 _outCoerceToDomainValue(str, obj);
3233 case T_SetToDefault:
3234 _outSetToDefault(str, obj);
3236 case T_CurrentOfExpr:
3237 _outCurrentOfExpr(str, obj);
3239 case T_InferenceElem:
3240 _outInferenceElem(str, obj);
3243 _outTargetEntry(str, obj);
3246 _outRangeTblRef(str, obj);
3249 _outJoinExpr(str, obj);
3252 _outFromExpr(str, obj);
3254 case T_OnConflictExpr:
3255 _outOnConflictExpr(str, obj);
3261 _outIndexPath(str, obj);
3263 case T_BitmapHeapPath:
3264 _outBitmapHeapPath(str, obj);
3266 case T_BitmapAndPath:
3267 _outBitmapAndPath(str, obj);
3269 case T_BitmapOrPath:
3270 _outBitmapOrPath(str, obj);
3273 _outTidPath(str, obj);
3276 _outForeignPath(str, obj);
3279 _outCustomPath(str, obj);
3282 _outAppendPath(str, obj);
3284 case T_MergeAppendPath:
3285 _outMergeAppendPath(str, obj);
3288 _outResultPath(str, obj);
3290 case T_MaterialPath:
3291 _outMaterialPath(str, obj);
3294 _outUniquePath(str, obj);
3297 _outNestPath(str, obj);
3300 _outMergePath(str, obj);
3303 _outHashPath(str, obj);
3305 case T_PlannerGlobal:
3306 _outPlannerGlobal(str, obj);
3309 _outPlannerInfo(str, obj);
3312 _outRelOptInfo(str, obj);
3314 case T_IndexOptInfo:
3315 _outIndexOptInfo(str, obj);
3317 case T_EquivalenceClass:
3318 _outEquivalenceClass(str, obj);
3320 case T_EquivalenceMember:
3321 _outEquivalenceMember(str, obj);
3324 _outPathKey(str, obj);
3326 case T_ParamPathInfo:
3327 _outParamPathInfo(str, obj);
3329 case T_RestrictInfo:
3330 _outRestrictInfo(str, obj);
3332 case T_PlaceHolderVar:
3333 _outPlaceHolderVar(str, obj);
3335 case T_SpecialJoinInfo:
3336 _outSpecialJoinInfo(str, obj);
3338 case T_LateralJoinInfo:
3339 _outLateralJoinInfo(str, obj);
3341 case T_AppendRelInfo:
3342 _outAppendRelInfo(str, obj);
3344 case T_PlaceHolderInfo:
3345 _outPlaceHolderInfo(str, obj);
3347 case T_MinMaxAggInfo:
3348 _outMinMaxAggInfo(str, obj);
3350 case T_PlannerParamItem:
3351 _outPlannerParamItem(str, obj);
3355 _outCreateStmt(str, obj);
3357 case T_CreateForeignTableStmt:
3358 _outCreateForeignTableStmt(str, obj);
3360 case T_ImportForeignSchemaStmt:
3361 _outImportForeignSchemaStmt(str, obj);
3364 _outIndexStmt(str, obj);
3367 _outNotifyStmt(str, obj);
3369 case T_DeclareCursorStmt:
3370 _outDeclareCursorStmt(str, obj);
3373 _outSelectStmt(str, obj);
3376 _outColumnDef(str, obj);
3379 _outTypeName(str, obj);
3382 _outTypeCast(str, obj);
3384 case T_CollateClause:
3385 _outCollateClause(str, obj);
3388 _outIndexElem(str, obj);
3391 _outQuery(str, obj);
3393 case T_WithCheckOption:
3394 _outWithCheckOption(str, obj);
3396 case T_SortGroupClause:
3397 _outSortGroupClause(str, obj);
3400 _outGroupingSet(str, obj);
3402 case T_WindowClause:
3403 _outWindowClause(str, obj);
3405 case T_RowMarkClause:
3406 _outRowMarkClause(str, obj);
3409 _outWithClause(str, obj);
3411 case T_CommonTableExpr:
3412 _outCommonTableExpr(str, obj);
3414 case T_SetOperationStmt:
3415 _outSetOperationStmt(str, obj);
3417 case T_RangeTblEntry:
3418 _outRangeTblEntry(str, obj);
3420 case T_RangeTblFunction:
3421 _outRangeTblFunction(str, obj);
3423 case T_TableSampleClause:
3424 _outTableSampleClause(str, obj);
3427 _outAExpr(str, obj);
3430 _outColumnRef(str, obj);
3433 _outParamRef(str, obj);
3436 _outAConst(str, obj);
3439 _outA_Star(str, obj);
3442 _outA_Indices(str, obj);
3444 case T_A_Indirection:
3445 _outA_Indirection(str, obj);
3448 _outA_ArrayExpr(str, obj);
3451 _outResTarget(str, obj);
3453 case T_MultiAssignRef:
3454 _outMultiAssignRef(str, obj);
3457 _outSortBy(str, obj);
3460 _outWindowDef(str, obj);
3462 case T_RangeSubselect:
3463 _outRangeSubselect(str, obj);
3465 case T_RangeFunction:
3466 _outRangeFunction(str, obj);
3468 case T_RangeTableSample:
3469 _outRangeTableSample(str, obj);
3472 _outConstraint(str, obj);
3475 _outFuncCall(str, obj);
3478 _outDefElem(str, obj);
3480 case T_TableLikeClause:
3481 _outTableLikeClause(str, obj);
3483 case T_LockingClause:
3484 _outLockingClause(str, obj);
3486 case T_XmlSerialize:
3487 _outXmlSerialize(str, obj);
3493 * This should be an ERROR, but it's too useful to be able to
3494 * dump structures that _outNode only understands part of.
3496 elog(WARNING, "could not dump unrecognized node type: %d",
3497 (int) nodeTag(obj));
3500 appendStringInfoChar(str, '}');
3506 * returns the ascii representation of the Node as a palloc'd string
3509 nodeToString(const void *obj)
3513 /* see stringinfo.h for an explanation of this maneuver */
3514 initStringInfo(&str);
3515 _outNode(&str, obj);