1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/nodes/outfuncs.c
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "foreign/fdwapi.h"
28 #include "nodes/plannodes.h"
29 #include "nodes/relation.h"
30 #include "utils/datum.h"
34 * Macros to simplify output of different kinds of fields. Use these
35 * wherever possible to reduce the chance for silly typos. Note that these
36 * hard-wire conventions about the names of the local variables in an Out
40 /* Write the label for the node type */
41 #define WRITE_NODE_TYPE(nodelabel) \
42 appendStringInfoString(str, nodelabel)
44 /* Write an integer field (anything written as ":fldname %d") */
45 #define WRITE_INT_FIELD(fldname) \
46 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
48 /* Write an unsigned integer field (anything written as ":fldname %u") */
49 #define WRITE_UINT_FIELD(fldname) \
50 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
52 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
53 #define WRITE_OID_FIELD(fldname) \
54 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
56 /* Write a long-integer field */
57 #define WRITE_LONG_FIELD(fldname) \
58 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
60 /* Write a char field (ie, one ascii character) */
61 #define WRITE_CHAR_FIELD(fldname) \
62 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
64 /* Write an enumerated-type field as an integer code */
65 #define WRITE_ENUM_FIELD(fldname, enumtype) \
66 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
69 /* Write a float field --- caller must give format to define precision */
70 #define WRITE_FLOAT_FIELD(fldname,format) \
71 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
73 /* Write a boolean field */
74 #define WRITE_BOOL_FIELD(fldname) \
75 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
76 booltostr(node->fldname))
78 /* Write a character-string (possibly NULL) field */
79 #define WRITE_STRING_FIELD(fldname) \
80 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
81 _outToken(str, node->fldname))
83 /* Write a parse location field (actually same as INT case) */
84 #define WRITE_LOCATION_FIELD(fldname) \
85 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
87 /* Write a Node field */
88 #define WRITE_NODE_FIELD(fldname) \
89 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
90 _outNode(str, node->fldname))
92 /* Write a bitmapset field */
93 #define WRITE_BITMAPSET_FIELD(fldname) \
94 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
95 _outBitmapset(str, node->fldname))
98 #define booltostr(x) ((x) ? "true" : "false")
100 static void _outNode(StringInfo str, void *obj);
105 * Convert an ordinary string (eg, an identifier) into a form that
106 * will be decoded back to a plain token by read.c's functions.
108 * If a null or empty string is given, it is encoded as "<>".
111 _outToken(StringInfo str, char *s)
113 if (s == NULL || *s == '\0')
115 appendStringInfo(str, "<>");
120 * Look for characters or patterns that are treated specially by read.c
121 * (either in pg_strtok() or in nodeRead()), and therefore need a
122 * protective backslash.
124 /* These characters only need to be quoted at the start of the string */
127 isdigit((unsigned char) *s) ||
128 ((*s == '+' || *s == '-') &&
129 (isdigit((unsigned char) s[1]) || s[1] == '.')))
130 appendStringInfoChar(str, '\\');
133 /* These chars must be backslashed anywhere in the string */
134 if (*s == ' ' || *s == '\n' || *s == '\t' ||
135 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
137 appendStringInfoChar(str, '\\');
138 appendStringInfoChar(str, *s++);
143 _outList(StringInfo str, List *node)
147 appendStringInfoChar(str, '(');
149 if (IsA(node, IntList))
150 appendStringInfoChar(str, 'i');
151 else if (IsA(node, OidList))
152 appendStringInfoChar(str, 'o');
157 * For the sake of backward compatibility, we emit a slightly
158 * different whitespace format for lists of nodes vs. other types of
159 * lists. XXX: is this necessary?
163 _outNode(str, lfirst(lc));
165 appendStringInfoChar(str, ' ');
167 else if (IsA(node, IntList))
168 appendStringInfo(str, " %d", lfirst_int(lc));
169 else if (IsA(node, OidList))
170 appendStringInfo(str, " %u", lfirst_oid(lc));
172 elog(ERROR, "unrecognized list node type: %d",
176 appendStringInfoChar(str, ')');
181 * converts a bitmap set of integers
183 * Note: the output format is "(b int int ...)", similar to an integer List.
186 _outBitmapset(StringInfo str, Bitmapset *bms)
191 appendStringInfoChar(str, '(');
192 appendStringInfoChar(str, 'b');
193 tmpset = bms_copy(bms);
194 while ((x = bms_first_member(tmpset)) >= 0)
195 appendStringInfo(str, " %d", x);
197 appendStringInfoChar(str, ')');
201 * Print the value of a Datum given its type.
204 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
210 length = datumGetSize(value, typbyval, typlen);
214 s = (char *) (&value);
215 appendStringInfo(str, "%u [ ", (unsigned int) length);
216 for (i = 0; i < (Size) sizeof(Datum); i++)
217 appendStringInfo(str, "%d ", (int) (s[i]));
218 appendStringInfo(str, "]");
222 s = (char *) DatumGetPointer(value);
223 if (!PointerIsValid(s))
224 appendStringInfo(str, "0 [ ]");
227 appendStringInfo(str, "%u [ ", (unsigned int) length);
228 for (i = 0; i < length; i++)
229 appendStringInfo(str, "%d ", (int) (s[i]));
230 appendStringInfo(str, "]");
237 * Stuff from plannodes.h
241 _outPlannedStmt(StringInfo str, PlannedStmt *node)
243 WRITE_NODE_TYPE("PLANNEDSTMT");
245 WRITE_ENUM_FIELD(commandType, CmdType);
246 WRITE_BOOL_FIELD(hasReturning);
247 WRITE_BOOL_FIELD(hasModifyingCTE);
248 WRITE_BOOL_FIELD(canSetTag);
249 WRITE_BOOL_FIELD(transientPlan);
250 WRITE_NODE_FIELD(planTree);
251 WRITE_NODE_FIELD(rtable);
252 WRITE_NODE_FIELD(resultRelations);
253 WRITE_NODE_FIELD(utilityStmt);
254 WRITE_NODE_FIELD(intoClause);
255 WRITE_NODE_FIELD(subplans);
256 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
257 WRITE_NODE_FIELD(rowMarks);
258 WRITE_NODE_FIELD(relationOids);
259 WRITE_NODE_FIELD(invalItems);
260 WRITE_INT_FIELD(nParamExec);
264 * print the basic stuff of all nodes that inherit from Plan
267 _outPlanInfo(StringInfo str, Plan *node)
269 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
270 WRITE_FLOAT_FIELD(total_cost, "%.2f");
271 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
272 WRITE_INT_FIELD(plan_width);
273 WRITE_NODE_FIELD(targetlist);
274 WRITE_NODE_FIELD(qual);
275 WRITE_NODE_FIELD(lefttree);
276 WRITE_NODE_FIELD(righttree);
277 WRITE_NODE_FIELD(initPlan);
278 WRITE_BITMAPSET_FIELD(extParam);
279 WRITE_BITMAPSET_FIELD(allParam);
283 * print the basic stuff of all nodes that inherit from Scan
286 _outScanInfo(StringInfo str, Scan *node)
288 _outPlanInfo(str, (Plan *) node);
290 WRITE_UINT_FIELD(scanrelid);
294 * print the basic stuff of all nodes that inherit from Join
297 _outJoinPlanInfo(StringInfo str, Join *node)
299 _outPlanInfo(str, (Plan *) node);
301 WRITE_ENUM_FIELD(jointype, JoinType);
302 WRITE_NODE_FIELD(joinqual);
307 _outPlan(StringInfo str, Plan *node)
309 WRITE_NODE_TYPE("PLAN");
311 _outPlanInfo(str, (Plan *) node);
315 _outResult(StringInfo str, Result *node)
317 WRITE_NODE_TYPE("RESULT");
319 _outPlanInfo(str, (Plan *) node);
321 WRITE_NODE_FIELD(resconstantqual);
325 _outModifyTable(StringInfo str, ModifyTable *node)
327 WRITE_NODE_TYPE("MODIFYTABLE");
329 _outPlanInfo(str, (Plan *) node);
331 WRITE_ENUM_FIELD(operation, CmdType);
332 WRITE_BOOL_FIELD(canSetTag);
333 WRITE_NODE_FIELD(resultRelations);
334 WRITE_INT_FIELD(resultRelIndex);
335 WRITE_NODE_FIELD(plans);
336 WRITE_NODE_FIELD(returningLists);
337 WRITE_NODE_FIELD(rowMarks);
338 WRITE_INT_FIELD(epqParam);
342 _outAppend(StringInfo str, Append *node)
344 WRITE_NODE_TYPE("APPEND");
346 _outPlanInfo(str, (Plan *) node);
348 WRITE_NODE_FIELD(appendplans);
352 _outMergeAppend(StringInfo str, MergeAppend *node)
356 WRITE_NODE_TYPE("MERGEAPPEND");
358 _outPlanInfo(str, (Plan *) node);
360 WRITE_NODE_FIELD(mergeplans);
362 WRITE_INT_FIELD(numCols);
364 appendStringInfo(str, " :sortColIdx");
365 for (i = 0; i < node->numCols; i++)
366 appendStringInfo(str, " %d", node->sortColIdx[i]);
368 appendStringInfo(str, " :sortOperators");
369 for (i = 0; i < node->numCols; i++)
370 appendStringInfo(str, " %u", node->sortOperators[i]);
372 appendStringInfo(str, " :collations");
373 for (i = 0; i < node->numCols; i++)
374 appendStringInfo(str, " %u", node->collations[i]);
376 appendStringInfo(str, " :nullsFirst");
377 for (i = 0; i < node->numCols; i++)
378 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
382 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
386 WRITE_NODE_TYPE("RECURSIVEUNION");
388 _outPlanInfo(str, (Plan *) node);
390 WRITE_INT_FIELD(wtParam);
391 WRITE_INT_FIELD(numCols);
393 appendStringInfo(str, " :dupColIdx");
394 for (i = 0; i < node->numCols; i++)
395 appendStringInfo(str, " %d", node->dupColIdx[i]);
397 appendStringInfo(str, " :dupOperators");
398 for (i = 0; i < node->numCols; i++)
399 appendStringInfo(str, " %u", node->dupOperators[i]);
401 WRITE_LONG_FIELD(numGroups);
405 _outBitmapAnd(StringInfo str, BitmapAnd *node)
407 WRITE_NODE_TYPE("BITMAPAND");
409 _outPlanInfo(str, (Plan *) node);
411 WRITE_NODE_FIELD(bitmapplans);
415 _outBitmapOr(StringInfo str, BitmapOr *node)
417 WRITE_NODE_TYPE("BITMAPOR");
419 _outPlanInfo(str, (Plan *) node);
421 WRITE_NODE_FIELD(bitmapplans);
425 _outScan(StringInfo str, Scan *node)
427 WRITE_NODE_TYPE("SCAN");
429 _outScanInfo(str, (Scan *) node);
433 _outSeqScan(StringInfo str, SeqScan *node)
435 WRITE_NODE_TYPE("SEQSCAN");
437 _outScanInfo(str, (Scan *) node);
441 _outIndexScan(StringInfo str, IndexScan *node)
443 WRITE_NODE_TYPE("INDEXSCAN");
445 _outScanInfo(str, (Scan *) node);
447 WRITE_OID_FIELD(indexid);
448 WRITE_NODE_FIELD(indexqual);
449 WRITE_NODE_FIELD(indexqualorig);
450 WRITE_NODE_FIELD(indexorderby);
451 WRITE_NODE_FIELD(indexorderbyorig);
452 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
456 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
458 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
460 _outScanInfo(str, (Scan *) node);
462 WRITE_OID_FIELD(indexid);
463 WRITE_NODE_FIELD(indexqual);
464 WRITE_NODE_FIELD(indexqualorig);
468 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
470 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
472 _outScanInfo(str, (Scan *) node);
474 WRITE_NODE_FIELD(bitmapqualorig);
478 _outTidScan(StringInfo str, TidScan *node)
480 WRITE_NODE_TYPE("TIDSCAN");
482 _outScanInfo(str, (Scan *) node);
484 WRITE_NODE_FIELD(tidquals);
488 _outSubqueryScan(StringInfo str, SubqueryScan *node)
490 WRITE_NODE_TYPE("SUBQUERYSCAN");
492 _outScanInfo(str, (Scan *) node);
494 WRITE_NODE_FIELD(subplan);
495 WRITE_NODE_FIELD(subrtable);
496 WRITE_NODE_FIELD(subrowmark);
500 _outFunctionScan(StringInfo str, FunctionScan *node)
502 WRITE_NODE_TYPE("FUNCTIONSCAN");
504 _outScanInfo(str, (Scan *) node);
506 WRITE_NODE_FIELD(funcexpr);
507 WRITE_NODE_FIELD(funccolnames);
508 WRITE_NODE_FIELD(funccoltypes);
509 WRITE_NODE_FIELD(funccoltypmods);
510 WRITE_NODE_FIELD(funccolcollations);
514 _outValuesScan(StringInfo str, ValuesScan *node)
516 WRITE_NODE_TYPE("VALUESSCAN");
518 _outScanInfo(str, (Scan *) node);
520 WRITE_NODE_FIELD(values_lists);
524 _outCteScan(StringInfo str, CteScan *node)
526 WRITE_NODE_TYPE("CTESCAN");
528 _outScanInfo(str, (Scan *) node);
530 WRITE_INT_FIELD(ctePlanId);
531 WRITE_INT_FIELD(cteParam);
535 _outWorkTableScan(StringInfo str, WorkTableScan *node)
537 WRITE_NODE_TYPE("WORKTABLESCAN");
539 _outScanInfo(str, (Scan *) node);
541 WRITE_INT_FIELD(wtParam);
545 _outForeignScan(StringInfo str, ForeignScan *node)
547 WRITE_NODE_TYPE("FOREIGNSCAN");
549 _outScanInfo(str, (Scan *) node);
551 WRITE_BOOL_FIELD(fsSystemCol);
552 WRITE_NODE_FIELD(fdwplan);
556 _outFdwPlan(StringInfo str, FdwPlan *node)
558 WRITE_NODE_TYPE("FDWPLAN");
560 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
561 WRITE_FLOAT_FIELD(total_cost, "%.2f");
562 WRITE_NODE_FIELD(fdw_private);
566 _outJoin(StringInfo str, Join *node)
568 WRITE_NODE_TYPE("JOIN");
570 _outJoinPlanInfo(str, (Join *) node);
574 _outNestLoop(StringInfo str, NestLoop *node)
576 WRITE_NODE_TYPE("NESTLOOP");
578 _outJoinPlanInfo(str, (Join *) node);
580 WRITE_NODE_FIELD(nestParams);
584 _outMergeJoin(StringInfo str, MergeJoin *node)
589 WRITE_NODE_TYPE("MERGEJOIN");
591 _outJoinPlanInfo(str, (Join *) node);
593 WRITE_NODE_FIELD(mergeclauses);
595 numCols = list_length(node->mergeclauses);
597 appendStringInfo(str, " :mergeFamilies");
598 for (i = 0; i < numCols; i++)
599 appendStringInfo(str, " %u", node->mergeFamilies[i]);
601 appendStringInfo(str, " :mergeCollations");
602 for (i = 0; i < numCols; i++)
603 appendStringInfo(str, " %u", node->mergeCollations[i]);
605 appendStringInfo(str, " :mergeStrategies");
606 for (i = 0; i < numCols; i++)
607 appendStringInfo(str, " %d", node->mergeStrategies[i]);
609 appendStringInfo(str, " :mergeNullsFirst");
610 for (i = 0; i < numCols; i++)
611 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
615 _outHashJoin(StringInfo str, HashJoin *node)
617 WRITE_NODE_TYPE("HASHJOIN");
619 _outJoinPlanInfo(str, (Join *) node);
621 WRITE_NODE_FIELD(hashclauses);
625 _outAgg(StringInfo str, Agg *node)
629 WRITE_NODE_TYPE("AGG");
631 _outPlanInfo(str, (Plan *) node);
633 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
634 WRITE_INT_FIELD(numCols);
636 appendStringInfo(str, " :grpColIdx");
637 for (i = 0; i < node->numCols; i++)
638 appendStringInfo(str, " %d", node->grpColIdx[i]);
640 appendStringInfo(str, " :grpOperators");
641 for (i = 0; i < node->numCols; i++)
642 appendStringInfo(str, " %u", node->grpOperators[i]);
644 WRITE_LONG_FIELD(numGroups);
648 _outWindowAgg(StringInfo str, WindowAgg *node)
652 WRITE_NODE_TYPE("WINDOWAGG");
654 _outPlanInfo(str, (Plan *) node);
656 WRITE_UINT_FIELD(winref);
657 WRITE_INT_FIELD(partNumCols);
659 appendStringInfo(str, " :partColIdx");
660 for (i = 0; i < node->partNumCols; i++)
661 appendStringInfo(str, " %d", node->partColIdx[i]);
663 appendStringInfo(str, " :partOperations");
664 for (i = 0; i < node->partNumCols; i++)
665 appendStringInfo(str, " %u", node->partOperators[i]);
667 WRITE_INT_FIELD(ordNumCols);
669 appendStringInfo(str, " :ordColIdx");
670 for (i = 0; i < node->ordNumCols; i++)
671 appendStringInfo(str, " %d", node->ordColIdx[i]);
673 appendStringInfo(str, " :ordOperations");
674 for (i = 0; i < node->ordNumCols; i++)
675 appendStringInfo(str, " %u", node->ordOperators[i]);
677 WRITE_INT_FIELD(frameOptions);
678 WRITE_NODE_FIELD(startOffset);
679 WRITE_NODE_FIELD(endOffset);
683 _outGroup(StringInfo str, Group *node)
687 WRITE_NODE_TYPE("GROUP");
689 _outPlanInfo(str, (Plan *) node);
691 WRITE_INT_FIELD(numCols);
693 appendStringInfo(str, " :grpColIdx");
694 for (i = 0; i < node->numCols; i++)
695 appendStringInfo(str, " %d", node->grpColIdx[i]);
697 appendStringInfo(str, " :grpOperators");
698 for (i = 0; i < node->numCols; i++)
699 appendStringInfo(str, " %u", node->grpOperators[i]);
703 _outMaterial(StringInfo str, Material *node)
705 WRITE_NODE_TYPE("MATERIAL");
707 _outPlanInfo(str, (Plan *) node);
711 _outSort(StringInfo str, Sort *node)
715 WRITE_NODE_TYPE("SORT");
717 _outPlanInfo(str, (Plan *) node);
719 WRITE_INT_FIELD(numCols);
721 appendStringInfo(str, " :sortColIdx");
722 for (i = 0; i < node->numCols; i++)
723 appendStringInfo(str, " %d", node->sortColIdx[i]);
725 appendStringInfo(str, " :sortOperators");
726 for (i = 0; i < node->numCols; i++)
727 appendStringInfo(str, " %u", node->sortOperators[i]);
729 appendStringInfo(str, " :collations");
730 for (i = 0; i < node->numCols; i++)
731 appendStringInfo(str, " %u", node->collations[i]);
733 appendStringInfo(str, " :nullsFirst");
734 for (i = 0; i < node->numCols; i++)
735 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
739 _outUnique(StringInfo str, Unique *node)
743 WRITE_NODE_TYPE("UNIQUE");
745 _outPlanInfo(str, (Plan *) node);
747 WRITE_INT_FIELD(numCols);
749 appendStringInfo(str, " :uniqColIdx");
750 for (i = 0; i < node->numCols; i++)
751 appendStringInfo(str, " %d", node->uniqColIdx[i]);
753 appendStringInfo(str, " :uniqOperators");
754 for (i = 0; i < node->numCols; i++)
755 appendStringInfo(str, " %u", node->uniqOperators[i]);
759 _outHash(StringInfo str, Hash *node)
761 WRITE_NODE_TYPE("HASH");
763 _outPlanInfo(str, (Plan *) node);
765 WRITE_OID_FIELD(skewTable);
766 WRITE_INT_FIELD(skewColumn);
767 WRITE_BOOL_FIELD(skewInherit);
768 WRITE_OID_FIELD(skewColType);
769 WRITE_INT_FIELD(skewColTypmod);
773 _outSetOp(StringInfo str, SetOp *node)
777 WRITE_NODE_TYPE("SETOP");
779 _outPlanInfo(str, (Plan *) node);
781 WRITE_ENUM_FIELD(cmd, SetOpCmd);
782 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
783 WRITE_INT_FIELD(numCols);
785 appendStringInfo(str, " :dupColIdx");
786 for (i = 0; i < node->numCols; i++)
787 appendStringInfo(str, " %d", node->dupColIdx[i]);
789 appendStringInfo(str, " :dupOperators");
790 for (i = 0; i < node->numCols; i++)
791 appendStringInfo(str, " %u", node->dupOperators[i]);
793 WRITE_INT_FIELD(flagColIdx);
794 WRITE_INT_FIELD(firstFlag);
795 WRITE_LONG_FIELD(numGroups);
799 _outLockRows(StringInfo str, LockRows *node)
801 WRITE_NODE_TYPE("LOCKROWS");
803 _outPlanInfo(str, (Plan *) node);
805 WRITE_NODE_FIELD(rowMarks);
806 WRITE_INT_FIELD(epqParam);
810 _outLimit(StringInfo str, Limit *node)
812 WRITE_NODE_TYPE("LIMIT");
814 _outPlanInfo(str, (Plan *) node);
816 WRITE_NODE_FIELD(limitOffset);
817 WRITE_NODE_FIELD(limitCount);
821 _outNestLoopParam(StringInfo str, NestLoopParam *node)
823 WRITE_NODE_TYPE("NESTLOOPPARAM");
825 WRITE_INT_FIELD(paramno);
826 WRITE_NODE_FIELD(paramval);
830 _outPlanRowMark(StringInfo str, PlanRowMark *node)
832 WRITE_NODE_TYPE("PLANROWMARK");
834 WRITE_UINT_FIELD(rti);
835 WRITE_UINT_FIELD(prti);
836 WRITE_UINT_FIELD(rowmarkId);
837 WRITE_ENUM_FIELD(markType, RowMarkType);
838 WRITE_BOOL_FIELD(noWait);
839 WRITE_BOOL_FIELD(isParent);
843 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
845 WRITE_NODE_TYPE("PLANINVALITEM");
847 WRITE_INT_FIELD(cacheId);
848 appendStringInfo(str, " :tupleId (%u,%u)",
849 ItemPointerGetBlockNumber(&node->tupleId),
850 ItemPointerGetOffsetNumber(&node->tupleId));
853 /*****************************************************************************
855 * Stuff from primnodes.h.
857 *****************************************************************************/
860 _outAlias(StringInfo str, Alias *node)
862 WRITE_NODE_TYPE("ALIAS");
864 WRITE_STRING_FIELD(aliasname);
865 WRITE_NODE_FIELD(colnames);
869 _outRangeVar(StringInfo str, RangeVar *node)
871 WRITE_NODE_TYPE("RANGEVAR");
874 * we deliberately ignore catalogname here, since it is presently not
875 * semantically meaningful
877 WRITE_STRING_FIELD(schemaname);
878 WRITE_STRING_FIELD(relname);
879 WRITE_ENUM_FIELD(inhOpt, InhOption);
880 WRITE_CHAR_FIELD(relpersistence);
881 WRITE_NODE_FIELD(alias);
882 WRITE_LOCATION_FIELD(location);
886 _outIntoClause(StringInfo str, IntoClause *node)
888 WRITE_NODE_TYPE("INTOCLAUSE");
890 WRITE_NODE_FIELD(rel);
891 WRITE_NODE_FIELD(colNames);
892 WRITE_NODE_FIELD(options);
893 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
894 WRITE_STRING_FIELD(tableSpaceName);
898 _outVar(StringInfo str, Var *node)
900 WRITE_NODE_TYPE("VAR");
902 WRITE_UINT_FIELD(varno);
903 WRITE_INT_FIELD(varattno);
904 WRITE_OID_FIELD(vartype);
905 WRITE_INT_FIELD(vartypmod);
906 WRITE_OID_FIELD(varcollid);
907 WRITE_UINT_FIELD(varlevelsup);
908 WRITE_UINT_FIELD(varnoold);
909 WRITE_INT_FIELD(varoattno);
910 WRITE_LOCATION_FIELD(location);
914 _outConst(StringInfo str, Const *node)
916 WRITE_NODE_TYPE("CONST");
918 WRITE_OID_FIELD(consttype);
919 WRITE_INT_FIELD(consttypmod);
920 WRITE_OID_FIELD(constcollid);
921 WRITE_INT_FIELD(constlen);
922 WRITE_BOOL_FIELD(constbyval);
923 WRITE_BOOL_FIELD(constisnull);
924 WRITE_LOCATION_FIELD(location);
926 appendStringInfo(str, " :constvalue ");
927 if (node->constisnull)
928 appendStringInfo(str, "<>");
930 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
934 _outParam(StringInfo str, Param *node)
936 WRITE_NODE_TYPE("PARAM");
938 WRITE_ENUM_FIELD(paramkind, ParamKind);
939 WRITE_INT_FIELD(paramid);
940 WRITE_OID_FIELD(paramtype);
941 WRITE_INT_FIELD(paramtypmod);
942 WRITE_OID_FIELD(paramcollation);
943 WRITE_LOCATION_FIELD(location);
947 _outAggref(StringInfo str, Aggref *node)
949 WRITE_NODE_TYPE("AGGREF");
951 WRITE_OID_FIELD(aggfnoid);
952 WRITE_OID_FIELD(aggtype);
953 WRITE_NODE_FIELD(args);
954 WRITE_NODE_FIELD(aggorder);
955 WRITE_NODE_FIELD(aggdistinct);
956 WRITE_BOOL_FIELD(aggstar);
957 WRITE_UINT_FIELD(agglevelsup);
958 WRITE_OID_FIELD(collid);
959 WRITE_LOCATION_FIELD(location);
963 _outWindowFunc(StringInfo str, WindowFunc *node)
965 WRITE_NODE_TYPE("WINDOWFUNC");
967 WRITE_OID_FIELD(winfnoid);
968 WRITE_OID_FIELD(wintype);
969 WRITE_NODE_FIELD(args);
970 WRITE_UINT_FIELD(winref);
971 WRITE_BOOL_FIELD(winstar);
972 WRITE_BOOL_FIELD(winagg);
973 WRITE_OID_FIELD(collid);
974 WRITE_LOCATION_FIELD(location);
978 _outArrayRef(StringInfo str, ArrayRef *node)
980 WRITE_NODE_TYPE("ARRAYREF");
982 WRITE_OID_FIELD(refarraytype);
983 WRITE_OID_FIELD(refelemtype);
984 WRITE_INT_FIELD(reftypmod);
985 WRITE_INT_FIELD(refcollid);
986 WRITE_NODE_FIELD(refupperindexpr);
987 WRITE_NODE_FIELD(reflowerindexpr);
988 WRITE_NODE_FIELD(refexpr);
989 WRITE_NODE_FIELD(refassgnexpr);
993 _outFuncExpr(StringInfo str, FuncExpr *node)
995 WRITE_NODE_TYPE("FUNCEXPR");
997 WRITE_OID_FIELD(funcid);
998 WRITE_OID_FIELD(funcresulttype);
999 WRITE_BOOL_FIELD(funcretset);
1000 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1001 WRITE_NODE_FIELD(args);
1002 WRITE_OID_FIELD(collid);
1003 WRITE_LOCATION_FIELD(location);
1007 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
1009 WRITE_NODE_TYPE("NAMEDARGEXPR");
1011 WRITE_NODE_FIELD(arg);
1012 WRITE_STRING_FIELD(name);
1013 WRITE_INT_FIELD(argnumber);
1014 WRITE_LOCATION_FIELD(location);
1018 _outOpExpr(StringInfo str, OpExpr *node)
1020 WRITE_NODE_TYPE("OPEXPR");
1022 WRITE_OID_FIELD(opno);
1023 WRITE_OID_FIELD(opfuncid);
1024 WRITE_OID_FIELD(opresulttype);
1025 WRITE_BOOL_FIELD(opretset);
1026 WRITE_NODE_FIELD(args);
1027 WRITE_OID_FIELD(collid);
1028 WRITE_LOCATION_FIELD(location);
1032 _outDistinctExpr(StringInfo str, DistinctExpr *node)
1034 WRITE_NODE_TYPE("DISTINCTEXPR");
1036 WRITE_OID_FIELD(opno);
1037 WRITE_OID_FIELD(opfuncid);
1038 WRITE_OID_FIELD(opresulttype);
1039 WRITE_BOOL_FIELD(opretset);
1040 WRITE_NODE_FIELD(args);
1041 WRITE_OID_FIELD(collid);
1042 WRITE_LOCATION_FIELD(location);
1046 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
1048 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1050 WRITE_OID_FIELD(opno);
1051 WRITE_OID_FIELD(opfuncid);
1052 WRITE_BOOL_FIELD(useOr);
1053 WRITE_NODE_FIELD(args);
1054 WRITE_OID_FIELD(collid);
1055 WRITE_LOCATION_FIELD(location);
1059 _outBoolExpr(StringInfo str, BoolExpr *node)
1063 WRITE_NODE_TYPE("BOOLEXPR");
1065 /* do-it-yourself enum representation */
1066 switch (node->boolop)
1078 appendStringInfo(str, " :boolop ");
1079 _outToken(str, opstr);
1081 WRITE_NODE_FIELD(args);
1082 WRITE_LOCATION_FIELD(location);
1086 _outSubLink(StringInfo str, SubLink *node)
1088 WRITE_NODE_TYPE("SUBLINK");
1090 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1091 WRITE_NODE_FIELD(testexpr);
1092 WRITE_NODE_FIELD(operName);
1093 WRITE_NODE_FIELD(subselect);
1094 WRITE_LOCATION_FIELD(location);
1098 _outSubPlan(StringInfo str, SubPlan *node)
1100 WRITE_NODE_TYPE("SUBPLAN");
1102 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1103 WRITE_NODE_FIELD(testexpr);
1104 WRITE_NODE_FIELD(paramIds);
1105 WRITE_INT_FIELD(plan_id);
1106 WRITE_STRING_FIELD(plan_name);
1107 WRITE_OID_FIELD(firstColType);
1108 WRITE_INT_FIELD(firstColTypmod);
1109 WRITE_OID_FIELD(firstColCollation);
1110 WRITE_BOOL_FIELD(useHashTable);
1111 WRITE_BOOL_FIELD(unknownEqFalse);
1112 WRITE_NODE_FIELD(setParam);
1113 WRITE_NODE_FIELD(parParam);
1114 WRITE_NODE_FIELD(args);
1115 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1116 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1120 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1122 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1124 WRITE_NODE_FIELD(subplans);
1128 _outFieldSelect(StringInfo str, FieldSelect *node)
1130 WRITE_NODE_TYPE("FIELDSELECT");
1132 WRITE_NODE_FIELD(arg);
1133 WRITE_INT_FIELD(fieldnum);
1134 WRITE_OID_FIELD(resulttype);
1135 WRITE_INT_FIELD(resulttypmod);
1136 WRITE_OID_FIELD(resultcollation);
1140 _outFieldStore(StringInfo str, FieldStore *node)
1142 WRITE_NODE_TYPE("FIELDSTORE");
1144 WRITE_NODE_FIELD(arg);
1145 WRITE_NODE_FIELD(newvals);
1146 WRITE_NODE_FIELD(fieldnums);
1147 WRITE_OID_FIELD(resulttype);
1151 _outRelabelType(StringInfo str, RelabelType *node)
1153 WRITE_NODE_TYPE("RELABELTYPE");
1155 WRITE_NODE_FIELD(arg);
1156 WRITE_OID_FIELD(resulttype);
1157 WRITE_INT_FIELD(resulttypmod);
1158 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1159 WRITE_LOCATION_FIELD(location);
1163 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1165 WRITE_NODE_TYPE("COERCEVIAIO");
1167 WRITE_NODE_FIELD(arg);
1168 WRITE_OID_FIELD(resulttype);
1169 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1170 WRITE_LOCATION_FIELD(location);
1174 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1176 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1178 WRITE_NODE_FIELD(arg);
1179 WRITE_OID_FIELD(elemfuncid);
1180 WRITE_OID_FIELD(resulttype);
1181 WRITE_INT_FIELD(resulttypmod);
1182 WRITE_BOOL_FIELD(isExplicit);
1183 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1184 WRITE_LOCATION_FIELD(location);
1188 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1190 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1192 WRITE_NODE_FIELD(arg);
1193 WRITE_OID_FIELD(resulttype);
1194 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1195 WRITE_LOCATION_FIELD(location);
1199 _outCollateExpr(StringInfo str, CollateExpr *node)
1201 WRITE_NODE_TYPE("COLLATE");
1203 WRITE_NODE_FIELD(arg);
1204 WRITE_OID_FIELD(collOid);
1205 WRITE_LOCATION_FIELD(location);
1209 _outCaseExpr(StringInfo str, CaseExpr *node)
1211 WRITE_NODE_TYPE("CASE");
1213 WRITE_OID_FIELD(casetype);
1214 WRITE_OID_FIELD(casecollation);
1215 WRITE_NODE_FIELD(arg);
1216 WRITE_NODE_FIELD(args);
1217 WRITE_NODE_FIELD(defresult);
1218 WRITE_LOCATION_FIELD(location);
1222 _outCaseWhen(StringInfo str, CaseWhen *node)
1224 WRITE_NODE_TYPE("WHEN");
1226 WRITE_NODE_FIELD(expr);
1227 WRITE_NODE_FIELD(result);
1228 WRITE_LOCATION_FIELD(location);
1232 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1234 WRITE_NODE_TYPE("CASETESTEXPR");
1236 WRITE_OID_FIELD(typeId);
1237 WRITE_INT_FIELD(typeMod);
1238 WRITE_OID_FIELD(collation);
1242 _outArrayExpr(StringInfo str, ArrayExpr *node)
1244 WRITE_NODE_TYPE("ARRAY");
1246 WRITE_OID_FIELD(array_typeid);
1247 WRITE_OID_FIELD(element_typeid);
1248 WRITE_NODE_FIELD(elements);
1249 WRITE_BOOL_FIELD(multidims);
1250 WRITE_LOCATION_FIELD(location);
1254 _outRowExpr(StringInfo str, RowExpr *node)
1256 WRITE_NODE_TYPE("ROW");
1258 WRITE_NODE_FIELD(args);
1259 WRITE_OID_FIELD(row_typeid);
1260 WRITE_ENUM_FIELD(row_format, CoercionForm);
1261 WRITE_NODE_FIELD(colnames);
1262 WRITE_LOCATION_FIELD(location);
1266 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1268 WRITE_NODE_TYPE("ROWCOMPARE");
1270 WRITE_ENUM_FIELD(rctype, RowCompareType);
1271 WRITE_NODE_FIELD(opnos);
1272 WRITE_NODE_FIELD(opfamilies);
1273 WRITE_NODE_FIELD(collids);
1274 WRITE_NODE_FIELD(largs);
1275 WRITE_NODE_FIELD(rargs);
1279 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1281 WRITE_NODE_TYPE("COALESCE");
1283 WRITE_OID_FIELD(coalescetype);
1284 WRITE_OID_FIELD(coalescecollation);
1285 WRITE_NODE_FIELD(args);
1286 WRITE_LOCATION_FIELD(location);
1290 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1292 WRITE_NODE_TYPE("MINMAX");
1294 WRITE_OID_FIELD(minmaxtype);
1295 WRITE_ENUM_FIELD(op, MinMaxOp);
1296 WRITE_NODE_FIELD(args);
1297 WRITE_OID_FIELD(collid);
1298 WRITE_LOCATION_FIELD(location);
1302 _outXmlExpr(StringInfo str, XmlExpr *node)
1304 WRITE_NODE_TYPE("XMLEXPR");
1306 WRITE_ENUM_FIELD(op, XmlExprOp);
1307 WRITE_STRING_FIELD(name);
1308 WRITE_NODE_FIELD(named_args);
1309 WRITE_NODE_FIELD(arg_names);
1310 WRITE_NODE_FIELD(args);
1311 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1312 WRITE_OID_FIELD(type);
1313 WRITE_INT_FIELD(typmod);
1314 WRITE_LOCATION_FIELD(location);
1318 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1320 WRITE_NODE_TYPE("NULLIFEXPR");
1322 WRITE_OID_FIELD(opno);
1323 WRITE_OID_FIELD(opfuncid);
1324 WRITE_OID_FIELD(opresulttype);
1325 WRITE_BOOL_FIELD(opretset);
1326 WRITE_NODE_FIELD(args);
1327 WRITE_LOCATION_FIELD(location);
1331 _outNullTest(StringInfo str, NullTest *node)
1333 WRITE_NODE_TYPE("NULLTEST");
1335 WRITE_NODE_FIELD(arg);
1336 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1337 WRITE_BOOL_FIELD(argisrow);
1341 _outBooleanTest(StringInfo str, BooleanTest *node)
1343 WRITE_NODE_TYPE("BOOLEANTEST");
1345 WRITE_NODE_FIELD(arg);
1346 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1350 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1352 WRITE_NODE_TYPE("COERCETODOMAIN");
1354 WRITE_NODE_FIELD(arg);
1355 WRITE_OID_FIELD(resulttype);
1356 WRITE_INT_FIELD(resulttypmod);
1357 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1358 WRITE_LOCATION_FIELD(location);
1362 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1364 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1366 WRITE_OID_FIELD(typeId);
1367 WRITE_INT_FIELD(typeMod);
1368 WRITE_LOCATION_FIELD(location);
1372 _outSetToDefault(StringInfo str, SetToDefault *node)
1374 WRITE_NODE_TYPE("SETTODEFAULT");
1376 WRITE_OID_FIELD(typeId);
1377 WRITE_INT_FIELD(typeMod);
1378 WRITE_OID_FIELD(collid);
1379 WRITE_LOCATION_FIELD(location);
1383 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1385 WRITE_NODE_TYPE("CURRENTOFEXPR");
1387 WRITE_UINT_FIELD(cvarno);
1388 WRITE_STRING_FIELD(cursor_name);
1389 WRITE_INT_FIELD(cursor_param);
1393 _outTargetEntry(StringInfo str, TargetEntry *node)
1395 WRITE_NODE_TYPE("TARGETENTRY");
1397 WRITE_NODE_FIELD(expr);
1398 WRITE_INT_FIELD(resno);
1399 WRITE_STRING_FIELD(resname);
1400 WRITE_UINT_FIELD(ressortgroupref);
1401 WRITE_OID_FIELD(resorigtbl);
1402 WRITE_INT_FIELD(resorigcol);
1403 WRITE_BOOL_FIELD(resjunk);
1407 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1409 WRITE_NODE_TYPE("RANGETBLREF");
1411 WRITE_INT_FIELD(rtindex);
1415 _outJoinExpr(StringInfo str, JoinExpr *node)
1417 WRITE_NODE_TYPE("JOINEXPR");
1419 WRITE_ENUM_FIELD(jointype, JoinType);
1420 WRITE_BOOL_FIELD(isNatural);
1421 WRITE_NODE_FIELD(larg);
1422 WRITE_NODE_FIELD(rarg);
1423 WRITE_NODE_FIELD(usingClause);
1424 WRITE_NODE_FIELD(quals);
1425 WRITE_NODE_FIELD(alias);
1426 WRITE_INT_FIELD(rtindex);
1430 _outFromExpr(StringInfo str, FromExpr *node)
1432 WRITE_NODE_TYPE("FROMEXPR");
1434 WRITE_NODE_FIELD(fromlist);
1435 WRITE_NODE_FIELD(quals);
1438 /*****************************************************************************
1440 * Stuff from relation.h.
1442 *****************************************************************************/
1445 * print the basic stuff of all nodes that inherit from Path
1447 * Note we do NOT print the parent, else we'd be in infinite recursion.
1448 * We can print the parent's relids for identification purposes, though.
1451 _outPathInfo(StringInfo str, Path *node)
1453 WRITE_ENUM_FIELD(pathtype, NodeTag);
1454 appendStringInfo(str, " :parent_relids ");
1455 _outBitmapset(str, node->parent->relids);
1456 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1457 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1458 WRITE_NODE_FIELD(pathkeys);
1462 * print the basic stuff of all nodes that inherit from JoinPath
1465 _outJoinPathInfo(StringInfo str, JoinPath *node)
1467 _outPathInfo(str, (Path *) node);
1469 WRITE_ENUM_FIELD(jointype, JoinType);
1470 WRITE_NODE_FIELD(outerjoinpath);
1471 WRITE_NODE_FIELD(innerjoinpath);
1472 WRITE_NODE_FIELD(joinrestrictinfo);
1476 _outPath(StringInfo str, Path *node)
1478 WRITE_NODE_TYPE("PATH");
1480 _outPathInfo(str, (Path *) node);
1484 _outIndexPath(StringInfo str, IndexPath *node)
1486 WRITE_NODE_TYPE("INDEXPATH");
1488 _outPathInfo(str, (Path *) node);
1490 WRITE_NODE_FIELD(indexinfo);
1491 WRITE_NODE_FIELD(indexclauses);
1492 WRITE_NODE_FIELD(indexquals);
1493 WRITE_NODE_FIELD(indexorderbys);
1494 WRITE_BOOL_FIELD(isjoininner);
1495 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1496 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1497 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1498 WRITE_FLOAT_FIELD(rows, "%.0f");
1502 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1504 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1506 _outPathInfo(str, (Path *) node);
1508 WRITE_NODE_FIELD(bitmapqual);
1509 WRITE_BOOL_FIELD(isjoininner);
1510 WRITE_FLOAT_FIELD(rows, "%.0f");
1514 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1516 WRITE_NODE_TYPE("BITMAPANDPATH");
1518 _outPathInfo(str, (Path *) node);
1520 WRITE_NODE_FIELD(bitmapquals);
1521 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1525 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1527 WRITE_NODE_TYPE("BITMAPORPATH");
1529 _outPathInfo(str, (Path *) node);
1531 WRITE_NODE_FIELD(bitmapquals);
1532 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1536 _outTidPath(StringInfo str, TidPath *node)
1538 WRITE_NODE_TYPE("TIDPATH");
1540 _outPathInfo(str, (Path *) node);
1542 WRITE_NODE_FIELD(tidquals);
1546 _outForeignPath(StringInfo str, ForeignPath *node)
1548 WRITE_NODE_TYPE("FOREIGNPATH");
1550 _outPathInfo(str, (Path *) node);
1552 WRITE_NODE_FIELD(fdwplan);
1556 _outAppendPath(StringInfo str, AppendPath *node)
1558 WRITE_NODE_TYPE("APPENDPATH");
1560 _outPathInfo(str, (Path *) node);
1562 WRITE_NODE_FIELD(subpaths);
1566 _outMergeAppendPath(StringInfo str, MergeAppendPath *node)
1568 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1570 _outPathInfo(str, (Path *) node);
1572 WRITE_NODE_FIELD(subpaths);
1573 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1577 _outResultPath(StringInfo str, ResultPath *node)
1579 WRITE_NODE_TYPE("RESULTPATH");
1581 _outPathInfo(str, (Path *) node);
1583 WRITE_NODE_FIELD(quals);
1587 _outMaterialPath(StringInfo str, MaterialPath *node)
1589 WRITE_NODE_TYPE("MATERIALPATH");
1591 _outPathInfo(str, (Path *) node);
1593 WRITE_NODE_FIELD(subpath);
1597 _outUniquePath(StringInfo str, UniquePath *node)
1599 WRITE_NODE_TYPE("UNIQUEPATH");
1601 _outPathInfo(str, (Path *) node);
1603 WRITE_NODE_FIELD(subpath);
1604 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1605 WRITE_NODE_FIELD(in_operators);
1606 WRITE_NODE_FIELD(uniq_exprs);
1607 WRITE_FLOAT_FIELD(rows, "%.0f");
1611 _outNestPath(StringInfo str, NestPath *node)
1613 WRITE_NODE_TYPE("NESTPATH");
1615 _outJoinPathInfo(str, (JoinPath *) node);
1619 _outMergePath(StringInfo str, MergePath *node)
1621 WRITE_NODE_TYPE("MERGEPATH");
1623 _outJoinPathInfo(str, (JoinPath *) node);
1625 WRITE_NODE_FIELD(path_mergeclauses);
1626 WRITE_NODE_FIELD(outersortkeys);
1627 WRITE_NODE_FIELD(innersortkeys);
1628 WRITE_BOOL_FIELD(materialize_inner);
1632 _outHashPath(StringInfo str, HashPath *node)
1634 WRITE_NODE_TYPE("HASHPATH");
1636 _outJoinPathInfo(str, (JoinPath *) node);
1638 WRITE_NODE_FIELD(path_hashclauses);
1639 WRITE_INT_FIELD(num_batches);
1643 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1645 WRITE_NODE_TYPE("PLANNERGLOBAL");
1647 /* NB: this isn't a complete set of fields */
1648 WRITE_NODE_FIELD(paramlist);
1649 WRITE_NODE_FIELD(subplans);
1650 WRITE_NODE_FIELD(subrtables);
1651 WRITE_NODE_FIELD(subrowmarks);
1652 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1653 WRITE_NODE_FIELD(finalrtable);
1654 WRITE_NODE_FIELD(finalrowmarks);
1655 WRITE_NODE_FIELD(resultRelations);
1656 WRITE_NODE_FIELD(relationOids);
1657 WRITE_NODE_FIELD(invalItems);
1658 WRITE_UINT_FIELD(lastPHId);
1659 WRITE_UINT_FIELD(lastRowMarkId);
1660 WRITE_BOOL_FIELD(transientPlan);
1664 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1666 WRITE_NODE_TYPE("PLANNERINFO");
1668 /* NB: this isn't a complete set of fields */
1669 WRITE_NODE_FIELD(parse);
1670 WRITE_NODE_FIELD(glob);
1671 WRITE_UINT_FIELD(query_level);
1672 WRITE_NODE_FIELD(join_rel_list);
1673 WRITE_INT_FIELD(join_cur_level);
1674 WRITE_NODE_FIELD(init_plans);
1675 WRITE_NODE_FIELD(cte_plan_ids);
1676 WRITE_NODE_FIELD(eq_classes);
1677 WRITE_NODE_FIELD(canon_pathkeys);
1678 WRITE_NODE_FIELD(left_join_clauses);
1679 WRITE_NODE_FIELD(right_join_clauses);
1680 WRITE_NODE_FIELD(full_join_clauses);
1681 WRITE_NODE_FIELD(join_info_list);
1682 WRITE_NODE_FIELD(append_rel_list);
1683 WRITE_NODE_FIELD(rowMarks);
1684 WRITE_NODE_FIELD(placeholder_list);
1685 WRITE_NODE_FIELD(query_pathkeys);
1686 WRITE_NODE_FIELD(group_pathkeys);
1687 WRITE_NODE_FIELD(window_pathkeys);
1688 WRITE_NODE_FIELD(distinct_pathkeys);
1689 WRITE_NODE_FIELD(sort_pathkeys);
1690 WRITE_NODE_FIELD(minmax_aggs);
1691 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1692 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1693 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1694 WRITE_BOOL_FIELD(hasInheritedTarget);
1695 WRITE_BOOL_FIELD(hasJoinRTEs);
1696 WRITE_BOOL_FIELD(hasHavingQual);
1697 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1698 WRITE_BOOL_FIELD(hasRecursion);
1699 WRITE_INT_FIELD(wt_param_id);
1700 WRITE_BITMAPSET_FIELD(curOuterRels);
1701 WRITE_NODE_FIELD(curOuterParams);
1705 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1707 WRITE_NODE_TYPE("RELOPTINFO");
1709 /* NB: this isn't a complete set of fields */
1710 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1711 WRITE_BITMAPSET_FIELD(relids);
1712 WRITE_FLOAT_FIELD(rows, "%.0f");
1713 WRITE_INT_FIELD(width);
1714 WRITE_NODE_FIELD(reltargetlist);
1715 WRITE_NODE_FIELD(pathlist);
1716 WRITE_NODE_FIELD(cheapest_startup_path);
1717 WRITE_NODE_FIELD(cheapest_total_path);
1718 WRITE_NODE_FIELD(cheapest_unique_path);
1719 WRITE_UINT_FIELD(relid);
1720 WRITE_UINT_FIELD(reltablespace);
1721 WRITE_ENUM_FIELD(rtekind, RTEKind);
1722 WRITE_INT_FIELD(min_attr);
1723 WRITE_INT_FIELD(max_attr);
1724 WRITE_NODE_FIELD(indexlist);
1725 WRITE_UINT_FIELD(pages);
1726 WRITE_FLOAT_FIELD(tuples, "%.0f");
1727 WRITE_NODE_FIELD(subplan);
1728 WRITE_NODE_FIELD(subrtable);
1729 WRITE_NODE_FIELD(subrowmark);
1730 WRITE_NODE_FIELD(baserestrictinfo);
1731 WRITE_NODE_FIELD(joininfo);
1732 WRITE_BOOL_FIELD(has_eclass_joins);
1733 WRITE_BITMAPSET_FIELD(index_outer_relids);
1734 WRITE_NODE_FIELD(index_inner_paths);
1738 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1740 WRITE_NODE_TYPE("INDEXOPTINFO");
1742 /* NB: this isn't a complete set of fields */
1743 WRITE_OID_FIELD(indexoid);
1744 /* Do NOT print rel field, else infinite recursion */
1745 WRITE_UINT_FIELD(pages);
1746 WRITE_FLOAT_FIELD(tuples, "%.0f");
1747 WRITE_INT_FIELD(ncolumns);
1748 WRITE_OID_FIELD(relam);
1749 WRITE_NODE_FIELD(indexprs);
1750 WRITE_NODE_FIELD(indpred);
1751 WRITE_BOOL_FIELD(predOK);
1752 WRITE_BOOL_FIELD(unique);
1753 WRITE_BOOL_FIELD(hypothetical);
1757 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1760 * To simplify reading, we just chase up to the topmost merged EC and
1761 * print that, without bothering to show the merge-ees separately.
1763 while (node->ec_merged)
1764 node = node->ec_merged;
1766 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1768 WRITE_NODE_FIELD(ec_opfamilies);
1769 WRITE_NODE_FIELD(ec_members);
1770 WRITE_NODE_FIELD(ec_sources);
1771 WRITE_NODE_FIELD(ec_derives);
1772 WRITE_BITMAPSET_FIELD(ec_relids);
1773 WRITE_BOOL_FIELD(ec_has_const);
1774 WRITE_BOOL_FIELD(ec_has_volatile);
1775 WRITE_BOOL_FIELD(ec_below_outer_join);
1776 WRITE_BOOL_FIELD(ec_broken);
1777 WRITE_UINT_FIELD(ec_sortref);
1781 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1783 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1785 WRITE_NODE_FIELD(em_expr);
1786 WRITE_BITMAPSET_FIELD(em_relids);
1787 WRITE_BOOL_FIELD(em_is_const);
1788 WRITE_BOOL_FIELD(em_is_child);
1789 WRITE_OID_FIELD(em_datatype);
1793 _outPathKey(StringInfo str, PathKey *node)
1795 WRITE_NODE_TYPE("PATHKEY");
1797 WRITE_NODE_FIELD(pk_eclass);
1798 WRITE_OID_FIELD(pk_opfamily);
1799 WRITE_OID_FIELD(pk_collation);
1800 WRITE_INT_FIELD(pk_strategy);
1801 WRITE_BOOL_FIELD(pk_nulls_first);
1805 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1807 WRITE_NODE_TYPE("RESTRICTINFO");
1809 /* NB: this isn't a complete set of fields */
1810 WRITE_NODE_FIELD(clause);
1811 WRITE_BOOL_FIELD(is_pushed_down);
1812 WRITE_BOOL_FIELD(outerjoin_delayed);
1813 WRITE_BOOL_FIELD(can_join);
1814 WRITE_BOOL_FIELD(pseudoconstant);
1815 WRITE_BITMAPSET_FIELD(clause_relids);
1816 WRITE_BITMAPSET_FIELD(required_relids);
1817 WRITE_BITMAPSET_FIELD(nullable_relids);
1818 WRITE_BITMAPSET_FIELD(left_relids);
1819 WRITE_BITMAPSET_FIELD(right_relids);
1820 WRITE_NODE_FIELD(orclause);
1821 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1822 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1823 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1824 WRITE_NODE_FIELD(mergeopfamilies);
1825 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1826 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1827 WRITE_NODE_FIELD(left_em);
1828 WRITE_NODE_FIELD(right_em);
1829 WRITE_BOOL_FIELD(outer_is_left);
1830 WRITE_OID_FIELD(hashjoinoperator);
1834 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1836 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1837 WRITE_BITMAPSET_FIELD(other_relids);
1838 WRITE_BOOL_FIELD(isouterjoin);
1839 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1840 WRITE_NODE_FIELD(cheapest_total_innerpath);
1844 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1846 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1848 WRITE_NODE_FIELD(phexpr);
1849 WRITE_BITMAPSET_FIELD(phrels);
1850 WRITE_UINT_FIELD(phid);
1851 WRITE_UINT_FIELD(phlevelsup);
1855 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1857 WRITE_NODE_TYPE("SPECIALJOININFO");
1859 WRITE_BITMAPSET_FIELD(min_lefthand);
1860 WRITE_BITMAPSET_FIELD(min_righthand);
1861 WRITE_BITMAPSET_FIELD(syn_lefthand);
1862 WRITE_BITMAPSET_FIELD(syn_righthand);
1863 WRITE_ENUM_FIELD(jointype, JoinType);
1864 WRITE_BOOL_FIELD(lhs_strict);
1865 WRITE_BOOL_FIELD(delay_upper_joins);
1866 WRITE_NODE_FIELD(join_quals);
1870 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1872 WRITE_NODE_TYPE("APPENDRELINFO");
1874 WRITE_UINT_FIELD(parent_relid);
1875 WRITE_UINT_FIELD(child_relid);
1876 WRITE_OID_FIELD(parent_reltype);
1877 WRITE_OID_FIELD(child_reltype);
1878 WRITE_NODE_FIELD(translated_vars);
1879 WRITE_OID_FIELD(parent_reloid);
1883 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1885 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1887 WRITE_UINT_FIELD(phid);
1888 WRITE_NODE_FIELD(ph_var);
1889 WRITE_BITMAPSET_FIELD(ph_eval_at);
1890 WRITE_BITMAPSET_FIELD(ph_needed);
1891 WRITE_BITMAPSET_FIELD(ph_may_need);
1892 WRITE_INT_FIELD(ph_width);
1896 _outMinMaxAggInfo(StringInfo str, MinMaxAggInfo *node)
1898 WRITE_NODE_TYPE("MINMAXAGGINFO");
1900 WRITE_OID_FIELD(aggfnoid);
1901 WRITE_OID_FIELD(aggsortop);
1902 WRITE_NODE_FIELD(target);
1903 WRITE_NODE_FIELD(pathkeys);
1907 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1909 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1911 WRITE_NODE_FIELD(item);
1912 WRITE_UINT_FIELD(abslevel);
1915 /*****************************************************************************
1917 * Stuff from parsenodes.h.
1919 *****************************************************************************/
1922 _outCreateStmt(StringInfo str, CreateStmt *node)
1924 WRITE_NODE_TYPE("CREATESTMT");
1926 WRITE_NODE_FIELD(relation);
1927 WRITE_NODE_FIELD(tableElts);
1928 WRITE_NODE_FIELD(inhRelations);
1929 WRITE_NODE_FIELD(ofTypename);
1930 WRITE_NODE_FIELD(constraints);
1931 WRITE_NODE_FIELD(options);
1932 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1933 WRITE_STRING_FIELD(tablespacename);
1934 WRITE_BOOL_FIELD(if_not_exists);
1938 _outCreateForeignTableStmt(StringInfo str, CreateForeignTableStmt *node)
1940 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
1942 _outCreateStmt(str, (CreateStmt *) &node->base);
1944 WRITE_STRING_FIELD(servername);
1945 WRITE_NODE_FIELD(options);
1949 _outIndexStmt(StringInfo str, IndexStmt *node)
1951 WRITE_NODE_TYPE("INDEXSTMT");
1953 WRITE_STRING_FIELD(idxname);
1954 WRITE_NODE_FIELD(relation);
1955 WRITE_STRING_FIELD(accessMethod);
1956 WRITE_STRING_FIELD(tableSpace);
1957 WRITE_NODE_FIELD(indexParams);
1958 WRITE_NODE_FIELD(options);
1959 WRITE_NODE_FIELD(whereClause);
1960 WRITE_NODE_FIELD(excludeOpNames);
1961 WRITE_OID_FIELD(indexOid);
1962 WRITE_BOOL_FIELD(unique);
1963 WRITE_BOOL_FIELD(primary);
1964 WRITE_BOOL_FIELD(isconstraint);
1965 WRITE_BOOL_FIELD(deferrable);
1966 WRITE_BOOL_FIELD(initdeferred);
1967 WRITE_BOOL_FIELD(concurrent);
1971 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1973 WRITE_NODE_TYPE("NOTIFY");
1975 WRITE_STRING_FIELD(conditionname);
1976 WRITE_STRING_FIELD(payload);
1980 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1982 WRITE_NODE_TYPE("DECLARECURSOR");
1984 WRITE_STRING_FIELD(portalname);
1985 WRITE_INT_FIELD(options);
1986 WRITE_NODE_FIELD(query);
1990 _outSelectStmt(StringInfo str, SelectStmt *node)
1992 WRITE_NODE_TYPE("SELECT");
1994 WRITE_NODE_FIELD(distinctClause);
1995 WRITE_NODE_FIELD(intoClause);
1996 WRITE_NODE_FIELD(targetList);
1997 WRITE_NODE_FIELD(fromClause);
1998 WRITE_NODE_FIELD(whereClause);
1999 WRITE_NODE_FIELD(groupClause);
2000 WRITE_NODE_FIELD(havingClause);
2001 WRITE_NODE_FIELD(windowClause);
2002 WRITE_NODE_FIELD(withClause);
2003 WRITE_NODE_FIELD(valuesLists);
2004 WRITE_NODE_FIELD(sortClause);
2005 WRITE_NODE_FIELD(limitOffset);
2006 WRITE_NODE_FIELD(limitCount);
2007 WRITE_NODE_FIELD(lockingClause);
2008 WRITE_ENUM_FIELD(op, SetOperation);
2009 WRITE_BOOL_FIELD(all);
2010 WRITE_NODE_FIELD(larg);
2011 WRITE_NODE_FIELD(rarg);
2015 _outFuncCall(StringInfo str, FuncCall *node)
2017 WRITE_NODE_TYPE("FUNCCALL");
2019 WRITE_NODE_FIELD(funcname);
2020 WRITE_NODE_FIELD(args);
2021 WRITE_NODE_FIELD(agg_order);
2022 WRITE_BOOL_FIELD(agg_star);
2023 WRITE_BOOL_FIELD(agg_distinct);
2024 WRITE_BOOL_FIELD(func_variadic);
2025 WRITE_NODE_FIELD(over);
2026 WRITE_LOCATION_FIELD(location);
2030 _outDefElem(StringInfo str, DefElem *node)
2032 WRITE_NODE_TYPE("DEFELEM");
2034 WRITE_STRING_FIELD(defnamespace);
2035 WRITE_STRING_FIELD(defname);
2036 WRITE_NODE_FIELD(arg);
2037 WRITE_ENUM_FIELD(defaction, DefElemAction);
2041 _outInhRelation(StringInfo str, InhRelation *node)
2043 WRITE_NODE_TYPE("INHRELATION");
2045 WRITE_NODE_FIELD(relation);
2046 WRITE_UINT_FIELD(options);
2050 _outLockingClause(StringInfo str, LockingClause *node)
2052 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2054 WRITE_NODE_FIELD(lockedRels);
2055 WRITE_BOOL_FIELD(forUpdate);
2056 WRITE_BOOL_FIELD(noWait);
2060 _outXmlSerialize(StringInfo str, XmlSerialize *node)
2062 WRITE_NODE_TYPE("XMLSERIALIZE");
2064 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2065 WRITE_NODE_FIELD(expr);
2066 WRITE_NODE_FIELD(typeName);
2067 WRITE_LOCATION_FIELD(location);
2071 _outColumnDef(StringInfo str, ColumnDef *node)
2073 WRITE_NODE_TYPE("COLUMNDEF");
2075 WRITE_STRING_FIELD(colname);
2076 WRITE_NODE_FIELD(typeName);
2077 WRITE_INT_FIELD(inhcount);
2078 WRITE_BOOL_FIELD(is_local);
2079 WRITE_BOOL_FIELD(is_not_null);
2080 WRITE_BOOL_FIELD(is_from_type);
2081 WRITE_INT_FIELD(storage);
2082 WRITE_NODE_FIELD(raw_default);
2083 WRITE_NODE_FIELD(cooked_default);
2084 WRITE_NODE_FIELD(collClause);
2085 WRITE_OID_FIELD(collOid);
2086 WRITE_NODE_FIELD(constraints);
2090 _outTypeName(StringInfo str, TypeName *node)
2092 WRITE_NODE_TYPE("TYPENAME");
2094 WRITE_NODE_FIELD(names);
2095 WRITE_OID_FIELD(typeOid);
2096 WRITE_BOOL_FIELD(setof);
2097 WRITE_BOOL_FIELD(pct_type);
2098 WRITE_NODE_FIELD(typmods);
2099 WRITE_INT_FIELD(typemod);
2100 WRITE_NODE_FIELD(arrayBounds);
2101 WRITE_LOCATION_FIELD(location);
2105 _outTypeCast(StringInfo str, TypeCast *node)
2107 WRITE_NODE_TYPE("TYPECAST");
2109 WRITE_NODE_FIELD(arg);
2110 WRITE_NODE_FIELD(typeName);
2111 WRITE_LOCATION_FIELD(location);
2115 _outCollateClause(StringInfo str, CollateClause *node)
2117 WRITE_NODE_TYPE("COLLATECLAUSE");
2119 WRITE_NODE_FIELD(arg);
2120 WRITE_NODE_FIELD(collname);
2121 WRITE_LOCATION_FIELD(location);
2125 _outIndexElem(StringInfo str, IndexElem *node)
2127 WRITE_NODE_TYPE("INDEXELEM");
2129 WRITE_STRING_FIELD(name);
2130 WRITE_NODE_FIELD(expr);
2131 WRITE_STRING_FIELD(indexcolname);
2132 WRITE_NODE_FIELD(collation);
2133 WRITE_NODE_FIELD(opclass);
2134 WRITE_ENUM_FIELD(ordering, SortByDir);
2135 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2139 _outQuery(StringInfo str, Query *node)
2141 WRITE_NODE_TYPE("QUERY");
2143 WRITE_ENUM_FIELD(commandType, CmdType);
2144 WRITE_ENUM_FIELD(querySource, QuerySource);
2145 WRITE_BOOL_FIELD(canSetTag);
2148 * Hack to work around missing outfuncs routines for a lot of the
2149 * utility-statement node types. (The only one we actually *need* for
2150 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2151 * for the meantime do this to avoid getting lots of warnings when running
2152 * with debug_print_parse on.
2154 if (node->utilityStmt)
2156 switch (nodeTag(node->utilityStmt))
2161 case T_DeclareCursorStmt:
2162 WRITE_NODE_FIELD(utilityStmt);
2165 appendStringInfo(str, " :utilityStmt ?");
2170 appendStringInfo(str, " :utilityStmt <>");
2172 WRITE_INT_FIELD(resultRelation);
2173 WRITE_NODE_FIELD(intoClause);
2174 WRITE_BOOL_FIELD(hasAggs);
2175 WRITE_BOOL_FIELD(hasWindowFuncs);
2176 WRITE_BOOL_FIELD(hasSubLinks);
2177 WRITE_BOOL_FIELD(hasDistinctOn);
2178 WRITE_BOOL_FIELD(hasRecursive);
2179 WRITE_BOOL_FIELD(hasModifyingCTE);
2180 WRITE_BOOL_FIELD(hasForUpdate);
2181 WRITE_NODE_FIELD(cteList);
2182 WRITE_NODE_FIELD(rtable);
2183 WRITE_NODE_FIELD(jointree);
2184 WRITE_NODE_FIELD(targetList);
2185 WRITE_NODE_FIELD(returningList);
2186 WRITE_NODE_FIELD(groupClause);
2187 WRITE_NODE_FIELD(havingQual);
2188 WRITE_NODE_FIELD(windowClause);
2189 WRITE_NODE_FIELD(distinctClause);
2190 WRITE_NODE_FIELD(sortClause);
2191 WRITE_NODE_FIELD(limitOffset);
2192 WRITE_NODE_FIELD(limitCount);
2193 WRITE_NODE_FIELD(rowMarks);
2194 WRITE_NODE_FIELD(setOperations);
2195 WRITE_NODE_FIELD(constraintDeps);
2199 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2201 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2203 WRITE_UINT_FIELD(tleSortGroupRef);
2204 WRITE_OID_FIELD(eqop);
2205 WRITE_OID_FIELD(sortop);
2206 WRITE_BOOL_FIELD(nulls_first);
2207 WRITE_BOOL_FIELD(hashable);
2211 _outWindowClause(StringInfo str, WindowClause *node)
2213 WRITE_NODE_TYPE("WINDOWCLAUSE");
2215 WRITE_STRING_FIELD(name);
2216 WRITE_STRING_FIELD(refname);
2217 WRITE_NODE_FIELD(partitionClause);
2218 WRITE_NODE_FIELD(orderClause);
2219 WRITE_INT_FIELD(frameOptions);
2220 WRITE_NODE_FIELD(startOffset);
2221 WRITE_NODE_FIELD(endOffset);
2222 WRITE_UINT_FIELD(winref);
2223 WRITE_BOOL_FIELD(copiedOrder);
2227 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2229 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2231 WRITE_UINT_FIELD(rti);
2232 WRITE_BOOL_FIELD(forUpdate);
2233 WRITE_BOOL_FIELD(noWait);
2234 WRITE_BOOL_FIELD(pushedDown);
2238 _outWithClause(StringInfo str, WithClause *node)
2240 WRITE_NODE_TYPE("WITHCLAUSE");
2242 WRITE_NODE_FIELD(ctes);
2243 WRITE_BOOL_FIELD(recursive);
2244 WRITE_LOCATION_FIELD(location);
2248 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2250 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2252 WRITE_STRING_FIELD(ctename);
2253 WRITE_NODE_FIELD(aliascolnames);
2254 WRITE_NODE_FIELD(ctequery);
2255 WRITE_LOCATION_FIELD(location);
2256 WRITE_BOOL_FIELD(cterecursive);
2257 WRITE_INT_FIELD(cterefcount);
2258 WRITE_NODE_FIELD(ctecolnames);
2259 WRITE_NODE_FIELD(ctecoltypes);
2260 WRITE_NODE_FIELD(ctecoltypmods);
2261 WRITE_NODE_FIELD(ctecolcollations);
2265 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2267 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2269 WRITE_ENUM_FIELD(op, SetOperation);
2270 WRITE_BOOL_FIELD(all);
2271 WRITE_NODE_FIELD(larg);
2272 WRITE_NODE_FIELD(rarg);
2273 WRITE_NODE_FIELD(colTypes);
2274 WRITE_NODE_FIELD(colTypmods);
2275 WRITE_NODE_FIELD(colCollations);
2276 WRITE_NODE_FIELD(groupClauses);
2280 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2282 WRITE_NODE_TYPE("RTE");
2284 /* put alias + eref first to make dump more legible */
2285 WRITE_NODE_FIELD(alias);
2286 WRITE_NODE_FIELD(eref);
2287 WRITE_ENUM_FIELD(rtekind, RTEKind);
2289 switch (node->rtekind)
2292 WRITE_OID_FIELD(relid);
2293 WRITE_CHAR_FIELD(relkind);
2296 WRITE_NODE_FIELD(subquery);
2299 WRITE_ENUM_FIELD(jointype, JoinType);
2300 WRITE_NODE_FIELD(joinaliasvars);
2303 WRITE_NODE_FIELD(funcexpr);
2304 WRITE_NODE_FIELD(funccoltypes);
2305 WRITE_NODE_FIELD(funccoltypmods);
2306 WRITE_NODE_FIELD(funccolcollations);
2309 WRITE_NODE_FIELD(values_lists);
2312 WRITE_STRING_FIELD(ctename);
2313 WRITE_UINT_FIELD(ctelevelsup);
2314 WRITE_BOOL_FIELD(self_reference);
2315 WRITE_NODE_FIELD(ctecoltypes);
2316 WRITE_NODE_FIELD(ctecoltypmods);
2317 WRITE_NODE_FIELD(ctecolcollations);
2320 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2324 WRITE_BOOL_FIELD(inh);
2325 WRITE_BOOL_FIELD(inFromCl);
2326 WRITE_UINT_FIELD(requiredPerms);
2327 WRITE_OID_FIELD(checkAsUser);
2328 WRITE_BITMAPSET_FIELD(selectedCols);
2329 WRITE_BITMAPSET_FIELD(modifiedCols);
2333 _outAExpr(StringInfo str, A_Expr *node)
2335 WRITE_NODE_TYPE("AEXPR");
2340 appendStringInfo(str, " ");
2341 WRITE_NODE_FIELD(name);
2344 appendStringInfo(str, " AND");
2347 appendStringInfo(str, " OR");
2350 appendStringInfo(str, " NOT");
2353 appendStringInfo(str, " ");
2354 WRITE_NODE_FIELD(name);
2355 appendStringInfo(str, " ANY ");
2358 appendStringInfo(str, " ");
2359 WRITE_NODE_FIELD(name);
2360 appendStringInfo(str, " ALL ");
2362 case AEXPR_DISTINCT:
2363 appendStringInfo(str, " DISTINCT ");
2364 WRITE_NODE_FIELD(name);
2367 appendStringInfo(str, " NULLIF ");
2368 WRITE_NODE_FIELD(name);
2371 appendStringInfo(str, " OF ");
2372 WRITE_NODE_FIELD(name);
2375 appendStringInfo(str, " IN ");
2376 WRITE_NODE_FIELD(name);
2379 appendStringInfo(str, " ??");
2383 WRITE_NODE_FIELD(lexpr);
2384 WRITE_NODE_FIELD(rexpr);
2385 WRITE_LOCATION_FIELD(location);
2389 _outValue(StringInfo str, Value *value)
2391 switch (value->type)
2394 appendStringInfo(str, "%ld", value->val.ival);
2399 * We assume the value is a valid numeric literal and so does not
2402 appendStringInfoString(str, value->val.str);
2405 appendStringInfoChar(str, '"');
2406 _outToken(str, value->val.str);
2407 appendStringInfoChar(str, '"');
2410 /* internal representation already has leading 'b' */
2411 appendStringInfoString(str, value->val.str);
2414 /* this is seen only within A_Const, not in transformed trees */
2415 appendStringInfoString(str, "NULL");
2418 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2424 _outColumnRef(StringInfo str, ColumnRef *node)
2426 WRITE_NODE_TYPE("COLUMNREF");
2428 WRITE_NODE_FIELD(fields);
2429 WRITE_LOCATION_FIELD(location);
2433 _outParamRef(StringInfo str, ParamRef *node)
2435 WRITE_NODE_TYPE("PARAMREF");
2437 WRITE_INT_FIELD(number);
2438 WRITE_LOCATION_FIELD(location);
2442 _outAConst(StringInfo str, A_Const *node)
2444 WRITE_NODE_TYPE("A_CONST");
2446 appendStringInfo(str, " :val ");
2447 _outValue(str, &(node->val));
2448 WRITE_LOCATION_FIELD(location);
2452 _outA_Star(StringInfo str, A_Star *node)
2454 WRITE_NODE_TYPE("A_STAR");
2458 _outA_Indices(StringInfo str, A_Indices *node)
2460 WRITE_NODE_TYPE("A_INDICES");
2462 WRITE_NODE_FIELD(lidx);
2463 WRITE_NODE_FIELD(uidx);
2467 _outA_Indirection(StringInfo str, A_Indirection *node)
2469 WRITE_NODE_TYPE("A_INDIRECTION");
2471 WRITE_NODE_FIELD(arg);
2472 WRITE_NODE_FIELD(indirection);
2476 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2478 WRITE_NODE_TYPE("A_ARRAYEXPR");
2480 WRITE_NODE_FIELD(elements);
2481 WRITE_LOCATION_FIELD(location);
2485 _outResTarget(StringInfo str, ResTarget *node)
2487 WRITE_NODE_TYPE("RESTARGET");
2489 WRITE_STRING_FIELD(name);
2490 WRITE_NODE_FIELD(indirection);
2491 WRITE_NODE_FIELD(val);
2492 WRITE_LOCATION_FIELD(location);
2496 _outSortBy(StringInfo str, SortBy *node)
2498 WRITE_NODE_TYPE("SORTBY");
2500 WRITE_NODE_FIELD(node);
2501 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2502 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2503 WRITE_NODE_FIELD(useOp);
2504 WRITE_LOCATION_FIELD(location);
2508 _outWindowDef(StringInfo str, WindowDef *node)
2510 WRITE_NODE_TYPE("WINDOWDEF");
2512 WRITE_STRING_FIELD(name);
2513 WRITE_STRING_FIELD(refname);
2514 WRITE_NODE_FIELD(partitionClause);
2515 WRITE_NODE_FIELD(orderClause);
2516 WRITE_INT_FIELD(frameOptions);
2517 WRITE_NODE_FIELD(startOffset);
2518 WRITE_NODE_FIELD(endOffset);
2519 WRITE_LOCATION_FIELD(location);
2523 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2525 WRITE_NODE_TYPE("RANGESUBSELECT");
2527 WRITE_NODE_FIELD(subquery);
2528 WRITE_NODE_FIELD(alias);
2532 _outRangeFunction(StringInfo str, RangeFunction *node)
2534 WRITE_NODE_TYPE("RANGEFUNCTION");
2536 WRITE_NODE_FIELD(funccallnode);
2537 WRITE_NODE_FIELD(alias);
2538 WRITE_NODE_FIELD(coldeflist);
2542 _outConstraint(StringInfo str, Constraint *node)
2544 WRITE_NODE_TYPE("CONSTRAINT");
2546 WRITE_STRING_FIELD(conname);
2547 WRITE_BOOL_FIELD(deferrable);
2548 WRITE_BOOL_FIELD(initdeferred);
2549 WRITE_LOCATION_FIELD(location);
2551 appendStringInfo(str, " :contype ");
2552 switch (node->contype)
2555 appendStringInfo(str, "NULL");
2558 case CONSTR_NOTNULL:
2559 appendStringInfo(str, "NOT_NULL");
2562 case CONSTR_DEFAULT:
2563 appendStringInfo(str, "DEFAULT");
2564 WRITE_NODE_FIELD(raw_expr);
2565 WRITE_STRING_FIELD(cooked_expr);
2569 appendStringInfo(str, "CHECK");
2570 WRITE_NODE_FIELD(raw_expr);
2571 WRITE_STRING_FIELD(cooked_expr);
2574 case CONSTR_PRIMARY:
2575 appendStringInfo(str, "PRIMARY_KEY");
2576 WRITE_NODE_FIELD(keys);
2577 WRITE_NODE_FIELD(options);
2578 WRITE_STRING_FIELD(indexname);
2579 WRITE_STRING_FIELD(indexspace);
2580 /* access_method and where_clause not currently used */
2584 appendStringInfo(str, "UNIQUE");
2585 WRITE_NODE_FIELD(keys);
2586 WRITE_NODE_FIELD(options);
2587 WRITE_STRING_FIELD(indexname);
2588 WRITE_STRING_FIELD(indexspace);
2589 /* access_method and where_clause not currently used */
2592 case CONSTR_EXCLUSION:
2593 appendStringInfo(str, "EXCLUSION");
2594 WRITE_NODE_FIELD(exclusions);
2595 WRITE_NODE_FIELD(options);
2596 WRITE_STRING_FIELD(indexname);
2597 WRITE_STRING_FIELD(indexspace);
2598 WRITE_STRING_FIELD(access_method);
2599 WRITE_NODE_FIELD(where_clause);
2602 case CONSTR_FOREIGN:
2603 appendStringInfo(str, "FOREIGN_KEY");
2604 WRITE_NODE_FIELD(pktable);
2605 WRITE_NODE_FIELD(fk_attrs);
2606 WRITE_NODE_FIELD(pk_attrs);
2607 WRITE_CHAR_FIELD(fk_matchtype);
2608 WRITE_CHAR_FIELD(fk_upd_action);
2609 WRITE_CHAR_FIELD(fk_del_action);
2610 WRITE_BOOL_FIELD(skip_validation);
2613 case CONSTR_ATTR_DEFERRABLE:
2614 appendStringInfo(str, "ATTR_DEFERRABLE");
2617 case CONSTR_ATTR_NOT_DEFERRABLE:
2618 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2621 case CONSTR_ATTR_DEFERRED:
2622 appendStringInfo(str, "ATTR_DEFERRED");
2625 case CONSTR_ATTR_IMMEDIATE:
2626 appendStringInfo(str, "ATTR_IMMEDIATE");
2630 appendStringInfo(str, "<unrecognized_constraint %d>",
2631 (int) node->contype);
2639 * converts a Node into ascii string and append it to 'str'
2642 _outNode(StringInfo str, void *obj)
2645 appendStringInfo(str, "<>");
2646 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2648 else if (IsA(obj, Integer) ||
2651 IsA(obj, BitString))
2653 /* nodeRead does not want to see { } around these! */
2654 _outValue(str, obj);
2658 appendStringInfoChar(str, '{');
2659 switch (nodeTag(obj))
2662 _outPlannedStmt(str, obj);
2668 _outResult(str, obj);
2671 _outModifyTable(str, obj);
2674 _outAppend(str, obj);
2677 _outMergeAppend(str, obj);
2679 case T_RecursiveUnion:
2680 _outRecursiveUnion(str, obj);
2683 _outBitmapAnd(str, obj);
2686 _outBitmapOr(str, obj);
2692 _outSeqScan(str, obj);
2695 _outIndexScan(str, obj);
2697 case T_BitmapIndexScan:
2698 _outBitmapIndexScan(str, obj);
2700 case T_BitmapHeapScan:
2701 _outBitmapHeapScan(str, obj);
2704 _outTidScan(str, obj);
2706 case T_SubqueryScan:
2707 _outSubqueryScan(str, obj);
2709 case T_FunctionScan:
2710 _outFunctionScan(str, obj);
2713 _outValuesScan(str, obj);
2716 _outCteScan(str, obj);
2718 case T_WorkTableScan:
2719 _outWorkTableScan(str, obj);
2722 _outForeignScan(str, obj);
2725 _outFdwPlan(str, obj);
2731 _outNestLoop(str, obj);
2734 _outMergeJoin(str, obj);
2737 _outHashJoin(str, obj);
2743 _outWindowAgg(str, obj);
2746 _outGroup(str, obj);
2749 _outMaterial(str, obj);
2755 _outUnique(str, obj);
2761 _outSetOp(str, obj);
2764 _outLockRows(str, obj);
2767 _outLimit(str, obj);
2769 case T_NestLoopParam:
2770 _outNestLoopParam(str, obj);
2773 _outPlanRowMark(str, obj);
2775 case T_PlanInvalItem:
2776 _outPlanInvalItem(str, obj);
2779 _outAlias(str, obj);
2782 _outRangeVar(str, obj);
2785 _outIntoClause(str, obj);
2791 _outConst(str, obj);
2794 _outParam(str, obj);
2797 _outAggref(str, obj);
2800 _outWindowFunc(str, obj);
2803 _outArrayRef(str, obj);
2806 _outFuncExpr(str, obj);
2808 case T_NamedArgExpr:
2809 _outNamedArgExpr(str, obj);
2812 _outOpExpr(str, obj);
2814 case T_DistinctExpr:
2815 _outDistinctExpr(str, obj);
2817 case T_ScalarArrayOpExpr:
2818 _outScalarArrayOpExpr(str, obj);
2821 _outBoolExpr(str, obj);
2824 _outSubLink(str, obj);
2827 _outSubPlan(str, obj);
2829 case T_AlternativeSubPlan:
2830 _outAlternativeSubPlan(str, obj);
2833 _outFieldSelect(str, obj);
2836 _outFieldStore(str, obj);
2839 _outRelabelType(str, obj);
2842 _outCoerceViaIO(str, obj);
2844 case T_ArrayCoerceExpr:
2845 _outArrayCoerceExpr(str, obj);
2847 case T_ConvertRowtypeExpr:
2848 _outConvertRowtypeExpr(str, obj);
2851 _outCollateExpr(str, obj);
2854 _outCaseExpr(str, obj);
2857 _outCaseWhen(str, obj);
2859 case T_CaseTestExpr:
2860 _outCaseTestExpr(str, obj);
2863 _outArrayExpr(str, obj);
2866 _outRowExpr(str, obj);
2868 case T_RowCompareExpr:
2869 _outRowCompareExpr(str, obj);
2871 case T_CoalesceExpr:
2872 _outCoalesceExpr(str, obj);
2875 _outMinMaxExpr(str, obj);
2878 _outXmlExpr(str, obj);
2881 _outNullIfExpr(str, obj);
2884 _outNullTest(str, obj);
2887 _outBooleanTest(str, obj);
2889 case T_CoerceToDomain:
2890 _outCoerceToDomain(str, obj);
2892 case T_CoerceToDomainValue:
2893 _outCoerceToDomainValue(str, obj);
2895 case T_SetToDefault:
2896 _outSetToDefault(str, obj);
2898 case T_CurrentOfExpr:
2899 _outCurrentOfExpr(str, obj);
2902 _outTargetEntry(str, obj);
2905 _outRangeTblRef(str, obj);
2908 _outJoinExpr(str, obj);
2911 _outFromExpr(str, obj);
2918 _outIndexPath(str, obj);
2920 case T_BitmapHeapPath:
2921 _outBitmapHeapPath(str, obj);
2923 case T_BitmapAndPath:
2924 _outBitmapAndPath(str, obj);
2926 case T_BitmapOrPath:
2927 _outBitmapOrPath(str, obj);
2930 _outTidPath(str, obj);
2933 _outForeignPath(str, obj);
2936 _outAppendPath(str, obj);
2938 case T_MergeAppendPath:
2939 _outMergeAppendPath(str, obj);
2942 _outResultPath(str, obj);
2944 case T_MaterialPath:
2945 _outMaterialPath(str, obj);
2948 _outUniquePath(str, obj);
2951 _outNestPath(str, obj);
2954 _outMergePath(str, obj);
2957 _outHashPath(str, obj);
2959 case T_PlannerGlobal:
2960 _outPlannerGlobal(str, obj);
2963 _outPlannerInfo(str, obj);
2966 _outRelOptInfo(str, obj);
2968 case T_IndexOptInfo:
2969 _outIndexOptInfo(str, obj);
2971 case T_EquivalenceClass:
2972 _outEquivalenceClass(str, obj);
2974 case T_EquivalenceMember:
2975 _outEquivalenceMember(str, obj);
2978 _outPathKey(str, obj);
2980 case T_RestrictInfo:
2981 _outRestrictInfo(str, obj);
2983 case T_InnerIndexscanInfo:
2984 _outInnerIndexscanInfo(str, obj);
2986 case T_PlaceHolderVar:
2987 _outPlaceHolderVar(str, obj);
2989 case T_SpecialJoinInfo:
2990 _outSpecialJoinInfo(str, obj);
2992 case T_AppendRelInfo:
2993 _outAppendRelInfo(str, obj);
2995 case T_PlaceHolderInfo:
2996 _outPlaceHolderInfo(str, obj);
2998 case T_MinMaxAggInfo:
2999 _outMinMaxAggInfo(str, obj);
3001 case T_PlannerParamItem:
3002 _outPlannerParamItem(str, obj);
3006 _outCreateStmt(str, obj);
3008 case T_CreateForeignTableStmt:
3009 _outCreateForeignTableStmt(str, obj);
3012 _outIndexStmt(str, obj);
3015 _outNotifyStmt(str, obj);
3017 case T_DeclareCursorStmt:
3018 _outDeclareCursorStmt(str, obj);
3021 _outSelectStmt(str, obj);
3024 _outColumnDef(str, obj);
3027 _outTypeName(str, obj);
3030 _outTypeCast(str, obj);
3032 case T_CollateClause:
3033 _outCollateClause(str, obj);
3036 _outIndexElem(str, obj);
3039 _outQuery(str, obj);
3041 case T_SortGroupClause:
3042 _outSortGroupClause(str, obj);
3044 case T_WindowClause:
3045 _outWindowClause(str, obj);
3047 case T_RowMarkClause:
3048 _outRowMarkClause(str, obj);
3051 _outWithClause(str, obj);
3053 case T_CommonTableExpr:
3054 _outCommonTableExpr(str, obj);
3056 case T_SetOperationStmt:
3057 _outSetOperationStmt(str, obj);
3059 case T_RangeTblEntry:
3060 _outRangeTblEntry(str, obj);
3063 _outAExpr(str, obj);
3066 _outColumnRef(str, obj);
3069 _outParamRef(str, obj);
3072 _outAConst(str, obj);
3075 _outA_Star(str, obj);
3078 _outA_Indices(str, obj);
3080 case T_A_Indirection:
3081 _outA_Indirection(str, obj);
3084 _outA_ArrayExpr(str, obj);
3087 _outResTarget(str, obj);
3090 _outSortBy(str, obj);
3093 _outWindowDef(str, obj);
3095 case T_RangeSubselect:
3096 _outRangeSubselect(str, obj);
3098 case T_RangeFunction:
3099 _outRangeFunction(str, obj);
3102 _outConstraint(str, obj);
3105 _outFuncCall(str, obj);
3108 _outDefElem(str, obj);
3111 _outInhRelation(str, obj);
3113 case T_LockingClause:
3114 _outLockingClause(str, obj);
3116 case T_XmlSerialize:
3117 _outXmlSerialize(str, obj);
3123 * This should be an ERROR, but it's too useful to be able to
3124 * dump structures that _outNode only understands part of.
3126 elog(WARNING, "could not dump unrecognized node type: %d",
3127 (int) nodeTag(obj));
3130 appendStringInfoChar(str, '}');
3136 * returns the ascii representation of the Node as a palloc'd string
3139 nodeToString(void *obj)
3143 /* see stringinfo.h for an explanation of this maneuver */
3144 initStringInfo(&str);
3145 _outNode(&str, obj);