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.374 2009/12/07 05:22:22 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_UINT_FIELD(agglevelsup);
873 WRITE_BOOL_FIELD(aggstar);
874 WRITE_BOOL_FIELD(aggdistinct);
875 WRITE_LOCATION_FIELD(location);
879 _outWindowFunc(StringInfo str, WindowFunc *node)
881 WRITE_NODE_TYPE("WINDOWFUNC");
883 WRITE_OID_FIELD(winfnoid);
884 WRITE_OID_FIELD(wintype);
885 WRITE_NODE_FIELD(args);
886 WRITE_UINT_FIELD(winref);
887 WRITE_BOOL_FIELD(winstar);
888 WRITE_BOOL_FIELD(winagg);
889 WRITE_LOCATION_FIELD(location);
893 _outArrayRef(StringInfo str, ArrayRef *node)
895 WRITE_NODE_TYPE("ARRAYREF");
897 WRITE_OID_FIELD(refarraytype);
898 WRITE_OID_FIELD(refelemtype);
899 WRITE_INT_FIELD(reftypmod);
900 WRITE_NODE_FIELD(refupperindexpr);
901 WRITE_NODE_FIELD(reflowerindexpr);
902 WRITE_NODE_FIELD(refexpr);
903 WRITE_NODE_FIELD(refassgnexpr);
907 _outFuncExpr(StringInfo str, FuncExpr *node)
909 WRITE_NODE_TYPE("FUNCEXPR");
911 WRITE_OID_FIELD(funcid);
912 WRITE_OID_FIELD(funcresulttype);
913 WRITE_BOOL_FIELD(funcretset);
914 WRITE_ENUM_FIELD(funcformat, CoercionForm);
915 WRITE_NODE_FIELD(args);
916 WRITE_LOCATION_FIELD(location);
920 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
922 WRITE_NODE_TYPE("NAMEDARGEXPR");
924 WRITE_NODE_FIELD(arg);
925 WRITE_STRING_FIELD(name);
926 WRITE_INT_FIELD(argnumber);
927 WRITE_LOCATION_FIELD(location);
931 _outOpExpr(StringInfo str, OpExpr *node)
933 WRITE_NODE_TYPE("OPEXPR");
935 WRITE_OID_FIELD(opno);
936 WRITE_OID_FIELD(opfuncid);
937 WRITE_OID_FIELD(opresulttype);
938 WRITE_BOOL_FIELD(opretset);
939 WRITE_NODE_FIELD(args);
940 WRITE_LOCATION_FIELD(location);
944 _outDistinctExpr(StringInfo str, DistinctExpr *node)
946 WRITE_NODE_TYPE("DISTINCTEXPR");
948 WRITE_OID_FIELD(opno);
949 WRITE_OID_FIELD(opfuncid);
950 WRITE_OID_FIELD(opresulttype);
951 WRITE_BOOL_FIELD(opretset);
952 WRITE_NODE_FIELD(args);
953 WRITE_LOCATION_FIELD(location);
957 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
959 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
961 WRITE_OID_FIELD(opno);
962 WRITE_OID_FIELD(opfuncid);
963 WRITE_BOOL_FIELD(useOr);
964 WRITE_NODE_FIELD(args);
965 WRITE_LOCATION_FIELD(location);
969 _outBoolExpr(StringInfo str, BoolExpr *node)
973 WRITE_NODE_TYPE("BOOLEXPR");
975 /* do-it-yourself enum representation */
976 switch (node->boolop)
988 appendStringInfo(str, " :boolop ");
989 _outToken(str, opstr);
991 WRITE_NODE_FIELD(args);
992 WRITE_LOCATION_FIELD(location);
996 _outSubLink(StringInfo str, SubLink *node)
998 WRITE_NODE_TYPE("SUBLINK");
1000 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1001 WRITE_NODE_FIELD(testexpr);
1002 WRITE_NODE_FIELD(operName);
1003 WRITE_NODE_FIELD(subselect);
1004 WRITE_LOCATION_FIELD(location);
1008 _outSubPlan(StringInfo str, SubPlan *node)
1010 WRITE_NODE_TYPE("SUBPLAN");
1012 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1013 WRITE_NODE_FIELD(testexpr);
1014 WRITE_NODE_FIELD(paramIds);
1015 WRITE_INT_FIELD(plan_id);
1016 WRITE_STRING_FIELD(plan_name);
1017 WRITE_OID_FIELD(firstColType);
1018 WRITE_INT_FIELD(firstColTypmod);
1019 WRITE_BOOL_FIELD(useHashTable);
1020 WRITE_BOOL_FIELD(unknownEqFalse);
1021 WRITE_NODE_FIELD(setParam);
1022 WRITE_NODE_FIELD(parParam);
1023 WRITE_NODE_FIELD(args);
1024 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1025 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1029 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1031 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1033 WRITE_NODE_FIELD(subplans);
1037 _outFieldSelect(StringInfo str, FieldSelect *node)
1039 WRITE_NODE_TYPE("FIELDSELECT");
1041 WRITE_NODE_FIELD(arg);
1042 WRITE_INT_FIELD(fieldnum);
1043 WRITE_OID_FIELD(resulttype);
1044 WRITE_INT_FIELD(resulttypmod);
1048 _outFieldStore(StringInfo str, FieldStore *node)
1050 WRITE_NODE_TYPE("FIELDSTORE");
1052 WRITE_NODE_FIELD(arg);
1053 WRITE_NODE_FIELD(newvals);
1054 WRITE_NODE_FIELD(fieldnums);
1055 WRITE_OID_FIELD(resulttype);
1059 _outRelabelType(StringInfo str, RelabelType *node)
1061 WRITE_NODE_TYPE("RELABELTYPE");
1063 WRITE_NODE_FIELD(arg);
1064 WRITE_OID_FIELD(resulttype);
1065 WRITE_INT_FIELD(resulttypmod);
1066 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1067 WRITE_LOCATION_FIELD(location);
1071 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1073 WRITE_NODE_TYPE("COERCEVIAIO");
1075 WRITE_NODE_FIELD(arg);
1076 WRITE_OID_FIELD(resulttype);
1077 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1078 WRITE_LOCATION_FIELD(location);
1082 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1084 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1086 WRITE_NODE_FIELD(arg);
1087 WRITE_OID_FIELD(elemfuncid);
1088 WRITE_OID_FIELD(resulttype);
1089 WRITE_INT_FIELD(resulttypmod);
1090 WRITE_BOOL_FIELD(isExplicit);
1091 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1092 WRITE_LOCATION_FIELD(location);
1096 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1098 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1100 WRITE_NODE_FIELD(arg);
1101 WRITE_OID_FIELD(resulttype);
1102 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1103 WRITE_LOCATION_FIELD(location);
1107 _outCaseExpr(StringInfo str, CaseExpr *node)
1109 WRITE_NODE_TYPE("CASE");
1111 WRITE_OID_FIELD(casetype);
1112 WRITE_NODE_FIELD(arg);
1113 WRITE_NODE_FIELD(args);
1114 WRITE_NODE_FIELD(defresult);
1115 WRITE_LOCATION_FIELD(location);
1119 _outCaseWhen(StringInfo str, CaseWhen *node)
1121 WRITE_NODE_TYPE("WHEN");
1123 WRITE_NODE_FIELD(expr);
1124 WRITE_NODE_FIELD(result);
1125 WRITE_LOCATION_FIELD(location);
1129 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1131 WRITE_NODE_TYPE("CASETESTEXPR");
1133 WRITE_OID_FIELD(typeId);
1134 WRITE_INT_FIELD(typeMod);
1138 _outArrayExpr(StringInfo str, ArrayExpr *node)
1140 WRITE_NODE_TYPE("ARRAY");
1142 WRITE_OID_FIELD(array_typeid);
1143 WRITE_OID_FIELD(element_typeid);
1144 WRITE_NODE_FIELD(elements);
1145 WRITE_BOOL_FIELD(multidims);
1146 WRITE_LOCATION_FIELD(location);
1150 _outRowExpr(StringInfo str, RowExpr *node)
1152 WRITE_NODE_TYPE("ROW");
1154 WRITE_NODE_FIELD(args);
1155 WRITE_OID_FIELD(row_typeid);
1156 WRITE_ENUM_FIELD(row_format, CoercionForm);
1157 WRITE_NODE_FIELD(colnames);
1158 WRITE_LOCATION_FIELD(location);
1162 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1164 WRITE_NODE_TYPE("ROWCOMPARE");
1166 WRITE_ENUM_FIELD(rctype, RowCompareType);
1167 WRITE_NODE_FIELD(opnos);
1168 WRITE_NODE_FIELD(opfamilies);
1169 WRITE_NODE_FIELD(largs);
1170 WRITE_NODE_FIELD(rargs);
1174 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1176 WRITE_NODE_TYPE("COALESCE");
1178 WRITE_OID_FIELD(coalescetype);
1179 WRITE_NODE_FIELD(args);
1180 WRITE_LOCATION_FIELD(location);
1184 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1186 WRITE_NODE_TYPE("MINMAX");
1188 WRITE_OID_FIELD(minmaxtype);
1189 WRITE_ENUM_FIELD(op, MinMaxOp);
1190 WRITE_NODE_FIELD(args);
1191 WRITE_LOCATION_FIELD(location);
1195 _outXmlExpr(StringInfo str, XmlExpr *node)
1197 WRITE_NODE_TYPE("XMLEXPR");
1199 WRITE_ENUM_FIELD(op, XmlExprOp);
1200 WRITE_STRING_FIELD(name);
1201 WRITE_NODE_FIELD(named_args);
1202 WRITE_NODE_FIELD(arg_names);
1203 WRITE_NODE_FIELD(args);
1204 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1205 WRITE_OID_FIELD(type);
1206 WRITE_INT_FIELD(typmod);
1207 WRITE_LOCATION_FIELD(location);
1211 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1213 WRITE_NODE_TYPE("NULLIFEXPR");
1215 WRITE_OID_FIELD(opno);
1216 WRITE_OID_FIELD(opfuncid);
1217 WRITE_OID_FIELD(opresulttype);
1218 WRITE_BOOL_FIELD(opretset);
1219 WRITE_NODE_FIELD(args);
1220 WRITE_LOCATION_FIELD(location);
1224 _outNullTest(StringInfo str, NullTest *node)
1226 WRITE_NODE_TYPE("NULLTEST");
1228 WRITE_NODE_FIELD(arg);
1229 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1233 _outBooleanTest(StringInfo str, BooleanTest *node)
1235 WRITE_NODE_TYPE("BOOLEANTEST");
1237 WRITE_NODE_FIELD(arg);
1238 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1242 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1244 WRITE_NODE_TYPE("COERCETODOMAIN");
1246 WRITE_NODE_FIELD(arg);
1247 WRITE_OID_FIELD(resulttype);
1248 WRITE_INT_FIELD(resulttypmod);
1249 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1250 WRITE_LOCATION_FIELD(location);
1254 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1256 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1258 WRITE_OID_FIELD(typeId);
1259 WRITE_INT_FIELD(typeMod);
1260 WRITE_LOCATION_FIELD(location);
1264 _outSetToDefault(StringInfo str, SetToDefault *node)
1266 WRITE_NODE_TYPE("SETTODEFAULT");
1268 WRITE_OID_FIELD(typeId);
1269 WRITE_INT_FIELD(typeMod);
1270 WRITE_LOCATION_FIELD(location);
1274 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1276 WRITE_NODE_TYPE("CURRENTOFEXPR");
1278 WRITE_UINT_FIELD(cvarno);
1279 WRITE_STRING_FIELD(cursor_name);
1280 WRITE_INT_FIELD(cursor_param);
1284 _outTargetEntry(StringInfo str, TargetEntry *node)
1286 WRITE_NODE_TYPE("TARGETENTRY");
1288 WRITE_NODE_FIELD(expr);
1289 WRITE_INT_FIELD(resno);
1290 WRITE_STRING_FIELD(resname);
1291 WRITE_UINT_FIELD(ressortgroupref);
1292 WRITE_OID_FIELD(resorigtbl);
1293 WRITE_INT_FIELD(resorigcol);
1294 WRITE_BOOL_FIELD(resjunk);
1298 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1300 WRITE_NODE_TYPE("RANGETBLREF");
1302 WRITE_INT_FIELD(rtindex);
1306 _outJoinExpr(StringInfo str, JoinExpr *node)
1308 WRITE_NODE_TYPE("JOINEXPR");
1310 WRITE_ENUM_FIELD(jointype, JoinType);
1311 WRITE_BOOL_FIELD(isNatural);
1312 WRITE_NODE_FIELD(larg);
1313 WRITE_NODE_FIELD(rarg);
1314 WRITE_NODE_FIELD(usingClause);
1315 WRITE_NODE_FIELD(quals);
1316 WRITE_NODE_FIELD(alias);
1317 WRITE_INT_FIELD(rtindex);
1321 _outFromExpr(StringInfo str, FromExpr *node)
1323 WRITE_NODE_TYPE("FROMEXPR");
1325 WRITE_NODE_FIELD(fromlist);
1326 WRITE_NODE_FIELD(quals);
1329 /*****************************************************************************
1331 * Stuff from relation.h.
1333 *****************************************************************************/
1336 * print the basic stuff of all nodes that inherit from Path
1338 * Note we do NOT print the parent, else we'd be in infinite recursion
1341 _outPathInfo(StringInfo str, Path *node)
1343 WRITE_ENUM_FIELD(pathtype, NodeTag);
1344 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1345 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1346 WRITE_NODE_FIELD(pathkeys);
1350 * print the basic stuff of all nodes that inherit from JoinPath
1353 _outJoinPathInfo(StringInfo str, JoinPath *node)
1355 _outPathInfo(str, (Path *) node);
1357 WRITE_ENUM_FIELD(jointype, JoinType);
1358 WRITE_NODE_FIELD(outerjoinpath);
1359 WRITE_NODE_FIELD(innerjoinpath);
1360 WRITE_NODE_FIELD(joinrestrictinfo);
1364 _outPath(StringInfo str, Path *node)
1366 WRITE_NODE_TYPE("PATH");
1368 _outPathInfo(str, (Path *) node);
1372 _outIndexPath(StringInfo str, IndexPath *node)
1374 WRITE_NODE_TYPE("INDEXPATH");
1376 _outPathInfo(str, (Path *) node);
1378 WRITE_NODE_FIELD(indexinfo);
1379 WRITE_NODE_FIELD(indexclauses);
1380 WRITE_NODE_FIELD(indexquals);
1381 WRITE_BOOL_FIELD(isjoininner);
1382 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1383 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1384 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1385 WRITE_FLOAT_FIELD(rows, "%.0f");
1389 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1391 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1393 _outPathInfo(str, (Path *) node);
1395 WRITE_NODE_FIELD(bitmapqual);
1396 WRITE_BOOL_FIELD(isjoininner);
1397 WRITE_FLOAT_FIELD(rows, "%.0f");
1401 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1403 WRITE_NODE_TYPE("BITMAPANDPATH");
1405 _outPathInfo(str, (Path *) node);
1407 WRITE_NODE_FIELD(bitmapquals);
1408 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1412 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1414 WRITE_NODE_TYPE("BITMAPORPATH");
1416 _outPathInfo(str, (Path *) node);
1418 WRITE_NODE_FIELD(bitmapquals);
1419 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1423 _outTidPath(StringInfo str, TidPath *node)
1425 WRITE_NODE_TYPE("TIDPATH");
1427 _outPathInfo(str, (Path *) node);
1429 WRITE_NODE_FIELD(tidquals);
1433 _outAppendPath(StringInfo str, AppendPath *node)
1435 WRITE_NODE_TYPE("APPENDPATH");
1437 _outPathInfo(str, (Path *) node);
1439 WRITE_NODE_FIELD(subpaths);
1443 _outResultPath(StringInfo str, ResultPath *node)
1445 WRITE_NODE_TYPE("RESULTPATH");
1447 _outPathInfo(str, (Path *) node);
1449 WRITE_NODE_FIELD(quals);
1453 _outMaterialPath(StringInfo str, MaterialPath *node)
1455 WRITE_NODE_TYPE("MATERIALPATH");
1457 _outPathInfo(str, (Path *) node);
1459 WRITE_NODE_FIELD(subpath);
1463 _outUniquePath(StringInfo str, UniquePath *node)
1465 WRITE_NODE_TYPE("UNIQUEPATH");
1467 _outPathInfo(str, (Path *) node);
1469 WRITE_NODE_FIELD(subpath);
1470 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1471 WRITE_NODE_FIELD(in_operators);
1472 WRITE_NODE_FIELD(uniq_exprs);
1473 WRITE_FLOAT_FIELD(rows, "%.0f");
1477 _outNoOpPath(StringInfo str, NoOpPath *node)
1479 WRITE_NODE_TYPE("NOOPPATH");
1481 _outPathInfo(str, (Path *) node);
1483 WRITE_NODE_FIELD(subpath);
1487 _outNestPath(StringInfo str, NestPath *node)
1489 WRITE_NODE_TYPE("NESTPATH");
1491 _outJoinPathInfo(str, (JoinPath *) node);
1495 _outMergePath(StringInfo str, MergePath *node)
1497 WRITE_NODE_TYPE("MERGEPATH");
1499 _outJoinPathInfo(str, (JoinPath *) node);
1501 WRITE_NODE_FIELD(path_mergeclauses);
1502 WRITE_NODE_FIELD(outersortkeys);
1503 WRITE_NODE_FIELD(innersortkeys);
1504 WRITE_BOOL_FIELD(materialize_inner);
1508 _outHashPath(StringInfo str, HashPath *node)
1510 WRITE_NODE_TYPE("HASHPATH");
1512 _outJoinPathInfo(str, (JoinPath *) node);
1514 WRITE_NODE_FIELD(path_hashclauses);
1515 WRITE_INT_FIELD(num_batches);
1519 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1521 WRITE_NODE_TYPE("PLANNERGLOBAL");
1523 /* NB: this isn't a complete set of fields */
1524 WRITE_NODE_FIELD(paramlist);
1525 WRITE_NODE_FIELD(subplans);
1526 WRITE_NODE_FIELD(subrtables);
1527 WRITE_NODE_FIELD(subrowmarks);
1528 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1529 WRITE_NODE_FIELD(finalrtable);
1530 WRITE_NODE_FIELD(finalrowmarks);
1531 WRITE_NODE_FIELD(relationOids);
1532 WRITE_NODE_FIELD(invalItems);
1533 WRITE_UINT_FIELD(lastPHId);
1534 WRITE_BOOL_FIELD(transientPlan);
1538 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1540 WRITE_NODE_TYPE("PLANNERINFO");
1542 /* NB: this isn't a complete set of fields */
1543 WRITE_NODE_FIELD(parse);
1544 WRITE_NODE_FIELD(glob);
1545 WRITE_UINT_FIELD(query_level);
1546 WRITE_NODE_FIELD(join_rel_list);
1547 WRITE_INT_FIELD(join_cur_level);
1548 WRITE_NODE_FIELD(resultRelations);
1549 WRITE_NODE_FIELD(init_plans);
1550 WRITE_NODE_FIELD(cte_plan_ids);
1551 WRITE_NODE_FIELD(eq_classes);
1552 WRITE_NODE_FIELD(canon_pathkeys);
1553 WRITE_NODE_FIELD(left_join_clauses);
1554 WRITE_NODE_FIELD(right_join_clauses);
1555 WRITE_NODE_FIELD(full_join_clauses);
1556 WRITE_NODE_FIELD(join_info_list);
1557 WRITE_NODE_FIELD(append_rel_list);
1558 WRITE_NODE_FIELD(rowMarks);
1559 WRITE_NODE_FIELD(placeholder_list);
1560 WRITE_NODE_FIELD(query_pathkeys);
1561 WRITE_NODE_FIELD(group_pathkeys);
1562 WRITE_NODE_FIELD(window_pathkeys);
1563 WRITE_NODE_FIELD(distinct_pathkeys);
1564 WRITE_NODE_FIELD(sort_pathkeys);
1565 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1566 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1567 WRITE_BOOL_FIELD(hasJoinRTEs);
1568 WRITE_BOOL_FIELD(hasHavingQual);
1569 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1570 WRITE_BOOL_FIELD(hasRecursion);
1571 WRITE_INT_FIELD(wt_param_id);
1575 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1577 WRITE_NODE_TYPE("RELOPTINFO");
1579 /* NB: this isn't a complete set of fields */
1580 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1581 WRITE_BITMAPSET_FIELD(relids);
1582 WRITE_FLOAT_FIELD(rows, "%.0f");
1583 WRITE_INT_FIELD(width);
1584 WRITE_NODE_FIELD(reltargetlist);
1585 WRITE_NODE_FIELD(pathlist);
1586 WRITE_NODE_FIELD(cheapest_startup_path);
1587 WRITE_NODE_FIELD(cheapest_total_path);
1588 WRITE_NODE_FIELD(cheapest_unique_path);
1589 WRITE_UINT_FIELD(relid);
1590 WRITE_ENUM_FIELD(rtekind, RTEKind);
1591 WRITE_INT_FIELD(min_attr);
1592 WRITE_INT_FIELD(max_attr);
1593 WRITE_NODE_FIELD(indexlist);
1594 WRITE_UINT_FIELD(pages);
1595 WRITE_FLOAT_FIELD(tuples, "%.0f");
1596 WRITE_NODE_FIELD(subplan);
1597 WRITE_NODE_FIELD(subrtable);
1598 WRITE_NODE_FIELD(subrowmark);
1599 WRITE_NODE_FIELD(baserestrictinfo);
1600 WRITE_NODE_FIELD(joininfo);
1601 WRITE_BOOL_FIELD(has_eclass_joins);
1602 WRITE_BITMAPSET_FIELD(index_outer_relids);
1603 WRITE_NODE_FIELD(index_inner_paths);
1607 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1609 WRITE_NODE_TYPE("INDEXOPTINFO");
1611 /* NB: this isn't a complete set of fields */
1612 WRITE_OID_FIELD(indexoid);
1613 /* Do NOT print rel field, else infinite recursion */
1614 WRITE_UINT_FIELD(pages);
1615 WRITE_FLOAT_FIELD(tuples, "%.0f");
1616 WRITE_INT_FIELD(ncolumns);
1617 WRITE_NODE_FIELD(indexprs);
1618 WRITE_NODE_FIELD(indpred);
1619 WRITE_BOOL_FIELD(predOK);
1620 WRITE_BOOL_FIELD(unique);
1624 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1627 * To simplify reading, we just chase up to the topmost merged EC and
1628 * print that, without bothering to show the merge-ees separately.
1630 while (node->ec_merged)
1631 node = node->ec_merged;
1633 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1635 WRITE_NODE_FIELD(ec_opfamilies);
1636 WRITE_NODE_FIELD(ec_members);
1637 WRITE_NODE_FIELD(ec_sources);
1638 WRITE_NODE_FIELD(ec_derives);
1639 WRITE_BITMAPSET_FIELD(ec_relids);
1640 WRITE_BOOL_FIELD(ec_has_const);
1641 WRITE_BOOL_FIELD(ec_has_volatile);
1642 WRITE_BOOL_FIELD(ec_below_outer_join);
1643 WRITE_BOOL_FIELD(ec_broken);
1644 WRITE_UINT_FIELD(ec_sortref);
1648 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1650 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1652 WRITE_NODE_FIELD(em_expr);
1653 WRITE_BITMAPSET_FIELD(em_relids);
1654 WRITE_BOOL_FIELD(em_is_const);
1655 WRITE_BOOL_FIELD(em_is_child);
1656 WRITE_OID_FIELD(em_datatype);
1660 _outPathKey(StringInfo str, PathKey *node)
1662 WRITE_NODE_TYPE("PATHKEY");
1664 WRITE_NODE_FIELD(pk_eclass);
1665 WRITE_OID_FIELD(pk_opfamily);
1666 WRITE_INT_FIELD(pk_strategy);
1667 WRITE_BOOL_FIELD(pk_nulls_first);
1671 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1673 WRITE_NODE_TYPE("RESTRICTINFO");
1675 /* NB: this isn't a complete set of fields */
1676 WRITE_NODE_FIELD(clause);
1677 WRITE_BOOL_FIELD(is_pushed_down);
1678 WRITE_BOOL_FIELD(outerjoin_delayed);
1679 WRITE_BOOL_FIELD(can_join);
1680 WRITE_BOOL_FIELD(pseudoconstant);
1681 WRITE_BITMAPSET_FIELD(clause_relids);
1682 WRITE_BITMAPSET_FIELD(required_relids);
1683 WRITE_BITMAPSET_FIELD(nullable_relids);
1684 WRITE_BITMAPSET_FIELD(left_relids);
1685 WRITE_BITMAPSET_FIELD(right_relids);
1686 WRITE_NODE_FIELD(orclause);
1687 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1688 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1689 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1690 WRITE_NODE_FIELD(mergeopfamilies);
1691 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1692 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1693 WRITE_NODE_FIELD(left_em);
1694 WRITE_NODE_FIELD(right_em);
1695 WRITE_BOOL_FIELD(outer_is_left);
1696 WRITE_OID_FIELD(hashjoinoperator);
1700 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1702 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1703 WRITE_BITMAPSET_FIELD(other_relids);
1704 WRITE_BOOL_FIELD(isouterjoin);
1705 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1706 WRITE_NODE_FIELD(cheapest_total_innerpath);
1710 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1712 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1714 WRITE_NODE_FIELD(phexpr);
1715 WRITE_BITMAPSET_FIELD(phrels);
1716 WRITE_UINT_FIELD(phid);
1717 WRITE_UINT_FIELD(phlevelsup);
1721 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1723 WRITE_NODE_TYPE("SPECIALJOININFO");
1725 WRITE_BITMAPSET_FIELD(min_lefthand);
1726 WRITE_BITMAPSET_FIELD(min_righthand);
1727 WRITE_BITMAPSET_FIELD(syn_lefthand);
1728 WRITE_BITMAPSET_FIELD(syn_righthand);
1729 WRITE_ENUM_FIELD(jointype, JoinType);
1730 WRITE_BOOL_FIELD(lhs_strict);
1731 WRITE_BOOL_FIELD(delay_upper_joins);
1732 WRITE_NODE_FIELD(join_quals);
1736 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1738 WRITE_NODE_TYPE("APPENDRELINFO");
1740 WRITE_UINT_FIELD(parent_relid);
1741 WRITE_UINT_FIELD(child_relid);
1742 WRITE_OID_FIELD(parent_reltype);
1743 WRITE_OID_FIELD(child_reltype);
1744 WRITE_NODE_FIELD(translated_vars);
1745 WRITE_OID_FIELD(parent_reloid);
1749 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1751 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1753 WRITE_UINT_FIELD(phid);
1754 WRITE_NODE_FIELD(ph_var);
1755 WRITE_BITMAPSET_FIELD(ph_eval_at);
1756 WRITE_BITMAPSET_FIELD(ph_needed);
1757 WRITE_INT_FIELD(ph_width);
1761 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1763 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1765 WRITE_NODE_FIELD(item);
1766 WRITE_UINT_FIELD(abslevel);
1769 /*****************************************************************************
1771 * Stuff from parsenodes.h.
1773 *****************************************************************************/
1776 _outCreateStmt(StringInfo str, CreateStmt *node)
1778 WRITE_NODE_TYPE("CREATESTMT");
1780 WRITE_NODE_FIELD(relation);
1781 WRITE_NODE_FIELD(tableElts);
1782 WRITE_NODE_FIELD(inhRelations);
1783 WRITE_NODE_FIELD(constraints);
1784 WRITE_NODE_FIELD(options);
1785 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1786 WRITE_STRING_FIELD(tablespacename);
1790 _outIndexStmt(StringInfo str, IndexStmt *node)
1792 WRITE_NODE_TYPE("INDEXSTMT");
1794 WRITE_STRING_FIELD(idxname);
1795 WRITE_NODE_FIELD(relation);
1796 WRITE_STRING_FIELD(accessMethod);
1797 WRITE_STRING_FIELD(tableSpace);
1798 WRITE_NODE_FIELD(indexParams);
1799 WRITE_NODE_FIELD(options);
1800 WRITE_NODE_FIELD(whereClause);
1801 WRITE_NODE_FIELD(excludeOpNames);
1802 WRITE_BOOL_FIELD(unique);
1803 WRITE_BOOL_FIELD(primary);
1804 WRITE_BOOL_FIELD(isconstraint);
1805 WRITE_BOOL_FIELD(deferrable);
1806 WRITE_BOOL_FIELD(initdeferred);
1807 WRITE_BOOL_FIELD(concurrent);
1811 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1813 WRITE_NODE_TYPE("NOTIFY");
1815 WRITE_STRING_FIELD(conditionname);
1819 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1821 WRITE_NODE_TYPE("DECLARECURSOR");
1823 WRITE_STRING_FIELD(portalname);
1824 WRITE_INT_FIELD(options);
1825 WRITE_NODE_FIELD(query);
1829 _outSelectStmt(StringInfo str, SelectStmt *node)
1831 WRITE_NODE_TYPE("SELECT");
1833 WRITE_NODE_FIELD(distinctClause);
1834 WRITE_NODE_FIELD(intoClause);
1835 WRITE_NODE_FIELD(targetList);
1836 WRITE_NODE_FIELD(fromClause);
1837 WRITE_NODE_FIELD(whereClause);
1838 WRITE_NODE_FIELD(groupClause);
1839 WRITE_NODE_FIELD(havingClause);
1840 WRITE_NODE_FIELD(windowClause);
1841 WRITE_NODE_FIELD(withClause);
1842 WRITE_NODE_FIELD(valuesLists);
1843 WRITE_NODE_FIELD(sortClause);
1844 WRITE_NODE_FIELD(limitOffset);
1845 WRITE_NODE_FIELD(limitCount);
1846 WRITE_NODE_FIELD(lockingClause);
1847 WRITE_ENUM_FIELD(op, SetOperation);
1848 WRITE_BOOL_FIELD(all);
1849 WRITE_NODE_FIELD(larg);
1850 WRITE_NODE_FIELD(rarg);
1854 _outFuncCall(StringInfo str, FuncCall *node)
1856 WRITE_NODE_TYPE("FUNCCALL");
1858 WRITE_NODE_FIELD(funcname);
1859 WRITE_NODE_FIELD(args);
1860 WRITE_BOOL_FIELD(agg_star);
1861 WRITE_BOOL_FIELD(agg_distinct);
1862 WRITE_BOOL_FIELD(func_variadic);
1863 WRITE_NODE_FIELD(over);
1864 WRITE_LOCATION_FIELD(location);
1868 _outDefElem(StringInfo str, DefElem *node)
1870 WRITE_NODE_TYPE("DEFELEM");
1872 WRITE_STRING_FIELD(defnamespace);
1873 WRITE_STRING_FIELD(defname);
1874 WRITE_NODE_FIELD(arg);
1875 WRITE_ENUM_FIELD(defaction, DefElemAction);
1879 _outLockingClause(StringInfo str, LockingClause *node)
1881 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1883 WRITE_NODE_FIELD(lockedRels);
1884 WRITE_BOOL_FIELD(forUpdate);
1885 WRITE_BOOL_FIELD(noWait);
1889 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1891 WRITE_NODE_TYPE("XMLSERIALIZE");
1893 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1894 WRITE_NODE_FIELD(expr);
1895 WRITE_NODE_FIELD(typeName);
1896 WRITE_LOCATION_FIELD(location);
1900 _outColumnDef(StringInfo str, ColumnDef *node)
1902 WRITE_NODE_TYPE("COLUMNDEF");
1904 WRITE_STRING_FIELD(colname);
1905 WRITE_NODE_FIELD(typeName);
1906 WRITE_INT_FIELD(inhcount);
1907 WRITE_BOOL_FIELD(is_local);
1908 WRITE_BOOL_FIELD(is_not_null);
1909 WRITE_INT_FIELD(storage);
1910 WRITE_NODE_FIELD(raw_default);
1911 WRITE_NODE_FIELD(cooked_default);
1912 WRITE_NODE_FIELD(constraints);
1916 _outTypeName(StringInfo str, TypeName *node)
1918 WRITE_NODE_TYPE("TYPENAME");
1920 WRITE_NODE_FIELD(names);
1921 WRITE_OID_FIELD(typeOid);
1922 WRITE_BOOL_FIELD(setof);
1923 WRITE_BOOL_FIELD(pct_type);
1924 WRITE_NODE_FIELD(typmods);
1925 WRITE_INT_FIELD(typemod);
1926 WRITE_NODE_FIELD(arrayBounds);
1927 WRITE_LOCATION_FIELD(location);
1931 _outTypeCast(StringInfo str, TypeCast *node)
1933 WRITE_NODE_TYPE("TYPECAST");
1935 WRITE_NODE_FIELD(arg);
1936 WRITE_NODE_FIELD(typeName);
1937 WRITE_LOCATION_FIELD(location);
1941 _outIndexElem(StringInfo str, IndexElem *node)
1943 WRITE_NODE_TYPE("INDEXELEM");
1945 WRITE_STRING_FIELD(name);
1946 WRITE_NODE_FIELD(expr);
1947 WRITE_NODE_FIELD(opclass);
1948 WRITE_ENUM_FIELD(ordering, SortByDir);
1949 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1953 _outQuery(StringInfo str, Query *node)
1955 WRITE_NODE_TYPE("QUERY");
1957 WRITE_ENUM_FIELD(commandType, CmdType);
1958 WRITE_ENUM_FIELD(querySource, QuerySource);
1959 WRITE_BOOL_FIELD(canSetTag);
1962 * Hack to work around missing outfuncs routines for a lot of the
1963 * utility-statement node types. (The only one we actually *need* for
1964 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1965 * for the meantime do this to avoid getting lots of warnings when running
1966 * with debug_print_parse on.
1968 if (node->utilityStmt)
1970 switch (nodeTag(node->utilityStmt))
1975 case T_DeclareCursorStmt:
1976 WRITE_NODE_FIELD(utilityStmt);
1979 appendStringInfo(str, " :utilityStmt ?");
1984 appendStringInfo(str, " :utilityStmt <>");
1986 WRITE_INT_FIELD(resultRelation);
1987 WRITE_NODE_FIELD(intoClause);
1988 WRITE_BOOL_FIELD(hasAggs);
1989 WRITE_BOOL_FIELD(hasWindowFuncs);
1990 WRITE_BOOL_FIELD(hasSubLinks);
1991 WRITE_BOOL_FIELD(hasDistinctOn);
1992 WRITE_BOOL_FIELD(hasRecursive);
1993 WRITE_BOOL_FIELD(hasForUpdate);
1994 WRITE_NODE_FIELD(cteList);
1995 WRITE_NODE_FIELD(rtable);
1996 WRITE_NODE_FIELD(jointree);
1997 WRITE_NODE_FIELD(targetList);
1998 WRITE_NODE_FIELD(returningList);
1999 WRITE_NODE_FIELD(groupClause);
2000 WRITE_NODE_FIELD(havingQual);
2001 WRITE_NODE_FIELD(windowClause);
2002 WRITE_NODE_FIELD(distinctClause);
2003 WRITE_NODE_FIELD(sortClause);
2004 WRITE_NODE_FIELD(limitOffset);
2005 WRITE_NODE_FIELD(limitCount);
2006 WRITE_NODE_FIELD(rowMarks);
2007 WRITE_NODE_FIELD(setOperations);
2011 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2013 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2015 WRITE_UINT_FIELD(tleSortGroupRef);
2016 WRITE_OID_FIELD(eqop);
2017 WRITE_OID_FIELD(sortop);
2018 WRITE_BOOL_FIELD(nulls_first);
2022 _outWindowClause(StringInfo str, WindowClause *node)
2024 WRITE_NODE_TYPE("WINDOWCLAUSE");
2026 WRITE_STRING_FIELD(name);
2027 WRITE_STRING_FIELD(refname);
2028 WRITE_NODE_FIELD(partitionClause);
2029 WRITE_NODE_FIELD(orderClause);
2030 WRITE_INT_FIELD(frameOptions);
2031 WRITE_UINT_FIELD(winref);
2032 WRITE_BOOL_FIELD(copiedOrder);
2036 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2038 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2040 WRITE_UINT_FIELD(rti);
2041 WRITE_BOOL_FIELD(forUpdate);
2042 WRITE_BOOL_FIELD(noWait);
2043 WRITE_BOOL_FIELD(pushedDown);
2047 _outWithClause(StringInfo str, WithClause *node)
2049 WRITE_NODE_TYPE("WITHCLAUSE");
2051 WRITE_NODE_FIELD(ctes);
2052 WRITE_BOOL_FIELD(recursive);
2053 WRITE_LOCATION_FIELD(location);
2057 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2059 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2061 WRITE_STRING_FIELD(ctename);
2062 WRITE_NODE_FIELD(aliascolnames);
2063 WRITE_NODE_FIELD(ctequery);
2064 WRITE_LOCATION_FIELD(location);
2065 WRITE_BOOL_FIELD(cterecursive);
2066 WRITE_INT_FIELD(cterefcount);
2067 WRITE_NODE_FIELD(ctecolnames);
2068 WRITE_NODE_FIELD(ctecoltypes);
2069 WRITE_NODE_FIELD(ctecoltypmods);
2073 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2075 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2077 WRITE_ENUM_FIELD(op, SetOperation);
2078 WRITE_BOOL_FIELD(all);
2079 WRITE_NODE_FIELD(larg);
2080 WRITE_NODE_FIELD(rarg);
2081 WRITE_NODE_FIELD(colTypes);
2082 WRITE_NODE_FIELD(colTypmods);
2083 WRITE_NODE_FIELD(groupClauses);
2087 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2089 WRITE_NODE_TYPE("RTE");
2091 /* put alias + eref first to make dump more legible */
2092 WRITE_NODE_FIELD(alias);
2093 WRITE_NODE_FIELD(eref);
2094 WRITE_ENUM_FIELD(rtekind, RTEKind);
2096 switch (node->rtekind)
2100 WRITE_OID_FIELD(relid);
2103 WRITE_NODE_FIELD(subquery);
2106 WRITE_ENUM_FIELD(jointype, JoinType);
2107 WRITE_NODE_FIELD(joinaliasvars);
2110 WRITE_NODE_FIELD(funcexpr);
2111 WRITE_NODE_FIELD(funccoltypes);
2112 WRITE_NODE_FIELD(funccoltypmods);
2115 WRITE_NODE_FIELD(values_lists);
2118 WRITE_STRING_FIELD(ctename);
2119 WRITE_UINT_FIELD(ctelevelsup);
2120 WRITE_BOOL_FIELD(self_reference);
2121 WRITE_NODE_FIELD(ctecoltypes);
2122 WRITE_NODE_FIELD(ctecoltypmods);
2125 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2129 WRITE_BOOL_FIELD(inh);
2130 WRITE_BOOL_FIELD(inFromCl);
2131 WRITE_UINT_FIELD(requiredPerms);
2132 WRITE_OID_FIELD(checkAsUser);
2133 WRITE_BITMAPSET_FIELD(selectedCols);
2134 WRITE_BITMAPSET_FIELD(modifiedCols);
2138 _outAExpr(StringInfo str, A_Expr *node)
2140 WRITE_NODE_TYPE("AEXPR");
2145 appendStringInfo(str, " ");
2146 WRITE_NODE_FIELD(name);
2149 appendStringInfo(str, " AND");
2152 appendStringInfo(str, " OR");
2155 appendStringInfo(str, " NOT");
2158 appendStringInfo(str, " ");
2159 WRITE_NODE_FIELD(name);
2160 appendStringInfo(str, " ANY ");
2163 appendStringInfo(str, " ");
2164 WRITE_NODE_FIELD(name);
2165 appendStringInfo(str, " ALL ");
2167 case AEXPR_DISTINCT:
2168 appendStringInfo(str, " DISTINCT ");
2169 WRITE_NODE_FIELD(name);
2172 appendStringInfo(str, " NULLIF ");
2173 WRITE_NODE_FIELD(name);
2176 appendStringInfo(str, " OF ");
2177 WRITE_NODE_FIELD(name);
2180 appendStringInfo(str, " IN ");
2181 WRITE_NODE_FIELD(name);
2184 appendStringInfo(str, " ??");
2188 WRITE_NODE_FIELD(lexpr);
2189 WRITE_NODE_FIELD(rexpr);
2190 WRITE_LOCATION_FIELD(location);
2194 _outValue(StringInfo str, Value *value)
2196 switch (value->type)
2199 appendStringInfo(str, "%ld", value->val.ival);
2204 * We assume the value is a valid numeric literal and so does not
2207 appendStringInfoString(str, value->val.str);
2210 appendStringInfoChar(str, '"');
2211 _outToken(str, value->val.str);
2212 appendStringInfoChar(str, '"');
2215 /* internal representation already has leading 'b' */
2216 appendStringInfoString(str, value->val.str);
2219 /* this is seen only within A_Const, not in transformed trees */
2220 appendStringInfoString(str, "NULL");
2223 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2229 _outColumnRef(StringInfo str, ColumnRef *node)
2231 WRITE_NODE_TYPE("COLUMNREF");
2233 WRITE_NODE_FIELD(fields);
2234 WRITE_LOCATION_FIELD(location);
2238 _outParamRef(StringInfo str, ParamRef *node)
2240 WRITE_NODE_TYPE("PARAMREF");
2242 WRITE_INT_FIELD(number);
2243 WRITE_LOCATION_FIELD(location);
2247 _outAConst(StringInfo str, A_Const *node)
2249 WRITE_NODE_TYPE("A_CONST");
2251 appendStringInfo(str, " :val ");
2252 _outValue(str, &(node->val));
2253 WRITE_LOCATION_FIELD(location);
2257 _outA_Star(StringInfo str, A_Star *node)
2259 WRITE_NODE_TYPE("A_STAR");
2263 _outA_Indices(StringInfo str, A_Indices *node)
2265 WRITE_NODE_TYPE("A_INDICES");
2267 WRITE_NODE_FIELD(lidx);
2268 WRITE_NODE_FIELD(uidx);
2272 _outA_Indirection(StringInfo str, A_Indirection *node)
2274 WRITE_NODE_TYPE("A_INDIRECTION");
2276 WRITE_NODE_FIELD(arg);
2277 WRITE_NODE_FIELD(indirection);
2281 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2283 WRITE_NODE_TYPE("A_ARRAYEXPR");
2285 WRITE_NODE_FIELD(elements);
2286 WRITE_LOCATION_FIELD(location);
2290 _outResTarget(StringInfo str, ResTarget *node)
2292 WRITE_NODE_TYPE("RESTARGET");
2294 WRITE_STRING_FIELD(name);
2295 WRITE_NODE_FIELD(indirection);
2296 WRITE_NODE_FIELD(val);
2297 WRITE_LOCATION_FIELD(location);
2301 _outSortBy(StringInfo str, SortBy *node)
2303 WRITE_NODE_TYPE("SORTBY");
2305 WRITE_NODE_FIELD(node);
2306 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2307 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2308 WRITE_NODE_FIELD(useOp);
2309 WRITE_LOCATION_FIELD(location);
2313 _outWindowDef(StringInfo str, WindowDef *node)
2315 WRITE_NODE_TYPE("WINDOWDEF");
2317 WRITE_STRING_FIELD(name);
2318 WRITE_STRING_FIELD(refname);
2319 WRITE_NODE_FIELD(partitionClause);
2320 WRITE_NODE_FIELD(orderClause);
2321 WRITE_INT_FIELD(frameOptions);
2322 WRITE_LOCATION_FIELD(location);
2326 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2328 WRITE_NODE_TYPE("RANGESUBSELECT");
2330 WRITE_NODE_FIELD(subquery);
2331 WRITE_NODE_FIELD(alias);
2335 _outRangeFunction(StringInfo str, RangeFunction *node)
2337 WRITE_NODE_TYPE("RANGEFUNCTION");
2339 WRITE_NODE_FIELD(funccallnode);
2340 WRITE_NODE_FIELD(alias);
2341 WRITE_NODE_FIELD(coldeflist);
2345 _outConstraint(StringInfo str, Constraint *node)
2347 WRITE_NODE_TYPE("CONSTRAINT");
2349 WRITE_STRING_FIELD(conname);
2350 WRITE_BOOL_FIELD(deferrable);
2351 WRITE_BOOL_FIELD(initdeferred);
2352 WRITE_LOCATION_FIELD(location);
2354 appendStringInfo(str, " :contype ");
2355 switch (node->contype)
2358 appendStringInfo(str, "NULL");
2361 case CONSTR_NOTNULL:
2362 appendStringInfo(str, "NOT_NULL");
2365 case CONSTR_DEFAULT:
2366 appendStringInfo(str, "DEFAULT");
2367 WRITE_NODE_FIELD(raw_expr);
2368 WRITE_STRING_FIELD(cooked_expr);
2372 appendStringInfo(str, "CHECK");
2373 WRITE_NODE_FIELD(raw_expr);
2374 WRITE_STRING_FIELD(cooked_expr);
2377 case CONSTR_PRIMARY:
2378 appendStringInfo(str, "PRIMARY_KEY");
2379 WRITE_NODE_FIELD(keys);
2380 WRITE_NODE_FIELD(options);
2381 WRITE_STRING_FIELD(indexspace);
2382 /* access_method and where_clause not currently used */
2386 appendStringInfo(str, "UNIQUE");
2387 WRITE_NODE_FIELD(keys);
2388 WRITE_NODE_FIELD(options);
2389 WRITE_STRING_FIELD(indexspace);
2390 /* access_method and where_clause not currently used */
2393 case CONSTR_EXCLUSION:
2394 appendStringInfo(str, "EXCLUSION");
2395 WRITE_NODE_FIELD(exclusions);
2396 WRITE_NODE_FIELD(options);
2397 WRITE_STRING_FIELD(indexspace);
2398 WRITE_STRING_FIELD(access_method);
2399 WRITE_NODE_FIELD(where_clause);
2402 case CONSTR_FOREIGN:
2403 appendStringInfo(str, "FOREIGN_KEY");
2404 WRITE_NODE_FIELD(pktable);
2405 WRITE_NODE_FIELD(fk_attrs);
2406 WRITE_NODE_FIELD(pk_attrs);
2407 WRITE_CHAR_FIELD(fk_matchtype);
2408 WRITE_CHAR_FIELD(fk_upd_action);
2409 WRITE_CHAR_FIELD(fk_del_action);
2410 WRITE_BOOL_FIELD(skip_validation);
2413 case CONSTR_ATTR_DEFERRABLE:
2414 appendStringInfo(str, "ATTR_DEFERRABLE");
2417 case CONSTR_ATTR_NOT_DEFERRABLE:
2418 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2421 case CONSTR_ATTR_DEFERRED:
2422 appendStringInfo(str, "ATTR_DEFERRED");
2425 case CONSTR_ATTR_IMMEDIATE:
2426 appendStringInfo(str, "ATTR_IMMEDIATE");
2430 appendStringInfo(str, "<unrecognized_constraint %d>",
2431 (int) node->contype);
2439 * converts a Node into ascii string and append it to 'str'
2442 _outNode(StringInfo str, void *obj)
2445 appendStringInfo(str, "<>");
2446 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2448 else if (IsA(obj, Integer) ||
2451 IsA(obj, BitString))
2453 /* nodeRead does not want to see { } around these! */
2454 _outValue(str, obj);
2458 appendStringInfoChar(str, '{');
2459 switch (nodeTag(obj))
2462 _outPlannedStmt(str, obj);
2468 _outResult(str, obj);
2471 _outModifyTable(str, obj);
2474 _outAppend(str, obj);
2476 case T_RecursiveUnion:
2477 _outRecursiveUnion(str, obj);
2480 _outBitmapAnd(str, obj);
2483 _outBitmapOr(str, obj);
2489 _outSeqScan(str, obj);
2492 _outIndexScan(str, obj);
2494 case T_BitmapIndexScan:
2495 _outBitmapIndexScan(str, obj);
2497 case T_BitmapHeapScan:
2498 _outBitmapHeapScan(str, obj);
2501 _outTidScan(str, obj);
2503 case T_SubqueryScan:
2504 _outSubqueryScan(str, obj);
2506 case T_FunctionScan:
2507 _outFunctionScan(str, obj);
2510 _outValuesScan(str, obj);
2513 _outCteScan(str, obj);
2515 case T_WorkTableScan:
2516 _outWorkTableScan(str, obj);
2522 _outNestLoop(str, obj);
2525 _outMergeJoin(str, obj);
2528 _outHashJoin(str, obj);
2534 _outWindowAgg(str, obj);
2537 _outGroup(str, obj);
2540 _outMaterial(str, obj);
2546 _outUnique(str, obj);
2552 _outSetOp(str, obj);
2555 _outLockRows(str, obj);
2558 _outLimit(str, obj);
2561 _outPlanRowMark(str, obj);
2563 case T_PlanInvalItem:
2564 _outPlanInvalItem(str, obj);
2567 _outAlias(str, obj);
2570 _outRangeVar(str, obj);
2573 _outIntoClause(str, obj);
2579 _outConst(str, obj);
2582 _outParam(str, obj);
2585 _outAggref(str, obj);
2588 _outWindowFunc(str, obj);
2591 _outArrayRef(str, obj);
2594 _outFuncExpr(str, obj);
2596 case T_NamedArgExpr:
2597 _outNamedArgExpr(str, obj);
2600 _outOpExpr(str, obj);
2602 case T_DistinctExpr:
2603 _outDistinctExpr(str, obj);
2605 case T_ScalarArrayOpExpr:
2606 _outScalarArrayOpExpr(str, obj);
2609 _outBoolExpr(str, obj);
2612 _outSubLink(str, obj);
2615 _outSubPlan(str, obj);
2617 case T_AlternativeSubPlan:
2618 _outAlternativeSubPlan(str, obj);
2621 _outFieldSelect(str, obj);
2624 _outFieldStore(str, obj);
2627 _outRelabelType(str, obj);
2630 _outCoerceViaIO(str, obj);
2632 case T_ArrayCoerceExpr:
2633 _outArrayCoerceExpr(str, obj);
2635 case T_ConvertRowtypeExpr:
2636 _outConvertRowtypeExpr(str, obj);
2639 _outCaseExpr(str, obj);
2642 _outCaseWhen(str, obj);
2644 case T_CaseTestExpr:
2645 _outCaseTestExpr(str, obj);
2648 _outArrayExpr(str, obj);
2651 _outRowExpr(str, obj);
2653 case T_RowCompareExpr:
2654 _outRowCompareExpr(str, obj);
2656 case T_CoalesceExpr:
2657 _outCoalesceExpr(str, obj);
2660 _outMinMaxExpr(str, obj);
2663 _outXmlExpr(str, obj);
2666 _outNullIfExpr(str, obj);
2669 _outNullTest(str, obj);
2672 _outBooleanTest(str, obj);
2674 case T_CoerceToDomain:
2675 _outCoerceToDomain(str, obj);
2677 case T_CoerceToDomainValue:
2678 _outCoerceToDomainValue(str, obj);
2680 case T_SetToDefault:
2681 _outSetToDefault(str, obj);
2683 case T_CurrentOfExpr:
2684 _outCurrentOfExpr(str, obj);
2687 _outTargetEntry(str, obj);
2690 _outRangeTblRef(str, obj);
2693 _outJoinExpr(str, obj);
2696 _outFromExpr(str, obj);
2703 _outIndexPath(str, obj);
2705 case T_BitmapHeapPath:
2706 _outBitmapHeapPath(str, obj);
2708 case T_BitmapAndPath:
2709 _outBitmapAndPath(str, obj);
2711 case T_BitmapOrPath:
2712 _outBitmapOrPath(str, obj);
2715 _outTidPath(str, obj);
2718 _outAppendPath(str, obj);
2721 _outResultPath(str, obj);
2723 case T_MaterialPath:
2724 _outMaterialPath(str, obj);
2727 _outUniquePath(str, obj);
2730 _outNoOpPath(str, obj);
2733 _outNestPath(str, obj);
2736 _outMergePath(str, obj);
2739 _outHashPath(str, obj);
2741 case T_PlannerGlobal:
2742 _outPlannerGlobal(str, obj);
2745 _outPlannerInfo(str, obj);
2748 _outRelOptInfo(str, obj);
2750 case T_IndexOptInfo:
2751 _outIndexOptInfo(str, obj);
2753 case T_EquivalenceClass:
2754 _outEquivalenceClass(str, obj);
2756 case T_EquivalenceMember:
2757 _outEquivalenceMember(str, obj);
2760 _outPathKey(str, obj);
2762 case T_RestrictInfo:
2763 _outRestrictInfo(str, obj);
2765 case T_InnerIndexscanInfo:
2766 _outInnerIndexscanInfo(str, obj);
2768 case T_PlaceHolderVar:
2769 _outPlaceHolderVar(str, obj);
2771 case T_SpecialJoinInfo:
2772 _outSpecialJoinInfo(str, obj);
2774 case T_AppendRelInfo:
2775 _outAppendRelInfo(str, obj);
2777 case T_PlaceHolderInfo:
2778 _outPlaceHolderInfo(str, obj);
2780 case T_PlannerParamItem:
2781 _outPlannerParamItem(str, obj);
2785 _outCreateStmt(str, obj);
2788 _outIndexStmt(str, obj);
2791 _outNotifyStmt(str, obj);
2793 case T_DeclareCursorStmt:
2794 _outDeclareCursorStmt(str, obj);
2797 _outSelectStmt(str, obj);
2800 _outColumnDef(str, obj);
2803 _outTypeName(str, obj);
2806 _outTypeCast(str, obj);
2809 _outIndexElem(str, obj);
2812 _outQuery(str, obj);
2814 case T_SortGroupClause:
2815 _outSortGroupClause(str, obj);
2817 case T_WindowClause:
2818 _outWindowClause(str, obj);
2820 case T_RowMarkClause:
2821 _outRowMarkClause(str, obj);
2824 _outWithClause(str, obj);
2826 case T_CommonTableExpr:
2827 _outCommonTableExpr(str, obj);
2829 case T_SetOperationStmt:
2830 _outSetOperationStmt(str, obj);
2832 case T_RangeTblEntry:
2833 _outRangeTblEntry(str, obj);
2836 _outAExpr(str, obj);
2839 _outColumnRef(str, obj);
2842 _outParamRef(str, obj);
2845 _outAConst(str, obj);
2848 _outA_Star(str, obj);
2851 _outA_Indices(str, obj);
2853 case T_A_Indirection:
2854 _outA_Indirection(str, obj);
2857 _outA_ArrayExpr(str, obj);
2860 _outResTarget(str, obj);
2863 _outSortBy(str, obj);
2866 _outWindowDef(str, obj);
2868 case T_RangeSubselect:
2869 _outRangeSubselect(str, obj);
2871 case T_RangeFunction:
2872 _outRangeFunction(str, obj);
2875 _outConstraint(str, obj);
2878 _outFuncCall(str, obj);
2881 _outDefElem(str, obj);
2883 case T_LockingClause:
2884 _outLockingClause(str, obj);
2886 case T_XmlSerialize:
2887 _outXmlSerialize(str, obj);
2893 * This should be an ERROR, but it's too useful to be able to
2894 * dump structures that _outNode only understands part of.
2896 elog(WARNING, "could not dump unrecognized node type: %d",
2897 (int) nodeTag(obj));
2900 appendStringInfoChar(str, '}');
2906 * returns the ascii representation of the Node as a palloc'd string
2909 nodeToString(void *obj)
2913 /* see stringinfo.h for an explanation of this maneuver */
2914 initStringInfo(&str);
2915 _outNode(&str, obj);