1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2011, 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, 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, char *s)
112 if (s == NULL || *s == '\0')
114 appendStringInfo(str, "<>");
119 * Look for characters or patterns that are treated specially by read.c
120 * (either in pg_strtok() or in nodeRead()), and therefore need a
121 * protective backslash.
123 /* These characters only need to be quoted at the start of the string */
126 isdigit((unsigned char) *s) ||
127 ((*s == '+' || *s == '-') &&
128 (isdigit((unsigned char) s[1]) || s[1] == '.')))
129 appendStringInfoChar(str, '\\');
132 /* These chars must be backslashed anywhere in the string */
133 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
136 appendStringInfoChar(str, '\\');
137 appendStringInfoChar(str, *s++);
142 _outList(StringInfo str, 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, Bitmapset *bms)
190 appendStringInfoChar(str, '(');
191 appendStringInfoChar(str, 'b');
192 tmpset = bms_copy(bms);
193 while ((x = bms_first_member(tmpset)) >= 0)
194 appendStringInfo(str, " %d", x);
196 appendStringInfoChar(str, ')');
200 * Print the value of a Datum given its type.
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
209 length = datumGetSize(value, typbyval, typlen);
213 s = (char *) (&value);
214 appendStringInfo(str, "%u [ ", (unsigned int) length);
215 for (i = 0; i < (Size) sizeof(Datum); i++)
216 appendStringInfo(str, "%d ", (int) (s[i]));
217 appendStringInfo(str, "]");
221 s = (char *) DatumGetPointer(value);
222 if (!PointerIsValid(s))
223 appendStringInfo(str, "0 [ ]");
226 appendStringInfo(str, "%u [ ", (unsigned int) length);
227 for (i = 0; i < length; i++)
228 appendStringInfo(str, "%d ", (int) (s[i]));
229 appendStringInfo(str, "]");
236 * Stuff from plannodes.h
240 _outPlannedStmt(StringInfo str, PlannedStmt *node)
242 WRITE_NODE_TYPE("PLANNEDSTMT");
244 WRITE_ENUM_FIELD(commandType, CmdType);
245 WRITE_BOOL_FIELD(hasReturning);
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(intoClause);
253 WRITE_NODE_FIELD(subplans);
254 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
255 WRITE_NODE_FIELD(rowMarks);
256 WRITE_NODE_FIELD(relationOids);
257 WRITE_NODE_FIELD(invalItems);
258 WRITE_INT_FIELD(nParamExec);
262 * print the basic stuff of all nodes that inherit from Plan
265 _outPlanInfo(StringInfo str, 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, Scan *node)
286 _outPlanInfo(str, (Plan *) node);
288 WRITE_UINT_FIELD(scanrelid);
292 * print the basic stuff of all nodes that inherit from Join
295 _outJoinPlanInfo(StringInfo str, Join *node)
297 _outPlanInfo(str, (Plan *) node);
299 WRITE_ENUM_FIELD(jointype, JoinType);
300 WRITE_NODE_FIELD(joinqual);
305 _outPlan(StringInfo str, Plan *node)
307 WRITE_NODE_TYPE("PLAN");
309 _outPlanInfo(str, (Plan *) node);
313 _outResult(StringInfo str, Result *node)
315 WRITE_NODE_TYPE("RESULT");
317 _outPlanInfo(str, (Plan *) node);
319 WRITE_NODE_FIELD(resconstantqual);
323 _outModifyTable(StringInfo str, ModifyTable *node)
325 WRITE_NODE_TYPE("MODIFYTABLE");
327 _outPlanInfo(str, (Plan *) node);
329 WRITE_ENUM_FIELD(operation, CmdType);
330 WRITE_NODE_FIELD(resultRelations);
331 WRITE_NODE_FIELD(plans);
332 WRITE_NODE_FIELD(returningLists);
333 WRITE_NODE_FIELD(rowMarks);
334 WRITE_INT_FIELD(epqParam);
338 _outAppend(StringInfo str, Append *node)
340 WRITE_NODE_TYPE("APPEND");
342 _outPlanInfo(str, (Plan *) node);
344 WRITE_NODE_FIELD(appendplans);
348 _outMergeAppend(StringInfo str, MergeAppend *node)
352 WRITE_NODE_TYPE("MERGEAPPEND");
354 _outPlanInfo(str, (Plan *) node);
356 WRITE_NODE_FIELD(mergeplans);
358 WRITE_INT_FIELD(numCols);
360 appendStringInfo(str, " :sortColIdx");
361 for (i = 0; i < node->numCols; i++)
362 appendStringInfo(str, " %d", node->sortColIdx[i]);
364 appendStringInfo(str, " :sortOperators");
365 for (i = 0; i < node->numCols; i++)
366 appendStringInfo(str, " %u", node->sortOperators[i]);
368 appendStringInfo(str, " :collations");
369 for (i = 0; i < node->numCols; i++)
370 appendStringInfo(str, " %u", node->collations[i]);
372 appendStringInfo(str, " :nullsFirst");
373 for (i = 0; i < node->numCols; i++)
374 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
378 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
382 WRITE_NODE_TYPE("RECURSIVEUNION");
384 _outPlanInfo(str, (Plan *) node);
386 WRITE_INT_FIELD(wtParam);
387 WRITE_INT_FIELD(numCols);
389 appendStringInfo(str, " :dupColIdx");
390 for (i = 0; i < node->numCols; i++)
391 appendStringInfo(str, " %d", node->dupColIdx[i]);
393 appendStringInfo(str, " :dupOperators");
394 for (i = 0; i < node->numCols; i++)
395 appendStringInfo(str, " %u", node->dupOperators[i]);
397 WRITE_LONG_FIELD(numGroups);
401 _outBitmapAnd(StringInfo str, BitmapAnd *node)
403 WRITE_NODE_TYPE("BITMAPAND");
405 _outPlanInfo(str, (Plan *) node);
407 WRITE_NODE_FIELD(bitmapplans);
411 _outBitmapOr(StringInfo str, BitmapOr *node)
413 WRITE_NODE_TYPE("BITMAPOR");
415 _outPlanInfo(str, (Plan *) node);
417 WRITE_NODE_FIELD(bitmapplans);
421 _outScan(StringInfo str, Scan *node)
423 WRITE_NODE_TYPE("SCAN");
425 _outScanInfo(str, (Scan *) node);
429 _outSeqScan(StringInfo str, SeqScan *node)
431 WRITE_NODE_TYPE("SEQSCAN");
433 _outScanInfo(str, (Scan *) node);
437 _outIndexScan(StringInfo str, IndexScan *node)
439 WRITE_NODE_TYPE("INDEXSCAN");
441 _outScanInfo(str, (Scan *) node);
443 WRITE_OID_FIELD(indexid);
444 WRITE_NODE_FIELD(indexqual);
445 WRITE_NODE_FIELD(indexqualorig);
446 WRITE_NODE_FIELD(indexorderby);
447 WRITE_NODE_FIELD(indexorderbyorig);
448 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
452 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
454 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
456 _outScanInfo(str, (Scan *) node);
458 WRITE_OID_FIELD(indexid);
459 WRITE_NODE_FIELD(indexqual);
460 WRITE_NODE_FIELD(indexqualorig);
464 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
466 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
468 _outScanInfo(str, (Scan *) node);
470 WRITE_NODE_FIELD(bitmapqualorig);
474 _outTidScan(StringInfo str, TidScan *node)
476 WRITE_NODE_TYPE("TIDSCAN");
478 _outScanInfo(str, (Scan *) node);
480 WRITE_NODE_FIELD(tidquals);
484 _outSubqueryScan(StringInfo str, SubqueryScan *node)
486 WRITE_NODE_TYPE("SUBQUERYSCAN");
488 _outScanInfo(str, (Scan *) node);
490 WRITE_NODE_FIELD(subplan);
491 WRITE_NODE_FIELD(subrtable);
492 WRITE_NODE_FIELD(subrowmark);
496 _outFunctionScan(StringInfo str, FunctionScan *node)
498 WRITE_NODE_TYPE("FUNCTIONSCAN");
500 _outScanInfo(str, (Scan *) node);
502 WRITE_NODE_FIELD(funcexpr);
503 WRITE_NODE_FIELD(funccolnames);
504 WRITE_NODE_FIELD(funccoltypes);
505 WRITE_NODE_FIELD(funccoltypmods);
506 WRITE_NODE_FIELD(funccolcollations);
510 _outValuesScan(StringInfo str, ValuesScan *node)
512 WRITE_NODE_TYPE("VALUESSCAN");
514 _outScanInfo(str, (Scan *) node);
516 WRITE_NODE_FIELD(values_lists);
520 _outCteScan(StringInfo str, CteScan *node)
522 WRITE_NODE_TYPE("CTESCAN");
524 _outScanInfo(str, (Scan *) node);
526 WRITE_INT_FIELD(ctePlanId);
527 WRITE_INT_FIELD(cteParam);
531 _outWorkTableScan(StringInfo str, WorkTableScan *node)
533 WRITE_NODE_TYPE("WORKTABLESCAN");
535 _outScanInfo(str, (Scan *) node);
537 WRITE_INT_FIELD(wtParam);
541 _outJoin(StringInfo str, Join *node)
543 WRITE_NODE_TYPE("JOIN");
545 _outJoinPlanInfo(str, (Join *) node);
549 _outNestLoop(StringInfo str, NestLoop *node)
551 WRITE_NODE_TYPE("NESTLOOP");
553 _outJoinPlanInfo(str, (Join *) node);
555 WRITE_NODE_FIELD(nestParams);
559 _outMergeJoin(StringInfo str, MergeJoin *node)
564 WRITE_NODE_TYPE("MERGEJOIN");
566 _outJoinPlanInfo(str, (Join *) node);
568 WRITE_NODE_FIELD(mergeclauses);
570 numCols = list_length(node->mergeclauses);
572 appendStringInfo(str, " :mergeFamilies");
573 for (i = 0; i < numCols; i++)
574 appendStringInfo(str, " %u", node->mergeFamilies[i]);
576 appendStringInfo(str, " :mergeCollations");
577 for (i = 0; i < numCols; i++)
578 appendStringInfo(str, " %u", node->mergeCollations[i]);
580 appendStringInfo(str, " :mergeStrategies");
581 for (i = 0; i < numCols; i++)
582 appendStringInfo(str, " %d", node->mergeStrategies[i]);
584 appendStringInfo(str, " :mergeNullsFirst");
585 for (i = 0; i < numCols; i++)
586 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
590 _outHashJoin(StringInfo str, HashJoin *node)
592 WRITE_NODE_TYPE("HASHJOIN");
594 _outJoinPlanInfo(str, (Join *) node);
596 WRITE_NODE_FIELD(hashclauses);
600 _outAgg(StringInfo str, Agg *node)
604 WRITE_NODE_TYPE("AGG");
606 _outPlanInfo(str, (Plan *) node);
608 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
609 WRITE_INT_FIELD(numCols);
611 appendStringInfo(str, " :grpColIdx");
612 for (i = 0; i < node->numCols; i++)
613 appendStringInfo(str, " %d", node->grpColIdx[i]);
615 appendStringInfo(str, " :grpOperators");
616 for (i = 0; i < node->numCols; i++)
617 appendStringInfo(str, " %u", node->grpOperators[i]);
619 WRITE_LONG_FIELD(numGroups);
623 _outWindowAgg(StringInfo str, WindowAgg *node)
627 WRITE_NODE_TYPE("WINDOWAGG");
629 _outPlanInfo(str, (Plan *) node);
631 WRITE_UINT_FIELD(winref);
632 WRITE_INT_FIELD(partNumCols);
634 appendStringInfo(str, " :partColIdx");
635 for (i = 0; i < node->partNumCols; i++)
636 appendStringInfo(str, " %d", node->partColIdx[i]);
638 appendStringInfo(str, " :partOperations");
639 for (i = 0; i < node->partNumCols; i++)
640 appendStringInfo(str, " %u", node->partOperators[i]);
642 WRITE_INT_FIELD(ordNumCols);
644 appendStringInfo(str, " :ordColIdx");
645 for (i = 0; i < node->ordNumCols; i++)
646 appendStringInfo(str, " %d", node->ordColIdx[i]);
648 appendStringInfo(str, " :ordOperations");
649 for (i = 0; i < node->ordNumCols; i++)
650 appendStringInfo(str, " %u", node->ordOperators[i]);
652 WRITE_INT_FIELD(frameOptions);
653 WRITE_NODE_FIELD(startOffset);
654 WRITE_NODE_FIELD(endOffset);
658 _outGroup(StringInfo str, Group *node)
662 WRITE_NODE_TYPE("GROUP");
664 _outPlanInfo(str, (Plan *) node);
666 WRITE_INT_FIELD(numCols);
668 appendStringInfo(str, " :grpColIdx");
669 for (i = 0; i < node->numCols; i++)
670 appendStringInfo(str, " %d", node->grpColIdx[i]);
672 appendStringInfo(str, " :grpOperators");
673 for (i = 0; i < node->numCols; i++)
674 appendStringInfo(str, " %u", node->grpOperators[i]);
678 _outMaterial(StringInfo str, Material *node)
680 WRITE_NODE_TYPE("MATERIAL");
682 _outPlanInfo(str, (Plan *) node);
686 _outSort(StringInfo str, Sort *node)
690 WRITE_NODE_TYPE("SORT");
692 _outPlanInfo(str, (Plan *) node);
694 WRITE_INT_FIELD(numCols);
696 appendStringInfo(str, " :sortColIdx");
697 for (i = 0; i < node->numCols; i++)
698 appendStringInfo(str, " %d", node->sortColIdx[i]);
700 appendStringInfo(str, " :sortOperators");
701 for (i = 0; i < node->numCols; i++)
702 appendStringInfo(str, " %u", node->sortOperators[i]);
704 appendStringInfo(str, " :collations");
705 for (i = 0; i < node->numCols; i++)
706 appendStringInfo(str, " %u", node->collations[i]);
708 appendStringInfo(str, " :nullsFirst");
709 for (i = 0; i < node->numCols; i++)
710 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
714 _outUnique(StringInfo str, Unique *node)
718 WRITE_NODE_TYPE("UNIQUE");
720 _outPlanInfo(str, (Plan *) node);
722 WRITE_INT_FIELD(numCols);
724 appendStringInfo(str, " :uniqColIdx");
725 for (i = 0; i < node->numCols; i++)
726 appendStringInfo(str, " %d", node->uniqColIdx[i]);
728 appendStringInfo(str, " :uniqOperators");
729 for (i = 0; i < node->numCols; i++)
730 appendStringInfo(str, " %u", node->uniqOperators[i]);
734 _outHash(StringInfo str, Hash *node)
736 WRITE_NODE_TYPE("HASH");
738 _outPlanInfo(str, (Plan *) node);
740 WRITE_OID_FIELD(skewTable);
741 WRITE_INT_FIELD(skewColumn);
742 WRITE_BOOL_FIELD(skewInherit);
743 WRITE_OID_FIELD(skewColType);
744 WRITE_INT_FIELD(skewColTypmod);
748 _outSetOp(StringInfo str, SetOp *node)
752 WRITE_NODE_TYPE("SETOP");
754 _outPlanInfo(str, (Plan *) node);
756 WRITE_ENUM_FIELD(cmd, SetOpCmd);
757 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
758 WRITE_INT_FIELD(numCols);
760 appendStringInfo(str, " :dupColIdx");
761 for (i = 0; i < node->numCols; i++)
762 appendStringInfo(str, " %d", node->dupColIdx[i]);
764 appendStringInfo(str, " :dupOperators");
765 for (i = 0; i < node->numCols; i++)
766 appendStringInfo(str, " %u", node->dupOperators[i]);
768 WRITE_INT_FIELD(flagColIdx);
769 WRITE_INT_FIELD(firstFlag);
770 WRITE_LONG_FIELD(numGroups);
774 _outLockRows(StringInfo str, LockRows *node)
776 WRITE_NODE_TYPE("LOCKROWS");
778 _outPlanInfo(str, (Plan *) node);
780 WRITE_NODE_FIELD(rowMarks);
781 WRITE_INT_FIELD(epqParam);
785 _outLimit(StringInfo str, Limit *node)
787 WRITE_NODE_TYPE("LIMIT");
789 _outPlanInfo(str, (Plan *) node);
791 WRITE_NODE_FIELD(limitOffset);
792 WRITE_NODE_FIELD(limitCount);
796 _outNestLoopParam(StringInfo str, NestLoopParam *node)
798 WRITE_NODE_TYPE("NESTLOOPPARAM");
800 WRITE_INT_FIELD(paramno);
801 WRITE_NODE_FIELD(paramval);
805 _outPlanRowMark(StringInfo str, PlanRowMark *node)
807 WRITE_NODE_TYPE("PLANROWMARK");
809 WRITE_UINT_FIELD(rti);
810 WRITE_UINT_FIELD(prti);
811 WRITE_ENUM_FIELD(markType, RowMarkType);
812 WRITE_BOOL_FIELD(noWait);
813 WRITE_BOOL_FIELD(isParent);
817 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
819 WRITE_NODE_TYPE("PLANINVALITEM");
821 WRITE_INT_FIELD(cacheId);
822 appendStringInfo(str, " :tupleId (%u,%u)",
823 ItemPointerGetBlockNumber(&node->tupleId),
824 ItemPointerGetOffsetNumber(&node->tupleId));
827 /*****************************************************************************
829 * Stuff from primnodes.h.
831 *****************************************************************************/
834 _outAlias(StringInfo str, Alias *node)
836 WRITE_NODE_TYPE("ALIAS");
838 WRITE_STRING_FIELD(aliasname);
839 WRITE_NODE_FIELD(colnames);
843 _outRangeVar(StringInfo str, RangeVar *node)
845 WRITE_NODE_TYPE("RANGEVAR");
848 * we deliberately ignore catalogname here, since it is presently not
849 * semantically meaningful
851 WRITE_STRING_FIELD(schemaname);
852 WRITE_STRING_FIELD(relname);
853 WRITE_ENUM_FIELD(inhOpt, InhOption);
854 WRITE_CHAR_FIELD(relpersistence);
855 WRITE_NODE_FIELD(alias);
856 WRITE_LOCATION_FIELD(location);
860 _outIntoClause(StringInfo str, IntoClause *node)
862 WRITE_NODE_TYPE("INTOCLAUSE");
864 WRITE_NODE_FIELD(rel);
865 WRITE_NODE_FIELD(colNames);
866 WRITE_NODE_FIELD(options);
867 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
868 WRITE_STRING_FIELD(tableSpaceName);
872 _outVar(StringInfo str, Var *node)
874 WRITE_NODE_TYPE("VAR");
876 WRITE_UINT_FIELD(varno);
877 WRITE_INT_FIELD(varattno);
878 WRITE_OID_FIELD(vartype);
879 WRITE_INT_FIELD(vartypmod);
880 WRITE_OID_FIELD(varcollid);
881 WRITE_UINT_FIELD(varlevelsup);
882 WRITE_UINT_FIELD(varnoold);
883 WRITE_INT_FIELD(varoattno);
884 WRITE_LOCATION_FIELD(location);
888 _outConst(StringInfo str, Const *node)
890 WRITE_NODE_TYPE("CONST");
892 WRITE_OID_FIELD(consttype);
893 WRITE_INT_FIELD(consttypmod);
894 WRITE_OID_FIELD(constcollid);
895 WRITE_INT_FIELD(constlen);
896 WRITE_BOOL_FIELD(constbyval);
897 WRITE_BOOL_FIELD(constisnull);
898 WRITE_LOCATION_FIELD(location);
900 appendStringInfo(str, " :constvalue ");
901 if (node->constisnull)
902 appendStringInfo(str, "<>");
904 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
908 _outParam(StringInfo str, Param *node)
910 WRITE_NODE_TYPE("PARAM");
912 WRITE_ENUM_FIELD(paramkind, ParamKind);
913 WRITE_INT_FIELD(paramid);
914 WRITE_OID_FIELD(paramtype);
915 WRITE_INT_FIELD(paramtypmod);
916 WRITE_OID_FIELD(paramcollation);
917 WRITE_LOCATION_FIELD(location);
921 _outAggref(StringInfo str, Aggref *node)
923 WRITE_NODE_TYPE("AGGREF");
925 WRITE_OID_FIELD(aggfnoid);
926 WRITE_OID_FIELD(aggtype);
927 WRITE_NODE_FIELD(args);
928 WRITE_NODE_FIELD(aggorder);
929 WRITE_NODE_FIELD(aggdistinct);
930 WRITE_BOOL_FIELD(aggstar);
931 WRITE_UINT_FIELD(agglevelsup);
932 WRITE_OID_FIELD(collid);
933 WRITE_LOCATION_FIELD(location);
937 _outWindowFunc(StringInfo str, WindowFunc *node)
939 WRITE_NODE_TYPE("WINDOWFUNC");
941 WRITE_OID_FIELD(winfnoid);
942 WRITE_OID_FIELD(wintype);
943 WRITE_NODE_FIELD(args);
944 WRITE_UINT_FIELD(winref);
945 WRITE_BOOL_FIELD(winstar);
946 WRITE_BOOL_FIELD(winagg);
947 WRITE_OID_FIELD(collid);
948 WRITE_LOCATION_FIELD(location);
952 _outArrayRef(StringInfo str, ArrayRef *node)
954 WRITE_NODE_TYPE("ARRAYREF");
956 WRITE_OID_FIELD(refarraytype);
957 WRITE_OID_FIELD(refelemtype);
958 WRITE_INT_FIELD(reftypmod);
959 WRITE_INT_FIELD(refcollid);
960 WRITE_NODE_FIELD(refupperindexpr);
961 WRITE_NODE_FIELD(reflowerindexpr);
962 WRITE_NODE_FIELD(refexpr);
963 WRITE_NODE_FIELD(refassgnexpr);
967 _outFuncExpr(StringInfo str, FuncExpr *node)
969 WRITE_NODE_TYPE("FUNCEXPR");
971 WRITE_OID_FIELD(funcid);
972 WRITE_OID_FIELD(funcresulttype);
973 WRITE_BOOL_FIELD(funcretset);
974 WRITE_ENUM_FIELD(funcformat, CoercionForm);
975 WRITE_NODE_FIELD(args);
976 WRITE_OID_FIELD(collid);
977 WRITE_LOCATION_FIELD(location);
981 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
983 WRITE_NODE_TYPE("NAMEDARGEXPR");
985 WRITE_NODE_FIELD(arg);
986 WRITE_STRING_FIELD(name);
987 WRITE_INT_FIELD(argnumber);
988 WRITE_LOCATION_FIELD(location);
992 _outOpExpr(StringInfo str, OpExpr *node)
994 WRITE_NODE_TYPE("OPEXPR");
996 WRITE_OID_FIELD(opno);
997 WRITE_OID_FIELD(opfuncid);
998 WRITE_OID_FIELD(opresulttype);
999 WRITE_BOOL_FIELD(opretset);
1000 WRITE_NODE_FIELD(args);
1001 WRITE_OID_FIELD(collid);
1002 WRITE_LOCATION_FIELD(location);
1006 _outDistinctExpr(StringInfo str, DistinctExpr *node)
1008 WRITE_NODE_TYPE("DISTINCTEXPR");
1010 WRITE_OID_FIELD(opno);
1011 WRITE_OID_FIELD(opfuncid);
1012 WRITE_OID_FIELD(opresulttype);
1013 WRITE_BOOL_FIELD(opretset);
1014 WRITE_NODE_FIELD(args);
1015 WRITE_OID_FIELD(collid);
1016 WRITE_LOCATION_FIELD(location);
1020 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
1022 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1024 WRITE_OID_FIELD(opno);
1025 WRITE_OID_FIELD(opfuncid);
1026 WRITE_BOOL_FIELD(useOr);
1027 WRITE_NODE_FIELD(args);
1028 WRITE_OID_FIELD(collid);
1029 WRITE_LOCATION_FIELD(location);
1033 _outBoolExpr(StringInfo str, BoolExpr *node)
1037 WRITE_NODE_TYPE("BOOLEXPR");
1039 /* do-it-yourself enum representation */
1040 switch (node->boolop)
1052 appendStringInfo(str, " :boolop ");
1053 _outToken(str, opstr);
1055 WRITE_NODE_FIELD(args);
1056 WRITE_LOCATION_FIELD(location);
1060 _outSubLink(StringInfo str, SubLink *node)
1062 WRITE_NODE_TYPE("SUBLINK");
1064 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1065 WRITE_NODE_FIELD(testexpr);
1066 WRITE_NODE_FIELD(operName);
1067 WRITE_NODE_FIELD(subselect);
1068 WRITE_LOCATION_FIELD(location);
1072 _outSubPlan(StringInfo str, SubPlan *node)
1074 WRITE_NODE_TYPE("SUBPLAN");
1076 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1077 WRITE_NODE_FIELD(testexpr);
1078 WRITE_NODE_FIELD(paramIds);
1079 WRITE_INT_FIELD(plan_id);
1080 WRITE_STRING_FIELD(plan_name);
1081 WRITE_OID_FIELD(firstColType);
1082 WRITE_INT_FIELD(firstColTypmod);
1083 WRITE_OID_FIELD(firstColCollation);
1084 WRITE_BOOL_FIELD(useHashTable);
1085 WRITE_BOOL_FIELD(unknownEqFalse);
1086 WRITE_NODE_FIELD(setParam);
1087 WRITE_NODE_FIELD(parParam);
1088 WRITE_NODE_FIELD(args);
1089 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1090 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1094 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1096 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1098 WRITE_NODE_FIELD(subplans);
1102 _outFieldSelect(StringInfo str, FieldSelect *node)
1104 WRITE_NODE_TYPE("FIELDSELECT");
1106 WRITE_NODE_FIELD(arg);
1107 WRITE_INT_FIELD(fieldnum);
1108 WRITE_OID_FIELD(resulttype);
1109 WRITE_INT_FIELD(resulttypmod);
1110 WRITE_OID_FIELD(resultcollation);
1114 _outFieldStore(StringInfo str, FieldStore *node)
1116 WRITE_NODE_TYPE("FIELDSTORE");
1118 WRITE_NODE_FIELD(arg);
1119 WRITE_NODE_FIELD(newvals);
1120 WRITE_NODE_FIELD(fieldnums);
1121 WRITE_OID_FIELD(resulttype);
1125 _outRelabelType(StringInfo str, RelabelType *node)
1127 WRITE_NODE_TYPE("RELABELTYPE");
1129 WRITE_NODE_FIELD(arg);
1130 WRITE_OID_FIELD(resulttype);
1131 WRITE_INT_FIELD(resulttypmod);
1132 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1133 WRITE_LOCATION_FIELD(location);
1137 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1139 WRITE_NODE_TYPE("COERCEVIAIO");
1141 WRITE_NODE_FIELD(arg);
1142 WRITE_OID_FIELD(resulttype);
1143 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1144 WRITE_LOCATION_FIELD(location);
1148 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1150 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1152 WRITE_NODE_FIELD(arg);
1153 WRITE_OID_FIELD(elemfuncid);
1154 WRITE_OID_FIELD(resulttype);
1155 WRITE_INT_FIELD(resulttypmod);
1156 WRITE_BOOL_FIELD(isExplicit);
1157 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1158 WRITE_LOCATION_FIELD(location);
1162 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1164 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1166 WRITE_NODE_FIELD(arg);
1167 WRITE_OID_FIELD(resulttype);
1168 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1169 WRITE_LOCATION_FIELD(location);
1173 _outCaseExpr(StringInfo str, CaseExpr *node)
1175 WRITE_NODE_TYPE("CASE");
1177 WRITE_OID_FIELD(casetype);
1178 WRITE_OID_FIELD(casecollation);
1179 WRITE_NODE_FIELD(arg);
1180 WRITE_NODE_FIELD(args);
1181 WRITE_NODE_FIELD(defresult);
1182 WRITE_LOCATION_FIELD(location);
1186 _outCaseWhen(StringInfo str, CaseWhen *node)
1188 WRITE_NODE_TYPE("WHEN");
1190 WRITE_NODE_FIELD(expr);
1191 WRITE_NODE_FIELD(result);
1192 WRITE_LOCATION_FIELD(location);
1196 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1198 WRITE_NODE_TYPE("CASETESTEXPR");
1200 WRITE_OID_FIELD(typeId);
1201 WRITE_INT_FIELD(typeMod);
1202 WRITE_OID_FIELD(collation);
1206 _outArrayExpr(StringInfo str, ArrayExpr *node)
1208 WRITE_NODE_TYPE("ARRAY");
1210 WRITE_OID_FIELD(array_typeid);
1211 WRITE_OID_FIELD(element_typeid);
1212 WRITE_NODE_FIELD(elements);
1213 WRITE_BOOL_FIELD(multidims);
1214 WRITE_LOCATION_FIELD(location);
1218 _outRowExpr(StringInfo str, RowExpr *node)
1220 WRITE_NODE_TYPE("ROW");
1222 WRITE_NODE_FIELD(args);
1223 WRITE_OID_FIELD(row_typeid);
1224 WRITE_ENUM_FIELD(row_format, CoercionForm);
1225 WRITE_NODE_FIELD(colnames);
1226 WRITE_LOCATION_FIELD(location);
1230 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1232 WRITE_NODE_TYPE("ROWCOMPARE");
1234 WRITE_ENUM_FIELD(rctype, RowCompareType);
1235 WRITE_NODE_FIELD(opnos);
1236 WRITE_NODE_FIELD(opfamilies);
1237 WRITE_NODE_FIELD(collids);
1238 WRITE_NODE_FIELD(largs);
1239 WRITE_NODE_FIELD(rargs);
1243 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1245 WRITE_NODE_TYPE("COALESCE");
1247 WRITE_OID_FIELD(coalescetype);
1248 WRITE_OID_FIELD(coalescecollation);
1249 WRITE_NODE_FIELD(args);
1250 WRITE_LOCATION_FIELD(location);
1254 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1256 WRITE_NODE_TYPE("MINMAX");
1258 WRITE_OID_FIELD(minmaxtype);
1259 WRITE_ENUM_FIELD(op, MinMaxOp);
1260 WRITE_NODE_FIELD(args);
1261 WRITE_OID_FIELD(collid);
1262 WRITE_LOCATION_FIELD(location);
1266 _outXmlExpr(StringInfo str, XmlExpr *node)
1268 WRITE_NODE_TYPE("XMLEXPR");
1270 WRITE_ENUM_FIELD(op, XmlExprOp);
1271 WRITE_STRING_FIELD(name);
1272 WRITE_NODE_FIELD(named_args);
1273 WRITE_NODE_FIELD(arg_names);
1274 WRITE_NODE_FIELD(args);
1275 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1276 WRITE_OID_FIELD(type);
1277 WRITE_INT_FIELD(typmod);
1278 WRITE_LOCATION_FIELD(location);
1282 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1284 WRITE_NODE_TYPE("NULLIFEXPR");
1286 WRITE_OID_FIELD(opno);
1287 WRITE_OID_FIELD(opfuncid);
1288 WRITE_OID_FIELD(opresulttype);
1289 WRITE_BOOL_FIELD(opretset);
1290 WRITE_NODE_FIELD(args);
1291 WRITE_LOCATION_FIELD(location);
1295 _outNullTest(StringInfo str, NullTest *node)
1297 WRITE_NODE_TYPE("NULLTEST");
1299 WRITE_NODE_FIELD(arg);
1300 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1301 WRITE_BOOL_FIELD(argisrow);
1305 _outBooleanTest(StringInfo str, BooleanTest *node)
1307 WRITE_NODE_TYPE("BOOLEANTEST");
1309 WRITE_NODE_FIELD(arg);
1310 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1314 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1316 WRITE_NODE_TYPE("COERCETODOMAIN");
1318 WRITE_NODE_FIELD(arg);
1319 WRITE_OID_FIELD(resulttype);
1320 WRITE_INT_FIELD(resulttypmod);
1321 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1322 WRITE_LOCATION_FIELD(location);
1326 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1328 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1330 WRITE_OID_FIELD(typeId);
1331 WRITE_INT_FIELD(typeMod);
1332 WRITE_LOCATION_FIELD(location);
1336 _outSetToDefault(StringInfo str, SetToDefault *node)
1338 WRITE_NODE_TYPE("SETTODEFAULT");
1340 WRITE_OID_FIELD(typeId);
1341 WRITE_INT_FIELD(typeMod);
1342 WRITE_OID_FIELD(collid);
1343 WRITE_LOCATION_FIELD(location);
1347 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1349 WRITE_NODE_TYPE("CURRENTOFEXPR");
1351 WRITE_UINT_FIELD(cvarno);
1352 WRITE_STRING_FIELD(cursor_name);
1353 WRITE_INT_FIELD(cursor_param);
1357 _outTargetEntry(StringInfo str, TargetEntry *node)
1359 WRITE_NODE_TYPE("TARGETENTRY");
1361 WRITE_NODE_FIELD(expr);
1362 WRITE_INT_FIELD(resno);
1363 WRITE_STRING_FIELD(resname);
1364 WRITE_UINT_FIELD(ressortgroupref);
1365 WRITE_OID_FIELD(resorigtbl);
1366 WRITE_INT_FIELD(resorigcol);
1367 WRITE_BOOL_FIELD(resjunk);
1371 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1373 WRITE_NODE_TYPE("RANGETBLREF");
1375 WRITE_INT_FIELD(rtindex);
1379 _outJoinExpr(StringInfo str, JoinExpr *node)
1381 WRITE_NODE_TYPE("JOINEXPR");
1383 WRITE_ENUM_FIELD(jointype, JoinType);
1384 WRITE_BOOL_FIELD(isNatural);
1385 WRITE_NODE_FIELD(larg);
1386 WRITE_NODE_FIELD(rarg);
1387 WRITE_NODE_FIELD(usingClause);
1388 WRITE_NODE_FIELD(quals);
1389 WRITE_NODE_FIELD(alias);
1390 WRITE_INT_FIELD(rtindex);
1394 _outFromExpr(StringInfo str, FromExpr *node)
1396 WRITE_NODE_TYPE("FROMEXPR");
1398 WRITE_NODE_FIELD(fromlist);
1399 WRITE_NODE_FIELD(quals);
1402 /*****************************************************************************
1404 * Stuff from relation.h.
1406 *****************************************************************************/
1409 * print the basic stuff of all nodes that inherit from Path
1411 * Note we do NOT print the parent, else we'd be in infinite recursion.
1412 * We can print the parent's relids for identification purposes, though.
1415 _outPathInfo(StringInfo str, Path *node)
1417 WRITE_ENUM_FIELD(pathtype, NodeTag);
1418 appendStringInfo(str, " :parent_relids ");
1419 _outBitmapset(str, node->parent->relids);
1420 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1421 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1422 WRITE_NODE_FIELD(pathkeys);
1426 * print the basic stuff of all nodes that inherit from JoinPath
1429 _outJoinPathInfo(StringInfo str, JoinPath *node)
1431 _outPathInfo(str, (Path *) node);
1433 WRITE_ENUM_FIELD(jointype, JoinType);
1434 WRITE_NODE_FIELD(outerjoinpath);
1435 WRITE_NODE_FIELD(innerjoinpath);
1436 WRITE_NODE_FIELD(joinrestrictinfo);
1440 _outPath(StringInfo str, Path *node)
1442 WRITE_NODE_TYPE("PATH");
1444 _outPathInfo(str, (Path *) node);
1448 _outIndexPath(StringInfo str, IndexPath *node)
1450 WRITE_NODE_TYPE("INDEXPATH");
1452 _outPathInfo(str, (Path *) node);
1454 WRITE_NODE_FIELD(indexinfo);
1455 WRITE_NODE_FIELD(indexclauses);
1456 WRITE_NODE_FIELD(indexquals);
1457 WRITE_NODE_FIELD(indexorderbys);
1458 WRITE_BOOL_FIELD(isjoininner);
1459 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1460 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1461 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1462 WRITE_FLOAT_FIELD(rows, "%.0f");
1466 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1468 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1470 _outPathInfo(str, (Path *) node);
1472 WRITE_NODE_FIELD(bitmapqual);
1473 WRITE_BOOL_FIELD(isjoininner);
1474 WRITE_FLOAT_FIELD(rows, "%.0f");
1478 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1480 WRITE_NODE_TYPE("BITMAPANDPATH");
1482 _outPathInfo(str, (Path *) node);
1484 WRITE_NODE_FIELD(bitmapquals);
1485 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1489 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1491 WRITE_NODE_TYPE("BITMAPORPATH");
1493 _outPathInfo(str, (Path *) node);
1495 WRITE_NODE_FIELD(bitmapquals);
1496 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1500 _outTidPath(StringInfo str, TidPath *node)
1502 WRITE_NODE_TYPE("TIDPATH");
1504 _outPathInfo(str, (Path *) node);
1506 WRITE_NODE_FIELD(tidquals);
1510 _outAppendPath(StringInfo str, AppendPath *node)
1512 WRITE_NODE_TYPE("APPENDPATH");
1514 _outPathInfo(str, (Path *) node);
1516 WRITE_NODE_FIELD(subpaths);
1520 _outMergeAppendPath(StringInfo str, MergeAppendPath *node)
1522 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1524 _outPathInfo(str, (Path *) node);
1526 WRITE_NODE_FIELD(subpaths);
1527 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1531 _outResultPath(StringInfo str, ResultPath *node)
1533 WRITE_NODE_TYPE("RESULTPATH");
1535 _outPathInfo(str, (Path *) node);
1537 WRITE_NODE_FIELD(quals);
1541 _outMaterialPath(StringInfo str, MaterialPath *node)
1543 WRITE_NODE_TYPE("MATERIALPATH");
1545 _outPathInfo(str, (Path *) node);
1547 WRITE_NODE_FIELD(subpath);
1551 _outUniquePath(StringInfo str, UniquePath *node)
1553 WRITE_NODE_TYPE("UNIQUEPATH");
1555 _outPathInfo(str, (Path *) node);
1557 WRITE_NODE_FIELD(subpath);
1558 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1559 WRITE_NODE_FIELD(in_operators);
1560 WRITE_NODE_FIELD(uniq_exprs);
1561 WRITE_FLOAT_FIELD(rows, "%.0f");
1565 _outNestPath(StringInfo str, NestPath *node)
1567 WRITE_NODE_TYPE("NESTPATH");
1569 _outJoinPathInfo(str, (JoinPath *) node);
1573 _outMergePath(StringInfo str, MergePath *node)
1575 WRITE_NODE_TYPE("MERGEPATH");
1577 _outJoinPathInfo(str, (JoinPath *) node);
1579 WRITE_NODE_FIELD(path_mergeclauses);
1580 WRITE_NODE_FIELD(outersortkeys);
1581 WRITE_NODE_FIELD(innersortkeys);
1582 WRITE_BOOL_FIELD(materialize_inner);
1586 _outHashPath(StringInfo str, HashPath *node)
1588 WRITE_NODE_TYPE("HASHPATH");
1590 _outJoinPathInfo(str, (JoinPath *) node);
1592 WRITE_NODE_FIELD(path_hashclauses);
1593 WRITE_INT_FIELD(num_batches);
1597 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1599 WRITE_NODE_TYPE("PLANNERGLOBAL");
1601 /* NB: this isn't a complete set of fields */
1602 WRITE_NODE_FIELD(paramlist);
1603 WRITE_NODE_FIELD(subplans);
1604 WRITE_NODE_FIELD(subrtables);
1605 WRITE_NODE_FIELD(subrowmarks);
1606 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1607 WRITE_NODE_FIELD(finalrtable);
1608 WRITE_NODE_FIELD(finalrowmarks);
1609 WRITE_NODE_FIELD(relationOids);
1610 WRITE_NODE_FIELD(invalItems);
1611 WRITE_UINT_FIELD(lastPHId);
1612 WRITE_BOOL_FIELD(transientPlan);
1616 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1618 WRITE_NODE_TYPE("PLANNERINFO");
1620 /* NB: this isn't a complete set of fields */
1621 WRITE_NODE_FIELD(parse);
1622 WRITE_NODE_FIELD(glob);
1623 WRITE_UINT_FIELD(query_level);
1624 WRITE_NODE_FIELD(join_rel_list);
1625 WRITE_INT_FIELD(join_cur_level);
1626 WRITE_NODE_FIELD(resultRelations);
1627 WRITE_NODE_FIELD(init_plans);
1628 WRITE_NODE_FIELD(cte_plan_ids);
1629 WRITE_NODE_FIELD(eq_classes);
1630 WRITE_NODE_FIELD(canon_pathkeys);
1631 WRITE_NODE_FIELD(left_join_clauses);
1632 WRITE_NODE_FIELD(right_join_clauses);
1633 WRITE_NODE_FIELD(full_join_clauses);
1634 WRITE_NODE_FIELD(join_info_list);
1635 WRITE_NODE_FIELD(append_rel_list);
1636 WRITE_NODE_FIELD(rowMarks);
1637 WRITE_NODE_FIELD(placeholder_list);
1638 WRITE_NODE_FIELD(query_pathkeys);
1639 WRITE_NODE_FIELD(group_pathkeys);
1640 WRITE_NODE_FIELD(window_pathkeys);
1641 WRITE_NODE_FIELD(distinct_pathkeys);
1642 WRITE_NODE_FIELD(sort_pathkeys);
1643 WRITE_NODE_FIELD(minmax_aggs);
1644 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1645 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1646 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1647 WRITE_BOOL_FIELD(hasInheritedTarget);
1648 WRITE_BOOL_FIELD(hasJoinRTEs);
1649 WRITE_BOOL_FIELD(hasHavingQual);
1650 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1651 WRITE_BOOL_FIELD(hasRecursion);
1652 WRITE_INT_FIELD(wt_param_id);
1653 WRITE_BITMAPSET_FIELD(curOuterRels);
1654 WRITE_NODE_FIELD(curOuterParams);
1658 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1660 WRITE_NODE_TYPE("RELOPTINFO");
1662 /* NB: this isn't a complete set of fields */
1663 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1664 WRITE_BITMAPSET_FIELD(relids);
1665 WRITE_FLOAT_FIELD(rows, "%.0f");
1666 WRITE_INT_FIELD(width);
1667 WRITE_NODE_FIELD(reltargetlist);
1668 WRITE_NODE_FIELD(pathlist);
1669 WRITE_NODE_FIELD(cheapest_startup_path);
1670 WRITE_NODE_FIELD(cheapest_total_path);
1671 WRITE_NODE_FIELD(cheapest_unique_path);
1672 WRITE_UINT_FIELD(relid);
1673 WRITE_UINT_FIELD(reltablespace);
1674 WRITE_ENUM_FIELD(rtekind, RTEKind);
1675 WRITE_INT_FIELD(min_attr);
1676 WRITE_INT_FIELD(max_attr);
1677 WRITE_NODE_FIELD(indexlist);
1678 WRITE_UINT_FIELD(pages);
1679 WRITE_FLOAT_FIELD(tuples, "%.0f");
1680 WRITE_NODE_FIELD(subplan);
1681 WRITE_NODE_FIELD(subrtable);
1682 WRITE_NODE_FIELD(subrowmark);
1683 WRITE_NODE_FIELD(baserestrictinfo);
1684 WRITE_NODE_FIELD(joininfo);
1685 WRITE_BOOL_FIELD(has_eclass_joins);
1686 WRITE_BITMAPSET_FIELD(index_outer_relids);
1687 WRITE_NODE_FIELD(index_inner_paths);
1691 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1693 WRITE_NODE_TYPE("INDEXOPTINFO");
1695 /* NB: this isn't a complete set of fields */
1696 WRITE_OID_FIELD(indexoid);
1697 /* Do NOT print rel field, else infinite recursion */
1698 WRITE_UINT_FIELD(pages);
1699 WRITE_FLOAT_FIELD(tuples, "%.0f");
1700 WRITE_INT_FIELD(ncolumns);
1701 WRITE_NODE_FIELD(indexprs);
1702 WRITE_NODE_FIELD(indpred);
1703 WRITE_BOOL_FIELD(predOK);
1704 WRITE_BOOL_FIELD(unique);
1708 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1711 * To simplify reading, we just chase up to the topmost merged EC and
1712 * print that, without bothering to show the merge-ees separately.
1714 while (node->ec_merged)
1715 node = node->ec_merged;
1717 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1719 WRITE_NODE_FIELD(ec_opfamilies);
1720 WRITE_NODE_FIELD(ec_members);
1721 WRITE_NODE_FIELD(ec_sources);
1722 WRITE_NODE_FIELD(ec_derives);
1723 WRITE_BITMAPSET_FIELD(ec_relids);
1724 WRITE_BOOL_FIELD(ec_has_const);
1725 WRITE_BOOL_FIELD(ec_has_volatile);
1726 WRITE_BOOL_FIELD(ec_below_outer_join);
1727 WRITE_BOOL_FIELD(ec_broken);
1728 WRITE_UINT_FIELD(ec_sortref);
1732 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1734 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1736 WRITE_NODE_FIELD(em_expr);
1737 WRITE_BITMAPSET_FIELD(em_relids);
1738 WRITE_BOOL_FIELD(em_is_const);
1739 WRITE_BOOL_FIELD(em_is_child);
1740 WRITE_OID_FIELD(em_datatype);
1744 _outPathKey(StringInfo str, PathKey *node)
1746 WRITE_NODE_TYPE("PATHKEY");
1748 WRITE_NODE_FIELD(pk_eclass);
1749 WRITE_OID_FIELD(pk_opfamily);
1750 WRITE_OID_FIELD(pk_collation);
1751 WRITE_INT_FIELD(pk_strategy);
1752 WRITE_BOOL_FIELD(pk_nulls_first);
1756 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1758 WRITE_NODE_TYPE("RESTRICTINFO");
1760 /* NB: this isn't a complete set of fields */
1761 WRITE_NODE_FIELD(clause);
1762 WRITE_BOOL_FIELD(is_pushed_down);
1763 WRITE_BOOL_FIELD(outerjoin_delayed);
1764 WRITE_BOOL_FIELD(can_join);
1765 WRITE_BOOL_FIELD(pseudoconstant);
1766 WRITE_BITMAPSET_FIELD(clause_relids);
1767 WRITE_BITMAPSET_FIELD(required_relids);
1768 WRITE_BITMAPSET_FIELD(nullable_relids);
1769 WRITE_BITMAPSET_FIELD(left_relids);
1770 WRITE_BITMAPSET_FIELD(right_relids);
1771 WRITE_NODE_FIELD(orclause);
1772 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1773 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1774 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1775 WRITE_NODE_FIELD(mergeopfamilies);
1776 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1777 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1778 WRITE_NODE_FIELD(left_em);
1779 WRITE_NODE_FIELD(right_em);
1780 WRITE_BOOL_FIELD(outer_is_left);
1781 WRITE_OID_FIELD(hashjoinoperator);
1785 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1787 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1788 WRITE_BITMAPSET_FIELD(other_relids);
1789 WRITE_BOOL_FIELD(isouterjoin);
1790 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1791 WRITE_NODE_FIELD(cheapest_total_innerpath);
1795 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1797 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1799 WRITE_NODE_FIELD(phexpr);
1800 WRITE_BITMAPSET_FIELD(phrels);
1801 WRITE_UINT_FIELD(phid);
1802 WRITE_UINT_FIELD(phlevelsup);
1806 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1808 WRITE_NODE_TYPE("SPECIALJOININFO");
1810 WRITE_BITMAPSET_FIELD(min_lefthand);
1811 WRITE_BITMAPSET_FIELD(min_righthand);
1812 WRITE_BITMAPSET_FIELD(syn_lefthand);
1813 WRITE_BITMAPSET_FIELD(syn_righthand);
1814 WRITE_ENUM_FIELD(jointype, JoinType);
1815 WRITE_BOOL_FIELD(lhs_strict);
1816 WRITE_BOOL_FIELD(delay_upper_joins);
1817 WRITE_NODE_FIELD(join_quals);
1821 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1823 WRITE_NODE_TYPE("APPENDRELINFO");
1825 WRITE_UINT_FIELD(parent_relid);
1826 WRITE_UINT_FIELD(child_relid);
1827 WRITE_OID_FIELD(parent_reltype);
1828 WRITE_OID_FIELD(child_reltype);
1829 WRITE_NODE_FIELD(translated_vars);
1830 WRITE_OID_FIELD(parent_reloid);
1834 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1836 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1838 WRITE_UINT_FIELD(phid);
1839 WRITE_NODE_FIELD(ph_var);
1840 WRITE_BITMAPSET_FIELD(ph_eval_at);
1841 WRITE_BITMAPSET_FIELD(ph_needed);
1842 WRITE_BITMAPSET_FIELD(ph_may_need);
1843 WRITE_INT_FIELD(ph_width);
1847 _outMinMaxAggInfo(StringInfo str, MinMaxAggInfo *node)
1849 WRITE_NODE_TYPE("MINMAXAGGINFO");
1851 WRITE_OID_FIELD(aggfnoid);
1852 WRITE_OID_FIELD(aggsortop);
1853 WRITE_NODE_FIELD(target);
1854 WRITE_NODE_FIELD(pathkeys);
1858 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1860 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1862 WRITE_NODE_FIELD(item);
1863 WRITE_UINT_FIELD(abslevel);
1866 /*****************************************************************************
1868 * Stuff from parsenodes.h.
1870 *****************************************************************************/
1873 _outCreateStmt(StringInfo str, CreateStmt *node)
1875 WRITE_NODE_TYPE("CREATESTMT");
1877 WRITE_NODE_FIELD(relation);
1878 WRITE_NODE_FIELD(tableElts);
1879 WRITE_NODE_FIELD(inhRelations);
1880 WRITE_NODE_FIELD(ofTypename);
1881 WRITE_NODE_FIELD(constraints);
1882 WRITE_NODE_FIELD(options);
1883 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1884 WRITE_STRING_FIELD(tablespacename);
1885 WRITE_BOOL_FIELD(if_not_exists);
1889 _outCreateForeignTableStmt(StringInfo str, CreateForeignTableStmt *node)
1891 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
1893 _outCreateStmt(str, (CreateStmt *) &node->base);
1895 WRITE_STRING_FIELD(servername);
1896 WRITE_NODE_FIELD(options);
1900 _outIndexStmt(StringInfo str, IndexStmt *node)
1902 WRITE_NODE_TYPE("INDEXSTMT");
1904 WRITE_STRING_FIELD(idxname);
1905 WRITE_NODE_FIELD(relation);
1906 WRITE_STRING_FIELD(accessMethod);
1907 WRITE_STRING_FIELD(tableSpace);
1908 WRITE_NODE_FIELD(indexParams);
1909 WRITE_NODE_FIELD(options);
1910 WRITE_NODE_FIELD(whereClause);
1911 WRITE_NODE_FIELD(excludeOpNames);
1912 WRITE_OID_FIELD(indexOid);
1913 WRITE_BOOL_FIELD(unique);
1914 WRITE_BOOL_FIELD(primary);
1915 WRITE_BOOL_FIELD(isconstraint);
1916 WRITE_BOOL_FIELD(deferrable);
1917 WRITE_BOOL_FIELD(initdeferred);
1918 WRITE_BOOL_FIELD(concurrent);
1922 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1924 WRITE_NODE_TYPE("NOTIFY");
1926 WRITE_STRING_FIELD(conditionname);
1927 WRITE_STRING_FIELD(payload);
1931 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1933 WRITE_NODE_TYPE("DECLARECURSOR");
1935 WRITE_STRING_FIELD(portalname);
1936 WRITE_INT_FIELD(options);
1937 WRITE_NODE_FIELD(query);
1941 _outSelectStmt(StringInfo str, SelectStmt *node)
1943 WRITE_NODE_TYPE("SELECT");
1945 WRITE_NODE_FIELD(distinctClause);
1946 WRITE_NODE_FIELD(intoClause);
1947 WRITE_NODE_FIELD(targetList);
1948 WRITE_NODE_FIELD(fromClause);
1949 WRITE_NODE_FIELD(whereClause);
1950 WRITE_NODE_FIELD(groupClause);
1951 WRITE_NODE_FIELD(havingClause);
1952 WRITE_NODE_FIELD(windowClause);
1953 WRITE_NODE_FIELD(withClause);
1954 WRITE_NODE_FIELD(valuesLists);
1955 WRITE_NODE_FIELD(sortClause);
1956 WRITE_NODE_FIELD(limitOffset);
1957 WRITE_NODE_FIELD(limitCount);
1958 WRITE_NODE_FIELD(lockingClause);
1959 WRITE_ENUM_FIELD(op, SetOperation);
1960 WRITE_BOOL_FIELD(all);
1961 WRITE_NODE_FIELD(larg);
1962 WRITE_NODE_FIELD(rarg);
1966 _outFuncCall(StringInfo str, FuncCall *node)
1968 WRITE_NODE_TYPE("FUNCCALL");
1970 WRITE_NODE_FIELD(funcname);
1971 WRITE_NODE_FIELD(args);
1972 WRITE_NODE_FIELD(agg_order);
1973 WRITE_BOOL_FIELD(agg_star);
1974 WRITE_BOOL_FIELD(agg_distinct);
1975 WRITE_BOOL_FIELD(func_variadic);
1976 WRITE_NODE_FIELD(over);
1977 WRITE_LOCATION_FIELD(location);
1981 _outDefElem(StringInfo str, DefElem *node)
1983 WRITE_NODE_TYPE("DEFELEM");
1985 WRITE_STRING_FIELD(defnamespace);
1986 WRITE_STRING_FIELD(defname);
1987 WRITE_NODE_FIELD(arg);
1988 WRITE_ENUM_FIELD(defaction, DefElemAction);
1992 _outInhRelation(StringInfo str, InhRelation *node)
1994 WRITE_NODE_TYPE("INHRELATION");
1996 WRITE_NODE_FIELD(relation);
1997 WRITE_UINT_FIELD(options);
2001 _outLockingClause(StringInfo str, LockingClause *node)
2003 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2005 WRITE_NODE_FIELD(lockedRels);
2006 WRITE_BOOL_FIELD(forUpdate);
2007 WRITE_BOOL_FIELD(noWait);
2011 _outXmlSerialize(StringInfo str, XmlSerialize *node)
2013 WRITE_NODE_TYPE("XMLSERIALIZE");
2015 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2016 WRITE_NODE_FIELD(expr);
2017 WRITE_NODE_FIELD(typeName);
2018 WRITE_LOCATION_FIELD(location);
2022 _outColumnDef(StringInfo str, ColumnDef *node)
2024 WRITE_NODE_TYPE("COLUMNDEF");
2026 WRITE_STRING_FIELD(colname);
2027 WRITE_NODE_FIELD(typeName);
2028 WRITE_INT_FIELD(inhcount);
2029 WRITE_BOOL_FIELD(is_local);
2030 WRITE_BOOL_FIELD(is_not_null);
2031 WRITE_INT_FIELD(storage);
2032 WRITE_NODE_FIELD(raw_default);
2033 WRITE_NODE_FIELD(cooked_default);
2034 WRITE_NODE_FIELD(constraints);
2038 _outTypeName(StringInfo str, TypeName *node)
2040 WRITE_NODE_TYPE("TYPENAME");
2042 WRITE_NODE_FIELD(names);
2043 WRITE_OID_FIELD(typeOid);
2044 WRITE_BOOL_FIELD(setof);
2045 WRITE_BOOL_FIELD(pct_type);
2046 WRITE_NODE_FIELD(typmods);
2047 WRITE_INT_FIELD(typemod);
2048 WRITE_NODE_FIELD(arrayBounds);
2049 WRITE_NODE_FIELD(collnames);
2050 WRITE_OID_FIELD(collOid);
2051 WRITE_LOCATION_FIELD(location);
2055 _outTypeCast(StringInfo str, TypeCast *node)
2057 WRITE_NODE_TYPE("TYPECAST");
2059 WRITE_NODE_FIELD(arg);
2060 WRITE_NODE_FIELD(typeName);
2061 WRITE_LOCATION_FIELD(location);
2065 _outCollateClause(StringInfo str, CollateClause *node)
2067 WRITE_NODE_TYPE("COLLATE");
2069 WRITE_NODE_FIELD(arg);
2070 WRITE_NODE_FIELD(collnames);
2071 WRITE_OID_FIELD(collOid);
2072 WRITE_LOCATION_FIELD(location);
2076 _outIndexElem(StringInfo str, IndexElem *node)
2078 WRITE_NODE_TYPE("INDEXELEM");
2080 WRITE_STRING_FIELD(name);
2081 WRITE_NODE_FIELD(expr);
2082 WRITE_STRING_FIELD(indexcolname);
2083 WRITE_NODE_FIELD(collation);
2084 WRITE_NODE_FIELD(opclass);
2085 WRITE_ENUM_FIELD(ordering, SortByDir);
2086 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2090 _outQuery(StringInfo str, Query *node)
2092 WRITE_NODE_TYPE("QUERY");
2094 WRITE_ENUM_FIELD(commandType, CmdType);
2095 WRITE_ENUM_FIELD(querySource, QuerySource);
2096 WRITE_BOOL_FIELD(canSetTag);
2099 * Hack to work around missing outfuncs routines for a lot of the
2100 * utility-statement node types. (The only one we actually *need* for
2101 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2102 * for the meantime do this to avoid getting lots of warnings when running
2103 * with debug_print_parse on.
2105 if (node->utilityStmt)
2107 switch (nodeTag(node->utilityStmt))
2112 case T_DeclareCursorStmt:
2113 WRITE_NODE_FIELD(utilityStmt);
2116 appendStringInfo(str, " :utilityStmt ?");
2121 appendStringInfo(str, " :utilityStmt <>");
2123 WRITE_INT_FIELD(resultRelation);
2124 WRITE_NODE_FIELD(intoClause);
2125 WRITE_BOOL_FIELD(hasAggs);
2126 WRITE_BOOL_FIELD(hasWindowFuncs);
2127 WRITE_BOOL_FIELD(hasSubLinks);
2128 WRITE_BOOL_FIELD(hasDistinctOn);
2129 WRITE_BOOL_FIELD(hasRecursive);
2130 WRITE_BOOL_FIELD(hasForUpdate);
2131 WRITE_NODE_FIELD(cteList);
2132 WRITE_NODE_FIELD(rtable);
2133 WRITE_NODE_FIELD(jointree);
2134 WRITE_NODE_FIELD(targetList);
2135 WRITE_NODE_FIELD(returningList);
2136 WRITE_NODE_FIELD(groupClause);
2137 WRITE_NODE_FIELD(havingQual);
2138 WRITE_NODE_FIELD(windowClause);
2139 WRITE_NODE_FIELD(distinctClause);
2140 WRITE_NODE_FIELD(sortClause);
2141 WRITE_NODE_FIELD(limitOffset);
2142 WRITE_NODE_FIELD(limitCount);
2143 WRITE_NODE_FIELD(rowMarks);
2144 WRITE_NODE_FIELD(setOperations);
2145 WRITE_NODE_FIELD(constraintDeps);
2149 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2151 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2153 WRITE_UINT_FIELD(tleSortGroupRef);
2154 WRITE_OID_FIELD(eqop);
2155 WRITE_OID_FIELD(sortop);
2156 WRITE_BOOL_FIELD(nulls_first);
2157 WRITE_BOOL_FIELD(hashable);
2161 _outWindowClause(StringInfo str, WindowClause *node)
2163 WRITE_NODE_TYPE("WINDOWCLAUSE");
2165 WRITE_STRING_FIELD(name);
2166 WRITE_STRING_FIELD(refname);
2167 WRITE_NODE_FIELD(partitionClause);
2168 WRITE_NODE_FIELD(orderClause);
2169 WRITE_INT_FIELD(frameOptions);
2170 WRITE_NODE_FIELD(startOffset);
2171 WRITE_NODE_FIELD(endOffset);
2172 WRITE_UINT_FIELD(winref);
2173 WRITE_BOOL_FIELD(copiedOrder);
2177 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2179 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2181 WRITE_UINT_FIELD(rti);
2182 WRITE_BOOL_FIELD(forUpdate);
2183 WRITE_BOOL_FIELD(noWait);
2184 WRITE_BOOL_FIELD(pushedDown);
2188 _outWithClause(StringInfo str, WithClause *node)
2190 WRITE_NODE_TYPE("WITHCLAUSE");
2192 WRITE_NODE_FIELD(ctes);
2193 WRITE_BOOL_FIELD(recursive);
2194 WRITE_LOCATION_FIELD(location);
2198 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2200 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2202 WRITE_STRING_FIELD(ctename);
2203 WRITE_NODE_FIELD(aliascolnames);
2204 WRITE_NODE_FIELD(ctequery);
2205 WRITE_LOCATION_FIELD(location);
2206 WRITE_BOOL_FIELD(cterecursive);
2207 WRITE_INT_FIELD(cterefcount);
2208 WRITE_NODE_FIELD(ctecolnames);
2209 WRITE_NODE_FIELD(ctecoltypes);
2210 WRITE_NODE_FIELD(ctecoltypmods);
2211 WRITE_NODE_FIELD(ctecolcollations);
2215 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2217 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2219 WRITE_ENUM_FIELD(op, SetOperation);
2220 WRITE_BOOL_FIELD(all);
2221 WRITE_NODE_FIELD(larg);
2222 WRITE_NODE_FIELD(rarg);
2223 WRITE_NODE_FIELD(colTypes);
2224 WRITE_NODE_FIELD(colTypmods);
2225 WRITE_NODE_FIELD(colCollations);
2226 WRITE_NODE_FIELD(groupClauses);
2230 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2232 WRITE_NODE_TYPE("RTE");
2234 /* put alias + eref first to make dump more legible */
2235 WRITE_NODE_FIELD(alias);
2236 WRITE_NODE_FIELD(eref);
2237 WRITE_ENUM_FIELD(rtekind, RTEKind);
2239 switch (node->rtekind)
2243 WRITE_OID_FIELD(relid);
2246 WRITE_NODE_FIELD(subquery);
2249 WRITE_ENUM_FIELD(jointype, JoinType);
2250 WRITE_NODE_FIELD(joinaliasvars);
2253 WRITE_NODE_FIELD(funcexpr);
2254 WRITE_NODE_FIELD(funccoltypes);
2255 WRITE_NODE_FIELD(funccoltypmods);
2256 WRITE_NODE_FIELD(funccolcollations);
2259 WRITE_NODE_FIELD(values_lists);
2262 WRITE_STRING_FIELD(ctename);
2263 WRITE_UINT_FIELD(ctelevelsup);
2264 WRITE_BOOL_FIELD(self_reference);
2265 WRITE_NODE_FIELD(ctecoltypes);
2266 WRITE_NODE_FIELD(ctecoltypmods);
2267 WRITE_NODE_FIELD(ctecolcollations);
2270 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2274 WRITE_BOOL_FIELD(inh);
2275 WRITE_BOOL_FIELD(inFromCl);
2276 WRITE_UINT_FIELD(requiredPerms);
2277 WRITE_OID_FIELD(checkAsUser);
2278 WRITE_BITMAPSET_FIELD(selectedCols);
2279 WRITE_BITMAPSET_FIELD(modifiedCols);
2283 _outAExpr(StringInfo str, A_Expr *node)
2285 WRITE_NODE_TYPE("AEXPR");
2290 appendStringInfo(str, " ");
2291 WRITE_NODE_FIELD(name);
2294 appendStringInfo(str, " AND");
2297 appendStringInfo(str, " OR");
2300 appendStringInfo(str, " NOT");
2303 appendStringInfo(str, " ");
2304 WRITE_NODE_FIELD(name);
2305 appendStringInfo(str, " ANY ");
2308 appendStringInfo(str, " ");
2309 WRITE_NODE_FIELD(name);
2310 appendStringInfo(str, " ALL ");
2312 case AEXPR_DISTINCT:
2313 appendStringInfo(str, " DISTINCT ");
2314 WRITE_NODE_FIELD(name);
2317 appendStringInfo(str, " NULLIF ");
2318 WRITE_NODE_FIELD(name);
2321 appendStringInfo(str, " OF ");
2322 WRITE_NODE_FIELD(name);
2325 appendStringInfo(str, " IN ");
2326 WRITE_NODE_FIELD(name);
2329 appendStringInfo(str, " ??");
2333 WRITE_NODE_FIELD(lexpr);
2334 WRITE_NODE_FIELD(rexpr);
2335 WRITE_LOCATION_FIELD(location);
2339 _outValue(StringInfo str, Value *value)
2341 switch (value->type)
2344 appendStringInfo(str, "%ld", value->val.ival);
2349 * We assume the value is a valid numeric literal and so does not
2352 appendStringInfoString(str, value->val.str);
2355 appendStringInfoChar(str, '"');
2356 _outToken(str, value->val.str);
2357 appendStringInfoChar(str, '"');
2360 /* internal representation already has leading 'b' */
2361 appendStringInfoString(str, value->val.str);
2364 /* this is seen only within A_Const, not in transformed trees */
2365 appendStringInfoString(str, "NULL");
2368 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2374 _outColumnRef(StringInfo str, ColumnRef *node)
2376 WRITE_NODE_TYPE("COLUMNREF");
2378 WRITE_NODE_FIELD(fields);
2379 WRITE_LOCATION_FIELD(location);
2383 _outParamRef(StringInfo str, ParamRef *node)
2385 WRITE_NODE_TYPE("PARAMREF");
2387 WRITE_INT_FIELD(number);
2388 WRITE_LOCATION_FIELD(location);
2392 _outAConst(StringInfo str, A_Const *node)
2394 WRITE_NODE_TYPE("A_CONST");
2396 appendStringInfo(str, " :val ");
2397 _outValue(str, &(node->val));
2398 WRITE_LOCATION_FIELD(location);
2402 _outA_Star(StringInfo str, A_Star *node)
2404 WRITE_NODE_TYPE("A_STAR");
2408 _outA_Indices(StringInfo str, A_Indices *node)
2410 WRITE_NODE_TYPE("A_INDICES");
2412 WRITE_NODE_FIELD(lidx);
2413 WRITE_NODE_FIELD(uidx);
2417 _outA_Indirection(StringInfo str, A_Indirection *node)
2419 WRITE_NODE_TYPE("A_INDIRECTION");
2421 WRITE_NODE_FIELD(arg);
2422 WRITE_NODE_FIELD(indirection);
2426 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2428 WRITE_NODE_TYPE("A_ARRAYEXPR");
2430 WRITE_NODE_FIELD(elements);
2431 WRITE_LOCATION_FIELD(location);
2435 _outResTarget(StringInfo str, ResTarget *node)
2437 WRITE_NODE_TYPE("RESTARGET");
2439 WRITE_STRING_FIELD(name);
2440 WRITE_NODE_FIELD(indirection);
2441 WRITE_NODE_FIELD(val);
2442 WRITE_LOCATION_FIELD(location);
2446 _outSortBy(StringInfo str, SortBy *node)
2448 WRITE_NODE_TYPE("SORTBY");
2450 WRITE_NODE_FIELD(node);
2451 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2452 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2453 WRITE_NODE_FIELD(useOp);
2454 WRITE_LOCATION_FIELD(location);
2458 _outWindowDef(StringInfo str, WindowDef *node)
2460 WRITE_NODE_TYPE("WINDOWDEF");
2462 WRITE_STRING_FIELD(name);
2463 WRITE_STRING_FIELD(refname);
2464 WRITE_NODE_FIELD(partitionClause);
2465 WRITE_NODE_FIELD(orderClause);
2466 WRITE_INT_FIELD(frameOptions);
2467 WRITE_NODE_FIELD(startOffset);
2468 WRITE_NODE_FIELD(endOffset);
2469 WRITE_LOCATION_FIELD(location);
2473 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2475 WRITE_NODE_TYPE("RANGESUBSELECT");
2477 WRITE_NODE_FIELD(subquery);
2478 WRITE_NODE_FIELD(alias);
2482 _outRangeFunction(StringInfo str, RangeFunction *node)
2484 WRITE_NODE_TYPE("RANGEFUNCTION");
2486 WRITE_NODE_FIELD(funccallnode);
2487 WRITE_NODE_FIELD(alias);
2488 WRITE_NODE_FIELD(coldeflist);
2492 _outConstraint(StringInfo str, Constraint *node)
2494 WRITE_NODE_TYPE("CONSTRAINT");
2496 WRITE_STRING_FIELD(conname);
2497 WRITE_BOOL_FIELD(deferrable);
2498 WRITE_BOOL_FIELD(initdeferred);
2499 WRITE_LOCATION_FIELD(location);
2501 appendStringInfo(str, " :contype ");
2502 switch (node->contype)
2505 appendStringInfo(str, "NULL");
2508 case CONSTR_NOTNULL:
2509 appendStringInfo(str, "NOT_NULL");
2512 case CONSTR_DEFAULT:
2513 appendStringInfo(str, "DEFAULT");
2514 WRITE_NODE_FIELD(raw_expr);
2515 WRITE_STRING_FIELD(cooked_expr);
2519 appendStringInfo(str, "CHECK");
2520 WRITE_NODE_FIELD(raw_expr);
2521 WRITE_STRING_FIELD(cooked_expr);
2524 case CONSTR_PRIMARY:
2525 appendStringInfo(str, "PRIMARY_KEY");
2526 WRITE_NODE_FIELD(keys);
2527 WRITE_NODE_FIELD(options);
2528 WRITE_STRING_FIELD(indexname);
2529 WRITE_STRING_FIELD(indexspace);
2530 /* access_method and where_clause not currently used */
2534 appendStringInfo(str, "UNIQUE");
2535 WRITE_NODE_FIELD(keys);
2536 WRITE_NODE_FIELD(options);
2537 WRITE_STRING_FIELD(indexname);
2538 WRITE_STRING_FIELD(indexspace);
2539 /* access_method and where_clause not currently used */
2542 case CONSTR_EXCLUSION:
2543 appendStringInfo(str, "EXCLUSION");
2544 WRITE_NODE_FIELD(exclusions);
2545 WRITE_NODE_FIELD(options);
2546 WRITE_STRING_FIELD(indexname);
2547 WRITE_STRING_FIELD(indexspace);
2548 WRITE_STRING_FIELD(access_method);
2549 WRITE_NODE_FIELD(where_clause);
2552 case CONSTR_FOREIGN:
2553 appendStringInfo(str, "FOREIGN_KEY");
2554 WRITE_NODE_FIELD(pktable);
2555 WRITE_NODE_FIELD(fk_attrs);
2556 WRITE_NODE_FIELD(pk_attrs);
2557 WRITE_CHAR_FIELD(fk_matchtype);
2558 WRITE_CHAR_FIELD(fk_upd_action);
2559 WRITE_CHAR_FIELD(fk_del_action);
2560 WRITE_BOOL_FIELD(skip_validation);
2563 case CONSTR_ATTR_DEFERRABLE:
2564 appendStringInfo(str, "ATTR_DEFERRABLE");
2567 case CONSTR_ATTR_NOT_DEFERRABLE:
2568 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2571 case CONSTR_ATTR_DEFERRED:
2572 appendStringInfo(str, "ATTR_DEFERRED");
2575 case CONSTR_ATTR_IMMEDIATE:
2576 appendStringInfo(str, "ATTR_IMMEDIATE");
2580 appendStringInfo(str, "<unrecognized_constraint %d>",
2581 (int) node->contype);
2589 * converts a Node into ascii string and append it to 'str'
2592 _outNode(StringInfo str, void *obj)
2595 appendStringInfo(str, "<>");
2596 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2598 else if (IsA(obj, Integer) ||
2601 IsA(obj, BitString))
2603 /* nodeRead does not want to see { } around these! */
2604 _outValue(str, obj);
2608 appendStringInfoChar(str, '{');
2609 switch (nodeTag(obj))
2612 _outPlannedStmt(str, obj);
2618 _outResult(str, obj);
2621 _outModifyTable(str, obj);
2624 _outAppend(str, obj);
2627 _outMergeAppend(str, obj);
2629 case T_RecursiveUnion:
2630 _outRecursiveUnion(str, obj);
2633 _outBitmapAnd(str, obj);
2636 _outBitmapOr(str, obj);
2642 _outSeqScan(str, obj);
2645 _outIndexScan(str, obj);
2647 case T_BitmapIndexScan:
2648 _outBitmapIndexScan(str, obj);
2650 case T_BitmapHeapScan:
2651 _outBitmapHeapScan(str, obj);
2654 _outTidScan(str, obj);
2656 case T_SubqueryScan:
2657 _outSubqueryScan(str, obj);
2659 case T_FunctionScan:
2660 _outFunctionScan(str, obj);
2663 _outValuesScan(str, obj);
2666 _outCteScan(str, obj);
2668 case T_WorkTableScan:
2669 _outWorkTableScan(str, obj);
2675 _outNestLoop(str, obj);
2678 _outMergeJoin(str, obj);
2681 _outHashJoin(str, obj);
2687 _outWindowAgg(str, obj);
2690 _outGroup(str, obj);
2693 _outMaterial(str, obj);
2699 _outUnique(str, obj);
2705 _outSetOp(str, obj);
2708 _outLockRows(str, obj);
2711 _outLimit(str, obj);
2713 case T_NestLoopParam:
2714 _outNestLoopParam(str, obj);
2717 _outPlanRowMark(str, obj);
2719 case T_PlanInvalItem:
2720 _outPlanInvalItem(str, obj);
2723 _outAlias(str, obj);
2726 _outRangeVar(str, obj);
2729 _outIntoClause(str, obj);
2735 _outConst(str, obj);
2738 _outParam(str, obj);
2741 _outAggref(str, obj);
2744 _outWindowFunc(str, obj);
2747 _outArrayRef(str, obj);
2750 _outFuncExpr(str, obj);
2752 case T_NamedArgExpr:
2753 _outNamedArgExpr(str, obj);
2756 _outOpExpr(str, obj);
2758 case T_DistinctExpr:
2759 _outDistinctExpr(str, obj);
2761 case T_ScalarArrayOpExpr:
2762 _outScalarArrayOpExpr(str, obj);
2765 _outBoolExpr(str, obj);
2768 _outSubLink(str, obj);
2771 _outSubPlan(str, obj);
2773 case T_AlternativeSubPlan:
2774 _outAlternativeSubPlan(str, obj);
2777 _outFieldSelect(str, obj);
2780 _outFieldStore(str, obj);
2783 _outRelabelType(str, obj);
2785 case T_CollateClause:
2786 _outCollateClause(str, obj);
2789 _outCoerceViaIO(str, obj);
2791 case T_ArrayCoerceExpr:
2792 _outArrayCoerceExpr(str, obj);
2794 case T_ConvertRowtypeExpr:
2795 _outConvertRowtypeExpr(str, obj);
2798 _outCaseExpr(str, obj);
2801 _outCaseWhen(str, obj);
2803 case T_CaseTestExpr:
2804 _outCaseTestExpr(str, obj);
2807 _outArrayExpr(str, obj);
2810 _outRowExpr(str, obj);
2812 case T_RowCompareExpr:
2813 _outRowCompareExpr(str, obj);
2815 case T_CoalesceExpr:
2816 _outCoalesceExpr(str, obj);
2819 _outMinMaxExpr(str, obj);
2822 _outXmlExpr(str, obj);
2825 _outNullIfExpr(str, obj);
2828 _outNullTest(str, obj);
2831 _outBooleanTest(str, obj);
2833 case T_CoerceToDomain:
2834 _outCoerceToDomain(str, obj);
2836 case T_CoerceToDomainValue:
2837 _outCoerceToDomainValue(str, obj);
2839 case T_SetToDefault:
2840 _outSetToDefault(str, obj);
2842 case T_CurrentOfExpr:
2843 _outCurrentOfExpr(str, obj);
2846 _outTargetEntry(str, obj);
2849 _outRangeTblRef(str, obj);
2852 _outJoinExpr(str, obj);
2855 _outFromExpr(str, obj);
2862 _outIndexPath(str, obj);
2864 case T_BitmapHeapPath:
2865 _outBitmapHeapPath(str, obj);
2867 case T_BitmapAndPath:
2868 _outBitmapAndPath(str, obj);
2870 case T_BitmapOrPath:
2871 _outBitmapOrPath(str, obj);
2874 _outTidPath(str, obj);
2877 _outAppendPath(str, obj);
2879 case T_MergeAppendPath:
2880 _outMergeAppendPath(str, obj);
2883 _outResultPath(str, obj);
2885 case T_MaterialPath:
2886 _outMaterialPath(str, obj);
2889 _outUniquePath(str, obj);
2892 _outNestPath(str, obj);
2895 _outMergePath(str, obj);
2898 _outHashPath(str, obj);
2900 case T_PlannerGlobal:
2901 _outPlannerGlobal(str, obj);
2904 _outPlannerInfo(str, obj);
2907 _outRelOptInfo(str, obj);
2909 case T_IndexOptInfo:
2910 _outIndexOptInfo(str, obj);
2912 case T_EquivalenceClass:
2913 _outEquivalenceClass(str, obj);
2915 case T_EquivalenceMember:
2916 _outEquivalenceMember(str, obj);
2919 _outPathKey(str, obj);
2921 case T_RestrictInfo:
2922 _outRestrictInfo(str, obj);
2924 case T_InnerIndexscanInfo:
2925 _outInnerIndexscanInfo(str, obj);
2927 case T_PlaceHolderVar:
2928 _outPlaceHolderVar(str, obj);
2930 case T_SpecialJoinInfo:
2931 _outSpecialJoinInfo(str, obj);
2933 case T_AppendRelInfo:
2934 _outAppendRelInfo(str, obj);
2936 case T_PlaceHolderInfo:
2937 _outPlaceHolderInfo(str, obj);
2939 case T_MinMaxAggInfo:
2940 _outMinMaxAggInfo(str, obj);
2942 case T_PlannerParamItem:
2943 _outPlannerParamItem(str, obj);
2947 _outCreateStmt(str, obj);
2949 case T_CreateForeignTableStmt:
2950 _outCreateForeignTableStmt(str, obj);
2953 _outIndexStmt(str, obj);
2956 _outNotifyStmt(str, obj);
2958 case T_DeclareCursorStmt:
2959 _outDeclareCursorStmt(str, obj);
2962 _outSelectStmt(str, obj);
2965 _outColumnDef(str, obj);
2968 _outTypeName(str, obj);
2971 _outTypeCast(str, obj);
2974 _outIndexElem(str, obj);
2977 _outQuery(str, obj);
2979 case T_SortGroupClause:
2980 _outSortGroupClause(str, obj);
2982 case T_WindowClause:
2983 _outWindowClause(str, obj);
2985 case T_RowMarkClause:
2986 _outRowMarkClause(str, obj);
2989 _outWithClause(str, obj);
2991 case T_CommonTableExpr:
2992 _outCommonTableExpr(str, obj);
2994 case T_SetOperationStmt:
2995 _outSetOperationStmt(str, obj);
2997 case T_RangeTblEntry:
2998 _outRangeTblEntry(str, obj);
3001 _outAExpr(str, obj);
3004 _outColumnRef(str, obj);
3007 _outParamRef(str, obj);
3010 _outAConst(str, obj);
3013 _outA_Star(str, obj);
3016 _outA_Indices(str, obj);
3018 case T_A_Indirection:
3019 _outA_Indirection(str, obj);
3022 _outA_ArrayExpr(str, obj);
3025 _outResTarget(str, obj);
3028 _outSortBy(str, obj);
3031 _outWindowDef(str, obj);
3033 case T_RangeSubselect:
3034 _outRangeSubselect(str, obj);
3036 case T_RangeFunction:
3037 _outRangeFunction(str, obj);
3040 _outConstraint(str, obj);
3043 _outFuncCall(str, obj);
3046 _outDefElem(str, obj);
3049 _outInhRelation(str, obj);
3051 case T_LockingClause:
3052 _outLockingClause(str, obj);
3054 case T_XmlSerialize:
3055 _outXmlSerialize(str, obj);
3061 * This should be an ERROR, but it's too useful to be able to
3062 * dump structures that _outNode only understands part of.
3064 elog(WARNING, "could not dump unrecognized node type: %d",
3065 (int) nodeTag(obj));
3068 appendStringInfoChar(str, '}');
3074 * returns the ascii representation of the Node as a palloc'd string
3077 nodeToString(void *obj)
3081 /* see stringinfo.h for an explanation of this maneuver */
3082 initStringInfo(&str);
3083 _outNode(&str, obj);