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, 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, 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, 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, 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, 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, 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, Scan *node)
285 _outPlanInfo(str, (Plan *) node);
287 WRITE_UINT_FIELD(scanrelid);
291 * print the basic stuff of all nodes that inherit from Join
294 _outJoinPlanInfo(StringInfo str, Join *node)
296 _outPlanInfo(str, (Plan *) node);
298 WRITE_ENUM_FIELD(jointype, JoinType);
299 WRITE_NODE_FIELD(joinqual);
304 _outPlan(StringInfo str, Plan *node)
306 WRITE_NODE_TYPE("PLAN");
308 _outPlanInfo(str, (Plan *) node);
312 _outResult(StringInfo str, Result *node)
314 WRITE_NODE_TYPE("RESULT");
316 _outPlanInfo(str, (Plan *) node);
318 WRITE_NODE_FIELD(resconstantqual);
322 _outModifyTable(StringInfo str, ModifyTable *node)
324 WRITE_NODE_TYPE("MODIFYTABLE");
326 _outPlanInfo(str, (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, Append *node)
341 WRITE_NODE_TYPE("APPEND");
343 _outPlanInfo(str, (Plan *) node);
345 WRITE_NODE_FIELD(appendplans);
349 _outMergeAppend(StringInfo str, MergeAppend *node)
353 WRITE_NODE_TYPE("MERGEAPPEND");
355 _outPlanInfo(str, (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, RecursiveUnion *node)
383 WRITE_NODE_TYPE("RECURSIVEUNION");
385 _outPlanInfo(str, (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, BitmapAnd *node)
404 WRITE_NODE_TYPE("BITMAPAND");
406 _outPlanInfo(str, (Plan *) node);
408 WRITE_NODE_FIELD(bitmapplans);
412 _outBitmapOr(StringInfo str, BitmapOr *node)
414 WRITE_NODE_TYPE("BITMAPOR");
416 _outPlanInfo(str, (Plan *) node);
418 WRITE_NODE_FIELD(bitmapplans);
422 _outScan(StringInfo str, Scan *node)
424 WRITE_NODE_TYPE("SCAN");
426 _outScanInfo(str, (Scan *) node);
430 _outSeqScan(StringInfo str, SeqScan *node)
432 WRITE_NODE_TYPE("SEQSCAN");
434 _outScanInfo(str, (Scan *) node);
438 _outIndexScan(StringInfo str, IndexScan *node)
440 WRITE_NODE_TYPE("INDEXSCAN");
442 _outScanInfo(str, (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, IndexOnlyScan *node)
455 WRITE_NODE_TYPE("INDEXONLYSCAN");
457 _outScanInfo(str, (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, BitmapIndexScan *node)
469 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
471 _outScanInfo(str, (Scan *) node);
473 WRITE_OID_FIELD(indexid);
474 WRITE_NODE_FIELD(indexqual);
475 WRITE_NODE_FIELD(indexqualorig);
479 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
481 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
483 _outScanInfo(str, (Scan *) node);
485 WRITE_NODE_FIELD(bitmapqualorig);
489 _outTidScan(StringInfo str, TidScan *node)
491 WRITE_NODE_TYPE("TIDSCAN");
493 _outScanInfo(str, (Scan *) node);
495 WRITE_NODE_FIELD(tidquals);
499 _outSubqueryScan(StringInfo str, SubqueryScan *node)
501 WRITE_NODE_TYPE("SUBQUERYSCAN");
503 _outScanInfo(str, (Scan *) node);
505 WRITE_NODE_FIELD(subplan);
509 _outFunctionScan(StringInfo str, FunctionScan *node)
511 WRITE_NODE_TYPE("FUNCTIONSCAN");
513 _outScanInfo(str, (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, ValuesScan *node)
525 WRITE_NODE_TYPE("VALUESSCAN");
527 _outScanInfo(str, (Scan *) node);
529 WRITE_NODE_FIELD(values_lists);
533 _outCteScan(StringInfo str, CteScan *node)
535 WRITE_NODE_TYPE("CTESCAN");
537 _outScanInfo(str, (Scan *) node);
539 WRITE_INT_FIELD(ctePlanId);
540 WRITE_INT_FIELD(cteParam);
544 _outWorkTableScan(StringInfo str, WorkTableScan *node)
546 WRITE_NODE_TYPE("WORKTABLESCAN");
548 _outScanInfo(str, (Scan *) node);
550 WRITE_INT_FIELD(wtParam);
554 _outForeignScan(StringInfo str, ForeignScan *node)
556 WRITE_NODE_TYPE("FOREIGNSCAN");
558 _outScanInfo(str, (Scan *) node);
560 WRITE_BOOL_FIELD(fsSystemCol);
561 WRITE_NODE_FIELD(fdwplan);
565 _outFdwPlan(StringInfo str, 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, Join *node)
577 WRITE_NODE_TYPE("JOIN");
579 _outJoinPlanInfo(str, (Join *) node);
583 _outNestLoop(StringInfo str, NestLoop *node)
585 WRITE_NODE_TYPE("NESTLOOP");
587 _outJoinPlanInfo(str, (Join *) node);
589 WRITE_NODE_FIELD(nestParams);
593 _outMergeJoin(StringInfo str, MergeJoin *node)
598 WRITE_NODE_TYPE("MERGEJOIN");
600 _outJoinPlanInfo(str, (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, HashJoin *node)
626 WRITE_NODE_TYPE("HASHJOIN");
628 _outJoinPlanInfo(str, (Join *) node);
630 WRITE_NODE_FIELD(hashclauses);
634 _outAgg(StringInfo str, Agg *node)
638 WRITE_NODE_TYPE("AGG");
640 _outPlanInfo(str, (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, WindowAgg *node)
661 WRITE_NODE_TYPE("WINDOWAGG");
663 _outPlanInfo(str, (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, Group *node)
696 WRITE_NODE_TYPE("GROUP");
698 _outPlanInfo(str, (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, Material *node)
714 WRITE_NODE_TYPE("MATERIAL");
716 _outPlanInfo(str, (Plan *) node);
720 _outSort(StringInfo str, Sort *node)
724 WRITE_NODE_TYPE("SORT");
726 _outPlanInfo(str, (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, Unique *node)
752 WRITE_NODE_TYPE("UNIQUE");
754 _outPlanInfo(str, (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, Hash *node)
770 WRITE_NODE_TYPE("HASH");
772 _outPlanInfo(str, (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, SetOp *node)
786 WRITE_NODE_TYPE("SETOP");
788 _outPlanInfo(str, (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, LockRows *node)
810 WRITE_NODE_TYPE("LOCKROWS");
812 _outPlanInfo(str, (Plan *) node);
814 WRITE_NODE_FIELD(rowMarks);
815 WRITE_INT_FIELD(epqParam);
819 _outLimit(StringInfo str, Limit *node)
821 WRITE_NODE_TYPE("LIMIT");
823 _outPlanInfo(str, (Plan *) node);
825 WRITE_NODE_FIELD(limitOffset);
826 WRITE_NODE_FIELD(limitCount);
830 _outNestLoopParam(StringInfo str, NestLoopParam *node)
832 WRITE_NODE_TYPE("NESTLOOPPARAM");
834 WRITE_INT_FIELD(paramno);
835 WRITE_NODE_FIELD(paramval);
839 _outPlanRowMark(StringInfo str, 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, 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, Alias *node)
869 WRITE_NODE_TYPE("ALIAS");
871 WRITE_STRING_FIELD(aliasname);
872 WRITE_NODE_FIELD(colnames);
876 _outRangeVar(StringInfo str, 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, 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);
905 _outVar(StringInfo str, Var *node)
907 WRITE_NODE_TYPE("VAR");
909 WRITE_UINT_FIELD(varno);
910 WRITE_INT_FIELD(varattno);
911 WRITE_OID_FIELD(vartype);
912 WRITE_INT_FIELD(vartypmod);
913 WRITE_OID_FIELD(varcollid);
914 WRITE_UINT_FIELD(varlevelsup);
915 WRITE_UINT_FIELD(varnoold);
916 WRITE_INT_FIELD(varoattno);
917 WRITE_LOCATION_FIELD(location);
921 _outConst(StringInfo str, Const *node)
923 WRITE_NODE_TYPE("CONST");
925 WRITE_OID_FIELD(consttype);
926 WRITE_INT_FIELD(consttypmod);
927 WRITE_OID_FIELD(constcollid);
928 WRITE_INT_FIELD(constlen);
929 WRITE_BOOL_FIELD(constbyval);
930 WRITE_BOOL_FIELD(constisnull);
931 WRITE_LOCATION_FIELD(location);
933 appendStringInfo(str, " :constvalue ");
934 if (node->constisnull)
935 appendStringInfo(str, "<>");
937 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
941 _outParam(StringInfo str, Param *node)
943 WRITE_NODE_TYPE("PARAM");
945 WRITE_ENUM_FIELD(paramkind, ParamKind);
946 WRITE_INT_FIELD(paramid);
947 WRITE_OID_FIELD(paramtype);
948 WRITE_INT_FIELD(paramtypmod);
949 WRITE_OID_FIELD(paramcollid);
950 WRITE_LOCATION_FIELD(location);
954 _outAggref(StringInfo str, Aggref *node)
956 WRITE_NODE_TYPE("AGGREF");
958 WRITE_OID_FIELD(aggfnoid);
959 WRITE_OID_FIELD(aggtype);
960 WRITE_OID_FIELD(aggcollid);
961 WRITE_OID_FIELD(inputcollid);
962 WRITE_NODE_FIELD(args);
963 WRITE_NODE_FIELD(aggorder);
964 WRITE_NODE_FIELD(aggdistinct);
965 WRITE_BOOL_FIELD(aggstar);
966 WRITE_UINT_FIELD(agglevelsup);
967 WRITE_LOCATION_FIELD(location);
971 _outWindowFunc(StringInfo str, WindowFunc *node)
973 WRITE_NODE_TYPE("WINDOWFUNC");
975 WRITE_OID_FIELD(winfnoid);
976 WRITE_OID_FIELD(wintype);
977 WRITE_OID_FIELD(wincollid);
978 WRITE_OID_FIELD(inputcollid);
979 WRITE_NODE_FIELD(args);
980 WRITE_UINT_FIELD(winref);
981 WRITE_BOOL_FIELD(winstar);
982 WRITE_BOOL_FIELD(winagg);
983 WRITE_LOCATION_FIELD(location);
987 _outArrayRef(StringInfo str, ArrayRef *node)
989 WRITE_NODE_TYPE("ARRAYREF");
991 WRITE_OID_FIELD(refarraytype);
992 WRITE_OID_FIELD(refelemtype);
993 WRITE_INT_FIELD(reftypmod);
994 WRITE_OID_FIELD(refcollid);
995 WRITE_NODE_FIELD(refupperindexpr);
996 WRITE_NODE_FIELD(reflowerindexpr);
997 WRITE_NODE_FIELD(refexpr);
998 WRITE_NODE_FIELD(refassgnexpr);
1002 _outFuncExpr(StringInfo str, FuncExpr *node)
1004 WRITE_NODE_TYPE("FUNCEXPR");
1006 WRITE_OID_FIELD(funcid);
1007 WRITE_OID_FIELD(funcresulttype);
1008 WRITE_BOOL_FIELD(funcretset);
1009 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1010 WRITE_OID_FIELD(funccollid);
1011 WRITE_OID_FIELD(inputcollid);
1012 WRITE_NODE_FIELD(args);
1013 WRITE_LOCATION_FIELD(location);
1017 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
1019 WRITE_NODE_TYPE("NAMEDARGEXPR");
1021 WRITE_NODE_FIELD(arg);
1022 WRITE_STRING_FIELD(name);
1023 WRITE_INT_FIELD(argnumber);
1024 WRITE_LOCATION_FIELD(location);
1028 _outOpExpr(StringInfo str, OpExpr *node)
1030 WRITE_NODE_TYPE("OPEXPR");
1032 WRITE_OID_FIELD(opno);
1033 WRITE_OID_FIELD(opfuncid);
1034 WRITE_OID_FIELD(opresulttype);
1035 WRITE_BOOL_FIELD(opretset);
1036 WRITE_OID_FIELD(opcollid);
1037 WRITE_OID_FIELD(inputcollid);
1038 WRITE_NODE_FIELD(args);
1039 WRITE_LOCATION_FIELD(location);
1043 _outDistinctExpr(StringInfo str, DistinctExpr *node)
1045 WRITE_NODE_TYPE("DISTINCTEXPR");
1047 WRITE_OID_FIELD(opno);
1048 WRITE_OID_FIELD(opfuncid);
1049 WRITE_OID_FIELD(opresulttype);
1050 WRITE_BOOL_FIELD(opretset);
1051 WRITE_OID_FIELD(opcollid);
1052 WRITE_OID_FIELD(inputcollid);
1053 WRITE_NODE_FIELD(args);
1054 WRITE_LOCATION_FIELD(location);
1058 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1060 WRITE_NODE_TYPE("NULLIFEXPR");
1062 WRITE_OID_FIELD(opno);
1063 WRITE_OID_FIELD(opfuncid);
1064 WRITE_OID_FIELD(opresulttype);
1065 WRITE_BOOL_FIELD(opretset);
1066 WRITE_OID_FIELD(opcollid);
1067 WRITE_OID_FIELD(inputcollid);
1068 WRITE_NODE_FIELD(args);
1069 WRITE_LOCATION_FIELD(location);
1073 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
1075 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1077 WRITE_OID_FIELD(opno);
1078 WRITE_OID_FIELD(opfuncid);
1079 WRITE_BOOL_FIELD(useOr);
1080 WRITE_OID_FIELD(inputcollid);
1081 WRITE_NODE_FIELD(args);
1082 WRITE_LOCATION_FIELD(location);
1086 _outBoolExpr(StringInfo str, BoolExpr *node)
1090 WRITE_NODE_TYPE("BOOLEXPR");
1092 /* do-it-yourself enum representation */
1093 switch (node->boolop)
1105 appendStringInfo(str, " :boolop ");
1106 _outToken(str, opstr);
1108 WRITE_NODE_FIELD(args);
1109 WRITE_LOCATION_FIELD(location);
1113 _outSubLink(StringInfo str, SubLink *node)
1115 WRITE_NODE_TYPE("SUBLINK");
1117 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1118 WRITE_NODE_FIELD(testexpr);
1119 WRITE_NODE_FIELD(operName);
1120 WRITE_NODE_FIELD(subselect);
1121 WRITE_LOCATION_FIELD(location);
1125 _outSubPlan(StringInfo str, SubPlan *node)
1127 WRITE_NODE_TYPE("SUBPLAN");
1129 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1130 WRITE_NODE_FIELD(testexpr);
1131 WRITE_NODE_FIELD(paramIds);
1132 WRITE_INT_FIELD(plan_id);
1133 WRITE_STRING_FIELD(plan_name);
1134 WRITE_OID_FIELD(firstColType);
1135 WRITE_INT_FIELD(firstColTypmod);
1136 WRITE_OID_FIELD(firstColCollation);
1137 WRITE_BOOL_FIELD(useHashTable);
1138 WRITE_BOOL_FIELD(unknownEqFalse);
1139 WRITE_NODE_FIELD(setParam);
1140 WRITE_NODE_FIELD(parParam);
1141 WRITE_NODE_FIELD(args);
1142 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1143 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1147 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1149 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1151 WRITE_NODE_FIELD(subplans);
1155 _outFieldSelect(StringInfo str, FieldSelect *node)
1157 WRITE_NODE_TYPE("FIELDSELECT");
1159 WRITE_NODE_FIELD(arg);
1160 WRITE_INT_FIELD(fieldnum);
1161 WRITE_OID_FIELD(resulttype);
1162 WRITE_INT_FIELD(resulttypmod);
1163 WRITE_OID_FIELD(resultcollid);
1167 _outFieldStore(StringInfo str, FieldStore *node)
1169 WRITE_NODE_TYPE("FIELDSTORE");
1171 WRITE_NODE_FIELD(arg);
1172 WRITE_NODE_FIELD(newvals);
1173 WRITE_NODE_FIELD(fieldnums);
1174 WRITE_OID_FIELD(resulttype);
1178 _outRelabelType(StringInfo str, RelabelType *node)
1180 WRITE_NODE_TYPE("RELABELTYPE");
1182 WRITE_NODE_FIELD(arg);
1183 WRITE_OID_FIELD(resulttype);
1184 WRITE_INT_FIELD(resulttypmod);
1185 WRITE_OID_FIELD(resultcollid);
1186 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1187 WRITE_LOCATION_FIELD(location);
1191 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1193 WRITE_NODE_TYPE("COERCEVIAIO");
1195 WRITE_NODE_FIELD(arg);
1196 WRITE_OID_FIELD(resulttype);
1197 WRITE_OID_FIELD(resultcollid);
1198 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1199 WRITE_LOCATION_FIELD(location);
1203 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1205 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1207 WRITE_NODE_FIELD(arg);
1208 WRITE_OID_FIELD(elemfuncid);
1209 WRITE_OID_FIELD(resulttype);
1210 WRITE_INT_FIELD(resulttypmod);
1211 WRITE_OID_FIELD(resultcollid);
1212 WRITE_BOOL_FIELD(isExplicit);
1213 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1214 WRITE_LOCATION_FIELD(location);
1218 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1220 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1222 WRITE_NODE_FIELD(arg);
1223 WRITE_OID_FIELD(resulttype);
1224 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1225 WRITE_LOCATION_FIELD(location);
1229 _outCollateExpr(StringInfo str, CollateExpr *node)
1231 WRITE_NODE_TYPE("COLLATE");
1233 WRITE_NODE_FIELD(arg);
1234 WRITE_OID_FIELD(collOid);
1235 WRITE_LOCATION_FIELD(location);
1239 _outCaseExpr(StringInfo str, CaseExpr *node)
1241 WRITE_NODE_TYPE("CASE");
1243 WRITE_OID_FIELD(casetype);
1244 WRITE_OID_FIELD(casecollid);
1245 WRITE_NODE_FIELD(arg);
1246 WRITE_NODE_FIELD(args);
1247 WRITE_NODE_FIELD(defresult);
1248 WRITE_LOCATION_FIELD(location);
1252 _outCaseWhen(StringInfo str, CaseWhen *node)
1254 WRITE_NODE_TYPE("WHEN");
1256 WRITE_NODE_FIELD(expr);
1257 WRITE_NODE_FIELD(result);
1258 WRITE_LOCATION_FIELD(location);
1262 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1264 WRITE_NODE_TYPE("CASETESTEXPR");
1266 WRITE_OID_FIELD(typeId);
1267 WRITE_INT_FIELD(typeMod);
1268 WRITE_OID_FIELD(collation);
1272 _outArrayExpr(StringInfo str, ArrayExpr *node)
1274 WRITE_NODE_TYPE("ARRAY");
1276 WRITE_OID_FIELD(array_typeid);
1277 WRITE_OID_FIELD(array_collid);
1278 WRITE_OID_FIELD(element_typeid);
1279 WRITE_NODE_FIELD(elements);
1280 WRITE_BOOL_FIELD(multidims);
1281 WRITE_LOCATION_FIELD(location);
1285 _outRowExpr(StringInfo str, RowExpr *node)
1287 WRITE_NODE_TYPE("ROW");
1289 WRITE_NODE_FIELD(args);
1290 WRITE_OID_FIELD(row_typeid);
1291 WRITE_ENUM_FIELD(row_format, CoercionForm);
1292 WRITE_NODE_FIELD(colnames);
1293 WRITE_LOCATION_FIELD(location);
1297 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1299 WRITE_NODE_TYPE("ROWCOMPARE");
1301 WRITE_ENUM_FIELD(rctype, RowCompareType);
1302 WRITE_NODE_FIELD(opnos);
1303 WRITE_NODE_FIELD(opfamilies);
1304 WRITE_NODE_FIELD(inputcollids);
1305 WRITE_NODE_FIELD(largs);
1306 WRITE_NODE_FIELD(rargs);
1310 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1312 WRITE_NODE_TYPE("COALESCE");
1314 WRITE_OID_FIELD(coalescetype);
1315 WRITE_OID_FIELD(coalescecollid);
1316 WRITE_NODE_FIELD(args);
1317 WRITE_LOCATION_FIELD(location);
1321 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1323 WRITE_NODE_TYPE("MINMAX");
1325 WRITE_OID_FIELD(minmaxtype);
1326 WRITE_OID_FIELD(minmaxcollid);
1327 WRITE_OID_FIELD(inputcollid);
1328 WRITE_ENUM_FIELD(op, MinMaxOp);
1329 WRITE_NODE_FIELD(args);
1330 WRITE_LOCATION_FIELD(location);
1334 _outXmlExpr(StringInfo str, XmlExpr *node)
1336 WRITE_NODE_TYPE("XMLEXPR");
1338 WRITE_ENUM_FIELD(op, XmlExprOp);
1339 WRITE_STRING_FIELD(name);
1340 WRITE_NODE_FIELD(named_args);
1341 WRITE_NODE_FIELD(arg_names);
1342 WRITE_NODE_FIELD(args);
1343 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1344 WRITE_OID_FIELD(type);
1345 WRITE_INT_FIELD(typmod);
1346 WRITE_LOCATION_FIELD(location);
1350 _outNullTest(StringInfo str, NullTest *node)
1352 WRITE_NODE_TYPE("NULLTEST");
1354 WRITE_NODE_FIELD(arg);
1355 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1356 WRITE_BOOL_FIELD(argisrow);
1360 _outBooleanTest(StringInfo str, BooleanTest *node)
1362 WRITE_NODE_TYPE("BOOLEANTEST");
1364 WRITE_NODE_FIELD(arg);
1365 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1369 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1371 WRITE_NODE_TYPE("COERCETODOMAIN");
1373 WRITE_NODE_FIELD(arg);
1374 WRITE_OID_FIELD(resulttype);
1375 WRITE_INT_FIELD(resulttypmod);
1376 WRITE_OID_FIELD(resultcollid);
1377 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1378 WRITE_LOCATION_FIELD(location);
1382 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1384 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1386 WRITE_OID_FIELD(typeId);
1387 WRITE_INT_FIELD(typeMod);
1388 WRITE_OID_FIELD(collation);
1389 WRITE_LOCATION_FIELD(location);
1393 _outSetToDefault(StringInfo str, SetToDefault *node)
1395 WRITE_NODE_TYPE("SETTODEFAULT");
1397 WRITE_OID_FIELD(typeId);
1398 WRITE_INT_FIELD(typeMod);
1399 WRITE_OID_FIELD(collation);
1400 WRITE_LOCATION_FIELD(location);
1404 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1406 WRITE_NODE_TYPE("CURRENTOFEXPR");
1408 WRITE_UINT_FIELD(cvarno);
1409 WRITE_STRING_FIELD(cursor_name);
1410 WRITE_INT_FIELD(cursor_param);
1414 _outTargetEntry(StringInfo str, TargetEntry *node)
1416 WRITE_NODE_TYPE("TARGETENTRY");
1418 WRITE_NODE_FIELD(expr);
1419 WRITE_INT_FIELD(resno);
1420 WRITE_STRING_FIELD(resname);
1421 WRITE_UINT_FIELD(ressortgroupref);
1422 WRITE_OID_FIELD(resorigtbl);
1423 WRITE_INT_FIELD(resorigcol);
1424 WRITE_BOOL_FIELD(resjunk);
1428 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1430 WRITE_NODE_TYPE("RANGETBLREF");
1432 WRITE_INT_FIELD(rtindex);
1436 _outJoinExpr(StringInfo str, JoinExpr *node)
1438 WRITE_NODE_TYPE("JOINEXPR");
1440 WRITE_ENUM_FIELD(jointype, JoinType);
1441 WRITE_BOOL_FIELD(isNatural);
1442 WRITE_NODE_FIELD(larg);
1443 WRITE_NODE_FIELD(rarg);
1444 WRITE_NODE_FIELD(usingClause);
1445 WRITE_NODE_FIELD(quals);
1446 WRITE_NODE_FIELD(alias);
1447 WRITE_INT_FIELD(rtindex);
1451 _outFromExpr(StringInfo str, FromExpr *node)
1453 WRITE_NODE_TYPE("FROMEXPR");
1455 WRITE_NODE_FIELD(fromlist);
1456 WRITE_NODE_FIELD(quals);
1459 /*****************************************************************************
1461 * Stuff from relation.h.
1463 *****************************************************************************/
1466 * print the basic stuff of all nodes that inherit from Path
1468 * Note we do NOT print the parent, else we'd be in infinite recursion.
1469 * We can print the parent's relids for identification purposes, though.
1472 _outPathInfo(StringInfo str, Path *node)
1474 WRITE_ENUM_FIELD(pathtype, NodeTag);
1475 appendStringInfo(str, " :parent_relids ");
1476 _outBitmapset(str, node->parent->relids);
1477 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1478 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1479 WRITE_NODE_FIELD(pathkeys);
1483 * print the basic stuff of all nodes that inherit from JoinPath
1486 _outJoinPathInfo(StringInfo str, JoinPath *node)
1488 _outPathInfo(str, (Path *) node);
1490 WRITE_ENUM_FIELD(jointype, JoinType);
1491 WRITE_NODE_FIELD(outerjoinpath);
1492 WRITE_NODE_FIELD(innerjoinpath);
1493 WRITE_NODE_FIELD(joinrestrictinfo);
1497 _outPath(StringInfo str, Path *node)
1499 WRITE_NODE_TYPE("PATH");
1501 _outPathInfo(str, (Path *) node);
1505 _outIndexPath(StringInfo str, IndexPath *node)
1507 WRITE_NODE_TYPE("INDEXPATH");
1509 _outPathInfo(str, (Path *) node);
1511 WRITE_NODE_FIELD(indexinfo);
1512 WRITE_NODE_FIELD(indexclauses);
1513 WRITE_NODE_FIELD(indexquals);
1514 WRITE_NODE_FIELD(indexorderbys);
1515 WRITE_BOOL_FIELD(isjoininner);
1516 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1517 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1518 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1519 WRITE_FLOAT_FIELD(rows, "%.0f");
1523 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1525 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1527 _outPathInfo(str, (Path *) node);
1529 WRITE_NODE_FIELD(bitmapqual);
1530 WRITE_BOOL_FIELD(isjoininner);
1531 WRITE_FLOAT_FIELD(rows, "%.0f");
1535 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1537 WRITE_NODE_TYPE("BITMAPANDPATH");
1539 _outPathInfo(str, (Path *) node);
1541 WRITE_NODE_FIELD(bitmapquals);
1542 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1546 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1548 WRITE_NODE_TYPE("BITMAPORPATH");
1550 _outPathInfo(str, (Path *) node);
1552 WRITE_NODE_FIELD(bitmapquals);
1553 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1557 _outTidPath(StringInfo str, TidPath *node)
1559 WRITE_NODE_TYPE("TIDPATH");
1561 _outPathInfo(str, (Path *) node);
1563 WRITE_NODE_FIELD(tidquals);
1567 _outForeignPath(StringInfo str, ForeignPath *node)
1569 WRITE_NODE_TYPE("FOREIGNPATH");
1571 _outPathInfo(str, (Path *) node);
1573 WRITE_NODE_FIELD(fdwplan);
1577 _outAppendPath(StringInfo str, AppendPath *node)
1579 WRITE_NODE_TYPE("APPENDPATH");
1581 _outPathInfo(str, (Path *) node);
1583 WRITE_NODE_FIELD(subpaths);
1587 _outMergeAppendPath(StringInfo str, MergeAppendPath *node)
1589 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1591 _outPathInfo(str, (Path *) node);
1593 WRITE_NODE_FIELD(subpaths);
1594 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1598 _outResultPath(StringInfo str, ResultPath *node)
1600 WRITE_NODE_TYPE("RESULTPATH");
1602 _outPathInfo(str, (Path *) node);
1604 WRITE_NODE_FIELD(quals);
1608 _outMaterialPath(StringInfo str, MaterialPath *node)
1610 WRITE_NODE_TYPE("MATERIALPATH");
1612 _outPathInfo(str, (Path *) node);
1614 WRITE_NODE_FIELD(subpath);
1618 _outUniquePath(StringInfo str, UniquePath *node)
1620 WRITE_NODE_TYPE("UNIQUEPATH");
1622 _outPathInfo(str, (Path *) node);
1624 WRITE_NODE_FIELD(subpath);
1625 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1626 WRITE_NODE_FIELD(in_operators);
1627 WRITE_NODE_FIELD(uniq_exprs);
1628 WRITE_FLOAT_FIELD(rows, "%.0f");
1632 _outNestPath(StringInfo str, NestPath *node)
1634 WRITE_NODE_TYPE("NESTPATH");
1636 _outJoinPathInfo(str, (JoinPath *) node);
1640 _outMergePath(StringInfo str, MergePath *node)
1642 WRITE_NODE_TYPE("MERGEPATH");
1644 _outJoinPathInfo(str, (JoinPath *) node);
1646 WRITE_NODE_FIELD(path_mergeclauses);
1647 WRITE_NODE_FIELD(outersortkeys);
1648 WRITE_NODE_FIELD(innersortkeys);
1649 WRITE_BOOL_FIELD(materialize_inner);
1653 _outHashPath(StringInfo str, HashPath *node)
1655 WRITE_NODE_TYPE("HASHPATH");
1657 _outJoinPathInfo(str, (JoinPath *) node);
1659 WRITE_NODE_FIELD(path_hashclauses);
1660 WRITE_INT_FIELD(num_batches);
1664 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1666 WRITE_NODE_TYPE("PLANNERGLOBAL");
1668 /* NB: this isn't a complete set of fields */
1669 WRITE_NODE_FIELD(paramlist);
1670 WRITE_NODE_FIELD(subplans);
1671 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1672 WRITE_NODE_FIELD(finalrtable);
1673 WRITE_NODE_FIELD(finalrowmarks);
1674 WRITE_NODE_FIELD(resultRelations);
1675 WRITE_NODE_FIELD(relationOids);
1676 WRITE_NODE_FIELD(invalItems);
1677 WRITE_UINT_FIELD(lastPHId);
1678 WRITE_UINT_FIELD(lastRowMarkId);
1679 WRITE_BOOL_FIELD(transientPlan);
1683 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1685 WRITE_NODE_TYPE("PLANNERINFO");
1687 /* NB: this isn't a complete set of fields */
1688 WRITE_NODE_FIELD(parse);
1689 WRITE_NODE_FIELD(glob);
1690 WRITE_UINT_FIELD(query_level);
1691 WRITE_NODE_FIELD(join_rel_list);
1692 WRITE_INT_FIELD(join_cur_level);
1693 WRITE_NODE_FIELD(init_plans);
1694 WRITE_NODE_FIELD(cte_plan_ids);
1695 WRITE_NODE_FIELD(eq_classes);
1696 WRITE_NODE_FIELD(canon_pathkeys);
1697 WRITE_NODE_FIELD(left_join_clauses);
1698 WRITE_NODE_FIELD(right_join_clauses);
1699 WRITE_NODE_FIELD(full_join_clauses);
1700 WRITE_NODE_FIELD(join_info_list);
1701 WRITE_NODE_FIELD(append_rel_list);
1702 WRITE_NODE_FIELD(rowMarks);
1703 WRITE_NODE_FIELD(placeholder_list);
1704 WRITE_NODE_FIELD(query_pathkeys);
1705 WRITE_NODE_FIELD(group_pathkeys);
1706 WRITE_NODE_FIELD(window_pathkeys);
1707 WRITE_NODE_FIELD(distinct_pathkeys);
1708 WRITE_NODE_FIELD(sort_pathkeys);
1709 WRITE_NODE_FIELD(minmax_aggs);
1710 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1711 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1712 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1713 WRITE_BOOL_FIELD(hasInheritedTarget);
1714 WRITE_BOOL_FIELD(hasJoinRTEs);
1715 WRITE_BOOL_FIELD(hasHavingQual);
1716 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1717 WRITE_BOOL_FIELD(hasRecursion);
1718 WRITE_INT_FIELD(wt_param_id);
1719 WRITE_BITMAPSET_FIELD(curOuterRels);
1720 WRITE_NODE_FIELD(curOuterParams);
1724 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1726 WRITE_NODE_TYPE("RELOPTINFO");
1728 /* NB: this isn't a complete set of fields */
1729 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1730 WRITE_BITMAPSET_FIELD(relids);
1731 WRITE_FLOAT_FIELD(rows, "%.0f");
1732 WRITE_INT_FIELD(width);
1733 WRITE_NODE_FIELD(reltargetlist);
1734 WRITE_NODE_FIELD(pathlist);
1735 WRITE_NODE_FIELD(cheapest_startup_path);
1736 WRITE_NODE_FIELD(cheapest_total_path);
1737 WRITE_NODE_FIELD(cheapest_unique_path);
1738 WRITE_UINT_FIELD(relid);
1739 WRITE_UINT_FIELD(reltablespace);
1740 WRITE_ENUM_FIELD(rtekind, RTEKind);
1741 WRITE_INT_FIELD(min_attr);
1742 WRITE_INT_FIELD(max_attr);
1743 WRITE_NODE_FIELD(indexlist);
1744 WRITE_UINT_FIELD(pages);
1745 WRITE_FLOAT_FIELD(tuples, "%.0f");
1746 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
1747 WRITE_NODE_FIELD(subplan);
1748 WRITE_NODE_FIELD(subroot);
1749 WRITE_NODE_FIELD(baserestrictinfo);
1750 WRITE_NODE_FIELD(joininfo);
1751 WRITE_BOOL_FIELD(has_eclass_joins);
1752 WRITE_BITMAPSET_FIELD(index_outer_relids);
1753 WRITE_NODE_FIELD(index_inner_paths);
1757 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1759 WRITE_NODE_TYPE("INDEXOPTINFO");
1761 /* NB: this isn't a complete set of fields */
1762 WRITE_OID_FIELD(indexoid);
1763 /* Do NOT print rel field, else infinite recursion */
1764 WRITE_UINT_FIELD(pages);
1765 WRITE_FLOAT_FIELD(tuples, "%.0f");
1766 WRITE_INT_FIELD(ncolumns);
1767 WRITE_OID_FIELD(relam);
1768 /* indexprs is redundant since we print indextlist */
1769 WRITE_NODE_FIELD(indpred);
1770 WRITE_NODE_FIELD(indextlist);
1771 WRITE_BOOL_FIELD(predOK);
1772 WRITE_BOOL_FIELD(unique);
1773 WRITE_BOOL_FIELD(immediate);
1774 WRITE_BOOL_FIELD(hypothetical);
1778 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1781 * To simplify reading, we just chase up to the topmost merged EC and
1782 * print that, without bothering to show the merge-ees separately.
1784 while (node->ec_merged)
1785 node = node->ec_merged;
1787 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1789 WRITE_NODE_FIELD(ec_opfamilies);
1790 WRITE_OID_FIELD(ec_collation);
1791 WRITE_NODE_FIELD(ec_members);
1792 WRITE_NODE_FIELD(ec_sources);
1793 WRITE_NODE_FIELD(ec_derives);
1794 WRITE_BITMAPSET_FIELD(ec_relids);
1795 WRITE_BOOL_FIELD(ec_has_const);
1796 WRITE_BOOL_FIELD(ec_has_volatile);
1797 WRITE_BOOL_FIELD(ec_below_outer_join);
1798 WRITE_BOOL_FIELD(ec_broken);
1799 WRITE_UINT_FIELD(ec_sortref);
1803 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1805 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1807 WRITE_NODE_FIELD(em_expr);
1808 WRITE_BITMAPSET_FIELD(em_relids);
1809 WRITE_BOOL_FIELD(em_is_const);
1810 WRITE_BOOL_FIELD(em_is_child);
1811 WRITE_OID_FIELD(em_datatype);
1815 _outPathKey(StringInfo str, PathKey *node)
1817 WRITE_NODE_TYPE("PATHKEY");
1819 WRITE_NODE_FIELD(pk_eclass);
1820 WRITE_OID_FIELD(pk_opfamily);
1821 WRITE_INT_FIELD(pk_strategy);
1822 WRITE_BOOL_FIELD(pk_nulls_first);
1826 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1828 WRITE_NODE_TYPE("RESTRICTINFO");
1830 /* NB: this isn't a complete set of fields */
1831 WRITE_NODE_FIELD(clause);
1832 WRITE_BOOL_FIELD(is_pushed_down);
1833 WRITE_BOOL_FIELD(outerjoin_delayed);
1834 WRITE_BOOL_FIELD(can_join);
1835 WRITE_BOOL_FIELD(pseudoconstant);
1836 WRITE_BITMAPSET_FIELD(clause_relids);
1837 WRITE_BITMAPSET_FIELD(required_relids);
1838 WRITE_BITMAPSET_FIELD(nullable_relids);
1839 WRITE_BITMAPSET_FIELD(left_relids);
1840 WRITE_BITMAPSET_FIELD(right_relids);
1841 WRITE_NODE_FIELD(orclause);
1842 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1843 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1844 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1845 WRITE_NODE_FIELD(mergeopfamilies);
1846 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1847 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1848 WRITE_NODE_FIELD(left_em);
1849 WRITE_NODE_FIELD(right_em);
1850 WRITE_BOOL_FIELD(outer_is_left);
1851 WRITE_OID_FIELD(hashjoinoperator);
1855 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1857 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1858 WRITE_BITMAPSET_FIELD(other_relids);
1859 WRITE_BOOL_FIELD(isouterjoin);
1860 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1861 WRITE_NODE_FIELD(cheapest_total_innerpath);
1865 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1867 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1869 WRITE_NODE_FIELD(phexpr);
1870 WRITE_BITMAPSET_FIELD(phrels);
1871 WRITE_UINT_FIELD(phid);
1872 WRITE_UINT_FIELD(phlevelsup);
1876 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1878 WRITE_NODE_TYPE("SPECIALJOININFO");
1880 WRITE_BITMAPSET_FIELD(min_lefthand);
1881 WRITE_BITMAPSET_FIELD(min_righthand);
1882 WRITE_BITMAPSET_FIELD(syn_lefthand);
1883 WRITE_BITMAPSET_FIELD(syn_righthand);
1884 WRITE_ENUM_FIELD(jointype, JoinType);
1885 WRITE_BOOL_FIELD(lhs_strict);
1886 WRITE_BOOL_FIELD(delay_upper_joins);
1887 WRITE_NODE_FIELD(join_quals);
1891 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1893 WRITE_NODE_TYPE("APPENDRELINFO");
1895 WRITE_UINT_FIELD(parent_relid);
1896 WRITE_UINT_FIELD(child_relid);
1897 WRITE_OID_FIELD(parent_reltype);
1898 WRITE_OID_FIELD(child_reltype);
1899 WRITE_NODE_FIELD(translated_vars);
1900 WRITE_OID_FIELD(parent_reloid);
1904 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1906 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1908 WRITE_UINT_FIELD(phid);
1909 WRITE_NODE_FIELD(ph_var);
1910 WRITE_BITMAPSET_FIELD(ph_eval_at);
1911 WRITE_BITMAPSET_FIELD(ph_needed);
1912 WRITE_BITMAPSET_FIELD(ph_may_need);
1913 WRITE_INT_FIELD(ph_width);
1917 _outMinMaxAggInfo(StringInfo str, MinMaxAggInfo *node)
1919 WRITE_NODE_TYPE("MINMAXAGGINFO");
1921 WRITE_OID_FIELD(aggfnoid);
1922 WRITE_OID_FIELD(aggsortop);
1923 WRITE_NODE_FIELD(target);
1924 /* We intentionally omit subroot --- too large, not interesting enough */
1925 WRITE_NODE_FIELD(path);
1926 WRITE_FLOAT_FIELD(pathcost, "%.2f");
1927 WRITE_NODE_FIELD(param);
1931 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1933 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1935 WRITE_NODE_FIELD(item);
1936 WRITE_UINT_FIELD(abslevel);
1939 /*****************************************************************************
1941 * Stuff from parsenodes.h.
1943 *****************************************************************************/
1946 _outCreateStmt(StringInfo str, CreateStmt *node)
1948 WRITE_NODE_TYPE("CREATESTMT");
1950 WRITE_NODE_FIELD(relation);
1951 WRITE_NODE_FIELD(tableElts);
1952 WRITE_NODE_FIELD(inhRelations);
1953 WRITE_NODE_FIELD(ofTypename);
1954 WRITE_NODE_FIELD(constraints);
1955 WRITE_NODE_FIELD(options);
1956 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1957 WRITE_STRING_FIELD(tablespacename);
1958 WRITE_BOOL_FIELD(if_not_exists);
1962 _outCreateForeignTableStmt(StringInfo str, CreateForeignTableStmt *node)
1964 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
1966 _outCreateStmt(str, (CreateStmt *) &node->base);
1968 WRITE_STRING_FIELD(servername);
1969 WRITE_NODE_FIELD(options);
1973 _outIndexStmt(StringInfo str, IndexStmt *node)
1975 WRITE_NODE_TYPE("INDEXSTMT");
1977 WRITE_STRING_FIELD(idxname);
1978 WRITE_NODE_FIELD(relation);
1979 WRITE_STRING_FIELD(accessMethod);
1980 WRITE_STRING_FIELD(tableSpace);
1981 WRITE_NODE_FIELD(indexParams);
1982 WRITE_NODE_FIELD(options);
1983 WRITE_NODE_FIELD(whereClause);
1984 WRITE_NODE_FIELD(excludeOpNames);
1985 WRITE_OID_FIELD(indexOid);
1986 WRITE_OID_FIELD(oldNode);
1987 WRITE_BOOL_FIELD(unique);
1988 WRITE_BOOL_FIELD(primary);
1989 WRITE_BOOL_FIELD(isconstraint);
1990 WRITE_BOOL_FIELD(deferrable);
1991 WRITE_BOOL_FIELD(initdeferred);
1992 WRITE_BOOL_FIELD(concurrent);
1996 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1998 WRITE_NODE_TYPE("NOTIFY");
2000 WRITE_STRING_FIELD(conditionname);
2001 WRITE_STRING_FIELD(payload);
2005 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
2007 WRITE_NODE_TYPE("DECLARECURSOR");
2009 WRITE_STRING_FIELD(portalname);
2010 WRITE_INT_FIELD(options);
2011 WRITE_NODE_FIELD(query);
2015 _outSelectStmt(StringInfo str, SelectStmt *node)
2017 WRITE_NODE_TYPE("SELECT");
2019 WRITE_NODE_FIELD(distinctClause);
2020 WRITE_NODE_FIELD(intoClause);
2021 WRITE_NODE_FIELD(targetList);
2022 WRITE_NODE_FIELD(fromClause);
2023 WRITE_NODE_FIELD(whereClause);
2024 WRITE_NODE_FIELD(groupClause);
2025 WRITE_NODE_FIELD(havingClause);
2026 WRITE_NODE_FIELD(windowClause);
2027 WRITE_NODE_FIELD(withClause);
2028 WRITE_NODE_FIELD(valuesLists);
2029 WRITE_NODE_FIELD(sortClause);
2030 WRITE_NODE_FIELD(limitOffset);
2031 WRITE_NODE_FIELD(limitCount);
2032 WRITE_NODE_FIELD(lockingClause);
2033 WRITE_ENUM_FIELD(op, SetOperation);
2034 WRITE_BOOL_FIELD(all);
2035 WRITE_NODE_FIELD(larg);
2036 WRITE_NODE_FIELD(rarg);
2040 _outFuncCall(StringInfo str, FuncCall *node)
2042 WRITE_NODE_TYPE("FUNCCALL");
2044 WRITE_NODE_FIELD(funcname);
2045 WRITE_NODE_FIELD(args);
2046 WRITE_NODE_FIELD(agg_order);
2047 WRITE_BOOL_FIELD(agg_star);
2048 WRITE_BOOL_FIELD(agg_distinct);
2049 WRITE_BOOL_FIELD(func_variadic);
2050 WRITE_NODE_FIELD(over);
2051 WRITE_LOCATION_FIELD(location);
2055 _outDefElem(StringInfo str, DefElem *node)
2057 WRITE_NODE_TYPE("DEFELEM");
2059 WRITE_STRING_FIELD(defnamespace);
2060 WRITE_STRING_FIELD(defname);
2061 WRITE_NODE_FIELD(arg);
2062 WRITE_ENUM_FIELD(defaction, DefElemAction);
2066 _outInhRelation(StringInfo str, InhRelation *node)
2068 WRITE_NODE_TYPE("INHRELATION");
2070 WRITE_NODE_FIELD(relation);
2071 WRITE_UINT_FIELD(options);
2075 _outLockingClause(StringInfo str, LockingClause *node)
2077 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2079 WRITE_NODE_FIELD(lockedRels);
2080 WRITE_BOOL_FIELD(forUpdate);
2081 WRITE_BOOL_FIELD(noWait);
2085 _outXmlSerialize(StringInfo str, XmlSerialize *node)
2087 WRITE_NODE_TYPE("XMLSERIALIZE");
2089 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2090 WRITE_NODE_FIELD(expr);
2091 WRITE_NODE_FIELD(typeName);
2092 WRITE_LOCATION_FIELD(location);
2096 _outColumnDef(StringInfo str, ColumnDef *node)
2098 WRITE_NODE_TYPE("COLUMNDEF");
2100 WRITE_STRING_FIELD(colname);
2101 WRITE_NODE_FIELD(typeName);
2102 WRITE_INT_FIELD(inhcount);
2103 WRITE_BOOL_FIELD(is_local);
2104 WRITE_BOOL_FIELD(is_not_null);
2105 WRITE_BOOL_FIELD(is_from_type);
2106 WRITE_INT_FIELD(storage);
2107 WRITE_NODE_FIELD(raw_default);
2108 WRITE_NODE_FIELD(cooked_default);
2109 WRITE_NODE_FIELD(collClause);
2110 WRITE_OID_FIELD(collOid);
2111 WRITE_NODE_FIELD(constraints);
2112 WRITE_NODE_FIELD(fdwoptions);
2116 _outTypeName(StringInfo str, TypeName *node)
2118 WRITE_NODE_TYPE("TYPENAME");
2120 WRITE_NODE_FIELD(names);
2121 WRITE_OID_FIELD(typeOid);
2122 WRITE_BOOL_FIELD(setof);
2123 WRITE_BOOL_FIELD(pct_type);
2124 WRITE_NODE_FIELD(typmods);
2125 WRITE_INT_FIELD(typemod);
2126 WRITE_NODE_FIELD(arrayBounds);
2127 WRITE_LOCATION_FIELD(location);
2131 _outTypeCast(StringInfo str, TypeCast *node)
2133 WRITE_NODE_TYPE("TYPECAST");
2135 WRITE_NODE_FIELD(arg);
2136 WRITE_NODE_FIELD(typeName);
2137 WRITE_LOCATION_FIELD(location);
2141 _outCollateClause(StringInfo str, CollateClause *node)
2143 WRITE_NODE_TYPE("COLLATECLAUSE");
2145 WRITE_NODE_FIELD(arg);
2146 WRITE_NODE_FIELD(collname);
2147 WRITE_LOCATION_FIELD(location);
2151 _outIndexElem(StringInfo str, IndexElem *node)
2153 WRITE_NODE_TYPE("INDEXELEM");
2155 WRITE_STRING_FIELD(name);
2156 WRITE_NODE_FIELD(expr);
2157 WRITE_STRING_FIELD(indexcolname);
2158 WRITE_NODE_FIELD(collation);
2159 WRITE_NODE_FIELD(opclass);
2160 WRITE_ENUM_FIELD(ordering, SortByDir);
2161 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2165 _outQuery(StringInfo str, Query *node)
2167 WRITE_NODE_TYPE("QUERY");
2169 WRITE_ENUM_FIELD(commandType, CmdType);
2170 WRITE_ENUM_FIELD(querySource, QuerySource);
2171 WRITE_BOOL_FIELD(canSetTag);
2174 * Hack to work around missing outfuncs routines for a lot of the
2175 * utility-statement node types. (The only one we actually *need* for
2176 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2177 * for the meantime do this to avoid getting lots of warnings when running
2178 * with debug_print_parse on.
2180 if (node->utilityStmt)
2182 switch (nodeTag(node->utilityStmt))
2187 case T_DeclareCursorStmt:
2188 WRITE_NODE_FIELD(utilityStmt);
2191 appendStringInfo(str, " :utilityStmt ?");
2196 appendStringInfo(str, " :utilityStmt <>");
2198 WRITE_INT_FIELD(resultRelation);
2199 WRITE_NODE_FIELD(intoClause);
2200 WRITE_BOOL_FIELD(hasAggs);
2201 WRITE_BOOL_FIELD(hasWindowFuncs);
2202 WRITE_BOOL_FIELD(hasSubLinks);
2203 WRITE_BOOL_FIELD(hasDistinctOn);
2204 WRITE_BOOL_FIELD(hasRecursive);
2205 WRITE_BOOL_FIELD(hasModifyingCTE);
2206 WRITE_BOOL_FIELD(hasForUpdate);
2207 WRITE_NODE_FIELD(cteList);
2208 WRITE_NODE_FIELD(rtable);
2209 WRITE_NODE_FIELD(jointree);
2210 WRITE_NODE_FIELD(targetList);
2211 WRITE_NODE_FIELD(returningList);
2212 WRITE_NODE_FIELD(groupClause);
2213 WRITE_NODE_FIELD(havingQual);
2214 WRITE_NODE_FIELD(windowClause);
2215 WRITE_NODE_FIELD(distinctClause);
2216 WRITE_NODE_FIELD(sortClause);
2217 WRITE_NODE_FIELD(limitOffset);
2218 WRITE_NODE_FIELD(limitCount);
2219 WRITE_NODE_FIELD(rowMarks);
2220 WRITE_NODE_FIELD(setOperations);
2221 WRITE_NODE_FIELD(constraintDeps);
2225 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2227 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2229 WRITE_UINT_FIELD(tleSortGroupRef);
2230 WRITE_OID_FIELD(eqop);
2231 WRITE_OID_FIELD(sortop);
2232 WRITE_BOOL_FIELD(nulls_first);
2233 WRITE_BOOL_FIELD(hashable);
2237 _outWindowClause(StringInfo str, WindowClause *node)
2239 WRITE_NODE_TYPE("WINDOWCLAUSE");
2241 WRITE_STRING_FIELD(name);
2242 WRITE_STRING_FIELD(refname);
2243 WRITE_NODE_FIELD(partitionClause);
2244 WRITE_NODE_FIELD(orderClause);
2245 WRITE_INT_FIELD(frameOptions);
2246 WRITE_NODE_FIELD(startOffset);
2247 WRITE_NODE_FIELD(endOffset);
2248 WRITE_UINT_FIELD(winref);
2249 WRITE_BOOL_FIELD(copiedOrder);
2253 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2255 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2257 WRITE_UINT_FIELD(rti);
2258 WRITE_BOOL_FIELD(forUpdate);
2259 WRITE_BOOL_FIELD(noWait);
2260 WRITE_BOOL_FIELD(pushedDown);
2264 _outWithClause(StringInfo str, WithClause *node)
2266 WRITE_NODE_TYPE("WITHCLAUSE");
2268 WRITE_NODE_FIELD(ctes);
2269 WRITE_BOOL_FIELD(recursive);
2270 WRITE_LOCATION_FIELD(location);
2274 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2276 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2278 WRITE_STRING_FIELD(ctename);
2279 WRITE_NODE_FIELD(aliascolnames);
2280 WRITE_NODE_FIELD(ctequery);
2281 WRITE_LOCATION_FIELD(location);
2282 WRITE_BOOL_FIELD(cterecursive);
2283 WRITE_INT_FIELD(cterefcount);
2284 WRITE_NODE_FIELD(ctecolnames);
2285 WRITE_NODE_FIELD(ctecoltypes);
2286 WRITE_NODE_FIELD(ctecoltypmods);
2287 WRITE_NODE_FIELD(ctecolcollations);
2291 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2293 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2295 WRITE_ENUM_FIELD(op, SetOperation);
2296 WRITE_BOOL_FIELD(all);
2297 WRITE_NODE_FIELD(larg);
2298 WRITE_NODE_FIELD(rarg);
2299 WRITE_NODE_FIELD(colTypes);
2300 WRITE_NODE_FIELD(colTypmods);
2301 WRITE_NODE_FIELD(colCollations);
2302 WRITE_NODE_FIELD(groupClauses);
2306 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2308 WRITE_NODE_TYPE("RTE");
2310 /* put alias + eref first to make dump more legible */
2311 WRITE_NODE_FIELD(alias);
2312 WRITE_NODE_FIELD(eref);
2313 WRITE_ENUM_FIELD(rtekind, RTEKind);
2315 switch (node->rtekind)
2318 WRITE_OID_FIELD(relid);
2319 WRITE_CHAR_FIELD(relkind);
2322 WRITE_NODE_FIELD(subquery);
2325 WRITE_ENUM_FIELD(jointype, JoinType);
2326 WRITE_NODE_FIELD(joinaliasvars);
2329 WRITE_NODE_FIELD(funcexpr);
2330 WRITE_NODE_FIELD(funccoltypes);
2331 WRITE_NODE_FIELD(funccoltypmods);
2332 WRITE_NODE_FIELD(funccolcollations);
2335 WRITE_NODE_FIELD(values_lists);
2336 WRITE_NODE_FIELD(values_collations);
2339 WRITE_STRING_FIELD(ctename);
2340 WRITE_UINT_FIELD(ctelevelsup);
2341 WRITE_BOOL_FIELD(self_reference);
2342 WRITE_NODE_FIELD(ctecoltypes);
2343 WRITE_NODE_FIELD(ctecoltypmods);
2344 WRITE_NODE_FIELD(ctecolcollations);
2347 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2351 WRITE_BOOL_FIELD(inh);
2352 WRITE_BOOL_FIELD(inFromCl);
2353 WRITE_UINT_FIELD(requiredPerms);
2354 WRITE_OID_FIELD(checkAsUser);
2355 WRITE_BITMAPSET_FIELD(selectedCols);
2356 WRITE_BITMAPSET_FIELD(modifiedCols);
2360 _outAExpr(StringInfo str, A_Expr *node)
2362 WRITE_NODE_TYPE("AEXPR");
2367 appendStringInfo(str, " ");
2368 WRITE_NODE_FIELD(name);
2371 appendStringInfo(str, " AND");
2374 appendStringInfo(str, " OR");
2377 appendStringInfo(str, " NOT");
2380 appendStringInfo(str, " ");
2381 WRITE_NODE_FIELD(name);
2382 appendStringInfo(str, " ANY ");
2385 appendStringInfo(str, " ");
2386 WRITE_NODE_FIELD(name);
2387 appendStringInfo(str, " ALL ");
2389 case AEXPR_DISTINCT:
2390 appendStringInfo(str, " DISTINCT ");
2391 WRITE_NODE_FIELD(name);
2394 appendStringInfo(str, " NULLIF ");
2395 WRITE_NODE_FIELD(name);
2398 appendStringInfo(str, " OF ");
2399 WRITE_NODE_FIELD(name);
2402 appendStringInfo(str, " IN ");
2403 WRITE_NODE_FIELD(name);
2406 appendStringInfo(str, " ??");
2410 WRITE_NODE_FIELD(lexpr);
2411 WRITE_NODE_FIELD(rexpr);
2412 WRITE_LOCATION_FIELD(location);
2416 _outValue(StringInfo str, Value *value)
2418 switch (value->type)
2421 appendStringInfo(str, "%ld", value->val.ival);
2426 * We assume the value is a valid numeric literal and so does not
2429 appendStringInfoString(str, value->val.str);
2432 appendStringInfoChar(str, '"');
2433 _outToken(str, value->val.str);
2434 appendStringInfoChar(str, '"');
2437 /* internal representation already has leading 'b' */
2438 appendStringInfoString(str, value->val.str);
2441 /* this is seen only within A_Const, not in transformed trees */
2442 appendStringInfoString(str, "NULL");
2445 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2451 _outColumnRef(StringInfo str, ColumnRef *node)
2453 WRITE_NODE_TYPE("COLUMNREF");
2455 WRITE_NODE_FIELD(fields);
2456 WRITE_LOCATION_FIELD(location);
2460 _outParamRef(StringInfo str, ParamRef *node)
2462 WRITE_NODE_TYPE("PARAMREF");
2464 WRITE_INT_FIELD(number);
2465 WRITE_LOCATION_FIELD(location);
2469 _outAConst(StringInfo str, A_Const *node)
2471 WRITE_NODE_TYPE("A_CONST");
2473 appendStringInfo(str, " :val ");
2474 _outValue(str, &(node->val));
2475 WRITE_LOCATION_FIELD(location);
2479 _outA_Star(StringInfo str, A_Star *node)
2481 WRITE_NODE_TYPE("A_STAR");
2485 _outA_Indices(StringInfo str, A_Indices *node)
2487 WRITE_NODE_TYPE("A_INDICES");
2489 WRITE_NODE_FIELD(lidx);
2490 WRITE_NODE_FIELD(uidx);
2494 _outA_Indirection(StringInfo str, A_Indirection *node)
2496 WRITE_NODE_TYPE("A_INDIRECTION");
2498 WRITE_NODE_FIELD(arg);
2499 WRITE_NODE_FIELD(indirection);
2503 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2505 WRITE_NODE_TYPE("A_ARRAYEXPR");
2507 WRITE_NODE_FIELD(elements);
2508 WRITE_LOCATION_FIELD(location);
2512 _outResTarget(StringInfo str, ResTarget *node)
2514 WRITE_NODE_TYPE("RESTARGET");
2516 WRITE_STRING_FIELD(name);
2517 WRITE_NODE_FIELD(indirection);
2518 WRITE_NODE_FIELD(val);
2519 WRITE_LOCATION_FIELD(location);
2523 _outSortBy(StringInfo str, SortBy *node)
2525 WRITE_NODE_TYPE("SORTBY");
2527 WRITE_NODE_FIELD(node);
2528 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2529 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2530 WRITE_NODE_FIELD(useOp);
2531 WRITE_LOCATION_FIELD(location);
2535 _outWindowDef(StringInfo str, WindowDef *node)
2537 WRITE_NODE_TYPE("WINDOWDEF");
2539 WRITE_STRING_FIELD(name);
2540 WRITE_STRING_FIELD(refname);
2541 WRITE_NODE_FIELD(partitionClause);
2542 WRITE_NODE_FIELD(orderClause);
2543 WRITE_INT_FIELD(frameOptions);
2544 WRITE_NODE_FIELD(startOffset);
2545 WRITE_NODE_FIELD(endOffset);
2546 WRITE_LOCATION_FIELD(location);
2550 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2552 WRITE_NODE_TYPE("RANGESUBSELECT");
2554 WRITE_NODE_FIELD(subquery);
2555 WRITE_NODE_FIELD(alias);
2559 _outRangeFunction(StringInfo str, RangeFunction *node)
2561 WRITE_NODE_TYPE("RANGEFUNCTION");
2563 WRITE_NODE_FIELD(funccallnode);
2564 WRITE_NODE_FIELD(alias);
2565 WRITE_NODE_FIELD(coldeflist);
2569 _outConstraint(StringInfo str, Constraint *node)
2571 WRITE_NODE_TYPE("CONSTRAINT");
2573 WRITE_STRING_FIELD(conname);
2574 WRITE_BOOL_FIELD(deferrable);
2575 WRITE_BOOL_FIELD(initdeferred);
2576 WRITE_LOCATION_FIELD(location);
2578 appendStringInfo(str, " :contype ");
2579 switch (node->contype)
2582 appendStringInfo(str, "NULL");
2585 case CONSTR_NOTNULL:
2586 appendStringInfo(str, "NOT_NULL");
2589 case CONSTR_DEFAULT:
2590 appendStringInfo(str, "DEFAULT");
2591 WRITE_NODE_FIELD(raw_expr);
2592 WRITE_STRING_FIELD(cooked_expr);
2596 appendStringInfo(str, "CHECK");
2597 WRITE_NODE_FIELD(raw_expr);
2598 WRITE_STRING_FIELD(cooked_expr);
2601 case CONSTR_PRIMARY:
2602 appendStringInfo(str, "PRIMARY_KEY");
2603 WRITE_NODE_FIELD(keys);
2604 WRITE_NODE_FIELD(options);
2605 WRITE_STRING_FIELD(indexname);
2606 WRITE_STRING_FIELD(indexspace);
2607 /* access_method and where_clause not currently used */
2611 appendStringInfo(str, "UNIQUE");
2612 WRITE_NODE_FIELD(keys);
2613 WRITE_NODE_FIELD(options);
2614 WRITE_STRING_FIELD(indexname);
2615 WRITE_STRING_FIELD(indexspace);
2616 /* access_method and where_clause not currently used */
2619 case CONSTR_EXCLUSION:
2620 appendStringInfo(str, "EXCLUSION");
2621 WRITE_NODE_FIELD(exclusions);
2622 WRITE_NODE_FIELD(options);
2623 WRITE_STRING_FIELD(indexname);
2624 WRITE_STRING_FIELD(indexspace);
2625 WRITE_STRING_FIELD(access_method);
2626 WRITE_NODE_FIELD(where_clause);
2629 case CONSTR_FOREIGN:
2630 appendStringInfo(str, "FOREIGN_KEY");
2631 WRITE_NODE_FIELD(pktable);
2632 WRITE_NODE_FIELD(fk_attrs);
2633 WRITE_NODE_FIELD(pk_attrs);
2634 WRITE_CHAR_FIELD(fk_matchtype);
2635 WRITE_CHAR_FIELD(fk_upd_action);
2636 WRITE_CHAR_FIELD(fk_del_action);
2637 WRITE_BOOL_FIELD(skip_validation);
2638 WRITE_BOOL_FIELD(initially_valid);
2641 case CONSTR_ATTR_DEFERRABLE:
2642 appendStringInfo(str, "ATTR_DEFERRABLE");
2645 case CONSTR_ATTR_NOT_DEFERRABLE:
2646 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2649 case CONSTR_ATTR_DEFERRED:
2650 appendStringInfo(str, "ATTR_DEFERRED");
2653 case CONSTR_ATTR_IMMEDIATE:
2654 appendStringInfo(str, "ATTR_IMMEDIATE");
2658 appendStringInfo(str, "<unrecognized_constraint %d>",
2659 (int) node->contype);
2667 * converts a Node into ascii string and append it to 'str'
2670 _outNode(StringInfo str, void *obj)
2673 appendStringInfo(str, "<>");
2674 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2676 else if (IsA(obj, Integer) ||
2679 IsA(obj, BitString))
2681 /* nodeRead does not want to see { } around these! */
2682 _outValue(str, obj);
2686 appendStringInfoChar(str, '{');
2687 switch (nodeTag(obj))
2690 _outPlannedStmt(str, obj);
2696 _outResult(str, obj);
2699 _outModifyTable(str, obj);
2702 _outAppend(str, obj);
2705 _outMergeAppend(str, obj);
2707 case T_RecursiveUnion:
2708 _outRecursiveUnion(str, obj);
2711 _outBitmapAnd(str, obj);
2714 _outBitmapOr(str, obj);
2720 _outSeqScan(str, obj);
2723 _outIndexScan(str, obj);
2725 case T_IndexOnlyScan:
2726 _outIndexOnlyScan(str, obj);
2728 case T_BitmapIndexScan:
2729 _outBitmapIndexScan(str, obj);
2731 case T_BitmapHeapScan:
2732 _outBitmapHeapScan(str, obj);
2735 _outTidScan(str, obj);
2737 case T_SubqueryScan:
2738 _outSubqueryScan(str, obj);
2740 case T_FunctionScan:
2741 _outFunctionScan(str, obj);
2744 _outValuesScan(str, obj);
2747 _outCteScan(str, obj);
2749 case T_WorkTableScan:
2750 _outWorkTableScan(str, obj);
2753 _outForeignScan(str, obj);
2756 _outFdwPlan(str, obj);
2762 _outNestLoop(str, obj);
2765 _outMergeJoin(str, obj);
2768 _outHashJoin(str, obj);
2774 _outWindowAgg(str, obj);
2777 _outGroup(str, obj);
2780 _outMaterial(str, obj);
2786 _outUnique(str, obj);
2792 _outSetOp(str, obj);
2795 _outLockRows(str, obj);
2798 _outLimit(str, obj);
2800 case T_NestLoopParam:
2801 _outNestLoopParam(str, obj);
2804 _outPlanRowMark(str, obj);
2806 case T_PlanInvalItem:
2807 _outPlanInvalItem(str, obj);
2810 _outAlias(str, obj);
2813 _outRangeVar(str, obj);
2816 _outIntoClause(str, obj);
2822 _outConst(str, obj);
2825 _outParam(str, obj);
2828 _outAggref(str, obj);
2831 _outWindowFunc(str, obj);
2834 _outArrayRef(str, obj);
2837 _outFuncExpr(str, obj);
2839 case T_NamedArgExpr:
2840 _outNamedArgExpr(str, obj);
2843 _outOpExpr(str, obj);
2845 case T_DistinctExpr:
2846 _outDistinctExpr(str, obj);
2849 _outNullIfExpr(str, obj);
2851 case T_ScalarArrayOpExpr:
2852 _outScalarArrayOpExpr(str, obj);
2855 _outBoolExpr(str, obj);
2858 _outSubLink(str, obj);
2861 _outSubPlan(str, obj);
2863 case T_AlternativeSubPlan:
2864 _outAlternativeSubPlan(str, obj);
2867 _outFieldSelect(str, obj);
2870 _outFieldStore(str, obj);
2873 _outRelabelType(str, obj);
2876 _outCoerceViaIO(str, obj);
2878 case T_ArrayCoerceExpr:
2879 _outArrayCoerceExpr(str, obj);
2881 case T_ConvertRowtypeExpr:
2882 _outConvertRowtypeExpr(str, obj);
2885 _outCollateExpr(str, obj);
2888 _outCaseExpr(str, obj);
2891 _outCaseWhen(str, obj);
2893 case T_CaseTestExpr:
2894 _outCaseTestExpr(str, obj);
2897 _outArrayExpr(str, obj);
2900 _outRowExpr(str, obj);
2902 case T_RowCompareExpr:
2903 _outRowCompareExpr(str, obj);
2905 case T_CoalesceExpr:
2906 _outCoalesceExpr(str, obj);
2909 _outMinMaxExpr(str, obj);
2912 _outXmlExpr(str, obj);
2915 _outNullTest(str, obj);
2918 _outBooleanTest(str, obj);
2920 case T_CoerceToDomain:
2921 _outCoerceToDomain(str, obj);
2923 case T_CoerceToDomainValue:
2924 _outCoerceToDomainValue(str, obj);
2926 case T_SetToDefault:
2927 _outSetToDefault(str, obj);
2929 case T_CurrentOfExpr:
2930 _outCurrentOfExpr(str, obj);
2933 _outTargetEntry(str, obj);
2936 _outRangeTblRef(str, obj);
2939 _outJoinExpr(str, obj);
2942 _outFromExpr(str, obj);
2949 _outIndexPath(str, obj);
2951 case T_BitmapHeapPath:
2952 _outBitmapHeapPath(str, obj);
2954 case T_BitmapAndPath:
2955 _outBitmapAndPath(str, obj);
2957 case T_BitmapOrPath:
2958 _outBitmapOrPath(str, obj);
2961 _outTidPath(str, obj);
2964 _outForeignPath(str, obj);
2967 _outAppendPath(str, obj);
2969 case T_MergeAppendPath:
2970 _outMergeAppendPath(str, obj);
2973 _outResultPath(str, obj);
2975 case T_MaterialPath:
2976 _outMaterialPath(str, obj);
2979 _outUniquePath(str, obj);
2982 _outNestPath(str, obj);
2985 _outMergePath(str, obj);
2988 _outHashPath(str, obj);
2990 case T_PlannerGlobal:
2991 _outPlannerGlobal(str, obj);
2994 _outPlannerInfo(str, obj);
2997 _outRelOptInfo(str, obj);
2999 case T_IndexOptInfo:
3000 _outIndexOptInfo(str, obj);
3002 case T_EquivalenceClass:
3003 _outEquivalenceClass(str, obj);
3005 case T_EquivalenceMember:
3006 _outEquivalenceMember(str, obj);
3009 _outPathKey(str, obj);
3011 case T_RestrictInfo:
3012 _outRestrictInfo(str, obj);
3014 case T_InnerIndexscanInfo:
3015 _outInnerIndexscanInfo(str, obj);
3017 case T_PlaceHolderVar:
3018 _outPlaceHolderVar(str, obj);
3020 case T_SpecialJoinInfo:
3021 _outSpecialJoinInfo(str, obj);
3023 case T_AppendRelInfo:
3024 _outAppendRelInfo(str, obj);
3026 case T_PlaceHolderInfo:
3027 _outPlaceHolderInfo(str, obj);
3029 case T_MinMaxAggInfo:
3030 _outMinMaxAggInfo(str, obj);
3032 case T_PlannerParamItem:
3033 _outPlannerParamItem(str, obj);
3037 _outCreateStmt(str, obj);
3039 case T_CreateForeignTableStmt:
3040 _outCreateForeignTableStmt(str, obj);
3043 _outIndexStmt(str, obj);
3046 _outNotifyStmt(str, obj);
3048 case T_DeclareCursorStmt:
3049 _outDeclareCursorStmt(str, obj);
3052 _outSelectStmt(str, obj);
3055 _outColumnDef(str, obj);
3058 _outTypeName(str, obj);
3061 _outTypeCast(str, obj);
3063 case T_CollateClause:
3064 _outCollateClause(str, obj);
3067 _outIndexElem(str, obj);
3070 _outQuery(str, obj);
3072 case T_SortGroupClause:
3073 _outSortGroupClause(str, obj);
3075 case T_WindowClause:
3076 _outWindowClause(str, obj);
3078 case T_RowMarkClause:
3079 _outRowMarkClause(str, obj);
3082 _outWithClause(str, obj);
3084 case T_CommonTableExpr:
3085 _outCommonTableExpr(str, obj);
3087 case T_SetOperationStmt:
3088 _outSetOperationStmt(str, obj);
3090 case T_RangeTblEntry:
3091 _outRangeTblEntry(str, obj);
3094 _outAExpr(str, obj);
3097 _outColumnRef(str, obj);
3100 _outParamRef(str, obj);
3103 _outAConst(str, obj);
3106 _outA_Star(str, obj);
3109 _outA_Indices(str, obj);
3111 case T_A_Indirection:
3112 _outA_Indirection(str, obj);
3115 _outA_ArrayExpr(str, obj);
3118 _outResTarget(str, obj);
3121 _outSortBy(str, obj);
3124 _outWindowDef(str, obj);
3126 case T_RangeSubselect:
3127 _outRangeSubselect(str, obj);
3129 case T_RangeFunction:
3130 _outRangeFunction(str, obj);
3133 _outConstraint(str, obj);
3136 _outFuncCall(str, obj);
3139 _outDefElem(str, obj);
3142 _outInhRelation(str, obj);
3144 case T_LockingClause:
3145 _outLockingClause(str, obj);
3147 case T_XmlSerialize:
3148 _outXmlSerialize(str, obj);
3154 * This should be an ERROR, but it's too useful to be able to
3155 * dump structures that _outNode only understands part of.
3157 elog(WARNING, "could not dump unrecognized node type: %d",
3158 (int) nodeTag(obj));
3161 appendStringInfoChar(str, '}');
3167 * returns the ascii representation of the Node as a palloc'd string
3170 nodeToString(void *obj)
3174 /* see stringinfo.h for an explanation of this maneuver */
3175 initStringInfo(&str);
3176 _outNode(&str, obj);