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.368 2009/10/12 18:10:45 tgl Exp $
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify output of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire conventions about the names of the local variables in an Out
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41 appendStringInfoString(str, nodelabel)
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47 /* Write an unsigned integer field (anything written as ":fldname %u") */
48 #define WRITE_UINT_FIELD(fldname) \
49 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
51 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
52 #define WRITE_OID_FIELD(fldname) \
53 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
68 /* Write a float field --- caller must give format to define precision */
69 #define WRITE_FLOAT_FIELD(fldname,format) \
70 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75 booltostr(node->fldname))
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 _outToken(str, node->fldname))
82 /* Write a parse location field (actually same as INT case) */
83 #define WRITE_LOCATION_FIELD(fldname) \
84 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
86 /* Write a Node field */
87 #define WRITE_NODE_FIELD(fldname) \
88 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
89 _outNode(str, node->fldname))
91 /* Write a bitmapset field */
92 #define WRITE_BITMAPSET_FIELD(fldname) \
93 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
94 _outBitmapset(str, node->fldname))
97 #define booltostr(x) ((x) ? "true" : "false")
99 static void _outNode(StringInfo str, void *obj);
104 * Convert an ordinary string (eg, an identifier) into a form that
105 * will be decoded back to a plain token by read.c's functions.
107 * If a null or empty string is given, it is encoded as "<>".
110 _outToken(StringInfo str, char *s)
112 if (s == NULL || *s == '\0')
114 appendStringInfo(str, "<>");
119 * Look for characters or patterns that are treated specially by read.c
120 * (either in pg_strtok() or in nodeRead()), and therefore need a
121 * protective backslash.
123 /* These characters only need to be quoted at the start of the string */
126 isdigit((unsigned char) *s) ||
127 ((*s == '+' || *s == '-') &&
128 (isdigit((unsigned char) s[1]) || s[1] == '.')))
129 appendStringInfoChar(str, '\\');
132 /* These chars must be backslashed anywhere in the string */
133 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
136 appendStringInfoChar(str, '\\');
137 appendStringInfoChar(str, *s++);
142 _outList(StringInfo str, List *node)
146 appendStringInfoChar(str, '(');
148 if (IsA(node, IntList))
149 appendStringInfoChar(str, 'i');
150 else if (IsA(node, OidList))
151 appendStringInfoChar(str, 'o');
156 * For the sake of backward compatibility, we emit a slightly
157 * different whitespace format for lists of nodes vs. other types of
158 * lists. XXX: is this necessary?
162 _outNode(str, lfirst(lc));
164 appendStringInfoChar(str, ' ');
166 else if (IsA(node, IntList))
167 appendStringInfo(str, " %d", lfirst_int(lc));
168 else if (IsA(node, OidList))
169 appendStringInfo(str, " %u", lfirst_oid(lc));
171 elog(ERROR, "unrecognized list node type: %d",
175 appendStringInfoChar(str, ')');
180 * converts a bitmap set of integers
182 * Note: the output format is "(b int int ...)", similar to an integer List.
185 _outBitmapset(StringInfo str, Bitmapset *bms)
190 appendStringInfoChar(str, '(');
191 appendStringInfoChar(str, 'b');
192 tmpset = bms_copy(bms);
193 while ((x = bms_first_member(tmpset)) >= 0)
194 appendStringInfo(str, " %d", x);
196 appendStringInfoChar(str, ')');
200 * Print the value of a Datum given its type.
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
209 length = datumGetSize(value, typbyval, typlen);
213 s = (char *) (&value);
214 appendStringInfo(str, "%u [ ", (unsigned int) length);
215 for (i = 0; i < (Size) sizeof(Datum); i++)
216 appendStringInfo(str, "%d ", (int) (s[i]));
217 appendStringInfo(str, "]");
221 s = (char *) DatumGetPointer(value);
222 if (!PointerIsValid(s))
223 appendStringInfo(str, "0 [ ]");
226 appendStringInfo(str, "%u [ ", (unsigned int) length);
227 for (i = 0; i < length; i++)
228 appendStringInfo(str, "%d ", (int) (s[i]));
229 appendStringInfo(str, "]");
236 * Stuff from plannodes.h
240 _outPlannedStmt(StringInfo str, PlannedStmt *node)
242 WRITE_NODE_TYPE("PLANNEDSTMT");
244 WRITE_ENUM_FIELD(commandType, CmdType);
245 WRITE_BOOL_FIELD(hasReturning);
246 WRITE_BOOL_FIELD(canSetTag);
247 WRITE_NODE_FIELD(planTree);
248 WRITE_NODE_FIELD(rtable);
249 WRITE_NODE_FIELD(resultRelations);
250 WRITE_NODE_FIELD(utilityStmt);
251 WRITE_NODE_FIELD(intoClause);
252 WRITE_NODE_FIELD(subplans);
253 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
254 WRITE_NODE_FIELD(rowMarks);
255 WRITE_NODE_FIELD(relationOids);
256 WRITE_NODE_FIELD(invalItems);
257 WRITE_INT_FIELD(nParamExec);
261 * print the basic stuff of all nodes that inherit from Plan
264 _outPlanInfo(StringInfo str, Plan *node)
266 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
267 WRITE_FLOAT_FIELD(total_cost, "%.2f");
268 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
269 WRITE_INT_FIELD(plan_width);
270 WRITE_NODE_FIELD(targetlist);
271 WRITE_NODE_FIELD(qual);
272 WRITE_NODE_FIELD(lefttree);
273 WRITE_NODE_FIELD(righttree);
274 WRITE_NODE_FIELD(initPlan);
275 WRITE_BITMAPSET_FIELD(extParam);
276 WRITE_BITMAPSET_FIELD(allParam);
280 * print the basic stuff of all nodes that inherit from Scan
283 _outScanInfo(StringInfo str, Scan *node)
285 _outPlanInfo(str, (Plan *) node);
287 WRITE_UINT_FIELD(scanrelid);
291 * print the basic stuff of all nodes that inherit from Join
294 _outJoinPlanInfo(StringInfo str, Join *node)
296 _outPlanInfo(str, (Plan *) node);
298 WRITE_ENUM_FIELD(jointype, JoinType);
299 WRITE_NODE_FIELD(joinqual);
304 _outPlan(StringInfo str, Plan *node)
306 WRITE_NODE_TYPE("PLAN");
308 _outPlanInfo(str, (Plan *) node);
312 _outResult(StringInfo str, Result *node)
314 WRITE_NODE_TYPE("RESULT");
316 _outPlanInfo(str, (Plan *) node);
318 WRITE_NODE_FIELD(resconstantqual);
322 _outModifyTable(StringInfo str, ModifyTable *node)
324 WRITE_NODE_TYPE("MODIFYTABLE");
326 _outPlanInfo(str, (Plan *) node);
328 WRITE_ENUM_FIELD(operation, CmdType);
329 WRITE_NODE_FIELD(resultRelations);
330 WRITE_NODE_FIELD(plans);
331 WRITE_NODE_FIELD(returningLists);
335 _outAppend(StringInfo str, Append *node)
337 WRITE_NODE_TYPE("APPEND");
339 _outPlanInfo(str, (Plan *) node);
341 WRITE_NODE_FIELD(appendplans);
345 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
349 WRITE_NODE_TYPE("RECURSIVEUNION");
351 _outPlanInfo(str, (Plan *) node);
353 WRITE_INT_FIELD(wtParam);
354 WRITE_INT_FIELD(numCols);
356 appendStringInfo(str, " :dupColIdx");
357 for (i = 0; i < node->numCols; i++)
358 appendStringInfo(str, " %d", node->dupColIdx[i]);
360 appendStringInfo(str, " :dupOperators");
361 for (i = 0; i < node->numCols; i++)
362 appendStringInfo(str, " %u", node->dupOperators[i]);
364 WRITE_LONG_FIELD(numGroups);
368 _outBitmapAnd(StringInfo str, BitmapAnd *node)
370 WRITE_NODE_TYPE("BITMAPAND");
372 _outPlanInfo(str, (Plan *) node);
374 WRITE_NODE_FIELD(bitmapplans);
378 _outBitmapOr(StringInfo str, BitmapOr *node)
380 WRITE_NODE_TYPE("BITMAPOR");
382 _outPlanInfo(str, (Plan *) node);
384 WRITE_NODE_FIELD(bitmapplans);
388 _outScan(StringInfo str, Scan *node)
390 WRITE_NODE_TYPE("SCAN");
392 _outScanInfo(str, (Scan *) node);
396 _outSeqScan(StringInfo str, SeqScan *node)
398 WRITE_NODE_TYPE("SEQSCAN");
400 _outScanInfo(str, (Scan *) node);
404 _outIndexScan(StringInfo str, IndexScan *node)
406 WRITE_NODE_TYPE("INDEXSCAN");
408 _outScanInfo(str, (Scan *) node);
410 WRITE_OID_FIELD(indexid);
411 WRITE_NODE_FIELD(indexqual);
412 WRITE_NODE_FIELD(indexqualorig);
413 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
417 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
419 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
421 _outScanInfo(str, (Scan *) node);
423 WRITE_OID_FIELD(indexid);
424 WRITE_NODE_FIELD(indexqual);
425 WRITE_NODE_FIELD(indexqualorig);
429 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
431 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
433 _outScanInfo(str, (Scan *) node);
435 WRITE_NODE_FIELD(bitmapqualorig);
439 _outTidScan(StringInfo str, TidScan *node)
441 WRITE_NODE_TYPE("TIDSCAN");
443 _outScanInfo(str, (Scan *) node);
445 WRITE_NODE_FIELD(tidquals);
449 _outSubqueryScan(StringInfo str, SubqueryScan *node)
451 WRITE_NODE_TYPE("SUBQUERYSCAN");
453 _outScanInfo(str, (Scan *) node);
455 WRITE_NODE_FIELD(subplan);
456 WRITE_NODE_FIELD(subrtable);
457 WRITE_NODE_FIELD(subrowmark);
461 _outFunctionScan(StringInfo str, FunctionScan *node)
463 WRITE_NODE_TYPE("FUNCTIONSCAN");
465 _outScanInfo(str, (Scan *) node);
467 WRITE_NODE_FIELD(funcexpr);
468 WRITE_NODE_FIELD(funccolnames);
469 WRITE_NODE_FIELD(funccoltypes);
470 WRITE_NODE_FIELD(funccoltypmods);
474 _outValuesScan(StringInfo str, ValuesScan *node)
476 WRITE_NODE_TYPE("VALUESSCAN");
478 _outScanInfo(str, (Scan *) node);
480 WRITE_NODE_FIELD(values_lists);
484 _outCteScan(StringInfo str, CteScan *node)
486 WRITE_NODE_TYPE("CTESCAN");
488 _outScanInfo(str, (Scan *) node);
490 WRITE_INT_FIELD(ctePlanId);
491 WRITE_INT_FIELD(cteParam);
495 _outWorkTableScan(StringInfo str, WorkTableScan *node)
497 WRITE_NODE_TYPE("WORKTABLESCAN");
499 _outScanInfo(str, (Scan *) node);
501 WRITE_INT_FIELD(wtParam);
505 _outJoin(StringInfo str, Join *node)
507 WRITE_NODE_TYPE("JOIN");
509 _outJoinPlanInfo(str, (Join *) node);
513 _outNestLoop(StringInfo str, NestLoop *node)
515 WRITE_NODE_TYPE("NESTLOOP");
517 _outJoinPlanInfo(str, (Join *) node);
521 _outMergeJoin(StringInfo str, MergeJoin *node)
526 WRITE_NODE_TYPE("MERGEJOIN");
528 _outJoinPlanInfo(str, (Join *) node);
530 WRITE_NODE_FIELD(mergeclauses);
532 numCols = list_length(node->mergeclauses);
534 appendStringInfo(str, " :mergeFamilies");
535 for (i = 0; i < numCols; i++)
536 appendStringInfo(str, " %u", node->mergeFamilies[i]);
538 appendStringInfo(str, " :mergeStrategies");
539 for (i = 0; i < numCols; i++)
540 appendStringInfo(str, " %d", node->mergeStrategies[i]);
542 appendStringInfo(str, " :mergeNullsFirst");
543 for (i = 0; i < numCols; i++)
544 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
548 _outHashJoin(StringInfo str, HashJoin *node)
550 WRITE_NODE_TYPE("HASHJOIN");
552 _outJoinPlanInfo(str, (Join *) node);
554 WRITE_NODE_FIELD(hashclauses);
558 _outAgg(StringInfo str, Agg *node)
562 WRITE_NODE_TYPE("AGG");
564 _outPlanInfo(str, (Plan *) node);
566 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
567 WRITE_INT_FIELD(numCols);
569 appendStringInfo(str, " :grpColIdx");
570 for (i = 0; i < node->numCols; i++)
571 appendStringInfo(str, " %d", node->grpColIdx[i]);
573 appendStringInfo(str, " :grpOperators");
574 for (i = 0; i < node->numCols; i++)
575 appendStringInfo(str, " %u", node->grpOperators[i]);
577 WRITE_LONG_FIELD(numGroups);
581 _outWindowAgg(StringInfo str, WindowAgg *node)
585 WRITE_NODE_TYPE("WINDOWAGG");
587 _outPlanInfo(str, (Plan *) node);
589 WRITE_UINT_FIELD(winref);
590 WRITE_INT_FIELD(partNumCols);
592 appendStringInfo(str, " :partColIdx");
593 for (i = 0; i < node->partNumCols; i++)
594 appendStringInfo(str, " %d", node->partColIdx[i]);
596 appendStringInfo(str, " :partOperations");
597 for (i = 0; i < node->partNumCols; i++)
598 appendStringInfo(str, " %u", node->partOperators[i]);
600 WRITE_INT_FIELD(ordNumCols);
602 appendStringInfo(str, " :ordColIdx");
603 for (i = 0; i < node->ordNumCols; i++)
604 appendStringInfo(str, " %d", node->ordColIdx[i]);
606 appendStringInfo(str, " :ordOperations");
607 for (i = 0; i < node->ordNumCols; i++)
608 appendStringInfo(str, " %u", node->ordOperators[i]);
610 WRITE_INT_FIELD(frameOptions);
614 _outGroup(StringInfo str, Group *node)
618 WRITE_NODE_TYPE("GROUP");
620 _outPlanInfo(str, (Plan *) node);
622 WRITE_INT_FIELD(numCols);
624 appendStringInfo(str, " :grpColIdx");
625 for (i = 0; i < node->numCols; i++)
626 appendStringInfo(str, " %d", node->grpColIdx[i]);
628 appendStringInfo(str, " :grpOperators");
629 for (i = 0; i < node->numCols; i++)
630 appendStringInfo(str, " %u", node->grpOperators[i]);
634 _outMaterial(StringInfo str, Material *node)
636 WRITE_NODE_TYPE("MATERIAL");
638 _outPlanInfo(str, (Plan *) node);
642 _outSort(StringInfo str, Sort *node)
646 WRITE_NODE_TYPE("SORT");
648 _outPlanInfo(str, (Plan *) node);
650 WRITE_INT_FIELD(numCols);
652 appendStringInfo(str, " :sortColIdx");
653 for (i = 0; i < node->numCols; i++)
654 appendStringInfo(str, " %d", node->sortColIdx[i]);
656 appendStringInfo(str, " :sortOperators");
657 for (i = 0; i < node->numCols; i++)
658 appendStringInfo(str, " %u", node->sortOperators[i]);
660 appendStringInfo(str, " :nullsFirst");
661 for (i = 0; i < node->numCols; i++)
662 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
666 _outUnique(StringInfo str, Unique *node)
670 WRITE_NODE_TYPE("UNIQUE");
672 _outPlanInfo(str, (Plan *) node);
674 WRITE_INT_FIELD(numCols);
676 appendStringInfo(str, " :uniqColIdx");
677 for (i = 0; i < node->numCols; i++)
678 appendStringInfo(str, " %d", node->uniqColIdx[i]);
680 appendStringInfo(str, " :uniqOperators");
681 for (i = 0; i < node->numCols; i++)
682 appendStringInfo(str, " %u", node->uniqOperators[i]);
686 _outHash(StringInfo str, Hash *node)
688 WRITE_NODE_TYPE("HASH");
690 _outPlanInfo(str, (Plan *) node);
692 WRITE_OID_FIELD(skewTable);
693 WRITE_INT_FIELD(skewColumn);
694 WRITE_OID_FIELD(skewColType);
695 WRITE_INT_FIELD(skewColTypmod);
699 _outSetOp(StringInfo str, SetOp *node)
703 WRITE_NODE_TYPE("SETOP");
705 _outPlanInfo(str, (Plan *) node);
707 WRITE_ENUM_FIELD(cmd, SetOpCmd);
708 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
709 WRITE_INT_FIELD(numCols);
711 appendStringInfo(str, " :dupColIdx");
712 for (i = 0; i < node->numCols; i++)
713 appendStringInfo(str, " %d", node->dupColIdx[i]);
715 appendStringInfo(str, " :dupOperators");
716 for (i = 0; i < node->numCols; i++)
717 appendStringInfo(str, " %u", node->dupOperators[i]);
719 WRITE_INT_FIELD(flagColIdx);
720 WRITE_INT_FIELD(firstFlag);
721 WRITE_LONG_FIELD(numGroups);
725 _outLockRows(StringInfo str, LockRows *node)
727 WRITE_NODE_TYPE("LOCKROWS");
729 _outPlanInfo(str, (Plan *) node);
731 WRITE_NODE_FIELD(rowMarks);
735 _outLimit(StringInfo str, Limit *node)
737 WRITE_NODE_TYPE("LIMIT");
739 _outPlanInfo(str, (Plan *) node);
741 WRITE_NODE_FIELD(limitOffset);
742 WRITE_NODE_FIELD(limitCount);
746 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
748 WRITE_NODE_TYPE("PLANINVALITEM");
750 WRITE_INT_FIELD(cacheId);
751 appendStringInfo(str, " :tupleId (%u,%u)",
752 ItemPointerGetBlockNumber(&node->tupleId),
753 ItemPointerGetOffsetNumber(&node->tupleId));
756 /*****************************************************************************
758 * Stuff from primnodes.h.
760 *****************************************************************************/
763 _outAlias(StringInfo str, Alias *node)
765 WRITE_NODE_TYPE("ALIAS");
767 WRITE_STRING_FIELD(aliasname);
768 WRITE_NODE_FIELD(colnames);
772 _outRangeVar(StringInfo str, RangeVar *node)
774 WRITE_NODE_TYPE("RANGEVAR");
777 * we deliberately ignore catalogname here, since it is presently not
778 * semantically meaningful
780 WRITE_STRING_FIELD(schemaname);
781 WRITE_STRING_FIELD(relname);
782 WRITE_ENUM_FIELD(inhOpt, InhOption);
783 WRITE_BOOL_FIELD(istemp);
784 WRITE_NODE_FIELD(alias);
785 WRITE_LOCATION_FIELD(location);
789 _outIntoClause(StringInfo str, IntoClause *node)
791 WRITE_NODE_TYPE("INTOCLAUSE");
793 WRITE_NODE_FIELD(rel);
794 WRITE_NODE_FIELD(colNames);
795 WRITE_NODE_FIELD(options);
796 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
797 WRITE_STRING_FIELD(tableSpaceName);
801 _outVar(StringInfo str, Var *node)
803 WRITE_NODE_TYPE("VAR");
805 WRITE_UINT_FIELD(varno);
806 WRITE_INT_FIELD(varattno);
807 WRITE_OID_FIELD(vartype);
808 WRITE_INT_FIELD(vartypmod);
809 WRITE_UINT_FIELD(varlevelsup);
810 WRITE_UINT_FIELD(varnoold);
811 WRITE_INT_FIELD(varoattno);
812 WRITE_LOCATION_FIELD(location);
816 _outConst(StringInfo str, Const *node)
818 WRITE_NODE_TYPE("CONST");
820 WRITE_OID_FIELD(consttype);
821 WRITE_INT_FIELD(consttypmod);
822 WRITE_INT_FIELD(constlen);
823 WRITE_BOOL_FIELD(constbyval);
824 WRITE_BOOL_FIELD(constisnull);
825 WRITE_LOCATION_FIELD(location);
827 appendStringInfo(str, " :constvalue ");
828 if (node->constisnull)
829 appendStringInfo(str, "<>");
831 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
835 _outParam(StringInfo str, Param *node)
837 WRITE_NODE_TYPE("PARAM");
839 WRITE_ENUM_FIELD(paramkind, ParamKind);
840 WRITE_INT_FIELD(paramid);
841 WRITE_OID_FIELD(paramtype);
842 WRITE_INT_FIELD(paramtypmod);
843 WRITE_LOCATION_FIELD(location);
847 _outAggref(StringInfo str, Aggref *node)
849 WRITE_NODE_TYPE("AGGREF");
851 WRITE_OID_FIELD(aggfnoid);
852 WRITE_OID_FIELD(aggtype);
853 WRITE_NODE_FIELD(args);
854 WRITE_UINT_FIELD(agglevelsup);
855 WRITE_BOOL_FIELD(aggstar);
856 WRITE_BOOL_FIELD(aggdistinct);
857 WRITE_LOCATION_FIELD(location);
861 _outWindowFunc(StringInfo str, WindowFunc *node)
863 WRITE_NODE_TYPE("WINDOWFUNC");
865 WRITE_OID_FIELD(winfnoid);
866 WRITE_OID_FIELD(wintype);
867 WRITE_NODE_FIELD(args);
868 WRITE_UINT_FIELD(winref);
869 WRITE_BOOL_FIELD(winstar);
870 WRITE_BOOL_FIELD(winagg);
871 WRITE_LOCATION_FIELD(location);
875 _outArrayRef(StringInfo str, ArrayRef *node)
877 WRITE_NODE_TYPE("ARRAYREF");
879 WRITE_OID_FIELD(refarraytype);
880 WRITE_OID_FIELD(refelemtype);
881 WRITE_INT_FIELD(reftypmod);
882 WRITE_NODE_FIELD(refupperindexpr);
883 WRITE_NODE_FIELD(reflowerindexpr);
884 WRITE_NODE_FIELD(refexpr);
885 WRITE_NODE_FIELD(refassgnexpr);
889 _outFuncExpr(StringInfo str, FuncExpr *node)
891 WRITE_NODE_TYPE("FUNCEXPR");
893 WRITE_OID_FIELD(funcid);
894 WRITE_OID_FIELD(funcresulttype);
895 WRITE_BOOL_FIELD(funcretset);
896 WRITE_ENUM_FIELD(funcformat, CoercionForm);
897 WRITE_NODE_FIELD(args);
898 WRITE_LOCATION_FIELD(location);
902 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
904 WRITE_NODE_TYPE("NAMEDARGEXPR");
906 WRITE_NODE_FIELD(arg);
907 WRITE_STRING_FIELD(name);
908 WRITE_INT_FIELD(argnumber);
909 WRITE_LOCATION_FIELD(location);
913 _outOpExpr(StringInfo str, OpExpr *node)
915 WRITE_NODE_TYPE("OPEXPR");
917 WRITE_OID_FIELD(opno);
918 WRITE_OID_FIELD(opfuncid);
919 WRITE_OID_FIELD(opresulttype);
920 WRITE_BOOL_FIELD(opretset);
921 WRITE_NODE_FIELD(args);
922 WRITE_LOCATION_FIELD(location);
926 _outDistinctExpr(StringInfo str, DistinctExpr *node)
928 WRITE_NODE_TYPE("DISTINCTEXPR");
930 WRITE_OID_FIELD(opno);
931 WRITE_OID_FIELD(opfuncid);
932 WRITE_OID_FIELD(opresulttype);
933 WRITE_BOOL_FIELD(opretset);
934 WRITE_NODE_FIELD(args);
935 WRITE_LOCATION_FIELD(location);
939 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
941 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
943 WRITE_OID_FIELD(opno);
944 WRITE_OID_FIELD(opfuncid);
945 WRITE_BOOL_FIELD(useOr);
946 WRITE_NODE_FIELD(args);
947 WRITE_LOCATION_FIELD(location);
951 _outBoolExpr(StringInfo str, BoolExpr *node)
955 WRITE_NODE_TYPE("BOOLEXPR");
957 /* do-it-yourself enum representation */
958 switch (node->boolop)
970 appendStringInfo(str, " :boolop ");
971 _outToken(str, opstr);
973 WRITE_NODE_FIELD(args);
974 WRITE_LOCATION_FIELD(location);
978 _outSubLink(StringInfo str, SubLink *node)
980 WRITE_NODE_TYPE("SUBLINK");
982 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
983 WRITE_NODE_FIELD(testexpr);
984 WRITE_NODE_FIELD(operName);
985 WRITE_NODE_FIELD(subselect);
986 WRITE_LOCATION_FIELD(location);
990 _outSubPlan(StringInfo str, SubPlan *node)
992 WRITE_NODE_TYPE("SUBPLAN");
994 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
995 WRITE_NODE_FIELD(testexpr);
996 WRITE_NODE_FIELD(paramIds);
997 WRITE_INT_FIELD(plan_id);
998 WRITE_STRING_FIELD(plan_name);
999 WRITE_OID_FIELD(firstColType);
1000 WRITE_INT_FIELD(firstColTypmod);
1001 WRITE_BOOL_FIELD(useHashTable);
1002 WRITE_BOOL_FIELD(unknownEqFalse);
1003 WRITE_NODE_FIELD(setParam);
1004 WRITE_NODE_FIELD(parParam);
1005 WRITE_NODE_FIELD(args);
1006 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1007 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1011 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1013 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1015 WRITE_NODE_FIELD(subplans);
1019 _outFieldSelect(StringInfo str, FieldSelect *node)
1021 WRITE_NODE_TYPE("FIELDSELECT");
1023 WRITE_NODE_FIELD(arg);
1024 WRITE_INT_FIELD(fieldnum);
1025 WRITE_OID_FIELD(resulttype);
1026 WRITE_INT_FIELD(resulttypmod);
1030 _outFieldStore(StringInfo str, FieldStore *node)
1032 WRITE_NODE_TYPE("FIELDSTORE");
1034 WRITE_NODE_FIELD(arg);
1035 WRITE_NODE_FIELD(newvals);
1036 WRITE_NODE_FIELD(fieldnums);
1037 WRITE_OID_FIELD(resulttype);
1041 _outRelabelType(StringInfo str, RelabelType *node)
1043 WRITE_NODE_TYPE("RELABELTYPE");
1045 WRITE_NODE_FIELD(arg);
1046 WRITE_OID_FIELD(resulttype);
1047 WRITE_INT_FIELD(resulttypmod);
1048 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1049 WRITE_LOCATION_FIELD(location);
1053 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1055 WRITE_NODE_TYPE("COERCEVIAIO");
1057 WRITE_NODE_FIELD(arg);
1058 WRITE_OID_FIELD(resulttype);
1059 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1060 WRITE_LOCATION_FIELD(location);
1064 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1066 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1068 WRITE_NODE_FIELD(arg);
1069 WRITE_OID_FIELD(elemfuncid);
1070 WRITE_OID_FIELD(resulttype);
1071 WRITE_INT_FIELD(resulttypmod);
1072 WRITE_BOOL_FIELD(isExplicit);
1073 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1074 WRITE_LOCATION_FIELD(location);
1078 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1080 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1082 WRITE_NODE_FIELD(arg);
1083 WRITE_OID_FIELD(resulttype);
1084 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1085 WRITE_LOCATION_FIELD(location);
1089 _outCaseExpr(StringInfo str, CaseExpr *node)
1091 WRITE_NODE_TYPE("CASE");
1093 WRITE_OID_FIELD(casetype);
1094 WRITE_NODE_FIELD(arg);
1095 WRITE_NODE_FIELD(args);
1096 WRITE_NODE_FIELD(defresult);
1097 WRITE_LOCATION_FIELD(location);
1101 _outCaseWhen(StringInfo str, CaseWhen *node)
1103 WRITE_NODE_TYPE("WHEN");
1105 WRITE_NODE_FIELD(expr);
1106 WRITE_NODE_FIELD(result);
1107 WRITE_LOCATION_FIELD(location);
1111 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1113 WRITE_NODE_TYPE("CASETESTEXPR");
1115 WRITE_OID_FIELD(typeId);
1116 WRITE_INT_FIELD(typeMod);
1120 _outArrayExpr(StringInfo str, ArrayExpr *node)
1122 WRITE_NODE_TYPE("ARRAY");
1124 WRITE_OID_FIELD(array_typeid);
1125 WRITE_OID_FIELD(element_typeid);
1126 WRITE_NODE_FIELD(elements);
1127 WRITE_BOOL_FIELD(multidims);
1128 WRITE_LOCATION_FIELD(location);
1132 _outRowExpr(StringInfo str, RowExpr *node)
1134 WRITE_NODE_TYPE("ROW");
1136 WRITE_NODE_FIELD(args);
1137 WRITE_OID_FIELD(row_typeid);
1138 WRITE_ENUM_FIELD(row_format, CoercionForm);
1139 WRITE_NODE_FIELD(colnames);
1140 WRITE_LOCATION_FIELD(location);
1144 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1146 WRITE_NODE_TYPE("ROWCOMPARE");
1148 WRITE_ENUM_FIELD(rctype, RowCompareType);
1149 WRITE_NODE_FIELD(opnos);
1150 WRITE_NODE_FIELD(opfamilies);
1151 WRITE_NODE_FIELD(largs);
1152 WRITE_NODE_FIELD(rargs);
1156 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1158 WRITE_NODE_TYPE("COALESCE");
1160 WRITE_OID_FIELD(coalescetype);
1161 WRITE_NODE_FIELD(args);
1162 WRITE_LOCATION_FIELD(location);
1166 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1168 WRITE_NODE_TYPE("MINMAX");
1170 WRITE_OID_FIELD(minmaxtype);
1171 WRITE_ENUM_FIELD(op, MinMaxOp);
1172 WRITE_NODE_FIELD(args);
1173 WRITE_LOCATION_FIELD(location);
1177 _outXmlExpr(StringInfo str, XmlExpr *node)
1179 WRITE_NODE_TYPE("XMLEXPR");
1181 WRITE_ENUM_FIELD(op, XmlExprOp);
1182 WRITE_STRING_FIELD(name);
1183 WRITE_NODE_FIELD(named_args);
1184 WRITE_NODE_FIELD(arg_names);
1185 WRITE_NODE_FIELD(args);
1186 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1187 WRITE_OID_FIELD(type);
1188 WRITE_INT_FIELD(typmod);
1189 WRITE_LOCATION_FIELD(location);
1193 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1195 WRITE_NODE_TYPE("NULLIFEXPR");
1197 WRITE_OID_FIELD(opno);
1198 WRITE_OID_FIELD(opfuncid);
1199 WRITE_OID_FIELD(opresulttype);
1200 WRITE_BOOL_FIELD(opretset);
1201 WRITE_NODE_FIELD(args);
1202 WRITE_LOCATION_FIELD(location);
1206 _outNullTest(StringInfo str, NullTest *node)
1208 WRITE_NODE_TYPE("NULLTEST");
1210 WRITE_NODE_FIELD(arg);
1211 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1215 _outBooleanTest(StringInfo str, BooleanTest *node)
1217 WRITE_NODE_TYPE("BOOLEANTEST");
1219 WRITE_NODE_FIELD(arg);
1220 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1224 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1226 WRITE_NODE_TYPE("COERCETODOMAIN");
1228 WRITE_NODE_FIELD(arg);
1229 WRITE_OID_FIELD(resulttype);
1230 WRITE_INT_FIELD(resulttypmod);
1231 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1232 WRITE_LOCATION_FIELD(location);
1236 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1238 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1240 WRITE_OID_FIELD(typeId);
1241 WRITE_INT_FIELD(typeMod);
1242 WRITE_LOCATION_FIELD(location);
1246 _outSetToDefault(StringInfo str, SetToDefault *node)
1248 WRITE_NODE_TYPE("SETTODEFAULT");
1250 WRITE_OID_FIELD(typeId);
1251 WRITE_INT_FIELD(typeMod);
1252 WRITE_LOCATION_FIELD(location);
1256 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1258 WRITE_NODE_TYPE("CURRENTOFEXPR");
1260 WRITE_UINT_FIELD(cvarno);
1261 WRITE_STRING_FIELD(cursor_name);
1262 WRITE_INT_FIELD(cursor_param);
1266 _outTargetEntry(StringInfo str, TargetEntry *node)
1268 WRITE_NODE_TYPE("TARGETENTRY");
1270 WRITE_NODE_FIELD(expr);
1271 WRITE_INT_FIELD(resno);
1272 WRITE_STRING_FIELD(resname);
1273 WRITE_UINT_FIELD(ressortgroupref);
1274 WRITE_OID_FIELD(resorigtbl);
1275 WRITE_INT_FIELD(resorigcol);
1276 WRITE_BOOL_FIELD(resjunk);
1280 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1282 WRITE_NODE_TYPE("RANGETBLREF");
1284 WRITE_INT_FIELD(rtindex);
1288 _outJoinExpr(StringInfo str, JoinExpr *node)
1290 WRITE_NODE_TYPE("JOINEXPR");
1292 WRITE_ENUM_FIELD(jointype, JoinType);
1293 WRITE_BOOL_FIELD(isNatural);
1294 WRITE_NODE_FIELD(larg);
1295 WRITE_NODE_FIELD(rarg);
1296 WRITE_NODE_FIELD(usingClause);
1297 WRITE_NODE_FIELD(quals);
1298 WRITE_NODE_FIELD(alias);
1299 WRITE_INT_FIELD(rtindex);
1303 _outFromExpr(StringInfo str, FromExpr *node)
1305 WRITE_NODE_TYPE("FROMEXPR");
1307 WRITE_NODE_FIELD(fromlist);
1308 WRITE_NODE_FIELD(quals);
1311 /*****************************************************************************
1313 * Stuff from relation.h.
1315 *****************************************************************************/
1318 * print the basic stuff of all nodes that inherit from Path
1320 * Note we do NOT print the parent, else we'd be in infinite recursion
1323 _outPathInfo(StringInfo str, Path *node)
1325 WRITE_ENUM_FIELD(pathtype, NodeTag);
1326 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1327 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1328 WRITE_NODE_FIELD(pathkeys);
1332 * print the basic stuff of all nodes that inherit from JoinPath
1335 _outJoinPathInfo(StringInfo str, JoinPath *node)
1337 _outPathInfo(str, (Path *) node);
1339 WRITE_ENUM_FIELD(jointype, JoinType);
1340 WRITE_NODE_FIELD(outerjoinpath);
1341 WRITE_NODE_FIELD(innerjoinpath);
1342 WRITE_NODE_FIELD(joinrestrictinfo);
1346 _outPath(StringInfo str, Path *node)
1348 WRITE_NODE_TYPE("PATH");
1350 _outPathInfo(str, (Path *) node);
1354 _outIndexPath(StringInfo str, IndexPath *node)
1356 WRITE_NODE_TYPE("INDEXPATH");
1358 _outPathInfo(str, (Path *) node);
1360 WRITE_NODE_FIELD(indexinfo);
1361 WRITE_NODE_FIELD(indexclauses);
1362 WRITE_NODE_FIELD(indexquals);
1363 WRITE_BOOL_FIELD(isjoininner);
1364 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1365 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1366 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1367 WRITE_FLOAT_FIELD(rows, "%.0f");
1371 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1373 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1375 _outPathInfo(str, (Path *) node);
1377 WRITE_NODE_FIELD(bitmapqual);
1378 WRITE_BOOL_FIELD(isjoininner);
1379 WRITE_FLOAT_FIELD(rows, "%.0f");
1383 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1385 WRITE_NODE_TYPE("BITMAPANDPATH");
1387 _outPathInfo(str, (Path *) node);
1389 WRITE_NODE_FIELD(bitmapquals);
1390 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1394 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1396 WRITE_NODE_TYPE("BITMAPORPATH");
1398 _outPathInfo(str, (Path *) node);
1400 WRITE_NODE_FIELD(bitmapquals);
1401 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1405 _outTidPath(StringInfo str, TidPath *node)
1407 WRITE_NODE_TYPE("TIDPATH");
1409 _outPathInfo(str, (Path *) node);
1411 WRITE_NODE_FIELD(tidquals);
1415 _outAppendPath(StringInfo str, AppendPath *node)
1417 WRITE_NODE_TYPE("APPENDPATH");
1419 _outPathInfo(str, (Path *) node);
1421 WRITE_NODE_FIELD(subpaths);
1425 _outResultPath(StringInfo str, ResultPath *node)
1427 WRITE_NODE_TYPE("RESULTPATH");
1429 _outPathInfo(str, (Path *) node);
1431 WRITE_NODE_FIELD(quals);
1435 _outMaterialPath(StringInfo str, MaterialPath *node)
1437 WRITE_NODE_TYPE("MATERIALPATH");
1439 _outPathInfo(str, (Path *) node);
1441 WRITE_NODE_FIELD(subpath);
1445 _outUniquePath(StringInfo str, UniquePath *node)
1447 WRITE_NODE_TYPE("UNIQUEPATH");
1449 _outPathInfo(str, (Path *) node);
1451 WRITE_NODE_FIELD(subpath);
1452 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1453 WRITE_NODE_FIELD(in_operators);
1454 WRITE_NODE_FIELD(uniq_exprs);
1455 WRITE_FLOAT_FIELD(rows, "%.0f");
1459 _outNoOpPath(StringInfo str, NoOpPath *node)
1461 WRITE_NODE_TYPE("NOOPPATH");
1463 _outPathInfo(str, (Path *) node);
1465 WRITE_NODE_FIELD(subpath);
1469 _outNestPath(StringInfo str, NestPath *node)
1471 WRITE_NODE_TYPE("NESTPATH");
1473 _outJoinPathInfo(str, (JoinPath *) node);
1477 _outMergePath(StringInfo str, MergePath *node)
1479 WRITE_NODE_TYPE("MERGEPATH");
1481 _outJoinPathInfo(str, (JoinPath *) node);
1483 WRITE_NODE_FIELD(path_mergeclauses);
1484 WRITE_NODE_FIELD(outersortkeys);
1485 WRITE_NODE_FIELD(innersortkeys);
1489 _outHashPath(StringInfo str, HashPath *node)
1491 WRITE_NODE_TYPE("HASHPATH");
1493 _outJoinPathInfo(str, (JoinPath *) node);
1495 WRITE_NODE_FIELD(path_hashclauses);
1496 WRITE_INT_FIELD(num_batches);
1500 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1502 WRITE_NODE_TYPE("PLANNERGLOBAL");
1504 /* NB: this isn't a complete set of fields */
1505 WRITE_NODE_FIELD(paramlist);
1506 WRITE_NODE_FIELD(subplans);
1507 WRITE_NODE_FIELD(subrtables);
1508 WRITE_NODE_FIELD(subrowmarks);
1509 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1510 WRITE_NODE_FIELD(finalrtable);
1511 WRITE_NODE_FIELD(finalrowmarks);
1512 WRITE_NODE_FIELD(relationOids);
1513 WRITE_NODE_FIELD(invalItems);
1514 WRITE_UINT_FIELD(lastPHId);
1515 WRITE_UINT_FIELD(lastRowmarkId);
1516 WRITE_BOOL_FIELD(transientPlan);
1520 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1522 WRITE_NODE_TYPE("PLANNERINFO");
1524 /* NB: this isn't a complete set of fields */
1525 WRITE_NODE_FIELD(parse);
1526 WRITE_NODE_FIELD(glob);
1527 WRITE_UINT_FIELD(query_level);
1528 WRITE_NODE_FIELD(join_rel_list);
1529 WRITE_NODE_FIELD(resultRelations);
1530 WRITE_NODE_FIELD(init_plans);
1531 WRITE_NODE_FIELD(cte_plan_ids);
1532 WRITE_NODE_FIELD(eq_classes);
1533 WRITE_NODE_FIELD(canon_pathkeys);
1534 WRITE_NODE_FIELD(left_join_clauses);
1535 WRITE_NODE_FIELD(right_join_clauses);
1536 WRITE_NODE_FIELD(full_join_clauses);
1537 WRITE_NODE_FIELD(join_info_list);
1538 WRITE_NODE_FIELD(append_rel_list);
1539 WRITE_NODE_FIELD(placeholder_list);
1540 WRITE_NODE_FIELD(query_pathkeys);
1541 WRITE_NODE_FIELD(group_pathkeys);
1542 WRITE_NODE_FIELD(window_pathkeys);
1543 WRITE_NODE_FIELD(distinct_pathkeys);
1544 WRITE_NODE_FIELD(sort_pathkeys);
1545 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1546 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1547 WRITE_BOOL_FIELD(hasJoinRTEs);
1548 WRITE_BOOL_FIELD(hasHavingQual);
1549 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1550 WRITE_BOOL_FIELD(hasRecursion);
1551 WRITE_INT_FIELD(wt_param_id);
1555 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1557 WRITE_NODE_TYPE("RELOPTINFO");
1559 /* NB: this isn't a complete set of fields */
1560 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1561 WRITE_BITMAPSET_FIELD(relids);
1562 WRITE_FLOAT_FIELD(rows, "%.0f");
1563 WRITE_INT_FIELD(width);
1564 WRITE_NODE_FIELD(reltargetlist);
1565 WRITE_NODE_FIELD(pathlist);
1566 WRITE_NODE_FIELD(cheapest_startup_path);
1567 WRITE_NODE_FIELD(cheapest_total_path);
1568 WRITE_NODE_FIELD(cheapest_unique_path);
1569 WRITE_UINT_FIELD(relid);
1570 WRITE_ENUM_FIELD(rtekind, RTEKind);
1571 WRITE_INT_FIELD(min_attr);
1572 WRITE_INT_FIELD(max_attr);
1573 WRITE_NODE_FIELD(indexlist);
1574 WRITE_UINT_FIELD(pages);
1575 WRITE_FLOAT_FIELD(tuples, "%.0f");
1576 WRITE_NODE_FIELD(subplan);
1577 WRITE_NODE_FIELD(subrtable);
1578 WRITE_NODE_FIELD(subrowmark);
1579 WRITE_NODE_FIELD(baserestrictinfo);
1580 WRITE_NODE_FIELD(joininfo);
1581 WRITE_BOOL_FIELD(has_eclass_joins);
1582 WRITE_BITMAPSET_FIELD(index_outer_relids);
1583 WRITE_NODE_FIELD(index_inner_paths);
1587 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1589 WRITE_NODE_TYPE("INDEXOPTINFO");
1591 /* NB: this isn't a complete set of fields */
1592 WRITE_OID_FIELD(indexoid);
1593 /* Do NOT print rel field, else infinite recursion */
1594 WRITE_UINT_FIELD(pages);
1595 WRITE_FLOAT_FIELD(tuples, "%.0f");
1596 WRITE_INT_FIELD(ncolumns);
1597 WRITE_NODE_FIELD(indexprs);
1598 WRITE_NODE_FIELD(indpred);
1599 WRITE_BOOL_FIELD(predOK);
1600 WRITE_BOOL_FIELD(unique);
1604 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1607 * To simplify reading, we just chase up to the topmost merged EC and
1608 * print that, without bothering to show the merge-ees separately.
1610 while (node->ec_merged)
1611 node = node->ec_merged;
1613 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1615 WRITE_NODE_FIELD(ec_opfamilies);
1616 WRITE_NODE_FIELD(ec_members);
1617 WRITE_NODE_FIELD(ec_sources);
1618 WRITE_NODE_FIELD(ec_derives);
1619 WRITE_BITMAPSET_FIELD(ec_relids);
1620 WRITE_BOOL_FIELD(ec_has_const);
1621 WRITE_BOOL_FIELD(ec_has_volatile);
1622 WRITE_BOOL_FIELD(ec_below_outer_join);
1623 WRITE_BOOL_FIELD(ec_broken);
1624 WRITE_UINT_FIELD(ec_sortref);
1628 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1630 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1632 WRITE_NODE_FIELD(em_expr);
1633 WRITE_BITMAPSET_FIELD(em_relids);
1634 WRITE_BOOL_FIELD(em_is_const);
1635 WRITE_BOOL_FIELD(em_is_child);
1636 WRITE_OID_FIELD(em_datatype);
1640 _outPathKey(StringInfo str, PathKey *node)
1642 WRITE_NODE_TYPE("PATHKEY");
1644 WRITE_NODE_FIELD(pk_eclass);
1645 WRITE_OID_FIELD(pk_opfamily);
1646 WRITE_INT_FIELD(pk_strategy);
1647 WRITE_BOOL_FIELD(pk_nulls_first);
1651 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1653 WRITE_NODE_TYPE("RESTRICTINFO");
1655 /* NB: this isn't a complete set of fields */
1656 WRITE_NODE_FIELD(clause);
1657 WRITE_BOOL_FIELD(is_pushed_down);
1658 WRITE_BOOL_FIELD(outerjoin_delayed);
1659 WRITE_BOOL_FIELD(can_join);
1660 WRITE_BOOL_FIELD(pseudoconstant);
1661 WRITE_BITMAPSET_FIELD(clause_relids);
1662 WRITE_BITMAPSET_FIELD(required_relids);
1663 WRITE_BITMAPSET_FIELD(nullable_relids);
1664 WRITE_BITMAPSET_FIELD(left_relids);
1665 WRITE_BITMAPSET_FIELD(right_relids);
1666 WRITE_NODE_FIELD(orclause);
1667 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1668 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1669 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1670 WRITE_NODE_FIELD(mergeopfamilies);
1671 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1672 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1673 WRITE_NODE_FIELD(left_em);
1674 WRITE_NODE_FIELD(right_em);
1675 WRITE_BOOL_FIELD(outer_is_left);
1676 WRITE_OID_FIELD(hashjoinoperator);
1680 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1682 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1683 WRITE_BITMAPSET_FIELD(other_relids);
1684 WRITE_BOOL_FIELD(isouterjoin);
1685 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1686 WRITE_NODE_FIELD(cheapest_total_innerpath);
1690 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1692 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1694 WRITE_NODE_FIELD(phexpr);
1695 WRITE_BITMAPSET_FIELD(phrels);
1696 WRITE_UINT_FIELD(phid);
1697 WRITE_UINT_FIELD(phlevelsup);
1701 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1703 WRITE_NODE_TYPE("SPECIALJOININFO");
1705 WRITE_BITMAPSET_FIELD(min_lefthand);
1706 WRITE_BITMAPSET_FIELD(min_righthand);
1707 WRITE_BITMAPSET_FIELD(syn_lefthand);
1708 WRITE_BITMAPSET_FIELD(syn_righthand);
1709 WRITE_ENUM_FIELD(jointype, JoinType);
1710 WRITE_BOOL_FIELD(lhs_strict);
1711 WRITE_BOOL_FIELD(delay_upper_joins);
1712 WRITE_NODE_FIELD(join_quals);
1716 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1718 WRITE_NODE_TYPE("APPENDRELINFO");
1720 WRITE_UINT_FIELD(parent_relid);
1721 WRITE_UINT_FIELD(child_relid);
1722 WRITE_OID_FIELD(parent_reltype);
1723 WRITE_OID_FIELD(child_reltype);
1724 WRITE_NODE_FIELD(translated_vars);
1725 WRITE_OID_FIELD(parent_reloid);
1729 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1731 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1733 WRITE_UINT_FIELD(phid);
1734 WRITE_NODE_FIELD(ph_var);
1735 WRITE_BITMAPSET_FIELD(ph_eval_at);
1736 WRITE_BITMAPSET_FIELD(ph_needed);
1737 WRITE_INT_FIELD(ph_width);
1741 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1743 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1745 WRITE_NODE_FIELD(item);
1746 WRITE_UINT_FIELD(abslevel);
1749 /*****************************************************************************
1751 * Stuff from parsenodes.h.
1753 *****************************************************************************/
1756 _outCreateStmt(StringInfo str, CreateStmt *node)
1758 WRITE_NODE_TYPE("CREATESTMT");
1760 WRITE_NODE_FIELD(relation);
1761 WRITE_NODE_FIELD(tableElts);
1762 WRITE_NODE_FIELD(inhRelations);
1763 WRITE_NODE_FIELD(constraints);
1764 WRITE_NODE_FIELD(options);
1765 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1766 WRITE_STRING_FIELD(tablespacename);
1770 _outIndexStmt(StringInfo str, IndexStmt *node)
1772 WRITE_NODE_TYPE("INDEXSTMT");
1774 WRITE_STRING_FIELD(idxname);
1775 WRITE_NODE_FIELD(relation);
1776 WRITE_STRING_FIELD(accessMethod);
1777 WRITE_STRING_FIELD(tableSpace);
1778 WRITE_NODE_FIELD(indexParams);
1779 WRITE_NODE_FIELD(options);
1780 WRITE_NODE_FIELD(whereClause);
1781 WRITE_BOOL_FIELD(unique);
1782 WRITE_BOOL_FIELD(primary);
1783 WRITE_BOOL_FIELD(isconstraint);
1784 WRITE_BOOL_FIELD(deferrable);
1785 WRITE_BOOL_FIELD(initdeferred);
1786 WRITE_BOOL_FIELD(concurrent);
1790 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1792 WRITE_NODE_TYPE("NOTIFY");
1794 WRITE_STRING_FIELD(conditionname);
1798 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1800 WRITE_NODE_TYPE("DECLARECURSOR");
1802 WRITE_STRING_FIELD(portalname);
1803 WRITE_INT_FIELD(options);
1804 WRITE_NODE_FIELD(query);
1808 _outSelectStmt(StringInfo str, SelectStmt *node)
1810 WRITE_NODE_TYPE("SELECT");
1812 WRITE_NODE_FIELD(distinctClause);
1813 WRITE_NODE_FIELD(intoClause);
1814 WRITE_NODE_FIELD(targetList);
1815 WRITE_NODE_FIELD(fromClause);
1816 WRITE_NODE_FIELD(whereClause);
1817 WRITE_NODE_FIELD(groupClause);
1818 WRITE_NODE_FIELD(havingClause);
1819 WRITE_NODE_FIELD(windowClause);
1820 WRITE_NODE_FIELD(withClause);
1821 WRITE_NODE_FIELD(valuesLists);
1822 WRITE_NODE_FIELD(sortClause);
1823 WRITE_NODE_FIELD(limitOffset);
1824 WRITE_NODE_FIELD(limitCount);
1825 WRITE_NODE_FIELD(lockingClause);
1826 WRITE_ENUM_FIELD(op, SetOperation);
1827 WRITE_BOOL_FIELD(all);
1828 WRITE_NODE_FIELD(larg);
1829 WRITE_NODE_FIELD(rarg);
1833 _outFuncCall(StringInfo str, FuncCall *node)
1835 WRITE_NODE_TYPE("FUNCCALL");
1837 WRITE_NODE_FIELD(funcname);
1838 WRITE_NODE_FIELD(args);
1839 WRITE_BOOL_FIELD(agg_star);
1840 WRITE_BOOL_FIELD(agg_distinct);
1841 WRITE_BOOL_FIELD(func_variadic);
1842 WRITE_NODE_FIELD(over);
1843 WRITE_LOCATION_FIELD(location);
1847 _outDefElem(StringInfo str, DefElem *node)
1849 WRITE_NODE_TYPE("DEFELEM");
1851 WRITE_STRING_FIELD(defnamespace);
1852 WRITE_STRING_FIELD(defname);
1853 WRITE_NODE_FIELD(arg);
1854 WRITE_ENUM_FIELD(defaction, DefElemAction);
1858 _outLockingClause(StringInfo str, LockingClause *node)
1860 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1862 WRITE_NODE_FIELD(lockedRels);
1863 WRITE_BOOL_FIELD(forUpdate);
1864 WRITE_BOOL_FIELD(noWait);
1868 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1870 WRITE_NODE_TYPE("XMLSERIALIZE");
1872 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1873 WRITE_NODE_FIELD(expr);
1874 WRITE_NODE_FIELD(typeName);
1875 WRITE_LOCATION_FIELD(location);
1879 _outColumnDef(StringInfo str, ColumnDef *node)
1881 WRITE_NODE_TYPE("COLUMNDEF");
1883 WRITE_STRING_FIELD(colname);
1884 WRITE_NODE_FIELD(typeName);
1885 WRITE_INT_FIELD(inhcount);
1886 WRITE_BOOL_FIELD(is_local);
1887 WRITE_BOOL_FIELD(is_not_null);
1888 WRITE_NODE_FIELD(raw_default);
1889 WRITE_NODE_FIELD(cooked_default);
1890 WRITE_NODE_FIELD(constraints);
1894 _outTypeName(StringInfo str, TypeName *node)
1896 WRITE_NODE_TYPE("TYPENAME");
1898 WRITE_NODE_FIELD(names);
1899 WRITE_OID_FIELD(typeOid);
1900 WRITE_BOOL_FIELD(setof);
1901 WRITE_BOOL_FIELD(pct_type);
1902 WRITE_NODE_FIELD(typmods);
1903 WRITE_INT_FIELD(typemod);
1904 WRITE_NODE_FIELD(arrayBounds);
1905 WRITE_LOCATION_FIELD(location);
1909 _outTypeCast(StringInfo str, TypeCast *node)
1911 WRITE_NODE_TYPE("TYPECAST");
1913 WRITE_NODE_FIELD(arg);
1914 WRITE_NODE_FIELD(typeName);
1915 WRITE_LOCATION_FIELD(location);
1919 _outIndexElem(StringInfo str, IndexElem *node)
1921 WRITE_NODE_TYPE("INDEXELEM");
1923 WRITE_STRING_FIELD(name);
1924 WRITE_NODE_FIELD(expr);
1925 WRITE_NODE_FIELD(opclass);
1926 WRITE_ENUM_FIELD(ordering, SortByDir);
1927 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1931 _outQuery(StringInfo str, Query *node)
1933 WRITE_NODE_TYPE("QUERY");
1935 WRITE_ENUM_FIELD(commandType, CmdType);
1936 WRITE_ENUM_FIELD(querySource, QuerySource);
1937 WRITE_BOOL_FIELD(canSetTag);
1940 * Hack to work around missing outfuncs routines for a lot of the
1941 * utility-statement node types. (The only one we actually *need* for
1942 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1943 * for the meantime do this to avoid getting lots of warnings when running
1944 * with debug_print_parse on.
1946 if (node->utilityStmt)
1948 switch (nodeTag(node->utilityStmt))
1953 case T_DeclareCursorStmt:
1954 WRITE_NODE_FIELD(utilityStmt);
1957 appendStringInfo(str, " :utilityStmt ?");
1962 appendStringInfo(str, " :utilityStmt <>");
1964 WRITE_INT_FIELD(resultRelation);
1965 WRITE_NODE_FIELD(intoClause);
1966 WRITE_BOOL_FIELD(hasAggs);
1967 WRITE_BOOL_FIELD(hasWindowFuncs);
1968 WRITE_BOOL_FIELD(hasSubLinks);
1969 WRITE_BOOL_FIELD(hasDistinctOn);
1970 WRITE_BOOL_FIELD(hasRecursive);
1971 WRITE_NODE_FIELD(cteList);
1972 WRITE_NODE_FIELD(rtable);
1973 WRITE_NODE_FIELD(jointree);
1974 WRITE_NODE_FIELD(targetList);
1975 WRITE_NODE_FIELD(returningList);
1976 WRITE_NODE_FIELD(groupClause);
1977 WRITE_NODE_FIELD(havingQual);
1978 WRITE_NODE_FIELD(windowClause);
1979 WRITE_NODE_FIELD(distinctClause);
1980 WRITE_NODE_FIELD(sortClause);
1981 WRITE_NODE_FIELD(limitOffset);
1982 WRITE_NODE_FIELD(limitCount);
1983 WRITE_NODE_FIELD(rowMarks);
1984 WRITE_NODE_FIELD(setOperations);
1988 _outSortGroupClause(StringInfo str, SortGroupClause *node)
1990 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
1992 WRITE_UINT_FIELD(tleSortGroupRef);
1993 WRITE_OID_FIELD(eqop);
1994 WRITE_OID_FIELD(sortop);
1995 WRITE_BOOL_FIELD(nulls_first);
1999 _outWindowClause(StringInfo str, WindowClause *node)
2001 WRITE_NODE_TYPE("WINDOWCLAUSE");
2003 WRITE_STRING_FIELD(name);
2004 WRITE_STRING_FIELD(refname);
2005 WRITE_NODE_FIELD(partitionClause);
2006 WRITE_NODE_FIELD(orderClause);
2007 WRITE_INT_FIELD(frameOptions);
2008 WRITE_UINT_FIELD(winref);
2009 WRITE_BOOL_FIELD(copiedOrder);
2013 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2015 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2017 WRITE_UINT_FIELD(rti);
2018 WRITE_UINT_FIELD(prti);
2019 WRITE_UINT_FIELD(rowmarkId);
2020 WRITE_BOOL_FIELD(forUpdate);
2021 WRITE_BOOL_FIELD(noWait);
2022 WRITE_BOOL_FIELD(isParent);
2026 _outWithClause(StringInfo str, WithClause *node)
2028 WRITE_NODE_TYPE("WITHCLAUSE");
2030 WRITE_NODE_FIELD(ctes);
2031 WRITE_BOOL_FIELD(recursive);
2032 WRITE_LOCATION_FIELD(location);
2036 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2038 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2040 WRITE_STRING_FIELD(ctename);
2041 WRITE_NODE_FIELD(aliascolnames);
2042 WRITE_NODE_FIELD(ctequery);
2043 WRITE_LOCATION_FIELD(location);
2044 WRITE_BOOL_FIELD(cterecursive);
2045 WRITE_INT_FIELD(cterefcount);
2046 WRITE_NODE_FIELD(ctecolnames);
2047 WRITE_NODE_FIELD(ctecoltypes);
2048 WRITE_NODE_FIELD(ctecoltypmods);
2052 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2054 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2056 WRITE_ENUM_FIELD(op, SetOperation);
2057 WRITE_BOOL_FIELD(all);
2058 WRITE_NODE_FIELD(larg);
2059 WRITE_NODE_FIELD(rarg);
2060 WRITE_NODE_FIELD(colTypes);
2061 WRITE_NODE_FIELD(colTypmods);
2062 WRITE_NODE_FIELD(groupClauses);
2066 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2068 WRITE_NODE_TYPE("RTE");
2070 /* put alias + eref first to make dump more legible */
2071 WRITE_NODE_FIELD(alias);
2072 WRITE_NODE_FIELD(eref);
2073 WRITE_ENUM_FIELD(rtekind, RTEKind);
2075 switch (node->rtekind)
2079 WRITE_OID_FIELD(relid);
2082 WRITE_NODE_FIELD(subquery);
2085 WRITE_ENUM_FIELD(jointype, JoinType);
2086 WRITE_NODE_FIELD(joinaliasvars);
2089 WRITE_NODE_FIELD(funcexpr);
2090 WRITE_NODE_FIELD(funccoltypes);
2091 WRITE_NODE_FIELD(funccoltypmods);
2094 WRITE_NODE_FIELD(values_lists);
2097 WRITE_STRING_FIELD(ctename);
2098 WRITE_UINT_FIELD(ctelevelsup);
2099 WRITE_BOOL_FIELD(self_reference);
2100 WRITE_NODE_FIELD(ctecoltypes);
2101 WRITE_NODE_FIELD(ctecoltypmods);
2104 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2108 WRITE_BOOL_FIELD(inh);
2109 WRITE_BOOL_FIELD(inFromCl);
2110 WRITE_UINT_FIELD(requiredPerms);
2111 WRITE_OID_FIELD(checkAsUser);
2112 WRITE_BITMAPSET_FIELD(selectedCols);
2113 WRITE_BITMAPSET_FIELD(modifiedCols);
2117 _outAExpr(StringInfo str, A_Expr *node)
2119 WRITE_NODE_TYPE("AEXPR");
2124 appendStringInfo(str, " ");
2125 WRITE_NODE_FIELD(name);
2128 appendStringInfo(str, " AND");
2131 appendStringInfo(str, " OR");
2134 appendStringInfo(str, " NOT");
2137 appendStringInfo(str, " ");
2138 WRITE_NODE_FIELD(name);
2139 appendStringInfo(str, " ANY ");
2142 appendStringInfo(str, " ");
2143 WRITE_NODE_FIELD(name);
2144 appendStringInfo(str, " ALL ");
2146 case AEXPR_DISTINCT:
2147 appendStringInfo(str, " DISTINCT ");
2148 WRITE_NODE_FIELD(name);
2151 appendStringInfo(str, " NULLIF ");
2152 WRITE_NODE_FIELD(name);
2155 appendStringInfo(str, " OF ");
2156 WRITE_NODE_FIELD(name);
2159 appendStringInfo(str, " IN ");
2160 WRITE_NODE_FIELD(name);
2163 appendStringInfo(str, " ??");
2167 WRITE_NODE_FIELD(lexpr);
2168 WRITE_NODE_FIELD(rexpr);
2169 WRITE_LOCATION_FIELD(location);
2173 _outValue(StringInfo str, Value *value)
2175 switch (value->type)
2178 appendStringInfo(str, "%ld", value->val.ival);
2183 * We assume the value is a valid numeric literal and so does not
2186 appendStringInfoString(str, value->val.str);
2189 appendStringInfoChar(str, '"');
2190 _outToken(str, value->val.str);
2191 appendStringInfoChar(str, '"');
2194 /* internal representation already has leading 'b' */
2195 appendStringInfoString(str, value->val.str);
2198 /* this is seen only within A_Const, not in transformed trees */
2199 appendStringInfoString(str, "NULL");
2202 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2208 _outColumnRef(StringInfo str, ColumnRef *node)
2210 WRITE_NODE_TYPE("COLUMNREF");
2212 WRITE_NODE_FIELD(fields);
2213 WRITE_LOCATION_FIELD(location);
2217 _outParamRef(StringInfo str, ParamRef *node)
2219 WRITE_NODE_TYPE("PARAMREF");
2221 WRITE_INT_FIELD(number);
2222 WRITE_LOCATION_FIELD(location);
2226 _outAConst(StringInfo str, A_Const *node)
2228 WRITE_NODE_TYPE("A_CONST");
2230 appendStringInfo(str, " :val ");
2231 _outValue(str, &(node->val));
2232 WRITE_LOCATION_FIELD(location);
2236 _outA_Star(StringInfo str, A_Star *node)
2238 WRITE_NODE_TYPE("A_STAR");
2242 _outA_Indices(StringInfo str, A_Indices *node)
2244 WRITE_NODE_TYPE("A_INDICES");
2246 WRITE_NODE_FIELD(lidx);
2247 WRITE_NODE_FIELD(uidx);
2251 _outA_Indirection(StringInfo str, A_Indirection *node)
2253 WRITE_NODE_TYPE("A_INDIRECTION");
2255 WRITE_NODE_FIELD(arg);
2256 WRITE_NODE_FIELD(indirection);
2260 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2262 WRITE_NODE_TYPE("A_ARRAYEXPR");
2264 WRITE_NODE_FIELD(elements);
2265 WRITE_LOCATION_FIELD(location);
2269 _outResTarget(StringInfo str, ResTarget *node)
2271 WRITE_NODE_TYPE("RESTARGET");
2273 WRITE_STRING_FIELD(name);
2274 WRITE_NODE_FIELD(indirection);
2275 WRITE_NODE_FIELD(val);
2276 WRITE_LOCATION_FIELD(location);
2280 _outSortBy(StringInfo str, SortBy *node)
2282 WRITE_NODE_TYPE("SORTBY");
2284 WRITE_NODE_FIELD(node);
2285 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2286 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2287 WRITE_NODE_FIELD(useOp);
2288 WRITE_LOCATION_FIELD(location);
2292 _outWindowDef(StringInfo str, WindowDef *node)
2294 WRITE_NODE_TYPE("WINDOWDEF");
2296 WRITE_STRING_FIELD(name);
2297 WRITE_STRING_FIELD(refname);
2298 WRITE_NODE_FIELD(partitionClause);
2299 WRITE_NODE_FIELD(orderClause);
2300 WRITE_INT_FIELD(frameOptions);
2301 WRITE_LOCATION_FIELD(location);
2305 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2307 WRITE_NODE_TYPE("RANGESUBSELECT");
2309 WRITE_NODE_FIELD(subquery);
2310 WRITE_NODE_FIELD(alias);
2314 _outRangeFunction(StringInfo str, RangeFunction *node)
2316 WRITE_NODE_TYPE("RANGEFUNCTION");
2318 WRITE_NODE_FIELD(funccallnode);
2319 WRITE_NODE_FIELD(alias);
2320 WRITE_NODE_FIELD(coldeflist);
2324 _outConstraint(StringInfo str, Constraint *node)
2326 WRITE_NODE_TYPE("CONSTRAINT");
2328 WRITE_STRING_FIELD(conname);
2329 WRITE_BOOL_FIELD(deferrable);
2330 WRITE_BOOL_FIELD(initdeferred);
2331 WRITE_LOCATION_FIELD(location);
2333 appendStringInfo(str, " :contype ");
2334 switch (node->contype)
2337 appendStringInfo(str, "NULL");
2340 case CONSTR_NOTNULL:
2341 appendStringInfo(str, "NOT_NULL");
2344 case CONSTR_DEFAULT:
2345 appendStringInfo(str, "DEFAULT");
2346 WRITE_NODE_FIELD(raw_expr);
2347 WRITE_STRING_FIELD(cooked_expr);
2351 appendStringInfo(str, "CHECK");
2352 WRITE_NODE_FIELD(raw_expr);
2353 WRITE_STRING_FIELD(cooked_expr);
2356 case CONSTR_PRIMARY:
2357 appendStringInfo(str, "PRIMARY_KEY");
2358 WRITE_NODE_FIELD(keys);
2359 WRITE_NODE_FIELD(options);
2360 WRITE_STRING_FIELD(indexspace);
2364 appendStringInfo(str, "UNIQUE");
2365 WRITE_NODE_FIELD(keys);
2366 WRITE_NODE_FIELD(options);
2367 WRITE_STRING_FIELD(indexspace);
2370 case CONSTR_FOREIGN:
2371 appendStringInfo(str, "FOREIGN_KEY");
2372 WRITE_NODE_FIELD(pktable);
2373 WRITE_NODE_FIELD(fk_attrs);
2374 WRITE_NODE_FIELD(pk_attrs);
2375 WRITE_CHAR_FIELD(fk_matchtype);
2376 WRITE_CHAR_FIELD(fk_upd_action);
2377 WRITE_CHAR_FIELD(fk_del_action);
2378 WRITE_BOOL_FIELD(skip_validation);
2381 case CONSTR_ATTR_DEFERRABLE:
2382 appendStringInfo(str, "ATTR_DEFERRABLE");
2385 case CONSTR_ATTR_NOT_DEFERRABLE:
2386 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2389 case CONSTR_ATTR_DEFERRED:
2390 appendStringInfo(str, "ATTR_DEFERRED");
2393 case CONSTR_ATTR_IMMEDIATE:
2394 appendStringInfo(str, "ATTR_IMMEDIATE");
2398 appendStringInfo(str, "<unrecognized_constraint %d>",
2399 (int) node->contype);
2407 * converts a Node into ascii string and append it to 'str'
2410 _outNode(StringInfo str, void *obj)
2413 appendStringInfo(str, "<>");
2414 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2416 else if (IsA(obj, Integer) ||
2419 IsA(obj, BitString))
2421 /* nodeRead does not want to see { } around these! */
2422 _outValue(str, obj);
2426 appendStringInfoChar(str, '{');
2427 switch (nodeTag(obj))
2430 _outPlannedStmt(str, obj);
2436 _outResult(str, obj);
2439 _outModifyTable(str, obj);
2442 _outAppend(str, obj);
2444 case T_RecursiveUnion:
2445 _outRecursiveUnion(str, obj);
2448 _outBitmapAnd(str, obj);
2451 _outBitmapOr(str, obj);
2457 _outSeqScan(str, obj);
2460 _outIndexScan(str, obj);
2462 case T_BitmapIndexScan:
2463 _outBitmapIndexScan(str, obj);
2465 case T_BitmapHeapScan:
2466 _outBitmapHeapScan(str, obj);
2469 _outTidScan(str, obj);
2471 case T_SubqueryScan:
2472 _outSubqueryScan(str, obj);
2474 case T_FunctionScan:
2475 _outFunctionScan(str, obj);
2478 _outValuesScan(str, obj);
2481 _outCteScan(str, obj);
2483 case T_WorkTableScan:
2484 _outWorkTableScan(str, obj);
2490 _outNestLoop(str, obj);
2493 _outMergeJoin(str, obj);
2496 _outHashJoin(str, obj);
2502 _outWindowAgg(str, obj);
2505 _outGroup(str, obj);
2508 _outMaterial(str, obj);
2514 _outUnique(str, obj);
2520 _outSetOp(str, obj);
2523 _outLockRows(str, obj);
2526 _outLimit(str, obj);
2528 case T_PlanInvalItem:
2529 _outPlanInvalItem(str, obj);
2532 _outAlias(str, obj);
2535 _outRangeVar(str, obj);
2538 _outIntoClause(str, obj);
2544 _outConst(str, obj);
2547 _outParam(str, obj);
2550 _outAggref(str, obj);
2553 _outWindowFunc(str, obj);
2556 _outArrayRef(str, obj);
2559 _outFuncExpr(str, obj);
2561 case T_NamedArgExpr:
2562 _outNamedArgExpr(str, obj);
2565 _outOpExpr(str, obj);
2567 case T_DistinctExpr:
2568 _outDistinctExpr(str, obj);
2570 case T_ScalarArrayOpExpr:
2571 _outScalarArrayOpExpr(str, obj);
2574 _outBoolExpr(str, obj);
2577 _outSubLink(str, obj);
2580 _outSubPlan(str, obj);
2582 case T_AlternativeSubPlan:
2583 _outAlternativeSubPlan(str, obj);
2586 _outFieldSelect(str, obj);
2589 _outFieldStore(str, obj);
2592 _outRelabelType(str, obj);
2595 _outCoerceViaIO(str, obj);
2597 case T_ArrayCoerceExpr:
2598 _outArrayCoerceExpr(str, obj);
2600 case T_ConvertRowtypeExpr:
2601 _outConvertRowtypeExpr(str, obj);
2604 _outCaseExpr(str, obj);
2607 _outCaseWhen(str, obj);
2609 case T_CaseTestExpr:
2610 _outCaseTestExpr(str, obj);
2613 _outArrayExpr(str, obj);
2616 _outRowExpr(str, obj);
2618 case T_RowCompareExpr:
2619 _outRowCompareExpr(str, obj);
2621 case T_CoalesceExpr:
2622 _outCoalesceExpr(str, obj);
2625 _outMinMaxExpr(str, obj);
2628 _outXmlExpr(str, obj);
2631 _outNullIfExpr(str, obj);
2634 _outNullTest(str, obj);
2637 _outBooleanTest(str, obj);
2639 case T_CoerceToDomain:
2640 _outCoerceToDomain(str, obj);
2642 case T_CoerceToDomainValue:
2643 _outCoerceToDomainValue(str, obj);
2645 case T_SetToDefault:
2646 _outSetToDefault(str, obj);
2648 case T_CurrentOfExpr:
2649 _outCurrentOfExpr(str, obj);
2652 _outTargetEntry(str, obj);
2655 _outRangeTblRef(str, obj);
2658 _outJoinExpr(str, obj);
2661 _outFromExpr(str, obj);
2668 _outIndexPath(str, obj);
2670 case T_BitmapHeapPath:
2671 _outBitmapHeapPath(str, obj);
2673 case T_BitmapAndPath:
2674 _outBitmapAndPath(str, obj);
2676 case T_BitmapOrPath:
2677 _outBitmapOrPath(str, obj);
2680 _outTidPath(str, obj);
2683 _outAppendPath(str, obj);
2686 _outResultPath(str, obj);
2688 case T_MaterialPath:
2689 _outMaterialPath(str, obj);
2692 _outUniquePath(str, obj);
2695 _outNoOpPath(str, obj);
2698 _outNestPath(str, obj);
2701 _outMergePath(str, obj);
2704 _outHashPath(str, obj);
2706 case T_PlannerGlobal:
2707 _outPlannerGlobal(str, obj);
2710 _outPlannerInfo(str, obj);
2713 _outRelOptInfo(str, obj);
2715 case T_IndexOptInfo:
2716 _outIndexOptInfo(str, obj);
2718 case T_EquivalenceClass:
2719 _outEquivalenceClass(str, obj);
2721 case T_EquivalenceMember:
2722 _outEquivalenceMember(str, obj);
2725 _outPathKey(str, obj);
2727 case T_RestrictInfo:
2728 _outRestrictInfo(str, obj);
2730 case T_InnerIndexscanInfo:
2731 _outInnerIndexscanInfo(str, obj);
2733 case T_PlaceHolderVar:
2734 _outPlaceHolderVar(str, obj);
2736 case T_SpecialJoinInfo:
2737 _outSpecialJoinInfo(str, obj);
2739 case T_AppendRelInfo:
2740 _outAppendRelInfo(str, obj);
2742 case T_PlaceHolderInfo:
2743 _outPlaceHolderInfo(str, obj);
2745 case T_PlannerParamItem:
2746 _outPlannerParamItem(str, obj);
2750 _outCreateStmt(str, obj);
2753 _outIndexStmt(str, obj);
2756 _outNotifyStmt(str, obj);
2758 case T_DeclareCursorStmt:
2759 _outDeclareCursorStmt(str, obj);
2762 _outSelectStmt(str, obj);
2765 _outColumnDef(str, obj);
2768 _outTypeName(str, obj);
2771 _outTypeCast(str, obj);
2774 _outIndexElem(str, obj);
2777 _outQuery(str, obj);
2779 case T_SortGroupClause:
2780 _outSortGroupClause(str, obj);
2782 case T_WindowClause:
2783 _outWindowClause(str, obj);
2785 case T_RowMarkClause:
2786 _outRowMarkClause(str, obj);
2789 _outWithClause(str, obj);
2791 case T_CommonTableExpr:
2792 _outCommonTableExpr(str, obj);
2794 case T_SetOperationStmt:
2795 _outSetOperationStmt(str, obj);
2797 case T_RangeTblEntry:
2798 _outRangeTblEntry(str, obj);
2801 _outAExpr(str, obj);
2804 _outColumnRef(str, obj);
2807 _outParamRef(str, obj);
2810 _outAConst(str, obj);
2813 _outA_Star(str, obj);
2816 _outA_Indices(str, obj);
2818 case T_A_Indirection:
2819 _outA_Indirection(str, obj);
2822 _outA_ArrayExpr(str, obj);
2825 _outResTarget(str, obj);
2828 _outSortBy(str, obj);
2831 _outWindowDef(str, obj);
2833 case T_RangeSubselect:
2834 _outRangeSubselect(str, obj);
2836 case T_RangeFunction:
2837 _outRangeFunction(str, obj);
2840 _outConstraint(str, obj);
2843 _outFuncCall(str, obj);
2846 _outDefElem(str, obj);
2848 case T_LockingClause:
2849 _outLockingClause(str, obj);
2851 case T_XmlSerialize:
2852 _outXmlSerialize(str, obj);
2858 * This should be an ERROR, but it's too useful to be able to
2859 * dump structures that _outNode only understands part of.
2861 elog(WARNING, "could not dump unrecognized node type: %d",
2862 (int) nodeTag(obj));
2865 appendStringInfoChar(str, '}');
2871 * returns the ascii representation of the Node as a palloc'd string
2874 nodeToString(void *obj)
2878 /* see stringinfo.h for an explanation of this maneuver */
2879 initStringInfo(&str);
2880 _outNode(&str, obj);