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 "foreign/fdwapi.h"
27 #include "utils/datum.h"
31 * Macros to simplify output of different kinds of fields. Use these
32 * wherever possible to reduce the chance for silly typos. Note that these
33 * hard-wire conventions about the names of the local variables in an Out
37 /* Write the label for the node type */
38 #define WRITE_NODE_TYPE(nodelabel) \
39 appendStringInfoString(str, nodelabel)
41 /* Write an integer field (anything written as ":fldname %d") */
42 #define WRITE_INT_FIELD(fldname) \
43 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
45 /* Write an unsigned integer field (anything written as ":fldname %u") */
46 #define WRITE_UINT_FIELD(fldname) \
47 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
49 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
50 #define WRITE_OID_FIELD(fldname) \
51 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
53 /* Write a long-integer field */
54 #define WRITE_LONG_FIELD(fldname) \
55 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
57 /* Write a char field (ie, one ascii character) */
58 #define WRITE_CHAR_FIELD(fldname) \
59 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
61 /* Write an enumerated-type field as an integer code */
62 #define WRITE_ENUM_FIELD(fldname, enumtype) \
63 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
66 /* Write a float field --- caller must give format to define precision */
67 #define WRITE_FLOAT_FIELD(fldname,format) \
68 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
70 /* Write a boolean field */
71 #define WRITE_BOOL_FIELD(fldname) \
72 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
73 booltostr(node->fldname))
75 /* Write a character-string (possibly NULL) field */
76 #define WRITE_STRING_FIELD(fldname) \
77 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
78 _outToken(str, node->fldname))
80 /* Write a parse location field (actually same as INT case) */
81 #define WRITE_LOCATION_FIELD(fldname) \
82 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
84 /* Write a Node field */
85 #define WRITE_NODE_FIELD(fldname) \
86 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
87 _outNode(str, node->fldname))
89 /* Write a bitmapset field */
90 #define WRITE_BITMAPSET_FIELD(fldname) \
91 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
92 _outBitmapset(str, node->fldname))
95 #define booltostr(x) ((x) ? "true" : "false")
97 static void _outNode(StringInfo str, const void *obj);
102 * Convert an ordinary string (eg, an identifier) into a form that
103 * will be decoded back to a plain token by read.c's functions.
105 * If a null or empty string is given, it is encoded as "<>".
108 _outToken(StringInfo str, const char *s)
110 if (s == NULL || *s == '\0')
112 appendStringInfo(str, "<>");
117 * Look for characters or patterns that are treated specially by read.c
118 * (either in pg_strtok() or in nodeRead()), and therefore need a
119 * protective backslash.
121 /* These characters only need to be quoted at the start of the string */
124 isdigit((unsigned char) *s) ||
125 ((*s == '+' || *s == '-') &&
126 (isdigit((unsigned char) s[1]) || s[1] == '.')))
127 appendStringInfoChar(str, '\\');
130 /* These chars must be backslashed anywhere in the string */
131 if (*s == ' ' || *s == '\n' || *s == '\t' ||
132 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
134 appendStringInfoChar(str, '\\');
135 appendStringInfoChar(str, *s++);
140 _outList(StringInfo str, const List *node)
144 appendStringInfoChar(str, '(');
146 if (IsA(node, IntList))
147 appendStringInfoChar(str, 'i');
148 else if (IsA(node, OidList))
149 appendStringInfoChar(str, 'o');
154 * For the sake of backward compatibility, we emit a slightly
155 * different whitespace format for lists of nodes vs. other types of
156 * lists. XXX: is this necessary?
160 _outNode(str, lfirst(lc));
162 appendStringInfoChar(str, ' ');
164 else if (IsA(node, IntList))
165 appendStringInfo(str, " %d", lfirst_int(lc));
166 else if (IsA(node, OidList))
167 appendStringInfo(str, " %u", lfirst_oid(lc));
169 elog(ERROR, "unrecognized list node type: %d",
173 appendStringInfoChar(str, ')');
178 * converts a bitmap set of integers
180 * Note: the output format is "(b int int ...)", similar to an integer List.
183 _outBitmapset(StringInfo str, const Bitmapset *bms)
188 appendStringInfoChar(str, '(');
189 appendStringInfoChar(str, 'b');
190 tmpset = bms_copy(bms);
191 while ((x = bms_first_member(tmpset)) >= 0)
192 appendStringInfo(str, " %d", x);
194 appendStringInfoChar(str, ')');
198 * Print the value of a Datum given its type.
201 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
207 length = datumGetSize(value, typbyval, typlen);
211 s = (char *) (&value);
212 appendStringInfo(str, "%u [ ", (unsigned int) length);
213 for (i = 0; i < (Size) sizeof(Datum); i++)
214 appendStringInfo(str, "%d ", (int) (s[i]));
215 appendStringInfo(str, "]");
219 s = (char *) DatumGetPointer(value);
220 if (!PointerIsValid(s))
221 appendStringInfo(str, "0 [ ]");
224 appendStringInfo(str, "%u [ ", (unsigned int) length);
225 for (i = 0; i < length; i++)
226 appendStringInfo(str, "%d ", (int) (s[i]));
227 appendStringInfo(str, "]");
234 * Stuff from plannodes.h
238 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
240 WRITE_NODE_TYPE("PLANNEDSTMT");
242 WRITE_ENUM_FIELD(commandType, CmdType);
243 WRITE_BOOL_FIELD(hasReturning);
244 WRITE_BOOL_FIELD(hasModifyingCTE);
245 WRITE_BOOL_FIELD(canSetTag);
246 WRITE_BOOL_FIELD(transientPlan);
247 WRITE_NODE_FIELD(planTree);
248 WRITE_NODE_FIELD(rtable);
249 WRITE_NODE_FIELD(resultRelations);
250 WRITE_NODE_FIELD(utilityStmt);
251 WRITE_NODE_FIELD(intoClause);
252 WRITE_NODE_FIELD(subplans);
253 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
254 WRITE_NODE_FIELD(rowMarks);
255 WRITE_NODE_FIELD(relationOids);
256 WRITE_NODE_FIELD(invalItems);
257 WRITE_INT_FIELD(nParamExec);
261 * print the basic stuff of all nodes that inherit from Plan
264 _outPlanInfo(StringInfo str, const Plan *node)
266 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
267 WRITE_FLOAT_FIELD(total_cost, "%.2f");
268 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
269 WRITE_INT_FIELD(plan_width);
270 WRITE_NODE_FIELD(targetlist);
271 WRITE_NODE_FIELD(qual);
272 WRITE_NODE_FIELD(lefttree);
273 WRITE_NODE_FIELD(righttree);
274 WRITE_NODE_FIELD(initPlan);
275 WRITE_BITMAPSET_FIELD(extParam);
276 WRITE_BITMAPSET_FIELD(allParam);
280 * print the basic stuff of all nodes that inherit from Scan
283 _outScanInfo(StringInfo str, const Scan *node)
285 _outPlanInfo(str, (const Plan *) node);
287 WRITE_UINT_FIELD(scanrelid);
291 * print the basic stuff of all nodes that inherit from Join
294 _outJoinPlanInfo(StringInfo str, const Join *node)
296 _outPlanInfo(str, (const Plan *) node);
298 WRITE_ENUM_FIELD(jointype, JoinType);
299 WRITE_NODE_FIELD(joinqual);
304 _outPlan(StringInfo str, const Plan *node)
306 WRITE_NODE_TYPE("PLAN");
308 _outPlanInfo(str, (const Plan *) node);
312 _outResult(StringInfo str, const Result *node)
314 WRITE_NODE_TYPE("RESULT");
316 _outPlanInfo(str, (const Plan *) node);
318 WRITE_NODE_FIELD(resconstantqual);
322 _outModifyTable(StringInfo str, const ModifyTable *node)
324 WRITE_NODE_TYPE("MODIFYTABLE");
326 _outPlanInfo(str, (const Plan *) node);
328 WRITE_ENUM_FIELD(operation, CmdType);
329 WRITE_BOOL_FIELD(canSetTag);
330 WRITE_NODE_FIELD(resultRelations);
331 WRITE_INT_FIELD(resultRelIndex);
332 WRITE_NODE_FIELD(plans);
333 WRITE_NODE_FIELD(returningLists);
334 WRITE_NODE_FIELD(rowMarks);
335 WRITE_INT_FIELD(epqParam);
339 _outAppend(StringInfo str, const Append *node)
341 WRITE_NODE_TYPE("APPEND");
343 _outPlanInfo(str, (const Plan *) node);
345 WRITE_NODE_FIELD(appendplans);
349 _outMergeAppend(StringInfo str, const MergeAppend *node)
353 WRITE_NODE_TYPE("MERGEAPPEND");
355 _outPlanInfo(str, (const Plan *) node);
357 WRITE_NODE_FIELD(mergeplans);
359 WRITE_INT_FIELD(numCols);
361 appendStringInfo(str, " :sortColIdx");
362 for (i = 0; i < node->numCols; i++)
363 appendStringInfo(str, " %d", node->sortColIdx[i]);
365 appendStringInfo(str, " :sortOperators");
366 for (i = 0; i < node->numCols; i++)
367 appendStringInfo(str, " %u", node->sortOperators[i]);
369 appendStringInfo(str, " :collations");
370 for (i = 0; i < node->numCols; i++)
371 appendStringInfo(str, " %u", node->collations[i]);
373 appendStringInfo(str, " :nullsFirst");
374 for (i = 0; i < node->numCols; i++)
375 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
379 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
383 WRITE_NODE_TYPE("RECURSIVEUNION");
385 _outPlanInfo(str, (const Plan *) node);
387 WRITE_INT_FIELD(wtParam);
388 WRITE_INT_FIELD(numCols);
390 appendStringInfo(str, " :dupColIdx");
391 for (i = 0; i < node->numCols; i++)
392 appendStringInfo(str, " %d", node->dupColIdx[i]);
394 appendStringInfo(str, " :dupOperators");
395 for (i = 0; i < node->numCols; i++)
396 appendStringInfo(str, " %u", node->dupOperators[i]);
398 WRITE_LONG_FIELD(numGroups);
402 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
404 WRITE_NODE_TYPE("BITMAPAND");
406 _outPlanInfo(str, (const Plan *) node);
408 WRITE_NODE_FIELD(bitmapplans);
412 _outBitmapOr(StringInfo str, const BitmapOr *node)
414 WRITE_NODE_TYPE("BITMAPOR");
416 _outPlanInfo(str, (const Plan *) node);
418 WRITE_NODE_FIELD(bitmapplans);
422 _outScan(StringInfo str, const Scan *node)
424 WRITE_NODE_TYPE("SCAN");
426 _outScanInfo(str, node);
430 _outSeqScan(StringInfo str, const SeqScan *node)
432 WRITE_NODE_TYPE("SEQSCAN");
434 _outScanInfo(str, (const Scan *) node);
438 _outIndexScan(StringInfo str, const IndexScan *node)
440 WRITE_NODE_TYPE("INDEXSCAN");
442 _outScanInfo(str, (const Scan *) node);
444 WRITE_OID_FIELD(indexid);
445 WRITE_NODE_FIELD(indexqual);
446 WRITE_NODE_FIELD(indexqualorig);
447 WRITE_NODE_FIELD(indexorderby);
448 WRITE_NODE_FIELD(indexorderbyorig);
449 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
453 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
455 WRITE_NODE_TYPE("INDEXONLYSCAN");
457 _outScanInfo(str, (const Scan *) node);
459 WRITE_OID_FIELD(indexid);
460 WRITE_NODE_FIELD(indexqual);
461 WRITE_NODE_FIELD(indexorderby);
462 WRITE_NODE_FIELD(indextlist);
463 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
467 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
469 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
471 _outScanInfo(str, (const Scan *) node);
473 WRITE_OID_FIELD(indexid);
474 WRITE_NODE_FIELD(indexqual);
475 WRITE_NODE_FIELD(indexqualorig);
479 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
481 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
483 _outScanInfo(str, (const Scan *) node);
485 WRITE_NODE_FIELD(bitmapqualorig);
489 _outTidScan(StringInfo str, const TidScan *node)
491 WRITE_NODE_TYPE("TIDSCAN");
493 _outScanInfo(str, (const Scan *) node);
495 WRITE_NODE_FIELD(tidquals);
499 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
501 WRITE_NODE_TYPE("SUBQUERYSCAN");
503 _outScanInfo(str, (const Scan *) node);
505 WRITE_NODE_FIELD(subplan);
509 _outFunctionScan(StringInfo str, const FunctionScan *node)
511 WRITE_NODE_TYPE("FUNCTIONSCAN");
513 _outScanInfo(str, (const Scan *) node);
515 WRITE_NODE_FIELD(funcexpr);
516 WRITE_NODE_FIELD(funccolnames);
517 WRITE_NODE_FIELD(funccoltypes);
518 WRITE_NODE_FIELD(funccoltypmods);
519 WRITE_NODE_FIELD(funccolcollations);
523 _outValuesScan(StringInfo str, const ValuesScan *node)
525 WRITE_NODE_TYPE("VALUESSCAN");
527 _outScanInfo(str, (const Scan *) node);
529 WRITE_NODE_FIELD(values_lists);
533 _outCteScan(StringInfo str, const CteScan *node)
535 WRITE_NODE_TYPE("CTESCAN");
537 _outScanInfo(str, (const Scan *) node);
539 WRITE_INT_FIELD(ctePlanId);
540 WRITE_INT_FIELD(cteParam);
544 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
546 WRITE_NODE_TYPE("WORKTABLESCAN");
548 _outScanInfo(str, (const Scan *) node);
550 WRITE_INT_FIELD(wtParam);
554 _outForeignScan(StringInfo str, const ForeignScan *node)
556 WRITE_NODE_TYPE("FOREIGNSCAN");
558 _outScanInfo(str, (const Scan *) node);
560 WRITE_BOOL_FIELD(fsSystemCol);
561 WRITE_NODE_FIELD(fdwplan);
565 _outFdwPlan(StringInfo str, const FdwPlan *node)
567 WRITE_NODE_TYPE("FDWPLAN");
569 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
570 WRITE_FLOAT_FIELD(total_cost, "%.2f");
571 WRITE_NODE_FIELD(fdw_private);
575 _outJoin(StringInfo str, const Join *node)
577 WRITE_NODE_TYPE("JOIN");
579 _outJoinPlanInfo(str, (const Join *) node);
583 _outNestLoop(StringInfo str, const NestLoop *node)
585 WRITE_NODE_TYPE("NESTLOOP");
587 _outJoinPlanInfo(str, (const Join *) node);
589 WRITE_NODE_FIELD(nestParams);
593 _outMergeJoin(StringInfo str, const MergeJoin *node)
598 WRITE_NODE_TYPE("MERGEJOIN");
600 _outJoinPlanInfo(str, (const Join *) node);
602 WRITE_NODE_FIELD(mergeclauses);
604 numCols = list_length(node->mergeclauses);
606 appendStringInfo(str, " :mergeFamilies");
607 for (i = 0; i < numCols; i++)
608 appendStringInfo(str, " %u", node->mergeFamilies[i]);
610 appendStringInfo(str, " :mergeCollations");
611 for (i = 0; i < numCols; i++)
612 appendStringInfo(str, " %u", node->mergeCollations[i]);
614 appendStringInfo(str, " :mergeStrategies");
615 for (i = 0; i < numCols; i++)
616 appendStringInfo(str, " %d", node->mergeStrategies[i]);
618 appendStringInfo(str, " :mergeNullsFirst");
619 for (i = 0; i < numCols; i++)
620 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
624 _outHashJoin(StringInfo str, const HashJoin *node)
626 WRITE_NODE_TYPE("HASHJOIN");
628 _outJoinPlanInfo(str, (const Join *) node);
630 WRITE_NODE_FIELD(hashclauses);
634 _outAgg(StringInfo str, const Agg *node)
638 WRITE_NODE_TYPE("AGG");
640 _outPlanInfo(str, (const Plan *) node);
642 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
643 WRITE_INT_FIELD(numCols);
645 appendStringInfo(str, " :grpColIdx");
646 for (i = 0; i < node->numCols; i++)
647 appendStringInfo(str, " %d", node->grpColIdx[i]);
649 appendStringInfo(str, " :grpOperators");
650 for (i = 0; i < node->numCols; i++)
651 appendStringInfo(str, " %u", node->grpOperators[i]);
653 WRITE_LONG_FIELD(numGroups);
657 _outWindowAgg(StringInfo str, const WindowAgg *node)
661 WRITE_NODE_TYPE("WINDOWAGG");
663 _outPlanInfo(str, (const Plan *) node);
665 WRITE_UINT_FIELD(winref);
666 WRITE_INT_FIELD(partNumCols);
668 appendStringInfo(str, " :partColIdx");
669 for (i = 0; i < node->partNumCols; i++)
670 appendStringInfo(str, " %d", node->partColIdx[i]);
672 appendStringInfo(str, " :partOperations");
673 for (i = 0; i < node->partNumCols; i++)
674 appendStringInfo(str, " %u", node->partOperators[i]);
676 WRITE_INT_FIELD(ordNumCols);
678 appendStringInfo(str, " :ordColIdx");
679 for (i = 0; i < node->ordNumCols; i++)
680 appendStringInfo(str, " %d", node->ordColIdx[i]);
682 appendStringInfo(str, " :ordOperations");
683 for (i = 0; i < node->ordNumCols; i++)
684 appendStringInfo(str, " %u", node->ordOperators[i]);
686 WRITE_INT_FIELD(frameOptions);
687 WRITE_NODE_FIELD(startOffset);
688 WRITE_NODE_FIELD(endOffset);
692 _outGroup(StringInfo str, const Group *node)
696 WRITE_NODE_TYPE("GROUP");
698 _outPlanInfo(str, (const Plan *) node);
700 WRITE_INT_FIELD(numCols);
702 appendStringInfo(str, " :grpColIdx");
703 for (i = 0; i < node->numCols; i++)
704 appendStringInfo(str, " %d", node->grpColIdx[i]);
706 appendStringInfo(str, " :grpOperators");
707 for (i = 0; i < node->numCols; i++)
708 appendStringInfo(str, " %u", node->grpOperators[i]);
712 _outMaterial(StringInfo str, const Material *node)
714 WRITE_NODE_TYPE("MATERIAL");
716 _outPlanInfo(str, (const Plan *) node);
720 _outSort(StringInfo str, const Sort *node)
724 WRITE_NODE_TYPE("SORT");
726 _outPlanInfo(str, (const Plan *) node);
728 WRITE_INT_FIELD(numCols);
730 appendStringInfo(str, " :sortColIdx");
731 for (i = 0; i < node->numCols; i++)
732 appendStringInfo(str, " %d", node->sortColIdx[i]);
734 appendStringInfo(str, " :sortOperators");
735 for (i = 0; i < node->numCols; i++)
736 appendStringInfo(str, " %u", node->sortOperators[i]);
738 appendStringInfo(str, " :collations");
739 for (i = 0; i < node->numCols; i++)
740 appendStringInfo(str, " %u", node->collations[i]);
742 appendStringInfo(str, " :nullsFirst");
743 for (i = 0; i < node->numCols; i++)
744 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
748 _outUnique(StringInfo str, const Unique *node)
752 WRITE_NODE_TYPE("UNIQUE");
754 _outPlanInfo(str, (const Plan *) node);
756 WRITE_INT_FIELD(numCols);
758 appendStringInfo(str, " :uniqColIdx");
759 for (i = 0; i < node->numCols; i++)
760 appendStringInfo(str, " %d", node->uniqColIdx[i]);
762 appendStringInfo(str, " :uniqOperators");
763 for (i = 0; i < node->numCols; i++)
764 appendStringInfo(str, " %u", node->uniqOperators[i]);
768 _outHash(StringInfo str, const Hash *node)
770 WRITE_NODE_TYPE("HASH");
772 _outPlanInfo(str, (const Plan *) node);
774 WRITE_OID_FIELD(skewTable);
775 WRITE_INT_FIELD(skewColumn);
776 WRITE_BOOL_FIELD(skewInherit);
777 WRITE_OID_FIELD(skewColType);
778 WRITE_INT_FIELD(skewColTypmod);
782 _outSetOp(StringInfo str, const SetOp *node)
786 WRITE_NODE_TYPE("SETOP");
788 _outPlanInfo(str, (const Plan *) node);
790 WRITE_ENUM_FIELD(cmd, SetOpCmd);
791 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
792 WRITE_INT_FIELD(numCols);
794 appendStringInfo(str, " :dupColIdx");
795 for (i = 0; i < node->numCols; i++)
796 appendStringInfo(str, " %d", node->dupColIdx[i]);
798 appendStringInfo(str, " :dupOperators");
799 for (i = 0; i < node->numCols; i++)
800 appendStringInfo(str, " %u", node->dupOperators[i]);
802 WRITE_INT_FIELD(flagColIdx);
803 WRITE_INT_FIELD(firstFlag);
804 WRITE_LONG_FIELD(numGroups);
808 _outLockRows(StringInfo str, const LockRows *node)
810 WRITE_NODE_TYPE("LOCKROWS");
812 _outPlanInfo(str, (const Plan *) node);
814 WRITE_NODE_FIELD(rowMarks);
815 WRITE_INT_FIELD(epqParam);
819 _outLimit(StringInfo str, const Limit *node)
821 WRITE_NODE_TYPE("LIMIT");
823 _outPlanInfo(str, (const Plan *) node);
825 WRITE_NODE_FIELD(limitOffset);
826 WRITE_NODE_FIELD(limitCount);
830 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
832 WRITE_NODE_TYPE("NESTLOOPPARAM");
834 WRITE_INT_FIELD(paramno);
835 WRITE_NODE_FIELD(paramval);
839 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
841 WRITE_NODE_TYPE("PLANROWMARK");
843 WRITE_UINT_FIELD(rti);
844 WRITE_UINT_FIELD(prti);
845 WRITE_UINT_FIELD(rowmarkId);
846 WRITE_ENUM_FIELD(markType, RowMarkType);
847 WRITE_BOOL_FIELD(noWait);
848 WRITE_BOOL_FIELD(isParent);
852 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
854 WRITE_NODE_TYPE("PLANINVALITEM");
856 WRITE_INT_FIELD(cacheId);
857 WRITE_UINT_FIELD(hashValue);
860 /*****************************************************************************
862 * Stuff from primnodes.h.
864 *****************************************************************************/
867 _outAlias(StringInfo str, const Alias *node)
869 WRITE_NODE_TYPE("ALIAS");
871 WRITE_STRING_FIELD(aliasname);
872 WRITE_NODE_FIELD(colnames);
876 _outRangeVar(StringInfo str, const RangeVar *node)
878 WRITE_NODE_TYPE("RANGEVAR");
881 * we deliberately ignore catalogname here, since it is presently not
882 * semantically meaningful
884 WRITE_STRING_FIELD(schemaname);
885 WRITE_STRING_FIELD(relname);
886 WRITE_ENUM_FIELD(inhOpt, InhOption);
887 WRITE_CHAR_FIELD(relpersistence);
888 WRITE_NODE_FIELD(alias);
889 WRITE_LOCATION_FIELD(location);
893 _outIntoClause(StringInfo str, const IntoClause *node)
895 WRITE_NODE_TYPE("INTOCLAUSE");
897 WRITE_NODE_FIELD(rel);
898 WRITE_NODE_FIELD(colNames);
899 WRITE_NODE_FIELD(options);
900 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
901 WRITE_STRING_FIELD(tableSpaceName);
902 WRITE_BOOL_FIELD(skipData);
906 _outVar(StringInfo str, const Var *node)
908 WRITE_NODE_TYPE("VAR");
910 WRITE_UINT_FIELD(varno);
911 WRITE_INT_FIELD(varattno);
912 WRITE_OID_FIELD(vartype);
913 WRITE_INT_FIELD(vartypmod);
914 WRITE_OID_FIELD(varcollid);
915 WRITE_UINT_FIELD(varlevelsup);
916 WRITE_UINT_FIELD(varnoold);
917 WRITE_INT_FIELD(varoattno);
918 WRITE_LOCATION_FIELD(location);
922 _outConst(StringInfo str, const Const *node)
924 WRITE_NODE_TYPE("CONST");
926 WRITE_OID_FIELD(consttype);
927 WRITE_INT_FIELD(consttypmod);
928 WRITE_OID_FIELD(constcollid);
929 WRITE_INT_FIELD(constlen);
930 WRITE_BOOL_FIELD(constbyval);
931 WRITE_BOOL_FIELD(constisnull);
932 WRITE_LOCATION_FIELD(location);
934 appendStringInfo(str, " :constvalue ");
935 if (node->constisnull)
936 appendStringInfo(str, "<>");
938 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
942 _outParam(StringInfo str, const Param *node)
944 WRITE_NODE_TYPE("PARAM");
946 WRITE_ENUM_FIELD(paramkind, ParamKind);
947 WRITE_INT_FIELD(paramid);
948 WRITE_OID_FIELD(paramtype);
949 WRITE_INT_FIELD(paramtypmod);
950 WRITE_OID_FIELD(paramcollid);
951 WRITE_LOCATION_FIELD(location);
955 _outAggref(StringInfo str, const Aggref *node)
957 WRITE_NODE_TYPE("AGGREF");
959 WRITE_OID_FIELD(aggfnoid);
960 WRITE_OID_FIELD(aggtype);
961 WRITE_OID_FIELD(aggcollid);
962 WRITE_OID_FIELD(inputcollid);
963 WRITE_NODE_FIELD(args);
964 WRITE_NODE_FIELD(aggorder);
965 WRITE_NODE_FIELD(aggdistinct);
966 WRITE_BOOL_FIELD(aggstar);
967 WRITE_UINT_FIELD(agglevelsup);
968 WRITE_LOCATION_FIELD(location);
972 _outWindowFunc(StringInfo str, const WindowFunc *node)
974 WRITE_NODE_TYPE("WINDOWFUNC");
976 WRITE_OID_FIELD(winfnoid);
977 WRITE_OID_FIELD(wintype);
978 WRITE_OID_FIELD(wincollid);
979 WRITE_OID_FIELD(inputcollid);
980 WRITE_NODE_FIELD(args);
981 WRITE_UINT_FIELD(winref);
982 WRITE_BOOL_FIELD(winstar);
983 WRITE_BOOL_FIELD(winagg);
984 WRITE_LOCATION_FIELD(location);
988 _outArrayRef(StringInfo str, const ArrayRef *node)
990 WRITE_NODE_TYPE("ARRAYREF");
992 WRITE_OID_FIELD(refarraytype);
993 WRITE_OID_FIELD(refelemtype);
994 WRITE_INT_FIELD(reftypmod);
995 WRITE_OID_FIELD(refcollid);
996 WRITE_NODE_FIELD(refupperindexpr);
997 WRITE_NODE_FIELD(reflowerindexpr);
998 WRITE_NODE_FIELD(refexpr);
999 WRITE_NODE_FIELD(refassgnexpr);
1003 _outFuncExpr(StringInfo str, const FuncExpr *node)
1005 WRITE_NODE_TYPE("FUNCEXPR");
1007 WRITE_OID_FIELD(funcid);
1008 WRITE_OID_FIELD(funcresulttype);
1009 WRITE_BOOL_FIELD(funcretset);
1010 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1011 WRITE_OID_FIELD(funccollid);
1012 WRITE_OID_FIELD(inputcollid);
1013 WRITE_NODE_FIELD(args);
1014 WRITE_LOCATION_FIELD(location);
1018 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1020 WRITE_NODE_TYPE("NAMEDARGEXPR");
1022 WRITE_NODE_FIELD(arg);
1023 WRITE_STRING_FIELD(name);
1024 WRITE_INT_FIELD(argnumber);
1025 WRITE_LOCATION_FIELD(location);
1029 _outOpExpr(StringInfo str, const OpExpr *node)
1031 WRITE_NODE_TYPE("OPEXPR");
1033 WRITE_OID_FIELD(opno);
1034 WRITE_OID_FIELD(opfuncid);
1035 WRITE_OID_FIELD(opresulttype);
1036 WRITE_BOOL_FIELD(opretset);
1037 WRITE_OID_FIELD(opcollid);
1038 WRITE_OID_FIELD(inputcollid);
1039 WRITE_NODE_FIELD(args);
1040 WRITE_LOCATION_FIELD(location);
1044 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1046 WRITE_NODE_TYPE("DISTINCTEXPR");
1048 WRITE_OID_FIELD(opno);
1049 WRITE_OID_FIELD(opfuncid);
1050 WRITE_OID_FIELD(opresulttype);
1051 WRITE_BOOL_FIELD(opretset);
1052 WRITE_OID_FIELD(opcollid);
1053 WRITE_OID_FIELD(inputcollid);
1054 WRITE_NODE_FIELD(args);
1055 WRITE_LOCATION_FIELD(location);
1059 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1061 WRITE_NODE_TYPE("NULLIFEXPR");
1063 WRITE_OID_FIELD(opno);
1064 WRITE_OID_FIELD(opfuncid);
1065 WRITE_OID_FIELD(opresulttype);
1066 WRITE_BOOL_FIELD(opretset);
1067 WRITE_OID_FIELD(opcollid);
1068 WRITE_OID_FIELD(inputcollid);
1069 WRITE_NODE_FIELD(args);
1070 WRITE_LOCATION_FIELD(location);
1074 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1076 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1078 WRITE_OID_FIELD(opno);
1079 WRITE_OID_FIELD(opfuncid);
1080 WRITE_BOOL_FIELD(useOr);
1081 WRITE_OID_FIELD(inputcollid);
1082 WRITE_NODE_FIELD(args);
1083 WRITE_LOCATION_FIELD(location);
1087 _outBoolExpr(StringInfo str, const BoolExpr *node)
1091 WRITE_NODE_TYPE("BOOLEXPR");
1093 /* do-it-yourself enum representation */
1094 switch (node->boolop)
1106 appendStringInfo(str, " :boolop ");
1107 _outToken(str, opstr);
1109 WRITE_NODE_FIELD(args);
1110 WRITE_LOCATION_FIELD(location);
1114 _outSubLink(StringInfo str, const SubLink *node)
1116 WRITE_NODE_TYPE("SUBLINK");
1118 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1119 WRITE_NODE_FIELD(testexpr);
1120 WRITE_NODE_FIELD(operName);
1121 WRITE_NODE_FIELD(subselect);
1122 WRITE_LOCATION_FIELD(location);
1126 _outSubPlan(StringInfo str, const SubPlan *node)
1128 WRITE_NODE_TYPE("SUBPLAN");
1130 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1131 WRITE_NODE_FIELD(testexpr);
1132 WRITE_NODE_FIELD(paramIds);
1133 WRITE_INT_FIELD(plan_id);
1134 WRITE_STRING_FIELD(plan_name);
1135 WRITE_OID_FIELD(firstColType);
1136 WRITE_INT_FIELD(firstColTypmod);
1137 WRITE_OID_FIELD(firstColCollation);
1138 WRITE_BOOL_FIELD(useHashTable);
1139 WRITE_BOOL_FIELD(unknownEqFalse);
1140 WRITE_NODE_FIELD(setParam);
1141 WRITE_NODE_FIELD(parParam);
1142 WRITE_NODE_FIELD(args);
1143 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1144 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1148 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1150 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1152 WRITE_NODE_FIELD(subplans);
1156 _outFieldSelect(StringInfo str, const FieldSelect *node)
1158 WRITE_NODE_TYPE("FIELDSELECT");
1160 WRITE_NODE_FIELD(arg);
1161 WRITE_INT_FIELD(fieldnum);
1162 WRITE_OID_FIELD(resulttype);
1163 WRITE_INT_FIELD(resulttypmod);
1164 WRITE_OID_FIELD(resultcollid);
1168 _outFieldStore(StringInfo str, const FieldStore *node)
1170 WRITE_NODE_TYPE("FIELDSTORE");
1172 WRITE_NODE_FIELD(arg);
1173 WRITE_NODE_FIELD(newvals);
1174 WRITE_NODE_FIELD(fieldnums);
1175 WRITE_OID_FIELD(resulttype);
1179 _outRelabelType(StringInfo str, const RelabelType *node)
1181 WRITE_NODE_TYPE("RELABELTYPE");
1183 WRITE_NODE_FIELD(arg);
1184 WRITE_OID_FIELD(resulttype);
1185 WRITE_INT_FIELD(resulttypmod);
1186 WRITE_OID_FIELD(resultcollid);
1187 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1188 WRITE_LOCATION_FIELD(location);
1192 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1194 WRITE_NODE_TYPE("COERCEVIAIO");
1196 WRITE_NODE_FIELD(arg);
1197 WRITE_OID_FIELD(resulttype);
1198 WRITE_OID_FIELD(resultcollid);
1199 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1200 WRITE_LOCATION_FIELD(location);
1204 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1206 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1208 WRITE_NODE_FIELD(arg);
1209 WRITE_OID_FIELD(elemfuncid);
1210 WRITE_OID_FIELD(resulttype);
1211 WRITE_INT_FIELD(resulttypmod);
1212 WRITE_OID_FIELD(resultcollid);
1213 WRITE_BOOL_FIELD(isExplicit);
1214 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1215 WRITE_LOCATION_FIELD(location);
1219 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1221 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1223 WRITE_NODE_FIELD(arg);
1224 WRITE_OID_FIELD(resulttype);
1225 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1226 WRITE_LOCATION_FIELD(location);
1230 _outCollateExpr(StringInfo str, const CollateExpr *node)
1232 WRITE_NODE_TYPE("COLLATE");
1234 WRITE_NODE_FIELD(arg);
1235 WRITE_OID_FIELD(collOid);
1236 WRITE_LOCATION_FIELD(location);
1240 _outCaseExpr(StringInfo str, const CaseExpr *node)
1242 WRITE_NODE_TYPE("CASE");
1244 WRITE_OID_FIELD(casetype);
1245 WRITE_OID_FIELD(casecollid);
1246 WRITE_NODE_FIELD(arg);
1247 WRITE_NODE_FIELD(args);
1248 WRITE_NODE_FIELD(defresult);
1249 WRITE_LOCATION_FIELD(location);
1253 _outCaseWhen(StringInfo str, const CaseWhen *node)
1255 WRITE_NODE_TYPE("WHEN");
1257 WRITE_NODE_FIELD(expr);
1258 WRITE_NODE_FIELD(result);
1259 WRITE_LOCATION_FIELD(location);
1263 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1265 WRITE_NODE_TYPE("CASETESTEXPR");
1267 WRITE_OID_FIELD(typeId);
1268 WRITE_INT_FIELD(typeMod);
1269 WRITE_OID_FIELD(collation);
1273 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1275 WRITE_NODE_TYPE("ARRAY");
1277 WRITE_OID_FIELD(array_typeid);
1278 WRITE_OID_FIELD(array_collid);
1279 WRITE_OID_FIELD(element_typeid);
1280 WRITE_NODE_FIELD(elements);
1281 WRITE_BOOL_FIELD(multidims);
1282 WRITE_LOCATION_FIELD(location);
1286 _outRowExpr(StringInfo str, const RowExpr *node)
1288 WRITE_NODE_TYPE("ROW");
1290 WRITE_NODE_FIELD(args);
1291 WRITE_OID_FIELD(row_typeid);
1292 WRITE_ENUM_FIELD(row_format, CoercionForm);
1293 WRITE_NODE_FIELD(colnames);
1294 WRITE_LOCATION_FIELD(location);
1298 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1300 WRITE_NODE_TYPE("ROWCOMPARE");
1302 WRITE_ENUM_FIELD(rctype, RowCompareType);
1303 WRITE_NODE_FIELD(opnos);
1304 WRITE_NODE_FIELD(opfamilies);
1305 WRITE_NODE_FIELD(inputcollids);
1306 WRITE_NODE_FIELD(largs);
1307 WRITE_NODE_FIELD(rargs);
1311 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1313 WRITE_NODE_TYPE("COALESCE");
1315 WRITE_OID_FIELD(coalescetype);
1316 WRITE_OID_FIELD(coalescecollid);
1317 WRITE_NODE_FIELD(args);
1318 WRITE_LOCATION_FIELD(location);
1322 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1324 WRITE_NODE_TYPE("MINMAX");
1326 WRITE_OID_FIELD(minmaxtype);
1327 WRITE_OID_FIELD(minmaxcollid);
1328 WRITE_OID_FIELD(inputcollid);
1329 WRITE_ENUM_FIELD(op, MinMaxOp);
1330 WRITE_NODE_FIELD(args);
1331 WRITE_LOCATION_FIELD(location);
1335 _outXmlExpr(StringInfo str, const XmlExpr *node)
1337 WRITE_NODE_TYPE("XMLEXPR");
1339 WRITE_ENUM_FIELD(op, XmlExprOp);
1340 WRITE_STRING_FIELD(name);
1341 WRITE_NODE_FIELD(named_args);
1342 WRITE_NODE_FIELD(arg_names);
1343 WRITE_NODE_FIELD(args);
1344 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1345 WRITE_OID_FIELD(type);
1346 WRITE_INT_FIELD(typmod);
1347 WRITE_LOCATION_FIELD(location);
1351 _outNullTest(StringInfo str, const NullTest *node)
1353 WRITE_NODE_TYPE("NULLTEST");
1355 WRITE_NODE_FIELD(arg);
1356 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1357 WRITE_BOOL_FIELD(argisrow);
1361 _outBooleanTest(StringInfo str, const BooleanTest *node)
1363 WRITE_NODE_TYPE("BOOLEANTEST");
1365 WRITE_NODE_FIELD(arg);
1366 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1370 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1372 WRITE_NODE_TYPE("COERCETODOMAIN");
1374 WRITE_NODE_FIELD(arg);
1375 WRITE_OID_FIELD(resulttype);
1376 WRITE_INT_FIELD(resulttypmod);
1377 WRITE_OID_FIELD(resultcollid);
1378 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1379 WRITE_LOCATION_FIELD(location);
1383 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1385 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1387 WRITE_OID_FIELD(typeId);
1388 WRITE_INT_FIELD(typeMod);
1389 WRITE_OID_FIELD(collation);
1390 WRITE_LOCATION_FIELD(location);
1394 _outSetToDefault(StringInfo str, const SetToDefault *node)
1396 WRITE_NODE_TYPE("SETTODEFAULT");
1398 WRITE_OID_FIELD(typeId);
1399 WRITE_INT_FIELD(typeMod);
1400 WRITE_OID_FIELD(collation);
1401 WRITE_LOCATION_FIELD(location);
1405 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1407 WRITE_NODE_TYPE("CURRENTOFEXPR");
1409 WRITE_UINT_FIELD(cvarno);
1410 WRITE_STRING_FIELD(cursor_name);
1411 WRITE_INT_FIELD(cursor_param);
1415 _outTargetEntry(StringInfo str, const TargetEntry *node)
1417 WRITE_NODE_TYPE("TARGETENTRY");
1419 WRITE_NODE_FIELD(expr);
1420 WRITE_INT_FIELD(resno);
1421 WRITE_STRING_FIELD(resname);
1422 WRITE_UINT_FIELD(ressortgroupref);
1423 WRITE_OID_FIELD(resorigtbl);
1424 WRITE_INT_FIELD(resorigcol);
1425 WRITE_BOOL_FIELD(resjunk);
1429 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1431 WRITE_NODE_TYPE("RANGETBLREF");
1433 WRITE_INT_FIELD(rtindex);
1437 _outJoinExpr(StringInfo str, const JoinExpr *node)
1439 WRITE_NODE_TYPE("JOINEXPR");
1441 WRITE_ENUM_FIELD(jointype, JoinType);
1442 WRITE_BOOL_FIELD(isNatural);
1443 WRITE_NODE_FIELD(larg);
1444 WRITE_NODE_FIELD(rarg);
1445 WRITE_NODE_FIELD(usingClause);
1446 WRITE_NODE_FIELD(quals);
1447 WRITE_NODE_FIELD(alias);
1448 WRITE_INT_FIELD(rtindex);
1452 _outFromExpr(StringInfo str, const FromExpr *node)
1454 WRITE_NODE_TYPE("FROMEXPR");
1456 WRITE_NODE_FIELD(fromlist);
1457 WRITE_NODE_FIELD(quals);
1460 /*****************************************************************************
1462 * Stuff from relation.h.
1464 *****************************************************************************/
1467 * print the basic stuff of all nodes that inherit from Path
1469 * Note we do NOT print the parent, else we'd be in infinite recursion.
1470 * We can print the parent's relids for identification purposes, though.
1473 _outPathInfo(StringInfo str, const Path *node)
1475 WRITE_ENUM_FIELD(pathtype, NodeTag);
1476 appendStringInfo(str, " :parent_relids ");
1477 _outBitmapset(str, node->parent->relids);
1478 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1479 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1480 WRITE_NODE_FIELD(pathkeys);
1484 * print the basic stuff of all nodes that inherit from JoinPath
1487 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1489 _outPathInfo(str, (const Path *) node);
1491 WRITE_ENUM_FIELD(jointype, JoinType);
1492 WRITE_NODE_FIELD(outerjoinpath);
1493 WRITE_NODE_FIELD(innerjoinpath);
1494 WRITE_NODE_FIELD(joinrestrictinfo);
1498 _outPath(StringInfo str, const Path *node)
1500 WRITE_NODE_TYPE("PATH");
1502 _outPathInfo(str, (const Path *) node);
1506 _outIndexPath(StringInfo str, const IndexPath *node)
1508 WRITE_NODE_TYPE("INDEXPATH");
1510 _outPathInfo(str, (const Path *) node);
1512 WRITE_NODE_FIELD(indexinfo);
1513 WRITE_NODE_FIELD(indexclauses);
1514 WRITE_NODE_FIELD(indexquals);
1515 WRITE_NODE_FIELD(indexorderbys);
1516 WRITE_BOOL_FIELD(isjoininner);
1517 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1518 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1519 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1520 WRITE_FLOAT_FIELD(rows, "%.0f");
1524 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1526 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1528 _outPathInfo(str, (const Path *) node);
1530 WRITE_NODE_FIELD(bitmapqual);
1531 WRITE_BOOL_FIELD(isjoininner);
1532 WRITE_FLOAT_FIELD(rows, "%.0f");
1536 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1538 WRITE_NODE_TYPE("BITMAPANDPATH");
1540 _outPathInfo(str, (const Path *) node);
1542 WRITE_NODE_FIELD(bitmapquals);
1543 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1547 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1549 WRITE_NODE_TYPE("BITMAPORPATH");
1551 _outPathInfo(str, (const Path *) node);
1553 WRITE_NODE_FIELD(bitmapquals);
1554 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1558 _outTidPath(StringInfo str, const TidPath *node)
1560 WRITE_NODE_TYPE("TIDPATH");
1562 _outPathInfo(str, (const Path *) node);
1564 WRITE_NODE_FIELD(tidquals);
1568 _outForeignPath(StringInfo str, const ForeignPath *node)
1570 WRITE_NODE_TYPE("FOREIGNPATH");
1572 _outPathInfo(str, (const Path *) node);
1574 WRITE_NODE_FIELD(fdwplan);
1578 _outAppendPath(StringInfo str, const AppendPath *node)
1580 WRITE_NODE_TYPE("APPENDPATH");
1582 _outPathInfo(str, (const Path *) node);
1584 WRITE_NODE_FIELD(subpaths);
1588 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1590 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1592 _outPathInfo(str, (const Path *) node);
1594 WRITE_NODE_FIELD(subpaths);
1595 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1599 _outResultPath(StringInfo str, const ResultPath *node)
1601 WRITE_NODE_TYPE("RESULTPATH");
1603 _outPathInfo(str, (const Path *) node);
1605 WRITE_NODE_FIELD(quals);
1609 _outMaterialPath(StringInfo str, const MaterialPath *node)
1611 WRITE_NODE_TYPE("MATERIALPATH");
1613 _outPathInfo(str, (const Path *) node);
1615 WRITE_NODE_FIELD(subpath);
1619 _outUniquePath(StringInfo str, const UniquePath *node)
1621 WRITE_NODE_TYPE("UNIQUEPATH");
1623 _outPathInfo(str, (const Path *) node);
1625 WRITE_NODE_FIELD(subpath);
1626 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1627 WRITE_NODE_FIELD(in_operators);
1628 WRITE_NODE_FIELD(uniq_exprs);
1629 WRITE_FLOAT_FIELD(rows, "%.0f");
1633 _outNestPath(StringInfo str, const NestPath *node)
1635 WRITE_NODE_TYPE("NESTPATH");
1637 _outJoinPathInfo(str, (const JoinPath *) node);
1641 _outMergePath(StringInfo str, const MergePath *node)
1643 WRITE_NODE_TYPE("MERGEPATH");
1645 _outJoinPathInfo(str, (const JoinPath *) node);
1647 WRITE_NODE_FIELD(path_mergeclauses);
1648 WRITE_NODE_FIELD(outersortkeys);
1649 WRITE_NODE_FIELD(innersortkeys);
1650 WRITE_BOOL_FIELD(materialize_inner);
1654 _outHashPath(StringInfo str, const HashPath *node)
1656 WRITE_NODE_TYPE("HASHPATH");
1658 _outJoinPathInfo(str, (const JoinPath *) node);
1660 WRITE_NODE_FIELD(path_hashclauses);
1661 WRITE_INT_FIELD(num_batches);
1665 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
1667 WRITE_NODE_TYPE("PLANNERGLOBAL");
1669 /* NB: this isn't a complete set of fields */
1670 WRITE_NODE_FIELD(paramlist);
1671 WRITE_NODE_FIELD(subplans);
1672 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1673 WRITE_NODE_FIELD(finalrtable);
1674 WRITE_NODE_FIELD(finalrowmarks);
1675 WRITE_NODE_FIELD(resultRelations);
1676 WRITE_NODE_FIELD(relationOids);
1677 WRITE_NODE_FIELD(invalItems);
1678 WRITE_UINT_FIELD(lastPHId);
1679 WRITE_UINT_FIELD(lastRowMarkId);
1680 WRITE_BOOL_FIELD(transientPlan);
1684 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
1686 WRITE_NODE_TYPE("PLANNERINFO");
1688 /* NB: this isn't a complete set of fields */
1689 WRITE_NODE_FIELD(parse);
1690 WRITE_NODE_FIELD(glob);
1691 WRITE_UINT_FIELD(query_level);
1692 WRITE_NODE_FIELD(join_rel_list);
1693 WRITE_INT_FIELD(join_cur_level);
1694 WRITE_NODE_FIELD(init_plans);
1695 WRITE_NODE_FIELD(cte_plan_ids);
1696 WRITE_NODE_FIELD(eq_classes);
1697 WRITE_NODE_FIELD(canon_pathkeys);
1698 WRITE_NODE_FIELD(left_join_clauses);
1699 WRITE_NODE_FIELD(right_join_clauses);
1700 WRITE_NODE_FIELD(full_join_clauses);
1701 WRITE_NODE_FIELD(join_info_list);
1702 WRITE_NODE_FIELD(append_rel_list);
1703 WRITE_NODE_FIELD(rowMarks);
1704 WRITE_NODE_FIELD(placeholder_list);
1705 WRITE_NODE_FIELD(query_pathkeys);
1706 WRITE_NODE_FIELD(group_pathkeys);
1707 WRITE_NODE_FIELD(window_pathkeys);
1708 WRITE_NODE_FIELD(distinct_pathkeys);
1709 WRITE_NODE_FIELD(sort_pathkeys);
1710 WRITE_NODE_FIELD(minmax_aggs);
1711 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1712 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1713 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1714 WRITE_BOOL_FIELD(hasInheritedTarget);
1715 WRITE_BOOL_FIELD(hasJoinRTEs);
1716 WRITE_BOOL_FIELD(hasHavingQual);
1717 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1718 WRITE_BOOL_FIELD(hasRecursion);
1719 WRITE_INT_FIELD(wt_param_id);
1720 WRITE_BITMAPSET_FIELD(curOuterRels);
1721 WRITE_NODE_FIELD(curOuterParams);
1725 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
1727 WRITE_NODE_TYPE("RELOPTINFO");
1729 /* NB: this isn't a complete set of fields */
1730 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1731 WRITE_BITMAPSET_FIELD(relids);
1732 WRITE_FLOAT_FIELD(rows, "%.0f");
1733 WRITE_INT_FIELD(width);
1734 WRITE_NODE_FIELD(reltargetlist);
1735 WRITE_NODE_FIELD(pathlist);
1736 WRITE_NODE_FIELD(cheapest_startup_path);
1737 WRITE_NODE_FIELD(cheapest_total_path);
1738 WRITE_NODE_FIELD(cheapest_unique_path);
1739 WRITE_UINT_FIELD(relid);
1740 WRITE_UINT_FIELD(reltablespace);
1741 WRITE_ENUM_FIELD(rtekind, RTEKind);
1742 WRITE_INT_FIELD(min_attr);
1743 WRITE_INT_FIELD(max_attr);
1744 WRITE_NODE_FIELD(indexlist);
1745 WRITE_UINT_FIELD(pages);
1746 WRITE_FLOAT_FIELD(tuples, "%.0f");
1747 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
1748 WRITE_NODE_FIELD(subplan);
1749 WRITE_NODE_FIELD(subroot);
1750 WRITE_NODE_FIELD(baserestrictinfo);
1751 WRITE_NODE_FIELD(joininfo);
1752 WRITE_BOOL_FIELD(has_eclass_joins);
1753 WRITE_BITMAPSET_FIELD(index_outer_relids);
1754 WRITE_NODE_FIELD(index_inner_paths);
1758 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
1760 WRITE_NODE_TYPE("INDEXOPTINFO");
1762 /* NB: this isn't a complete set of fields */
1763 WRITE_OID_FIELD(indexoid);
1764 /* Do NOT print rel field, else infinite recursion */
1765 WRITE_UINT_FIELD(pages);
1766 WRITE_FLOAT_FIELD(tuples, "%.0f");
1767 WRITE_INT_FIELD(ncolumns);
1768 WRITE_OID_FIELD(relam);
1769 /* indexprs is redundant since we print indextlist */
1770 WRITE_NODE_FIELD(indpred);
1771 WRITE_NODE_FIELD(indextlist);
1772 WRITE_BOOL_FIELD(predOK);
1773 WRITE_BOOL_FIELD(unique);
1774 WRITE_BOOL_FIELD(immediate);
1775 WRITE_BOOL_FIELD(hypothetical);
1779 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
1782 * To simplify reading, we just chase up to the topmost merged EC and
1783 * print that, without bothering to show the merge-ees separately.
1785 while (node->ec_merged)
1786 node = node->ec_merged;
1788 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1790 WRITE_NODE_FIELD(ec_opfamilies);
1791 WRITE_OID_FIELD(ec_collation);
1792 WRITE_NODE_FIELD(ec_members);
1793 WRITE_NODE_FIELD(ec_sources);
1794 WRITE_NODE_FIELD(ec_derives);
1795 WRITE_BITMAPSET_FIELD(ec_relids);
1796 WRITE_BOOL_FIELD(ec_has_const);
1797 WRITE_BOOL_FIELD(ec_has_volatile);
1798 WRITE_BOOL_FIELD(ec_below_outer_join);
1799 WRITE_BOOL_FIELD(ec_broken);
1800 WRITE_UINT_FIELD(ec_sortref);
1804 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
1806 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1808 WRITE_NODE_FIELD(em_expr);
1809 WRITE_BITMAPSET_FIELD(em_relids);
1810 WRITE_BOOL_FIELD(em_is_const);
1811 WRITE_BOOL_FIELD(em_is_child);
1812 WRITE_OID_FIELD(em_datatype);
1816 _outPathKey(StringInfo str, const PathKey *node)
1818 WRITE_NODE_TYPE("PATHKEY");
1820 WRITE_NODE_FIELD(pk_eclass);
1821 WRITE_OID_FIELD(pk_opfamily);
1822 WRITE_INT_FIELD(pk_strategy);
1823 WRITE_BOOL_FIELD(pk_nulls_first);
1827 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
1829 WRITE_NODE_TYPE("RESTRICTINFO");
1831 /* NB: this isn't a complete set of fields */
1832 WRITE_NODE_FIELD(clause);
1833 WRITE_BOOL_FIELD(is_pushed_down);
1834 WRITE_BOOL_FIELD(outerjoin_delayed);
1835 WRITE_BOOL_FIELD(can_join);
1836 WRITE_BOOL_FIELD(pseudoconstant);
1837 WRITE_BITMAPSET_FIELD(clause_relids);
1838 WRITE_BITMAPSET_FIELD(required_relids);
1839 WRITE_BITMAPSET_FIELD(nullable_relids);
1840 WRITE_BITMAPSET_FIELD(left_relids);
1841 WRITE_BITMAPSET_FIELD(right_relids);
1842 WRITE_NODE_FIELD(orclause);
1843 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1844 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1845 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1846 WRITE_NODE_FIELD(mergeopfamilies);
1847 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1848 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1849 WRITE_NODE_FIELD(left_em);
1850 WRITE_NODE_FIELD(right_em);
1851 WRITE_BOOL_FIELD(outer_is_left);
1852 WRITE_OID_FIELD(hashjoinoperator);
1856 _outInnerIndexscanInfo(StringInfo str, const InnerIndexscanInfo *node)
1858 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1859 WRITE_BITMAPSET_FIELD(other_relids);
1860 WRITE_BOOL_FIELD(isouterjoin);
1861 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1862 WRITE_NODE_FIELD(cheapest_total_innerpath);
1866 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
1868 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1870 WRITE_NODE_FIELD(phexpr);
1871 WRITE_BITMAPSET_FIELD(phrels);
1872 WRITE_UINT_FIELD(phid);
1873 WRITE_UINT_FIELD(phlevelsup);
1877 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
1879 WRITE_NODE_TYPE("SPECIALJOININFO");
1881 WRITE_BITMAPSET_FIELD(min_lefthand);
1882 WRITE_BITMAPSET_FIELD(min_righthand);
1883 WRITE_BITMAPSET_FIELD(syn_lefthand);
1884 WRITE_BITMAPSET_FIELD(syn_righthand);
1885 WRITE_ENUM_FIELD(jointype, JoinType);
1886 WRITE_BOOL_FIELD(lhs_strict);
1887 WRITE_BOOL_FIELD(delay_upper_joins);
1888 WRITE_NODE_FIELD(join_quals);
1892 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
1894 WRITE_NODE_TYPE("APPENDRELINFO");
1896 WRITE_UINT_FIELD(parent_relid);
1897 WRITE_UINT_FIELD(child_relid);
1898 WRITE_OID_FIELD(parent_reltype);
1899 WRITE_OID_FIELD(child_reltype);
1900 WRITE_NODE_FIELD(translated_vars);
1901 WRITE_OID_FIELD(parent_reloid);
1905 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
1907 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1909 WRITE_UINT_FIELD(phid);
1910 WRITE_NODE_FIELD(ph_var);
1911 WRITE_BITMAPSET_FIELD(ph_eval_at);
1912 WRITE_BITMAPSET_FIELD(ph_needed);
1913 WRITE_BITMAPSET_FIELD(ph_may_need);
1914 WRITE_INT_FIELD(ph_width);
1918 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
1920 WRITE_NODE_TYPE("MINMAXAGGINFO");
1922 WRITE_OID_FIELD(aggfnoid);
1923 WRITE_OID_FIELD(aggsortop);
1924 WRITE_NODE_FIELD(target);
1925 /* We intentionally omit subroot --- too large, not interesting enough */
1926 WRITE_NODE_FIELD(path);
1927 WRITE_FLOAT_FIELD(pathcost, "%.2f");
1928 WRITE_NODE_FIELD(param);
1932 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
1934 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1936 WRITE_NODE_FIELD(item);
1937 WRITE_UINT_FIELD(abslevel);
1940 /*****************************************************************************
1942 * Stuff from parsenodes.h.
1944 *****************************************************************************/
1947 _outCreateStmt(StringInfo str, const CreateStmt *node)
1949 WRITE_NODE_TYPE("CREATESTMT");
1951 WRITE_NODE_FIELD(relation);
1952 WRITE_NODE_FIELD(tableElts);
1953 WRITE_NODE_FIELD(inhRelations);
1954 WRITE_NODE_FIELD(ofTypename);
1955 WRITE_NODE_FIELD(constraints);
1956 WRITE_NODE_FIELD(options);
1957 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1958 WRITE_STRING_FIELD(tablespacename);
1959 WRITE_BOOL_FIELD(if_not_exists);
1963 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
1965 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
1967 _outCreateStmt(str, (const CreateStmt *) &node->base);
1969 WRITE_STRING_FIELD(servername);
1970 WRITE_NODE_FIELD(options);
1974 _outIndexStmt(StringInfo str, const IndexStmt *node)
1976 WRITE_NODE_TYPE("INDEXSTMT");
1978 WRITE_STRING_FIELD(idxname);
1979 WRITE_NODE_FIELD(relation);
1980 WRITE_STRING_FIELD(accessMethod);
1981 WRITE_STRING_FIELD(tableSpace);
1982 WRITE_NODE_FIELD(indexParams);
1983 WRITE_NODE_FIELD(options);
1984 WRITE_NODE_FIELD(whereClause);
1985 WRITE_NODE_FIELD(excludeOpNames);
1986 WRITE_OID_FIELD(indexOid);
1987 WRITE_OID_FIELD(oldNode);
1988 WRITE_BOOL_FIELD(unique);
1989 WRITE_BOOL_FIELD(primary);
1990 WRITE_BOOL_FIELD(isconstraint);
1991 WRITE_BOOL_FIELD(deferrable);
1992 WRITE_BOOL_FIELD(initdeferred);
1993 WRITE_BOOL_FIELD(concurrent);
1997 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
1999 WRITE_NODE_TYPE("NOTIFY");
2001 WRITE_STRING_FIELD(conditionname);
2002 WRITE_STRING_FIELD(payload);
2006 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2008 WRITE_NODE_TYPE("DECLARECURSOR");
2010 WRITE_STRING_FIELD(portalname);
2011 WRITE_INT_FIELD(options);
2012 WRITE_NODE_FIELD(query);
2016 _outSelectStmt(StringInfo str, const SelectStmt *node)
2018 WRITE_NODE_TYPE("SELECT");
2020 WRITE_NODE_FIELD(distinctClause);
2021 WRITE_NODE_FIELD(intoClause);
2022 WRITE_NODE_FIELD(targetList);
2023 WRITE_NODE_FIELD(fromClause);
2024 WRITE_NODE_FIELD(whereClause);
2025 WRITE_NODE_FIELD(groupClause);
2026 WRITE_NODE_FIELD(havingClause);
2027 WRITE_NODE_FIELD(windowClause);
2028 WRITE_NODE_FIELD(withClause);
2029 WRITE_NODE_FIELD(valuesLists);
2030 WRITE_NODE_FIELD(sortClause);
2031 WRITE_NODE_FIELD(limitOffset);
2032 WRITE_NODE_FIELD(limitCount);
2033 WRITE_NODE_FIELD(lockingClause);
2034 WRITE_ENUM_FIELD(op, SetOperation);
2035 WRITE_BOOL_FIELD(all);
2036 WRITE_NODE_FIELD(larg);
2037 WRITE_NODE_FIELD(rarg);
2041 _outFuncCall(StringInfo str, const FuncCall *node)
2043 WRITE_NODE_TYPE("FUNCCALL");
2045 WRITE_NODE_FIELD(funcname);
2046 WRITE_NODE_FIELD(args);
2047 WRITE_NODE_FIELD(agg_order);
2048 WRITE_BOOL_FIELD(agg_star);
2049 WRITE_BOOL_FIELD(agg_distinct);
2050 WRITE_BOOL_FIELD(func_variadic);
2051 WRITE_NODE_FIELD(over);
2052 WRITE_LOCATION_FIELD(location);
2056 _outDefElem(StringInfo str, const DefElem *node)
2058 WRITE_NODE_TYPE("DEFELEM");
2060 WRITE_STRING_FIELD(defnamespace);
2061 WRITE_STRING_FIELD(defname);
2062 WRITE_NODE_FIELD(arg);
2063 WRITE_ENUM_FIELD(defaction, DefElemAction);
2067 _outInhRelation(StringInfo str, const InhRelation *node)
2069 WRITE_NODE_TYPE("INHRELATION");
2071 WRITE_NODE_FIELD(relation);
2072 WRITE_UINT_FIELD(options);
2076 _outLockingClause(StringInfo str, const LockingClause *node)
2078 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2080 WRITE_NODE_FIELD(lockedRels);
2081 WRITE_BOOL_FIELD(forUpdate);
2082 WRITE_BOOL_FIELD(noWait);
2086 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2088 WRITE_NODE_TYPE("XMLSERIALIZE");
2090 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2091 WRITE_NODE_FIELD(expr);
2092 WRITE_NODE_FIELD(typeName);
2093 WRITE_LOCATION_FIELD(location);
2097 _outColumnDef(StringInfo str, const ColumnDef *node)
2099 WRITE_NODE_TYPE("COLUMNDEF");
2101 WRITE_STRING_FIELD(colname);
2102 WRITE_NODE_FIELD(typeName);
2103 WRITE_INT_FIELD(inhcount);
2104 WRITE_BOOL_FIELD(is_local);
2105 WRITE_BOOL_FIELD(is_not_null);
2106 WRITE_BOOL_FIELD(is_from_type);
2107 WRITE_INT_FIELD(storage);
2108 WRITE_NODE_FIELD(raw_default);
2109 WRITE_NODE_FIELD(cooked_default);
2110 WRITE_NODE_FIELD(collClause);
2111 WRITE_OID_FIELD(collOid);
2112 WRITE_NODE_FIELD(constraints);
2113 WRITE_NODE_FIELD(fdwoptions);
2117 _outTypeName(StringInfo str, const TypeName *node)
2119 WRITE_NODE_TYPE("TYPENAME");
2121 WRITE_NODE_FIELD(names);
2122 WRITE_OID_FIELD(typeOid);
2123 WRITE_BOOL_FIELD(setof);
2124 WRITE_BOOL_FIELD(pct_type);
2125 WRITE_NODE_FIELD(typmods);
2126 WRITE_INT_FIELD(typemod);
2127 WRITE_NODE_FIELD(arrayBounds);
2128 WRITE_LOCATION_FIELD(location);
2132 _outTypeCast(StringInfo str, const TypeCast *node)
2134 WRITE_NODE_TYPE("TYPECAST");
2136 WRITE_NODE_FIELD(arg);
2137 WRITE_NODE_FIELD(typeName);
2138 WRITE_LOCATION_FIELD(location);
2142 _outCollateClause(StringInfo str, const CollateClause *node)
2144 WRITE_NODE_TYPE("COLLATECLAUSE");
2146 WRITE_NODE_FIELD(arg);
2147 WRITE_NODE_FIELD(collname);
2148 WRITE_LOCATION_FIELD(location);
2152 _outIndexElem(StringInfo str, const IndexElem *node)
2154 WRITE_NODE_TYPE("INDEXELEM");
2156 WRITE_STRING_FIELD(name);
2157 WRITE_NODE_FIELD(expr);
2158 WRITE_STRING_FIELD(indexcolname);
2159 WRITE_NODE_FIELD(collation);
2160 WRITE_NODE_FIELD(opclass);
2161 WRITE_ENUM_FIELD(ordering, SortByDir);
2162 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2166 _outQuery(StringInfo str, const Query *node)
2168 WRITE_NODE_TYPE("QUERY");
2170 WRITE_ENUM_FIELD(commandType, CmdType);
2171 WRITE_ENUM_FIELD(querySource, QuerySource);
2172 WRITE_BOOL_FIELD(canSetTag);
2175 * Hack to work around missing outfuncs routines for a lot of the
2176 * utility-statement node types. (The only one we actually *need* for
2177 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2178 * for the meantime do this to avoid getting lots of warnings when running
2179 * with debug_print_parse on.
2181 if (node->utilityStmt)
2183 switch (nodeTag(node->utilityStmt))
2188 case T_DeclareCursorStmt:
2189 WRITE_NODE_FIELD(utilityStmt);
2192 appendStringInfo(str, " :utilityStmt ?");
2197 appendStringInfo(str, " :utilityStmt <>");
2199 WRITE_INT_FIELD(resultRelation);
2200 WRITE_NODE_FIELD(intoClause);
2201 WRITE_BOOL_FIELD(hasAggs);
2202 WRITE_BOOL_FIELD(hasWindowFuncs);
2203 WRITE_BOOL_FIELD(hasSubLinks);
2204 WRITE_BOOL_FIELD(hasDistinctOn);
2205 WRITE_BOOL_FIELD(hasRecursive);
2206 WRITE_BOOL_FIELD(hasModifyingCTE);
2207 WRITE_BOOL_FIELD(hasForUpdate);
2208 WRITE_NODE_FIELD(cteList);
2209 WRITE_NODE_FIELD(rtable);
2210 WRITE_NODE_FIELD(jointree);
2211 WRITE_NODE_FIELD(targetList);
2212 WRITE_NODE_FIELD(returningList);
2213 WRITE_NODE_FIELD(groupClause);
2214 WRITE_NODE_FIELD(havingQual);
2215 WRITE_NODE_FIELD(windowClause);
2216 WRITE_NODE_FIELD(distinctClause);
2217 WRITE_NODE_FIELD(sortClause);
2218 WRITE_NODE_FIELD(limitOffset);
2219 WRITE_NODE_FIELD(limitCount);
2220 WRITE_NODE_FIELD(rowMarks);
2221 WRITE_NODE_FIELD(setOperations);
2222 WRITE_NODE_FIELD(constraintDeps);
2226 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2228 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2230 WRITE_UINT_FIELD(tleSortGroupRef);
2231 WRITE_OID_FIELD(eqop);
2232 WRITE_OID_FIELD(sortop);
2233 WRITE_BOOL_FIELD(nulls_first);
2234 WRITE_BOOL_FIELD(hashable);
2238 _outWindowClause(StringInfo str, const WindowClause *node)
2240 WRITE_NODE_TYPE("WINDOWCLAUSE");
2242 WRITE_STRING_FIELD(name);
2243 WRITE_STRING_FIELD(refname);
2244 WRITE_NODE_FIELD(partitionClause);
2245 WRITE_NODE_FIELD(orderClause);
2246 WRITE_INT_FIELD(frameOptions);
2247 WRITE_NODE_FIELD(startOffset);
2248 WRITE_NODE_FIELD(endOffset);
2249 WRITE_UINT_FIELD(winref);
2250 WRITE_BOOL_FIELD(copiedOrder);
2254 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
2256 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2258 WRITE_UINT_FIELD(rti);
2259 WRITE_BOOL_FIELD(forUpdate);
2260 WRITE_BOOL_FIELD(noWait);
2261 WRITE_BOOL_FIELD(pushedDown);
2265 _outWithClause(StringInfo str, const WithClause *node)
2267 WRITE_NODE_TYPE("WITHCLAUSE");
2269 WRITE_NODE_FIELD(ctes);
2270 WRITE_BOOL_FIELD(recursive);
2271 WRITE_LOCATION_FIELD(location);
2275 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
2277 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2279 WRITE_STRING_FIELD(ctename);
2280 WRITE_NODE_FIELD(aliascolnames);
2281 WRITE_NODE_FIELD(ctequery);
2282 WRITE_LOCATION_FIELD(location);
2283 WRITE_BOOL_FIELD(cterecursive);
2284 WRITE_INT_FIELD(cterefcount);
2285 WRITE_NODE_FIELD(ctecolnames);
2286 WRITE_NODE_FIELD(ctecoltypes);
2287 WRITE_NODE_FIELD(ctecoltypmods);
2288 WRITE_NODE_FIELD(ctecolcollations);
2292 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
2294 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2296 WRITE_ENUM_FIELD(op, SetOperation);
2297 WRITE_BOOL_FIELD(all);
2298 WRITE_NODE_FIELD(larg);
2299 WRITE_NODE_FIELD(rarg);
2300 WRITE_NODE_FIELD(colTypes);
2301 WRITE_NODE_FIELD(colTypmods);
2302 WRITE_NODE_FIELD(colCollations);
2303 WRITE_NODE_FIELD(groupClauses);
2307 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
2309 WRITE_NODE_TYPE("RTE");
2311 /* put alias + eref first to make dump more legible */
2312 WRITE_NODE_FIELD(alias);
2313 WRITE_NODE_FIELD(eref);
2314 WRITE_ENUM_FIELD(rtekind, RTEKind);
2316 switch (node->rtekind)
2319 WRITE_OID_FIELD(relid);
2320 WRITE_CHAR_FIELD(relkind);
2323 WRITE_NODE_FIELD(subquery);
2324 WRITE_BOOL_FIELD(security_barrier);
2327 WRITE_ENUM_FIELD(jointype, JoinType);
2328 WRITE_NODE_FIELD(joinaliasvars);
2331 WRITE_NODE_FIELD(funcexpr);
2332 WRITE_NODE_FIELD(funccoltypes);
2333 WRITE_NODE_FIELD(funccoltypmods);
2334 WRITE_NODE_FIELD(funccolcollations);
2337 WRITE_NODE_FIELD(values_lists);
2338 WRITE_NODE_FIELD(values_collations);
2341 WRITE_STRING_FIELD(ctename);
2342 WRITE_UINT_FIELD(ctelevelsup);
2343 WRITE_BOOL_FIELD(self_reference);
2344 WRITE_NODE_FIELD(ctecoltypes);
2345 WRITE_NODE_FIELD(ctecoltypmods);
2346 WRITE_NODE_FIELD(ctecolcollations);
2349 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2353 WRITE_BOOL_FIELD(inh);
2354 WRITE_BOOL_FIELD(inFromCl);
2355 WRITE_UINT_FIELD(requiredPerms);
2356 WRITE_OID_FIELD(checkAsUser);
2357 WRITE_BITMAPSET_FIELD(selectedCols);
2358 WRITE_BITMAPSET_FIELD(modifiedCols);
2362 _outAExpr(StringInfo str, const A_Expr *node)
2364 WRITE_NODE_TYPE("AEXPR");
2369 appendStringInfo(str, " ");
2370 WRITE_NODE_FIELD(name);
2373 appendStringInfo(str, " AND");
2376 appendStringInfo(str, " OR");
2379 appendStringInfo(str, " NOT");
2382 appendStringInfo(str, " ");
2383 WRITE_NODE_FIELD(name);
2384 appendStringInfo(str, " ANY ");
2387 appendStringInfo(str, " ");
2388 WRITE_NODE_FIELD(name);
2389 appendStringInfo(str, " ALL ");
2391 case AEXPR_DISTINCT:
2392 appendStringInfo(str, " DISTINCT ");
2393 WRITE_NODE_FIELD(name);
2396 appendStringInfo(str, " NULLIF ");
2397 WRITE_NODE_FIELD(name);
2400 appendStringInfo(str, " OF ");
2401 WRITE_NODE_FIELD(name);
2404 appendStringInfo(str, " IN ");
2405 WRITE_NODE_FIELD(name);
2408 appendStringInfo(str, " ??");
2412 WRITE_NODE_FIELD(lexpr);
2413 WRITE_NODE_FIELD(rexpr);
2414 WRITE_LOCATION_FIELD(location);
2418 _outValue(StringInfo str, const Value *value)
2420 switch (value->type)
2423 appendStringInfo(str, "%ld", value->val.ival);
2428 * We assume the value is a valid numeric literal and so does not
2431 appendStringInfoString(str, value->val.str);
2434 appendStringInfoChar(str, '"');
2435 _outToken(str, value->val.str);
2436 appendStringInfoChar(str, '"');
2439 /* internal representation already has leading 'b' */
2440 appendStringInfoString(str, value->val.str);
2443 /* this is seen only within A_Const, not in transformed trees */
2444 appendStringInfoString(str, "NULL");
2447 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2453 _outColumnRef(StringInfo str, const ColumnRef *node)
2455 WRITE_NODE_TYPE("COLUMNREF");
2457 WRITE_NODE_FIELD(fields);
2458 WRITE_LOCATION_FIELD(location);
2462 _outParamRef(StringInfo str, const ParamRef *node)
2464 WRITE_NODE_TYPE("PARAMREF");
2466 WRITE_INT_FIELD(number);
2467 WRITE_LOCATION_FIELD(location);
2471 _outAConst(StringInfo str, const A_Const *node)
2473 WRITE_NODE_TYPE("A_CONST");
2475 appendStringInfo(str, " :val ");
2476 _outValue(str, &(node->val));
2477 WRITE_LOCATION_FIELD(location);
2481 _outA_Star(StringInfo str, const A_Star *node)
2483 WRITE_NODE_TYPE("A_STAR");
2487 _outA_Indices(StringInfo str, const A_Indices *node)
2489 WRITE_NODE_TYPE("A_INDICES");
2491 WRITE_NODE_FIELD(lidx);
2492 WRITE_NODE_FIELD(uidx);
2496 _outA_Indirection(StringInfo str, const A_Indirection *node)
2498 WRITE_NODE_TYPE("A_INDIRECTION");
2500 WRITE_NODE_FIELD(arg);
2501 WRITE_NODE_FIELD(indirection);
2505 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
2507 WRITE_NODE_TYPE("A_ARRAYEXPR");
2509 WRITE_NODE_FIELD(elements);
2510 WRITE_LOCATION_FIELD(location);
2514 _outResTarget(StringInfo str, const ResTarget *node)
2516 WRITE_NODE_TYPE("RESTARGET");
2518 WRITE_STRING_FIELD(name);
2519 WRITE_NODE_FIELD(indirection);
2520 WRITE_NODE_FIELD(val);
2521 WRITE_LOCATION_FIELD(location);
2525 _outSortBy(StringInfo str, const SortBy *node)
2527 WRITE_NODE_TYPE("SORTBY");
2529 WRITE_NODE_FIELD(node);
2530 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2531 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2532 WRITE_NODE_FIELD(useOp);
2533 WRITE_LOCATION_FIELD(location);
2537 _outWindowDef(StringInfo str, const WindowDef *node)
2539 WRITE_NODE_TYPE("WINDOWDEF");
2541 WRITE_STRING_FIELD(name);
2542 WRITE_STRING_FIELD(refname);
2543 WRITE_NODE_FIELD(partitionClause);
2544 WRITE_NODE_FIELD(orderClause);
2545 WRITE_INT_FIELD(frameOptions);
2546 WRITE_NODE_FIELD(startOffset);
2547 WRITE_NODE_FIELD(endOffset);
2548 WRITE_LOCATION_FIELD(location);
2552 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
2554 WRITE_NODE_TYPE("RANGESUBSELECT");
2556 WRITE_NODE_FIELD(subquery);
2557 WRITE_NODE_FIELD(alias);
2561 _outRangeFunction(StringInfo str, const RangeFunction *node)
2563 WRITE_NODE_TYPE("RANGEFUNCTION");
2565 WRITE_NODE_FIELD(funccallnode);
2566 WRITE_NODE_FIELD(alias);
2567 WRITE_NODE_FIELD(coldeflist);
2571 _outConstraint(StringInfo str, const Constraint *node)
2573 WRITE_NODE_TYPE("CONSTRAINT");
2575 WRITE_STRING_FIELD(conname);
2576 WRITE_BOOL_FIELD(deferrable);
2577 WRITE_BOOL_FIELD(initdeferred);
2578 WRITE_LOCATION_FIELD(location);
2580 appendStringInfo(str, " :contype ");
2581 switch (node->contype)
2584 appendStringInfo(str, "NULL");
2587 case CONSTR_NOTNULL:
2588 appendStringInfo(str, "NOT_NULL");
2591 case CONSTR_DEFAULT:
2592 appendStringInfo(str, "DEFAULT");
2593 WRITE_NODE_FIELD(raw_expr);
2594 WRITE_STRING_FIELD(cooked_expr);
2598 appendStringInfo(str, "CHECK");
2599 WRITE_NODE_FIELD(raw_expr);
2600 WRITE_STRING_FIELD(cooked_expr);
2603 case CONSTR_PRIMARY:
2604 appendStringInfo(str, "PRIMARY_KEY");
2605 WRITE_NODE_FIELD(keys);
2606 WRITE_NODE_FIELD(options);
2607 WRITE_STRING_FIELD(indexname);
2608 WRITE_STRING_FIELD(indexspace);
2609 /* access_method and where_clause not currently used */
2613 appendStringInfo(str, "UNIQUE");
2614 WRITE_NODE_FIELD(keys);
2615 WRITE_NODE_FIELD(options);
2616 WRITE_STRING_FIELD(indexname);
2617 WRITE_STRING_FIELD(indexspace);
2618 /* access_method and where_clause not currently used */
2621 case CONSTR_EXCLUSION:
2622 appendStringInfo(str, "EXCLUSION");
2623 WRITE_NODE_FIELD(exclusions);
2624 WRITE_NODE_FIELD(options);
2625 WRITE_STRING_FIELD(indexname);
2626 WRITE_STRING_FIELD(indexspace);
2627 WRITE_STRING_FIELD(access_method);
2628 WRITE_NODE_FIELD(where_clause);
2631 case CONSTR_FOREIGN:
2632 appendStringInfo(str, "FOREIGN_KEY");
2633 WRITE_NODE_FIELD(pktable);
2634 WRITE_NODE_FIELD(fk_attrs);
2635 WRITE_NODE_FIELD(pk_attrs);
2636 WRITE_CHAR_FIELD(fk_matchtype);
2637 WRITE_CHAR_FIELD(fk_upd_action);
2638 WRITE_CHAR_FIELD(fk_del_action);
2639 WRITE_BOOL_FIELD(skip_validation);
2640 WRITE_BOOL_FIELD(initially_valid);
2643 case CONSTR_ATTR_DEFERRABLE:
2644 appendStringInfo(str, "ATTR_DEFERRABLE");
2647 case CONSTR_ATTR_NOT_DEFERRABLE:
2648 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2651 case CONSTR_ATTR_DEFERRED:
2652 appendStringInfo(str, "ATTR_DEFERRED");
2655 case CONSTR_ATTR_IMMEDIATE:
2656 appendStringInfo(str, "ATTR_IMMEDIATE");
2660 appendStringInfo(str, "<unrecognized_constraint %d>",
2661 (int) node->contype);
2669 * converts a Node into ascii string and append it to 'str'
2672 _outNode(StringInfo str, const void *obj)
2675 appendStringInfo(str, "<>");
2676 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2678 else if (IsA(obj, Integer) ||
2681 IsA(obj, BitString))
2683 /* nodeRead does not want to see { } around these! */
2684 _outValue(str, obj);
2688 appendStringInfoChar(str, '{');
2689 switch (nodeTag(obj))
2692 _outPlannedStmt(str, obj);
2698 _outResult(str, obj);
2701 _outModifyTable(str, obj);
2704 _outAppend(str, obj);
2707 _outMergeAppend(str, obj);
2709 case T_RecursiveUnion:
2710 _outRecursiveUnion(str, obj);
2713 _outBitmapAnd(str, obj);
2716 _outBitmapOr(str, obj);
2722 _outSeqScan(str, obj);
2725 _outIndexScan(str, obj);
2727 case T_IndexOnlyScan:
2728 _outIndexOnlyScan(str, obj);
2730 case T_BitmapIndexScan:
2731 _outBitmapIndexScan(str, obj);
2733 case T_BitmapHeapScan:
2734 _outBitmapHeapScan(str, obj);
2737 _outTidScan(str, obj);
2739 case T_SubqueryScan:
2740 _outSubqueryScan(str, obj);
2742 case T_FunctionScan:
2743 _outFunctionScan(str, obj);
2746 _outValuesScan(str, obj);
2749 _outCteScan(str, obj);
2751 case T_WorkTableScan:
2752 _outWorkTableScan(str, obj);
2755 _outForeignScan(str, obj);
2758 _outFdwPlan(str, obj);
2764 _outNestLoop(str, obj);
2767 _outMergeJoin(str, obj);
2770 _outHashJoin(str, obj);
2776 _outWindowAgg(str, obj);
2779 _outGroup(str, obj);
2782 _outMaterial(str, obj);
2788 _outUnique(str, obj);
2794 _outSetOp(str, obj);
2797 _outLockRows(str, obj);
2800 _outLimit(str, obj);
2802 case T_NestLoopParam:
2803 _outNestLoopParam(str, obj);
2806 _outPlanRowMark(str, obj);
2808 case T_PlanInvalItem:
2809 _outPlanInvalItem(str, obj);
2812 _outAlias(str, obj);
2815 _outRangeVar(str, obj);
2818 _outIntoClause(str, obj);
2824 _outConst(str, obj);
2827 _outParam(str, obj);
2830 _outAggref(str, obj);
2833 _outWindowFunc(str, obj);
2836 _outArrayRef(str, obj);
2839 _outFuncExpr(str, obj);
2841 case T_NamedArgExpr:
2842 _outNamedArgExpr(str, obj);
2845 _outOpExpr(str, obj);
2847 case T_DistinctExpr:
2848 _outDistinctExpr(str, obj);
2851 _outNullIfExpr(str, obj);
2853 case T_ScalarArrayOpExpr:
2854 _outScalarArrayOpExpr(str, obj);
2857 _outBoolExpr(str, obj);
2860 _outSubLink(str, obj);
2863 _outSubPlan(str, obj);
2865 case T_AlternativeSubPlan:
2866 _outAlternativeSubPlan(str, obj);
2869 _outFieldSelect(str, obj);
2872 _outFieldStore(str, obj);
2875 _outRelabelType(str, obj);
2878 _outCoerceViaIO(str, obj);
2880 case T_ArrayCoerceExpr:
2881 _outArrayCoerceExpr(str, obj);
2883 case T_ConvertRowtypeExpr:
2884 _outConvertRowtypeExpr(str, obj);
2887 _outCollateExpr(str, obj);
2890 _outCaseExpr(str, obj);
2893 _outCaseWhen(str, obj);
2895 case T_CaseTestExpr:
2896 _outCaseTestExpr(str, obj);
2899 _outArrayExpr(str, obj);
2902 _outRowExpr(str, obj);
2904 case T_RowCompareExpr:
2905 _outRowCompareExpr(str, obj);
2907 case T_CoalesceExpr:
2908 _outCoalesceExpr(str, obj);
2911 _outMinMaxExpr(str, obj);
2914 _outXmlExpr(str, obj);
2917 _outNullTest(str, obj);
2920 _outBooleanTest(str, obj);
2922 case T_CoerceToDomain:
2923 _outCoerceToDomain(str, obj);
2925 case T_CoerceToDomainValue:
2926 _outCoerceToDomainValue(str, obj);
2928 case T_SetToDefault:
2929 _outSetToDefault(str, obj);
2931 case T_CurrentOfExpr:
2932 _outCurrentOfExpr(str, obj);
2935 _outTargetEntry(str, obj);
2938 _outRangeTblRef(str, obj);
2941 _outJoinExpr(str, obj);
2944 _outFromExpr(str, obj);
2951 _outIndexPath(str, obj);
2953 case T_BitmapHeapPath:
2954 _outBitmapHeapPath(str, obj);
2956 case T_BitmapAndPath:
2957 _outBitmapAndPath(str, obj);
2959 case T_BitmapOrPath:
2960 _outBitmapOrPath(str, obj);
2963 _outTidPath(str, obj);
2966 _outForeignPath(str, obj);
2969 _outAppendPath(str, obj);
2971 case T_MergeAppendPath:
2972 _outMergeAppendPath(str, obj);
2975 _outResultPath(str, obj);
2977 case T_MaterialPath:
2978 _outMaterialPath(str, obj);
2981 _outUniquePath(str, obj);
2984 _outNestPath(str, obj);
2987 _outMergePath(str, obj);
2990 _outHashPath(str, obj);
2992 case T_PlannerGlobal:
2993 _outPlannerGlobal(str, obj);
2996 _outPlannerInfo(str, obj);
2999 _outRelOptInfo(str, obj);
3001 case T_IndexOptInfo:
3002 _outIndexOptInfo(str, obj);
3004 case T_EquivalenceClass:
3005 _outEquivalenceClass(str, obj);
3007 case T_EquivalenceMember:
3008 _outEquivalenceMember(str, obj);
3011 _outPathKey(str, obj);
3013 case T_RestrictInfo:
3014 _outRestrictInfo(str, obj);
3016 case T_InnerIndexscanInfo:
3017 _outInnerIndexscanInfo(str, obj);
3019 case T_PlaceHolderVar:
3020 _outPlaceHolderVar(str, obj);
3022 case T_SpecialJoinInfo:
3023 _outSpecialJoinInfo(str, obj);
3025 case T_AppendRelInfo:
3026 _outAppendRelInfo(str, obj);
3028 case T_PlaceHolderInfo:
3029 _outPlaceHolderInfo(str, obj);
3031 case T_MinMaxAggInfo:
3032 _outMinMaxAggInfo(str, obj);
3034 case T_PlannerParamItem:
3035 _outPlannerParamItem(str, obj);
3039 _outCreateStmt(str, obj);
3041 case T_CreateForeignTableStmt:
3042 _outCreateForeignTableStmt(str, obj);
3045 _outIndexStmt(str, obj);
3048 _outNotifyStmt(str, obj);
3050 case T_DeclareCursorStmt:
3051 _outDeclareCursorStmt(str, obj);
3054 _outSelectStmt(str, obj);
3057 _outColumnDef(str, obj);
3060 _outTypeName(str, obj);
3063 _outTypeCast(str, obj);
3065 case T_CollateClause:
3066 _outCollateClause(str, obj);
3069 _outIndexElem(str, obj);
3072 _outQuery(str, obj);
3074 case T_SortGroupClause:
3075 _outSortGroupClause(str, obj);
3077 case T_WindowClause:
3078 _outWindowClause(str, obj);
3080 case T_RowMarkClause:
3081 _outRowMarkClause(str, obj);
3084 _outWithClause(str, obj);
3086 case T_CommonTableExpr:
3087 _outCommonTableExpr(str, obj);
3089 case T_SetOperationStmt:
3090 _outSetOperationStmt(str, obj);
3092 case T_RangeTblEntry:
3093 _outRangeTblEntry(str, obj);
3096 _outAExpr(str, obj);
3099 _outColumnRef(str, obj);
3102 _outParamRef(str, obj);
3105 _outAConst(str, obj);
3108 _outA_Star(str, obj);
3111 _outA_Indices(str, obj);
3113 case T_A_Indirection:
3114 _outA_Indirection(str, obj);
3117 _outA_ArrayExpr(str, obj);
3120 _outResTarget(str, obj);
3123 _outSortBy(str, obj);
3126 _outWindowDef(str, obj);
3128 case T_RangeSubselect:
3129 _outRangeSubselect(str, obj);
3131 case T_RangeFunction:
3132 _outRangeFunction(str, obj);
3135 _outConstraint(str, obj);
3138 _outFuncCall(str, obj);
3141 _outDefElem(str, obj);
3144 _outInhRelation(str, obj);
3146 case T_LockingClause:
3147 _outLockingClause(str, obj);
3149 case T_XmlSerialize:
3150 _outXmlSerialize(str, obj);
3156 * This should be an ERROR, but it's too useful to be able to
3157 * dump structures that _outNode only understands part of.
3159 elog(WARNING, "could not dump unrecognized node type: %d",
3160 (int) nodeTag(obj));
3163 appendStringInfoChar(str, '}');
3169 * returns the ascii representation of the Node as a palloc'd string
3172 nodeToString(const void *obj)
3176 /* see stringinfo.h for an explanation of this maneuver */
3177 initStringInfo(&str);
3178 _outNode(&str, obj);