1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.377 2009/12/29 20:11:45 tgl Exp $
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_NODE_FIELD(planTree);
248 WRITE_NODE_FIELD(rtable);
249 WRITE_NODE_FIELD(resultRelations);
250 WRITE_NODE_FIELD(utilityStmt);
251 WRITE_NODE_FIELD(intoClause);
252 WRITE_NODE_FIELD(subplans);
253 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
254 WRITE_NODE_FIELD(rowMarks);
255 WRITE_NODE_FIELD(relationOids);
256 WRITE_NODE_FIELD(invalItems);
257 WRITE_INT_FIELD(nParamExec);
261 * print the basic stuff of all nodes that inherit from Plan
264 _outPlanInfo(StringInfo str, Plan *node)
266 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
267 WRITE_FLOAT_FIELD(total_cost, "%.2f");
268 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
269 WRITE_INT_FIELD(plan_width);
270 WRITE_NODE_FIELD(targetlist);
271 WRITE_NODE_FIELD(qual);
272 WRITE_NODE_FIELD(lefttree);
273 WRITE_NODE_FIELD(righttree);
274 WRITE_NODE_FIELD(initPlan);
275 WRITE_BITMAPSET_FIELD(extParam);
276 WRITE_BITMAPSET_FIELD(allParam);
280 * print the basic stuff of all nodes that inherit from Scan
283 _outScanInfo(StringInfo str, Scan *node)
285 _outPlanInfo(str, (Plan *) node);
287 WRITE_UINT_FIELD(scanrelid);
291 * print the basic stuff of all nodes that inherit from Join
294 _outJoinPlanInfo(StringInfo str, Join *node)
296 _outPlanInfo(str, (Plan *) node);
298 WRITE_ENUM_FIELD(jointype, JoinType);
299 WRITE_NODE_FIELD(joinqual);
304 _outPlan(StringInfo str, Plan *node)
306 WRITE_NODE_TYPE("PLAN");
308 _outPlanInfo(str, (Plan *) node);
312 _outResult(StringInfo str, Result *node)
314 WRITE_NODE_TYPE("RESULT");
316 _outPlanInfo(str, (Plan *) node);
318 WRITE_NODE_FIELD(resconstantqual);
322 _outModifyTable(StringInfo str, ModifyTable *node)
324 WRITE_NODE_TYPE("MODIFYTABLE");
326 _outPlanInfo(str, (Plan *) node);
328 WRITE_ENUM_FIELD(operation, CmdType);
329 WRITE_NODE_FIELD(resultRelations);
330 WRITE_NODE_FIELD(plans);
331 WRITE_NODE_FIELD(returningLists);
332 WRITE_NODE_FIELD(rowMarks);
333 WRITE_INT_FIELD(epqParam);
337 _outAppend(StringInfo str, Append *node)
339 WRITE_NODE_TYPE("APPEND");
341 _outPlanInfo(str, (Plan *) node);
343 WRITE_NODE_FIELD(appendplans);
347 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
351 WRITE_NODE_TYPE("RECURSIVEUNION");
353 _outPlanInfo(str, (Plan *) node);
355 WRITE_INT_FIELD(wtParam);
356 WRITE_INT_FIELD(numCols);
358 appendStringInfo(str, " :dupColIdx");
359 for (i = 0; i < node->numCols; i++)
360 appendStringInfo(str, " %d", node->dupColIdx[i]);
362 appendStringInfo(str, " :dupOperators");
363 for (i = 0; i < node->numCols; i++)
364 appendStringInfo(str, " %u", node->dupOperators[i]);
366 WRITE_LONG_FIELD(numGroups);
370 _outBitmapAnd(StringInfo str, BitmapAnd *node)
372 WRITE_NODE_TYPE("BITMAPAND");
374 _outPlanInfo(str, (Plan *) node);
376 WRITE_NODE_FIELD(bitmapplans);
380 _outBitmapOr(StringInfo str, BitmapOr *node)
382 WRITE_NODE_TYPE("BITMAPOR");
384 _outPlanInfo(str, (Plan *) node);
386 WRITE_NODE_FIELD(bitmapplans);
390 _outScan(StringInfo str, Scan *node)
392 WRITE_NODE_TYPE("SCAN");
394 _outScanInfo(str, (Scan *) node);
398 _outSeqScan(StringInfo str, SeqScan *node)
400 WRITE_NODE_TYPE("SEQSCAN");
402 _outScanInfo(str, (Scan *) node);
406 _outIndexScan(StringInfo str, IndexScan *node)
408 WRITE_NODE_TYPE("INDEXSCAN");
410 _outScanInfo(str, (Scan *) node);
412 WRITE_OID_FIELD(indexid);
413 WRITE_NODE_FIELD(indexqual);
414 WRITE_NODE_FIELD(indexqualorig);
415 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
419 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
421 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
423 _outScanInfo(str, (Scan *) node);
425 WRITE_OID_FIELD(indexid);
426 WRITE_NODE_FIELD(indexqual);
427 WRITE_NODE_FIELD(indexqualorig);
431 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
433 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
435 _outScanInfo(str, (Scan *) node);
437 WRITE_NODE_FIELD(bitmapqualorig);
441 _outTidScan(StringInfo str, TidScan *node)
443 WRITE_NODE_TYPE("TIDSCAN");
445 _outScanInfo(str, (Scan *) node);
447 WRITE_NODE_FIELD(tidquals);
451 _outSubqueryScan(StringInfo str, SubqueryScan *node)
453 WRITE_NODE_TYPE("SUBQUERYSCAN");
455 _outScanInfo(str, (Scan *) node);
457 WRITE_NODE_FIELD(subplan);
458 WRITE_NODE_FIELD(subrtable);
459 WRITE_NODE_FIELD(subrowmark);
463 _outFunctionScan(StringInfo str, FunctionScan *node)
465 WRITE_NODE_TYPE("FUNCTIONSCAN");
467 _outScanInfo(str, (Scan *) node);
469 WRITE_NODE_FIELD(funcexpr);
470 WRITE_NODE_FIELD(funccolnames);
471 WRITE_NODE_FIELD(funccoltypes);
472 WRITE_NODE_FIELD(funccoltypmods);
476 _outValuesScan(StringInfo str, ValuesScan *node)
478 WRITE_NODE_TYPE("VALUESSCAN");
480 _outScanInfo(str, (Scan *) node);
482 WRITE_NODE_FIELD(values_lists);
486 _outCteScan(StringInfo str, CteScan *node)
488 WRITE_NODE_TYPE("CTESCAN");
490 _outScanInfo(str, (Scan *) node);
492 WRITE_INT_FIELD(ctePlanId);
493 WRITE_INT_FIELD(cteParam);
497 _outWorkTableScan(StringInfo str, WorkTableScan *node)
499 WRITE_NODE_TYPE("WORKTABLESCAN");
501 _outScanInfo(str, (Scan *) node);
503 WRITE_INT_FIELD(wtParam);
507 _outJoin(StringInfo str, Join *node)
509 WRITE_NODE_TYPE("JOIN");
511 _outJoinPlanInfo(str, (Join *) node);
515 _outNestLoop(StringInfo str, NestLoop *node)
517 WRITE_NODE_TYPE("NESTLOOP");
519 _outJoinPlanInfo(str, (Join *) node);
523 _outMergeJoin(StringInfo str, MergeJoin *node)
528 WRITE_NODE_TYPE("MERGEJOIN");
530 _outJoinPlanInfo(str, (Join *) node);
532 WRITE_NODE_FIELD(mergeclauses);
534 numCols = list_length(node->mergeclauses);
536 appendStringInfo(str, " :mergeFamilies");
537 for (i = 0; i < numCols; i++)
538 appendStringInfo(str, " %u", node->mergeFamilies[i]);
540 appendStringInfo(str, " :mergeStrategies");
541 for (i = 0; i < numCols; i++)
542 appendStringInfo(str, " %d", node->mergeStrategies[i]);
544 appendStringInfo(str, " :mergeNullsFirst");
545 for (i = 0; i < numCols; i++)
546 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
550 _outHashJoin(StringInfo str, HashJoin *node)
552 WRITE_NODE_TYPE("HASHJOIN");
554 _outJoinPlanInfo(str, (Join *) node);
556 WRITE_NODE_FIELD(hashclauses);
560 _outAgg(StringInfo str, Agg *node)
564 WRITE_NODE_TYPE("AGG");
566 _outPlanInfo(str, (Plan *) node);
568 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
569 WRITE_INT_FIELD(numCols);
571 appendStringInfo(str, " :grpColIdx");
572 for (i = 0; i < node->numCols; i++)
573 appendStringInfo(str, " %d", node->grpColIdx[i]);
575 appendStringInfo(str, " :grpOperators");
576 for (i = 0; i < node->numCols; i++)
577 appendStringInfo(str, " %u", node->grpOperators[i]);
579 WRITE_LONG_FIELD(numGroups);
583 _outWindowAgg(StringInfo str, WindowAgg *node)
587 WRITE_NODE_TYPE("WINDOWAGG");
589 _outPlanInfo(str, (Plan *) node);
591 WRITE_UINT_FIELD(winref);
592 WRITE_INT_FIELD(partNumCols);
594 appendStringInfo(str, " :partColIdx");
595 for (i = 0; i < node->partNumCols; i++)
596 appendStringInfo(str, " %d", node->partColIdx[i]);
598 appendStringInfo(str, " :partOperations");
599 for (i = 0; i < node->partNumCols; i++)
600 appendStringInfo(str, " %u", node->partOperators[i]);
602 WRITE_INT_FIELD(ordNumCols);
604 appendStringInfo(str, " :ordColIdx");
605 for (i = 0; i < node->ordNumCols; i++)
606 appendStringInfo(str, " %d", node->ordColIdx[i]);
608 appendStringInfo(str, " :ordOperations");
609 for (i = 0; i < node->ordNumCols; i++)
610 appendStringInfo(str, " %u", node->ordOperators[i]);
612 WRITE_INT_FIELD(frameOptions);
616 _outGroup(StringInfo str, Group *node)
620 WRITE_NODE_TYPE("GROUP");
622 _outPlanInfo(str, (Plan *) node);
624 WRITE_INT_FIELD(numCols);
626 appendStringInfo(str, " :grpColIdx");
627 for (i = 0; i < node->numCols; i++)
628 appendStringInfo(str, " %d", node->grpColIdx[i]);
630 appendStringInfo(str, " :grpOperators");
631 for (i = 0; i < node->numCols; i++)
632 appendStringInfo(str, " %u", node->grpOperators[i]);
636 _outMaterial(StringInfo str, Material *node)
638 WRITE_NODE_TYPE("MATERIAL");
640 _outPlanInfo(str, (Plan *) node);
644 _outSort(StringInfo str, Sort *node)
648 WRITE_NODE_TYPE("SORT");
650 _outPlanInfo(str, (Plan *) node);
652 WRITE_INT_FIELD(numCols);
654 appendStringInfo(str, " :sortColIdx");
655 for (i = 0; i < node->numCols; i++)
656 appendStringInfo(str, " %d", node->sortColIdx[i]);
658 appendStringInfo(str, " :sortOperators");
659 for (i = 0; i < node->numCols; i++)
660 appendStringInfo(str, " %u", node->sortOperators[i]);
662 appendStringInfo(str, " :nullsFirst");
663 for (i = 0; i < node->numCols; i++)
664 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
668 _outUnique(StringInfo str, Unique *node)
672 WRITE_NODE_TYPE("UNIQUE");
674 _outPlanInfo(str, (Plan *) node);
676 WRITE_INT_FIELD(numCols);
678 appendStringInfo(str, " :uniqColIdx");
679 for (i = 0; i < node->numCols; i++)
680 appendStringInfo(str, " %d", node->uniqColIdx[i]);
682 appendStringInfo(str, " :uniqOperators");
683 for (i = 0; i < node->numCols; i++)
684 appendStringInfo(str, " %u", node->uniqOperators[i]);
688 _outHash(StringInfo str, Hash *node)
690 WRITE_NODE_TYPE("HASH");
692 _outPlanInfo(str, (Plan *) node);
694 WRITE_OID_FIELD(skewTable);
695 WRITE_INT_FIELD(skewColumn);
696 WRITE_BOOL_FIELD(skewInherit);
697 WRITE_OID_FIELD(skewColType);
698 WRITE_INT_FIELD(skewColTypmod);
702 _outSetOp(StringInfo str, SetOp *node)
706 WRITE_NODE_TYPE("SETOP");
708 _outPlanInfo(str, (Plan *) node);
710 WRITE_ENUM_FIELD(cmd, SetOpCmd);
711 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
712 WRITE_INT_FIELD(numCols);
714 appendStringInfo(str, " :dupColIdx");
715 for (i = 0; i < node->numCols; i++)
716 appendStringInfo(str, " %d", node->dupColIdx[i]);
718 appendStringInfo(str, " :dupOperators");
719 for (i = 0; i < node->numCols; i++)
720 appendStringInfo(str, " %u", node->dupOperators[i]);
722 WRITE_INT_FIELD(flagColIdx);
723 WRITE_INT_FIELD(firstFlag);
724 WRITE_LONG_FIELD(numGroups);
728 _outLockRows(StringInfo str, LockRows *node)
730 WRITE_NODE_TYPE("LOCKROWS");
732 _outPlanInfo(str, (Plan *) node);
734 WRITE_NODE_FIELD(rowMarks);
735 WRITE_INT_FIELD(epqParam);
739 _outLimit(StringInfo str, Limit *node)
741 WRITE_NODE_TYPE("LIMIT");
743 _outPlanInfo(str, (Plan *) node);
745 WRITE_NODE_FIELD(limitOffset);
746 WRITE_NODE_FIELD(limitCount);
750 _outPlanRowMark(StringInfo str, PlanRowMark *node)
752 WRITE_NODE_TYPE("PLANROWMARK");
754 WRITE_UINT_FIELD(rti);
755 WRITE_UINT_FIELD(prti);
756 WRITE_ENUM_FIELD(markType, RowMarkType);
757 WRITE_BOOL_FIELD(noWait);
758 WRITE_BOOL_FIELD(isParent);
759 WRITE_INT_FIELD(ctidAttNo);
760 WRITE_INT_FIELD(toidAttNo);
761 WRITE_INT_FIELD(wholeAttNo);
765 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
767 WRITE_NODE_TYPE("PLANINVALITEM");
769 WRITE_INT_FIELD(cacheId);
770 appendStringInfo(str, " :tupleId (%u,%u)",
771 ItemPointerGetBlockNumber(&node->tupleId),
772 ItemPointerGetOffsetNumber(&node->tupleId));
775 /*****************************************************************************
777 * Stuff from primnodes.h.
779 *****************************************************************************/
782 _outAlias(StringInfo str, Alias *node)
784 WRITE_NODE_TYPE("ALIAS");
786 WRITE_STRING_FIELD(aliasname);
787 WRITE_NODE_FIELD(colnames);
791 _outRangeVar(StringInfo str, RangeVar *node)
793 WRITE_NODE_TYPE("RANGEVAR");
796 * we deliberately ignore catalogname here, since it is presently not
797 * semantically meaningful
799 WRITE_STRING_FIELD(schemaname);
800 WRITE_STRING_FIELD(relname);
801 WRITE_ENUM_FIELD(inhOpt, InhOption);
802 WRITE_BOOL_FIELD(istemp);
803 WRITE_NODE_FIELD(alias);
804 WRITE_LOCATION_FIELD(location);
808 _outIntoClause(StringInfo str, IntoClause *node)
810 WRITE_NODE_TYPE("INTOCLAUSE");
812 WRITE_NODE_FIELD(rel);
813 WRITE_NODE_FIELD(colNames);
814 WRITE_NODE_FIELD(options);
815 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
816 WRITE_STRING_FIELD(tableSpaceName);
820 _outVar(StringInfo str, Var *node)
822 WRITE_NODE_TYPE("VAR");
824 WRITE_UINT_FIELD(varno);
825 WRITE_INT_FIELD(varattno);
826 WRITE_OID_FIELD(vartype);
827 WRITE_INT_FIELD(vartypmod);
828 WRITE_UINT_FIELD(varlevelsup);
829 WRITE_UINT_FIELD(varnoold);
830 WRITE_INT_FIELD(varoattno);
831 WRITE_LOCATION_FIELD(location);
835 _outConst(StringInfo str, Const *node)
837 WRITE_NODE_TYPE("CONST");
839 WRITE_OID_FIELD(consttype);
840 WRITE_INT_FIELD(consttypmod);
841 WRITE_INT_FIELD(constlen);
842 WRITE_BOOL_FIELD(constbyval);
843 WRITE_BOOL_FIELD(constisnull);
844 WRITE_LOCATION_FIELD(location);
846 appendStringInfo(str, " :constvalue ");
847 if (node->constisnull)
848 appendStringInfo(str, "<>");
850 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
854 _outParam(StringInfo str, Param *node)
856 WRITE_NODE_TYPE("PARAM");
858 WRITE_ENUM_FIELD(paramkind, ParamKind);
859 WRITE_INT_FIELD(paramid);
860 WRITE_OID_FIELD(paramtype);
861 WRITE_INT_FIELD(paramtypmod);
862 WRITE_LOCATION_FIELD(location);
866 _outAggref(StringInfo str, Aggref *node)
868 WRITE_NODE_TYPE("AGGREF");
870 WRITE_OID_FIELD(aggfnoid);
871 WRITE_OID_FIELD(aggtype);
872 WRITE_NODE_FIELD(args);
873 WRITE_NODE_FIELD(aggorder);
874 WRITE_NODE_FIELD(aggdistinct);
875 WRITE_BOOL_FIELD(aggstar);
876 WRITE_UINT_FIELD(agglevelsup);
877 WRITE_LOCATION_FIELD(location);
881 _outWindowFunc(StringInfo str, WindowFunc *node)
883 WRITE_NODE_TYPE("WINDOWFUNC");
885 WRITE_OID_FIELD(winfnoid);
886 WRITE_OID_FIELD(wintype);
887 WRITE_NODE_FIELD(args);
888 WRITE_UINT_FIELD(winref);
889 WRITE_BOOL_FIELD(winstar);
890 WRITE_BOOL_FIELD(winagg);
891 WRITE_LOCATION_FIELD(location);
895 _outArrayRef(StringInfo str, ArrayRef *node)
897 WRITE_NODE_TYPE("ARRAYREF");
899 WRITE_OID_FIELD(refarraytype);
900 WRITE_OID_FIELD(refelemtype);
901 WRITE_INT_FIELD(reftypmod);
902 WRITE_NODE_FIELD(refupperindexpr);
903 WRITE_NODE_FIELD(reflowerindexpr);
904 WRITE_NODE_FIELD(refexpr);
905 WRITE_NODE_FIELD(refassgnexpr);
909 _outFuncExpr(StringInfo str, FuncExpr *node)
911 WRITE_NODE_TYPE("FUNCEXPR");
913 WRITE_OID_FIELD(funcid);
914 WRITE_OID_FIELD(funcresulttype);
915 WRITE_BOOL_FIELD(funcretset);
916 WRITE_ENUM_FIELD(funcformat, CoercionForm);
917 WRITE_NODE_FIELD(args);
918 WRITE_LOCATION_FIELD(location);
922 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
924 WRITE_NODE_TYPE("NAMEDARGEXPR");
926 WRITE_NODE_FIELD(arg);
927 WRITE_STRING_FIELD(name);
928 WRITE_INT_FIELD(argnumber);
929 WRITE_LOCATION_FIELD(location);
933 _outOpExpr(StringInfo str, OpExpr *node)
935 WRITE_NODE_TYPE("OPEXPR");
937 WRITE_OID_FIELD(opno);
938 WRITE_OID_FIELD(opfuncid);
939 WRITE_OID_FIELD(opresulttype);
940 WRITE_BOOL_FIELD(opretset);
941 WRITE_NODE_FIELD(args);
942 WRITE_LOCATION_FIELD(location);
946 _outDistinctExpr(StringInfo str, DistinctExpr *node)
948 WRITE_NODE_TYPE("DISTINCTEXPR");
950 WRITE_OID_FIELD(opno);
951 WRITE_OID_FIELD(opfuncid);
952 WRITE_OID_FIELD(opresulttype);
953 WRITE_BOOL_FIELD(opretset);
954 WRITE_NODE_FIELD(args);
955 WRITE_LOCATION_FIELD(location);
959 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
961 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
963 WRITE_OID_FIELD(opno);
964 WRITE_OID_FIELD(opfuncid);
965 WRITE_BOOL_FIELD(useOr);
966 WRITE_NODE_FIELD(args);
967 WRITE_LOCATION_FIELD(location);
971 _outBoolExpr(StringInfo str, BoolExpr *node)
975 WRITE_NODE_TYPE("BOOLEXPR");
977 /* do-it-yourself enum representation */
978 switch (node->boolop)
990 appendStringInfo(str, " :boolop ");
991 _outToken(str, opstr);
993 WRITE_NODE_FIELD(args);
994 WRITE_LOCATION_FIELD(location);
998 _outSubLink(StringInfo str, SubLink *node)
1000 WRITE_NODE_TYPE("SUBLINK");
1002 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1003 WRITE_NODE_FIELD(testexpr);
1004 WRITE_NODE_FIELD(operName);
1005 WRITE_NODE_FIELD(subselect);
1006 WRITE_LOCATION_FIELD(location);
1010 _outSubPlan(StringInfo str, SubPlan *node)
1012 WRITE_NODE_TYPE("SUBPLAN");
1014 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1015 WRITE_NODE_FIELD(testexpr);
1016 WRITE_NODE_FIELD(paramIds);
1017 WRITE_INT_FIELD(plan_id);
1018 WRITE_STRING_FIELD(plan_name);
1019 WRITE_OID_FIELD(firstColType);
1020 WRITE_INT_FIELD(firstColTypmod);
1021 WRITE_BOOL_FIELD(useHashTable);
1022 WRITE_BOOL_FIELD(unknownEqFalse);
1023 WRITE_NODE_FIELD(setParam);
1024 WRITE_NODE_FIELD(parParam);
1025 WRITE_NODE_FIELD(args);
1026 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1027 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1031 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1033 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1035 WRITE_NODE_FIELD(subplans);
1039 _outFieldSelect(StringInfo str, FieldSelect *node)
1041 WRITE_NODE_TYPE("FIELDSELECT");
1043 WRITE_NODE_FIELD(arg);
1044 WRITE_INT_FIELD(fieldnum);
1045 WRITE_OID_FIELD(resulttype);
1046 WRITE_INT_FIELD(resulttypmod);
1050 _outFieldStore(StringInfo str, FieldStore *node)
1052 WRITE_NODE_TYPE("FIELDSTORE");
1054 WRITE_NODE_FIELD(arg);
1055 WRITE_NODE_FIELD(newvals);
1056 WRITE_NODE_FIELD(fieldnums);
1057 WRITE_OID_FIELD(resulttype);
1061 _outRelabelType(StringInfo str, RelabelType *node)
1063 WRITE_NODE_TYPE("RELABELTYPE");
1065 WRITE_NODE_FIELD(arg);
1066 WRITE_OID_FIELD(resulttype);
1067 WRITE_INT_FIELD(resulttypmod);
1068 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1069 WRITE_LOCATION_FIELD(location);
1073 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1075 WRITE_NODE_TYPE("COERCEVIAIO");
1077 WRITE_NODE_FIELD(arg);
1078 WRITE_OID_FIELD(resulttype);
1079 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1080 WRITE_LOCATION_FIELD(location);
1084 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1086 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1088 WRITE_NODE_FIELD(arg);
1089 WRITE_OID_FIELD(elemfuncid);
1090 WRITE_OID_FIELD(resulttype);
1091 WRITE_INT_FIELD(resulttypmod);
1092 WRITE_BOOL_FIELD(isExplicit);
1093 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1094 WRITE_LOCATION_FIELD(location);
1098 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1100 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1102 WRITE_NODE_FIELD(arg);
1103 WRITE_OID_FIELD(resulttype);
1104 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1105 WRITE_LOCATION_FIELD(location);
1109 _outCaseExpr(StringInfo str, CaseExpr *node)
1111 WRITE_NODE_TYPE("CASE");
1113 WRITE_OID_FIELD(casetype);
1114 WRITE_NODE_FIELD(arg);
1115 WRITE_NODE_FIELD(args);
1116 WRITE_NODE_FIELD(defresult);
1117 WRITE_LOCATION_FIELD(location);
1121 _outCaseWhen(StringInfo str, CaseWhen *node)
1123 WRITE_NODE_TYPE("WHEN");
1125 WRITE_NODE_FIELD(expr);
1126 WRITE_NODE_FIELD(result);
1127 WRITE_LOCATION_FIELD(location);
1131 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1133 WRITE_NODE_TYPE("CASETESTEXPR");
1135 WRITE_OID_FIELD(typeId);
1136 WRITE_INT_FIELD(typeMod);
1140 _outArrayExpr(StringInfo str, ArrayExpr *node)
1142 WRITE_NODE_TYPE("ARRAY");
1144 WRITE_OID_FIELD(array_typeid);
1145 WRITE_OID_FIELD(element_typeid);
1146 WRITE_NODE_FIELD(elements);
1147 WRITE_BOOL_FIELD(multidims);
1148 WRITE_LOCATION_FIELD(location);
1152 _outRowExpr(StringInfo str, RowExpr *node)
1154 WRITE_NODE_TYPE("ROW");
1156 WRITE_NODE_FIELD(args);
1157 WRITE_OID_FIELD(row_typeid);
1158 WRITE_ENUM_FIELD(row_format, CoercionForm);
1159 WRITE_NODE_FIELD(colnames);
1160 WRITE_LOCATION_FIELD(location);
1164 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1166 WRITE_NODE_TYPE("ROWCOMPARE");
1168 WRITE_ENUM_FIELD(rctype, RowCompareType);
1169 WRITE_NODE_FIELD(opnos);
1170 WRITE_NODE_FIELD(opfamilies);
1171 WRITE_NODE_FIELD(largs);
1172 WRITE_NODE_FIELD(rargs);
1176 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1178 WRITE_NODE_TYPE("COALESCE");
1180 WRITE_OID_FIELD(coalescetype);
1181 WRITE_NODE_FIELD(args);
1182 WRITE_LOCATION_FIELD(location);
1186 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1188 WRITE_NODE_TYPE("MINMAX");
1190 WRITE_OID_FIELD(minmaxtype);
1191 WRITE_ENUM_FIELD(op, MinMaxOp);
1192 WRITE_NODE_FIELD(args);
1193 WRITE_LOCATION_FIELD(location);
1197 _outXmlExpr(StringInfo str, XmlExpr *node)
1199 WRITE_NODE_TYPE("XMLEXPR");
1201 WRITE_ENUM_FIELD(op, XmlExprOp);
1202 WRITE_STRING_FIELD(name);
1203 WRITE_NODE_FIELD(named_args);
1204 WRITE_NODE_FIELD(arg_names);
1205 WRITE_NODE_FIELD(args);
1206 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1207 WRITE_OID_FIELD(type);
1208 WRITE_INT_FIELD(typmod);
1209 WRITE_LOCATION_FIELD(location);
1213 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1215 WRITE_NODE_TYPE("NULLIFEXPR");
1217 WRITE_OID_FIELD(opno);
1218 WRITE_OID_FIELD(opfuncid);
1219 WRITE_OID_FIELD(opresulttype);
1220 WRITE_BOOL_FIELD(opretset);
1221 WRITE_NODE_FIELD(args);
1222 WRITE_LOCATION_FIELD(location);
1226 _outNullTest(StringInfo str, NullTest *node)
1228 WRITE_NODE_TYPE("NULLTEST");
1230 WRITE_NODE_FIELD(arg);
1231 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1235 _outBooleanTest(StringInfo str, BooleanTest *node)
1237 WRITE_NODE_TYPE("BOOLEANTEST");
1239 WRITE_NODE_FIELD(arg);
1240 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1244 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1246 WRITE_NODE_TYPE("COERCETODOMAIN");
1248 WRITE_NODE_FIELD(arg);
1249 WRITE_OID_FIELD(resulttype);
1250 WRITE_INT_FIELD(resulttypmod);
1251 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1252 WRITE_LOCATION_FIELD(location);
1256 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1258 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1260 WRITE_OID_FIELD(typeId);
1261 WRITE_INT_FIELD(typeMod);
1262 WRITE_LOCATION_FIELD(location);
1266 _outSetToDefault(StringInfo str, SetToDefault *node)
1268 WRITE_NODE_TYPE("SETTODEFAULT");
1270 WRITE_OID_FIELD(typeId);
1271 WRITE_INT_FIELD(typeMod);
1272 WRITE_LOCATION_FIELD(location);
1276 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1278 WRITE_NODE_TYPE("CURRENTOFEXPR");
1280 WRITE_UINT_FIELD(cvarno);
1281 WRITE_STRING_FIELD(cursor_name);
1282 WRITE_INT_FIELD(cursor_param);
1286 _outTargetEntry(StringInfo str, TargetEntry *node)
1288 WRITE_NODE_TYPE("TARGETENTRY");
1290 WRITE_NODE_FIELD(expr);
1291 WRITE_INT_FIELD(resno);
1292 WRITE_STRING_FIELD(resname);
1293 WRITE_UINT_FIELD(ressortgroupref);
1294 WRITE_OID_FIELD(resorigtbl);
1295 WRITE_INT_FIELD(resorigcol);
1296 WRITE_BOOL_FIELD(resjunk);
1300 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1302 WRITE_NODE_TYPE("RANGETBLREF");
1304 WRITE_INT_FIELD(rtindex);
1308 _outJoinExpr(StringInfo str, JoinExpr *node)
1310 WRITE_NODE_TYPE("JOINEXPR");
1312 WRITE_ENUM_FIELD(jointype, JoinType);
1313 WRITE_BOOL_FIELD(isNatural);
1314 WRITE_NODE_FIELD(larg);
1315 WRITE_NODE_FIELD(rarg);
1316 WRITE_NODE_FIELD(usingClause);
1317 WRITE_NODE_FIELD(quals);
1318 WRITE_NODE_FIELD(alias);
1319 WRITE_INT_FIELD(rtindex);
1323 _outFromExpr(StringInfo str, FromExpr *node)
1325 WRITE_NODE_TYPE("FROMEXPR");
1327 WRITE_NODE_FIELD(fromlist);
1328 WRITE_NODE_FIELD(quals);
1331 /*****************************************************************************
1333 * Stuff from relation.h.
1335 *****************************************************************************/
1338 * print the basic stuff of all nodes that inherit from Path
1340 * Note we do NOT print the parent, else we'd be in infinite recursion
1343 _outPathInfo(StringInfo str, Path *node)
1345 WRITE_ENUM_FIELD(pathtype, NodeTag);
1346 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1347 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1348 WRITE_NODE_FIELD(pathkeys);
1352 * print the basic stuff of all nodes that inherit from JoinPath
1355 _outJoinPathInfo(StringInfo str, JoinPath *node)
1357 _outPathInfo(str, (Path *) node);
1359 WRITE_ENUM_FIELD(jointype, JoinType);
1360 WRITE_NODE_FIELD(outerjoinpath);
1361 WRITE_NODE_FIELD(innerjoinpath);
1362 WRITE_NODE_FIELD(joinrestrictinfo);
1366 _outPath(StringInfo str, Path *node)
1368 WRITE_NODE_TYPE("PATH");
1370 _outPathInfo(str, (Path *) node);
1374 _outIndexPath(StringInfo str, IndexPath *node)
1376 WRITE_NODE_TYPE("INDEXPATH");
1378 _outPathInfo(str, (Path *) node);
1380 WRITE_NODE_FIELD(indexinfo);
1381 WRITE_NODE_FIELD(indexclauses);
1382 WRITE_NODE_FIELD(indexquals);
1383 WRITE_BOOL_FIELD(isjoininner);
1384 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1385 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1386 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1387 WRITE_FLOAT_FIELD(rows, "%.0f");
1391 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1393 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1395 _outPathInfo(str, (Path *) node);
1397 WRITE_NODE_FIELD(bitmapqual);
1398 WRITE_BOOL_FIELD(isjoininner);
1399 WRITE_FLOAT_FIELD(rows, "%.0f");
1403 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1405 WRITE_NODE_TYPE("BITMAPANDPATH");
1407 _outPathInfo(str, (Path *) node);
1409 WRITE_NODE_FIELD(bitmapquals);
1410 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1414 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1416 WRITE_NODE_TYPE("BITMAPORPATH");
1418 _outPathInfo(str, (Path *) node);
1420 WRITE_NODE_FIELD(bitmapquals);
1421 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1425 _outTidPath(StringInfo str, TidPath *node)
1427 WRITE_NODE_TYPE("TIDPATH");
1429 _outPathInfo(str, (Path *) node);
1431 WRITE_NODE_FIELD(tidquals);
1435 _outAppendPath(StringInfo str, AppendPath *node)
1437 WRITE_NODE_TYPE("APPENDPATH");
1439 _outPathInfo(str, (Path *) node);
1441 WRITE_NODE_FIELD(subpaths);
1445 _outResultPath(StringInfo str, ResultPath *node)
1447 WRITE_NODE_TYPE("RESULTPATH");
1449 _outPathInfo(str, (Path *) node);
1451 WRITE_NODE_FIELD(quals);
1455 _outMaterialPath(StringInfo str, MaterialPath *node)
1457 WRITE_NODE_TYPE("MATERIALPATH");
1459 _outPathInfo(str, (Path *) node);
1461 WRITE_NODE_FIELD(subpath);
1465 _outUniquePath(StringInfo str, UniquePath *node)
1467 WRITE_NODE_TYPE("UNIQUEPATH");
1469 _outPathInfo(str, (Path *) node);
1471 WRITE_NODE_FIELD(subpath);
1472 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1473 WRITE_NODE_FIELD(in_operators);
1474 WRITE_NODE_FIELD(uniq_exprs);
1475 WRITE_FLOAT_FIELD(rows, "%.0f");
1479 _outNoOpPath(StringInfo str, NoOpPath *node)
1481 WRITE_NODE_TYPE("NOOPPATH");
1483 _outPathInfo(str, (Path *) node);
1485 WRITE_NODE_FIELD(subpath);
1489 _outNestPath(StringInfo str, NestPath *node)
1491 WRITE_NODE_TYPE("NESTPATH");
1493 _outJoinPathInfo(str, (JoinPath *) node);
1497 _outMergePath(StringInfo str, MergePath *node)
1499 WRITE_NODE_TYPE("MERGEPATH");
1501 _outJoinPathInfo(str, (JoinPath *) node);
1503 WRITE_NODE_FIELD(path_mergeclauses);
1504 WRITE_NODE_FIELD(outersortkeys);
1505 WRITE_NODE_FIELD(innersortkeys);
1506 WRITE_BOOL_FIELD(materialize_inner);
1510 _outHashPath(StringInfo str, HashPath *node)
1512 WRITE_NODE_TYPE("HASHPATH");
1514 _outJoinPathInfo(str, (JoinPath *) node);
1516 WRITE_NODE_FIELD(path_hashclauses);
1517 WRITE_INT_FIELD(num_batches);
1521 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1523 WRITE_NODE_TYPE("PLANNERGLOBAL");
1525 /* NB: this isn't a complete set of fields */
1526 WRITE_NODE_FIELD(paramlist);
1527 WRITE_NODE_FIELD(subplans);
1528 WRITE_NODE_FIELD(subrtables);
1529 WRITE_NODE_FIELD(subrowmarks);
1530 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1531 WRITE_NODE_FIELD(finalrtable);
1532 WRITE_NODE_FIELD(finalrowmarks);
1533 WRITE_NODE_FIELD(relationOids);
1534 WRITE_NODE_FIELD(invalItems);
1535 WRITE_UINT_FIELD(lastPHId);
1536 WRITE_BOOL_FIELD(transientPlan);
1540 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1542 WRITE_NODE_TYPE("PLANNERINFO");
1544 /* NB: this isn't a complete set of fields */
1545 WRITE_NODE_FIELD(parse);
1546 WRITE_NODE_FIELD(glob);
1547 WRITE_UINT_FIELD(query_level);
1548 WRITE_NODE_FIELD(join_rel_list);
1549 WRITE_INT_FIELD(join_cur_level);
1550 WRITE_NODE_FIELD(resultRelations);
1551 WRITE_NODE_FIELD(init_plans);
1552 WRITE_NODE_FIELD(cte_plan_ids);
1553 WRITE_NODE_FIELD(eq_classes);
1554 WRITE_NODE_FIELD(canon_pathkeys);
1555 WRITE_NODE_FIELD(left_join_clauses);
1556 WRITE_NODE_FIELD(right_join_clauses);
1557 WRITE_NODE_FIELD(full_join_clauses);
1558 WRITE_NODE_FIELD(join_info_list);
1559 WRITE_NODE_FIELD(append_rel_list);
1560 WRITE_NODE_FIELD(rowMarks);
1561 WRITE_NODE_FIELD(placeholder_list);
1562 WRITE_NODE_FIELD(query_pathkeys);
1563 WRITE_NODE_FIELD(group_pathkeys);
1564 WRITE_NODE_FIELD(window_pathkeys);
1565 WRITE_NODE_FIELD(distinct_pathkeys);
1566 WRITE_NODE_FIELD(sort_pathkeys);
1567 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1568 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1569 WRITE_BOOL_FIELD(hasJoinRTEs);
1570 WRITE_BOOL_FIELD(hasHavingQual);
1571 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1572 WRITE_BOOL_FIELD(hasRecursion);
1573 WRITE_INT_FIELD(wt_param_id);
1577 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1579 WRITE_NODE_TYPE("RELOPTINFO");
1581 /* NB: this isn't a complete set of fields */
1582 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1583 WRITE_BITMAPSET_FIELD(relids);
1584 WRITE_FLOAT_FIELD(rows, "%.0f");
1585 WRITE_INT_FIELD(width);
1586 WRITE_NODE_FIELD(reltargetlist);
1587 WRITE_NODE_FIELD(pathlist);
1588 WRITE_NODE_FIELD(cheapest_startup_path);
1589 WRITE_NODE_FIELD(cheapest_total_path);
1590 WRITE_NODE_FIELD(cheapest_unique_path);
1591 WRITE_UINT_FIELD(relid);
1592 WRITE_ENUM_FIELD(rtekind, RTEKind);
1593 WRITE_INT_FIELD(min_attr);
1594 WRITE_INT_FIELD(max_attr);
1595 WRITE_NODE_FIELD(indexlist);
1596 WRITE_UINT_FIELD(pages);
1597 WRITE_FLOAT_FIELD(tuples, "%.0f");
1598 WRITE_NODE_FIELD(subplan);
1599 WRITE_NODE_FIELD(subrtable);
1600 WRITE_NODE_FIELD(subrowmark);
1601 WRITE_NODE_FIELD(baserestrictinfo);
1602 WRITE_NODE_FIELD(joininfo);
1603 WRITE_BOOL_FIELD(has_eclass_joins);
1604 WRITE_BITMAPSET_FIELD(index_outer_relids);
1605 WRITE_NODE_FIELD(index_inner_paths);
1609 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1611 WRITE_NODE_TYPE("INDEXOPTINFO");
1613 /* NB: this isn't a complete set of fields */
1614 WRITE_OID_FIELD(indexoid);
1615 /* Do NOT print rel field, else infinite recursion */
1616 WRITE_UINT_FIELD(pages);
1617 WRITE_FLOAT_FIELD(tuples, "%.0f");
1618 WRITE_INT_FIELD(ncolumns);
1619 WRITE_NODE_FIELD(indexprs);
1620 WRITE_NODE_FIELD(indpred);
1621 WRITE_BOOL_FIELD(predOK);
1622 WRITE_BOOL_FIELD(unique);
1626 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1629 * To simplify reading, we just chase up to the topmost merged EC and
1630 * print that, without bothering to show the merge-ees separately.
1632 while (node->ec_merged)
1633 node = node->ec_merged;
1635 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1637 WRITE_NODE_FIELD(ec_opfamilies);
1638 WRITE_NODE_FIELD(ec_members);
1639 WRITE_NODE_FIELD(ec_sources);
1640 WRITE_NODE_FIELD(ec_derives);
1641 WRITE_BITMAPSET_FIELD(ec_relids);
1642 WRITE_BOOL_FIELD(ec_has_const);
1643 WRITE_BOOL_FIELD(ec_has_volatile);
1644 WRITE_BOOL_FIELD(ec_below_outer_join);
1645 WRITE_BOOL_FIELD(ec_broken);
1646 WRITE_UINT_FIELD(ec_sortref);
1650 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1652 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1654 WRITE_NODE_FIELD(em_expr);
1655 WRITE_BITMAPSET_FIELD(em_relids);
1656 WRITE_BOOL_FIELD(em_is_const);
1657 WRITE_BOOL_FIELD(em_is_child);
1658 WRITE_OID_FIELD(em_datatype);
1662 _outPathKey(StringInfo str, PathKey *node)
1664 WRITE_NODE_TYPE("PATHKEY");
1666 WRITE_NODE_FIELD(pk_eclass);
1667 WRITE_OID_FIELD(pk_opfamily);
1668 WRITE_INT_FIELD(pk_strategy);
1669 WRITE_BOOL_FIELD(pk_nulls_first);
1673 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1675 WRITE_NODE_TYPE("RESTRICTINFO");
1677 /* NB: this isn't a complete set of fields */
1678 WRITE_NODE_FIELD(clause);
1679 WRITE_BOOL_FIELD(is_pushed_down);
1680 WRITE_BOOL_FIELD(outerjoin_delayed);
1681 WRITE_BOOL_FIELD(can_join);
1682 WRITE_BOOL_FIELD(pseudoconstant);
1683 WRITE_BITMAPSET_FIELD(clause_relids);
1684 WRITE_BITMAPSET_FIELD(required_relids);
1685 WRITE_BITMAPSET_FIELD(nullable_relids);
1686 WRITE_BITMAPSET_FIELD(left_relids);
1687 WRITE_BITMAPSET_FIELD(right_relids);
1688 WRITE_NODE_FIELD(orclause);
1689 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1690 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1691 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1692 WRITE_NODE_FIELD(mergeopfamilies);
1693 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1694 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1695 WRITE_NODE_FIELD(left_em);
1696 WRITE_NODE_FIELD(right_em);
1697 WRITE_BOOL_FIELD(outer_is_left);
1698 WRITE_OID_FIELD(hashjoinoperator);
1702 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1704 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1705 WRITE_BITMAPSET_FIELD(other_relids);
1706 WRITE_BOOL_FIELD(isouterjoin);
1707 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1708 WRITE_NODE_FIELD(cheapest_total_innerpath);
1712 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1714 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1716 WRITE_NODE_FIELD(phexpr);
1717 WRITE_BITMAPSET_FIELD(phrels);
1718 WRITE_UINT_FIELD(phid);
1719 WRITE_UINT_FIELD(phlevelsup);
1723 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1725 WRITE_NODE_TYPE("SPECIALJOININFO");
1727 WRITE_BITMAPSET_FIELD(min_lefthand);
1728 WRITE_BITMAPSET_FIELD(min_righthand);
1729 WRITE_BITMAPSET_FIELD(syn_lefthand);
1730 WRITE_BITMAPSET_FIELD(syn_righthand);
1731 WRITE_ENUM_FIELD(jointype, JoinType);
1732 WRITE_BOOL_FIELD(lhs_strict);
1733 WRITE_BOOL_FIELD(delay_upper_joins);
1734 WRITE_NODE_FIELD(join_quals);
1738 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1740 WRITE_NODE_TYPE("APPENDRELINFO");
1742 WRITE_UINT_FIELD(parent_relid);
1743 WRITE_UINT_FIELD(child_relid);
1744 WRITE_OID_FIELD(parent_reltype);
1745 WRITE_OID_FIELD(child_reltype);
1746 WRITE_NODE_FIELD(translated_vars);
1747 WRITE_OID_FIELD(parent_reloid);
1751 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1753 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1755 WRITE_UINT_FIELD(phid);
1756 WRITE_NODE_FIELD(ph_var);
1757 WRITE_BITMAPSET_FIELD(ph_eval_at);
1758 WRITE_BITMAPSET_FIELD(ph_needed);
1759 WRITE_INT_FIELD(ph_width);
1763 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1765 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1767 WRITE_NODE_FIELD(item);
1768 WRITE_UINT_FIELD(abslevel);
1771 /*****************************************************************************
1773 * Stuff from parsenodes.h.
1775 *****************************************************************************/
1778 _outCreateStmt(StringInfo str, CreateStmt *node)
1780 WRITE_NODE_TYPE("CREATESTMT");
1782 WRITE_NODE_FIELD(relation);
1783 WRITE_NODE_FIELD(tableElts);
1784 WRITE_NODE_FIELD(inhRelations);
1785 WRITE_NODE_FIELD(constraints);
1786 WRITE_NODE_FIELD(options);
1787 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1788 WRITE_STRING_FIELD(tablespacename);
1792 _outIndexStmt(StringInfo str, IndexStmt *node)
1794 WRITE_NODE_TYPE("INDEXSTMT");
1796 WRITE_STRING_FIELD(idxname);
1797 WRITE_NODE_FIELD(relation);
1798 WRITE_STRING_FIELD(accessMethod);
1799 WRITE_STRING_FIELD(tableSpace);
1800 WRITE_NODE_FIELD(indexParams);
1801 WRITE_NODE_FIELD(options);
1802 WRITE_NODE_FIELD(whereClause);
1803 WRITE_NODE_FIELD(excludeOpNames);
1804 WRITE_BOOL_FIELD(unique);
1805 WRITE_BOOL_FIELD(primary);
1806 WRITE_BOOL_FIELD(isconstraint);
1807 WRITE_BOOL_FIELD(deferrable);
1808 WRITE_BOOL_FIELD(initdeferred);
1809 WRITE_BOOL_FIELD(concurrent);
1813 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1815 WRITE_NODE_TYPE("NOTIFY");
1817 WRITE_STRING_FIELD(conditionname);
1821 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1823 WRITE_NODE_TYPE("DECLARECURSOR");
1825 WRITE_STRING_FIELD(portalname);
1826 WRITE_INT_FIELD(options);
1827 WRITE_NODE_FIELD(query);
1831 _outSelectStmt(StringInfo str, SelectStmt *node)
1833 WRITE_NODE_TYPE("SELECT");
1835 WRITE_NODE_FIELD(distinctClause);
1836 WRITE_NODE_FIELD(intoClause);
1837 WRITE_NODE_FIELD(targetList);
1838 WRITE_NODE_FIELD(fromClause);
1839 WRITE_NODE_FIELD(whereClause);
1840 WRITE_NODE_FIELD(groupClause);
1841 WRITE_NODE_FIELD(havingClause);
1842 WRITE_NODE_FIELD(windowClause);
1843 WRITE_NODE_FIELD(withClause);
1844 WRITE_NODE_FIELD(valuesLists);
1845 WRITE_NODE_FIELD(sortClause);
1846 WRITE_NODE_FIELD(limitOffset);
1847 WRITE_NODE_FIELD(limitCount);
1848 WRITE_NODE_FIELD(lockingClause);
1849 WRITE_ENUM_FIELD(op, SetOperation);
1850 WRITE_BOOL_FIELD(all);
1851 WRITE_NODE_FIELD(larg);
1852 WRITE_NODE_FIELD(rarg);
1856 _outFuncCall(StringInfo str, FuncCall *node)
1858 WRITE_NODE_TYPE("FUNCCALL");
1860 WRITE_NODE_FIELD(funcname);
1861 WRITE_NODE_FIELD(args);
1862 WRITE_NODE_FIELD(agg_order);
1863 WRITE_BOOL_FIELD(agg_star);
1864 WRITE_BOOL_FIELD(agg_distinct);
1865 WRITE_BOOL_FIELD(func_variadic);
1866 WRITE_NODE_FIELD(over);
1867 WRITE_LOCATION_FIELD(location);
1871 _outDefElem(StringInfo str, DefElem *node)
1873 WRITE_NODE_TYPE("DEFELEM");
1875 WRITE_STRING_FIELD(defnamespace);
1876 WRITE_STRING_FIELD(defname);
1877 WRITE_NODE_FIELD(arg);
1878 WRITE_ENUM_FIELD(defaction, DefElemAction);
1882 _outLockingClause(StringInfo str, LockingClause *node)
1884 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1886 WRITE_NODE_FIELD(lockedRels);
1887 WRITE_BOOL_FIELD(forUpdate);
1888 WRITE_BOOL_FIELD(noWait);
1892 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1894 WRITE_NODE_TYPE("XMLSERIALIZE");
1896 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1897 WRITE_NODE_FIELD(expr);
1898 WRITE_NODE_FIELD(typeName);
1899 WRITE_LOCATION_FIELD(location);
1903 _outColumnDef(StringInfo str, ColumnDef *node)
1905 WRITE_NODE_TYPE("COLUMNDEF");
1907 WRITE_STRING_FIELD(colname);
1908 WRITE_NODE_FIELD(typeName);
1909 WRITE_INT_FIELD(inhcount);
1910 WRITE_BOOL_FIELD(is_local);
1911 WRITE_BOOL_FIELD(is_not_null);
1912 WRITE_INT_FIELD(storage);
1913 WRITE_NODE_FIELD(raw_default);
1914 WRITE_NODE_FIELD(cooked_default);
1915 WRITE_NODE_FIELD(constraints);
1919 _outTypeName(StringInfo str, TypeName *node)
1921 WRITE_NODE_TYPE("TYPENAME");
1923 WRITE_NODE_FIELD(names);
1924 WRITE_OID_FIELD(typeOid);
1925 WRITE_BOOL_FIELD(setof);
1926 WRITE_BOOL_FIELD(pct_type);
1927 WRITE_NODE_FIELD(typmods);
1928 WRITE_INT_FIELD(typemod);
1929 WRITE_NODE_FIELD(arrayBounds);
1930 WRITE_LOCATION_FIELD(location);
1934 _outTypeCast(StringInfo str, TypeCast *node)
1936 WRITE_NODE_TYPE("TYPECAST");
1938 WRITE_NODE_FIELD(arg);
1939 WRITE_NODE_FIELD(typeName);
1940 WRITE_LOCATION_FIELD(location);
1944 _outIndexElem(StringInfo str, IndexElem *node)
1946 WRITE_NODE_TYPE("INDEXELEM");
1948 WRITE_STRING_FIELD(name);
1949 WRITE_NODE_FIELD(expr);
1950 WRITE_STRING_FIELD(indexcolname);
1951 WRITE_NODE_FIELD(opclass);
1952 WRITE_ENUM_FIELD(ordering, SortByDir);
1953 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1957 _outQuery(StringInfo str, Query *node)
1959 WRITE_NODE_TYPE("QUERY");
1961 WRITE_ENUM_FIELD(commandType, CmdType);
1962 WRITE_ENUM_FIELD(querySource, QuerySource);
1963 WRITE_BOOL_FIELD(canSetTag);
1966 * Hack to work around missing outfuncs routines for a lot of the
1967 * utility-statement node types. (The only one we actually *need* for
1968 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1969 * for the meantime do this to avoid getting lots of warnings when running
1970 * with debug_print_parse on.
1972 if (node->utilityStmt)
1974 switch (nodeTag(node->utilityStmt))
1979 case T_DeclareCursorStmt:
1980 WRITE_NODE_FIELD(utilityStmt);
1983 appendStringInfo(str, " :utilityStmt ?");
1988 appendStringInfo(str, " :utilityStmt <>");
1990 WRITE_INT_FIELD(resultRelation);
1991 WRITE_NODE_FIELD(intoClause);
1992 WRITE_BOOL_FIELD(hasAggs);
1993 WRITE_BOOL_FIELD(hasWindowFuncs);
1994 WRITE_BOOL_FIELD(hasSubLinks);
1995 WRITE_BOOL_FIELD(hasDistinctOn);
1996 WRITE_BOOL_FIELD(hasRecursive);
1997 WRITE_BOOL_FIELD(hasForUpdate);
1998 WRITE_NODE_FIELD(cteList);
1999 WRITE_NODE_FIELD(rtable);
2000 WRITE_NODE_FIELD(jointree);
2001 WRITE_NODE_FIELD(targetList);
2002 WRITE_NODE_FIELD(returningList);
2003 WRITE_NODE_FIELD(groupClause);
2004 WRITE_NODE_FIELD(havingQual);
2005 WRITE_NODE_FIELD(windowClause);
2006 WRITE_NODE_FIELD(distinctClause);
2007 WRITE_NODE_FIELD(sortClause);
2008 WRITE_NODE_FIELD(limitOffset);
2009 WRITE_NODE_FIELD(limitCount);
2010 WRITE_NODE_FIELD(rowMarks);
2011 WRITE_NODE_FIELD(setOperations);
2015 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2017 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2019 WRITE_UINT_FIELD(tleSortGroupRef);
2020 WRITE_OID_FIELD(eqop);
2021 WRITE_OID_FIELD(sortop);
2022 WRITE_BOOL_FIELD(nulls_first);
2026 _outWindowClause(StringInfo str, WindowClause *node)
2028 WRITE_NODE_TYPE("WINDOWCLAUSE");
2030 WRITE_STRING_FIELD(name);
2031 WRITE_STRING_FIELD(refname);
2032 WRITE_NODE_FIELD(partitionClause);
2033 WRITE_NODE_FIELD(orderClause);
2034 WRITE_INT_FIELD(frameOptions);
2035 WRITE_UINT_FIELD(winref);
2036 WRITE_BOOL_FIELD(copiedOrder);
2040 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2042 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2044 WRITE_UINT_FIELD(rti);
2045 WRITE_BOOL_FIELD(forUpdate);
2046 WRITE_BOOL_FIELD(noWait);
2047 WRITE_BOOL_FIELD(pushedDown);
2051 _outWithClause(StringInfo str, WithClause *node)
2053 WRITE_NODE_TYPE("WITHCLAUSE");
2055 WRITE_NODE_FIELD(ctes);
2056 WRITE_BOOL_FIELD(recursive);
2057 WRITE_LOCATION_FIELD(location);
2061 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2063 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2065 WRITE_STRING_FIELD(ctename);
2066 WRITE_NODE_FIELD(aliascolnames);
2067 WRITE_NODE_FIELD(ctequery);
2068 WRITE_LOCATION_FIELD(location);
2069 WRITE_BOOL_FIELD(cterecursive);
2070 WRITE_INT_FIELD(cterefcount);
2071 WRITE_NODE_FIELD(ctecolnames);
2072 WRITE_NODE_FIELD(ctecoltypes);
2073 WRITE_NODE_FIELD(ctecoltypmods);
2077 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2079 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2081 WRITE_ENUM_FIELD(op, SetOperation);
2082 WRITE_BOOL_FIELD(all);
2083 WRITE_NODE_FIELD(larg);
2084 WRITE_NODE_FIELD(rarg);
2085 WRITE_NODE_FIELD(colTypes);
2086 WRITE_NODE_FIELD(colTypmods);
2087 WRITE_NODE_FIELD(groupClauses);
2091 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2093 WRITE_NODE_TYPE("RTE");
2095 /* put alias + eref first to make dump more legible */
2096 WRITE_NODE_FIELD(alias);
2097 WRITE_NODE_FIELD(eref);
2098 WRITE_ENUM_FIELD(rtekind, RTEKind);
2100 switch (node->rtekind)
2104 WRITE_OID_FIELD(relid);
2107 WRITE_NODE_FIELD(subquery);
2110 WRITE_ENUM_FIELD(jointype, JoinType);
2111 WRITE_NODE_FIELD(joinaliasvars);
2114 WRITE_NODE_FIELD(funcexpr);
2115 WRITE_NODE_FIELD(funccoltypes);
2116 WRITE_NODE_FIELD(funccoltypmods);
2119 WRITE_NODE_FIELD(values_lists);
2122 WRITE_STRING_FIELD(ctename);
2123 WRITE_UINT_FIELD(ctelevelsup);
2124 WRITE_BOOL_FIELD(self_reference);
2125 WRITE_NODE_FIELD(ctecoltypes);
2126 WRITE_NODE_FIELD(ctecoltypmods);
2129 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2133 WRITE_BOOL_FIELD(inh);
2134 WRITE_BOOL_FIELD(inFromCl);
2135 WRITE_UINT_FIELD(requiredPerms);
2136 WRITE_OID_FIELD(checkAsUser);
2137 WRITE_BITMAPSET_FIELD(selectedCols);
2138 WRITE_BITMAPSET_FIELD(modifiedCols);
2142 _outAExpr(StringInfo str, A_Expr *node)
2144 WRITE_NODE_TYPE("AEXPR");
2149 appendStringInfo(str, " ");
2150 WRITE_NODE_FIELD(name);
2153 appendStringInfo(str, " AND");
2156 appendStringInfo(str, " OR");
2159 appendStringInfo(str, " NOT");
2162 appendStringInfo(str, " ");
2163 WRITE_NODE_FIELD(name);
2164 appendStringInfo(str, " ANY ");
2167 appendStringInfo(str, " ");
2168 WRITE_NODE_FIELD(name);
2169 appendStringInfo(str, " ALL ");
2171 case AEXPR_DISTINCT:
2172 appendStringInfo(str, " DISTINCT ");
2173 WRITE_NODE_FIELD(name);
2176 appendStringInfo(str, " NULLIF ");
2177 WRITE_NODE_FIELD(name);
2180 appendStringInfo(str, " OF ");
2181 WRITE_NODE_FIELD(name);
2184 appendStringInfo(str, " IN ");
2185 WRITE_NODE_FIELD(name);
2188 appendStringInfo(str, " ??");
2192 WRITE_NODE_FIELD(lexpr);
2193 WRITE_NODE_FIELD(rexpr);
2194 WRITE_LOCATION_FIELD(location);
2198 _outValue(StringInfo str, Value *value)
2200 switch (value->type)
2203 appendStringInfo(str, "%ld", value->val.ival);
2208 * We assume the value is a valid numeric literal and so does not
2211 appendStringInfoString(str, value->val.str);
2214 appendStringInfoChar(str, '"');
2215 _outToken(str, value->val.str);
2216 appendStringInfoChar(str, '"');
2219 /* internal representation already has leading 'b' */
2220 appendStringInfoString(str, value->val.str);
2223 /* this is seen only within A_Const, not in transformed trees */
2224 appendStringInfoString(str, "NULL");
2227 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2233 _outColumnRef(StringInfo str, ColumnRef *node)
2235 WRITE_NODE_TYPE("COLUMNREF");
2237 WRITE_NODE_FIELD(fields);
2238 WRITE_LOCATION_FIELD(location);
2242 _outParamRef(StringInfo str, ParamRef *node)
2244 WRITE_NODE_TYPE("PARAMREF");
2246 WRITE_INT_FIELD(number);
2247 WRITE_LOCATION_FIELD(location);
2251 _outAConst(StringInfo str, A_Const *node)
2253 WRITE_NODE_TYPE("A_CONST");
2255 appendStringInfo(str, " :val ");
2256 _outValue(str, &(node->val));
2257 WRITE_LOCATION_FIELD(location);
2261 _outA_Star(StringInfo str, A_Star *node)
2263 WRITE_NODE_TYPE("A_STAR");
2267 _outA_Indices(StringInfo str, A_Indices *node)
2269 WRITE_NODE_TYPE("A_INDICES");
2271 WRITE_NODE_FIELD(lidx);
2272 WRITE_NODE_FIELD(uidx);
2276 _outA_Indirection(StringInfo str, A_Indirection *node)
2278 WRITE_NODE_TYPE("A_INDIRECTION");
2280 WRITE_NODE_FIELD(arg);
2281 WRITE_NODE_FIELD(indirection);
2285 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2287 WRITE_NODE_TYPE("A_ARRAYEXPR");
2289 WRITE_NODE_FIELD(elements);
2290 WRITE_LOCATION_FIELD(location);
2294 _outResTarget(StringInfo str, ResTarget *node)
2296 WRITE_NODE_TYPE("RESTARGET");
2298 WRITE_STRING_FIELD(name);
2299 WRITE_NODE_FIELD(indirection);
2300 WRITE_NODE_FIELD(val);
2301 WRITE_LOCATION_FIELD(location);
2305 _outSortBy(StringInfo str, SortBy *node)
2307 WRITE_NODE_TYPE("SORTBY");
2309 WRITE_NODE_FIELD(node);
2310 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2311 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2312 WRITE_NODE_FIELD(useOp);
2313 WRITE_LOCATION_FIELD(location);
2317 _outWindowDef(StringInfo str, WindowDef *node)
2319 WRITE_NODE_TYPE("WINDOWDEF");
2321 WRITE_STRING_FIELD(name);
2322 WRITE_STRING_FIELD(refname);
2323 WRITE_NODE_FIELD(partitionClause);
2324 WRITE_NODE_FIELD(orderClause);
2325 WRITE_INT_FIELD(frameOptions);
2326 WRITE_LOCATION_FIELD(location);
2330 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2332 WRITE_NODE_TYPE("RANGESUBSELECT");
2334 WRITE_NODE_FIELD(subquery);
2335 WRITE_NODE_FIELD(alias);
2339 _outRangeFunction(StringInfo str, RangeFunction *node)
2341 WRITE_NODE_TYPE("RANGEFUNCTION");
2343 WRITE_NODE_FIELD(funccallnode);
2344 WRITE_NODE_FIELD(alias);
2345 WRITE_NODE_FIELD(coldeflist);
2349 _outConstraint(StringInfo str, Constraint *node)
2351 WRITE_NODE_TYPE("CONSTRAINT");
2353 WRITE_STRING_FIELD(conname);
2354 WRITE_BOOL_FIELD(deferrable);
2355 WRITE_BOOL_FIELD(initdeferred);
2356 WRITE_LOCATION_FIELD(location);
2358 appendStringInfo(str, " :contype ");
2359 switch (node->contype)
2362 appendStringInfo(str, "NULL");
2365 case CONSTR_NOTNULL:
2366 appendStringInfo(str, "NOT_NULL");
2369 case CONSTR_DEFAULT:
2370 appendStringInfo(str, "DEFAULT");
2371 WRITE_NODE_FIELD(raw_expr);
2372 WRITE_STRING_FIELD(cooked_expr);
2376 appendStringInfo(str, "CHECK");
2377 WRITE_NODE_FIELD(raw_expr);
2378 WRITE_STRING_FIELD(cooked_expr);
2381 case CONSTR_PRIMARY:
2382 appendStringInfo(str, "PRIMARY_KEY");
2383 WRITE_NODE_FIELD(keys);
2384 WRITE_NODE_FIELD(options);
2385 WRITE_STRING_FIELD(indexspace);
2386 /* access_method and where_clause not currently used */
2390 appendStringInfo(str, "UNIQUE");
2391 WRITE_NODE_FIELD(keys);
2392 WRITE_NODE_FIELD(options);
2393 WRITE_STRING_FIELD(indexspace);
2394 /* access_method and where_clause not currently used */
2397 case CONSTR_EXCLUSION:
2398 appendStringInfo(str, "EXCLUSION");
2399 WRITE_NODE_FIELD(exclusions);
2400 WRITE_NODE_FIELD(options);
2401 WRITE_STRING_FIELD(indexspace);
2402 WRITE_STRING_FIELD(access_method);
2403 WRITE_NODE_FIELD(where_clause);
2406 case CONSTR_FOREIGN:
2407 appendStringInfo(str, "FOREIGN_KEY");
2408 WRITE_NODE_FIELD(pktable);
2409 WRITE_NODE_FIELD(fk_attrs);
2410 WRITE_NODE_FIELD(pk_attrs);
2411 WRITE_CHAR_FIELD(fk_matchtype);
2412 WRITE_CHAR_FIELD(fk_upd_action);
2413 WRITE_CHAR_FIELD(fk_del_action);
2414 WRITE_BOOL_FIELD(skip_validation);
2417 case CONSTR_ATTR_DEFERRABLE:
2418 appendStringInfo(str, "ATTR_DEFERRABLE");
2421 case CONSTR_ATTR_NOT_DEFERRABLE:
2422 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2425 case CONSTR_ATTR_DEFERRED:
2426 appendStringInfo(str, "ATTR_DEFERRED");
2429 case CONSTR_ATTR_IMMEDIATE:
2430 appendStringInfo(str, "ATTR_IMMEDIATE");
2434 appendStringInfo(str, "<unrecognized_constraint %d>",
2435 (int) node->contype);
2443 * converts a Node into ascii string and append it to 'str'
2446 _outNode(StringInfo str, void *obj)
2449 appendStringInfo(str, "<>");
2450 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2452 else if (IsA(obj, Integer) ||
2455 IsA(obj, BitString))
2457 /* nodeRead does not want to see { } around these! */
2458 _outValue(str, obj);
2462 appendStringInfoChar(str, '{');
2463 switch (nodeTag(obj))
2466 _outPlannedStmt(str, obj);
2472 _outResult(str, obj);
2475 _outModifyTable(str, obj);
2478 _outAppend(str, obj);
2480 case T_RecursiveUnion:
2481 _outRecursiveUnion(str, obj);
2484 _outBitmapAnd(str, obj);
2487 _outBitmapOr(str, obj);
2493 _outSeqScan(str, obj);
2496 _outIndexScan(str, obj);
2498 case T_BitmapIndexScan:
2499 _outBitmapIndexScan(str, obj);
2501 case T_BitmapHeapScan:
2502 _outBitmapHeapScan(str, obj);
2505 _outTidScan(str, obj);
2507 case T_SubqueryScan:
2508 _outSubqueryScan(str, obj);
2510 case T_FunctionScan:
2511 _outFunctionScan(str, obj);
2514 _outValuesScan(str, obj);
2517 _outCteScan(str, obj);
2519 case T_WorkTableScan:
2520 _outWorkTableScan(str, obj);
2526 _outNestLoop(str, obj);
2529 _outMergeJoin(str, obj);
2532 _outHashJoin(str, obj);
2538 _outWindowAgg(str, obj);
2541 _outGroup(str, obj);
2544 _outMaterial(str, obj);
2550 _outUnique(str, obj);
2556 _outSetOp(str, obj);
2559 _outLockRows(str, obj);
2562 _outLimit(str, obj);
2565 _outPlanRowMark(str, obj);
2567 case T_PlanInvalItem:
2568 _outPlanInvalItem(str, obj);
2571 _outAlias(str, obj);
2574 _outRangeVar(str, obj);
2577 _outIntoClause(str, obj);
2583 _outConst(str, obj);
2586 _outParam(str, obj);
2589 _outAggref(str, obj);
2592 _outWindowFunc(str, obj);
2595 _outArrayRef(str, obj);
2598 _outFuncExpr(str, obj);
2600 case T_NamedArgExpr:
2601 _outNamedArgExpr(str, obj);
2604 _outOpExpr(str, obj);
2606 case T_DistinctExpr:
2607 _outDistinctExpr(str, obj);
2609 case T_ScalarArrayOpExpr:
2610 _outScalarArrayOpExpr(str, obj);
2613 _outBoolExpr(str, obj);
2616 _outSubLink(str, obj);
2619 _outSubPlan(str, obj);
2621 case T_AlternativeSubPlan:
2622 _outAlternativeSubPlan(str, obj);
2625 _outFieldSelect(str, obj);
2628 _outFieldStore(str, obj);
2631 _outRelabelType(str, obj);
2634 _outCoerceViaIO(str, obj);
2636 case T_ArrayCoerceExpr:
2637 _outArrayCoerceExpr(str, obj);
2639 case T_ConvertRowtypeExpr:
2640 _outConvertRowtypeExpr(str, obj);
2643 _outCaseExpr(str, obj);
2646 _outCaseWhen(str, obj);
2648 case T_CaseTestExpr:
2649 _outCaseTestExpr(str, obj);
2652 _outArrayExpr(str, obj);
2655 _outRowExpr(str, obj);
2657 case T_RowCompareExpr:
2658 _outRowCompareExpr(str, obj);
2660 case T_CoalesceExpr:
2661 _outCoalesceExpr(str, obj);
2664 _outMinMaxExpr(str, obj);
2667 _outXmlExpr(str, obj);
2670 _outNullIfExpr(str, obj);
2673 _outNullTest(str, obj);
2676 _outBooleanTest(str, obj);
2678 case T_CoerceToDomain:
2679 _outCoerceToDomain(str, obj);
2681 case T_CoerceToDomainValue:
2682 _outCoerceToDomainValue(str, obj);
2684 case T_SetToDefault:
2685 _outSetToDefault(str, obj);
2687 case T_CurrentOfExpr:
2688 _outCurrentOfExpr(str, obj);
2691 _outTargetEntry(str, obj);
2694 _outRangeTblRef(str, obj);
2697 _outJoinExpr(str, obj);
2700 _outFromExpr(str, obj);
2707 _outIndexPath(str, obj);
2709 case T_BitmapHeapPath:
2710 _outBitmapHeapPath(str, obj);
2712 case T_BitmapAndPath:
2713 _outBitmapAndPath(str, obj);
2715 case T_BitmapOrPath:
2716 _outBitmapOrPath(str, obj);
2719 _outTidPath(str, obj);
2722 _outAppendPath(str, obj);
2725 _outResultPath(str, obj);
2727 case T_MaterialPath:
2728 _outMaterialPath(str, obj);
2731 _outUniquePath(str, obj);
2734 _outNoOpPath(str, obj);
2737 _outNestPath(str, obj);
2740 _outMergePath(str, obj);
2743 _outHashPath(str, obj);
2745 case T_PlannerGlobal:
2746 _outPlannerGlobal(str, obj);
2749 _outPlannerInfo(str, obj);
2752 _outRelOptInfo(str, obj);
2754 case T_IndexOptInfo:
2755 _outIndexOptInfo(str, obj);
2757 case T_EquivalenceClass:
2758 _outEquivalenceClass(str, obj);
2760 case T_EquivalenceMember:
2761 _outEquivalenceMember(str, obj);
2764 _outPathKey(str, obj);
2766 case T_RestrictInfo:
2767 _outRestrictInfo(str, obj);
2769 case T_InnerIndexscanInfo:
2770 _outInnerIndexscanInfo(str, obj);
2772 case T_PlaceHolderVar:
2773 _outPlaceHolderVar(str, obj);
2775 case T_SpecialJoinInfo:
2776 _outSpecialJoinInfo(str, obj);
2778 case T_AppendRelInfo:
2779 _outAppendRelInfo(str, obj);
2781 case T_PlaceHolderInfo:
2782 _outPlaceHolderInfo(str, obj);
2784 case T_PlannerParamItem:
2785 _outPlannerParamItem(str, obj);
2789 _outCreateStmt(str, obj);
2792 _outIndexStmt(str, obj);
2795 _outNotifyStmt(str, obj);
2797 case T_DeclareCursorStmt:
2798 _outDeclareCursorStmt(str, obj);
2801 _outSelectStmt(str, obj);
2804 _outColumnDef(str, obj);
2807 _outTypeName(str, obj);
2810 _outTypeCast(str, obj);
2813 _outIndexElem(str, obj);
2816 _outQuery(str, obj);
2818 case T_SortGroupClause:
2819 _outSortGroupClause(str, obj);
2821 case T_WindowClause:
2822 _outWindowClause(str, obj);
2824 case T_RowMarkClause:
2825 _outRowMarkClause(str, obj);
2828 _outWithClause(str, obj);
2830 case T_CommonTableExpr:
2831 _outCommonTableExpr(str, obj);
2833 case T_SetOperationStmt:
2834 _outSetOperationStmt(str, obj);
2836 case T_RangeTblEntry:
2837 _outRangeTblEntry(str, obj);
2840 _outAExpr(str, obj);
2843 _outColumnRef(str, obj);
2846 _outParamRef(str, obj);
2849 _outAConst(str, obj);
2852 _outA_Star(str, obj);
2855 _outA_Indices(str, obj);
2857 case T_A_Indirection:
2858 _outA_Indirection(str, obj);
2861 _outA_ArrayExpr(str, obj);
2864 _outResTarget(str, obj);
2867 _outSortBy(str, obj);
2870 _outWindowDef(str, obj);
2872 case T_RangeSubselect:
2873 _outRangeSubselect(str, obj);
2875 case T_RangeFunction:
2876 _outRangeFunction(str, obj);
2879 _outConstraint(str, obj);
2882 _outFuncCall(str, obj);
2885 _outDefElem(str, obj);
2887 case T_LockingClause:
2888 _outLockingClause(str, obj);
2890 case T_XmlSerialize:
2891 _outXmlSerialize(str, obj);
2897 * This should be an ERROR, but it's too useful to be able to
2898 * dump structures that _outNode only understands part of.
2900 elog(WARNING, "could not dump unrecognized node type: %d",
2901 (int) nodeTag(obj));
2904 appendStringInfoChar(str, '}');
2910 * returns the ascii representation of the Node as a palloc'd string
2913 nodeToString(void *obj)
2917 /* see stringinfo.h for an explanation of this maneuver */
2918 initStringInfo(&str);
2919 _outNode(&str, obj);