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.375 2009/12/15 17:57:46 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_OID_FIELD(skewColType);
697 WRITE_INT_FIELD(skewColTypmod);
701 _outSetOp(StringInfo str, SetOp *node)
705 WRITE_NODE_TYPE("SETOP");
707 _outPlanInfo(str, (Plan *) node);
709 WRITE_ENUM_FIELD(cmd, SetOpCmd);
710 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
711 WRITE_INT_FIELD(numCols);
713 appendStringInfo(str, " :dupColIdx");
714 for (i = 0; i < node->numCols; i++)
715 appendStringInfo(str, " %d", node->dupColIdx[i]);
717 appendStringInfo(str, " :dupOperators");
718 for (i = 0; i < node->numCols; i++)
719 appendStringInfo(str, " %u", node->dupOperators[i]);
721 WRITE_INT_FIELD(flagColIdx);
722 WRITE_INT_FIELD(firstFlag);
723 WRITE_LONG_FIELD(numGroups);
727 _outLockRows(StringInfo str, LockRows *node)
729 WRITE_NODE_TYPE("LOCKROWS");
731 _outPlanInfo(str, (Plan *) node);
733 WRITE_NODE_FIELD(rowMarks);
734 WRITE_INT_FIELD(epqParam);
738 _outLimit(StringInfo str, Limit *node)
740 WRITE_NODE_TYPE("LIMIT");
742 _outPlanInfo(str, (Plan *) node);
744 WRITE_NODE_FIELD(limitOffset);
745 WRITE_NODE_FIELD(limitCount);
749 _outPlanRowMark(StringInfo str, PlanRowMark *node)
751 WRITE_NODE_TYPE("PLANROWMARK");
753 WRITE_UINT_FIELD(rti);
754 WRITE_UINT_FIELD(prti);
755 WRITE_ENUM_FIELD(markType, RowMarkType);
756 WRITE_BOOL_FIELD(noWait);
757 WRITE_BOOL_FIELD(isParent);
758 WRITE_INT_FIELD(ctidAttNo);
759 WRITE_INT_FIELD(toidAttNo);
760 WRITE_INT_FIELD(wholeAttNo);
764 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
766 WRITE_NODE_TYPE("PLANINVALITEM");
768 WRITE_INT_FIELD(cacheId);
769 appendStringInfo(str, " :tupleId (%u,%u)",
770 ItemPointerGetBlockNumber(&node->tupleId),
771 ItemPointerGetOffsetNumber(&node->tupleId));
774 /*****************************************************************************
776 * Stuff from primnodes.h.
778 *****************************************************************************/
781 _outAlias(StringInfo str, Alias *node)
783 WRITE_NODE_TYPE("ALIAS");
785 WRITE_STRING_FIELD(aliasname);
786 WRITE_NODE_FIELD(colnames);
790 _outRangeVar(StringInfo str, RangeVar *node)
792 WRITE_NODE_TYPE("RANGEVAR");
795 * we deliberately ignore catalogname here, since it is presently not
796 * semantically meaningful
798 WRITE_STRING_FIELD(schemaname);
799 WRITE_STRING_FIELD(relname);
800 WRITE_ENUM_FIELD(inhOpt, InhOption);
801 WRITE_BOOL_FIELD(istemp);
802 WRITE_NODE_FIELD(alias);
803 WRITE_LOCATION_FIELD(location);
807 _outIntoClause(StringInfo str, IntoClause *node)
809 WRITE_NODE_TYPE("INTOCLAUSE");
811 WRITE_NODE_FIELD(rel);
812 WRITE_NODE_FIELD(colNames);
813 WRITE_NODE_FIELD(options);
814 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
815 WRITE_STRING_FIELD(tableSpaceName);
819 _outVar(StringInfo str, Var *node)
821 WRITE_NODE_TYPE("VAR");
823 WRITE_UINT_FIELD(varno);
824 WRITE_INT_FIELD(varattno);
825 WRITE_OID_FIELD(vartype);
826 WRITE_INT_FIELD(vartypmod);
827 WRITE_UINT_FIELD(varlevelsup);
828 WRITE_UINT_FIELD(varnoold);
829 WRITE_INT_FIELD(varoattno);
830 WRITE_LOCATION_FIELD(location);
834 _outConst(StringInfo str, Const *node)
836 WRITE_NODE_TYPE("CONST");
838 WRITE_OID_FIELD(consttype);
839 WRITE_INT_FIELD(consttypmod);
840 WRITE_INT_FIELD(constlen);
841 WRITE_BOOL_FIELD(constbyval);
842 WRITE_BOOL_FIELD(constisnull);
843 WRITE_LOCATION_FIELD(location);
845 appendStringInfo(str, " :constvalue ");
846 if (node->constisnull)
847 appendStringInfo(str, "<>");
849 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
853 _outParam(StringInfo str, Param *node)
855 WRITE_NODE_TYPE("PARAM");
857 WRITE_ENUM_FIELD(paramkind, ParamKind);
858 WRITE_INT_FIELD(paramid);
859 WRITE_OID_FIELD(paramtype);
860 WRITE_INT_FIELD(paramtypmod);
861 WRITE_LOCATION_FIELD(location);
865 _outAggref(StringInfo str, Aggref *node)
867 WRITE_NODE_TYPE("AGGREF");
869 WRITE_OID_FIELD(aggfnoid);
870 WRITE_OID_FIELD(aggtype);
871 WRITE_NODE_FIELD(args);
872 WRITE_NODE_FIELD(aggorder);
873 WRITE_NODE_FIELD(aggdistinct);
874 WRITE_BOOL_FIELD(aggstar);
875 WRITE_UINT_FIELD(agglevelsup);
876 WRITE_LOCATION_FIELD(location);
880 _outWindowFunc(StringInfo str, WindowFunc *node)
882 WRITE_NODE_TYPE("WINDOWFUNC");
884 WRITE_OID_FIELD(winfnoid);
885 WRITE_OID_FIELD(wintype);
886 WRITE_NODE_FIELD(args);
887 WRITE_UINT_FIELD(winref);
888 WRITE_BOOL_FIELD(winstar);
889 WRITE_BOOL_FIELD(winagg);
890 WRITE_LOCATION_FIELD(location);
894 _outArrayRef(StringInfo str, ArrayRef *node)
896 WRITE_NODE_TYPE("ARRAYREF");
898 WRITE_OID_FIELD(refarraytype);
899 WRITE_OID_FIELD(refelemtype);
900 WRITE_INT_FIELD(reftypmod);
901 WRITE_NODE_FIELD(refupperindexpr);
902 WRITE_NODE_FIELD(reflowerindexpr);
903 WRITE_NODE_FIELD(refexpr);
904 WRITE_NODE_FIELD(refassgnexpr);
908 _outFuncExpr(StringInfo str, FuncExpr *node)
910 WRITE_NODE_TYPE("FUNCEXPR");
912 WRITE_OID_FIELD(funcid);
913 WRITE_OID_FIELD(funcresulttype);
914 WRITE_BOOL_FIELD(funcretset);
915 WRITE_ENUM_FIELD(funcformat, CoercionForm);
916 WRITE_NODE_FIELD(args);
917 WRITE_LOCATION_FIELD(location);
921 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
923 WRITE_NODE_TYPE("NAMEDARGEXPR");
925 WRITE_NODE_FIELD(arg);
926 WRITE_STRING_FIELD(name);
927 WRITE_INT_FIELD(argnumber);
928 WRITE_LOCATION_FIELD(location);
932 _outOpExpr(StringInfo str, OpExpr *node)
934 WRITE_NODE_TYPE("OPEXPR");
936 WRITE_OID_FIELD(opno);
937 WRITE_OID_FIELD(opfuncid);
938 WRITE_OID_FIELD(opresulttype);
939 WRITE_BOOL_FIELD(opretset);
940 WRITE_NODE_FIELD(args);
941 WRITE_LOCATION_FIELD(location);
945 _outDistinctExpr(StringInfo str, DistinctExpr *node)
947 WRITE_NODE_TYPE("DISTINCTEXPR");
949 WRITE_OID_FIELD(opno);
950 WRITE_OID_FIELD(opfuncid);
951 WRITE_OID_FIELD(opresulttype);
952 WRITE_BOOL_FIELD(opretset);
953 WRITE_NODE_FIELD(args);
954 WRITE_LOCATION_FIELD(location);
958 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
960 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
962 WRITE_OID_FIELD(opno);
963 WRITE_OID_FIELD(opfuncid);
964 WRITE_BOOL_FIELD(useOr);
965 WRITE_NODE_FIELD(args);
966 WRITE_LOCATION_FIELD(location);
970 _outBoolExpr(StringInfo str, BoolExpr *node)
974 WRITE_NODE_TYPE("BOOLEXPR");
976 /* do-it-yourself enum representation */
977 switch (node->boolop)
989 appendStringInfo(str, " :boolop ");
990 _outToken(str, opstr);
992 WRITE_NODE_FIELD(args);
993 WRITE_LOCATION_FIELD(location);
997 _outSubLink(StringInfo str, SubLink *node)
999 WRITE_NODE_TYPE("SUBLINK");
1001 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1002 WRITE_NODE_FIELD(testexpr);
1003 WRITE_NODE_FIELD(operName);
1004 WRITE_NODE_FIELD(subselect);
1005 WRITE_LOCATION_FIELD(location);
1009 _outSubPlan(StringInfo str, SubPlan *node)
1011 WRITE_NODE_TYPE("SUBPLAN");
1013 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1014 WRITE_NODE_FIELD(testexpr);
1015 WRITE_NODE_FIELD(paramIds);
1016 WRITE_INT_FIELD(plan_id);
1017 WRITE_STRING_FIELD(plan_name);
1018 WRITE_OID_FIELD(firstColType);
1019 WRITE_INT_FIELD(firstColTypmod);
1020 WRITE_BOOL_FIELD(useHashTable);
1021 WRITE_BOOL_FIELD(unknownEqFalse);
1022 WRITE_NODE_FIELD(setParam);
1023 WRITE_NODE_FIELD(parParam);
1024 WRITE_NODE_FIELD(args);
1025 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1026 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1030 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1032 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1034 WRITE_NODE_FIELD(subplans);
1038 _outFieldSelect(StringInfo str, FieldSelect *node)
1040 WRITE_NODE_TYPE("FIELDSELECT");
1042 WRITE_NODE_FIELD(arg);
1043 WRITE_INT_FIELD(fieldnum);
1044 WRITE_OID_FIELD(resulttype);
1045 WRITE_INT_FIELD(resulttypmod);
1049 _outFieldStore(StringInfo str, FieldStore *node)
1051 WRITE_NODE_TYPE("FIELDSTORE");
1053 WRITE_NODE_FIELD(arg);
1054 WRITE_NODE_FIELD(newvals);
1055 WRITE_NODE_FIELD(fieldnums);
1056 WRITE_OID_FIELD(resulttype);
1060 _outRelabelType(StringInfo str, RelabelType *node)
1062 WRITE_NODE_TYPE("RELABELTYPE");
1064 WRITE_NODE_FIELD(arg);
1065 WRITE_OID_FIELD(resulttype);
1066 WRITE_INT_FIELD(resulttypmod);
1067 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1068 WRITE_LOCATION_FIELD(location);
1072 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1074 WRITE_NODE_TYPE("COERCEVIAIO");
1076 WRITE_NODE_FIELD(arg);
1077 WRITE_OID_FIELD(resulttype);
1078 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1079 WRITE_LOCATION_FIELD(location);
1083 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1085 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1087 WRITE_NODE_FIELD(arg);
1088 WRITE_OID_FIELD(elemfuncid);
1089 WRITE_OID_FIELD(resulttype);
1090 WRITE_INT_FIELD(resulttypmod);
1091 WRITE_BOOL_FIELD(isExplicit);
1092 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1093 WRITE_LOCATION_FIELD(location);
1097 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1099 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1101 WRITE_NODE_FIELD(arg);
1102 WRITE_OID_FIELD(resulttype);
1103 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1104 WRITE_LOCATION_FIELD(location);
1108 _outCaseExpr(StringInfo str, CaseExpr *node)
1110 WRITE_NODE_TYPE("CASE");
1112 WRITE_OID_FIELD(casetype);
1113 WRITE_NODE_FIELD(arg);
1114 WRITE_NODE_FIELD(args);
1115 WRITE_NODE_FIELD(defresult);
1116 WRITE_LOCATION_FIELD(location);
1120 _outCaseWhen(StringInfo str, CaseWhen *node)
1122 WRITE_NODE_TYPE("WHEN");
1124 WRITE_NODE_FIELD(expr);
1125 WRITE_NODE_FIELD(result);
1126 WRITE_LOCATION_FIELD(location);
1130 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1132 WRITE_NODE_TYPE("CASETESTEXPR");
1134 WRITE_OID_FIELD(typeId);
1135 WRITE_INT_FIELD(typeMod);
1139 _outArrayExpr(StringInfo str, ArrayExpr *node)
1141 WRITE_NODE_TYPE("ARRAY");
1143 WRITE_OID_FIELD(array_typeid);
1144 WRITE_OID_FIELD(element_typeid);
1145 WRITE_NODE_FIELD(elements);
1146 WRITE_BOOL_FIELD(multidims);
1147 WRITE_LOCATION_FIELD(location);
1151 _outRowExpr(StringInfo str, RowExpr *node)
1153 WRITE_NODE_TYPE("ROW");
1155 WRITE_NODE_FIELD(args);
1156 WRITE_OID_FIELD(row_typeid);
1157 WRITE_ENUM_FIELD(row_format, CoercionForm);
1158 WRITE_NODE_FIELD(colnames);
1159 WRITE_LOCATION_FIELD(location);
1163 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1165 WRITE_NODE_TYPE("ROWCOMPARE");
1167 WRITE_ENUM_FIELD(rctype, RowCompareType);
1168 WRITE_NODE_FIELD(opnos);
1169 WRITE_NODE_FIELD(opfamilies);
1170 WRITE_NODE_FIELD(largs);
1171 WRITE_NODE_FIELD(rargs);
1175 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1177 WRITE_NODE_TYPE("COALESCE");
1179 WRITE_OID_FIELD(coalescetype);
1180 WRITE_NODE_FIELD(args);
1181 WRITE_LOCATION_FIELD(location);
1185 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1187 WRITE_NODE_TYPE("MINMAX");
1189 WRITE_OID_FIELD(minmaxtype);
1190 WRITE_ENUM_FIELD(op, MinMaxOp);
1191 WRITE_NODE_FIELD(args);
1192 WRITE_LOCATION_FIELD(location);
1196 _outXmlExpr(StringInfo str, XmlExpr *node)
1198 WRITE_NODE_TYPE("XMLEXPR");
1200 WRITE_ENUM_FIELD(op, XmlExprOp);
1201 WRITE_STRING_FIELD(name);
1202 WRITE_NODE_FIELD(named_args);
1203 WRITE_NODE_FIELD(arg_names);
1204 WRITE_NODE_FIELD(args);
1205 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1206 WRITE_OID_FIELD(type);
1207 WRITE_INT_FIELD(typmod);
1208 WRITE_LOCATION_FIELD(location);
1212 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1214 WRITE_NODE_TYPE("NULLIFEXPR");
1216 WRITE_OID_FIELD(opno);
1217 WRITE_OID_FIELD(opfuncid);
1218 WRITE_OID_FIELD(opresulttype);
1219 WRITE_BOOL_FIELD(opretset);
1220 WRITE_NODE_FIELD(args);
1221 WRITE_LOCATION_FIELD(location);
1225 _outNullTest(StringInfo str, NullTest *node)
1227 WRITE_NODE_TYPE("NULLTEST");
1229 WRITE_NODE_FIELD(arg);
1230 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1234 _outBooleanTest(StringInfo str, BooleanTest *node)
1236 WRITE_NODE_TYPE("BOOLEANTEST");
1238 WRITE_NODE_FIELD(arg);
1239 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1243 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1245 WRITE_NODE_TYPE("COERCETODOMAIN");
1247 WRITE_NODE_FIELD(arg);
1248 WRITE_OID_FIELD(resulttype);
1249 WRITE_INT_FIELD(resulttypmod);
1250 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1251 WRITE_LOCATION_FIELD(location);
1255 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1257 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1259 WRITE_OID_FIELD(typeId);
1260 WRITE_INT_FIELD(typeMod);
1261 WRITE_LOCATION_FIELD(location);
1265 _outSetToDefault(StringInfo str, SetToDefault *node)
1267 WRITE_NODE_TYPE("SETTODEFAULT");
1269 WRITE_OID_FIELD(typeId);
1270 WRITE_INT_FIELD(typeMod);
1271 WRITE_LOCATION_FIELD(location);
1275 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1277 WRITE_NODE_TYPE("CURRENTOFEXPR");
1279 WRITE_UINT_FIELD(cvarno);
1280 WRITE_STRING_FIELD(cursor_name);
1281 WRITE_INT_FIELD(cursor_param);
1285 _outTargetEntry(StringInfo str, TargetEntry *node)
1287 WRITE_NODE_TYPE("TARGETENTRY");
1289 WRITE_NODE_FIELD(expr);
1290 WRITE_INT_FIELD(resno);
1291 WRITE_STRING_FIELD(resname);
1292 WRITE_UINT_FIELD(ressortgroupref);
1293 WRITE_OID_FIELD(resorigtbl);
1294 WRITE_INT_FIELD(resorigcol);
1295 WRITE_BOOL_FIELD(resjunk);
1299 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1301 WRITE_NODE_TYPE("RANGETBLREF");
1303 WRITE_INT_FIELD(rtindex);
1307 _outJoinExpr(StringInfo str, JoinExpr *node)
1309 WRITE_NODE_TYPE("JOINEXPR");
1311 WRITE_ENUM_FIELD(jointype, JoinType);
1312 WRITE_BOOL_FIELD(isNatural);
1313 WRITE_NODE_FIELD(larg);
1314 WRITE_NODE_FIELD(rarg);
1315 WRITE_NODE_FIELD(usingClause);
1316 WRITE_NODE_FIELD(quals);
1317 WRITE_NODE_FIELD(alias);
1318 WRITE_INT_FIELD(rtindex);
1322 _outFromExpr(StringInfo str, FromExpr *node)
1324 WRITE_NODE_TYPE("FROMEXPR");
1326 WRITE_NODE_FIELD(fromlist);
1327 WRITE_NODE_FIELD(quals);
1330 /*****************************************************************************
1332 * Stuff from relation.h.
1334 *****************************************************************************/
1337 * print the basic stuff of all nodes that inherit from Path
1339 * Note we do NOT print the parent, else we'd be in infinite recursion
1342 _outPathInfo(StringInfo str, Path *node)
1344 WRITE_ENUM_FIELD(pathtype, NodeTag);
1345 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1346 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1347 WRITE_NODE_FIELD(pathkeys);
1351 * print the basic stuff of all nodes that inherit from JoinPath
1354 _outJoinPathInfo(StringInfo str, JoinPath *node)
1356 _outPathInfo(str, (Path *) node);
1358 WRITE_ENUM_FIELD(jointype, JoinType);
1359 WRITE_NODE_FIELD(outerjoinpath);
1360 WRITE_NODE_FIELD(innerjoinpath);
1361 WRITE_NODE_FIELD(joinrestrictinfo);
1365 _outPath(StringInfo str, Path *node)
1367 WRITE_NODE_TYPE("PATH");
1369 _outPathInfo(str, (Path *) node);
1373 _outIndexPath(StringInfo str, IndexPath *node)
1375 WRITE_NODE_TYPE("INDEXPATH");
1377 _outPathInfo(str, (Path *) node);
1379 WRITE_NODE_FIELD(indexinfo);
1380 WRITE_NODE_FIELD(indexclauses);
1381 WRITE_NODE_FIELD(indexquals);
1382 WRITE_BOOL_FIELD(isjoininner);
1383 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1384 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1385 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1386 WRITE_FLOAT_FIELD(rows, "%.0f");
1390 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1392 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1394 _outPathInfo(str, (Path *) node);
1396 WRITE_NODE_FIELD(bitmapqual);
1397 WRITE_BOOL_FIELD(isjoininner);
1398 WRITE_FLOAT_FIELD(rows, "%.0f");
1402 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1404 WRITE_NODE_TYPE("BITMAPANDPATH");
1406 _outPathInfo(str, (Path *) node);
1408 WRITE_NODE_FIELD(bitmapquals);
1409 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1413 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1415 WRITE_NODE_TYPE("BITMAPORPATH");
1417 _outPathInfo(str, (Path *) node);
1419 WRITE_NODE_FIELD(bitmapquals);
1420 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1424 _outTidPath(StringInfo str, TidPath *node)
1426 WRITE_NODE_TYPE("TIDPATH");
1428 _outPathInfo(str, (Path *) node);
1430 WRITE_NODE_FIELD(tidquals);
1434 _outAppendPath(StringInfo str, AppendPath *node)
1436 WRITE_NODE_TYPE("APPENDPATH");
1438 _outPathInfo(str, (Path *) node);
1440 WRITE_NODE_FIELD(subpaths);
1444 _outResultPath(StringInfo str, ResultPath *node)
1446 WRITE_NODE_TYPE("RESULTPATH");
1448 _outPathInfo(str, (Path *) node);
1450 WRITE_NODE_FIELD(quals);
1454 _outMaterialPath(StringInfo str, MaterialPath *node)
1456 WRITE_NODE_TYPE("MATERIALPATH");
1458 _outPathInfo(str, (Path *) node);
1460 WRITE_NODE_FIELD(subpath);
1464 _outUniquePath(StringInfo str, UniquePath *node)
1466 WRITE_NODE_TYPE("UNIQUEPATH");
1468 _outPathInfo(str, (Path *) node);
1470 WRITE_NODE_FIELD(subpath);
1471 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1472 WRITE_NODE_FIELD(in_operators);
1473 WRITE_NODE_FIELD(uniq_exprs);
1474 WRITE_FLOAT_FIELD(rows, "%.0f");
1478 _outNoOpPath(StringInfo str, NoOpPath *node)
1480 WRITE_NODE_TYPE("NOOPPATH");
1482 _outPathInfo(str, (Path *) node);
1484 WRITE_NODE_FIELD(subpath);
1488 _outNestPath(StringInfo str, NestPath *node)
1490 WRITE_NODE_TYPE("NESTPATH");
1492 _outJoinPathInfo(str, (JoinPath *) node);
1496 _outMergePath(StringInfo str, MergePath *node)
1498 WRITE_NODE_TYPE("MERGEPATH");
1500 _outJoinPathInfo(str, (JoinPath *) node);
1502 WRITE_NODE_FIELD(path_mergeclauses);
1503 WRITE_NODE_FIELD(outersortkeys);
1504 WRITE_NODE_FIELD(innersortkeys);
1505 WRITE_BOOL_FIELD(materialize_inner);
1509 _outHashPath(StringInfo str, HashPath *node)
1511 WRITE_NODE_TYPE("HASHPATH");
1513 _outJoinPathInfo(str, (JoinPath *) node);
1515 WRITE_NODE_FIELD(path_hashclauses);
1516 WRITE_INT_FIELD(num_batches);
1520 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1522 WRITE_NODE_TYPE("PLANNERGLOBAL");
1524 /* NB: this isn't a complete set of fields */
1525 WRITE_NODE_FIELD(paramlist);
1526 WRITE_NODE_FIELD(subplans);
1527 WRITE_NODE_FIELD(subrtables);
1528 WRITE_NODE_FIELD(subrowmarks);
1529 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1530 WRITE_NODE_FIELD(finalrtable);
1531 WRITE_NODE_FIELD(finalrowmarks);
1532 WRITE_NODE_FIELD(relationOids);
1533 WRITE_NODE_FIELD(invalItems);
1534 WRITE_UINT_FIELD(lastPHId);
1535 WRITE_BOOL_FIELD(transientPlan);
1539 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1541 WRITE_NODE_TYPE("PLANNERINFO");
1543 /* NB: this isn't a complete set of fields */
1544 WRITE_NODE_FIELD(parse);
1545 WRITE_NODE_FIELD(glob);
1546 WRITE_UINT_FIELD(query_level);
1547 WRITE_NODE_FIELD(join_rel_list);
1548 WRITE_INT_FIELD(join_cur_level);
1549 WRITE_NODE_FIELD(resultRelations);
1550 WRITE_NODE_FIELD(init_plans);
1551 WRITE_NODE_FIELD(cte_plan_ids);
1552 WRITE_NODE_FIELD(eq_classes);
1553 WRITE_NODE_FIELD(canon_pathkeys);
1554 WRITE_NODE_FIELD(left_join_clauses);
1555 WRITE_NODE_FIELD(right_join_clauses);
1556 WRITE_NODE_FIELD(full_join_clauses);
1557 WRITE_NODE_FIELD(join_info_list);
1558 WRITE_NODE_FIELD(append_rel_list);
1559 WRITE_NODE_FIELD(rowMarks);
1560 WRITE_NODE_FIELD(placeholder_list);
1561 WRITE_NODE_FIELD(query_pathkeys);
1562 WRITE_NODE_FIELD(group_pathkeys);
1563 WRITE_NODE_FIELD(window_pathkeys);
1564 WRITE_NODE_FIELD(distinct_pathkeys);
1565 WRITE_NODE_FIELD(sort_pathkeys);
1566 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1567 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1568 WRITE_BOOL_FIELD(hasJoinRTEs);
1569 WRITE_BOOL_FIELD(hasHavingQual);
1570 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1571 WRITE_BOOL_FIELD(hasRecursion);
1572 WRITE_INT_FIELD(wt_param_id);
1576 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1578 WRITE_NODE_TYPE("RELOPTINFO");
1580 /* NB: this isn't a complete set of fields */
1581 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1582 WRITE_BITMAPSET_FIELD(relids);
1583 WRITE_FLOAT_FIELD(rows, "%.0f");
1584 WRITE_INT_FIELD(width);
1585 WRITE_NODE_FIELD(reltargetlist);
1586 WRITE_NODE_FIELD(pathlist);
1587 WRITE_NODE_FIELD(cheapest_startup_path);
1588 WRITE_NODE_FIELD(cheapest_total_path);
1589 WRITE_NODE_FIELD(cheapest_unique_path);
1590 WRITE_UINT_FIELD(relid);
1591 WRITE_ENUM_FIELD(rtekind, RTEKind);
1592 WRITE_INT_FIELD(min_attr);
1593 WRITE_INT_FIELD(max_attr);
1594 WRITE_NODE_FIELD(indexlist);
1595 WRITE_UINT_FIELD(pages);
1596 WRITE_FLOAT_FIELD(tuples, "%.0f");
1597 WRITE_NODE_FIELD(subplan);
1598 WRITE_NODE_FIELD(subrtable);
1599 WRITE_NODE_FIELD(subrowmark);
1600 WRITE_NODE_FIELD(baserestrictinfo);
1601 WRITE_NODE_FIELD(joininfo);
1602 WRITE_BOOL_FIELD(has_eclass_joins);
1603 WRITE_BITMAPSET_FIELD(index_outer_relids);
1604 WRITE_NODE_FIELD(index_inner_paths);
1608 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1610 WRITE_NODE_TYPE("INDEXOPTINFO");
1612 /* NB: this isn't a complete set of fields */
1613 WRITE_OID_FIELD(indexoid);
1614 /* Do NOT print rel field, else infinite recursion */
1615 WRITE_UINT_FIELD(pages);
1616 WRITE_FLOAT_FIELD(tuples, "%.0f");
1617 WRITE_INT_FIELD(ncolumns);
1618 WRITE_NODE_FIELD(indexprs);
1619 WRITE_NODE_FIELD(indpred);
1620 WRITE_BOOL_FIELD(predOK);
1621 WRITE_BOOL_FIELD(unique);
1625 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1628 * To simplify reading, we just chase up to the topmost merged EC and
1629 * print that, without bothering to show the merge-ees separately.
1631 while (node->ec_merged)
1632 node = node->ec_merged;
1634 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1636 WRITE_NODE_FIELD(ec_opfamilies);
1637 WRITE_NODE_FIELD(ec_members);
1638 WRITE_NODE_FIELD(ec_sources);
1639 WRITE_NODE_FIELD(ec_derives);
1640 WRITE_BITMAPSET_FIELD(ec_relids);
1641 WRITE_BOOL_FIELD(ec_has_const);
1642 WRITE_BOOL_FIELD(ec_has_volatile);
1643 WRITE_BOOL_FIELD(ec_below_outer_join);
1644 WRITE_BOOL_FIELD(ec_broken);
1645 WRITE_UINT_FIELD(ec_sortref);
1649 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1651 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1653 WRITE_NODE_FIELD(em_expr);
1654 WRITE_BITMAPSET_FIELD(em_relids);
1655 WRITE_BOOL_FIELD(em_is_const);
1656 WRITE_BOOL_FIELD(em_is_child);
1657 WRITE_OID_FIELD(em_datatype);
1661 _outPathKey(StringInfo str, PathKey *node)
1663 WRITE_NODE_TYPE("PATHKEY");
1665 WRITE_NODE_FIELD(pk_eclass);
1666 WRITE_OID_FIELD(pk_opfamily);
1667 WRITE_INT_FIELD(pk_strategy);
1668 WRITE_BOOL_FIELD(pk_nulls_first);
1672 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1674 WRITE_NODE_TYPE("RESTRICTINFO");
1676 /* NB: this isn't a complete set of fields */
1677 WRITE_NODE_FIELD(clause);
1678 WRITE_BOOL_FIELD(is_pushed_down);
1679 WRITE_BOOL_FIELD(outerjoin_delayed);
1680 WRITE_BOOL_FIELD(can_join);
1681 WRITE_BOOL_FIELD(pseudoconstant);
1682 WRITE_BITMAPSET_FIELD(clause_relids);
1683 WRITE_BITMAPSET_FIELD(required_relids);
1684 WRITE_BITMAPSET_FIELD(nullable_relids);
1685 WRITE_BITMAPSET_FIELD(left_relids);
1686 WRITE_BITMAPSET_FIELD(right_relids);
1687 WRITE_NODE_FIELD(orclause);
1688 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1689 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1690 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1691 WRITE_NODE_FIELD(mergeopfamilies);
1692 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1693 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1694 WRITE_NODE_FIELD(left_em);
1695 WRITE_NODE_FIELD(right_em);
1696 WRITE_BOOL_FIELD(outer_is_left);
1697 WRITE_OID_FIELD(hashjoinoperator);
1701 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1703 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1704 WRITE_BITMAPSET_FIELD(other_relids);
1705 WRITE_BOOL_FIELD(isouterjoin);
1706 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1707 WRITE_NODE_FIELD(cheapest_total_innerpath);
1711 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1713 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1715 WRITE_NODE_FIELD(phexpr);
1716 WRITE_BITMAPSET_FIELD(phrels);
1717 WRITE_UINT_FIELD(phid);
1718 WRITE_UINT_FIELD(phlevelsup);
1722 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1724 WRITE_NODE_TYPE("SPECIALJOININFO");
1726 WRITE_BITMAPSET_FIELD(min_lefthand);
1727 WRITE_BITMAPSET_FIELD(min_righthand);
1728 WRITE_BITMAPSET_FIELD(syn_lefthand);
1729 WRITE_BITMAPSET_FIELD(syn_righthand);
1730 WRITE_ENUM_FIELD(jointype, JoinType);
1731 WRITE_BOOL_FIELD(lhs_strict);
1732 WRITE_BOOL_FIELD(delay_upper_joins);
1733 WRITE_NODE_FIELD(join_quals);
1737 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1739 WRITE_NODE_TYPE("APPENDRELINFO");
1741 WRITE_UINT_FIELD(parent_relid);
1742 WRITE_UINT_FIELD(child_relid);
1743 WRITE_OID_FIELD(parent_reltype);
1744 WRITE_OID_FIELD(child_reltype);
1745 WRITE_NODE_FIELD(translated_vars);
1746 WRITE_OID_FIELD(parent_reloid);
1750 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1752 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1754 WRITE_UINT_FIELD(phid);
1755 WRITE_NODE_FIELD(ph_var);
1756 WRITE_BITMAPSET_FIELD(ph_eval_at);
1757 WRITE_BITMAPSET_FIELD(ph_needed);
1758 WRITE_INT_FIELD(ph_width);
1762 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1764 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1766 WRITE_NODE_FIELD(item);
1767 WRITE_UINT_FIELD(abslevel);
1770 /*****************************************************************************
1772 * Stuff from parsenodes.h.
1774 *****************************************************************************/
1777 _outCreateStmt(StringInfo str, CreateStmt *node)
1779 WRITE_NODE_TYPE("CREATESTMT");
1781 WRITE_NODE_FIELD(relation);
1782 WRITE_NODE_FIELD(tableElts);
1783 WRITE_NODE_FIELD(inhRelations);
1784 WRITE_NODE_FIELD(constraints);
1785 WRITE_NODE_FIELD(options);
1786 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1787 WRITE_STRING_FIELD(tablespacename);
1791 _outIndexStmt(StringInfo str, IndexStmt *node)
1793 WRITE_NODE_TYPE("INDEXSTMT");
1795 WRITE_STRING_FIELD(idxname);
1796 WRITE_NODE_FIELD(relation);
1797 WRITE_STRING_FIELD(accessMethod);
1798 WRITE_STRING_FIELD(tableSpace);
1799 WRITE_NODE_FIELD(indexParams);
1800 WRITE_NODE_FIELD(options);
1801 WRITE_NODE_FIELD(whereClause);
1802 WRITE_NODE_FIELD(excludeOpNames);
1803 WRITE_BOOL_FIELD(unique);
1804 WRITE_BOOL_FIELD(primary);
1805 WRITE_BOOL_FIELD(isconstraint);
1806 WRITE_BOOL_FIELD(deferrable);
1807 WRITE_BOOL_FIELD(initdeferred);
1808 WRITE_BOOL_FIELD(concurrent);
1812 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1814 WRITE_NODE_TYPE("NOTIFY");
1816 WRITE_STRING_FIELD(conditionname);
1820 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1822 WRITE_NODE_TYPE("DECLARECURSOR");
1824 WRITE_STRING_FIELD(portalname);
1825 WRITE_INT_FIELD(options);
1826 WRITE_NODE_FIELD(query);
1830 _outSelectStmt(StringInfo str, SelectStmt *node)
1832 WRITE_NODE_TYPE("SELECT");
1834 WRITE_NODE_FIELD(distinctClause);
1835 WRITE_NODE_FIELD(intoClause);
1836 WRITE_NODE_FIELD(targetList);
1837 WRITE_NODE_FIELD(fromClause);
1838 WRITE_NODE_FIELD(whereClause);
1839 WRITE_NODE_FIELD(groupClause);
1840 WRITE_NODE_FIELD(havingClause);
1841 WRITE_NODE_FIELD(windowClause);
1842 WRITE_NODE_FIELD(withClause);
1843 WRITE_NODE_FIELD(valuesLists);
1844 WRITE_NODE_FIELD(sortClause);
1845 WRITE_NODE_FIELD(limitOffset);
1846 WRITE_NODE_FIELD(limitCount);
1847 WRITE_NODE_FIELD(lockingClause);
1848 WRITE_ENUM_FIELD(op, SetOperation);
1849 WRITE_BOOL_FIELD(all);
1850 WRITE_NODE_FIELD(larg);
1851 WRITE_NODE_FIELD(rarg);
1855 _outFuncCall(StringInfo str, FuncCall *node)
1857 WRITE_NODE_TYPE("FUNCCALL");
1859 WRITE_NODE_FIELD(funcname);
1860 WRITE_NODE_FIELD(args);
1861 WRITE_NODE_FIELD(agg_order);
1862 WRITE_BOOL_FIELD(agg_star);
1863 WRITE_BOOL_FIELD(agg_distinct);
1864 WRITE_BOOL_FIELD(func_variadic);
1865 WRITE_NODE_FIELD(over);
1866 WRITE_LOCATION_FIELD(location);
1870 _outDefElem(StringInfo str, DefElem *node)
1872 WRITE_NODE_TYPE("DEFELEM");
1874 WRITE_STRING_FIELD(defnamespace);
1875 WRITE_STRING_FIELD(defname);
1876 WRITE_NODE_FIELD(arg);
1877 WRITE_ENUM_FIELD(defaction, DefElemAction);
1881 _outLockingClause(StringInfo str, LockingClause *node)
1883 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1885 WRITE_NODE_FIELD(lockedRels);
1886 WRITE_BOOL_FIELD(forUpdate);
1887 WRITE_BOOL_FIELD(noWait);
1891 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1893 WRITE_NODE_TYPE("XMLSERIALIZE");
1895 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1896 WRITE_NODE_FIELD(expr);
1897 WRITE_NODE_FIELD(typeName);
1898 WRITE_LOCATION_FIELD(location);
1902 _outColumnDef(StringInfo str, ColumnDef *node)
1904 WRITE_NODE_TYPE("COLUMNDEF");
1906 WRITE_STRING_FIELD(colname);
1907 WRITE_NODE_FIELD(typeName);
1908 WRITE_INT_FIELD(inhcount);
1909 WRITE_BOOL_FIELD(is_local);
1910 WRITE_BOOL_FIELD(is_not_null);
1911 WRITE_INT_FIELD(storage);
1912 WRITE_NODE_FIELD(raw_default);
1913 WRITE_NODE_FIELD(cooked_default);
1914 WRITE_NODE_FIELD(constraints);
1918 _outTypeName(StringInfo str, TypeName *node)
1920 WRITE_NODE_TYPE("TYPENAME");
1922 WRITE_NODE_FIELD(names);
1923 WRITE_OID_FIELD(typeOid);
1924 WRITE_BOOL_FIELD(setof);
1925 WRITE_BOOL_FIELD(pct_type);
1926 WRITE_NODE_FIELD(typmods);
1927 WRITE_INT_FIELD(typemod);
1928 WRITE_NODE_FIELD(arrayBounds);
1929 WRITE_LOCATION_FIELD(location);
1933 _outTypeCast(StringInfo str, TypeCast *node)
1935 WRITE_NODE_TYPE("TYPECAST");
1937 WRITE_NODE_FIELD(arg);
1938 WRITE_NODE_FIELD(typeName);
1939 WRITE_LOCATION_FIELD(location);
1943 _outIndexElem(StringInfo str, IndexElem *node)
1945 WRITE_NODE_TYPE("INDEXELEM");
1947 WRITE_STRING_FIELD(name);
1948 WRITE_NODE_FIELD(expr);
1949 WRITE_NODE_FIELD(opclass);
1950 WRITE_ENUM_FIELD(ordering, SortByDir);
1951 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1955 _outQuery(StringInfo str, Query *node)
1957 WRITE_NODE_TYPE("QUERY");
1959 WRITE_ENUM_FIELD(commandType, CmdType);
1960 WRITE_ENUM_FIELD(querySource, QuerySource);
1961 WRITE_BOOL_FIELD(canSetTag);
1964 * Hack to work around missing outfuncs routines for a lot of the
1965 * utility-statement node types. (The only one we actually *need* for
1966 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1967 * for the meantime do this to avoid getting lots of warnings when running
1968 * with debug_print_parse on.
1970 if (node->utilityStmt)
1972 switch (nodeTag(node->utilityStmt))
1977 case T_DeclareCursorStmt:
1978 WRITE_NODE_FIELD(utilityStmt);
1981 appendStringInfo(str, " :utilityStmt ?");
1986 appendStringInfo(str, " :utilityStmt <>");
1988 WRITE_INT_FIELD(resultRelation);
1989 WRITE_NODE_FIELD(intoClause);
1990 WRITE_BOOL_FIELD(hasAggs);
1991 WRITE_BOOL_FIELD(hasWindowFuncs);
1992 WRITE_BOOL_FIELD(hasSubLinks);
1993 WRITE_BOOL_FIELD(hasDistinctOn);
1994 WRITE_BOOL_FIELD(hasRecursive);
1995 WRITE_BOOL_FIELD(hasForUpdate);
1996 WRITE_NODE_FIELD(cteList);
1997 WRITE_NODE_FIELD(rtable);
1998 WRITE_NODE_FIELD(jointree);
1999 WRITE_NODE_FIELD(targetList);
2000 WRITE_NODE_FIELD(returningList);
2001 WRITE_NODE_FIELD(groupClause);
2002 WRITE_NODE_FIELD(havingQual);
2003 WRITE_NODE_FIELD(windowClause);
2004 WRITE_NODE_FIELD(distinctClause);
2005 WRITE_NODE_FIELD(sortClause);
2006 WRITE_NODE_FIELD(limitOffset);
2007 WRITE_NODE_FIELD(limitCount);
2008 WRITE_NODE_FIELD(rowMarks);
2009 WRITE_NODE_FIELD(setOperations);
2013 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2015 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2017 WRITE_UINT_FIELD(tleSortGroupRef);
2018 WRITE_OID_FIELD(eqop);
2019 WRITE_OID_FIELD(sortop);
2020 WRITE_BOOL_FIELD(nulls_first);
2024 _outWindowClause(StringInfo str, WindowClause *node)
2026 WRITE_NODE_TYPE("WINDOWCLAUSE");
2028 WRITE_STRING_FIELD(name);
2029 WRITE_STRING_FIELD(refname);
2030 WRITE_NODE_FIELD(partitionClause);
2031 WRITE_NODE_FIELD(orderClause);
2032 WRITE_INT_FIELD(frameOptions);
2033 WRITE_UINT_FIELD(winref);
2034 WRITE_BOOL_FIELD(copiedOrder);
2038 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2040 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2042 WRITE_UINT_FIELD(rti);
2043 WRITE_BOOL_FIELD(forUpdate);
2044 WRITE_BOOL_FIELD(noWait);
2045 WRITE_BOOL_FIELD(pushedDown);
2049 _outWithClause(StringInfo str, WithClause *node)
2051 WRITE_NODE_TYPE("WITHCLAUSE");
2053 WRITE_NODE_FIELD(ctes);
2054 WRITE_BOOL_FIELD(recursive);
2055 WRITE_LOCATION_FIELD(location);
2059 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2061 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2063 WRITE_STRING_FIELD(ctename);
2064 WRITE_NODE_FIELD(aliascolnames);
2065 WRITE_NODE_FIELD(ctequery);
2066 WRITE_LOCATION_FIELD(location);
2067 WRITE_BOOL_FIELD(cterecursive);
2068 WRITE_INT_FIELD(cterefcount);
2069 WRITE_NODE_FIELD(ctecolnames);
2070 WRITE_NODE_FIELD(ctecoltypes);
2071 WRITE_NODE_FIELD(ctecoltypmods);
2075 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2077 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2079 WRITE_ENUM_FIELD(op, SetOperation);
2080 WRITE_BOOL_FIELD(all);
2081 WRITE_NODE_FIELD(larg);
2082 WRITE_NODE_FIELD(rarg);
2083 WRITE_NODE_FIELD(colTypes);
2084 WRITE_NODE_FIELD(colTypmods);
2085 WRITE_NODE_FIELD(groupClauses);
2089 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2091 WRITE_NODE_TYPE("RTE");
2093 /* put alias + eref first to make dump more legible */
2094 WRITE_NODE_FIELD(alias);
2095 WRITE_NODE_FIELD(eref);
2096 WRITE_ENUM_FIELD(rtekind, RTEKind);
2098 switch (node->rtekind)
2102 WRITE_OID_FIELD(relid);
2105 WRITE_NODE_FIELD(subquery);
2108 WRITE_ENUM_FIELD(jointype, JoinType);
2109 WRITE_NODE_FIELD(joinaliasvars);
2112 WRITE_NODE_FIELD(funcexpr);
2113 WRITE_NODE_FIELD(funccoltypes);
2114 WRITE_NODE_FIELD(funccoltypmods);
2117 WRITE_NODE_FIELD(values_lists);
2120 WRITE_STRING_FIELD(ctename);
2121 WRITE_UINT_FIELD(ctelevelsup);
2122 WRITE_BOOL_FIELD(self_reference);
2123 WRITE_NODE_FIELD(ctecoltypes);
2124 WRITE_NODE_FIELD(ctecoltypmods);
2127 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2131 WRITE_BOOL_FIELD(inh);
2132 WRITE_BOOL_FIELD(inFromCl);
2133 WRITE_UINT_FIELD(requiredPerms);
2134 WRITE_OID_FIELD(checkAsUser);
2135 WRITE_BITMAPSET_FIELD(selectedCols);
2136 WRITE_BITMAPSET_FIELD(modifiedCols);
2140 _outAExpr(StringInfo str, A_Expr *node)
2142 WRITE_NODE_TYPE("AEXPR");
2147 appendStringInfo(str, " ");
2148 WRITE_NODE_FIELD(name);
2151 appendStringInfo(str, " AND");
2154 appendStringInfo(str, " OR");
2157 appendStringInfo(str, " NOT");
2160 appendStringInfo(str, " ");
2161 WRITE_NODE_FIELD(name);
2162 appendStringInfo(str, " ANY ");
2165 appendStringInfo(str, " ");
2166 WRITE_NODE_FIELD(name);
2167 appendStringInfo(str, " ALL ");
2169 case AEXPR_DISTINCT:
2170 appendStringInfo(str, " DISTINCT ");
2171 WRITE_NODE_FIELD(name);
2174 appendStringInfo(str, " NULLIF ");
2175 WRITE_NODE_FIELD(name);
2178 appendStringInfo(str, " OF ");
2179 WRITE_NODE_FIELD(name);
2182 appendStringInfo(str, " IN ");
2183 WRITE_NODE_FIELD(name);
2186 appendStringInfo(str, " ??");
2190 WRITE_NODE_FIELD(lexpr);
2191 WRITE_NODE_FIELD(rexpr);
2192 WRITE_LOCATION_FIELD(location);
2196 _outValue(StringInfo str, Value *value)
2198 switch (value->type)
2201 appendStringInfo(str, "%ld", value->val.ival);
2206 * We assume the value is a valid numeric literal and so does not
2209 appendStringInfoString(str, value->val.str);
2212 appendStringInfoChar(str, '"');
2213 _outToken(str, value->val.str);
2214 appendStringInfoChar(str, '"');
2217 /* internal representation already has leading 'b' */
2218 appendStringInfoString(str, value->val.str);
2221 /* this is seen only within A_Const, not in transformed trees */
2222 appendStringInfoString(str, "NULL");
2225 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2231 _outColumnRef(StringInfo str, ColumnRef *node)
2233 WRITE_NODE_TYPE("COLUMNREF");
2235 WRITE_NODE_FIELD(fields);
2236 WRITE_LOCATION_FIELD(location);
2240 _outParamRef(StringInfo str, ParamRef *node)
2242 WRITE_NODE_TYPE("PARAMREF");
2244 WRITE_INT_FIELD(number);
2245 WRITE_LOCATION_FIELD(location);
2249 _outAConst(StringInfo str, A_Const *node)
2251 WRITE_NODE_TYPE("A_CONST");
2253 appendStringInfo(str, " :val ");
2254 _outValue(str, &(node->val));
2255 WRITE_LOCATION_FIELD(location);
2259 _outA_Star(StringInfo str, A_Star *node)
2261 WRITE_NODE_TYPE("A_STAR");
2265 _outA_Indices(StringInfo str, A_Indices *node)
2267 WRITE_NODE_TYPE("A_INDICES");
2269 WRITE_NODE_FIELD(lidx);
2270 WRITE_NODE_FIELD(uidx);
2274 _outA_Indirection(StringInfo str, A_Indirection *node)
2276 WRITE_NODE_TYPE("A_INDIRECTION");
2278 WRITE_NODE_FIELD(arg);
2279 WRITE_NODE_FIELD(indirection);
2283 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2285 WRITE_NODE_TYPE("A_ARRAYEXPR");
2287 WRITE_NODE_FIELD(elements);
2288 WRITE_LOCATION_FIELD(location);
2292 _outResTarget(StringInfo str, ResTarget *node)
2294 WRITE_NODE_TYPE("RESTARGET");
2296 WRITE_STRING_FIELD(name);
2297 WRITE_NODE_FIELD(indirection);
2298 WRITE_NODE_FIELD(val);
2299 WRITE_LOCATION_FIELD(location);
2303 _outSortBy(StringInfo str, SortBy *node)
2305 WRITE_NODE_TYPE("SORTBY");
2307 WRITE_NODE_FIELD(node);
2308 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2309 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2310 WRITE_NODE_FIELD(useOp);
2311 WRITE_LOCATION_FIELD(location);
2315 _outWindowDef(StringInfo str, WindowDef *node)
2317 WRITE_NODE_TYPE("WINDOWDEF");
2319 WRITE_STRING_FIELD(name);
2320 WRITE_STRING_FIELD(refname);
2321 WRITE_NODE_FIELD(partitionClause);
2322 WRITE_NODE_FIELD(orderClause);
2323 WRITE_INT_FIELD(frameOptions);
2324 WRITE_LOCATION_FIELD(location);
2328 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2330 WRITE_NODE_TYPE("RANGESUBSELECT");
2332 WRITE_NODE_FIELD(subquery);
2333 WRITE_NODE_FIELD(alias);
2337 _outRangeFunction(StringInfo str, RangeFunction *node)
2339 WRITE_NODE_TYPE("RANGEFUNCTION");
2341 WRITE_NODE_FIELD(funccallnode);
2342 WRITE_NODE_FIELD(alias);
2343 WRITE_NODE_FIELD(coldeflist);
2347 _outConstraint(StringInfo str, Constraint *node)
2349 WRITE_NODE_TYPE("CONSTRAINT");
2351 WRITE_STRING_FIELD(conname);
2352 WRITE_BOOL_FIELD(deferrable);
2353 WRITE_BOOL_FIELD(initdeferred);
2354 WRITE_LOCATION_FIELD(location);
2356 appendStringInfo(str, " :contype ");
2357 switch (node->contype)
2360 appendStringInfo(str, "NULL");
2363 case CONSTR_NOTNULL:
2364 appendStringInfo(str, "NOT_NULL");
2367 case CONSTR_DEFAULT:
2368 appendStringInfo(str, "DEFAULT");
2369 WRITE_NODE_FIELD(raw_expr);
2370 WRITE_STRING_FIELD(cooked_expr);
2374 appendStringInfo(str, "CHECK");
2375 WRITE_NODE_FIELD(raw_expr);
2376 WRITE_STRING_FIELD(cooked_expr);
2379 case CONSTR_PRIMARY:
2380 appendStringInfo(str, "PRIMARY_KEY");
2381 WRITE_NODE_FIELD(keys);
2382 WRITE_NODE_FIELD(options);
2383 WRITE_STRING_FIELD(indexspace);
2384 /* access_method and where_clause not currently used */
2388 appendStringInfo(str, "UNIQUE");
2389 WRITE_NODE_FIELD(keys);
2390 WRITE_NODE_FIELD(options);
2391 WRITE_STRING_FIELD(indexspace);
2392 /* access_method and where_clause not currently used */
2395 case CONSTR_EXCLUSION:
2396 appendStringInfo(str, "EXCLUSION");
2397 WRITE_NODE_FIELD(exclusions);
2398 WRITE_NODE_FIELD(options);
2399 WRITE_STRING_FIELD(indexspace);
2400 WRITE_STRING_FIELD(access_method);
2401 WRITE_NODE_FIELD(where_clause);
2404 case CONSTR_FOREIGN:
2405 appendStringInfo(str, "FOREIGN_KEY");
2406 WRITE_NODE_FIELD(pktable);
2407 WRITE_NODE_FIELD(fk_attrs);
2408 WRITE_NODE_FIELD(pk_attrs);
2409 WRITE_CHAR_FIELD(fk_matchtype);
2410 WRITE_CHAR_FIELD(fk_upd_action);
2411 WRITE_CHAR_FIELD(fk_del_action);
2412 WRITE_BOOL_FIELD(skip_validation);
2415 case CONSTR_ATTR_DEFERRABLE:
2416 appendStringInfo(str, "ATTR_DEFERRABLE");
2419 case CONSTR_ATTR_NOT_DEFERRABLE:
2420 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2423 case CONSTR_ATTR_DEFERRED:
2424 appendStringInfo(str, "ATTR_DEFERRED");
2427 case CONSTR_ATTR_IMMEDIATE:
2428 appendStringInfo(str, "ATTR_IMMEDIATE");
2432 appendStringInfo(str, "<unrecognized_constraint %d>",
2433 (int) node->contype);
2441 * converts a Node into ascii string and append it to 'str'
2444 _outNode(StringInfo str, void *obj)
2447 appendStringInfo(str, "<>");
2448 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2450 else if (IsA(obj, Integer) ||
2453 IsA(obj, BitString))
2455 /* nodeRead does not want to see { } around these! */
2456 _outValue(str, obj);
2460 appendStringInfoChar(str, '{');
2461 switch (nodeTag(obj))
2464 _outPlannedStmt(str, obj);
2470 _outResult(str, obj);
2473 _outModifyTable(str, obj);
2476 _outAppend(str, obj);
2478 case T_RecursiveUnion:
2479 _outRecursiveUnion(str, obj);
2482 _outBitmapAnd(str, obj);
2485 _outBitmapOr(str, obj);
2491 _outSeqScan(str, obj);
2494 _outIndexScan(str, obj);
2496 case T_BitmapIndexScan:
2497 _outBitmapIndexScan(str, obj);
2499 case T_BitmapHeapScan:
2500 _outBitmapHeapScan(str, obj);
2503 _outTidScan(str, obj);
2505 case T_SubqueryScan:
2506 _outSubqueryScan(str, obj);
2508 case T_FunctionScan:
2509 _outFunctionScan(str, obj);
2512 _outValuesScan(str, obj);
2515 _outCteScan(str, obj);
2517 case T_WorkTableScan:
2518 _outWorkTableScan(str, obj);
2524 _outNestLoop(str, obj);
2527 _outMergeJoin(str, obj);
2530 _outHashJoin(str, obj);
2536 _outWindowAgg(str, obj);
2539 _outGroup(str, obj);
2542 _outMaterial(str, obj);
2548 _outUnique(str, obj);
2554 _outSetOp(str, obj);
2557 _outLockRows(str, obj);
2560 _outLimit(str, obj);
2563 _outPlanRowMark(str, obj);
2565 case T_PlanInvalItem:
2566 _outPlanInvalItem(str, obj);
2569 _outAlias(str, obj);
2572 _outRangeVar(str, obj);
2575 _outIntoClause(str, obj);
2581 _outConst(str, obj);
2584 _outParam(str, obj);
2587 _outAggref(str, obj);
2590 _outWindowFunc(str, obj);
2593 _outArrayRef(str, obj);
2596 _outFuncExpr(str, obj);
2598 case T_NamedArgExpr:
2599 _outNamedArgExpr(str, obj);
2602 _outOpExpr(str, obj);
2604 case T_DistinctExpr:
2605 _outDistinctExpr(str, obj);
2607 case T_ScalarArrayOpExpr:
2608 _outScalarArrayOpExpr(str, obj);
2611 _outBoolExpr(str, obj);
2614 _outSubLink(str, obj);
2617 _outSubPlan(str, obj);
2619 case T_AlternativeSubPlan:
2620 _outAlternativeSubPlan(str, obj);
2623 _outFieldSelect(str, obj);
2626 _outFieldStore(str, obj);
2629 _outRelabelType(str, obj);
2632 _outCoerceViaIO(str, obj);
2634 case T_ArrayCoerceExpr:
2635 _outArrayCoerceExpr(str, obj);
2637 case T_ConvertRowtypeExpr:
2638 _outConvertRowtypeExpr(str, obj);
2641 _outCaseExpr(str, obj);
2644 _outCaseWhen(str, obj);
2646 case T_CaseTestExpr:
2647 _outCaseTestExpr(str, obj);
2650 _outArrayExpr(str, obj);
2653 _outRowExpr(str, obj);
2655 case T_RowCompareExpr:
2656 _outRowCompareExpr(str, obj);
2658 case T_CoalesceExpr:
2659 _outCoalesceExpr(str, obj);
2662 _outMinMaxExpr(str, obj);
2665 _outXmlExpr(str, obj);
2668 _outNullIfExpr(str, obj);
2671 _outNullTest(str, obj);
2674 _outBooleanTest(str, obj);
2676 case T_CoerceToDomain:
2677 _outCoerceToDomain(str, obj);
2679 case T_CoerceToDomainValue:
2680 _outCoerceToDomainValue(str, obj);
2682 case T_SetToDefault:
2683 _outSetToDefault(str, obj);
2685 case T_CurrentOfExpr:
2686 _outCurrentOfExpr(str, obj);
2689 _outTargetEntry(str, obj);
2692 _outRangeTblRef(str, obj);
2695 _outJoinExpr(str, obj);
2698 _outFromExpr(str, obj);
2705 _outIndexPath(str, obj);
2707 case T_BitmapHeapPath:
2708 _outBitmapHeapPath(str, obj);
2710 case T_BitmapAndPath:
2711 _outBitmapAndPath(str, obj);
2713 case T_BitmapOrPath:
2714 _outBitmapOrPath(str, obj);
2717 _outTidPath(str, obj);
2720 _outAppendPath(str, obj);
2723 _outResultPath(str, obj);
2725 case T_MaterialPath:
2726 _outMaterialPath(str, obj);
2729 _outUniquePath(str, obj);
2732 _outNoOpPath(str, obj);
2735 _outNestPath(str, obj);
2738 _outMergePath(str, obj);
2741 _outHashPath(str, obj);
2743 case T_PlannerGlobal:
2744 _outPlannerGlobal(str, obj);
2747 _outPlannerInfo(str, obj);
2750 _outRelOptInfo(str, obj);
2752 case T_IndexOptInfo:
2753 _outIndexOptInfo(str, obj);
2755 case T_EquivalenceClass:
2756 _outEquivalenceClass(str, obj);
2758 case T_EquivalenceMember:
2759 _outEquivalenceMember(str, obj);
2762 _outPathKey(str, obj);
2764 case T_RestrictInfo:
2765 _outRestrictInfo(str, obj);
2767 case T_InnerIndexscanInfo:
2768 _outInnerIndexscanInfo(str, obj);
2770 case T_PlaceHolderVar:
2771 _outPlaceHolderVar(str, obj);
2773 case T_SpecialJoinInfo:
2774 _outSpecialJoinInfo(str, obj);
2776 case T_AppendRelInfo:
2777 _outAppendRelInfo(str, obj);
2779 case T_PlaceHolderInfo:
2780 _outPlaceHolderInfo(str, obj);
2782 case T_PlannerParamItem:
2783 _outPlannerParamItem(str, obj);
2787 _outCreateStmt(str, obj);
2790 _outIndexStmt(str, obj);
2793 _outNotifyStmt(str, obj);
2795 case T_DeclareCursorStmt:
2796 _outDeclareCursorStmt(str, obj);
2799 _outSelectStmt(str, obj);
2802 _outColumnDef(str, obj);
2805 _outTypeName(str, obj);
2808 _outTypeCast(str, obj);
2811 _outIndexElem(str, obj);
2814 _outQuery(str, obj);
2816 case T_SortGroupClause:
2817 _outSortGroupClause(str, obj);
2819 case T_WindowClause:
2820 _outWindowClause(str, obj);
2822 case T_RowMarkClause:
2823 _outRowMarkClause(str, obj);
2826 _outWithClause(str, obj);
2828 case T_CommonTableExpr:
2829 _outCommonTableExpr(str, obj);
2831 case T_SetOperationStmt:
2832 _outSetOperationStmt(str, obj);
2834 case T_RangeTblEntry:
2835 _outRangeTblEntry(str, obj);
2838 _outAExpr(str, obj);
2841 _outColumnRef(str, obj);
2844 _outParamRef(str, obj);
2847 _outAConst(str, obj);
2850 _outA_Star(str, obj);
2853 _outA_Indices(str, obj);
2855 case T_A_Indirection:
2856 _outA_Indirection(str, obj);
2859 _outA_ArrayExpr(str, obj);
2862 _outResTarget(str, obj);
2865 _outSortBy(str, obj);
2868 _outWindowDef(str, obj);
2870 case T_RangeSubselect:
2871 _outRangeSubselect(str, obj);
2873 case T_RangeFunction:
2874 _outRangeFunction(str, obj);
2877 _outConstraint(str, obj);
2880 _outFuncCall(str, obj);
2883 _outDefElem(str, obj);
2885 case T_LockingClause:
2886 _outLockingClause(str, obj);
2888 case T_XmlSerialize:
2889 _outXmlSerialize(str, obj);
2895 * This should be an ERROR, but it's too useful to be able to
2896 * dump structures that _outNode only understands part of.
2898 elog(WARNING, "could not dump unrecognized node type: %d",
2899 (int) nodeTag(obj));
2902 appendStringInfoChar(str, '}');
2908 * returns the ascii representation of the Node as a palloc'd string
2911 nodeToString(void *obj)
2915 /* see stringinfo.h for an explanation of this maneuver */
2916 initStringInfo(&str);
2917 _outNode(&str, obj);