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.367 2009/10/10 01:43:49 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);
460 _outFunctionScan(StringInfo str, FunctionScan *node)
462 WRITE_NODE_TYPE("FUNCTIONSCAN");
464 _outScanInfo(str, (Scan *) node);
466 WRITE_NODE_FIELD(funcexpr);
467 WRITE_NODE_FIELD(funccolnames);
468 WRITE_NODE_FIELD(funccoltypes);
469 WRITE_NODE_FIELD(funccoltypmods);
473 _outValuesScan(StringInfo str, ValuesScan *node)
475 WRITE_NODE_TYPE("VALUESSCAN");
477 _outScanInfo(str, (Scan *) node);
479 WRITE_NODE_FIELD(values_lists);
483 _outCteScan(StringInfo str, CteScan *node)
485 WRITE_NODE_TYPE("CTESCAN");
487 _outScanInfo(str, (Scan *) node);
489 WRITE_INT_FIELD(ctePlanId);
490 WRITE_INT_FIELD(cteParam);
494 _outWorkTableScan(StringInfo str, WorkTableScan *node)
496 WRITE_NODE_TYPE("WORKTABLESCAN");
498 _outScanInfo(str, (Scan *) node);
500 WRITE_INT_FIELD(wtParam);
504 _outJoin(StringInfo str, Join *node)
506 WRITE_NODE_TYPE("JOIN");
508 _outJoinPlanInfo(str, (Join *) node);
512 _outNestLoop(StringInfo str, NestLoop *node)
514 WRITE_NODE_TYPE("NESTLOOP");
516 _outJoinPlanInfo(str, (Join *) node);
520 _outMergeJoin(StringInfo str, MergeJoin *node)
525 WRITE_NODE_TYPE("MERGEJOIN");
527 _outJoinPlanInfo(str, (Join *) node);
529 WRITE_NODE_FIELD(mergeclauses);
531 numCols = list_length(node->mergeclauses);
533 appendStringInfo(str, " :mergeFamilies");
534 for (i = 0; i < numCols; i++)
535 appendStringInfo(str, " %u", node->mergeFamilies[i]);
537 appendStringInfo(str, " :mergeStrategies");
538 for (i = 0; i < numCols; i++)
539 appendStringInfo(str, " %d", node->mergeStrategies[i]);
541 appendStringInfo(str, " :mergeNullsFirst");
542 for (i = 0; i < numCols; i++)
543 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
547 _outHashJoin(StringInfo str, HashJoin *node)
549 WRITE_NODE_TYPE("HASHJOIN");
551 _outJoinPlanInfo(str, (Join *) node);
553 WRITE_NODE_FIELD(hashclauses);
557 _outAgg(StringInfo str, Agg *node)
561 WRITE_NODE_TYPE("AGG");
563 _outPlanInfo(str, (Plan *) node);
565 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
566 WRITE_INT_FIELD(numCols);
568 appendStringInfo(str, " :grpColIdx");
569 for (i = 0; i < node->numCols; i++)
570 appendStringInfo(str, " %d", node->grpColIdx[i]);
572 appendStringInfo(str, " :grpOperators");
573 for (i = 0; i < node->numCols; i++)
574 appendStringInfo(str, " %u", node->grpOperators[i]);
576 WRITE_LONG_FIELD(numGroups);
580 _outWindowAgg(StringInfo str, WindowAgg *node)
584 WRITE_NODE_TYPE("WINDOWAGG");
586 _outPlanInfo(str, (Plan *) node);
588 WRITE_UINT_FIELD(winref);
589 WRITE_INT_FIELD(partNumCols);
591 appendStringInfo(str, " :partColIdx");
592 for (i = 0; i < node->partNumCols; i++)
593 appendStringInfo(str, " %d", node->partColIdx[i]);
595 appendStringInfo(str, " :partOperations");
596 for (i = 0; i < node->partNumCols; i++)
597 appendStringInfo(str, " %u", node->partOperators[i]);
599 WRITE_INT_FIELD(ordNumCols);
601 appendStringInfo(str, " :ordColIdx");
602 for (i = 0; i < node->ordNumCols; i++)
603 appendStringInfo(str, " %d", node->ordColIdx[i]);
605 appendStringInfo(str, " :ordOperations");
606 for (i = 0; i < node->ordNumCols; i++)
607 appendStringInfo(str, " %u", node->ordOperators[i]);
609 WRITE_INT_FIELD(frameOptions);
613 _outGroup(StringInfo str, Group *node)
617 WRITE_NODE_TYPE("GROUP");
619 _outPlanInfo(str, (Plan *) node);
621 WRITE_INT_FIELD(numCols);
623 appendStringInfo(str, " :grpColIdx");
624 for (i = 0; i < node->numCols; i++)
625 appendStringInfo(str, " %d", node->grpColIdx[i]);
627 appendStringInfo(str, " :grpOperators");
628 for (i = 0; i < node->numCols; i++)
629 appendStringInfo(str, " %u", node->grpOperators[i]);
633 _outMaterial(StringInfo str, Material *node)
635 WRITE_NODE_TYPE("MATERIAL");
637 _outPlanInfo(str, (Plan *) node);
641 _outSort(StringInfo str, Sort *node)
645 WRITE_NODE_TYPE("SORT");
647 _outPlanInfo(str, (Plan *) node);
649 WRITE_INT_FIELD(numCols);
651 appendStringInfo(str, " :sortColIdx");
652 for (i = 0; i < node->numCols; i++)
653 appendStringInfo(str, " %d", node->sortColIdx[i]);
655 appendStringInfo(str, " :sortOperators");
656 for (i = 0; i < node->numCols; i++)
657 appendStringInfo(str, " %u", node->sortOperators[i]);
659 appendStringInfo(str, " :nullsFirst");
660 for (i = 0; i < node->numCols; i++)
661 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
665 _outUnique(StringInfo str, Unique *node)
669 WRITE_NODE_TYPE("UNIQUE");
671 _outPlanInfo(str, (Plan *) node);
673 WRITE_INT_FIELD(numCols);
675 appendStringInfo(str, " :uniqColIdx");
676 for (i = 0; i < node->numCols; i++)
677 appendStringInfo(str, " %d", node->uniqColIdx[i]);
679 appendStringInfo(str, " :uniqOperators");
680 for (i = 0; i < node->numCols; i++)
681 appendStringInfo(str, " %u", node->uniqOperators[i]);
685 _outHash(StringInfo str, Hash *node)
687 WRITE_NODE_TYPE("HASH");
689 _outPlanInfo(str, (Plan *) node);
691 WRITE_OID_FIELD(skewTable);
692 WRITE_INT_FIELD(skewColumn);
693 WRITE_OID_FIELD(skewColType);
694 WRITE_INT_FIELD(skewColTypmod);
698 _outSetOp(StringInfo str, SetOp *node)
702 WRITE_NODE_TYPE("SETOP");
704 _outPlanInfo(str, (Plan *) node);
706 WRITE_ENUM_FIELD(cmd, SetOpCmd);
707 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
708 WRITE_INT_FIELD(numCols);
710 appendStringInfo(str, " :dupColIdx");
711 for (i = 0; i < node->numCols; i++)
712 appendStringInfo(str, " %d", node->dupColIdx[i]);
714 appendStringInfo(str, " :dupOperators");
715 for (i = 0; i < node->numCols; i++)
716 appendStringInfo(str, " %u", node->dupOperators[i]);
718 WRITE_INT_FIELD(flagColIdx);
719 WRITE_INT_FIELD(firstFlag);
720 WRITE_LONG_FIELD(numGroups);
724 _outLimit(StringInfo str, Limit *node)
726 WRITE_NODE_TYPE("LIMIT");
728 _outPlanInfo(str, (Plan *) node);
730 WRITE_NODE_FIELD(limitOffset);
731 WRITE_NODE_FIELD(limitCount);
735 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
737 WRITE_NODE_TYPE("PLANINVALITEM");
739 WRITE_INT_FIELD(cacheId);
740 appendStringInfo(str, " :tupleId (%u,%u)",
741 ItemPointerGetBlockNumber(&node->tupleId),
742 ItemPointerGetOffsetNumber(&node->tupleId));
745 /*****************************************************************************
747 * Stuff from primnodes.h.
749 *****************************************************************************/
752 _outAlias(StringInfo str, Alias *node)
754 WRITE_NODE_TYPE("ALIAS");
756 WRITE_STRING_FIELD(aliasname);
757 WRITE_NODE_FIELD(colnames);
761 _outRangeVar(StringInfo str, RangeVar *node)
763 WRITE_NODE_TYPE("RANGEVAR");
766 * we deliberately ignore catalogname here, since it is presently not
767 * semantically meaningful
769 WRITE_STRING_FIELD(schemaname);
770 WRITE_STRING_FIELD(relname);
771 WRITE_ENUM_FIELD(inhOpt, InhOption);
772 WRITE_BOOL_FIELD(istemp);
773 WRITE_NODE_FIELD(alias);
774 WRITE_LOCATION_FIELD(location);
778 _outIntoClause(StringInfo str, IntoClause *node)
780 WRITE_NODE_TYPE("INTOCLAUSE");
782 WRITE_NODE_FIELD(rel);
783 WRITE_NODE_FIELD(colNames);
784 WRITE_NODE_FIELD(options);
785 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
786 WRITE_STRING_FIELD(tableSpaceName);
790 _outVar(StringInfo str, Var *node)
792 WRITE_NODE_TYPE("VAR");
794 WRITE_UINT_FIELD(varno);
795 WRITE_INT_FIELD(varattno);
796 WRITE_OID_FIELD(vartype);
797 WRITE_INT_FIELD(vartypmod);
798 WRITE_UINT_FIELD(varlevelsup);
799 WRITE_UINT_FIELD(varnoold);
800 WRITE_INT_FIELD(varoattno);
801 WRITE_LOCATION_FIELD(location);
805 _outConst(StringInfo str, Const *node)
807 WRITE_NODE_TYPE("CONST");
809 WRITE_OID_FIELD(consttype);
810 WRITE_INT_FIELD(consttypmod);
811 WRITE_INT_FIELD(constlen);
812 WRITE_BOOL_FIELD(constbyval);
813 WRITE_BOOL_FIELD(constisnull);
814 WRITE_LOCATION_FIELD(location);
816 appendStringInfo(str, " :constvalue ");
817 if (node->constisnull)
818 appendStringInfo(str, "<>");
820 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
824 _outParam(StringInfo str, Param *node)
826 WRITE_NODE_TYPE("PARAM");
828 WRITE_ENUM_FIELD(paramkind, ParamKind);
829 WRITE_INT_FIELD(paramid);
830 WRITE_OID_FIELD(paramtype);
831 WRITE_INT_FIELD(paramtypmod);
832 WRITE_LOCATION_FIELD(location);
836 _outAggref(StringInfo str, Aggref *node)
838 WRITE_NODE_TYPE("AGGREF");
840 WRITE_OID_FIELD(aggfnoid);
841 WRITE_OID_FIELD(aggtype);
842 WRITE_NODE_FIELD(args);
843 WRITE_UINT_FIELD(agglevelsup);
844 WRITE_BOOL_FIELD(aggstar);
845 WRITE_BOOL_FIELD(aggdistinct);
846 WRITE_LOCATION_FIELD(location);
850 _outWindowFunc(StringInfo str, WindowFunc *node)
852 WRITE_NODE_TYPE("WINDOWFUNC");
854 WRITE_OID_FIELD(winfnoid);
855 WRITE_OID_FIELD(wintype);
856 WRITE_NODE_FIELD(args);
857 WRITE_UINT_FIELD(winref);
858 WRITE_BOOL_FIELD(winstar);
859 WRITE_BOOL_FIELD(winagg);
860 WRITE_LOCATION_FIELD(location);
864 _outArrayRef(StringInfo str, ArrayRef *node)
866 WRITE_NODE_TYPE("ARRAYREF");
868 WRITE_OID_FIELD(refarraytype);
869 WRITE_OID_FIELD(refelemtype);
870 WRITE_INT_FIELD(reftypmod);
871 WRITE_NODE_FIELD(refupperindexpr);
872 WRITE_NODE_FIELD(reflowerindexpr);
873 WRITE_NODE_FIELD(refexpr);
874 WRITE_NODE_FIELD(refassgnexpr);
878 _outFuncExpr(StringInfo str, FuncExpr *node)
880 WRITE_NODE_TYPE("FUNCEXPR");
882 WRITE_OID_FIELD(funcid);
883 WRITE_OID_FIELD(funcresulttype);
884 WRITE_BOOL_FIELD(funcretset);
885 WRITE_ENUM_FIELD(funcformat, CoercionForm);
886 WRITE_NODE_FIELD(args);
887 WRITE_LOCATION_FIELD(location);
891 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
893 WRITE_NODE_TYPE("NAMEDARGEXPR");
895 WRITE_NODE_FIELD(arg);
896 WRITE_STRING_FIELD(name);
897 WRITE_INT_FIELD(argnumber);
898 WRITE_LOCATION_FIELD(location);
902 _outOpExpr(StringInfo str, OpExpr *node)
904 WRITE_NODE_TYPE("OPEXPR");
906 WRITE_OID_FIELD(opno);
907 WRITE_OID_FIELD(opfuncid);
908 WRITE_OID_FIELD(opresulttype);
909 WRITE_BOOL_FIELD(opretset);
910 WRITE_NODE_FIELD(args);
911 WRITE_LOCATION_FIELD(location);
915 _outDistinctExpr(StringInfo str, DistinctExpr *node)
917 WRITE_NODE_TYPE("DISTINCTEXPR");
919 WRITE_OID_FIELD(opno);
920 WRITE_OID_FIELD(opfuncid);
921 WRITE_OID_FIELD(opresulttype);
922 WRITE_BOOL_FIELD(opretset);
923 WRITE_NODE_FIELD(args);
924 WRITE_LOCATION_FIELD(location);
928 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
930 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
932 WRITE_OID_FIELD(opno);
933 WRITE_OID_FIELD(opfuncid);
934 WRITE_BOOL_FIELD(useOr);
935 WRITE_NODE_FIELD(args);
936 WRITE_LOCATION_FIELD(location);
940 _outBoolExpr(StringInfo str, BoolExpr *node)
944 WRITE_NODE_TYPE("BOOLEXPR");
946 /* do-it-yourself enum representation */
947 switch (node->boolop)
959 appendStringInfo(str, " :boolop ");
960 _outToken(str, opstr);
962 WRITE_NODE_FIELD(args);
963 WRITE_LOCATION_FIELD(location);
967 _outSubLink(StringInfo str, SubLink *node)
969 WRITE_NODE_TYPE("SUBLINK");
971 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
972 WRITE_NODE_FIELD(testexpr);
973 WRITE_NODE_FIELD(operName);
974 WRITE_NODE_FIELD(subselect);
975 WRITE_LOCATION_FIELD(location);
979 _outSubPlan(StringInfo str, SubPlan *node)
981 WRITE_NODE_TYPE("SUBPLAN");
983 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
984 WRITE_NODE_FIELD(testexpr);
985 WRITE_NODE_FIELD(paramIds);
986 WRITE_INT_FIELD(plan_id);
987 WRITE_STRING_FIELD(plan_name);
988 WRITE_OID_FIELD(firstColType);
989 WRITE_INT_FIELD(firstColTypmod);
990 WRITE_BOOL_FIELD(useHashTable);
991 WRITE_BOOL_FIELD(unknownEqFalse);
992 WRITE_NODE_FIELD(setParam);
993 WRITE_NODE_FIELD(parParam);
994 WRITE_NODE_FIELD(args);
995 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
996 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1000 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1002 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1004 WRITE_NODE_FIELD(subplans);
1008 _outFieldSelect(StringInfo str, FieldSelect *node)
1010 WRITE_NODE_TYPE("FIELDSELECT");
1012 WRITE_NODE_FIELD(arg);
1013 WRITE_INT_FIELD(fieldnum);
1014 WRITE_OID_FIELD(resulttype);
1015 WRITE_INT_FIELD(resulttypmod);
1019 _outFieldStore(StringInfo str, FieldStore *node)
1021 WRITE_NODE_TYPE("FIELDSTORE");
1023 WRITE_NODE_FIELD(arg);
1024 WRITE_NODE_FIELD(newvals);
1025 WRITE_NODE_FIELD(fieldnums);
1026 WRITE_OID_FIELD(resulttype);
1030 _outRelabelType(StringInfo str, RelabelType *node)
1032 WRITE_NODE_TYPE("RELABELTYPE");
1034 WRITE_NODE_FIELD(arg);
1035 WRITE_OID_FIELD(resulttype);
1036 WRITE_INT_FIELD(resulttypmod);
1037 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1038 WRITE_LOCATION_FIELD(location);
1042 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1044 WRITE_NODE_TYPE("COERCEVIAIO");
1046 WRITE_NODE_FIELD(arg);
1047 WRITE_OID_FIELD(resulttype);
1048 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1049 WRITE_LOCATION_FIELD(location);
1053 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1055 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1057 WRITE_NODE_FIELD(arg);
1058 WRITE_OID_FIELD(elemfuncid);
1059 WRITE_OID_FIELD(resulttype);
1060 WRITE_INT_FIELD(resulttypmod);
1061 WRITE_BOOL_FIELD(isExplicit);
1062 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1063 WRITE_LOCATION_FIELD(location);
1067 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1069 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1071 WRITE_NODE_FIELD(arg);
1072 WRITE_OID_FIELD(resulttype);
1073 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1074 WRITE_LOCATION_FIELD(location);
1078 _outCaseExpr(StringInfo str, CaseExpr *node)
1080 WRITE_NODE_TYPE("CASE");
1082 WRITE_OID_FIELD(casetype);
1083 WRITE_NODE_FIELD(arg);
1084 WRITE_NODE_FIELD(args);
1085 WRITE_NODE_FIELD(defresult);
1086 WRITE_LOCATION_FIELD(location);
1090 _outCaseWhen(StringInfo str, CaseWhen *node)
1092 WRITE_NODE_TYPE("WHEN");
1094 WRITE_NODE_FIELD(expr);
1095 WRITE_NODE_FIELD(result);
1096 WRITE_LOCATION_FIELD(location);
1100 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1102 WRITE_NODE_TYPE("CASETESTEXPR");
1104 WRITE_OID_FIELD(typeId);
1105 WRITE_INT_FIELD(typeMod);
1109 _outArrayExpr(StringInfo str, ArrayExpr *node)
1111 WRITE_NODE_TYPE("ARRAY");
1113 WRITE_OID_FIELD(array_typeid);
1114 WRITE_OID_FIELD(element_typeid);
1115 WRITE_NODE_FIELD(elements);
1116 WRITE_BOOL_FIELD(multidims);
1117 WRITE_LOCATION_FIELD(location);
1121 _outRowExpr(StringInfo str, RowExpr *node)
1123 WRITE_NODE_TYPE("ROW");
1125 WRITE_NODE_FIELD(args);
1126 WRITE_OID_FIELD(row_typeid);
1127 WRITE_ENUM_FIELD(row_format, CoercionForm);
1128 WRITE_NODE_FIELD(colnames);
1129 WRITE_LOCATION_FIELD(location);
1133 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1135 WRITE_NODE_TYPE("ROWCOMPARE");
1137 WRITE_ENUM_FIELD(rctype, RowCompareType);
1138 WRITE_NODE_FIELD(opnos);
1139 WRITE_NODE_FIELD(opfamilies);
1140 WRITE_NODE_FIELD(largs);
1141 WRITE_NODE_FIELD(rargs);
1145 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1147 WRITE_NODE_TYPE("COALESCE");
1149 WRITE_OID_FIELD(coalescetype);
1150 WRITE_NODE_FIELD(args);
1151 WRITE_LOCATION_FIELD(location);
1155 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1157 WRITE_NODE_TYPE("MINMAX");
1159 WRITE_OID_FIELD(minmaxtype);
1160 WRITE_ENUM_FIELD(op, MinMaxOp);
1161 WRITE_NODE_FIELD(args);
1162 WRITE_LOCATION_FIELD(location);
1166 _outXmlExpr(StringInfo str, XmlExpr *node)
1168 WRITE_NODE_TYPE("XMLEXPR");
1170 WRITE_ENUM_FIELD(op, XmlExprOp);
1171 WRITE_STRING_FIELD(name);
1172 WRITE_NODE_FIELD(named_args);
1173 WRITE_NODE_FIELD(arg_names);
1174 WRITE_NODE_FIELD(args);
1175 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1176 WRITE_OID_FIELD(type);
1177 WRITE_INT_FIELD(typmod);
1178 WRITE_LOCATION_FIELD(location);
1182 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1184 WRITE_NODE_TYPE("NULLIFEXPR");
1186 WRITE_OID_FIELD(opno);
1187 WRITE_OID_FIELD(opfuncid);
1188 WRITE_OID_FIELD(opresulttype);
1189 WRITE_BOOL_FIELD(opretset);
1190 WRITE_NODE_FIELD(args);
1191 WRITE_LOCATION_FIELD(location);
1195 _outNullTest(StringInfo str, NullTest *node)
1197 WRITE_NODE_TYPE("NULLTEST");
1199 WRITE_NODE_FIELD(arg);
1200 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1204 _outBooleanTest(StringInfo str, BooleanTest *node)
1206 WRITE_NODE_TYPE("BOOLEANTEST");
1208 WRITE_NODE_FIELD(arg);
1209 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1213 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1215 WRITE_NODE_TYPE("COERCETODOMAIN");
1217 WRITE_NODE_FIELD(arg);
1218 WRITE_OID_FIELD(resulttype);
1219 WRITE_INT_FIELD(resulttypmod);
1220 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1221 WRITE_LOCATION_FIELD(location);
1225 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1227 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1229 WRITE_OID_FIELD(typeId);
1230 WRITE_INT_FIELD(typeMod);
1231 WRITE_LOCATION_FIELD(location);
1235 _outSetToDefault(StringInfo str, SetToDefault *node)
1237 WRITE_NODE_TYPE("SETTODEFAULT");
1239 WRITE_OID_FIELD(typeId);
1240 WRITE_INT_FIELD(typeMod);
1241 WRITE_LOCATION_FIELD(location);
1245 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1247 WRITE_NODE_TYPE("CURRENTOFEXPR");
1249 WRITE_UINT_FIELD(cvarno);
1250 WRITE_STRING_FIELD(cursor_name);
1251 WRITE_INT_FIELD(cursor_param);
1255 _outTargetEntry(StringInfo str, TargetEntry *node)
1257 WRITE_NODE_TYPE("TARGETENTRY");
1259 WRITE_NODE_FIELD(expr);
1260 WRITE_INT_FIELD(resno);
1261 WRITE_STRING_FIELD(resname);
1262 WRITE_UINT_FIELD(ressortgroupref);
1263 WRITE_OID_FIELD(resorigtbl);
1264 WRITE_INT_FIELD(resorigcol);
1265 WRITE_BOOL_FIELD(resjunk);
1269 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1271 WRITE_NODE_TYPE("RANGETBLREF");
1273 WRITE_INT_FIELD(rtindex);
1277 _outJoinExpr(StringInfo str, JoinExpr *node)
1279 WRITE_NODE_TYPE("JOINEXPR");
1281 WRITE_ENUM_FIELD(jointype, JoinType);
1282 WRITE_BOOL_FIELD(isNatural);
1283 WRITE_NODE_FIELD(larg);
1284 WRITE_NODE_FIELD(rarg);
1285 WRITE_NODE_FIELD(usingClause);
1286 WRITE_NODE_FIELD(quals);
1287 WRITE_NODE_FIELD(alias);
1288 WRITE_INT_FIELD(rtindex);
1292 _outFromExpr(StringInfo str, FromExpr *node)
1294 WRITE_NODE_TYPE("FROMEXPR");
1296 WRITE_NODE_FIELD(fromlist);
1297 WRITE_NODE_FIELD(quals);
1300 /*****************************************************************************
1302 * Stuff from relation.h.
1304 *****************************************************************************/
1307 * print the basic stuff of all nodes that inherit from Path
1309 * Note we do NOT print the parent, else we'd be in infinite recursion
1312 _outPathInfo(StringInfo str, Path *node)
1314 WRITE_ENUM_FIELD(pathtype, NodeTag);
1315 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1316 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1317 WRITE_NODE_FIELD(pathkeys);
1321 * print the basic stuff of all nodes that inherit from JoinPath
1324 _outJoinPathInfo(StringInfo str, JoinPath *node)
1326 _outPathInfo(str, (Path *) node);
1328 WRITE_ENUM_FIELD(jointype, JoinType);
1329 WRITE_NODE_FIELD(outerjoinpath);
1330 WRITE_NODE_FIELD(innerjoinpath);
1331 WRITE_NODE_FIELD(joinrestrictinfo);
1335 _outPath(StringInfo str, Path *node)
1337 WRITE_NODE_TYPE("PATH");
1339 _outPathInfo(str, (Path *) node);
1343 _outIndexPath(StringInfo str, IndexPath *node)
1345 WRITE_NODE_TYPE("INDEXPATH");
1347 _outPathInfo(str, (Path *) node);
1349 WRITE_NODE_FIELD(indexinfo);
1350 WRITE_NODE_FIELD(indexclauses);
1351 WRITE_NODE_FIELD(indexquals);
1352 WRITE_BOOL_FIELD(isjoininner);
1353 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1354 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1355 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1356 WRITE_FLOAT_FIELD(rows, "%.0f");
1360 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1362 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1364 _outPathInfo(str, (Path *) node);
1366 WRITE_NODE_FIELD(bitmapqual);
1367 WRITE_BOOL_FIELD(isjoininner);
1368 WRITE_FLOAT_FIELD(rows, "%.0f");
1372 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1374 WRITE_NODE_TYPE("BITMAPANDPATH");
1376 _outPathInfo(str, (Path *) node);
1378 WRITE_NODE_FIELD(bitmapquals);
1379 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1383 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1385 WRITE_NODE_TYPE("BITMAPORPATH");
1387 _outPathInfo(str, (Path *) node);
1389 WRITE_NODE_FIELD(bitmapquals);
1390 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1394 _outTidPath(StringInfo str, TidPath *node)
1396 WRITE_NODE_TYPE("TIDPATH");
1398 _outPathInfo(str, (Path *) node);
1400 WRITE_NODE_FIELD(tidquals);
1404 _outAppendPath(StringInfo str, AppendPath *node)
1406 WRITE_NODE_TYPE("APPENDPATH");
1408 _outPathInfo(str, (Path *) node);
1410 WRITE_NODE_FIELD(subpaths);
1414 _outResultPath(StringInfo str, ResultPath *node)
1416 WRITE_NODE_TYPE("RESULTPATH");
1418 _outPathInfo(str, (Path *) node);
1420 WRITE_NODE_FIELD(quals);
1424 _outMaterialPath(StringInfo str, MaterialPath *node)
1426 WRITE_NODE_TYPE("MATERIALPATH");
1428 _outPathInfo(str, (Path *) node);
1430 WRITE_NODE_FIELD(subpath);
1434 _outUniquePath(StringInfo str, UniquePath *node)
1436 WRITE_NODE_TYPE("UNIQUEPATH");
1438 _outPathInfo(str, (Path *) node);
1440 WRITE_NODE_FIELD(subpath);
1441 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1442 WRITE_NODE_FIELD(in_operators);
1443 WRITE_NODE_FIELD(uniq_exprs);
1444 WRITE_FLOAT_FIELD(rows, "%.0f");
1448 _outNoOpPath(StringInfo str, NoOpPath *node)
1450 WRITE_NODE_TYPE("NOOPPATH");
1452 _outPathInfo(str, (Path *) node);
1454 WRITE_NODE_FIELD(subpath);
1458 _outNestPath(StringInfo str, NestPath *node)
1460 WRITE_NODE_TYPE("NESTPATH");
1462 _outJoinPathInfo(str, (JoinPath *) node);
1466 _outMergePath(StringInfo str, MergePath *node)
1468 WRITE_NODE_TYPE("MERGEPATH");
1470 _outJoinPathInfo(str, (JoinPath *) node);
1472 WRITE_NODE_FIELD(path_mergeclauses);
1473 WRITE_NODE_FIELD(outersortkeys);
1474 WRITE_NODE_FIELD(innersortkeys);
1478 _outHashPath(StringInfo str, HashPath *node)
1480 WRITE_NODE_TYPE("HASHPATH");
1482 _outJoinPathInfo(str, (JoinPath *) node);
1484 WRITE_NODE_FIELD(path_hashclauses);
1485 WRITE_INT_FIELD(num_batches);
1489 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1491 WRITE_NODE_TYPE("PLANNERGLOBAL");
1493 /* NB: this isn't a complete set of fields */
1494 WRITE_NODE_FIELD(paramlist);
1495 WRITE_NODE_FIELD(subplans);
1496 WRITE_NODE_FIELD(subrtables);
1497 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1498 WRITE_NODE_FIELD(finalrtable);
1499 WRITE_NODE_FIELD(relationOids);
1500 WRITE_NODE_FIELD(invalItems);
1501 WRITE_UINT_FIELD(lastPHId);
1502 WRITE_BOOL_FIELD(transientPlan);
1506 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1508 WRITE_NODE_TYPE("PLANNERINFO");
1510 /* NB: this isn't a complete set of fields */
1511 WRITE_NODE_FIELD(parse);
1512 WRITE_NODE_FIELD(glob);
1513 WRITE_UINT_FIELD(query_level);
1514 WRITE_NODE_FIELD(join_rel_list);
1515 WRITE_NODE_FIELD(resultRelations);
1516 WRITE_NODE_FIELD(init_plans);
1517 WRITE_NODE_FIELD(cte_plan_ids);
1518 WRITE_NODE_FIELD(eq_classes);
1519 WRITE_NODE_FIELD(canon_pathkeys);
1520 WRITE_NODE_FIELD(left_join_clauses);
1521 WRITE_NODE_FIELD(right_join_clauses);
1522 WRITE_NODE_FIELD(full_join_clauses);
1523 WRITE_NODE_FIELD(join_info_list);
1524 WRITE_NODE_FIELD(append_rel_list);
1525 WRITE_NODE_FIELD(placeholder_list);
1526 WRITE_NODE_FIELD(query_pathkeys);
1527 WRITE_NODE_FIELD(group_pathkeys);
1528 WRITE_NODE_FIELD(window_pathkeys);
1529 WRITE_NODE_FIELD(distinct_pathkeys);
1530 WRITE_NODE_FIELD(sort_pathkeys);
1531 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1532 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1533 WRITE_BOOL_FIELD(hasJoinRTEs);
1534 WRITE_BOOL_FIELD(hasHavingQual);
1535 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1536 WRITE_BOOL_FIELD(hasRecursion);
1537 WRITE_INT_FIELD(wt_param_id);
1541 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1543 WRITE_NODE_TYPE("RELOPTINFO");
1545 /* NB: this isn't a complete set of fields */
1546 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1547 WRITE_BITMAPSET_FIELD(relids);
1548 WRITE_FLOAT_FIELD(rows, "%.0f");
1549 WRITE_INT_FIELD(width);
1550 WRITE_NODE_FIELD(reltargetlist);
1551 WRITE_NODE_FIELD(pathlist);
1552 WRITE_NODE_FIELD(cheapest_startup_path);
1553 WRITE_NODE_FIELD(cheapest_total_path);
1554 WRITE_NODE_FIELD(cheapest_unique_path);
1555 WRITE_UINT_FIELD(relid);
1556 WRITE_ENUM_FIELD(rtekind, RTEKind);
1557 WRITE_INT_FIELD(min_attr);
1558 WRITE_INT_FIELD(max_attr);
1559 WRITE_NODE_FIELD(indexlist);
1560 WRITE_UINT_FIELD(pages);
1561 WRITE_FLOAT_FIELD(tuples, "%.0f");
1562 WRITE_NODE_FIELD(subplan);
1563 WRITE_NODE_FIELD(subrtable);
1564 WRITE_NODE_FIELD(baserestrictinfo);
1565 WRITE_NODE_FIELD(joininfo);
1566 WRITE_BOOL_FIELD(has_eclass_joins);
1567 WRITE_BITMAPSET_FIELD(index_outer_relids);
1568 WRITE_NODE_FIELD(index_inner_paths);
1572 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1574 WRITE_NODE_TYPE("INDEXOPTINFO");
1576 /* NB: this isn't a complete set of fields */
1577 WRITE_OID_FIELD(indexoid);
1578 /* Do NOT print rel field, else infinite recursion */
1579 WRITE_UINT_FIELD(pages);
1580 WRITE_FLOAT_FIELD(tuples, "%.0f");
1581 WRITE_INT_FIELD(ncolumns);
1582 WRITE_NODE_FIELD(indexprs);
1583 WRITE_NODE_FIELD(indpred);
1584 WRITE_BOOL_FIELD(predOK);
1585 WRITE_BOOL_FIELD(unique);
1589 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1592 * To simplify reading, we just chase up to the topmost merged EC and
1593 * print that, without bothering to show the merge-ees separately.
1595 while (node->ec_merged)
1596 node = node->ec_merged;
1598 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1600 WRITE_NODE_FIELD(ec_opfamilies);
1601 WRITE_NODE_FIELD(ec_members);
1602 WRITE_NODE_FIELD(ec_sources);
1603 WRITE_NODE_FIELD(ec_derives);
1604 WRITE_BITMAPSET_FIELD(ec_relids);
1605 WRITE_BOOL_FIELD(ec_has_const);
1606 WRITE_BOOL_FIELD(ec_has_volatile);
1607 WRITE_BOOL_FIELD(ec_below_outer_join);
1608 WRITE_BOOL_FIELD(ec_broken);
1609 WRITE_UINT_FIELD(ec_sortref);
1613 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1615 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1617 WRITE_NODE_FIELD(em_expr);
1618 WRITE_BITMAPSET_FIELD(em_relids);
1619 WRITE_BOOL_FIELD(em_is_const);
1620 WRITE_BOOL_FIELD(em_is_child);
1621 WRITE_OID_FIELD(em_datatype);
1625 _outPathKey(StringInfo str, PathKey *node)
1627 WRITE_NODE_TYPE("PATHKEY");
1629 WRITE_NODE_FIELD(pk_eclass);
1630 WRITE_OID_FIELD(pk_opfamily);
1631 WRITE_INT_FIELD(pk_strategy);
1632 WRITE_BOOL_FIELD(pk_nulls_first);
1636 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1638 WRITE_NODE_TYPE("RESTRICTINFO");
1640 /* NB: this isn't a complete set of fields */
1641 WRITE_NODE_FIELD(clause);
1642 WRITE_BOOL_FIELD(is_pushed_down);
1643 WRITE_BOOL_FIELD(outerjoin_delayed);
1644 WRITE_BOOL_FIELD(can_join);
1645 WRITE_BOOL_FIELD(pseudoconstant);
1646 WRITE_BITMAPSET_FIELD(clause_relids);
1647 WRITE_BITMAPSET_FIELD(required_relids);
1648 WRITE_BITMAPSET_FIELD(nullable_relids);
1649 WRITE_BITMAPSET_FIELD(left_relids);
1650 WRITE_BITMAPSET_FIELD(right_relids);
1651 WRITE_NODE_FIELD(orclause);
1652 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1653 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1654 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1655 WRITE_NODE_FIELD(mergeopfamilies);
1656 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1657 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1658 WRITE_NODE_FIELD(left_em);
1659 WRITE_NODE_FIELD(right_em);
1660 WRITE_BOOL_FIELD(outer_is_left);
1661 WRITE_OID_FIELD(hashjoinoperator);
1665 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1667 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1668 WRITE_BITMAPSET_FIELD(other_relids);
1669 WRITE_BOOL_FIELD(isouterjoin);
1670 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1671 WRITE_NODE_FIELD(cheapest_total_innerpath);
1675 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1677 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1679 WRITE_NODE_FIELD(phexpr);
1680 WRITE_BITMAPSET_FIELD(phrels);
1681 WRITE_UINT_FIELD(phid);
1682 WRITE_UINT_FIELD(phlevelsup);
1686 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1688 WRITE_NODE_TYPE("SPECIALJOININFO");
1690 WRITE_BITMAPSET_FIELD(min_lefthand);
1691 WRITE_BITMAPSET_FIELD(min_righthand);
1692 WRITE_BITMAPSET_FIELD(syn_lefthand);
1693 WRITE_BITMAPSET_FIELD(syn_righthand);
1694 WRITE_ENUM_FIELD(jointype, JoinType);
1695 WRITE_BOOL_FIELD(lhs_strict);
1696 WRITE_BOOL_FIELD(delay_upper_joins);
1697 WRITE_NODE_FIELD(join_quals);
1701 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1703 WRITE_NODE_TYPE("APPENDRELINFO");
1705 WRITE_UINT_FIELD(parent_relid);
1706 WRITE_UINT_FIELD(child_relid);
1707 WRITE_OID_FIELD(parent_reltype);
1708 WRITE_OID_FIELD(child_reltype);
1709 WRITE_NODE_FIELD(translated_vars);
1710 WRITE_OID_FIELD(parent_reloid);
1714 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1716 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1718 WRITE_UINT_FIELD(phid);
1719 WRITE_NODE_FIELD(ph_var);
1720 WRITE_BITMAPSET_FIELD(ph_eval_at);
1721 WRITE_BITMAPSET_FIELD(ph_needed);
1722 WRITE_INT_FIELD(ph_width);
1726 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1728 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1730 WRITE_NODE_FIELD(item);
1731 WRITE_UINT_FIELD(abslevel);
1734 /*****************************************************************************
1736 * Stuff from parsenodes.h.
1738 *****************************************************************************/
1741 _outCreateStmt(StringInfo str, CreateStmt *node)
1743 WRITE_NODE_TYPE("CREATESTMT");
1745 WRITE_NODE_FIELD(relation);
1746 WRITE_NODE_FIELD(tableElts);
1747 WRITE_NODE_FIELD(inhRelations);
1748 WRITE_NODE_FIELD(constraints);
1749 WRITE_NODE_FIELD(options);
1750 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1751 WRITE_STRING_FIELD(tablespacename);
1755 _outIndexStmt(StringInfo str, IndexStmt *node)
1757 WRITE_NODE_TYPE("INDEXSTMT");
1759 WRITE_STRING_FIELD(idxname);
1760 WRITE_NODE_FIELD(relation);
1761 WRITE_STRING_FIELD(accessMethod);
1762 WRITE_STRING_FIELD(tableSpace);
1763 WRITE_NODE_FIELD(indexParams);
1764 WRITE_NODE_FIELD(options);
1765 WRITE_NODE_FIELD(whereClause);
1766 WRITE_BOOL_FIELD(unique);
1767 WRITE_BOOL_FIELD(primary);
1768 WRITE_BOOL_FIELD(isconstraint);
1769 WRITE_BOOL_FIELD(deferrable);
1770 WRITE_BOOL_FIELD(initdeferred);
1771 WRITE_BOOL_FIELD(concurrent);
1775 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1777 WRITE_NODE_TYPE("NOTIFY");
1779 WRITE_STRING_FIELD(conditionname);
1783 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1785 WRITE_NODE_TYPE("DECLARECURSOR");
1787 WRITE_STRING_FIELD(portalname);
1788 WRITE_INT_FIELD(options);
1789 WRITE_NODE_FIELD(query);
1793 _outSelectStmt(StringInfo str, SelectStmt *node)
1795 WRITE_NODE_TYPE("SELECT");
1797 WRITE_NODE_FIELD(distinctClause);
1798 WRITE_NODE_FIELD(intoClause);
1799 WRITE_NODE_FIELD(targetList);
1800 WRITE_NODE_FIELD(fromClause);
1801 WRITE_NODE_FIELD(whereClause);
1802 WRITE_NODE_FIELD(groupClause);
1803 WRITE_NODE_FIELD(havingClause);
1804 WRITE_NODE_FIELD(windowClause);
1805 WRITE_NODE_FIELD(withClause);
1806 WRITE_NODE_FIELD(valuesLists);
1807 WRITE_NODE_FIELD(sortClause);
1808 WRITE_NODE_FIELD(limitOffset);
1809 WRITE_NODE_FIELD(limitCount);
1810 WRITE_NODE_FIELD(lockingClause);
1811 WRITE_ENUM_FIELD(op, SetOperation);
1812 WRITE_BOOL_FIELD(all);
1813 WRITE_NODE_FIELD(larg);
1814 WRITE_NODE_FIELD(rarg);
1818 _outFuncCall(StringInfo str, FuncCall *node)
1820 WRITE_NODE_TYPE("FUNCCALL");
1822 WRITE_NODE_FIELD(funcname);
1823 WRITE_NODE_FIELD(args);
1824 WRITE_BOOL_FIELD(agg_star);
1825 WRITE_BOOL_FIELD(agg_distinct);
1826 WRITE_BOOL_FIELD(func_variadic);
1827 WRITE_NODE_FIELD(over);
1828 WRITE_LOCATION_FIELD(location);
1832 _outDefElem(StringInfo str, DefElem *node)
1834 WRITE_NODE_TYPE("DEFELEM");
1836 WRITE_STRING_FIELD(defnamespace);
1837 WRITE_STRING_FIELD(defname);
1838 WRITE_NODE_FIELD(arg);
1839 WRITE_ENUM_FIELD(defaction, DefElemAction);
1843 _outLockingClause(StringInfo str, LockingClause *node)
1845 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1847 WRITE_NODE_FIELD(lockedRels);
1848 WRITE_BOOL_FIELD(forUpdate);
1849 WRITE_BOOL_FIELD(noWait);
1853 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1855 WRITE_NODE_TYPE("XMLSERIALIZE");
1857 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1858 WRITE_NODE_FIELD(expr);
1859 WRITE_NODE_FIELD(typeName);
1860 WRITE_LOCATION_FIELD(location);
1864 _outColumnDef(StringInfo str, ColumnDef *node)
1866 WRITE_NODE_TYPE("COLUMNDEF");
1868 WRITE_STRING_FIELD(colname);
1869 WRITE_NODE_FIELD(typeName);
1870 WRITE_INT_FIELD(inhcount);
1871 WRITE_BOOL_FIELD(is_local);
1872 WRITE_BOOL_FIELD(is_not_null);
1873 WRITE_NODE_FIELD(raw_default);
1874 WRITE_NODE_FIELD(cooked_default);
1875 WRITE_NODE_FIELD(constraints);
1879 _outTypeName(StringInfo str, TypeName *node)
1881 WRITE_NODE_TYPE("TYPENAME");
1883 WRITE_NODE_FIELD(names);
1884 WRITE_OID_FIELD(typeOid);
1885 WRITE_BOOL_FIELD(setof);
1886 WRITE_BOOL_FIELD(pct_type);
1887 WRITE_NODE_FIELD(typmods);
1888 WRITE_INT_FIELD(typemod);
1889 WRITE_NODE_FIELD(arrayBounds);
1890 WRITE_LOCATION_FIELD(location);
1894 _outTypeCast(StringInfo str, TypeCast *node)
1896 WRITE_NODE_TYPE("TYPECAST");
1898 WRITE_NODE_FIELD(arg);
1899 WRITE_NODE_FIELD(typeName);
1900 WRITE_LOCATION_FIELD(location);
1904 _outIndexElem(StringInfo str, IndexElem *node)
1906 WRITE_NODE_TYPE("INDEXELEM");
1908 WRITE_STRING_FIELD(name);
1909 WRITE_NODE_FIELD(expr);
1910 WRITE_NODE_FIELD(opclass);
1911 WRITE_ENUM_FIELD(ordering, SortByDir);
1912 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1916 _outQuery(StringInfo str, Query *node)
1918 WRITE_NODE_TYPE("QUERY");
1920 WRITE_ENUM_FIELD(commandType, CmdType);
1921 WRITE_ENUM_FIELD(querySource, QuerySource);
1922 WRITE_BOOL_FIELD(canSetTag);
1925 * Hack to work around missing outfuncs routines for a lot of the
1926 * utility-statement node types. (The only one we actually *need* for
1927 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1928 * for the meantime do this to avoid getting lots of warnings when running
1929 * with debug_print_parse on.
1931 if (node->utilityStmt)
1933 switch (nodeTag(node->utilityStmt))
1938 case T_DeclareCursorStmt:
1939 WRITE_NODE_FIELD(utilityStmt);
1942 appendStringInfo(str, " :utilityStmt ?");
1947 appendStringInfo(str, " :utilityStmt <>");
1949 WRITE_INT_FIELD(resultRelation);
1950 WRITE_NODE_FIELD(intoClause);
1951 WRITE_BOOL_FIELD(hasAggs);
1952 WRITE_BOOL_FIELD(hasWindowFuncs);
1953 WRITE_BOOL_FIELD(hasSubLinks);
1954 WRITE_BOOL_FIELD(hasDistinctOn);
1955 WRITE_BOOL_FIELD(hasRecursive);
1956 WRITE_NODE_FIELD(cteList);
1957 WRITE_NODE_FIELD(rtable);
1958 WRITE_NODE_FIELD(jointree);
1959 WRITE_NODE_FIELD(targetList);
1960 WRITE_NODE_FIELD(returningList);
1961 WRITE_NODE_FIELD(groupClause);
1962 WRITE_NODE_FIELD(havingQual);
1963 WRITE_NODE_FIELD(windowClause);
1964 WRITE_NODE_FIELD(distinctClause);
1965 WRITE_NODE_FIELD(sortClause);
1966 WRITE_NODE_FIELD(limitOffset);
1967 WRITE_NODE_FIELD(limitCount);
1968 WRITE_NODE_FIELD(rowMarks);
1969 WRITE_NODE_FIELD(setOperations);
1973 _outSortGroupClause(StringInfo str, SortGroupClause *node)
1975 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
1977 WRITE_UINT_FIELD(tleSortGroupRef);
1978 WRITE_OID_FIELD(eqop);
1979 WRITE_OID_FIELD(sortop);
1980 WRITE_BOOL_FIELD(nulls_first);
1984 _outWindowClause(StringInfo str, WindowClause *node)
1986 WRITE_NODE_TYPE("WINDOWCLAUSE");
1988 WRITE_STRING_FIELD(name);
1989 WRITE_STRING_FIELD(refname);
1990 WRITE_NODE_FIELD(partitionClause);
1991 WRITE_NODE_FIELD(orderClause);
1992 WRITE_INT_FIELD(frameOptions);
1993 WRITE_UINT_FIELD(winref);
1994 WRITE_BOOL_FIELD(copiedOrder);
1998 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2000 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2002 WRITE_UINT_FIELD(rti);
2003 WRITE_UINT_FIELD(prti);
2004 WRITE_BOOL_FIELD(forUpdate);
2005 WRITE_BOOL_FIELD(noWait);
2006 WRITE_BOOL_FIELD(isParent);
2010 _outWithClause(StringInfo str, WithClause *node)
2012 WRITE_NODE_TYPE("WITHCLAUSE");
2014 WRITE_NODE_FIELD(ctes);
2015 WRITE_BOOL_FIELD(recursive);
2016 WRITE_LOCATION_FIELD(location);
2020 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2022 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2024 WRITE_STRING_FIELD(ctename);
2025 WRITE_NODE_FIELD(aliascolnames);
2026 WRITE_NODE_FIELD(ctequery);
2027 WRITE_LOCATION_FIELD(location);
2028 WRITE_BOOL_FIELD(cterecursive);
2029 WRITE_INT_FIELD(cterefcount);
2030 WRITE_NODE_FIELD(ctecolnames);
2031 WRITE_NODE_FIELD(ctecoltypes);
2032 WRITE_NODE_FIELD(ctecoltypmods);
2036 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2038 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2040 WRITE_ENUM_FIELD(op, SetOperation);
2041 WRITE_BOOL_FIELD(all);
2042 WRITE_NODE_FIELD(larg);
2043 WRITE_NODE_FIELD(rarg);
2044 WRITE_NODE_FIELD(colTypes);
2045 WRITE_NODE_FIELD(colTypmods);
2046 WRITE_NODE_FIELD(groupClauses);
2050 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2052 WRITE_NODE_TYPE("RTE");
2054 /* put alias + eref first to make dump more legible */
2055 WRITE_NODE_FIELD(alias);
2056 WRITE_NODE_FIELD(eref);
2057 WRITE_ENUM_FIELD(rtekind, RTEKind);
2059 switch (node->rtekind)
2063 WRITE_OID_FIELD(relid);
2066 WRITE_NODE_FIELD(subquery);
2069 WRITE_ENUM_FIELD(jointype, JoinType);
2070 WRITE_NODE_FIELD(joinaliasvars);
2073 WRITE_NODE_FIELD(funcexpr);
2074 WRITE_NODE_FIELD(funccoltypes);
2075 WRITE_NODE_FIELD(funccoltypmods);
2078 WRITE_NODE_FIELD(values_lists);
2081 WRITE_STRING_FIELD(ctename);
2082 WRITE_UINT_FIELD(ctelevelsup);
2083 WRITE_BOOL_FIELD(self_reference);
2084 WRITE_NODE_FIELD(ctecoltypes);
2085 WRITE_NODE_FIELD(ctecoltypmods);
2088 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2092 WRITE_BOOL_FIELD(inh);
2093 WRITE_BOOL_FIELD(inFromCl);
2094 WRITE_UINT_FIELD(requiredPerms);
2095 WRITE_OID_FIELD(checkAsUser);
2096 WRITE_BITMAPSET_FIELD(selectedCols);
2097 WRITE_BITMAPSET_FIELD(modifiedCols);
2101 _outAExpr(StringInfo str, A_Expr *node)
2103 WRITE_NODE_TYPE("AEXPR");
2108 appendStringInfo(str, " ");
2109 WRITE_NODE_FIELD(name);
2112 appendStringInfo(str, " AND");
2115 appendStringInfo(str, " OR");
2118 appendStringInfo(str, " NOT");
2121 appendStringInfo(str, " ");
2122 WRITE_NODE_FIELD(name);
2123 appendStringInfo(str, " ANY ");
2126 appendStringInfo(str, " ");
2127 WRITE_NODE_FIELD(name);
2128 appendStringInfo(str, " ALL ");
2130 case AEXPR_DISTINCT:
2131 appendStringInfo(str, " DISTINCT ");
2132 WRITE_NODE_FIELD(name);
2135 appendStringInfo(str, " NULLIF ");
2136 WRITE_NODE_FIELD(name);
2139 appendStringInfo(str, " OF ");
2140 WRITE_NODE_FIELD(name);
2143 appendStringInfo(str, " IN ");
2144 WRITE_NODE_FIELD(name);
2147 appendStringInfo(str, " ??");
2151 WRITE_NODE_FIELD(lexpr);
2152 WRITE_NODE_FIELD(rexpr);
2153 WRITE_LOCATION_FIELD(location);
2157 _outValue(StringInfo str, Value *value)
2159 switch (value->type)
2162 appendStringInfo(str, "%ld", value->val.ival);
2167 * We assume the value is a valid numeric literal and so does not
2170 appendStringInfoString(str, value->val.str);
2173 appendStringInfoChar(str, '"');
2174 _outToken(str, value->val.str);
2175 appendStringInfoChar(str, '"');
2178 /* internal representation already has leading 'b' */
2179 appendStringInfoString(str, value->val.str);
2182 /* this is seen only within A_Const, not in transformed trees */
2183 appendStringInfoString(str, "NULL");
2186 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2192 _outColumnRef(StringInfo str, ColumnRef *node)
2194 WRITE_NODE_TYPE("COLUMNREF");
2196 WRITE_NODE_FIELD(fields);
2197 WRITE_LOCATION_FIELD(location);
2201 _outParamRef(StringInfo str, ParamRef *node)
2203 WRITE_NODE_TYPE("PARAMREF");
2205 WRITE_INT_FIELD(number);
2206 WRITE_LOCATION_FIELD(location);
2210 _outAConst(StringInfo str, A_Const *node)
2212 WRITE_NODE_TYPE("A_CONST");
2214 appendStringInfo(str, " :val ");
2215 _outValue(str, &(node->val));
2216 WRITE_LOCATION_FIELD(location);
2220 _outA_Star(StringInfo str, A_Star *node)
2222 WRITE_NODE_TYPE("A_STAR");
2226 _outA_Indices(StringInfo str, A_Indices *node)
2228 WRITE_NODE_TYPE("A_INDICES");
2230 WRITE_NODE_FIELD(lidx);
2231 WRITE_NODE_FIELD(uidx);
2235 _outA_Indirection(StringInfo str, A_Indirection *node)
2237 WRITE_NODE_TYPE("A_INDIRECTION");
2239 WRITE_NODE_FIELD(arg);
2240 WRITE_NODE_FIELD(indirection);
2244 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2246 WRITE_NODE_TYPE("A_ARRAYEXPR");
2248 WRITE_NODE_FIELD(elements);
2249 WRITE_LOCATION_FIELD(location);
2253 _outResTarget(StringInfo str, ResTarget *node)
2255 WRITE_NODE_TYPE("RESTARGET");
2257 WRITE_STRING_FIELD(name);
2258 WRITE_NODE_FIELD(indirection);
2259 WRITE_NODE_FIELD(val);
2260 WRITE_LOCATION_FIELD(location);
2264 _outSortBy(StringInfo str, SortBy *node)
2266 WRITE_NODE_TYPE("SORTBY");
2268 WRITE_NODE_FIELD(node);
2269 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2270 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2271 WRITE_NODE_FIELD(useOp);
2272 WRITE_LOCATION_FIELD(location);
2276 _outWindowDef(StringInfo str, WindowDef *node)
2278 WRITE_NODE_TYPE("WINDOWDEF");
2280 WRITE_STRING_FIELD(name);
2281 WRITE_STRING_FIELD(refname);
2282 WRITE_NODE_FIELD(partitionClause);
2283 WRITE_NODE_FIELD(orderClause);
2284 WRITE_INT_FIELD(frameOptions);
2285 WRITE_LOCATION_FIELD(location);
2289 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2291 WRITE_NODE_TYPE("RANGESUBSELECT");
2293 WRITE_NODE_FIELD(subquery);
2294 WRITE_NODE_FIELD(alias);
2298 _outRangeFunction(StringInfo str, RangeFunction *node)
2300 WRITE_NODE_TYPE("RANGEFUNCTION");
2302 WRITE_NODE_FIELD(funccallnode);
2303 WRITE_NODE_FIELD(alias);
2304 WRITE_NODE_FIELD(coldeflist);
2308 _outConstraint(StringInfo str, Constraint *node)
2310 WRITE_NODE_TYPE("CONSTRAINT");
2312 WRITE_STRING_FIELD(conname);
2313 WRITE_BOOL_FIELD(deferrable);
2314 WRITE_BOOL_FIELD(initdeferred);
2315 WRITE_LOCATION_FIELD(location);
2317 appendStringInfo(str, " :contype ");
2318 switch (node->contype)
2321 appendStringInfo(str, "NULL");
2324 case CONSTR_NOTNULL:
2325 appendStringInfo(str, "NOT_NULL");
2328 case CONSTR_DEFAULT:
2329 appendStringInfo(str, "DEFAULT");
2330 WRITE_NODE_FIELD(raw_expr);
2331 WRITE_STRING_FIELD(cooked_expr);
2335 appendStringInfo(str, "CHECK");
2336 WRITE_NODE_FIELD(raw_expr);
2337 WRITE_STRING_FIELD(cooked_expr);
2340 case CONSTR_PRIMARY:
2341 appendStringInfo(str, "PRIMARY_KEY");
2342 WRITE_NODE_FIELD(keys);
2343 WRITE_NODE_FIELD(options);
2344 WRITE_STRING_FIELD(indexspace);
2348 appendStringInfo(str, "UNIQUE");
2349 WRITE_NODE_FIELD(keys);
2350 WRITE_NODE_FIELD(options);
2351 WRITE_STRING_FIELD(indexspace);
2354 case CONSTR_FOREIGN:
2355 appendStringInfo(str, "FOREIGN_KEY");
2356 WRITE_NODE_FIELD(pktable);
2357 WRITE_NODE_FIELD(fk_attrs);
2358 WRITE_NODE_FIELD(pk_attrs);
2359 WRITE_CHAR_FIELD(fk_matchtype);
2360 WRITE_CHAR_FIELD(fk_upd_action);
2361 WRITE_CHAR_FIELD(fk_del_action);
2362 WRITE_BOOL_FIELD(skip_validation);
2365 case CONSTR_ATTR_DEFERRABLE:
2366 appendStringInfo(str, "ATTR_DEFERRABLE");
2369 case CONSTR_ATTR_NOT_DEFERRABLE:
2370 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2373 case CONSTR_ATTR_DEFERRED:
2374 appendStringInfo(str, "ATTR_DEFERRED");
2377 case CONSTR_ATTR_IMMEDIATE:
2378 appendStringInfo(str, "ATTR_IMMEDIATE");
2382 appendStringInfo(str, "<unrecognized_constraint %d>",
2383 (int) node->contype);
2391 * converts a Node into ascii string and append it to 'str'
2394 _outNode(StringInfo str, void *obj)
2397 appendStringInfo(str, "<>");
2398 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2400 else if (IsA(obj, Integer) ||
2403 IsA(obj, BitString))
2405 /* nodeRead does not want to see { } around these! */
2406 _outValue(str, obj);
2410 appendStringInfoChar(str, '{');
2411 switch (nodeTag(obj))
2414 _outPlannedStmt(str, obj);
2420 _outResult(str, obj);
2423 _outModifyTable(str, obj);
2426 _outAppend(str, obj);
2428 case T_RecursiveUnion:
2429 _outRecursiveUnion(str, obj);
2432 _outBitmapAnd(str, obj);
2435 _outBitmapOr(str, obj);
2441 _outSeqScan(str, obj);
2444 _outIndexScan(str, obj);
2446 case T_BitmapIndexScan:
2447 _outBitmapIndexScan(str, obj);
2449 case T_BitmapHeapScan:
2450 _outBitmapHeapScan(str, obj);
2453 _outTidScan(str, obj);
2455 case T_SubqueryScan:
2456 _outSubqueryScan(str, obj);
2458 case T_FunctionScan:
2459 _outFunctionScan(str, obj);
2462 _outValuesScan(str, obj);
2465 _outCteScan(str, obj);
2467 case T_WorkTableScan:
2468 _outWorkTableScan(str, obj);
2474 _outNestLoop(str, obj);
2477 _outMergeJoin(str, obj);
2480 _outHashJoin(str, obj);
2486 _outWindowAgg(str, obj);
2489 _outGroup(str, obj);
2492 _outMaterial(str, obj);
2498 _outUnique(str, obj);
2504 _outSetOp(str, obj);
2507 _outLimit(str, obj);
2509 case T_PlanInvalItem:
2510 _outPlanInvalItem(str, obj);
2513 _outAlias(str, obj);
2516 _outRangeVar(str, obj);
2519 _outIntoClause(str, obj);
2525 _outConst(str, obj);
2528 _outParam(str, obj);
2531 _outAggref(str, obj);
2534 _outWindowFunc(str, obj);
2537 _outArrayRef(str, obj);
2540 _outFuncExpr(str, obj);
2542 case T_NamedArgExpr:
2543 _outNamedArgExpr(str, obj);
2546 _outOpExpr(str, obj);
2548 case T_DistinctExpr:
2549 _outDistinctExpr(str, obj);
2551 case T_ScalarArrayOpExpr:
2552 _outScalarArrayOpExpr(str, obj);
2555 _outBoolExpr(str, obj);
2558 _outSubLink(str, obj);
2561 _outSubPlan(str, obj);
2563 case T_AlternativeSubPlan:
2564 _outAlternativeSubPlan(str, obj);
2567 _outFieldSelect(str, obj);
2570 _outFieldStore(str, obj);
2573 _outRelabelType(str, obj);
2576 _outCoerceViaIO(str, obj);
2578 case T_ArrayCoerceExpr:
2579 _outArrayCoerceExpr(str, obj);
2581 case T_ConvertRowtypeExpr:
2582 _outConvertRowtypeExpr(str, obj);
2585 _outCaseExpr(str, obj);
2588 _outCaseWhen(str, obj);
2590 case T_CaseTestExpr:
2591 _outCaseTestExpr(str, obj);
2594 _outArrayExpr(str, obj);
2597 _outRowExpr(str, obj);
2599 case T_RowCompareExpr:
2600 _outRowCompareExpr(str, obj);
2602 case T_CoalesceExpr:
2603 _outCoalesceExpr(str, obj);
2606 _outMinMaxExpr(str, obj);
2609 _outXmlExpr(str, obj);
2612 _outNullIfExpr(str, obj);
2615 _outNullTest(str, obj);
2618 _outBooleanTest(str, obj);
2620 case T_CoerceToDomain:
2621 _outCoerceToDomain(str, obj);
2623 case T_CoerceToDomainValue:
2624 _outCoerceToDomainValue(str, obj);
2626 case T_SetToDefault:
2627 _outSetToDefault(str, obj);
2629 case T_CurrentOfExpr:
2630 _outCurrentOfExpr(str, obj);
2633 _outTargetEntry(str, obj);
2636 _outRangeTblRef(str, obj);
2639 _outJoinExpr(str, obj);
2642 _outFromExpr(str, obj);
2649 _outIndexPath(str, obj);
2651 case T_BitmapHeapPath:
2652 _outBitmapHeapPath(str, obj);
2654 case T_BitmapAndPath:
2655 _outBitmapAndPath(str, obj);
2657 case T_BitmapOrPath:
2658 _outBitmapOrPath(str, obj);
2661 _outTidPath(str, obj);
2664 _outAppendPath(str, obj);
2667 _outResultPath(str, obj);
2669 case T_MaterialPath:
2670 _outMaterialPath(str, obj);
2673 _outUniquePath(str, obj);
2676 _outNoOpPath(str, obj);
2679 _outNestPath(str, obj);
2682 _outMergePath(str, obj);
2685 _outHashPath(str, obj);
2687 case T_PlannerGlobal:
2688 _outPlannerGlobal(str, obj);
2691 _outPlannerInfo(str, obj);
2694 _outRelOptInfo(str, obj);
2696 case T_IndexOptInfo:
2697 _outIndexOptInfo(str, obj);
2699 case T_EquivalenceClass:
2700 _outEquivalenceClass(str, obj);
2702 case T_EquivalenceMember:
2703 _outEquivalenceMember(str, obj);
2706 _outPathKey(str, obj);
2708 case T_RestrictInfo:
2709 _outRestrictInfo(str, obj);
2711 case T_InnerIndexscanInfo:
2712 _outInnerIndexscanInfo(str, obj);
2714 case T_PlaceHolderVar:
2715 _outPlaceHolderVar(str, obj);
2717 case T_SpecialJoinInfo:
2718 _outSpecialJoinInfo(str, obj);
2720 case T_AppendRelInfo:
2721 _outAppendRelInfo(str, obj);
2723 case T_PlaceHolderInfo:
2724 _outPlaceHolderInfo(str, obj);
2726 case T_PlannerParamItem:
2727 _outPlannerParamItem(str, obj);
2731 _outCreateStmt(str, obj);
2734 _outIndexStmt(str, obj);
2737 _outNotifyStmt(str, obj);
2739 case T_DeclareCursorStmt:
2740 _outDeclareCursorStmt(str, obj);
2743 _outSelectStmt(str, obj);
2746 _outColumnDef(str, obj);
2749 _outTypeName(str, obj);
2752 _outTypeCast(str, obj);
2755 _outIndexElem(str, obj);
2758 _outQuery(str, obj);
2760 case T_SortGroupClause:
2761 _outSortGroupClause(str, obj);
2763 case T_WindowClause:
2764 _outWindowClause(str, obj);
2766 case T_RowMarkClause:
2767 _outRowMarkClause(str, obj);
2770 _outWithClause(str, obj);
2772 case T_CommonTableExpr:
2773 _outCommonTableExpr(str, obj);
2775 case T_SetOperationStmt:
2776 _outSetOperationStmt(str, obj);
2778 case T_RangeTblEntry:
2779 _outRangeTblEntry(str, obj);
2782 _outAExpr(str, obj);
2785 _outColumnRef(str, obj);
2788 _outParamRef(str, obj);
2791 _outAConst(str, obj);
2794 _outA_Star(str, obj);
2797 _outA_Indices(str, obj);
2799 case T_A_Indirection:
2800 _outA_Indirection(str, obj);
2803 _outA_ArrayExpr(str, obj);
2806 _outResTarget(str, obj);
2809 _outSortBy(str, obj);
2812 _outWindowDef(str, obj);
2814 case T_RangeSubselect:
2815 _outRangeSubselect(str, obj);
2817 case T_RangeFunction:
2818 _outRangeFunction(str, obj);
2821 _outConstraint(str, obj);
2824 _outFuncCall(str, obj);
2827 _outDefElem(str, obj);
2829 case T_LockingClause:
2830 _outLockingClause(str, obj);
2832 case T_XmlSerialize:
2833 _outXmlSerialize(str, obj);
2839 * This should be an ERROR, but it's too useful to be able to
2840 * dump structures that _outNode only understands part of.
2842 elog(WARNING, "could not dump unrecognized node type: %d",
2843 (int) nodeTag(obj));
2846 appendStringInfoChar(str, '}');
2852 * returns the ascii representation of the Node as a palloc'd string
2855 nodeToString(void *obj)
2859 /* see stringinfo.h for an explanation of this maneuver */
2860 initStringInfo(&str);
2861 _outNode(&str, obj);