1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/nodes/outfuncs.c
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify output of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire conventions about the names of the local variables in an Out
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41 appendStringInfoString(str, nodelabel)
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47 /* Write an unsigned integer field (anything written as ":fldname %u") */
48 #define WRITE_UINT_FIELD(fldname) \
49 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
51 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
52 #define WRITE_OID_FIELD(fldname) \
53 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
68 /* Write a float field --- caller must give format to define precision */
69 #define WRITE_FLOAT_FIELD(fldname,format) \
70 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75 booltostr(node->fldname))
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 _outToken(str, node->fldname))
82 /* Write a parse location field (actually same as INT case) */
83 #define WRITE_LOCATION_FIELD(fldname) \
84 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
86 /* Write a Node field */
87 #define WRITE_NODE_FIELD(fldname) \
88 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
89 _outNode(str, node->fldname))
91 /* Write a bitmapset field */
92 #define WRITE_BITMAPSET_FIELD(fldname) \
93 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
94 _outBitmapset(str, node->fldname))
97 #define booltostr(x) ((x) ? "true" : "false")
99 static void _outNode(StringInfo str, void *obj);
104 * Convert an ordinary string (eg, an identifier) into a form that
105 * will be decoded back to a plain token by read.c's functions.
107 * If a null or empty string is given, it is encoded as "<>".
110 _outToken(StringInfo str, char *s)
112 if (s == NULL || *s == '\0')
114 appendStringInfo(str, "<>");
119 * Look for characters or patterns that are treated specially by read.c
120 * (either in pg_strtok() or in nodeRead()), and therefore need a
121 * protective backslash.
123 /* These characters only need to be quoted at the start of the string */
126 isdigit((unsigned char) *s) ||
127 ((*s == '+' || *s == '-') &&
128 (isdigit((unsigned char) s[1]) || s[1] == '.')))
129 appendStringInfoChar(str, '\\');
132 /* These chars must be backslashed anywhere in the string */
133 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
136 appendStringInfoChar(str, '\\');
137 appendStringInfoChar(str, *s++);
142 _outList(StringInfo str, List *node)
146 appendStringInfoChar(str, '(');
148 if (IsA(node, IntList))
149 appendStringInfoChar(str, 'i');
150 else if (IsA(node, OidList))
151 appendStringInfoChar(str, 'o');
156 * For the sake of backward compatibility, we emit a slightly
157 * different whitespace format for lists of nodes vs. other types of
158 * lists. XXX: is this necessary?
162 _outNode(str, lfirst(lc));
164 appendStringInfoChar(str, ' ');
166 else if (IsA(node, IntList))
167 appendStringInfo(str, " %d", lfirst_int(lc));
168 else if (IsA(node, OidList))
169 appendStringInfo(str, " %u", lfirst_oid(lc));
171 elog(ERROR, "unrecognized list node type: %d",
175 appendStringInfoChar(str, ')');
180 * converts a bitmap set of integers
182 * Note: the output format is "(b int int ...)", similar to an integer List.
185 _outBitmapset(StringInfo str, Bitmapset *bms)
190 appendStringInfoChar(str, '(');
191 appendStringInfoChar(str, 'b');
192 tmpset = bms_copy(bms);
193 while ((x = bms_first_member(tmpset)) >= 0)
194 appendStringInfo(str, " %d", x);
196 appendStringInfoChar(str, ')');
200 * Print the value of a Datum given its type.
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
209 length = datumGetSize(value, typbyval, typlen);
213 s = (char *) (&value);
214 appendStringInfo(str, "%u [ ", (unsigned int) length);
215 for (i = 0; i < (Size) sizeof(Datum); i++)
216 appendStringInfo(str, "%d ", (int) (s[i]));
217 appendStringInfo(str, "]");
221 s = (char *) DatumGetPointer(value);
222 if (!PointerIsValid(s))
223 appendStringInfo(str, "0 [ ]");
226 appendStringInfo(str, "%u [ ", (unsigned int) length);
227 for (i = 0; i < length; i++)
228 appendStringInfo(str, "%d ", (int) (s[i]));
229 appendStringInfo(str, "]");
236 * Stuff from plannodes.h
240 _outPlannedStmt(StringInfo str, PlannedStmt *node)
242 WRITE_NODE_TYPE("PLANNEDSTMT");
244 WRITE_ENUM_FIELD(commandType, CmdType);
245 WRITE_BOOL_FIELD(hasReturning);
246 WRITE_BOOL_FIELD(canSetTag);
247 WRITE_BOOL_FIELD(transientPlan);
248 WRITE_NODE_FIELD(planTree);
249 WRITE_NODE_FIELD(rtable);
250 WRITE_NODE_FIELD(resultRelations);
251 WRITE_NODE_FIELD(utilityStmt);
252 WRITE_NODE_FIELD(intoClause);
253 WRITE_NODE_FIELD(subplans);
254 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
255 WRITE_NODE_FIELD(rowMarks);
256 WRITE_NODE_FIELD(relationOids);
257 WRITE_NODE_FIELD(invalItems);
258 WRITE_INT_FIELD(nParamExec);
262 * print the basic stuff of all nodes that inherit from Plan
265 _outPlanInfo(StringInfo str, Plan *node)
267 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
268 WRITE_FLOAT_FIELD(total_cost, "%.2f");
269 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
270 WRITE_INT_FIELD(plan_width);
271 WRITE_NODE_FIELD(targetlist);
272 WRITE_NODE_FIELD(qual);
273 WRITE_NODE_FIELD(lefttree);
274 WRITE_NODE_FIELD(righttree);
275 WRITE_NODE_FIELD(initPlan);
276 WRITE_BITMAPSET_FIELD(extParam);
277 WRITE_BITMAPSET_FIELD(allParam);
281 * print the basic stuff of all nodes that inherit from Scan
284 _outScanInfo(StringInfo str, Scan *node)
286 _outPlanInfo(str, (Plan *) node);
288 WRITE_UINT_FIELD(scanrelid);
292 * print the basic stuff of all nodes that inherit from Join
295 _outJoinPlanInfo(StringInfo str, Join *node)
297 _outPlanInfo(str, (Plan *) node);
299 WRITE_ENUM_FIELD(jointype, JoinType);
300 WRITE_NODE_FIELD(joinqual);
305 _outPlan(StringInfo str, Plan *node)
307 WRITE_NODE_TYPE("PLAN");
309 _outPlanInfo(str, (Plan *) node);
313 _outResult(StringInfo str, Result *node)
315 WRITE_NODE_TYPE("RESULT");
317 _outPlanInfo(str, (Plan *) node);
319 WRITE_NODE_FIELD(resconstantqual);
323 _outModifyTable(StringInfo str, ModifyTable *node)
325 WRITE_NODE_TYPE("MODIFYTABLE");
327 _outPlanInfo(str, (Plan *) node);
329 WRITE_ENUM_FIELD(operation, CmdType);
330 WRITE_NODE_FIELD(resultRelations);
331 WRITE_NODE_FIELD(plans);
332 WRITE_NODE_FIELD(returningLists);
333 WRITE_NODE_FIELD(rowMarks);
334 WRITE_INT_FIELD(epqParam);
338 _outAppend(StringInfo str, Append *node)
340 WRITE_NODE_TYPE("APPEND");
342 _outPlanInfo(str, (Plan *) node);
344 WRITE_NODE_FIELD(appendplans);
348 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
352 WRITE_NODE_TYPE("RECURSIVEUNION");
354 _outPlanInfo(str, (Plan *) node);
356 WRITE_INT_FIELD(wtParam);
357 WRITE_INT_FIELD(numCols);
359 appendStringInfo(str, " :dupColIdx");
360 for (i = 0; i < node->numCols; i++)
361 appendStringInfo(str, " %d", node->dupColIdx[i]);
363 appendStringInfo(str, " :dupOperators");
364 for (i = 0; i < node->numCols; i++)
365 appendStringInfo(str, " %u", node->dupOperators[i]);
367 WRITE_LONG_FIELD(numGroups);
371 _outBitmapAnd(StringInfo str, BitmapAnd *node)
373 WRITE_NODE_TYPE("BITMAPAND");
375 _outPlanInfo(str, (Plan *) node);
377 WRITE_NODE_FIELD(bitmapplans);
381 _outBitmapOr(StringInfo str, BitmapOr *node)
383 WRITE_NODE_TYPE("BITMAPOR");
385 _outPlanInfo(str, (Plan *) node);
387 WRITE_NODE_FIELD(bitmapplans);
391 _outScan(StringInfo str, Scan *node)
393 WRITE_NODE_TYPE("SCAN");
395 _outScanInfo(str, (Scan *) node);
399 _outSeqScan(StringInfo str, SeqScan *node)
401 WRITE_NODE_TYPE("SEQSCAN");
403 _outScanInfo(str, (Scan *) node);
407 _outIndexScan(StringInfo str, IndexScan *node)
409 WRITE_NODE_TYPE("INDEXSCAN");
411 _outScanInfo(str, (Scan *) node);
413 WRITE_OID_FIELD(indexid);
414 WRITE_NODE_FIELD(indexqual);
415 WRITE_NODE_FIELD(indexqualorig);
416 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
420 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
422 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
424 _outScanInfo(str, (Scan *) node);
426 WRITE_OID_FIELD(indexid);
427 WRITE_NODE_FIELD(indexqual);
428 WRITE_NODE_FIELD(indexqualorig);
432 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
434 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
436 _outScanInfo(str, (Scan *) node);
438 WRITE_NODE_FIELD(bitmapqualorig);
442 _outTidScan(StringInfo str, TidScan *node)
444 WRITE_NODE_TYPE("TIDSCAN");
446 _outScanInfo(str, (Scan *) node);
448 WRITE_NODE_FIELD(tidquals);
452 _outSubqueryScan(StringInfo str, SubqueryScan *node)
454 WRITE_NODE_TYPE("SUBQUERYSCAN");
456 _outScanInfo(str, (Scan *) node);
458 WRITE_NODE_FIELD(subplan);
459 WRITE_NODE_FIELD(subrtable);
460 WRITE_NODE_FIELD(subrowmark);
464 _outFunctionScan(StringInfo str, FunctionScan *node)
466 WRITE_NODE_TYPE("FUNCTIONSCAN");
468 _outScanInfo(str, (Scan *) node);
470 WRITE_NODE_FIELD(funcexpr);
471 WRITE_NODE_FIELD(funccolnames);
472 WRITE_NODE_FIELD(funccoltypes);
473 WRITE_NODE_FIELD(funccoltypmods);
477 _outValuesScan(StringInfo str, ValuesScan *node)
479 WRITE_NODE_TYPE("VALUESSCAN");
481 _outScanInfo(str, (Scan *) node);
483 WRITE_NODE_FIELD(values_lists);
487 _outCteScan(StringInfo str, CteScan *node)
489 WRITE_NODE_TYPE("CTESCAN");
491 _outScanInfo(str, (Scan *) node);
493 WRITE_INT_FIELD(ctePlanId);
494 WRITE_INT_FIELD(cteParam);
498 _outWorkTableScan(StringInfo str, WorkTableScan *node)
500 WRITE_NODE_TYPE("WORKTABLESCAN");
502 _outScanInfo(str, (Scan *) node);
504 WRITE_INT_FIELD(wtParam);
508 _outJoin(StringInfo str, Join *node)
510 WRITE_NODE_TYPE("JOIN");
512 _outJoinPlanInfo(str, (Join *) node);
516 _outNestLoop(StringInfo str, NestLoop *node)
518 WRITE_NODE_TYPE("NESTLOOP");
520 _outJoinPlanInfo(str, (Join *) node);
522 WRITE_NODE_FIELD(nestParams);
526 _outMergeJoin(StringInfo str, MergeJoin *node)
531 WRITE_NODE_TYPE("MERGEJOIN");
533 _outJoinPlanInfo(str, (Join *) node);
535 WRITE_NODE_FIELD(mergeclauses);
537 numCols = list_length(node->mergeclauses);
539 appendStringInfo(str, " :mergeFamilies");
540 for (i = 0; i < numCols; i++)
541 appendStringInfo(str, " %u", node->mergeFamilies[i]);
543 appendStringInfo(str, " :mergeStrategies");
544 for (i = 0; i < numCols; i++)
545 appendStringInfo(str, " %d", node->mergeStrategies[i]);
547 appendStringInfo(str, " :mergeNullsFirst");
548 for (i = 0; i < numCols; i++)
549 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
553 _outHashJoin(StringInfo str, HashJoin *node)
555 WRITE_NODE_TYPE("HASHJOIN");
557 _outJoinPlanInfo(str, (Join *) node);
559 WRITE_NODE_FIELD(hashclauses);
563 _outAgg(StringInfo str, Agg *node)
567 WRITE_NODE_TYPE("AGG");
569 _outPlanInfo(str, (Plan *) node);
571 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
572 WRITE_INT_FIELD(numCols);
574 appendStringInfo(str, " :grpColIdx");
575 for (i = 0; i < node->numCols; i++)
576 appendStringInfo(str, " %d", node->grpColIdx[i]);
578 appendStringInfo(str, " :grpOperators");
579 for (i = 0; i < node->numCols; i++)
580 appendStringInfo(str, " %u", node->grpOperators[i]);
582 WRITE_LONG_FIELD(numGroups);
586 _outWindowAgg(StringInfo str, WindowAgg *node)
590 WRITE_NODE_TYPE("WINDOWAGG");
592 _outPlanInfo(str, (Plan *) node);
594 WRITE_UINT_FIELD(winref);
595 WRITE_INT_FIELD(partNumCols);
597 appendStringInfo(str, " :partColIdx");
598 for (i = 0; i < node->partNumCols; i++)
599 appendStringInfo(str, " %d", node->partColIdx[i]);
601 appendStringInfo(str, " :partOperations");
602 for (i = 0; i < node->partNumCols; i++)
603 appendStringInfo(str, " %u", node->partOperators[i]);
605 WRITE_INT_FIELD(ordNumCols);
607 appendStringInfo(str, " :ordColIdx");
608 for (i = 0; i < node->ordNumCols; i++)
609 appendStringInfo(str, " %d", node->ordColIdx[i]);
611 appendStringInfo(str, " :ordOperations");
612 for (i = 0; i < node->ordNumCols; i++)
613 appendStringInfo(str, " %u", node->ordOperators[i]);
615 WRITE_INT_FIELD(frameOptions);
616 WRITE_NODE_FIELD(startOffset);
617 WRITE_NODE_FIELD(endOffset);
621 _outGroup(StringInfo str, Group *node)
625 WRITE_NODE_TYPE("GROUP");
627 _outPlanInfo(str, (Plan *) node);
629 WRITE_INT_FIELD(numCols);
631 appendStringInfo(str, " :grpColIdx");
632 for (i = 0; i < node->numCols; i++)
633 appendStringInfo(str, " %d", node->grpColIdx[i]);
635 appendStringInfo(str, " :grpOperators");
636 for (i = 0; i < node->numCols; i++)
637 appendStringInfo(str, " %u", node->grpOperators[i]);
641 _outMaterial(StringInfo str, Material *node)
643 WRITE_NODE_TYPE("MATERIAL");
645 _outPlanInfo(str, (Plan *) node);
649 _outSort(StringInfo str, Sort *node)
653 WRITE_NODE_TYPE("SORT");
655 _outPlanInfo(str, (Plan *) node);
657 WRITE_INT_FIELD(numCols);
659 appendStringInfo(str, " :sortColIdx");
660 for (i = 0; i < node->numCols; i++)
661 appendStringInfo(str, " %d", node->sortColIdx[i]);
663 appendStringInfo(str, " :sortOperators");
664 for (i = 0; i < node->numCols; i++)
665 appendStringInfo(str, " %u", node->sortOperators[i]);
667 appendStringInfo(str, " :nullsFirst");
668 for (i = 0; i < node->numCols; i++)
669 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
673 _outUnique(StringInfo str, Unique *node)
677 WRITE_NODE_TYPE("UNIQUE");
679 _outPlanInfo(str, (Plan *) node);
681 WRITE_INT_FIELD(numCols);
683 appendStringInfo(str, " :uniqColIdx");
684 for (i = 0; i < node->numCols; i++)
685 appendStringInfo(str, " %d", node->uniqColIdx[i]);
687 appendStringInfo(str, " :uniqOperators");
688 for (i = 0; i < node->numCols; i++)
689 appendStringInfo(str, " %u", node->uniqOperators[i]);
693 _outHash(StringInfo str, Hash *node)
695 WRITE_NODE_TYPE("HASH");
697 _outPlanInfo(str, (Plan *) node);
699 WRITE_OID_FIELD(skewTable);
700 WRITE_INT_FIELD(skewColumn);
701 WRITE_BOOL_FIELD(skewInherit);
702 WRITE_OID_FIELD(skewColType);
703 WRITE_INT_FIELD(skewColTypmod);
707 _outSetOp(StringInfo str, SetOp *node)
711 WRITE_NODE_TYPE("SETOP");
713 _outPlanInfo(str, (Plan *) node);
715 WRITE_ENUM_FIELD(cmd, SetOpCmd);
716 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
717 WRITE_INT_FIELD(numCols);
719 appendStringInfo(str, " :dupColIdx");
720 for (i = 0; i < node->numCols; i++)
721 appendStringInfo(str, " %d", node->dupColIdx[i]);
723 appendStringInfo(str, " :dupOperators");
724 for (i = 0; i < node->numCols; i++)
725 appendStringInfo(str, " %u", node->dupOperators[i]);
727 WRITE_INT_FIELD(flagColIdx);
728 WRITE_INT_FIELD(firstFlag);
729 WRITE_LONG_FIELD(numGroups);
733 _outLockRows(StringInfo str, LockRows *node)
735 WRITE_NODE_TYPE("LOCKROWS");
737 _outPlanInfo(str, (Plan *) node);
739 WRITE_NODE_FIELD(rowMarks);
740 WRITE_INT_FIELD(epqParam);
744 _outLimit(StringInfo str, Limit *node)
746 WRITE_NODE_TYPE("LIMIT");
748 _outPlanInfo(str, (Plan *) node);
750 WRITE_NODE_FIELD(limitOffset);
751 WRITE_NODE_FIELD(limitCount);
755 _outNestLoopParam(StringInfo str, NestLoopParam *node)
757 WRITE_NODE_TYPE("NESTLOOPPARAM");
759 WRITE_INT_FIELD(paramno);
760 WRITE_NODE_FIELD(paramval);
764 _outPlanRowMark(StringInfo str, PlanRowMark *node)
766 WRITE_NODE_TYPE("PLANROWMARK");
768 WRITE_UINT_FIELD(rti);
769 WRITE_UINT_FIELD(prti);
770 WRITE_ENUM_FIELD(markType, RowMarkType);
771 WRITE_BOOL_FIELD(noWait);
772 WRITE_BOOL_FIELD(isParent);
773 WRITE_INT_FIELD(ctidAttNo);
774 WRITE_INT_FIELD(toidAttNo);
775 WRITE_INT_FIELD(wholeAttNo);
779 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
781 WRITE_NODE_TYPE("PLANINVALITEM");
783 WRITE_INT_FIELD(cacheId);
784 appendStringInfo(str, " :tupleId (%u,%u)",
785 ItemPointerGetBlockNumber(&node->tupleId),
786 ItemPointerGetOffsetNumber(&node->tupleId));
789 /*****************************************************************************
791 * Stuff from primnodes.h.
793 *****************************************************************************/
796 _outAlias(StringInfo str, Alias *node)
798 WRITE_NODE_TYPE("ALIAS");
800 WRITE_STRING_FIELD(aliasname);
801 WRITE_NODE_FIELD(colnames);
805 _outRangeVar(StringInfo str, RangeVar *node)
807 WRITE_NODE_TYPE("RANGEVAR");
810 * we deliberately ignore catalogname here, since it is presently not
811 * semantically meaningful
813 WRITE_STRING_FIELD(schemaname);
814 WRITE_STRING_FIELD(relname);
815 WRITE_ENUM_FIELD(inhOpt, InhOption);
816 WRITE_BOOL_FIELD(istemp);
817 WRITE_NODE_FIELD(alias);
818 WRITE_LOCATION_FIELD(location);
822 _outIntoClause(StringInfo str, IntoClause *node)
824 WRITE_NODE_TYPE("INTOCLAUSE");
826 WRITE_NODE_FIELD(rel);
827 WRITE_NODE_FIELD(colNames);
828 WRITE_NODE_FIELD(options);
829 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
830 WRITE_STRING_FIELD(tableSpaceName);
834 _outVar(StringInfo str, Var *node)
836 WRITE_NODE_TYPE("VAR");
838 WRITE_UINT_FIELD(varno);
839 WRITE_INT_FIELD(varattno);
840 WRITE_OID_FIELD(vartype);
841 WRITE_INT_FIELD(vartypmod);
842 WRITE_UINT_FIELD(varlevelsup);
843 WRITE_UINT_FIELD(varnoold);
844 WRITE_INT_FIELD(varoattno);
845 WRITE_LOCATION_FIELD(location);
849 _outConst(StringInfo str, Const *node)
851 WRITE_NODE_TYPE("CONST");
853 WRITE_OID_FIELD(consttype);
854 WRITE_INT_FIELD(consttypmod);
855 WRITE_INT_FIELD(constlen);
856 WRITE_BOOL_FIELD(constbyval);
857 WRITE_BOOL_FIELD(constisnull);
858 WRITE_LOCATION_FIELD(location);
860 appendStringInfo(str, " :constvalue ");
861 if (node->constisnull)
862 appendStringInfo(str, "<>");
864 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
868 _outParam(StringInfo str, Param *node)
870 WRITE_NODE_TYPE("PARAM");
872 WRITE_ENUM_FIELD(paramkind, ParamKind);
873 WRITE_INT_FIELD(paramid);
874 WRITE_OID_FIELD(paramtype);
875 WRITE_INT_FIELD(paramtypmod);
876 WRITE_LOCATION_FIELD(location);
880 _outAggref(StringInfo str, Aggref *node)
882 WRITE_NODE_TYPE("AGGREF");
884 WRITE_OID_FIELD(aggfnoid);
885 WRITE_OID_FIELD(aggtype);
886 WRITE_NODE_FIELD(args);
887 WRITE_NODE_FIELD(aggorder);
888 WRITE_NODE_FIELD(aggdistinct);
889 WRITE_BOOL_FIELD(aggstar);
890 WRITE_UINT_FIELD(agglevelsup);
891 WRITE_LOCATION_FIELD(location);
895 _outWindowFunc(StringInfo str, WindowFunc *node)
897 WRITE_NODE_TYPE("WINDOWFUNC");
899 WRITE_OID_FIELD(winfnoid);
900 WRITE_OID_FIELD(wintype);
901 WRITE_NODE_FIELD(args);
902 WRITE_UINT_FIELD(winref);
903 WRITE_BOOL_FIELD(winstar);
904 WRITE_BOOL_FIELD(winagg);
905 WRITE_LOCATION_FIELD(location);
909 _outArrayRef(StringInfo str, ArrayRef *node)
911 WRITE_NODE_TYPE("ARRAYREF");
913 WRITE_OID_FIELD(refarraytype);
914 WRITE_OID_FIELD(refelemtype);
915 WRITE_INT_FIELD(reftypmod);
916 WRITE_NODE_FIELD(refupperindexpr);
917 WRITE_NODE_FIELD(reflowerindexpr);
918 WRITE_NODE_FIELD(refexpr);
919 WRITE_NODE_FIELD(refassgnexpr);
923 _outFuncExpr(StringInfo str, FuncExpr *node)
925 WRITE_NODE_TYPE("FUNCEXPR");
927 WRITE_OID_FIELD(funcid);
928 WRITE_OID_FIELD(funcresulttype);
929 WRITE_BOOL_FIELD(funcretset);
930 WRITE_ENUM_FIELD(funcformat, CoercionForm);
931 WRITE_NODE_FIELD(args);
932 WRITE_LOCATION_FIELD(location);
936 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
938 WRITE_NODE_TYPE("NAMEDARGEXPR");
940 WRITE_NODE_FIELD(arg);
941 WRITE_STRING_FIELD(name);
942 WRITE_INT_FIELD(argnumber);
943 WRITE_LOCATION_FIELD(location);
947 _outOpExpr(StringInfo str, OpExpr *node)
949 WRITE_NODE_TYPE("OPEXPR");
951 WRITE_OID_FIELD(opno);
952 WRITE_OID_FIELD(opfuncid);
953 WRITE_OID_FIELD(opresulttype);
954 WRITE_BOOL_FIELD(opretset);
955 WRITE_NODE_FIELD(args);
956 WRITE_LOCATION_FIELD(location);
960 _outDistinctExpr(StringInfo str, DistinctExpr *node)
962 WRITE_NODE_TYPE("DISTINCTEXPR");
964 WRITE_OID_FIELD(opno);
965 WRITE_OID_FIELD(opfuncid);
966 WRITE_OID_FIELD(opresulttype);
967 WRITE_BOOL_FIELD(opretset);
968 WRITE_NODE_FIELD(args);
969 WRITE_LOCATION_FIELD(location);
973 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
975 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
977 WRITE_OID_FIELD(opno);
978 WRITE_OID_FIELD(opfuncid);
979 WRITE_BOOL_FIELD(useOr);
980 WRITE_NODE_FIELD(args);
981 WRITE_LOCATION_FIELD(location);
985 _outBoolExpr(StringInfo str, BoolExpr *node)
989 WRITE_NODE_TYPE("BOOLEXPR");
991 /* do-it-yourself enum representation */
992 switch (node->boolop)
1004 appendStringInfo(str, " :boolop ");
1005 _outToken(str, opstr);
1007 WRITE_NODE_FIELD(args);
1008 WRITE_LOCATION_FIELD(location);
1012 _outSubLink(StringInfo str, SubLink *node)
1014 WRITE_NODE_TYPE("SUBLINK");
1016 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1017 WRITE_NODE_FIELD(testexpr);
1018 WRITE_NODE_FIELD(operName);
1019 WRITE_NODE_FIELD(subselect);
1020 WRITE_LOCATION_FIELD(location);
1024 _outSubPlan(StringInfo str, SubPlan *node)
1026 WRITE_NODE_TYPE("SUBPLAN");
1028 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1029 WRITE_NODE_FIELD(testexpr);
1030 WRITE_NODE_FIELD(paramIds);
1031 WRITE_INT_FIELD(plan_id);
1032 WRITE_STRING_FIELD(plan_name);
1033 WRITE_OID_FIELD(firstColType);
1034 WRITE_INT_FIELD(firstColTypmod);
1035 WRITE_BOOL_FIELD(useHashTable);
1036 WRITE_BOOL_FIELD(unknownEqFalse);
1037 WRITE_NODE_FIELD(setParam);
1038 WRITE_NODE_FIELD(parParam);
1039 WRITE_NODE_FIELD(args);
1040 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1041 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1045 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1047 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1049 WRITE_NODE_FIELD(subplans);
1053 _outFieldSelect(StringInfo str, FieldSelect *node)
1055 WRITE_NODE_TYPE("FIELDSELECT");
1057 WRITE_NODE_FIELD(arg);
1058 WRITE_INT_FIELD(fieldnum);
1059 WRITE_OID_FIELD(resulttype);
1060 WRITE_INT_FIELD(resulttypmod);
1064 _outFieldStore(StringInfo str, FieldStore *node)
1066 WRITE_NODE_TYPE("FIELDSTORE");
1068 WRITE_NODE_FIELD(arg);
1069 WRITE_NODE_FIELD(newvals);
1070 WRITE_NODE_FIELD(fieldnums);
1071 WRITE_OID_FIELD(resulttype);
1075 _outRelabelType(StringInfo str, RelabelType *node)
1077 WRITE_NODE_TYPE("RELABELTYPE");
1079 WRITE_NODE_FIELD(arg);
1080 WRITE_OID_FIELD(resulttype);
1081 WRITE_INT_FIELD(resulttypmod);
1082 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1083 WRITE_LOCATION_FIELD(location);
1087 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1089 WRITE_NODE_TYPE("COERCEVIAIO");
1091 WRITE_NODE_FIELD(arg);
1092 WRITE_OID_FIELD(resulttype);
1093 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1094 WRITE_LOCATION_FIELD(location);
1098 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1100 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1102 WRITE_NODE_FIELD(arg);
1103 WRITE_OID_FIELD(elemfuncid);
1104 WRITE_OID_FIELD(resulttype);
1105 WRITE_INT_FIELD(resulttypmod);
1106 WRITE_BOOL_FIELD(isExplicit);
1107 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1108 WRITE_LOCATION_FIELD(location);
1112 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1114 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1116 WRITE_NODE_FIELD(arg);
1117 WRITE_OID_FIELD(resulttype);
1118 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1119 WRITE_LOCATION_FIELD(location);
1123 _outCaseExpr(StringInfo str, CaseExpr *node)
1125 WRITE_NODE_TYPE("CASE");
1127 WRITE_OID_FIELD(casetype);
1128 WRITE_NODE_FIELD(arg);
1129 WRITE_NODE_FIELD(args);
1130 WRITE_NODE_FIELD(defresult);
1131 WRITE_LOCATION_FIELD(location);
1135 _outCaseWhen(StringInfo str, CaseWhen *node)
1137 WRITE_NODE_TYPE("WHEN");
1139 WRITE_NODE_FIELD(expr);
1140 WRITE_NODE_FIELD(result);
1141 WRITE_LOCATION_FIELD(location);
1145 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1147 WRITE_NODE_TYPE("CASETESTEXPR");
1149 WRITE_OID_FIELD(typeId);
1150 WRITE_INT_FIELD(typeMod);
1154 _outArrayExpr(StringInfo str, ArrayExpr *node)
1156 WRITE_NODE_TYPE("ARRAY");
1158 WRITE_OID_FIELD(array_typeid);
1159 WRITE_OID_FIELD(element_typeid);
1160 WRITE_NODE_FIELD(elements);
1161 WRITE_BOOL_FIELD(multidims);
1162 WRITE_LOCATION_FIELD(location);
1166 _outRowExpr(StringInfo str, RowExpr *node)
1168 WRITE_NODE_TYPE("ROW");
1170 WRITE_NODE_FIELD(args);
1171 WRITE_OID_FIELD(row_typeid);
1172 WRITE_ENUM_FIELD(row_format, CoercionForm);
1173 WRITE_NODE_FIELD(colnames);
1174 WRITE_LOCATION_FIELD(location);
1178 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1180 WRITE_NODE_TYPE("ROWCOMPARE");
1182 WRITE_ENUM_FIELD(rctype, RowCompareType);
1183 WRITE_NODE_FIELD(opnos);
1184 WRITE_NODE_FIELD(opfamilies);
1185 WRITE_NODE_FIELD(largs);
1186 WRITE_NODE_FIELD(rargs);
1190 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1192 WRITE_NODE_TYPE("COALESCE");
1194 WRITE_OID_FIELD(coalescetype);
1195 WRITE_NODE_FIELD(args);
1196 WRITE_LOCATION_FIELD(location);
1200 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1202 WRITE_NODE_TYPE("MINMAX");
1204 WRITE_OID_FIELD(minmaxtype);
1205 WRITE_ENUM_FIELD(op, MinMaxOp);
1206 WRITE_NODE_FIELD(args);
1207 WRITE_LOCATION_FIELD(location);
1211 _outXmlExpr(StringInfo str, XmlExpr *node)
1213 WRITE_NODE_TYPE("XMLEXPR");
1215 WRITE_ENUM_FIELD(op, XmlExprOp);
1216 WRITE_STRING_FIELD(name);
1217 WRITE_NODE_FIELD(named_args);
1218 WRITE_NODE_FIELD(arg_names);
1219 WRITE_NODE_FIELD(args);
1220 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1221 WRITE_OID_FIELD(type);
1222 WRITE_INT_FIELD(typmod);
1223 WRITE_LOCATION_FIELD(location);
1227 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1229 WRITE_NODE_TYPE("NULLIFEXPR");
1231 WRITE_OID_FIELD(opno);
1232 WRITE_OID_FIELD(opfuncid);
1233 WRITE_OID_FIELD(opresulttype);
1234 WRITE_BOOL_FIELD(opretset);
1235 WRITE_NODE_FIELD(args);
1236 WRITE_LOCATION_FIELD(location);
1240 _outNullTest(StringInfo str, NullTest *node)
1242 WRITE_NODE_TYPE("NULLTEST");
1244 WRITE_NODE_FIELD(arg);
1245 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1246 WRITE_BOOL_FIELD(argisrow);
1250 _outBooleanTest(StringInfo str, BooleanTest *node)
1252 WRITE_NODE_TYPE("BOOLEANTEST");
1254 WRITE_NODE_FIELD(arg);
1255 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1259 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1261 WRITE_NODE_TYPE("COERCETODOMAIN");
1263 WRITE_NODE_FIELD(arg);
1264 WRITE_OID_FIELD(resulttype);
1265 WRITE_INT_FIELD(resulttypmod);
1266 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1267 WRITE_LOCATION_FIELD(location);
1271 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1273 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1275 WRITE_OID_FIELD(typeId);
1276 WRITE_INT_FIELD(typeMod);
1277 WRITE_LOCATION_FIELD(location);
1281 _outSetToDefault(StringInfo str, SetToDefault *node)
1283 WRITE_NODE_TYPE("SETTODEFAULT");
1285 WRITE_OID_FIELD(typeId);
1286 WRITE_INT_FIELD(typeMod);
1287 WRITE_LOCATION_FIELD(location);
1291 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1293 WRITE_NODE_TYPE("CURRENTOFEXPR");
1295 WRITE_UINT_FIELD(cvarno);
1296 WRITE_STRING_FIELD(cursor_name);
1297 WRITE_INT_FIELD(cursor_param);
1301 _outTargetEntry(StringInfo str, TargetEntry *node)
1303 WRITE_NODE_TYPE("TARGETENTRY");
1305 WRITE_NODE_FIELD(expr);
1306 WRITE_INT_FIELD(resno);
1307 WRITE_STRING_FIELD(resname);
1308 WRITE_UINT_FIELD(ressortgroupref);
1309 WRITE_OID_FIELD(resorigtbl);
1310 WRITE_INT_FIELD(resorigcol);
1311 WRITE_BOOL_FIELD(resjunk);
1315 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1317 WRITE_NODE_TYPE("RANGETBLREF");
1319 WRITE_INT_FIELD(rtindex);
1323 _outJoinExpr(StringInfo str, JoinExpr *node)
1325 WRITE_NODE_TYPE("JOINEXPR");
1327 WRITE_ENUM_FIELD(jointype, JoinType);
1328 WRITE_BOOL_FIELD(isNatural);
1329 WRITE_NODE_FIELD(larg);
1330 WRITE_NODE_FIELD(rarg);
1331 WRITE_NODE_FIELD(usingClause);
1332 WRITE_NODE_FIELD(quals);
1333 WRITE_NODE_FIELD(alias);
1334 WRITE_INT_FIELD(rtindex);
1338 _outFromExpr(StringInfo str, FromExpr *node)
1340 WRITE_NODE_TYPE("FROMEXPR");
1342 WRITE_NODE_FIELD(fromlist);
1343 WRITE_NODE_FIELD(quals);
1346 /*****************************************************************************
1348 * Stuff from relation.h.
1350 *****************************************************************************/
1353 * print the basic stuff of all nodes that inherit from Path
1355 * Note we do NOT print the parent, else we'd be in infinite recursion.
1356 * We can print the parent's relids for identification purposes, though.
1359 _outPathInfo(StringInfo str, Path *node)
1361 WRITE_ENUM_FIELD(pathtype, NodeTag);
1362 appendStringInfo(str, " :parent_relids ");
1363 _outBitmapset(str, node->parent->relids);
1364 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1365 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1366 WRITE_NODE_FIELD(pathkeys);
1370 * print the basic stuff of all nodes that inherit from JoinPath
1373 _outJoinPathInfo(StringInfo str, JoinPath *node)
1375 _outPathInfo(str, (Path *) node);
1377 WRITE_ENUM_FIELD(jointype, JoinType);
1378 WRITE_NODE_FIELD(outerjoinpath);
1379 WRITE_NODE_FIELD(innerjoinpath);
1380 WRITE_NODE_FIELD(joinrestrictinfo);
1384 _outPath(StringInfo str, Path *node)
1386 WRITE_NODE_TYPE("PATH");
1388 _outPathInfo(str, (Path *) node);
1392 _outIndexPath(StringInfo str, IndexPath *node)
1394 WRITE_NODE_TYPE("INDEXPATH");
1396 _outPathInfo(str, (Path *) node);
1398 WRITE_NODE_FIELD(indexinfo);
1399 WRITE_NODE_FIELD(indexclauses);
1400 WRITE_NODE_FIELD(indexquals);
1401 WRITE_BOOL_FIELD(isjoininner);
1402 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1403 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1404 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1405 WRITE_FLOAT_FIELD(rows, "%.0f");
1409 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1411 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1413 _outPathInfo(str, (Path *) node);
1415 WRITE_NODE_FIELD(bitmapqual);
1416 WRITE_BOOL_FIELD(isjoininner);
1417 WRITE_FLOAT_FIELD(rows, "%.0f");
1421 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1423 WRITE_NODE_TYPE("BITMAPANDPATH");
1425 _outPathInfo(str, (Path *) node);
1427 WRITE_NODE_FIELD(bitmapquals);
1428 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1432 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1434 WRITE_NODE_TYPE("BITMAPORPATH");
1436 _outPathInfo(str, (Path *) node);
1438 WRITE_NODE_FIELD(bitmapquals);
1439 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1443 _outTidPath(StringInfo str, TidPath *node)
1445 WRITE_NODE_TYPE("TIDPATH");
1447 _outPathInfo(str, (Path *) node);
1449 WRITE_NODE_FIELD(tidquals);
1453 _outAppendPath(StringInfo str, AppendPath *node)
1455 WRITE_NODE_TYPE("APPENDPATH");
1457 _outPathInfo(str, (Path *) node);
1459 WRITE_NODE_FIELD(subpaths);
1463 _outResultPath(StringInfo str, ResultPath *node)
1465 WRITE_NODE_TYPE("RESULTPATH");
1467 _outPathInfo(str, (Path *) node);
1469 WRITE_NODE_FIELD(quals);
1473 _outMaterialPath(StringInfo str, MaterialPath *node)
1475 WRITE_NODE_TYPE("MATERIALPATH");
1477 _outPathInfo(str, (Path *) node);
1479 WRITE_NODE_FIELD(subpath);
1483 _outUniquePath(StringInfo str, UniquePath *node)
1485 WRITE_NODE_TYPE("UNIQUEPATH");
1487 _outPathInfo(str, (Path *) node);
1489 WRITE_NODE_FIELD(subpath);
1490 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1491 WRITE_NODE_FIELD(in_operators);
1492 WRITE_NODE_FIELD(uniq_exprs);
1493 WRITE_FLOAT_FIELD(rows, "%.0f");
1497 _outNestPath(StringInfo str, NestPath *node)
1499 WRITE_NODE_TYPE("NESTPATH");
1501 _outJoinPathInfo(str, (JoinPath *) node);
1505 _outMergePath(StringInfo str, MergePath *node)
1507 WRITE_NODE_TYPE("MERGEPATH");
1509 _outJoinPathInfo(str, (JoinPath *) node);
1511 WRITE_NODE_FIELD(path_mergeclauses);
1512 WRITE_NODE_FIELD(outersortkeys);
1513 WRITE_NODE_FIELD(innersortkeys);
1514 WRITE_BOOL_FIELD(materialize_inner);
1518 _outHashPath(StringInfo str, HashPath *node)
1520 WRITE_NODE_TYPE("HASHPATH");
1522 _outJoinPathInfo(str, (JoinPath *) node);
1524 WRITE_NODE_FIELD(path_hashclauses);
1525 WRITE_INT_FIELD(num_batches);
1529 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1531 WRITE_NODE_TYPE("PLANNERGLOBAL");
1533 /* NB: this isn't a complete set of fields */
1534 WRITE_NODE_FIELD(paramlist);
1535 WRITE_NODE_FIELD(subplans);
1536 WRITE_NODE_FIELD(subrtables);
1537 WRITE_NODE_FIELD(subrowmarks);
1538 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1539 WRITE_NODE_FIELD(finalrtable);
1540 WRITE_NODE_FIELD(finalrowmarks);
1541 WRITE_NODE_FIELD(relationOids);
1542 WRITE_NODE_FIELD(invalItems);
1543 WRITE_UINT_FIELD(lastPHId);
1544 WRITE_BOOL_FIELD(transientPlan);
1548 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1550 WRITE_NODE_TYPE("PLANNERINFO");
1552 /* NB: this isn't a complete set of fields */
1553 WRITE_NODE_FIELD(parse);
1554 WRITE_NODE_FIELD(glob);
1555 WRITE_UINT_FIELD(query_level);
1556 WRITE_NODE_FIELD(join_rel_list);
1557 WRITE_INT_FIELD(join_cur_level);
1558 WRITE_NODE_FIELD(resultRelations);
1559 WRITE_NODE_FIELD(init_plans);
1560 WRITE_NODE_FIELD(cte_plan_ids);
1561 WRITE_NODE_FIELD(eq_classes);
1562 WRITE_NODE_FIELD(canon_pathkeys);
1563 WRITE_NODE_FIELD(left_join_clauses);
1564 WRITE_NODE_FIELD(right_join_clauses);
1565 WRITE_NODE_FIELD(full_join_clauses);
1566 WRITE_NODE_FIELD(join_info_list);
1567 WRITE_NODE_FIELD(append_rel_list);
1568 WRITE_NODE_FIELD(rowMarks);
1569 WRITE_NODE_FIELD(placeholder_list);
1570 WRITE_NODE_FIELD(query_pathkeys);
1571 WRITE_NODE_FIELD(group_pathkeys);
1572 WRITE_NODE_FIELD(window_pathkeys);
1573 WRITE_NODE_FIELD(distinct_pathkeys);
1574 WRITE_NODE_FIELD(sort_pathkeys);
1575 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1576 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1577 WRITE_BOOL_FIELD(hasInheritedTarget);
1578 WRITE_BOOL_FIELD(hasJoinRTEs);
1579 WRITE_BOOL_FIELD(hasHavingQual);
1580 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1581 WRITE_BOOL_FIELD(hasRecursion);
1582 WRITE_INT_FIELD(wt_param_id);
1583 WRITE_BITMAPSET_FIELD(curOuterRels);
1584 WRITE_NODE_FIELD(curOuterParams);
1588 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1590 WRITE_NODE_TYPE("RELOPTINFO");
1592 /* NB: this isn't a complete set of fields */
1593 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1594 WRITE_BITMAPSET_FIELD(relids);
1595 WRITE_FLOAT_FIELD(rows, "%.0f");
1596 WRITE_INT_FIELD(width);
1597 WRITE_NODE_FIELD(reltargetlist);
1598 WRITE_NODE_FIELD(pathlist);
1599 WRITE_NODE_FIELD(cheapest_startup_path);
1600 WRITE_NODE_FIELD(cheapest_total_path);
1601 WRITE_NODE_FIELD(cheapest_unique_path);
1602 WRITE_UINT_FIELD(relid);
1603 WRITE_UINT_FIELD(reltablespace);
1604 WRITE_ENUM_FIELD(rtekind, RTEKind);
1605 WRITE_INT_FIELD(min_attr);
1606 WRITE_INT_FIELD(max_attr);
1607 WRITE_NODE_FIELD(indexlist);
1608 WRITE_UINT_FIELD(pages);
1609 WRITE_FLOAT_FIELD(tuples, "%.0f");
1610 WRITE_NODE_FIELD(subplan);
1611 WRITE_NODE_FIELD(subrtable);
1612 WRITE_NODE_FIELD(subrowmark);
1613 WRITE_NODE_FIELD(baserestrictinfo);
1614 WRITE_NODE_FIELD(joininfo);
1615 WRITE_BOOL_FIELD(has_eclass_joins);
1616 WRITE_BITMAPSET_FIELD(index_outer_relids);
1617 WRITE_NODE_FIELD(index_inner_paths);
1621 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1623 WRITE_NODE_TYPE("INDEXOPTINFO");
1625 /* NB: this isn't a complete set of fields */
1626 WRITE_OID_FIELD(indexoid);
1627 /* Do NOT print rel field, else infinite recursion */
1628 WRITE_UINT_FIELD(pages);
1629 WRITE_FLOAT_FIELD(tuples, "%.0f");
1630 WRITE_INT_FIELD(ncolumns);
1631 WRITE_NODE_FIELD(indexprs);
1632 WRITE_NODE_FIELD(indpred);
1633 WRITE_BOOL_FIELD(predOK);
1634 WRITE_BOOL_FIELD(unique);
1638 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1641 * To simplify reading, we just chase up to the topmost merged EC and
1642 * print that, without bothering to show the merge-ees separately.
1644 while (node->ec_merged)
1645 node = node->ec_merged;
1647 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1649 WRITE_NODE_FIELD(ec_opfamilies);
1650 WRITE_NODE_FIELD(ec_members);
1651 WRITE_NODE_FIELD(ec_sources);
1652 WRITE_NODE_FIELD(ec_derives);
1653 WRITE_BITMAPSET_FIELD(ec_relids);
1654 WRITE_BOOL_FIELD(ec_has_const);
1655 WRITE_BOOL_FIELD(ec_has_volatile);
1656 WRITE_BOOL_FIELD(ec_below_outer_join);
1657 WRITE_BOOL_FIELD(ec_broken);
1658 WRITE_UINT_FIELD(ec_sortref);
1662 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1664 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1666 WRITE_NODE_FIELD(em_expr);
1667 WRITE_BITMAPSET_FIELD(em_relids);
1668 WRITE_BOOL_FIELD(em_is_const);
1669 WRITE_BOOL_FIELD(em_is_child);
1670 WRITE_OID_FIELD(em_datatype);
1674 _outPathKey(StringInfo str, PathKey *node)
1676 WRITE_NODE_TYPE("PATHKEY");
1678 WRITE_NODE_FIELD(pk_eclass);
1679 WRITE_OID_FIELD(pk_opfamily);
1680 WRITE_INT_FIELD(pk_strategy);
1681 WRITE_BOOL_FIELD(pk_nulls_first);
1685 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1687 WRITE_NODE_TYPE("RESTRICTINFO");
1689 /* NB: this isn't a complete set of fields */
1690 WRITE_NODE_FIELD(clause);
1691 WRITE_BOOL_FIELD(is_pushed_down);
1692 WRITE_BOOL_FIELD(outerjoin_delayed);
1693 WRITE_BOOL_FIELD(can_join);
1694 WRITE_BOOL_FIELD(pseudoconstant);
1695 WRITE_BITMAPSET_FIELD(clause_relids);
1696 WRITE_BITMAPSET_FIELD(required_relids);
1697 WRITE_BITMAPSET_FIELD(nullable_relids);
1698 WRITE_BITMAPSET_FIELD(left_relids);
1699 WRITE_BITMAPSET_FIELD(right_relids);
1700 WRITE_NODE_FIELD(orclause);
1701 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1702 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1703 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1704 WRITE_NODE_FIELD(mergeopfamilies);
1705 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1706 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1707 WRITE_NODE_FIELD(left_em);
1708 WRITE_NODE_FIELD(right_em);
1709 WRITE_BOOL_FIELD(outer_is_left);
1710 WRITE_OID_FIELD(hashjoinoperator);
1714 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1716 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1717 WRITE_BITMAPSET_FIELD(other_relids);
1718 WRITE_BOOL_FIELD(isouterjoin);
1719 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1720 WRITE_NODE_FIELD(cheapest_total_innerpath);
1724 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1726 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1728 WRITE_NODE_FIELD(phexpr);
1729 WRITE_BITMAPSET_FIELD(phrels);
1730 WRITE_UINT_FIELD(phid);
1731 WRITE_UINT_FIELD(phlevelsup);
1735 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1737 WRITE_NODE_TYPE("SPECIALJOININFO");
1739 WRITE_BITMAPSET_FIELD(min_lefthand);
1740 WRITE_BITMAPSET_FIELD(min_righthand);
1741 WRITE_BITMAPSET_FIELD(syn_lefthand);
1742 WRITE_BITMAPSET_FIELD(syn_righthand);
1743 WRITE_ENUM_FIELD(jointype, JoinType);
1744 WRITE_BOOL_FIELD(lhs_strict);
1745 WRITE_BOOL_FIELD(delay_upper_joins);
1746 WRITE_NODE_FIELD(join_quals);
1750 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1752 WRITE_NODE_TYPE("APPENDRELINFO");
1754 WRITE_UINT_FIELD(parent_relid);
1755 WRITE_UINT_FIELD(child_relid);
1756 WRITE_OID_FIELD(parent_reltype);
1757 WRITE_OID_FIELD(child_reltype);
1758 WRITE_NODE_FIELD(translated_vars);
1759 WRITE_OID_FIELD(parent_reloid);
1763 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1765 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1767 WRITE_UINT_FIELD(phid);
1768 WRITE_NODE_FIELD(ph_var);
1769 WRITE_BITMAPSET_FIELD(ph_eval_at);
1770 WRITE_BITMAPSET_FIELD(ph_needed);
1771 WRITE_INT_FIELD(ph_width);
1775 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1777 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1779 WRITE_NODE_FIELD(item);
1780 WRITE_UINT_FIELD(abslevel);
1783 /*****************************************************************************
1785 * Stuff from parsenodes.h.
1787 *****************************************************************************/
1790 _outCreateStmt(StringInfo str, CreateStmt *node)
1792 WRITE_NODE_TYPE("CREATESTMT");
1794 WRITE_NODE_FIELD(relation);
1795 WRITE_NODE_FIELD(tableElts);
1796 WRITE_NODE_FIELD(inhRelations);
1797 WRITE_NODE_FIELD(ofTypename);
1798 WRITE_NODE_FIELD(constraints);
1799 WRITE_NODE_FIELD(options);
1800 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1801 WRITE_STRING_FIELD(tablespacename);
1802 WRITE_BOOL_FIELD(if_not_exists);
1806 _outIndexStmt(StringInfo str, IndexStmt *node)
1808 WRITE_NODE_TYPE("INDEXSTMT");
1810 WRITE_STRING_FIELD(idxname);
1811 WRITE_NODE_FIELD(relation);
1812 WRITE_STRING_FIELD(accessMethod);
1813 WRITE_STRING_FIELD(tableSpace);
1814 WRITE_NODE_FIELD(indexParams);
1815 WRITE_NODE_FIELD(options);
1816 WRITE_NODE_FIELD(whereClause);
1817 WRITE_NODE_FIELD(excludeOpNames);
1818 WRITE_BOOL_FIELD(unique);
1819 WRITE_BOOL_FIELD(primary);
1820 WRITE_BOOL_FIELD(isconstraint);
1821 WRITE_BOOL_FIELD(deferrable);
1822 WRITE_BOOL_FIELD(initdeferred);
1823 WRITE_BOOL_FIELD(concurrent);
1827 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1829 WRITE_NODE_TYPE("NOTIFY");
1831 WRITE_STRING_FIELD(conditionname);
1832 WRITE_STRING_FIELD(payload);
1836 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1838 WRITE_NODE_TYPE("DECLARECURSOR");
1840 WRITE_STRING_FIELD(portalname);
1841 WRITE_INT_FIELD(options);
1842 WRITE_NODE_FIELD(query);
1846 _outSelectStmt(StringInfo str, SelectStmt *node)
1848 WRITE_NODE_TYPE("SELECT");
1850 WRITE_NODE_FIELD(distinctClause);
1851 WRITE_NODE_FIELD(intoClause);
1852 WRITE_NODE_FIELD(targetList);
1853 WRITE_NODE_FIELD(fromClause);
1854 WRITE_NODE_FIELD(whereClause);
1855 WRITE_NODE_FIELD(groupClause);
1856 WRITE_NODE_FIELD(havingClause);
1857 WRITE_NODE_FIELD(windowClause);
1858 WRITE_NODE_FIELD(withClause);
1859 WRITE_NODE_FIELD(valuesLists);
1860 WRITE_NODE_FIELD(sortClause);
1861 WRITE_NODE_FIELD(limitOffset);
1862 WRITE_NODE_FIELD(limitCount);
1863 WRITE_NODE_FIELD(lockingClause);
1864 WRITE_ENUM_FIELD(op, SetOperation);
1865 WRITE_BOOL_FIELD(all);
1866 WRITE_NODE_FIELD(larg);
1867 WRITE_NODE_FIELD(rarg);
1871 _outFuncCall(StringInfo str, FuncCall *node)
1873 WRITE_NODE_TYPE("FUNCCALL");
1875 WRITE_NODE_FIELD(funcname);
1876 WRITE_NODE_FIELD(args);
1877 WRITE_NODE_FIELD(agg_order);
1878 WRITE_BOOL_FIELD(agg_star);
1879 WRITE_BOOL_FIELD(agg_distinct);
1880 WRITE_BOOL_FIELD(func_variadic);
1881 WRITE_NODE_FIELD(over);
1882 WRITE_LOCATION_FIELD(location);
1886 _outDefElem(StringInfo str, DefElem *node)
1888 WRITE_NODE_TYPE("DEFELEM");
1890 WRITE_STRING_FIELD(defnamespace);
1891 WRITE_STRING_FIELD(defname);
1892 WRITE_NODE_FIELD(arg);
1893 WRITE_ENUM_FIELD(defaction, DefElemAction);
1897 _outLockingClause(StringInfo str, LockingClause *node)
1899 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1901 WRITE_NODE_FIELD(lockedRels);
1902 WRITE_BOOL_FIELD(forUpdate);
1903 WRITE_BOOL_FIELD(noWait);
1907 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1909 WRITE_NODE_TYPE("XMLSERIALIZE");
1911 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1912 WRITE_NODE_FIELD(expr);
1913 WRITE_NODE_FIELD(typeName);
1914 WRITE_LOCATION_FIELD(location);
1918 _outColumnDef(StringInfo str, ColumnDef *node)
1920 WRITE_NODE_TYPE("COLUMNDEF");
1922 WRITE_STRING_FIELD(colname);
1923 WRITE_NODE_FIELD(typeName);
1924 WRITE_INT_FIELD(inhcount);
1925 WRITE_BOOL_FIELD(is_local);
1926 WRITE_BOOL_FIELD(is_not_null);
1927 WRITE_INT_FIELD(storage);
1928 WRITE_NODE_FIELD(raw_default);
1929 WRITE_NODE_FIELD(cooked_default);
1930 WRITE_NODE_FIELD(constraints);
1934 _outTypeName(StringInfo str, TypeName *node)
1936 WRITE_NODE_TYPE("TYPENAME");
1938 WRITE_NODE_FIELD(names);
1939 WRITE_OID_FIELD(typeOid);
1940 WRITE_BOOL_FIELD(setof);
1941 WRITE_BOOL_FIELD(pct_type);
1942 WRITE_NODE_FIELD(typmods);
1943 WRITE_INT_FIELD(typemod);
1944 WRITE_NODE_FIELD(arrayBounds);
1945 WRITE_LOCATION_FIELD(location);
1949 _outTypeCast(StringInfo str, TypeCast *node)
1951 WRITE_NODE_TYPE("TYPECAST");
1953 WRITE_NODE_FIELD(arg);
1954 WRITE_NODE_FIELD(typeName);
1955 WRITE_LOCATION_FIELD(location);
1959 _outIndexElem(StringInfo str, IndexElem *node)
1961 WRITE_NODE_TYPE("INDEXELEM");
1963 WRITE_STRING_FIELD(name);
1964 WRITE_NODE_FIELD(expr);
1965 WRITE_STRING_FIELD(indexcolname);
1966 WRITE_NODE_FIELD(opclass);
1967 WRITE_ENUM_FIELD(ordering, SortByDir);
1968 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1972 _outQuery(StringInfo str, Query *node)
1974 WRITE_NODE_TYPE("QUERY");
1976 WRITE_ENUM_FIELD(commandType, CmdType);
1977 WRITE_ENUM_FIELD(querySource, QuerySource);
1978 WRITE_BOOL_FIELD(canSetTag);
1981 * Hack to work around missing outfuncs routines for a lot of the
1982 * utility-statement node types. (The only one we actually *need* for
1983 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1984 * for the meantime do this to avoid getting lots of warnings when running
1985 * with debug_print_parse on.
1987 if (node->utilityStmt)
1989 switch (nodeTag(node->utilityStmt))
1994 case T_DeclareCursorStmt:
1995 WRITE_NODE_FIELD(utilityStmt);
1998 appendStringInfo(str, " :utilityStmt ?");
2003 appendStringInfo(str, " :utilityStmt <>");
2005 WRITE_INT_FIELD(resultRelation);
2006 WRITE_NODE_FIELD(intoClause);
2007 WRITE_BOOL_FIELD(hasAggs);
2008 WRITE_BOOL_FIELD(hasWindowFuncs);
2009 WRITE_BOOL_FIELD(hasSubLinks);
2010 WRITE_BOOL_FIELD(hasDistinctOn);
2011 WRITE_BOOL_FIELD(hasRecursive);
2012 WRITE_BOOL_FIELD(hasForUpdate);
2013 WRITE_NODE_FIELD(cteList);
2014 WRITE_NODE_FIELD(rtable);
2015 WRITE_NODE_FIELD(jointree);
2016 WRITE_NODE_FIELD(targetList);
2017 WRITE_NODE_FIELD(returningList);
2018 WRITE_NODE_FIELD(groupClause);
2019 WRITE_NODE_FIELD(havingQual);
2020 WRITE_NODE_FIELD(windowClause);
2021 WRITE_NODE_FIELD(distinctClause);
2022 WRITE_NODE_FIELD(sortClause);
2023 WRITE_NODE_FIELD(limitOffset);
2024 WRITE_NODE_FIELD(limitCount);
2025 WRITE_NODE_FIELD(rowMarks);
2026 WRITE_NODE_FIELD(setOperations);
2027 WRITE_NODE_FIELD(constraintDeps);
2031 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2033 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2035 WRITE_UINT_FIELD(tleSortGroupRef);
2036 WRITE_OID_FIELD(eqop);
2037 WRITE_OID_FIELD(sortop);
2038 WRITE_BOOL_FIELD(nulls_first);
2042 _outWindowClause(StringInfo str, WindowClause *node)
2044 WRITE_NODE_TYPE("WINDOWCLAUSE");
2046 WRITE_STRING_FIELD(name);
2047 WRITE_STRING_FIELD(refname);
2048 WRITE_NODE_FIELD(partitionClause);
2049 WRITE_NODE_FIELD(orderClause);
2050 WRITE_INT_FIELD(frameOptions);
2051 WRITE_NODE_FIELD(startOffset);
2052 WRITE_NODE_FIELD(endOffset);
2053 WRITE_UINT_FIELD(winref);
2054 WRITE_BOOL_FIELD(copiedOrder);
2058 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2060 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2062 WRITE_UINT_FIELD(rti);
2063 WRITE_BOOL_FIELD(forUpdate);
2064 WRITE_BOOL_FIELD(noWait);
2065 WRITE_BOOL_FIELD(pushedDown);
2069 _outWithClause(StringInfo str, WithClause *node)
2071 WRITE_NODE_TYPE("WITHCLAUSE");
2073 WRITE_NODE_FIELD(ctes);
2074 WRITE_BOOL_FIELD(recursive);
2075 WRITE_LOCATION_FIELD(location);
2079 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2081 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2083 WRITE_STRING_FIELD(ctename);
2084 WRITE_NODE_FIELD(aliascolnames);
2085 WRITE_NODE_FIELD(ctequery);
2086 WRITE_LOCATION_FIELD(location);
2087 WRITE_BOOL_FIELD(cterecursive);
2088 WRITE_INT_FIELD(cterefcount);
2089 WRITE_NODE_FIELD(ctecolnames);
2090 WRITE_NODE_FIELD(ctecoltypes);
2091 WRITE_NODE_FIELD(ctecoltypmods);
2095 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2097 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2099 WRITE_ENUM_FIELD(op, SetOperation);
2100 WRITE_BOOL_FIELD(all);
2101 WRITE_NODE_FIELD(larg);
2102 WRITE_NODE_FIELD(rarg);
2103 WRITE_NODE_FIELD(colTypes);
2104 WRITE_NODE_FIELD(colTypmods);
2105 WRITE_NODE_FIELD(groupClauses);
2109 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2111 WRITE_NODE_TYPE("RTE");
2113 /* put alias + eref first to make dump more legible */
2114 WRITE_NODE_FIELD(alias);
2115 WRITE_NODE_FIELD(eref);
2116 WRITE_ENUM_FIELD(rtekind, RTEKind);
2118 switch (node->rtekind)
2122 WRITE_OID_FIELD(relid);
2125 WRITE_NODE_FIELD(subquery);
2128 WRITE_ENUM_FIELD(jointype, JoinType);
2129 WRITE_NODE_FIELD(joinaliasvars);
2132 WRITE_NODE_FIELD(funcexpr);
2133 WRITE_NODE_FIELD(funccoltypes);
2134 WRITE_NODE_FIELD(funccoltypmods);
2137 WRITE_NODE_FIELD(values_lists);
2140 WRITE_STRING_FIELD(ctename);
2141 WRITE_UINT_FIELD(ctelevelsup);
2142 WRITE_BOOL_FIELD(self_reference);
2143 WRITE_NODE_FIELD(ctecoltypes);
2144 WRITE_NODE_FIELD(ctecoltypmods);
2147 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2151 WRITE_BOOL_FIELD(inh);
2152 WRITE_BOOL_FIELD(inFromCl);
2153 WRITE_UINT_FIELD(requiredPerms);
2154 WRITE_OID_FIELD(checkAsUser);
2155 WRITE_BITMAPSET_FIELD(selectedCols);
2156 WRITE_BITMAPSET_FIELD(modifiedCols);
2160 _outAExpr(StringInfo str, A_Expr *node)
2162 WRITE_NODE_TYPE("AEXPR");
2167 appendStringInfo(str, " ");
2168 WRITE_NODE_FIELD(name);
2171 appendStringInfo(str, " AND");
2174 appendStringInfo(str, " OR");
2177 appendStringInfo(str, " NOT");
2180 appendStringInfo(str, " ");
2181 WRITE_NODE_FIELD(name);
2182 appendStringInfo(str, " ANY ");
2185 appendStringInfo(str, " ");
2186 WRITE_NODE_FIELD(name);
2187 appendStringInfo(str, " ALL ");
2189 case AEXPR_DISTINCT:
2190 appendStringInfo(str, " DISTINCT ");
2191 WRITE_NODE_FIELD(name);
2194 appendStringInfo(str, " NULLIF ");
2195 WRITE_NODE_FIELD(name);
2198 appendStringInfo(str, " OF ");
2199 WRITE_NODE_FIELD(name);
2202 appendStringInfo(str, " IN ");
2203 WRITE_NODE_FIELD(name);
2206 appendStringInfo(str, " ??");
2210 WRITE_NODE_FIELD(lexpr);
2211 WRITE_NODE_FIELD(rexpr);
2212 WRITE_LOCATION_FIELD(location);
2216 _outValue(StringInfo str, Value *value)
2218 switch (value->type)
2221 appendStringInfo(str, "%ld", value->val.ival);
2226 * We assume the value is a valid numeric literal and so does not
2229 appendStringInfoString(str, value->val.str);
2232 appendStringInfoChar(str, '"');
2233 _outToken(str, value->val.str);
2234 appendStringInfoChar(str, '"');
2237 /* internal representation already has leading 'b' */
2238 appendStringInfoString(str, value->val.str);
2241 /* this is seen only within A_Const, not in transformed trees */
2242 appendStringInfoString(str, "NULL");
2245 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2251 _outColumnRef(StringInfo str, ColumnRef *node)
2253 WRITE_NODE_TYPE("COLUMNREF");
2255 WRITE_NODE_FIELD(fields);
2256 WRITE_LOCATION_FIELD(location);
2260 _outParamRef(StringInfo str, ParamRef *node)
2262 WRITE_NODE_TYPE("PARAMREF");
2264 WRITE_INT_FIELD(number);
2265 WRITE_LOCATION_FIELD(location);
2269 _outAConst(StringInfo str, A_Const *node)
2271 WRITE_NODE_TYPE("A_CONST");
2273 appendStringInfo(str, " :val ");
2274 _outValue(str, &(node->val));
2275 WRITE_LOCATION_FIELD(location);
2279 _outA_Star(StringInfo str, A_Star *node)
2281 WRITE_NODE_TYPE("A_STAR");
2285 _outA_Indices(StringInfo str, A_Indices *node)
2287 WRITE_NODE_TYPE("A_INDICES");
2289 WRITE_NODE_FIELD(lidx);
2290 WRITE_NODE_FIELD(uidx);
2294 _outA_Indirection(StringInfo str, A_Indirection *node)
2296 WRITE_NODE_TYPE("A_INDIRECTION");
2298 WRITE_NODE_FIELD(arg);
2299 WRITE_NODE_FIELD(indirection);
2303 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2305 WRITE_NODE_TYPE("A_ARRAYEXPR");
2307 WRITE_NODE_FIELD(elements);
2308 WRITE_LOCATION_FIELD(location);
2312 _outResTarget(StringInfo str, ResTarget *node)
2314 WRITE_NODE_TYPE("RESTARGET");
2316 WRITE_STRING_FIELD(name);
2317 WRITE_NODE_FIELD(indirection);
2318 WRITE_NODE_FIELD(val);
2319 WRITE_LOCATION_FIELD(location);
2323 _outSortBy(StringInfo str, SortBy *node)
2325 WRITE_NODE_TYPE("SORTBY");
2327 WRITE_NODE_FIELD(node);
2328 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2329 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2330 WRITE_NODE_FIELD(useOp);
2331 WRITE_LOCATION_FIELD(location);
2335 _outWindowDef(StringInfo str, WindowDef *node)
2337 WRITE_NODE_TYPE("WINDOWDEF");
2339 WRITE_STRING_FIELD(name);
2340 WRITE_STRING_FIELD(refname);
2341 WRITE_NODE_FIELD(partitionClause);
2342 WRITE_NODE_FIELD(orderClause);
2343 WRITE_INT_FIELD(frameOptions);
2344 WRITE_NODE_FIELD(startOffset);
2345 WRITE_NODE_FIELD(endOffset);
2346 WRITE_LOCATION_FIELD(location);
2350 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2352 WRITE_NODE_TYPE("RANGESUBSELECT");
2354 WRITE_NODE_FIELD(subquery);
2355 WRITE_NODE_FIELD(alias);
2359 _outRangeFunction(StringInfo str, RangeFunction *node)
2361 WRITE_NODE_TYPE("RANGEFUNCTION");
2363 WRITE_NODE_FIELD(funccallnode);
2364 WRITE_NODE_FIELD(alias);
2365 WRITE_NODE_FIELD(coldeflist);
2369 _outConstraint(StringInfo str, Constraint *node)
2371 WRITE_NODE_TYPE("CONSTRAINT");
2373 WRITE_STRING_FIELD(conname);
2374 WRITE_BOOL_FIELD(deferrable);
2375 WRITE_BOOL_FIELD(initdeferred);
2376 WRITE_LOCATION_FIELD(location);
2378 appendStringInfo(str, " :contype ");
2379 switch (node->contype)
2382 appendStringInfo(str, "NULL");
2385 case CONSTR_NOTNULL:
2386 appendStringInfo(str, "NOT_NULL");
2389 case CONSTR_DEFAULT:
2390 appendStringInfo(str, "DEFAULT");
2391 WRITE_NODE_FIELD(raw_expr);
2392 WRITE_STRING_FIELD(cooked_expr);
2396 appendStringInfo(str, "CHECK");
2397 WRITE_NODE_FIELD(raw_expr);
2398 WRITE_STRING_FIELD(cooked_expr);
2401 case CONSTR_PRIMARY:
2402 appendStringInfo(str, "PRIMARY_KEY");
2403 WRITE_NODE_FIELD(keys);
2404 WRITE_NODE_FIELD(options);
2405 WRITE_STRING_FIELD(indexspace);
2406 /* access_method and where_clause not currently used */
2410 appendStringInfo(str, "UNIQUE");
2411 WRITE_NODE_FIELD(keys);
2412 WRITE_NODE_FIELD(options);
2413 WRITE_STRING_FIELD(indexspace);
2414 /* access_method and where_clause not currently used */
2417 case CONSTR_EXCLUSION:
2418 appendStringInfo(str, "EXCLUSION");
2419 WRITE_NODE_FIELD(exclusions);
2420 WRITE_NODE_FIELD(options);
2421 WRITE_STRING_FIELD(indexspace);
2422 WRITE_STRING_FIELD(access_method);
2423 WRITE_NODE_FIELD(where_clause);
2426 case CONSTR_FOREIGN:
2427 appendStringInfo(str, "FOREIGN_KEY");
2428 WRITE_NODE_FIELD(pktable);
2429 WRITE_NODE_FIELD(fk_attrs);
2430 WRITE_NODE_FIELD(pk_attrs);
2431 WRITE_CHAR_FIELD(fk_matchtype);
2432 WRITE_CHAR_FIELD(fk_upd_action);
2433 WRITE_CHAR_FIELD(fk_del_action);
2434 WRITE_BOOL_FIELD(skip_validation);
2437 case CONSTR_ATTR_DEFERRABLE:
2438 appendStringInfo(str, "ATTR_DEFERRABLE");
2441 case CONSTR_ATTR_NOT_DEFERRABLE:
2442 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2445 case CONSTR_ATTR_DEFERRED:
2446 appendStringInfo(str, "ATTR_DEFERRED");
2449 case CONSTR_ATTR_IMMEDIATE:
2450 appendStringInfo(str, "ATTR_IMMEDIATE");
2454 appendStringInfo(str, "<unrecognized_constraint %d>",
2455 (int) node->contype);
2463 * converts a Node into ascii string and append it to 'str'
2466 _outNode(StringInfo str, void *obj)
2469 appendStringInfo(str, "<>");
2470 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2472 else if (IsA(obj, Integer) ||
2475 IsA(obj, BitString))
2477 /* nodeRead does not want to see { } around these! */
2478 _outValue(str, obj);
2482 appendStringInfoChar(str, '{');
2483 switch (nodeTag(obj))
2486 _outPlannedStmt(str, obj);
2492 _outResult(str, obj);
2495 _outModifyTable(str, obj);
2498 _outAppend(str, obj);
2500 case T_RecursiveUnion:
2501 _outRecursiveUnion(str, obj);
2504 _outBitmapAnd(str, obj);
2507 _outBitmapOr(str, obj);
2513 _outSeqScan(str, obj);
2516 _outIndexScan(str, obj);
2518 case T_BitmapIndexScan:
2519 _outBitmapIndexScan(str, obj);
2521 case T_BitmapHeapScan:
2522 _outBitmapHeapScan(str, obj);
2525 _outTidScan(str, obj);
2527 case T_SubqueryScan:
2528 _outSubqueryScan(str, obj);
2530 case T_FunctionScan:
2531 _outFunctionScan(str, obj);
2534 _outValuesScan(str, obj);
2537 _outCteScan(str, obj);
2539 case T_WorkTableScan:
2540 _outWorkTableScan(str, obj);
2546 _outNestLoop(str, obj);
2549 _outMergeJoin(str, obj);
2552 _outHashJoin(str, obj);
2558 _outWindowAgg(str, obj);
2561 _outGroup(str, obj);
2564 _outMaterial(str, obj);
2570 _outUnique(str, obj);
2576 _outSetOp(str, obj);
2579 _outLockRows(str, obj);
2582 _outLimit(str, obj);
2584 case T_NestLoopParam:
2585 _outNestLoopParam(str, obj);
2588 _outPlanRowMark(str, obj);
2590 case T_PlanInvalItem:
2591 _outPlanInvalItem(str, obj);
2594 _outAlias(str, obj);
2597 _outRangeVar(str, obj);
2600 _outIntoClause(str, obj);
2606 _outConst(str, obj);
2609 _outParam(str, obj);
2612 _outAggref(str, obj);
2615 _outWindowFunc(str, obj);
2618 _outArrayRef(str, obj);
2621 _outFuncExpr(str, obj);
2623 case T_NamedArgExpr:
2624 _outNamedArgExpr(str, obj);
2627 _outOpExpr(str, obj);
2629 case T_DistinctExpr:
2630 _outDistinctExpr(str, obj);
2632 case T_ScalarArrayOpExpr:
2633 _outScalarArrayOpExpr(str, obj);
2636 _outBoolExpr(str, obj);
2639 _outSubLink(str, obj);
2642 _outSubPlan(str, obj);
2644 case T_AlternativeSubPlan:
2645 _outAlternativeSubPlan(str, obj);
2648 _outFieldSelect(str, obj);
2651 _outFieldStore(str, obj);
2654 _outRelabelType(str, obj);
2657 _outCoerceViaIO(str, obj);
2659 case T_ArrayCoerceExpr:
2660 _outArrayCoerceExpr(str, obj);
2662 case T_ConvertRowtypeExpr:
2663 _outConvertRowtypeExpr(str, obj);
2666 _outCaseExpr(str, obj);
2669 _outCaseWhen(str, obj);
2671 case T_CaseTestExpr:
2672 _outCaseTestExpr(str, obj);
2675 _outArrayExpr(str, obj);
2678 _outRowExpr(str, obj);
2680 case T_RowCompareExpr:
2681 _outRowCompareExpr(str, obj);
2683 case T_CoalesceExpr:
2684 _outCoalesceExpr(str, obj);
2687 _outMinMaxExpr(str, obj);
2690 _outXmlExpr(str, obj);
2693 _outNullIfExpr(str, obj);
2696 _outNullTest(str, obj);
2699 _outBooleanTest(str, obj);
2701 case T_CoerceToDomain:
2702 _outCoerceToDomain(str, obj);
2704 case T_CoerceToDomainValue:
2705 _outCoerceToDomainValue(str, obj);
2707 case T_SetToDefault:
2708 _outSetToDefault(str, obj);
2710 case T_CurrentOfExpr:
2711 _outCurrentOfExpr(str, obj);
2714 _outTargetEntry(str, obj);
2717 _outRangeTblRef(str, obj);
2720 _outJoinExpr(str, obj);
2723 _outFromExpr(str, obj);
2730 _outIndexPath(str, obj);
2732 case T_BitmapHeapPath:
2733 _outBitmapHeapPath(str, obj);
2735 case T_BitmapAndPath:
2736 _outBitmapAndPath(str, obj);
2738 case T_BitmapOrPath:
2739 _outBitmapOrPath(str, obj);
2742 _outTidPath(str, obj);
2745 _outAppendPath(str, obj);
2748 _outResultPath(str, obj);
2750 case T_MaterialPath:
2751 _outMaterialPath(str, obj);
2754 _outUniquePath(str, obj);
2757 _outNestPath(str, obj);
2760 _outMergePath(str, obj);
2763 _outHashPath(str, obj);
2765 case T_PlannerGlobal:
2766 _outPlannerGlobal(str, obj);
2769 _outPlannerInfo(str, obj);
2772 _outRelOptInfo(str, obj);
2774 case T_IndexOptInfo:
2775 _outIndexOptInfo(str, obj);
2777 case T_EquivalenceClass:
2778 _outEquivalenceClass(str, obj);
2780 case T_EquivalenceMember:
2781 _outEquivalenceMember(str, obj);
2784 _outPathKey(str, obj);
2786 case T_RestrictInfo:
2787 _outRestrictInfo(str, obj);
2789 case T_InnerIndexscanInfo:
2790 _outInnerIndexscanInfo(str, obj);
2792 case T_PlaceHolderVar:
2793 _outPlaceHolderVar(str, obj);
2795 case T_SpecialJoinInfo:
2796 _outSpecialJoinInfo(str, obj);
2798 case T_AppendRelInfo:
2799 _outAppendRelInfo(str, obj);
2801 case T_PlaceHolderInfo:
2802 _outPlaceHolderInfo(str, obj);
2804 case T_PlannerParamItem:
2805 _outPlannerParamItem(str, obj);
2809 _outCreateStmt(str, obj);
2812 _outIndexStmt(str, obj);
2815 _outNotifyStmt(str, obj);
2817 case T_DeclareCursorStmt:
2818 _outDeclareCursorStmt(str, obj);
2821 _outSelectStmt(str, obj);
2824 _outColumnDef(str, obj);
2827 _outTypeName(str, obj);
2830 _outTypeCast(str, obj);
2833 _outIndexElem(str, obj);
2836 _outQuery(str, obj);
2838 case T_SortGroupClause:
2839 _outSortGroupClause(str, obj);
2841 case T_WindowClause:
2842 _outWindowClause(str, obj);
2844 case T_RowMarkClause:
2845 _outRowMarkClause(str, obj);
2848 _outWithClause(str, obj);
2850 case T_CommonTableExpr:
2851 _outCommonTableExpr(str, obj);
2853 case T_SetOperationStmt:
2854 _outSetOperationStmt(str, obj);
2856 case T_RangeTblEntry:
2857 _outRangeTblEntry(str, obj);
2860 _outAExpr(str, obj);
2863 _outColumnRef(str, obj);
2866 _outParamRef(str, obj);
2869 _outAConst(str, obj);
2872 _outA_Star(str, obj);
2875 _outA_Indices(str, obj);
2877 case T_A_Indirection:
2878 _outA_Indirection(str, obj);
2881 _outA_ArrayExpr(str, obj);
2884 _outResTarget(str, obj);
2887 _outSortBy(str, obj);
2890 _outWindowDef(str, obj);
2892 case T_RangeSubselect:
2893 _outRangeSubselect(str, obj);
2895 case T_RangeFunction:
2896 _outRangeFunction(str, obj);
2899 _outConstraint(str, obj);
2902 _outFuncCall(str, obj);
2905 _outDefElem(str, obj);
2907 case T_LockingClause:
2908 _outLockingClause(str, obj);
2910 case T_XmlSerialize:
2911 _outXmlSerialize(str, obj);
2917 * This should be an ERROR, but it's too useful to be able to
2918 * dump structures that _outNode only understands part of.
2920 elog(WARNING, "could not dump unrecognized node type: %d",
2921 (int) nodeTag(obj));
2924 appendStringInfoChar(str, '}');
2930 * returns the ascii representation of the Node as a palloc'd string
2933 nodeToString(void *obj)
2937 /* see stringinfo.h for an explanation of this maneuver */
2938 initStringInfo(&str);
2939 _outNode(&str, obj);