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.358 2009/04/05 19:59:40 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(canSetTag);
246 WRITE_NODE_FIELD(planTree);
247 WRITE_NODE_FIELD(rtable);
248 WRITE_NODE_FIELD(resultRelations);
249 WRITE_NODE_FIELD(utilityStmt);
250 WRITE_NODE_FIELD(intoClause);
251 WRITE_NODE_FIELD(subplans);
252 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
253 WRITE_NODE_FIELD(returningLists);
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 _outAppend(StringInfo str, Append *node)
324 WRITE_NODE_TYPE("APPEND");
326 _outPlanInfo(str, (Plan *) node);
328 WRITE_NODE_FIELD(appendplans);
329 WRITE_BOOL_FIELD(isTarget);
333 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
337 WRITE_NODE_TYPE("RECURSIVEUNION");
339 _outPlanInfo(str, (Plan *) node);
341 WRITE_INT_FIELD(wtParam);
342 WRITE_INT_FIELD(numCols);
344 appendStringInfo(str, " :dupColIdx");
345 for (i = 0; i < node->numCols; i++)
346 appendStringInfo(str, " %d", node->dupColIdx[i]);
348 appendStringInfo(str, " :dupOperators");
349 for (i = 0; i < node->numCols; i++)
350 appendStringInfo(str, " %u", node->dupOperators[i]);
352 WRITE_LONG_FIELD(numGroups);
356 _outBitmapAnd(StringInfo str, BitmapAnd *node)
358 WRITE_NODE_TYPE("BITMAPAND");
360 _outPlanInfo(str, (Plan *) node);
362 WRITE_NODE_FIELD(bitmapplans);
366 _outBitmapOr(StringInfo str, BitmapOr *node)
368 WRITE_NODE_TYPE("BITMAPOR");
370 _outPlanInfo(str, (Plan *) node);
372 WRITE_NODE_FIELD(bitmapplans);
376 _outScan(StringInfo str, Scan *node)
378 WRITE_NODE_TYPE("SCAN");
380 _outScanInfo(str, (Scan *) node);
384 _outSeqScan(StringInfo str, SeqScan *node)
386 WRITE_NODE_TYPE("SEQSCAN");
388 _outScanInfo(str, (Scan *) node);
392 _outIndexScan(StringInfo str, IndexScan *node)
394 WRITE_NODE_TYPE("INDEXSCAN");
396 _outScanInfo(str, (Scan *) node);
398 WRITE_OID_FIELD(indexid);
399 WRITE_NODE_FIELD(indexqual);
400 WRITE_NODE_FIELD(indexqualorig);
401 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
405 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
407 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
409 _outScanInfo(str, (Scan *) node);
411 WRITE_OID_FIELD(indexid);
412 WRITE_NODE_FIELD(indexqual);
413 WRITE_NODE_FIELD(indexqualorig);
417 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
419 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
421 _outScanInfo(str, (Scan *) node);
423 WRITE_NODE_FIELD(bitmapqualorig);
427 _outTidScan(StringInfo str, TidScan *node)
429 WRITE_NODE_TYPE("TIDSCAN");
431 _outScanInfo(str, (Scan *) node);
433 WRITE_NODE_FIELD(tidquals);
437 _outSubqueryScan(StringInfo str, SubqueryScan *node)
439 WRITE_NODE_TYPE("SUBQUERYSCAN");
441 _outScanInfo(str, (Scan *) node);
443 WRITE_NODE_FIELD(subplan);
444 WRITE_NODE_FIELD(subrtable);
448 _outFunctionScan(StringInfo str, FunctionScan *node)
450 WRITE_NODE_TYPE("FUNCTIONSCAN");
452 _outScanInfo(str, (Scan *) node);
454 WRITE_NODE_FIELD(funcexpr);
455 WRITE_NODE_FIELD(funccolnames);
456 WRITE_NODE_FIELD(funccoltypes);
457 WRITE_NODE_FIELD(funccoltypmods);
461 _outValuesScan(StringInfo str, ValuesScan *node)
463 WRITE_NODE_TYPE("VALUESSCAN");
465 _outScanInfo(str, (Scan *) node);
467 WRITE_NODE_FIELD(values_lists);
471 _outCteScan(StringInfo str, CteScan *node)
473 WRITE_NODE_TYPE("CTESCAN");
475 _outScanInfo(str, (Scan *) node);
477 WRITE_INT_FIELD(ctePlanId);
478 WRITE_INT_FIELD(cteParam);
482 _outWorkTableScan(StringInfo str, WorkTableScan *node)
484 WRITE_NODE_TYPE("WORKTABLESCAN");
486 _outScanInfo(str, (Scan *) node);
488 WRITE_INT_FIELD(wtParam);
492 _outJoin(StringInfo str, Join *node)
494 WRITE_NODE_TYPE("JOIN");
496 _outJoinPlanInfo(str, (Join *) node);
500 _outNestLoop(StringInfo str, NestLoop *node)
502 WRITE_NODE_TYPE("NESTLOOP");
504 _outJoinPlanInfo(str, (Join *) node);
508 _outMergeJoin(StringInfo str, MergeJoin *node)
513 WRITE_NODE_TYPE("MERGEJOIN");
515 _outJoinPlanInfo(str, (Join *) node);
517 WRITE_NODE_FIELD(mergeclauses);
519 numCols = list_length(node->mergeclauses);
521 appendStringInfo(str, " :mergeFamilies");
522 for (i = 0; i < numCols; i++)
523 appendStringInfo(str, " %u", node->mergeFamilies[i]);
525 appendStringInfo(str, " :mergeStrategies");
526 for (i = 0; i < numCols; i++)
527 appendStringInfo(str, " %d", node->mergeStrategies[i]);
529 appendStringInfo(str, " :mergeNullsFirst");
530 for (i = 0; i < numCols; i++)
531 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
535 _outHashJoin(StringInfo str, HashJoin *node)
537 WRITE_NODE_TYPE("HASHJOIN");
539 _outJoinPlanInfo(str, (Join *) node);
541 WRITE_NODE_FIELD(hashclauses);
545 _outAgg(StringInfo str, Agg *node)
549 WRITE_NODE_TYPE("AGG");
551 _outPlanInfo(str, (Plan *) node);
553 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
554 WRITE_INT_FIELD(numCols);
556 appendStringInfo(str, " :grpColIdx");
557 for (i = 0; i < node->numCols; i++)
558 appendStringInfo(str, " %d", node->grpColIdx[i]);
560 appendStringInfo(str, " :grpOperators");
561 for (i = 0; i < node->numCols; i++)
562 appendStringInfo(str, " %u", node->grpOperators[i]);
564 WRITE_LONG_FIELD(numGroups);
568 _outWindowAgg(StringInfo str, WindowAgg *node)
572 WRITE_NODE_TYPE("WINDOWAGG");
574 _outPlanInfo(str, (Plan *) node);
576 WRITE_UINT_FIELD(winref);
577 WRITE_INT_FIELD(partNumCols);
579 appendStringInfo(str, " :partColIdx");
580 for (i = 0; i < node->partNumCols; i++)
581 appendStringInfo(str, " %d", node->partColIdx[i]);
583 appendStringInfo(str, " :partOperations");
584 for (i = 0; i < node->partNumCols; i++)
585 appendStringInfo(str, " %u", node->partOperators[i]);
587 WRITE_INT_FIELD(ordNumCols);
589 appendStringInfo(str, " :ordColIdx");
590 for (i = 0; i< node->ordNumCols; i++)
591 appendStringInfo(str, " %d", node->ordColIdx[i]);
593 appendStringInfo(str, " :ordOperations");
594 for (i = 0; i < node->ordNumCols; i++)
595 appendStringInfo(str, " %u", node->ordOperators[i]);
597 WRITE_INT_FIELD(frameOptions);
601 _outGroup(StringInfo str, Group *node)
605 WRITE_NODE_TYPE("GROUP");
607 _outPlanInfo(str, (Plan *) node);
609 WRITE_INT_FIELD(numCols);
611 appendStringInfo(str, " :grpColIdx");
612 for (i = 0; i < node->numCols; i++)
613 appendStringInfo(str, " %d", node->grpColIdx[i]);
615 appendStringInfo(str, " :grpOperators");
616 for (i = 0; i < node->numCols; i++)
617 appendStringInfo(str, " %u", node->grpOperators[i]);
621 _outMaterial(StringInfo str, Material *node)
623 WRITE_NODE_TYPE("MATERIAL");
625 _outPlanInfo(str, (Plan *) node);
629 _outSort(StringInfo str, Sort *node)
633 WRITE_NODE_TYPE("SORT");
635 _outPlanInfo(str, (Plan *) node);
637 WRITE_INT_FIELD(numCols);
639 appendStringInfo(str, " :sortColIdx");
640 for (i = 0; i < node->numCols; i++)
641 appendStringInfo(str, " %d", node->sortColIdx[i]);
643 appendStringInfo(str, " :sortOperators");
644 for (i = 0; i < node->numCols; i++)
645 appendStringInfo(str, " %u", node->sortOperators[i]);
647 appendStringInfo(str, " :nullsFirst");
648 for (i = 0; i < node->numCols; i++)
649 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
653 _outUnique(StringInfo str, Unique *node)
657 WRITE_NODE_TYPE("UNIQUE");
659 _outPlanInfo(str, (Plan *) node);
661 WRITE_INT_FIELD(numCols);
663 appendStringInfo(str, " :uniqColIdx");
664 for (i = 0; i < node->numCols; i++)
665 appendStringInfo(str, " %d", node->uniqColIdx[i]);
667 appendStringInfo(str, " :uniqOperators");
668 for (i = 0; i < node->numCols; i++)
669 appendStringInfo(str, " %u", node->uniqOperators[i]);
673 _outHash(StringInfo str, Hash *node)
675 WRITE_NODE_TYPE("HASH");
677 _outPlanInfo(str, (Plan *) node);
679 WRITE_OID_FIELD(skewTable);
680 WRITE_INT_FIELD(skewColumn);
681 WRITE_OID_FIELD(skewColType);
682 WRITE_INT_FIELD(skewColTypmod);
686 _outSetOp(StringInfo str, SetOp *node)
690 WRITE_NODE_TYPE("SETOP");
692 _outPlanInfo(str, (Plan *) node);
694 WRITE_ENUM_FIELD(cmd, SetOpCmd);
695 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
696 WRITE_INT_FIELD(numCols);
698 appendStringInfo(str, " :dupColIdx");
699 for (i = 0; i < node->numCols; i++)
700 appendStringInfo(str, " %d", node->dupColIdx[i]);
702 appendStringInfo(str, " :dupOperators");
703 for (i = 0; i < node->numCols; i++)
704 appendStringInfo(str, " %u", node->dupOperators[i]);
706 WRITE_INT_FIELD(flagColIdx);
707 WRITE_INT_FIELD(firstFlag);
708 WRITE_LONG_FIELD(numGroups);
712 _outLimit(StringInfo str, Limit *node)
714 WRITE_NODE_TYPE("LIMIT");
716 _outPlanInfo(str, (Plan *) node);
718 WRITE_NODE_FIELD(limitOffset);
719 WRITE_NODE_FIELD(limitCount);
723 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
725 WRITE_NODE_TYPE("PLANINVALITEM");
727 WRITE_INT_FIELD(cacheId);
728 appendStringInfo(str, " :tupleId (%u,%u)",
729 ItemPointerGetBlockNumber(&node->tupleId),
730 ItemPointerGetOffsetNumber(&node->tupleId));
733 /*****************************************************************************
735 * Stuff from primnodes.h.
737 *****************************************************************************/
740 _outAlias(StringInfo str, Alias *node)
742 WRITE_NODE_TYPE("ALIAS");
744 WRITE_STRING_FIELD(aliasname);
745 WRITE_NODE_FIELD(colnames);
749 _outRangeVar(StringInfo str, RangeVar *node)
751 WRITE_NODE_TYPE("RANGEVAR");
754 * we deliberately ignore catalogname here, since it is presently not
755 * semantically meaningful
757 WRITE_STRING_FIELD(schemaname);
758 WRITE_STRING_FIELD(relname);
759 WRITE_ENUM_FIELD(inhOpt, InhOption);
760 WRITE_BOOL_FIELD(istemp);
761 WRITE_NODE_FIELD(alias);
762 WRITE_LOCATION_FIELD(location);
766 _outIntoClause(StringInfo str, IntoClause *node)
768 WRITE_NODE_TYPE("INTOCLAUSE");
770 WRITE_NODE_FIELD(rel);
771 WRITE_NODE_FIELD(colNames);
772 WRITE_NODE_FIELD(options);
773 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
774 WRITE_STRING_FIELD(tableSpaceName);
778 _outVar(StringInfo str, Var *node)
780 WRITE_NODE_TYPE("VAR");
782 WRITE_UINT_FIELD(varno);
783 WRITE_INT_FIELD(varattno);
784 WRITE_OID_FIELD(vartype);
785 WRITE_INT_FIELD(vartypmod);
786 WRITE_UINT_FIELD(varlevelsup);
787 WRITE_UINT_FIELD(varnoold);
788 WRITE_INT_FIELD(varoattno);
789 WRITE_LOCATION_FIELD(location);
793 _outConst(StringInfo str, Const *node)
795 WRITE_NODE_TYPE("CONST");
797 WRITE_OID_FIELD(consttype);
798 WRITE_INT_FIELD(consttypmod);
799 WRITE_INT_FIELD(constlen);
800 WRITE_BOOL_FIELD(constbyval);
801 WRITE_BOOL_FIELD(constisnull);
802 WRITE_LOCATION_FIELD(location);
804 appendStringInfo(str, " :constvalue ");
805 if (node->constisnull)
806 appendStringInfo(str, "<>");
808 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
812 _outParam(StringInfo str, Param *node)
814 WRITE_NODE_TYPE("PARAM");
816 WRITE_ENUM_FIELD(paramkind, ParamKind);
817 WRITE_INT_FIELD(paramid);
818 WRITE_OID_FIELD(paramtype);
819 WRITE_INT_FIELD(paramtypmod);
820 WRITE_LOCATION_FIELD(location);
824 _outAggref(StringInfo str, Aggref *node)
826 WRITE_NODE_TYPE("AGGREF");
828 WRITE_OID_FIELD(aggfnoid);
829 WRITE_OID_FIELD(aggtype);
830 WRITE_NODE_FIELD(args);
831 WRITE_UINT_FIELD(agglevelsup);
832 WRITE_BOOL_FIELD(aggstar);
833 WRITE_BOOL_FIELD(aggdistinct);
834 WRITE_LOCATION_FIELD(location);
838 _outWindowFunc(StringInfo str, WindowFunc *node)
840 WRITE_NODE_TYPE("WINDOWFUNC");
842 WRITE_OID_FIELD(winfnoid);
843 WRITE_OID_FIELD(wintype);
844 WRITE_NODE_FIELD(args);
845 WRITE_UINT_FIELD(winref);
846 WRITE_BOOL_FIELD(winstar);
847 WRITE_BOOL_FIELD(winagg);
848 WRITE_LOCATION_FIELD(location);
852 _outArrayRef(StringInfo str, ArrayRef *node)
854 WRITE_NODE_TYPE("ARRAYREF");
856 WRITE_OID_FIELD(refarraytype);
857 WRITE_OID_FIELD(refelemtype);
858 WRITE_INT_FIELD(reftypmod);
859 WRITE_NODE_FIELD(refupperindexpr);
860 WRITE_NODE_FIELD(reflowerindexpr);
861 WRITE_NODE_FIELD(refexpr);
862 WRITE_NODE_FIELD(refassgnexpr);
866 _outFuncExpr(StringInfo str, FuncExpr *node)
868 WRITE_NODE_TYPE("FUNCEXPR");
870 WRITE_OID_FIELD(funcid);
871 WRITE_OID_FIELD(funcresulttype);
872 WRITE_BOOL_FIELD(funcretset);
873 WRITE_ENUM_FIELD(funcformat, CoercionForm);
874 WRITE_NODE_FIELD(args);
875 WRITE_LOCATION_FIELD(location);
879 _outOpExpr(StringInfo str, OpExpr *node)
881 WRITE_NODE_TYPE("OPEXPR");
883 WRITE_OID_FIELD(opno);
884 WRITE_OID_FIELD(opfuncid);
885 WRITE_OID_FIELD(opresulttype);
886 WRITE_BOOL_FIELD(opretset);
887 WRITE_NODE_FIELD(args);
888 WRITE_LOCATION_FIELD(location);
892 _outDistinctExpr(StringInfo str, DistinctExpr *node)
894 WRITE_NODE_TYPE("DISTINCTEXPR");
896 WRITE_OID_FIELD(opno);
897 WRITE_OID_FIELD(opfuncid);
898 WRITE_OID_FIELD(opresulttype);
899 WRITE_BOOL_FIELD(opretset);
900 WRITE_NODE_FIELD(args);
901 WRITE_LOCATION_FIELD(location);
905 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
907 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
909 WRITE_OID_FIELD(opno);
910 WRITE_OID_FIELD(opfuncid);
911 WRITE_BOOL_FIELD(useOr);
912 WRITE_NODE_FIELD(args);
913 WRITE_LOCATION_FIELD(location);
917 _outBoolExpr(StringInfo str, BoolExpr *node)
921 WRITE_NODE_TYPE("BOOLEXPR");
923 /* do-it-yourself enum representation */
924 switch (node->boolop)
936 appendStringInfo(str, " :boolop ");
937 _outToken(str, opstr);
939 WRITE_NODE_FIELD(args);
940 WRITE_LOCATION_FIELD(location);
944 _outSubLink(StringInfo str, SubLink *node)
946 WRITE_NODE_TYPE("SUBLINK");
948 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
949 WRITE_NODE_FIELD(testexpr);
950 WRITE_NODE_FIELD(operName);
951 WRITE_NODE_FIELD(subselect);
952 WRITE_LOCATION_FIELD(location);
956 _outSubPlan(StringInfo str, SubPlan *node)
958 WRITE_NODE_TYPE("SUBPLAN");
960 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
961 WRITE_NODE_FIELD(testexpr);
962 WRITE_NODE_FIELD(paramIds);
963 WRITE_INT_FIELD(plan_id);
964 WRITE_STRING_FIELD(plan_name);
965 WRITE_OID_FIELD(firstColType);
966 WRITE_INT_FIELD(firstColTypmod);
967 WRITE_BOOL_FIELD(useHashTable);
968 WRITE_BOOL_FIELD(unknownEqFalse);
969 WRITE_NODE_FIELD(setParam);
970 WRITE_NODE_FIELD(parParam);
971 WRITE_NODE_FIELD(args);
972 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
973 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
977 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
979 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
981 WRITE_NODE_FIELD(subplans);
985 _outFieldSelect(StringInfo str, FieldSelect *node)
987 WRITE_NODE_TYPE("FIELDSELECT");
989 WRITE_NODE_FIELD(arg);
990 WRITE_INT_FIELD(fieldnum);
991 WRITE_OID_FIELD(resulttype);
992 WRITE_INT_FIELD(resulttypmod);
996 _outFieldStore(StringInfo str, FieldStore *node)
998 WRITE_NODE_TYPE("FIELDSTORE");
1000 WRITE_NODE_FIELD(arg);
1001 WRITE_NODE_FIELD(newvals);
1002 WRITE_NODE_FIELD(fieldnums);
1003 WRITE_OID_FIELD(resulttype);
1007 _outRelabelType(StringInfo str, RelabelType *node)
1009 WRITE_NODE_TYPE("RELABELTYPE");
1011 WRITE_NODE_FIELD(arg);
1012 WRITE_OID_FIELD(resulttype);
1013 WRITE_INT_FIELD(resulttypmod);
1014 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1015 WRITE_LOCATION_FIELD(location);
1019 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1021 WRITE_NODE_TYPE("COERCEVIAIO");
1023 WRITE_NODE_FIELD(arg);
1024 WRITE_OID_FIELD(resulttype);
1025 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1026 WRITE_LOCATION_FIELD(location);
1030 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1032 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1034 WRITE_NODE_FIELD(arg);
1035 WRITE_OID_FIELD(elemfuncid);
1036 WRITE_OID_FIELD(resulttype);
1037 WRITE_INT_FIELD(resulttypmod);
1038 WRITE_BOOL_FIELD(isExplicit);
1039 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1040 WRITE_LOCATION_FIELD(location);
1044 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1046 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1048 WRITE_NODE_FIELD(arg);
1049 WRITE_OID_FIELD(resulttype);
1050 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1051 WRITE_LOCATION_FIELD(location);
1055 _outCaseExpr(StringInfo str, CaseExpr *node)
1057 WRITE_NODE_TYPE("CASE");
1059 WRITE_OID_FIELD(casetype);
1060 WRITE_NODE_FIELD(arg);
1061 WRITE_NODE_FIELD(args);
1062 WRITE_NODE_FIELD(defresult);
1063 WRITE_LOCATION_FIELD(location);
1067 _outCaseWhen(StringInfo str, CaseWhen *node)
1069 WRITE_NODE_TYPE("WHEN");
1071 WRITE_NODE_FIELD(expr);
1072 WRITE_NODE_FIELD(result);
1073 WRITE_LOCATION_FIELD(location);
1077 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1079 WRITE_NODE_TYPE("CASETESTEXPR");
1081 WRITE_OID_FIELD(typeId);
1082 WRITE_INT_FIELD(typeMod);
1086 _outArrayExpr(StringInfo str, ArrayExpr *node)
1088 WRITE_NODE_TYPE("ARRAY");
1090 WRITE_OID_FIELD(array_typeid);
1091 WRITE_OID_FIELD(element_typeid);
1092 WRITE_NODE_FIELD(elements);
1093 WRITE_BOOL_FIELD(multidims);
1094 WRITE_LOCATION_FIELD(location);
1098 _outRowExpr(StringInfo str, RowExpr *node)
1100 WRITE_NODE_TYPE("ROW");
1102 WRITE_NODE_FIELD(args);
1103 WRITE_OID_FIELD(row_typeid);
1104 WRITE_ENUM_FIELD(row_format, CoercionForm);
1105 WRITE_NODE_FIELD(colnames);
1106 WRITE_LOCATION_FIELD(location);
1110 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1112 WRITE_NODE_TYPE("ROWCOMPARE");
1114 WRITE_ENUM_FIELD(rctype, RowCompareType);
1115 WRITE_NODE_FIELD(opnos);
1116 WRITE_NODE_FIELD(opfamilies);
1117 WRITE_NODE_FIELD(largs);
1118 WRITE_NODE_FIELD(rargs);
1122 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1124 WRITE_NODE_TYPE("COALESCE");
1126 WRITE_OID_FIELD(coalescetype);
1127 WRITE_NODE_FIELD(args);
1128 WRITE_LOCATION_FIELD(location);
1132 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1134 WRITE_NODE_TYPE("MINMAX");
1136 WRITE_OID_FIELD(minmaxtype);
1137 WRITE_ENUM_FIELD(op, MinMaxOp);
1138 WRITE_NODE_FIELD(args);
1139 WRITE_LOCATION_FIELD(location);
1143 _outXmlExpr(StringInfo str, XmlExpr *node)
1145 WRITE_NODE_TYPE("XMLEXPR");
1147 WRITE_ENUM_FIELD(op, XmlExprOp);
1148 WRITE_STRING_FIELD(name);
1149 WRITE_NODE_FIELD(named_args);
1150 WRITE_NODE_FIELD(arg_names);
1151 WRITE_NODE_FIELD(args);
1152 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1153 WRITE_OID_FIELD(type);
1154 WRITE_INT_FIELD(typmod);
1155 WRITE_LOCATION_FIELD(location);
1159 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1161 WRITE_NODE_TYPE("NULLIFEXPR");
1163 WRITE_OID_FIELD(opno);
1164 WRITE_OID_FIELD(opfuncid);
1165 WRITE_OID_FIELD(opresulttype);
1166 WRITE_BOOL_FIELD(opretset);
1167 WRITE_NODE_FIELD(args);
1168 WRITE_LOCATION_FIELD(location);
1172 _outNullTest(StringInfo str, NullTest *node)
1174 WRITE_NODE_TYPE("NULLTEST");
1176 WRITE_NODE_FIELD(arg);
1177 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1181 _outBooleanTest(StringInfo str, BooleanTest *node)
1183 WRITE_NODE_TYPE("BOOLEANTEST");
1185 WRITE_NODE_FIELD(arg);
1186 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1190 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1192 WRITE_NODE_TYPE("COERCETODOMAIN");
1194 WRITE_NODE_FIELD(arg);
1195 WRITE_OID_FIELD(resulttype);
1196 WRITE_INT_FIELD(resulttypmod);
1197 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1198 WRITE_LOCATION_FIELD(location);
1202 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1204 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1206 WRITE_OID_FIELD(typeId);
1207 WRITE_INT_FIELD(typeMod);
1208 WRITE_LOCATION_FIELD(location);
1212 _outSetToDefault(StringInfo str, SetToDefault *node)
1214 WRITE_NODE_TYPE("SETTODEFAULT");
1216 WRITE_OID_FIELD(typeId);
1217 WRITE_INT_FIELD(typeMod);
1218 WRITE_LOCATION_FIELD(location);
1222 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1224 WRITE_NODE_TYPE("CURRENTOFEXPR");
1226 WRITE_UINT_FIELD(cvarno);
1227 WRITE_STRING_FIELD(cursor_name);
1228 WRITE_INT_FIELD(cursor_param);
1232 _outTargetEntry(StringInfo str, TargetEntry *node)
1234 WRITE_NODE_TYPE("TARGETENTRY");
1236 WRITE_NODE_FIELD(expr);
1237 WRITE_INT_FIELD(resno);
1238 WRITE_STRING_FIELD(resname);
1239 WRITE_UINT_FIELD(ressortgroupref);
1240 WRITE_OID_FIELD(resorigtbl);
1241 WRITE_INT_FIELD(resorigcol);
1242 WRITE_BOOL_FIELD(resjunk);
1246 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1248 WRITE_NODE_TYPE("RANGETBLREF");
1250 WRITE_INT_FIELD(rtindex);
1254 _outJoinExpr(StringInfo str, JoinExpr *node)
1256 WRITE_NODE_TYPE("JOINEXPR");
1258 WRITE_ENUM_FIELD(jointype, JoinType);
1259 WRITE_BOOL_FIELD(isNatural);
1260 WRITE_NODE_FIELD(larg);
1261 WRITE_NODE_FIELD(rarg);
1262 WRITE_NODE_FIELD(using);
1263 WRITE_NODE_FIELD(quals);
1264 WRITE_NODE_FIELD(alias);
1265 WRITE_INT_FIELD(rtindex);
1269 _outFromExpr(StringInfo str, FromExpr *node)
1271 WRITE_NODE_TYPE("FROMEXPR");
1273 WRITE_NODE_FIELD(fromlist);
1274 WRITE_NODE_FIELD(quals);
1277 /*****************************************************************************
1279 * Stuff from relation.h.
1281 *****************************************************************************/
1284 * print the basic stuff of all nodes that inherit from Path
1286 * Note we do NOT print the parent, else we'd be in infinite recursion
1289 _outPathInfo(StringInfo str, Path *node)
1291 WRITE_ENUM_FIELD(pathtype, NodeTag);
1292 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1293 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1294 WRITE_NODE_FIELD(pathkeys);
1298 * print the basic stuff of all nodes that inherit from JoinPath
1301 _outJoinPathInfo(StringInfo str, JoinPath *node)
1303 _outPathInfo(str, (Path *) node);
1305 WRITE_ENUM_FIELD(jointype, JoinType);
1306 WRITE_NODE_FIELD(outerjoinpath);
1307 WRITE_NODE_FIELD(innerjoinpath);
1308 WRITE_NODE_FIELD(joinrestrictinfo);
1312 _outPath(StringInfo str, Path *node)
1314 WRITE_NODE_TYPE("PATH");
1316 _outPathInfo(str, (Path *) node);
1320 _outIndexPath(StringInfo str, IndexPath *node)
1322 WRITE_NODE_TYPE("INDEXPATH");
1324 _outPathInfo(str, (Path *) node);
1326 WRITE_NODE_FIELD(indexinfo);
1327 WRITE_NODE_FIELD(indexclauses);
1328 WRITE_NODE_FIELD(indexquals);
1329 WRITE_BOOL_FIELD(isjoininner);
1330 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1331 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1332 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1333 WRITE_FLOAT_FIELD(rows, "%.0f");
1337 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1339 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1341 _outPathInfo(str, (Path *) node);
1343 WRITE_NODE_FIELD(bitmapqual);
1344 WRITE_BOOL_FIELD(isjoininner);
1345 WRITE_FLOAT_FIELD(rows, "%.0f");
1349 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1351 WRITE_NODE_TYPE("BITMAPANDPATH");
1353 _outPathInfo(str, (Path *) node);
1355 WRITE_NODE_FIELD(bitmapquals);
1356 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1360 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1362 WRITE_NODE_TYPE("BITMAPORPATH");
1364 _outPathInfo(str, (Path *) node);
1366 WRITE_NODE_FIELD(bitmapquals);
1367 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1371 _outTidPath(StringInfo str, TidPath *node)
1373 WRITE_NODE_TYPE("TIDPATH");
1375 _outPathInfo(str, (Path *) node);
1377 WRITE_NODE_FIELD(tidquals);
1381 _outAppendPath(StringInfo str, AppendPath *node)
1383 WRITE_NODE_TYPE("APPENDPATH");
1385 _outPathInfo(str, (Path *) node);
1387 WRITE_NODE_FIELD(subpaths);
1391 _outResultPath(StringInfo str, ResultPath *node)
1393 WRITE_NODE_TYPE("RESULTPATH");
1395 _outPathInfo(str, (Path *) node);
1397 WRITE_NODE_FIELD(quals);
1401 _outMaterialPath(StringInfo str, MaterialPath *node)
1403 WRITE_NODE_TYPE("MATERIALPATH");
1405 _outPathInfo(str, (Path *) node);
1407 WRITE_NODE_FIELD(subpath);
1411 _outUniquePath(StringInfo str, UniquePath *node)
1413 WRITE_NODE_TYPE("UNIQUEPATH");
1415 _outPathInfo(str, (Path *) node);
1417 WRITE_NODE_FIELD(subpath);
1418 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1419 WRITE_NODE_FIELD(in_operators);
1420 WRITE_NODE_FIELD(uniq_exprs);
1421 WRITE_FLOAT_FIELD(rows, "%.0f");
1425 _outNestPath(StringInfo str, NestPath *node)
1427 WRITE_NODE_TYPE("NESTPATH");
1429 _outJoinPathInfo(str, (JoinPath *) node);
1433 _outMergePath(StringInfo str, MergePath *node)
1435 WRITE_NODE_TYPE("MERGEPATH");
1437 _outJoinPathInfo(str, (JoinPath *) node);
1439 WRITE_NODE_FIELD(path_mergeclauses);
1440 WRITE_NODE_FIELD(outersortkeys);
1441 WRITE_NODE_FIELD(innersortkeys);
1445 _outHashPath(StringInfo str, HashPath *node)
1447 WRITE_NODE_TYPE("HASHPATH");
1449 _outJoinPathInfo(str, (JoinPath *) node);
1451 WRITE_NODE_FIELD(path_hashclauses);
1452 WRITE_INT_FIELD(num_batches);
1456 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1458 WRITE_NODE_TYPE("PLANNERGLOBAL");
1460 /* NB: this isn't a complete set of fields */
1461 WRITE_NODE_FIELD(paramlist);
1462 WRITE_NODE_FIELD(subplans);
1463 WRITE_NODE_FIELD(subrtables);
1464 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1465 WRITE_NODE_FIELD(finalrtable);
1466 WRITE_NODE_FIELD(relationOids);
1467 WRITE_NODE_FIELD(invalItems);
1468 WRITE_UINT_FIELD(lastPHId);
1469 WRITE_BOOL_FIELD(transientPlan);
1473 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1475 WRITE_NODE_TYPE("PLANNERINFO");
1477 /* NB: this isn't a complete set of fields */
1478 WRITE_NODE_FIELD(parse);
1479 WRITE_NODE_FIELD(glob);
1480 WRITE_UINT_FIELD(query_level);
1481 WRITE_NODE_FIELD(join_rel_list);
1482 WRITE_NODE_FIELD(resultRelations);
1483 WRITE_NODE_FIELD(returningLists);
1484 WRITE_NODE_FIELD(init_plans);
1485 WRITE_NODE_FIELD(cte_plan_ids);
1486 WRITE_NODE_FIELD(eq_classes);
1487 WRITE_NODE_FIELD(canon_pathkeys);
1488 WRITE_NODE_FIELD(left_join_clauses);
1489 WRITE_NODE_FIELD(right_join_clauses);
1490 WRITE_NODE_FIELD(full_join_clauses);
1491 WRITE_NODE_FIELD(join_info_list);
1492 WRITE_NODE_FIELD(append_rel_list);
1493 WRITE_NODE_FIELD(placeholder_list);
1494 WRITE_NODE_FIELD(query_pathkeys);
1495 WRITE_NODE_FIELD(group_pathkeys);
1496 WRITE_NODE_FIELD(window_pathkeys);
1497 WRITE_NODE_FIELD(distinct_pathkeys);
1498 WRITE_NODE_FIELD(sort_pathkeys);
1499 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1500 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1501 WRITE_BOOL_FIELD(hasJoinRTEs);
1502 WRITE_BOOL_FIELD(hasHavingQual);
1503 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1504 WRITE_BOOL_FIELD(hasRecursion);
1505 WRITE_INT_FIELD(wt_param_id);
1509 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1511 WRITE_NODE_TYPE("RELOPTINFO");
1513 /* NB: this isn't a complete set of fields */
1514 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1515 WRITE_BITMAPSET_FIELD(relids);
1516 WRITE_FLOAT_FIELD(rows, "%.0f");
1517 WRITE_INT_FIELD(width);
1518 WRITE_NODE_FIELD(reltargetlist);
1519 WRITE_NODE_FIELD(pathlist);
1520 WRITE_NODE_FIELD(cheapest_startup_path);
1521 WRITE_NODE_FIELD(cheapest_total_path);
1522 WRITE_NODE_FIELD(cheapest_unique_path);
1523 WRITE_UINT_FIELD(relid);
1524 WRITE_ENUM_FIELD(rtekind, RTEKind);
1525 WRITE_INT_FIELD(min_attr);
1526 WRITE_INT_FIELD(max_attr);
1527 WRITE_NODE_FIELD(indexlist);
1528 WRITE_UINT_FIELD(pages);
1529 WRITE_FLOAT_FIELD(tuples, "%.0f");
1530 WRITE_NODE_FIELD(subplan);
1531 WRITE_NODE_FIELD(subrtable);
1532 WRITE_NODE_FIELD(baserestrictinfo);
1533 WRITE_NODE_FIELD(joininfo);
1534 WRITE_BOOL_FIELD(has_eclass_joins);
1535 WRITE_BITMAPSET_FIELD(index_outer_relids);
1536 WRITE_NODE_FIELD(index_inner_paths);
1540 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1542 WRITE_NODE_TYPE("INDEXOPTINFO");
1544 /* NB: this isn't a complete set of fields */
1545 WRITE_OID_FIELD(indexoid);
1546 /* Do NOT print rel field, else infinite recursion */
1547 WRITE_UINT_FIELD(pages);
1548 WRITE_FLOAT_FIELD(tuples, "%.0f");
1549 WRITE_INT_FIELD(ncolumns);
1550 WRITE_NODE_FIELD(indexprs);
1551 WRITE_NODE_FIELD(indpred);
1552 WRITE_BOOL_FIELD(predOK);
1553 WRITE_BOOL_FIELD(unique);
1557 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1560 * To simplify reading, we just chase up to the topmost merged EC and
1561 * print that, without bothering to show the merge-ees separately.
1563 while (node->ec_merged)
1564 node = node->ec_merged;
1566 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1568 WRITE_NODE_FIELD(ec_opfamilies);
1569 WRITE_NODE_FIELD(ec_members);
1570 WRITE_NODE_FIELD(ec_sources);
1571 WRITE_NODE_FIELD(ec_derives);
1572 WRITE_BITMAPSET_FIELD(ec_relids);
1573 WRITE_BOOL_FIELD(ec_has_const);
1574 WRITE_BOOL_FIELD(ec_has_volatile);
1575 WRITE_BOOL_FIELD(ec_below_outer_join);
1576 WRITE_BOOL_FIELD(ec_broken);
1577 WRITE_UINT_FIELD(ec_sortref);
1581 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1583 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1585 WRITE_NODE_FIELD(em_expr);
1586 WRITE_BITMAPSET_FIELD(em_relids);
1587 WRITE_BOOL_FIELD(em_is_const);
1588 WRITE_BOOL_FIELD(em_is_child);
1589 WRITE_OID_FIELD(em_datatype);
1593 _outPathKey(StringInfo str, PathKey *node)
1595 WRITE_NODE_TYPE("PATHKEY");
1597 WRITE_NODE_FIELD(pk_eclass);
1598 WRITE_OID_FIELD(pk_opfamily);
1599 WRITE_INT_FIELD(pk_strategy);
1600 WRITE_BOOL_FIELD(pk_nulls_first);
1604 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1606 WRITE_NODE_TYPE("RESTRICTINFO");
1608 /* NB: this isn't a complete set of fields */
1609 WRITE_NODE_FIELD(clause);
1610 WRITE_BOOL_FIELD(is_pushed_down);
1611 WRITE_BOOL_FIELD(outerjoin_delayed);
1612 WRITE_BOOL_FIELD(can_join);
1613 WRITE_BOOL_FIELD(pseudoconstant);
1614 WRITE_BITMAPSET_FIELD(clause_relids);
1615 WRITE_BITMAPSET_FIELD(required_relids);
1616 WRITE_BITMAPSET_FIELD(left_relids);
1617 WRITE_BITMAPSET_FIELD(right_relids);
1618 WRITE_NODE_FIELD(orclause);
1619 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1620 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1621 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1622 WRITE_NODE_FIELD(mergeopfamilies);
1623 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1624 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1625 WRITE_NODE_FIELD(left_em);
1626 WRITE_NODE_FIELD(right_em);
1627 WRITE_BOOL_FIELD(outer_is_left);
1628 WRITE_OID_FIELD(hashjoinoperator);
1632 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1634 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1635 WRITE_BITMAPSET_FIELD(other_relids);
1636 WRITE_BOOL_FIELD(isouterjoin);
1637 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1638 WRITE_NODE_FIELD(cheapest_total_innerpath);
1642 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1644 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1646 WRITE_NODE_FIELD(phexpr);
1647 WRITE_BITMAPSET_FIELD(phrels);
1648 WRITE_UINT_FIELD(phid);
1649 WRITE_UINT_FIELD(phlevelsup);
1653 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1655 WRITE_NODE_TYPE("SPECIALJOININFO");
1657 WRITE_BITMAPSET_FIELD(min_lefthand);
1658 WRITE_BITMAPSET_FIELD(min_righthand);
1659 WRITE_BITMAPSET_FIELD(syn_lefthand);
1660 WRITE_BITMAPSET_FIELD(syn_righthand);
1661 WRITE_ENUM_FIELD(jointype, JoinType);
1662 WRITE_BOOL_FIELD(lhs_strict);
1663 WRITE_BOOL_FIELD(delay_upper_joins);
1664 WRITE_NODE_FIELD(join_quals);
1668 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1670 WRITE_NODE_TYPE("APPENDRELINFO");
1672 WRITE_UINT_FIELD(parent_relid);
1673 WRITE_UINT_FIELD(child_relid);
1674 WRITE_OID_FIELD(parent_reltype);
1675 WRITE_OID_FIELD(child_reltype);
1676 WRITE_NODE_FIELD(translated_vars);
1677 WRITE_OID_FIELD(parent_reloid);
1681 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1683 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1685 WRITE_UINT_FIELD(phid);
1686 WRITE_NODE_FIELD(ph_var);
1687 WRITE_BITMAPSET_FIELD(ph_eval_at);
1688 WRITE_BITMAPSET_FIELD(ph_needed);
1689 WRITE_INT_FIELD(ph_width);
1693 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1695 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1697 WRITE_NODE_FIELD(item);
1698 WRITE_UINT_FIELD(abslevel);
1701 /*****************************************************************************
1703 * Stuff from parsenodes.h.
1705 *****************************************************************************/
1708 _outCreateStmt(StringInfo str, CreateStmt *node)
1710 WRITE_NODE_TYPE("CREATESTMT");
1712 WRITE_NODE_FIELD(relation);
1713 WRITE_NODE_FIELD(tableElts);
1714 WRITE_NODE_FIELD(inhRelations);
1715 WRITE_NODE_FIELD(constraints);
1716 WRITE_NODE_FIELD(options);
1717 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1718 WRITE_STRING_FIELD(tablespacename);
1722 _outIndexStmt(StringInfo str, IndexStmt *node)
1724 WRITE_NODE_TYPE("INDEXSTMT");
1726 WRITE_STRING_FIELD(idxname);
1727 WRITE_NODE_FIELD(relation);
1728 WRITE_STRING_FIELD(accessMethod);
1729 WRITE_STRING_FIELD(tableSpace);
1730 WRITE_NODE_FIELD(indexParams);
1731 WRITE_NODE_FIELD(options);
1732 WRITE_NODE_FIELD(whereClause);
1733 WRITE_BOOL_FIELD(unique);
1734 WRITE_BOOL_FIELD(primary);
1735 WRITE_BOOL_FIELD(isconstraint);
1736 WRITE_BOOL_FIELD(concurrent);
1740 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1742 WRITE_NODE_TYPE("NOTIFY");
1744 WRITE_STRING_FIELD(conditionname);
1748 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1750 WRITE_NODE_TYPE("DECLARECURSOR");
1752 WRITE_STRING_FIELD(portalname);
1753 WRITE_INT_FIELD(options);
1754 WRITE_NODE_FIELD(query);
1758 _outSelectStmt(StringInfo str, SelectStmt *node)
1760 WRITE_NODE_TYPE("SELECT");
1762 WRITE_NODE_FIELD(distinctClause);
1763 WRITE_NODE_FIELD(intoClause);
1764 WRITE_NODE_FIELD(targetList);
1765 WRITE_NODE_FIELD(fromClause);
1766 WRITE_NODE_FIELD(whereClause);
1767 WRITE_NODE_FIELD(groupClause);
1768 WRITE_NODE_FIELD(havingClause);
1769 WRITE_NODE_FIELD(windowClause);
1770 WRITE_NODE_FIELD(withClause);
1771 WRITE_NODE_FIELD(valuesLists);
1772 WRITE_NODE_FIELD(sortClause);
1773 WRITE_NODE_FIELD(limitOffset);
1774 WRITE_NODE_FIELD(limitCount);
1775 WRITE_NODE_FIELD(lockingClause);
1776 WRITE_ENUM_FIELD(op, SetOperation);
1777 WRITE_BOOL_FIELD(all);
1778 WRITE_NODE_FIELD(larg);
1779 WRITE_NODE_FIELD(rarg);
1783 _outFuncCall(StringInfo str, FuncCall *node)
1785 WRITE_NODE_TYPE("FUNCCALL");
1787 WRITE_NODE_FIELD(funcname);
1788 WRITE_NODE_FIELD(args);
1789 WRITE_BOOL_FIELD(agg_star);
1790 WRITE_BOOL_FIELD(agg_distinct);
1791 WRITE_BOOL_FIELD(func_variadic);
1792 WRITE_NODE_FIELD(over);
1793 WRITE_LOCATION_FIELD(location);
1797 _outDefElem(StringInfo str, DefElem *node)
1799 WRITE_NODE_TYPE("DEFELEM");
1801 WRITE_STRING_FIELD(defnamespace);
1802 WRITE_STRING_FIELD(defname);
1803 WRITE_NODE_FIELD(arg);
1804 WRITE_ENUM_FIELD(defaction, DefElemAction);
1808 _outLockingClause(StringInfo str, LockingClause *node)
1810 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1812 WRITE_NODE_FIELD(lockedRels);
1813 WRITE_BOOL_FIELD(forUpdate);
1814 WRITE_BOOL_FIELD(noWait);
1818 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1820 WRITE_NODE_TYPE("XMLSERIALIZE");
1822 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1823 WRITE_NODE_FIELD(expr);
1824 WRITE_NODE_FIELD(typename);
1825 WRITE_LOCATION_FIELD(location);
1829 _outColumnDef(StringInfo str, ColumnDef *node)
1831 WRITE_NODE_TYPE("COLUMNDEF");
1833 WRITE_STRING_FIELD(colname);
1834 WRITE_NODE_FIELD(typename);
1835 WRITE_INT_FIELD(inhcount);
1836 WRITE_BOOL_FIELD(is_local);
1837 WRITE_BOOL_FIELD(is_not_null);
1838 WRITE_NODE_FIELD(raw_default);
1839 WRITE_STRING_FIELD(cooked_default);
1840 WRITE_NODE_FIELD(constraints);
1844 _outTypeName(StringInfo str, TypeName *node)
1846 WRITE_NODE_TYPE("TYPENAME");
1848 WRITE_NODE_FIELD(names);
1849 WRITE_OID_FIELD(typeid);
1850 WRITE_BOOL_FIELD(setof);
1851 WRITE_BOOL_FIELD(pct_type);
1852 WRITE_NODE_FIELD(typmods);
1853 WRITE_INT_FIELD(typemod);
1854 WRITE_NODE_FIELD(arrayBounds);
1855 WRITE_LOCATION_FIELD(location);
1859 _outTypeCast(StringInfo str, TypeCast *node)
1861 WRITE_NODE_TYPE("TYPECAST");
1863 WRITE_NODE_FIELD(arg);
1864 WRITE_NODE_FIELD(typename);
1865 WRITE_LOCATION_FIELD(location);
1869 _outIndexElem(StringInfo str, IndexElem *node)
1871 WRITE_NODE_TYPE("INDEXELEM");
1873 WRITE_STRING_FIELD(name);
1874 WRITE_NODE_FIELD(expr);
1875 WRITE_NODE_FIELD(opclass);
1876 WRITE_ENUM_FIELD(ordering, SortByDir);
1877 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1881 _outQuery(StringInfo str, Query *node)
1883 WRITE_NODE_TYPE("QUERY");
1885 WRITE_ENUM_FIELD(commandType, CmdType);
1886 WRITE_ENUM_FIELD(querySource, QuerySource);
1887 WRITE_BOOL_FIELD(canSetTag);
1890 * Hack to work around missing outfuncs routines for a lot of the
1891 * utility-statement node types. (The only one we actually *need* for
1892 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1893 * for the meantime do this to avoid getting lots of warnings when running
1894 * with debug_print_parse on.
1896 if (node->utilityStmt)
1898 switch (nodeTag(node->utilityStmt))
1903 case T_DeclareCursorStmt:
1904 WRITE_NODE_FIELD(utilityStmt);
1907 appendStringInfo(str, " :utilityStmt ?");
1912 appendStringInfo(str, " :utilityStmt <>");
1914 WRITE_INT_FIELD(resultRelation);
1915 WRITE_NODE_FIELD(intoClause);
1916 WRITE_BOOL_FIELD(hasAggs);
1917 WRITE_BOOL_FIELD(hasWindowFuncs);
1918 WRITE_BOOL_FIELD(hasSubLinks);
1919 WRITE_BOOL_FIELD(hasDistinctOn);
1920 WRITE_BOOL_FIELD(hasRecursive);
1921 WRITE_NODE_FIELD(cteList);
1922 WRITE_NODE_FIELD(rtable);
1923 WRITE_NODE_FIELD(jointree);
1924 WRITE_NODE_FIELD(targetList);
1925 WRITE_NODE_FIELD(returningList);
1926 WRITE_NODE_FIELD(groupClause);
1927 WRITE_NODE_FIELD(havingQual);
1928 WRITE_NODE_FIELD(windowClause);
1929 WRITE_NODE_FIELD(distinctClause);
1930 WRITE_NODE_FIELD(sortClause);
1931 WRITE_NODE_FIELD(limitOffset);
1932 WRITE_NODE_FIELD(limitCount);
1933 WRITE_NODE_FIELD(rowMarks);
1934 WRITE_NODE_FIELD(setOperations);
1938 _outSortGroupClause(StringInfo str, SortGroupClause *node)
1940 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
1942 WRITE_UINT_FIELD(tleSortGroupRef);
1943 WRITE_OID_FIELD(eqop);
1944 WRITE_OID_FIELD(sortop);
1945 WRITE_BOOL_FIELD(nulls_first);
1949 _outWindowClause(StringInfo str, WindowClause *node)
1951 WRITE_NODE_TYPE("WINDOWCLAUSE");
1953 WRITE_STRING_FIELD(name);
1954 WRITE_STRING_FIELD(refname);
1955 WRITE_NODE_FIELD(partitionClause);
1956 WRITE_NODE_FIELD(orderClause);
1957 WRITE_INT_FIELD(frameOptions);
1958 WRITE_UINT_FIELD(winref);
1959 WRITE_BOOL_FIELD(copiedOrder);
1963 _outRowMarkClause(StringInfo str, RowMarkClause *node)
1965 WRITE_NODE_TYPE("ROWMARKCLAUSE");
1967 WRITE_UINT_FIELD(rti);
1968 WRITE_UINT_FIELD(prti);
1969 WRITE_BOOL_FIELD(forUpdate);
1970 WRITE_BOOL_FIELD(noWait);
1971 WRITE_BOOL_FIELD(isParent);
1975 _outWithClause(StringInfo str, WithClause *node)
1977 WRITE_NODE_TYPE("WITHCLAUSE");
1979 WRITE_NODE_FIELD(ctes);
1980 WRITE_BOOL_FIELD(recursive);
1981 WRITE_LOCATION_FIELD(location);
1985 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
1987 WRITE_NODE_TYPE("COMMONTABLEEXPR");
1989 WRITE_STRING_FIELD(ctename);
1990 WRITE_NODE_FIELD(aliascolnames);
1991 WRITE_NODE_FIELD(ctequery);
1992 WRITE_LOCATION_FIELD(location);
1993 WRITE_BOOL_FIELD(cterecursive);
1994 WRITE_INT_FIELD(cterefcount);
1995 WRITE_NODE_FIELD(ctecolnames);
1996 WRITE_NODE_FIELD(ctecoltypes);
1997 WRITE_NODE_FIELD(ctecoltypmods);
2001 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2003 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2005 WRITE_ENUM_FIELD(op, SetOperation);
2006 WRITE_BOOL_FIELD(all);
2007 WRITE_NODE_FIELD(larg);
2008 WRITE_NODE_FIELD(rarg);
2009 WRITE_NODE_FIELD(colTypes);
2010 WRITE_NODE_FIELD(colTypmods);
2011 WRITE_NODE_FIELD(groupClauses);
2015 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2017 WRITE_NODE_TYPE("RTE");
2019 /* put alias + eref first to make dump more legible */
2020 WRITE_NODE_FIELD(alias);
2021 WRITE_NODE_FIELD(eref);
2022 WRITE_ENUM_FIELD(rtekind, RTEKind);
2024 switch (node->rtekind)
2028 WRITE_OID_FIELD(relid);
2031 WRITE_NODE_FIELD(subquery);
2034 WRITE_ENUM_FIELD(jointype, JoinType);
2035 WRITE_NODE_FIELD(joinaliasvars);
2038 WRITE_NODE_FIELD(funcexpr);
2039 WRITE_NODE_FIELD(funccoltypes);
2040 WRITE_NODE_FIELD(funccoltypmods);
2043 WRITE_NODE_FIELD(values_lists);
2046 WRITE_STRING_FIELD(ctename);
2047 WRITE_UINT_FIELD(ctelevelsup);
2048 WRITE_BOOL_FIELD(self_reference);
2049 WRITE_NODE_FIELD(ctecoltypes);
2050 WRITE_NODE_FIELD(ctecoltypmods);
2053 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2057 WRITE_BOOL_FIELD(inh);
2058 WRITE_BOOL_FIELD(inFromCl);
2059 WRITE_UINT_FIELD(requiredPerms);
2060 WRITE_OID_FIELD(checkAsUser);
2061 WRITE_BITMAPSET_FIELD(selectedCols);
2062 WRITE_BITMAPSET_FIELD(modifiedCols);
2066 _outAExpr(StringInfo str, A_Expr *node)
2068 WRITE_NODE_TYPE("AEXPR");
2073 appendStringInfo(str, " ");
2074 WRITE_NODE_FIELD(name);
2077 appendStringInfo(str, " AND");
2080 appendStringInfo(str, " OR");
2083 appendStringInfo(str, " NOT");
2086 appendStringInfo(str, " ");
2087 WRITE_NODE_FIELD(name);
2088 appendStringInfo(str, " ANY ");
2091 appendStringInfo(str, " ");
2092 WRITE_NODE_FIELD(name);
2093 appendStringInfo(str, " ALL ");
2095 case AEXPR_DISTINCT:
2096 appendStringInfo(str, " DISTINCT ");
2097 WRITE_NODE_FIELD(name);
2100 appendStringInfo(str, " NULLIF ");
2101 WRITE_NODE_FIELD(name);
2104 appendStringInfo(str, " OF ");
2105 WRITE_NODE_FIELD(name);
2108 appendStringInfo(str, " IN ");
2109 WRITE_NODE_FIELD(name);
2112 appendStringInfo(str, " ??");
2116 WRITE_NODE_FIELD(lexpr);
2117 WRITE_NODE_FIELD(rexpr);
2118 WRITE_LOCATION_FIELD(location);
2122 _outValue(StringInfo str, Value *value)
2124 switch (value->type)
2127 appendStringInfo(str, "%ld", value->val.ival);
2132 * We assume the value is a valid numeric literal and so does not
2135 appendStringInfoString(str, value->val.str);
2138 appendStringInfoChar(str, '"');
2139 _outToken(str, value->val.str);
2140 appendStringInfoChar(str, '"');
2143 /* internal representation already has leading 'b' */
2144 appendStringInfoString(str, value->val.str);
2147 /* this is seen only within A_Const, not in transformed trees */
2148 appendStringInfoString(str, "NULL");
2151 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2157 _outColumnRef(StringInfo str, ColumnRef *node)
2159 WRITE_NODE_TYPE("COLUMNREF");
2161 WRITE_NODE_FIELD(fields);
2162 WRITE_LOCATION_FIELD(location);
2166 _outParamRef(StringInfo str, ParamRef *node)
2168 WRITE_NODE_TYPE("PARAMREF");
2170 WRITE_INT_FIELD(number);
2171 WRITE_LOCATION_FIELD(location);
2175 _outAConst(StringInfo str, A_Const *node)
2177 WRITE_NODE_TYPE("A_CONST");
2179 appendStringInfo(str, " :val ");
2180 _outValue(str, &(node->val));
2181 WRITE_LOCATION_FIELD(location);
2185 _outA_Star(StringInfo str, A_Star *node)
2187 WRITE_NODE_TYPE("A_STAR");
2191 _outA_Indices(StringInfo str, A_Indices *node)
2193 WRITE_NODE_TYPE("A_INDICES");
2195 WRITE_NODE_FIELD(lidx);
2196 WRITE_NODE_FIELD(uidx);
2200 _outA_Indirection(StringInfo str, A_Indirection *node)
2202 WRITE_NODE_TYPE("A_INDIRECTION");
2204 WRITE_NODE_FIELD(arg);
2205 WRITE_NODE_FIELD(indirection);
2209 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2211 WRITE_NODE_TYPE("A_ARRAYEXPR");
2213 WRITE_NODE_FIELD(elements);
2214 WRITE_LOCATION_FIELD(location);
2218 _outResTarget(StringInfo str, ResTarget *node)
2220 WRITE_NODE_TYPE("RESTARGET");
2222 WRITE_STRING_FIELD(name);
2223 WRITE_NODE_FIELD(indirection);
2224 WRITE_NODE_FIELD(val);
2225 WRITE_LOCATION_FIELD(location);
2229 _outSortBy(StringInfo str, SortBy *node)
2231 WRITE_NODE_TYPE("SORTBY");
2233 WRITE_NODE_FIELD(node);
2234 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2235 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2236 WRITE_NODE_FIELD(useOp);
2237 WRITE_LOCATION_FIELD(location);
2241 _outWindowDef(StringInfo str, WindowDef *node)
2243 WRITE_NODE_TYPE("WINDOWDEF");
2245 WRITE_STRING_FIELD(name);
2246 WRITE_STRING_FIELD(refname);
2247 WRITE_NODE_FIELD(partitionClause);
2248 WRITE_NODE_FIELD(orderClause);
2249 WRITE_INT_FIELD(frameOptions);
2250 WRITE_LOCATION_FIELD(location);
2254 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2256 WRITE_NODE_TYPE("RANGESUBSELECT");
2258 WRITE_NODE_FIELD(subquery);
2259 WRITE_NODE_FIELD(alias);
2263 _outRangeFunction(StringInfo str, RangeFunction *node)
2265 WRITE_NODE_TYPE("RANGEFUNCTION");
2267 WRITE_NODE_FIELD(funccallnode);
2268 WRITE_NODE_FIELD(alias);
2269 WRITE_NODE_FIELD(coldeflist);
2273 _outConstraint(StringInfo str, Constraint *node)
2275 WRITE_NODE_TYPE("CONSTRAINT");
2277 WRITE_STRING_FIELD(name);
2279 appendStringInfo(str, " :contype ");
2280 switch (node->contype)
2282 case CONSTR_PRIMARY:
2283 appendStringInfo(str, "PRIMARY_KEY");
2284 WRITE_NODE_FIELD(keys);
2285 WRITE_NODE_FIELD(options);
2286 WRITE_STRING_FIELD(indexspace);
2290 appendStringInfo(str, "UNIQUE");
2291 WRITE_NODE_FIELD(keys);
2292 WRITE_NODE_FIELD(options);
2293 WRITE_STRING_FIELD(indexspace);
2297 appendStringInfo(str, "CHECK");
2298 WRITE_NODE_FIELD(raw_expr);
2299 WRITE_STRING_FIELD(cooked_expr);
2302 case CONSTR_DEFAULT:
2303 appendStringInfo(str, "DEFAULT");
2304 WRITE_NODE_FIELD(raw_expr);
2305 WRITE_STRING_FIELD(cooked_expr);
2308 case CONSTR_NOTNULL:
2309 appendStringInfo(str, "NOT_NULL");
2313 appendStringInfo(str, "<unrecognized_constraint>");
2319 _outFkConstraint(StringInfo str, FkConstraint *node)
2321 WRITE_NODE_TYPE("FKCONSTRAINT");
2323 WRITE_STRING_FIELD(constr_name);
2324 WRITE_NODE_FIELD(pktable);
2325 WRITE_NODE_FIELD(fk_attrs);
2326 WRITE_NODE_FIELD(pk_attrs);
2327 WRITE_CHAR_FIELD(fk_matchtype);
2328 WRITE_CHAR_FIELD(fk_upd_action);
2329 WRITE_CHAR_FIELD(fk_del_action);
2330 WRITE_BOOL_FIELD(deferrable);
2331 WRITE_BOOL_FIELD(initdeferred);
2332 WRITE_BOOL_FIELD(skip_validation);
2338 * converts a Node into ascii string and append it to 'str'
2341 _outNode(StringInfo str, void *obj)
2344 appendStringInfo(str, "<>");
2345 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2347 else if (IsA(obj, Integer) ||
2350 IsA(obj, BitString))
2352 /* nodeRead does not want to see { } around these! */
2353 _outValue(str, obj);
2357 appendStringInfoChar(str, '{');
2358 switch (nodeTag(obj))
2361 _outPlannedStmt(str, obj);
2367 _outResult(str, obj);
2370 _outAppend(str, obj);
2372 case T_RecursiveUnion:
2373 _outRecursiveUnion(str, obj);
2376 _outBitmapAnd(str, obj);
2379 _outBitmapOr(str, obj);
2385 _outSeqScan(str, obj);
2388 _outIndexScan(str, obj);
2390 case T_BitmapIndexScan:
2391 _outBitmapIndexScan(str, obj);
2393 case T_BitmapHeapScan:
2394 _outBitmapHeapScan(str, obj);
2397 _outTidScan(str, obj);
2399 case T_SubqueryScan:
2400 _outSubqueryScan(str, obj);
2402 case T_FunctionScan:
2403 _outFunctionScan(str, obj);
2406 _outValuesScan(str, obj);
2409 _outCteScan(str, obj);
2411 case T_WorkTableScan:
2412 _outWorkTableScan(str, obj);
2418 _outNestLoop(str, obj);
2421 _outMergeJoin(str, obj);
2424 _outHashJoin(str, obj);
2430 _outWindowAgg(str, obj);
2433 _outGroup(str, obj);
2436 _outMaterial(str, obj);
2442 _outUnique(str, obj);
2448 _outSetOp(str, obj);
2451 _outLimit(str, obj);
2453 case T_PlanInvalItem:
2454 _outPlanInvalItem(str, obj);
2457 _outAlias(str, obj);
2460 _outRangeVar(str, obj);
2463 _outIntoClause(str, obj);
2469 _outConst(str, obj);
2472 _outParam(str, obj);
2475 _outAggref(str, obj);
2478 _outWindowFunc(str, obj);
2481 _outArrayRef(str, obj);
2484 _outFuncExpr(str, obj);
2487 _outOpExpr(str, obj);
2489 case T_DistinctExpr:
2490 _outDistinctExpr(str, obj);
2492 case T_ScalarArrayOpExpr:
2493 _outScalarArrayOpExpr(str, obj);
2496 _outBoolExpr(str, obj);
2499 _outSubLink(str, obj);
2502 _outSubPlan(str, obj);
2504 case T_AlternativeSubPlan:
2505 _outAlternativeSubPlan(str, obj);
2508 _outFieldSelect(str, obj);
2511 _outFieldStore(str, obj);
2514 _outRelabelType(str, obj);
2517 _outCoerceViaIO(str, obj);
2519 case T_ArrayCoerceExpr:
2520 _outArrayCoerceExpr(str, obj);
2522 case T_ConvertRowtypeExpr:
2523 _outConvertRowtypeExpr(str, obj);
2526 _outCaseExpr(str, obj);
2529 _outCaseWhen(str, obj);
2531 case T_CaseTestExpr:
2532 _outCaseTestExpr(str, obj);
2535 _outArrayExpr(str, obj);
2538 _outRowExpr(str, obj);
2540 case T_RowCompareExpr:
2541 _outRowCompareExpr(str, obj);
2543 case T_CoalesceExpr:
2544 _outCoalesceExpr(str, obj);
2547 _outMinMaxExpr(str, obj);
2550 _outXmlExpr(str, obj);
2553 _outNullIfExpr(str, obj);
2556 _outNullTest(str, obj);
2559 _outBooleanTest(str, obj);
2561 case T_CoerceToDomain:
2562 _outCoerceToDomain(str, obj);
2564 case T_CoerceToDomainValue:
2565 _outCoerceToDomainValue(str, obj);
2567 case T_SetToDefault:
2568 _outSetToDefault(str, obj);
2570 case T_CurrentOfExpr:
2571 _outCurrentOfExpr(str, obj);
2574 _outTargetEntry(str, obj);
2577 _outRangeTblRef(str, obj);
2580 _outJoinExpr(str, obj);
2583 _outFromExpr(str, obj);
2590 _outIndexPath(str, obj);
2592 case T_BitmapHeapPath:
2593 _outBitmapHeapPath(str, obj);
2595 case T_BitmapAndPath:
2596 _outBitmapAndPath(str, obj);
2598 case T_BitmapOrPath:
2599 _outBitmapOrPath(str, obj);
2602 _outTidPath(str, obj);
2605 _outAppendPath(str, obj);
2608 _outResultPath(str, obj);
2610 case T_MaterialPath:
2611 _outMaterialPath(str, obj);
2614 _outUniquePath(str, obj);
2617 _outNestPath(str, obj);
2620 _outMergePath(str, obj);
2623 _outHashPath(str, obj);
2625 case T_PlannerGlobal:
2626 _outPlannerGlobal(str, obj);
2629 _outPlannerInfo(str, obj);
2632 _outRelOptInfo(str, obj);
2634 case T_IndexOptInfo:
2635 _outIndexOptInfo(str, obj);
2637 case T_EquivalenceClass:
2638 _outEquivalenceClass(str, obj);
2640 case T_EquivalenceMember:
2641 _outEquivalenceMember(str, obj);
2644 _outPathKey(str, obj);
2646 case T_RestrictInfo:
2647 _outRestrictInfo(str, obj);
2649 case T_InnerIndexscanInfo:
2650 _outInnerIndexscanInfo(str, obj);
2652 case T_PlaceHolderVar:
2653 _outPlaceHolderVar(str, obj);
2655 case T_SpecialJoinInfo:
2656 _outSpecialJoinInfo(str, obj);
2658 case T_AppendRelInfo:
2659 _outAppendRelInfo(str, obj);
2661 case T_PlaceHolderInfo:
2662 _outPlaceHolderInfo(str, obj);
2664 case T_PlannerParamItem:
2665 _outPlannerParamItem(str, obj);
2669 _outCreateStmt(str, obj);
2672 _outIndexStmt(str, obj);
2675 _outNotifyStmt(str, obj);
2677 case T_DeclareCursorStmt:
2678 _outDeclareCursorStmt(str, obj);
2681 _outSelectStmt(str, obj);
2684 _outColumnDef(str, obj);
2687 _outTypeName(str, obj);
2690 _outTypeCast(str, obj);
2693 _outIndexElem(str, obj);
2696 _outQuery(str, obj);
2698 case T_SortGroupClause:
2699 _outSortGroupClause(str, obj);
2701 case T_WindowClause:
2702 _outWindowClause(str, obj);
2704 case T_RowMarkClause:
2705 _outRowMarkClause(str, obj);
2708 _outWithClause(str, obj);
2710 case T_CommonTableExpr:
2711 _outCommonTableExpr(str, obj);
2713 case T_SetOperationStmt:
2714 _outSetOperationStmt(str, obj);
2716 case T_RangeTblEntry:
2717 _outRangeTblEntry(str, obj);
2720 _outAExpr(str, obj);
2723 _outColumnRef(str, obj);
2726 _outParamRef(str, obj);
2729 _outAConst(str, obj);
2732 _outA_Star(str, obj);
2735 _outA_Indices(str, obj);
2737 case T_A_Indirection:
2738 _outA_Indirection(str, obj);
2741 _outA_ArrayExpr(str, obj);
2744 _outResTarget(str, obj);
2747 _outSortBy(str, obj);
2750 _outWindowDef(str, obj);
2752 case T_RangeSubselect:
2753 _outRangeSubselect(str, obj);
2755 case T_RangeFunction:
2756 _outRangeFunction(str, obj);
2759 _outConstraint(str, obj);
2761 case T_FkConstraint:
2762 _outFkConstraint(str, obj);
2765 _outFuncCall(str, obj);
2768 _outDefElem(str, obj);
2770 case T_LockingClause:
2771 _outLockingClause(str, obj);
2773 case T_XmlSerialize:
2774 _outXmlSerialize(str, obj);
2780 * This should be an ERROR, but it's too useful to be able to
2781 * dump structures that _outNode only understands part of.
2783 elog(WARNING, "could not dump unrecognized node type: %d",
2784 (int) nodeTag(obj));
2787 appendStringInfoChar(str, '}');
2793 * returns the ascii representation of the Node as a palloc'd string
2796 nodeToString(void *obj)
2800 /* see stringinfo.h for an explanation of this maneuver */
2801 initStringInfo(&str);
2802 _outNode(&str, obj);