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.349 2009/01/01 17:23:43 momjian 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.
183 * Currently bitmapsets do not appear in any node type that is stored in
184 * rules, so there is no support in readfuncs.c for reading this format.
187 _outBitmapset(StringInfo str, Bitmapset *bms)
192 appendStringInfoChar(str, '(');
193 appendStringInfoChar(str, 'b');
194 tmpset = bms_copy(bms);
195 while ((x = bms_first_member(tmpset)) >= 0)
196 appendStringInfo(str, " %d", x);
198 appendStringInfoChar(str, ')');
202 * Print the value of a Datum given its type.
205 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
211 length = datumGetSize(value, typbyval, typlen);
215 s = (char *) (&value);
216 appendStringInfo(str, "%u [ ", (unsigned int) length);
217 for (i = 0; i < (Size) sizeof(Datum); i++)
218 appendStringInfo(str, "%d ", (int) (s[i]));
219 appendStringInfo(str, "]");
223 s = (char *) DatumGetPointer(value);
224 if (!PointerIsValid(s))
225 appendStringInfo(str, "0 [ ]");
228 appendStringInfo(str, "%u [ ", (unsigned int) length);
229 for (i = 0; i < length; i++)
230 appendStringInfo(str, "%d ", (int) (s[i]));
231 appendStringInfo(str, "]");
238 * Stuff from plannodes.h
242 _outPlannedStmt(StringInfo str, PlannedStmt *node)
244 WRITE_NODE_TYPE("PLANNEDSTMT");
246 WRITE_ENUM_FIELD(commandType, CmdType);
247 WRITE_BOOL_FIELD(canSetTag);
248 WRITE_NODE_FIELD(planTree);
249 WRITE_NODE_FIELD(rtable);
250 WRITE_NODE_FIELD(resultRelations);
251 WRITE_NODE_FIELD(utilityStmt);
252 WRITE_NODE_FIELD(intoClause);
253 WRITE_NODE_FIELD(subplans);
254 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
255 WRITE_NODE_FIELD(returningLists);
256 WRITE_NODE_FIELD(rowMarks);
257 WRITE_NODE_FIELD(relationOids);
258 WRITE_NODE_FIELD(invalItems);
259 WRITE_INT_FIELD(nParamExec);
263 * print the basic stuff of all nodes that inherit from Plan
266 _outPlanInfo(StringInfo str, Plan *node)
268 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
269 WRITE_FLOAT_FIELD(total_cost, "%.2f");
270 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
271 WRITE_INT_FIELD(plan_width);
272 WRITE_NODE_FIELD(targetlist);
273 WRITE_NODE_FIELD(qual);
274 WRITE_NODE_FIELD(lefttree);
275 WRITE_NODE_FIELD(righttree);
276 WRITE_NODE_FIELD(initPlan);
277 WRITE_BITMAPSET_FIELD(extParam);
278 WRITE_BITMAPSET_FIELD(allParam);
282 * print the basic stuff of all nodes that inherit from Scan
285 _outScanInfo(StringInfo str, Scan *node)
287 _outPlanInfo(str, (Plan *) node);
289 WRITE_UINT_FIELD(scanrelid);
293 * print the basic stuff of all nodes that inherit from Join
296 _outJoinPlanInfo(StringInfo str, Join *node)
298 _outPlanInfo(str, (Plan *) node);
300 WRITE_ENUM_FIELD(jointype, JoinType);
301 WRITE_NODE_FIELD(joinqual);
306 _outPlan(StringInfo str, Plan *node)
308 WRITE_NODE_TYPE("PLAN");
310 _outPlanInfo(str, (Plan *) node);
314 _outResult(StringInfo str, Result *node)
316 WRITE_NODE_TYPE("RESULT");
318 _outPlanInfo(str, (Plan *) node);
320 WRITE_NODE_FIELD(resconstantqual);
324 _outAppend(StringInfo str, Append *node)
326 WRITE_NODE_TYPE("APPEND");
328 _outPlanInfo(str, (Plan *) node);
330 WRITE_NODE_FIELD(appendplans);
331 WRITE_BOOL_FIELD(isTarget);
335 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
339 WRITE_NODE_TYPE("RECURSIVEUNION");
341 _outPlanInfo(str, (Plan *) node);
343 WRITE_INT_FIELD(wtParam);
344 WRITE_INT_FIELD(numCols);
346 appendStringInfo(str, " :dupColIdx");
347 for (i = 0; i < node->numCols; i++)
348 appendStringInfo(str, " %d", node->dupColIdx[i]);
350 appendStringInfo(str, " :dupOperators");
351 for (i = 0; i < node->numCols; i++)
352 appendStringInfo(str, " %u", node->dupOperators[i]);
354 WRITE_LONG_FIELD(numGroups);
358 _outBitmapAnd(StringInfo str, BitmapAnd *node)
360 WRITE_NODE_TYPE("BITMAPAND");
362 _outPlanInfo(str, (Plan *) node);
364 WRITE_NODE_FIELD(bitmapplans);
368 _outBitmapOr(StringInfo str, BitmapOr *node)
370 WRITE_NODE_TYPE("BITMAPOR");
372 _outPlanInfo(str, (Plan *) node);
374 WRITE_NODE_FIELD(bitmapplans);
378 _outScan(StringInfo str, Scan *node)
380 WRITE_NODE_TYPE("SCAN");
382 _outScanInfo(str, (Scan *) node);
386 _outSeqScan(StringInfo str, SeqScan *node)
388 WRITE_NODE_TYPE("SEQSCAN");
390 _outScanInfo(str, (Scan *) node);
394 _outIndexScan(StringInfo str, IndexScan *node)
396 WRITE_NODE_TYPE("INDEXSCAN");
398 _outScanInfo(str, (Scan *) node);
400 WRITE_OID_FIELD(indexid);
401 WRITE_NODE_FIELD(indexqual);
402 WRITE_NODE_FIELD(indexqualorig);
403 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
407 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
409 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
411 _outScanInfo(str, (Scan *) node);
413 WRITE_OID_FIELD(indexid);
414 WRITE_NODE_FIELD(indexqual);
415 WRITE_NODE_FIELD(indexqualorig);
419 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
421 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
423 _outScanInfo(str, (Scan *) node);
425 WRITE_NODE_FIELD(bitmapqualorig);
429 _outTidScan(StringInfo str, TidScan *node)
431 WRITE_NODE_TYPE("TIDSCAN");
433 _outScanInfo(str, (Scan *) node);
435 WRITE_NODE_FIELD(tidquals);
439 _outSubqueryScan(StringInfo str, SubqueryScan *node)
441 WRITE_NODE_TYPE("SUBQUERYSCAN");
443 _outScanInfo(str, (Scan *) node);
445 WRITE_NODE_FIELD(subplan);
446 WRITE_NODE_FIELD(subrtable);
450 _outFunctionScan(StringInfo str, FunctionScan *node)
452 WRITE_NODE_TYPE("FUNCTIONSCAN");
454 _outScanInfo(str, (Scan *) node);
456 WRITE_NODE_FIELD(funcexpr);
457 WRITE_NODE_FIELD(funccolnames);
458 WRITE_NODE_FIELD(funccoltypes);
459 WRITE_NODE_FIELD(funccoltypmods);
463 _outValuesScan(StringInfo str, ValuesScan *node)
465 WRITE_NODE_TYPE("VALUESSCAN");
467 _outScanInfo(str, (Scan *) node);
469 WRITE_NODE_FIELD(values_lists);
473 _outCteScan(StringInfo str, CteScan *node)
475 WRITE_NODE_TYPE("CTESCAN");
477 _outScanInfo(str, (Scan *) node);
479 WRITE_INT_FIELD(ctePlanId);
480 WRITE_INT_FIELD(cteParam);
484 _outWorkTableScan(StringInfo str, WorkTableScan *node)
486 WRITE_NODE_TYPE("WORKTABLESCAN");
488 _outScanInfo(str, (Scan *) node);
490 WRITE_INT_FIELD(wtParam);
494 _outJoin(StringInfo str, Join *node)
496 WRITE_NODE_TYPE("JOIN");
498 _outJoinPlanInfo(str, (Join *) node);
502 _outNestLoop(StringInfo str, NestLoop *node)
504 WRITE_NODE_TYPE("NESTLOOP");
506 _outJoinPlanInfo(str, (Join *) node);
510 _outMergeJoin(StringInfo str, MergeJoin *node)
515 WRITE_NODE_TYPE("MERGEJOIN");
517 _outJoinPlanInfo(str, (Join *) node);
519 WRITE_NODE_FIELD(mergeclauses);
521 numCols = list_length(node->mergeclauses);
523 appendStringInfo(str, " :mergeFamilies");
524 for (i = 0; i < numCols; i++)
525 appendStringInfo(str, " %u", node->mergeFamilies[i]);
527 appendStringInfo(str, " :mergeStrategies");
528 for (i = 0; i < numCols; i++)
529 appendStringInfo(str, " %d", node->mergeStrategies[i]);
531 appendStringInfo(str, " :mergeNullsFirst");
532 for (i = 0; i < numCols; i++)
533 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
537 _outHashJoin(StringInfo str, HashJoin *node)
539 WRITE_NODE_TYPE("HASHJOIN");
541 _outJoinPlanInfo(str, (Join *) node);
543 WRITE_NODE_FIELD(hashclauses);
547 _outAgg(StringInfo str, Agg *node)
551 WRITE_NODE_TYPE("AGG");
553 _outPlanInfo(str, (Plan *) node);
555 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
556 WRITE_INT_FIELD(numCols);
558 appendStringInfo(str, " :grpColIdx");
559 for (i = 0; i < node->numCols; i++)
560 appendStringInfo(str, " %d", node->grpColIdx[i]);
562 appendStringInfo(str, " :grpOperators");
563 for (i = 0; i < node->numCols; i++)
564 appendStringInfo(str, " %u", node->grpOperators[i]);
566 WRITE_LONG_FIELD(numGroups);
570 _outWindowAgg(StringInfo str, WindowAgg *node)
574 WRITE_NODE_TYPE("WINDOWAGG");
576 _outPlanInfo(str, (Plan *) node);
578 WRITE_UINT_FIELD(winref);
579 WRITE_INT_FIELD(partNumCols);
581 appendStringInfo(str, " :partColIdx");
582 for (i = 0; i < node->partNumCols; i++)
583 appendStringInfo(str, " %d", node->partColIdx[i]);
585 appendStringInfo(str, " :partOperations");
586 for (i = 0; i < node->partNumCols; i++)
587 appendStringInfo(str, " %u", node->partOperators[i]);
589 WRITE_INT_FIELD(ordNumCols);
591 appendStringInfo(str, " :ordColIdx");
592 for (i = 0; i< node->ordNumCols; i++)
593 appendStringInfo(str, " %d", node->ordColIdx[i]);
595 appendStringInfo(str, " :ordOperations");
596 for (i = 0; i < node->ordNumCols; i++)
597 appendStringInfo(str, " %u", node->ordOperators[i]);
599 WRITE_INT_FIELD(frameOptions);
603 _outGroup(StringInfo str, Group *node)
607 WRITE_NODE_TYPE("GROUP");
609 _outPlanInfo(str, (Plan *) node);
611 WRITE_INT_FIELD(numCols);
613 appendStringInfo(str, " :grpColIdx");
614 for (i = 0; i < node->numCols; i++)
615 appendStringInfo(str, " %d", node->grpColIdx[i]);
617 appendStringInfo(str, " :grpOperators");
618 for (i = 0; i < node->numCols; i++)
619 appendStringInfo(str, " %u", node->grpOperators[i]);
623 _outMaterial(StringInfo str, Material *node)
625 WRITE_NODE_TYPE("MATERIAL");
627 _outPlanInfo(str, (Plan *) node);
631 _outSort(StringInfo str, Sort *node)
635 WRITE_NODE_TYPE("SORT");
637 _outPlanInfo(str, (Plan *) node);
639 WRITE_INT_FIELD(numCols);
641 appendStringInfo(str, " :sortColIdx");
642 for (i = 0; i < node->numCols; i++)
643 appendStringInfo(str, " %d", node->sortColIdx[i]);
645 appendStringInfo(str, " :sortOperators");
646 for (i = 0; i < node->numCols; i++)
647 appendStringInfo(str, " %u", node->sortOperators[i]);
649 appendStringInfo(str, " :nullsFirst");
650 for (i = 0; i < node->numCols; i++)
651 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
655 _outUnique(StringInfo str, Unique *node)
659 WRITE_NODE_TYPE("UNIQUE");
661 _outPlanInfo(str, (Plan *) node);
663 WRITE_INT_FIELD(numCols);
665 appendStringInfo(str, " :uniqColIdx");
666 for (i = 0; i < node->numCols; i++)
667 appendStringInfo(str, " %d", node->uniqColIdx[i]);
669 appendStringInfo(str, " :uniqOperators");
670 for (i = 0; i < node->numCols; i++)
671 appendStringInfo(str, " %u", node->uniqOperators[i]);
675 _outHash(StringInfo str, Hash *node)
677 WRITE_NODE_TYPE("HASH");
679 _outPlanInfo(str, (Plan *) node);
683 _outSetOp(StringInfo str, SetOp *node)
687 WRITE_NODE_TYPE("SETOP");
689 _outPlanInfo(str, (Plan *) node);
691 WRITE_ENUM_FIELD(cmd, SetOpCmd);
692 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
693 WRITE_INT_FIELD(numCols);
695 appendStringInfo(str, " :dupColIdx");
696 for (i = 0; i < node->numCols; i++)
697 appendStringInfo(str, " %d", node->dupColIdx[i]);
699 appendStringInfo(str, " :dupOperators");
700 for (i = 0; i < node->numCols; i++)
701 appendStringInfo(str, " %u", node->dupOperators[i]);
703 WRITE_INT_FIELD(flagColIdx);
704 WRITE_INT_FIELD(firstFlag);
705 WRITE_LONG_FIELD(numGroups);
709 _outLimit(StringInfo str, Limit *node)
711 WRITE_NODE_TYPE("LIMIT");
713 _outPlanInfo(str, (Plan *) node);
715 WRITE_NODE_FIELD(limitOffset);
716 WRITE_NODE_FIELD(limitCount);
720 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
722 WRITE_NODE_TYPE("PLANINVALITEM");
724 WRITE_INT_FIELD(cacheId);
725 appendStringInfo(str, " :tupleId (%u,%u)",
726 ItemPointerGetBlockNumber(&node->tupleId),
727 ItemPointerGetOffsetNumber(&node->tupleId));
730 /*****************************************************************************
732 * Stuff from primnodes.h.
734 *****************************************************************************/
737 _outAlias(StringInfo str, Alias *node)
739 WRITE_NODE_TYPE("ALIAS");
741 WRITE_STRING_FIELD(aliasname);
742 WRITE_NODE_FIELD(colnames);
746 _outRangeVar(StringInfo str, RangeVar *node)
748 WRITE_NODE_TYPE("RANGEVAR");
751 * we deliberately ignore catalogname here, since it is presently not
752 * semantically meaningful
754 WRITE_STRING_FIELD(schemaname);
755 WRITE_STRING_FIELD(relname);
756 WRITE_ENUM_FIELD(inhOpt, InhOption);
757 WRITE_BOOL_FIELD(istemp);
758 WRITE_NODE_FIELD(alias);
759 WRITE_LOCATION_FIELD(location);
763 _outIntoClause(StringInfo str, IntoClause *node)
765 WRITE_NODE_TYPE("INTOCLAUSE");
767 WRITE_NODE_FIELD(rel);
768 WRITE_NODE_FIELD(colNames);
769 WRITE_NODE_FIELD(options);
770 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
771 WRITE_STRING_FIELD(tableSpaceName);
775 _outVar(StringInfo str, Var *node)
777 WRITE_NODE_TYPE("VAR");
779 WRITE_UINT_FIELD(varno);
780 WRITE_INT_FIELD(varattno);
781 WRITE_OID_FIELD(vartype);
782 WRITE_INT_FIELD(vartypmod);
783 WRITE_UINT_FIELD(varlevelsup);
784 WRITE_UINT_FIELD(varnoold);
785 WRITE_INT_FIELD(varoattno);
786 WRITE_LOCATION_FIELD(location);
790 _outConst(StringInfo str, Const *node)
792 WRITE_NODE_TYPE("CONST");
794 WRITE_OID_FIELD(consttype);
795 WRITE_INT_FIELD(consttypmod);
796 WRITE_INT_FIELD(constlen);
797 WRITE_BOOL_FIELD(constbyval);
798 WRITE_BOOL_FIELD(constisnull);
799 WRITE_LOCATION_FIELD(location);
801 appendStringInfo(str, " :constvalue ");
802 if (node->constisnull)
803 appendStringInfo(str, "<>");
805 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
809 _outParam(StringInfo str, Param *node)
811 WRITE_NODE_TYPE("PARAM");
813 WRITE_ENUM_FIELD(paramkind, ParamKind);
814 WRITE_INT_FIELD(paramid);
815 WRITE_OID_FIELD(paramtype);
816 WRITE_INT_FIELD(paramtypmod);
817 WRITE_LOCATION_FIELD(location);
821 _outAggref(StringInfo str, Aggref *node)
823 WRITE_NODE_TYPE("AGGREF");
825 WRITE_OID_FIELD(aggfnoid);
826 WRITE_OID_FIELD(aggtype);
827 WRITE_NODE_FIELD(args);
828 WRITE_UINT_FIELD(agglevelsup);
829 WRITE_BOOL_FIELD(aggstar);
830 WRITE_BOOL_FIELD(aggdistinct);
831 WRITE_LOCATION_FIELD(location);
835 _outWindowFunc(StringInfo str, WindowFunc *node)
837 WRITE_NODE_TYPE("WINDOWFUNC");
839 WRITE_OID_FIELD(winfnoid);
840 WRITE_OID_FIELD(wintype);
841 WRITE_NODE_FIELD(args);
842 WRITE_UINT_FIELD(winref);
843 WRITE_BOOL_FIELD(winstar);
844 WRITE_BOOL_FIELD(winagg);
845 WRITE_LOCATION_FIELD(location);
849 _outArrayRef(StringInfo str, ArrayRef *node)
851 WRITE_NODE_TYPE("ARRAYREF");
853 WRITE_OID_FIELD(refarraytype);
854 WRITE_OID_FIELD(refelemtype);
855 WRITE_INT_FIELD(reftypmod);
856 WRITE_NODE_FIELD(refupperindexpr);
857 WRITE_NODE_FIELD(reflowerindexpr);
858 WRITE_NODE_FIELD(refexpr);
859 WRITE_NODE_FIELD(refassgnexpr);
863 _outFuncExpr(StringInfo str, FuncExpr *node)
865 WRITE_NODE_TYPE("FUNCEXPR");
867 WRITE_OID_FIELD(funcid);
868 WRITE_OID_FIELD(funcresulttype);
869 WRITE_BOOL_FIELD(funcretset);
870 WRITE_ENUM_FIELD(funcformat, CoercionForm);
871 WRITE_NODE_FIELD(args);
872 WRITE_LOCATION_FIELD(location);
876 _outOpExpr(StringInfo str, OpExpr *node)
878 WRITE_NODE_TYPE("OPEXPR");
880 WRITE_OID_FIELD(opno);
881 WRITE_OID_FIELD(opfuncid);
882 WRITE_OID_FIELD(opresulttype);
883 WRITE_BOOL_FIELD(opretset);
884 WRITE_NODE_FIELD(args);
885 WRITE_LOCATION_FIELD(location);
889 _outDistinctExpr(StringInfo str, DistinctExpr *node)
891 WRITE_NODE_TYPE("DISTINCTEXPR");
893 WRITE_OID_FIELD(opno);
894 WRITE_OID_FIELD(opfuncid);
895 WRITE_OID_FIELD(opresulttype);
896 WRITE_BOOL_FIELD(opretset);
897 WRITE_NODE_FIELD(args);
898 WRITE_LOCATION_FIELD(location);
902 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
904 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
906 WRITE_OID_FIELD(opno);
907 WRITE_OID_FIELD(opfuncid);
908 WRITE_BOOL_FIELD(useOr);
909 WRITE_NODE_FIELD(args);
910 WRITE_LOCATION_FIELD(location);
914 _outBoolExpr(StringInfo str, BoolExpr *node)
918 WRITE_NODE_TYPE("BOOLEXPR");
920 /* do-it-yourself enum representation */
921 switch (node->boolop)
933 appendStringInfo(str, " :boolop ");
934 _outToken(str, opstr);
936 WRITE_NODE_FIELD(args);
937 WRITE_LOCATION_FIELD(location);
941 _outSubLink(StringInfo str, SubLink *node)
943 WRITE_NODE_TYPE("SUBLINK");
945 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
946 WRITE_NODE_FIELD(testexpr);
947 WRITE_NODE_FIELD(operName);
948 WRITE_NODE_FIELD(subselect);
949 WRITE_LOCATION_FIELD(location);
953 _outSubPlan(StringInfo str, SubPlan *node)
955 WRITE_NODE_TYPE("SUBPLAN");
957 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
958 WRITE_NODE_FIELD(testexpr);
959 WRITE_NODE_FIELD(paramIds);
960 WRITE_INT_FIELD(plan_id);
961 WRITE_OID_FIELD(firstColType);
962 WRITE_BOOL_FIELD(useHashTable);
963 WRITE_BOOL_FIELD(unknownEqFalse);
964 WRITE_NODE_FIELD(setParam);
965 WRITE_NODE_FIELD(parParam);
966 WRITE_NODE_FIELD(args);
967 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
968 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
972 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
974 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
976 WRITE_NODE_FIELD(subplans);
980 _outFieldSelect(StringInfo str, FieldSelect *node)
982 WRITE_NODE_TYPE("FIELDSELECT");
984 WRITE_NODE_FIELD(arg);
985 WRITE_INT_FIELD(fieldnum);
986 WRITE_OID_FIELD(resulttype);
987 WRITE_INT_FIELD(resulttypmod);
991 _outFieldStore(StringInfo str, FieldStore *node)
993 WRITE_NODE_TYPE("FIELDSTORE");
995 WRITE_NODE_FIELD(arg);
996 WRITE_NODE_FIELD(newvals);
997 WRITE_NODE_FIELD(fieldnums);
998 WRITE_OID_FIELD(resulttype);
1002 _outRelabelType(StringInfo str, RelabelType *node)
1004 WRITE_NODE_TYPE("RELABELTYPE");
1006 WRITE_NODE_FIELD(arg);
1007 WRITE_OID_FIELD(resulttype);
1008 WRITE_INT_FIELD(resulttypmod);
1009 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1010 WRITE_LOCATION_FIELD(location);
1014 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1016 WRITE_NODE_TYPE("COERCEVIAIO");
1018 WRITE_NODE_FIELD(arg);
1019 WRITE_OID_FIELD(resulttype);
1020 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1021 WRITE_LOCATION_FIELD(location);
1025 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1027 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1029 WRITE_NODE_FIELD(arg);
1030 WRITE_OID_FIELD(elemfuncid);
1031 WRITE_OID_FIELD(resulttype);
1032 WRITE_INT_FIELD(resulttypmod);
1033 WRITE_BOOL_FIELD(isExplicit);
1034 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1035 WRITE_LOCATION_FIELD(location);
1039 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1041 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1043 WRITE_NODE_FIELD(arg);
1044 WRITE_OID_FIELD(resulttype);
1045 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1046 WRITE_LOCATION_FIELD(location);
1050 _outCaseExpr(StringInfo str, CaseExpr *node)
1052 WRITE_NODE_TYPE("CASE");
1054 WRITE_OID_FIELD(casetype);
1055 WRITE_NODE_FIELD(arg);
1056 WRITE_NODE_FIELD(args);
1057 WRITE_NODE_FIELD(defresult);
1058 WRITE_LOCATION_FIELD(location);
1062 _outCaseWhen(StringInfo str, CaseWhen *node)
1064 WRITE_NODE_TYPE("WHEN");
1066 WRITE_NODE_FIELD(expr);
1067 WRITE_NODE_FIELD(result);
1068 WRITE_LOCATION_FIELD(location);
1072 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1074 WRITE_NODE_TYPE("CASETESTEXPR");
1076 WRITE_OID_FIELD(typeId);
1077 WRITE_INT_FIELD(typeMod);
1081 _outArrayExpr(StringInfo str, ArrayExpr *node)
1083 WRITE_NODE_TYPE("ARRAY");
1085 WRITE_OID_FIELD(array_typeid);
1086 WRITE_OID_FIELD(element_typeid);
1087 WRITE_NODE_FIELD(elements);
1088 WRITE_BOOL_FIELD(multidims);
1089 WRITE_LOCATION_FIELD(location);
1093 _outRowExpr(StringInfo str, RowExpr *node)
1095 WRITE_NODE_TYPE("ROW");
1097 WRITE_NODE_FIELD(args);
1098 WRITE_OID_FIELD(row_typeid);
1099 WRITE_ENUM_FIELD(row_format, CoercionForm);
1100 WRITE_NODE_FIELD(colnames);
1101 WRITE_LOCATION_FIELD(location);
1105 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1107 WRITE_NODE_TYPE("ROWCOMPARE");
1109 WRITE_ENUM_FIELD(rctype, RowCompareType);
1110 WRITE_NODE_FIELD(opnos);
1111 WRITE_NODE_FIELD(opfamilies);
1112 WRITE_NODE_FIELD(largs);
1113 WRITE_NODE_FIELD(rargs);
1117 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1119 WRITE_NODE_TYPE("COALESCE");
1121 WRITE_OID_FIELD(coalescetype);
1122 WRITE_NODE_FIELD(args);
1123 WRITE_LOCATION_FIELD(location);
1127 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1129 WRITE_NODE_TYPE("MINMAX");
1131 WRITE_OID_FIELD(minmaxtype);
1132 WRITE_ENUM_FIELD(op, MinMaxOp);
1133 WRITE_NODE_FIELD(args);
1134 WRITE_LOCATION_FIELD(location);
1138 _outXmlExpr(StringInfo str, XmlExpr *node)
1140 WRITE_NODE_TYPE("XMLEXPR");
1142 WRITE_ENUM_FIELD(op, XmlExprOp);
1143 WRITE_STRING_FIELD(name);
1144 WRITE_NODE_FIELD(named_args);
1145 WRITE_NODE_FIELD(arg_names);
1146 WRITE_NODE_FIELD(args);
1147 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1148 WRITE_OID_FIELD(type);
1149 WRITE_INT_FIELD(typmod);
1150 WRITE_LOCATION_FIELD(location);
1154 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1156 WRITE_NODE_TYPE("NULLIFEXPR");
1158 WRITE_OID_FIELD(opno);
1159 WRITE_OID_FIELD(opfuncid);
1160 WRITE_OID_FIELD(opresulttype);
1161 WRITE_BOOL_FIELD(opretset);
1162 WRITE_NODE_FIELD(args);
1163 WRITE_LOCATION_FIELD(location);
1167 _outNullTest(StringInfo str, NullTest *node)
1169 WRITE_NODE_TYPE("NULLTEST");
1171 WRITE_NODE_FIELD(arg);
1172 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1176 _outBooleanTest(StringInfo str, BooleanTest *node)
1178 WRITE_NODE_TYPE("BOOLEANTEST");
1180 WRITE_NODE_FIELD(arg);
1181 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1185 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1187 WRITE_NODE_TYPE("COERCETODOMAIN");
1189 WRITE_NODE_FIELD(arg);
1190 WRITE_OID_FIELD(resulttype);
1191 WRITE_INT_FIELD(resulttypmod);
1192 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1193 WRITE_LOCATION_FIELD(location);
1197 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1199 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1201 WRITE_OID_FIELD(typeId);
1202 WRITE_INT_FIELD(typeMod);
1203 WRITE_LOCATION_FIELD(location);
1207 _outSetToDefault(StringInfo str, SetToDefault *node)
1209 WRITE_NODE_TYPE("SETTODEFAULT");
1211 WRITE_OID_FIELD(typeId);
1212 WRITE_INT_FIELD(typeMod);
1213 WRITE_LOCATION_FIELD(location);
1217 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1219 WRITE_NODE_TYPE("CURRENTOFEXPR");
1221 WRITE_UINT_FIELD(cvarno);
1222 WRITE_STRING_FIELD(cursor_name);
1223 WRITE_INT_FIELD(cursor_param);
1227 _outTargetEntry(StringInfo str, TargetEntry *node)
1229 WRITE_NODE_TYPE("TARGETENTRY");
1231 WRITE_NODE_FIELD(expr);
1232 WRITE_INT_FIELD(resno);
1233 WRITE_STRING_FIELD(resname);
1234 WRITE_UINT_FIELD(ressortgroupref);
1235 WRITE_OID_FIELD(resorigtbl);
1236 WRITE_INT_FIELD(resorigcol);
1237 WRITE_BOOL_FIELD(resjunk);
1241 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1243 WRITE_NODE_TYPE("RANGETBLREF");
1245 WRITE_INT_FIELD(rtindex);
1249 _outJoinExpr(StringInfo str, JoinExpr *node)
1251 WRITE_NODE_TYPE("JOINEXPR");
1253 WRITE_ENUM_FIELD(jointype, JoinType);
1254 WRITE_BOOL_FIELD(isNatural);
1255 WRITE_NODE_FIELD(larg);
1256 WRITE_NODE_FIELD(rarg);
1257 WRITE_NODE_FIELD(using);
1258 WRITE_NODE_FIELD(quals);
1259 WRITE_NODE_FIELD(alias);
1260 WRITE_INT_FIELD(rtindex);
1264 _outFromExpr(StringInfo str, FromExpr *node)
1266 WRITE_NODE_TYPE("FROMEXPR");
1268 WRITE_NODE_FIELD(fromlist);
1269 WRITE_NODE_FIELD(quals);
1272 /*****************************************************************************
1274 * Stuff from relation.h.
1276 *****************************************************************************/
1279 * print the basic stuff of all nodes that inherit from Path
1281 * Note we do NOT print the parent, else we'd be in infinite recursion
1284 _outPathInfo(StringInfo str, Path *node)
1286 WRITE_ENUM_FIELD(pathtype, NodeTag);
1287 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1288 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1289 WRITE_NODE_FIELD(pathkeys);
1293 * print the basic stuff of all nodes that inherit from JoinPath
1296 _outJoinPathInfo(StringInfo str, JoinPath *node)
1298 _outPathInfo(str, (Path *) node);
1300 WRITE_ENUM_FIELD(jointype, JoinType);
1301 WRITE_NODE_FIELD(outerjoinpath);
1302 WRITE_NODE_FIELD(innerjoinpath);
1303 WRITE_NODE_FIELD(joinrestrictinfo);
1307 _outPath(StringInfo str, Path *node)
1309 WRITE_NODE_TYPE("PATH");
1311 _outPathInfo(str, (Path *) node);
1315 _outIndexPath(StringInfo str, IndexPath *node)
1317 WRITE_NODE_TYPE("INDEXPATH");
1319 _outPathInfo(str, (Path *) node);
1321 WRITE_NODE_FIELD(indexinfo);
1322 WRITE_NODE_FIELD(indexclauses);
1323 WRITE_NODE_FIELD(indexquals);
1324 WRITE_BOOL_FIELD(isjoininner);
1325 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1326 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1327 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1328 WRITE_FLOAT_FIELD(rows, "%.0f");
1332 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1334 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1336 _outPathInfo(str, (Path *) node);
1338 WRITE_NODE_FIELD(bitmapqual);
1339 WRITE_BOOL_FIELD(isjoininner);
1340 WRITE_FLOAT_FIELD(rows, "%.0f");
1344 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1346 WRITE_NODE_TYPE("BITMAPANDPATH");
1348 _outPathInfo(str, (Path *) node);
1350 WRITE_NODE_FIELD(bitmapquals);
1351 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1355 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1357 WRITE_NODE_TYPE("BITMAPORPATH");
1359 _outPathInfo(str, (Path *) node);
1361 WRITE_NODE_FIELD(bitmapquals);
1362 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1366 _outTidPath(StringInfo str, TidPath *node)
1368 WRITE_NODE_TYPE("TIDPATH");
1370 _outPathInfo(str, (Path *) node);
1372 WRITE_NODE_FIELD(tidquals);
1376 _outAppendPath(StringInfo str, AppendPath *node)
1378 WRITE_NODE_TYPE("APPENDPATH");
1380 _outPathInfo(str, (Path *) node);
1382 WRITE_NODE_FIELD(subpaths);
1386 _outResultPath(StringInfo str, ResultPath *node)
1388 WRITE_NODE_TYPE("RESULTPATH");
1390 _outPathInfo(str, (Path *) node);
1392 WRITE_NODE_FIELD(quals);
1396 _outMaterialPath(StringInfo str, MaterialPath *node)
1398 WRITE_NODE_TYPE("MATERIALPATH");
1400 _outPathInfo(str, (Path *) node);
1402 WRITE_NODE_FIELD(subpath);
1406 _outUniquePath(StringInfo str, UniquePath *node)
1408 WRITE_NODE_TYPE("UNIQUEPATH");
1410 _outPathInfo(str, (Path *) node);
1412 WRITE_NODE_FIELD(subpath);
1413 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1414 WRITE_NODE_FIELD(in_operators);
1415 WRITE_NODE_FIELD(uniq_exprs);
1416 WRITE_FLOAT_FIELD(rows, "%.0f");
1420 _outNestPath(StringInfo str, NestPath *node)
1422 WRITE_NODE_TYPE("NESTPATH");
1424 _outJoinPathInfo(str, (JoinPath *) node);
1428 _outMergePath(StringInfo str, MergePath *node)
1430 WRITE_NODE_TYPE("MERGEPATH");
1432 _outJoinPathInfo(str, (JoinPath *) node);
1434 WRITE_NODE_FIELD(path_mergeclauses);
1435 WRITE_NODE_FIELD(outersortkeys);
1436 WRITE_NODE_FIELD(innersortkeys);
1440 _outHashPath(StringInfo str, HashPath *node)
1442 WRITE_NODE_TYPE("HASHPATH");
1444 _outJoinPathInfo(str, (JoinPath *) node);
1446 WRITE_NODE_FIELD(path_hashclauses);
1450 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1452 WRITE_NODE_TYPE("PLANNERGLOBAL");
1454 /* NB: this isn't a complete set of fields */
1455 WRITE_NODE_FIELD(paramlist);
1456 WRITE_NODE_FIELD(subplans);
1457 WRITE_NODE_FIELD(subrtables);
1458 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1459 WRITE_NODE_FIELD(finalrtable);
1460 WRITE_NODE_FIELD(relationOids);
1461 WRITE_NODE_FIELD(invalItems);
1462 WRITE_UINT_FIELD(lastPHId);
1463 WRITE_BOOL_FIELD(transientPlan);
1467 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1469 WRITE_NODE_TYPE("PLANNERINFO");
1471 /* NB: this isn't a complete set of fields */
1472 WRITE_NODE_FIELD(parse);
1473 WRITE_NODE_FIELD(glob);
1474 WRITE_UINT_FIELD(query_level);
1475 WRITE_NODE_FIELD(join_rel_list);
1476 WRITE_NODE_FIELD(resultRelations);
1477 WRITE_NODE_FIELD(returningLists);
1478 WRITE_NODE_FIELD(init_plans);
1479 WRITE_NODE_FIELD(cte_plan_ids);
1480 WRITE_NODE_FIELD(eq_classes);
1481 WRITE_NODE_FIELD(canon_pathkeys);
1482 WRITE_NODE_FIELD(left_join_clauses);
1483 WRITE_NODE_FIELD(right_join_clauses);
1484 WRITE_NODE_FIELD(full_join_clauses);
1485 WRITE_NODE_FIELD(join_info_list);
1486 WRITE_NODE_FIELD(append_rel_list);
1487 WRITE_NODE_FIELD(placeholder_list);
1488 WRITE_NODE_FIELD(query_pathkeys);
1489 WRITE_NODE_FIELD(group_pathkeys);
1490 WRITE_NODE_FIELD(window_pathkeys);
1491 WRITE_NODE_FIELD(distinct_pathkeys);
1492 WRITE_NODE_FIELD(sort_pathkeys);
1493 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1494 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1495 WRITE_BOOL_FIELD(hasJoinRTEs);
1496 WRITE_BOOL_FIELD(hasHavingQual);
1497 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1498 WRITE_BOOL_FIELD(hasRecursion);
1499 WRITE_INT_FIELD(wt_param_id);
1503 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1505 WRITE_NODE_TYPE("RELOPTINFO");
1507 /* NB: this isn't a complete set of fields */
1508 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1509 WRITE_BITMAPSET_FIELD(relids);
1510 WRITE_FLOAT_FIELD(rows, "%.0f");
1511 WRITE_INT_FIELD(width);
1512 WRITE_NODE_FIELD(reltargetlist);
1513 WRITE_NODE_FIELD(pathlist);
1514 WRITE_NODE_FIELD(cheapest_startup_path);
1515 WRITE_NODE_FIELD(cheapest_total_path);
1516 WRITE_NODE_FIELD(cheapest_unique_path);
1517 WRITE_UINT_FIELD(relid);
1518 WRITE_ENUM_FIELD(rtekind, RTEKind);
1519 WRITE_INT_FIELD(min_attr);
1520 WRITE_INT_FIELD(max_attr);
1521 WRITE_NODE_FIELD(indexlist);
1522 WRITE_UINT_FIELD(pages);
1523 WRITE_FLOAT_FIELD(tuples, "%.0f");
1524 WRITE_NODE_FIELD(subplan);
1525 WRITE_NODE_FIELD(subrtable);
1526 WRITE_NODE_FIELD(baserestrictinfo);
1527 WRITE_NODE_FIELD(joininfo);
1528 WRITE_BOOL_FIELD(has_eclass_joins);
1529 WRITE_BITMAPSET_FIELD(index_outer_relids);
1530 WRITE_NODE_FIELD(index_inner_paths);
1534 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1536 WRITE_NODE_TYPE("INDEXOPTINFO");
1538 /* NB: this isn't a complete set of fields */
1539 WRITE_OID_FIELD(indexoid);
1540 /* Do NOT print rel field, else infinite recursion */
1541 WRITE_UINT_FIELD(pages);
1542 WRITE_FLOAT_FIELD(tuples, "%.0f");
1543 WRITE_INT_FIELD(ncolumns);
1544 WRITE_NODE_FIELD(indexprs);
1545 WRITE_NODE_FIELD(indpred);
1546 WRITE_BOOL_FIELD(predOK);
1547 WRITE_BOOL_FIELD(unique);
1551 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1554 * To simplify reading, we just chase up to the topmost merged EC and
1555 * print that, without bothering to show the merge-ees separately.
1557 while (node->ec_merged)
1558 node = node->ec_merged;
1560 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1562 WRITE_NODE_FIELD(ec_opfamilies);
1563 WRITE_NODE_FIELD(ec_members);
1564 WRITE_NODE_FIELD(ec_sources);
1565 WRITE_NODE_FIELD(ec_derives);
1566 WRITE_BITMAPSET_FIELD(ec_relids);
1567 WRITE_BOOL_FIELD(ec_has_const);
1568 WRITE_BOOL_FIELD(ec_has_volatile);
1569 WRITE_BOOL_FIELD(ec_below_outer_join);
1570 WRITE_BOOL_FIELD(ec_broken);
1571 WRITE_UINT_FIELD(ec_sortref);
1575 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1577 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1579 WRITE_NODE_FIELD(em_expr);
1580 WRITE_BITMAPSET_FIELD(em_relids);
1581 WRITE_BOOL_FIELD(em_is_const);
1582 WRITE_BOOL_FIELD(em_is_child);
1583 WRITE_OID_FIELD(em_datatype);
1587 _outPathKey(StringInfo str, PathKey *node)
1589 WRITE_NODE_TYPE("PATHKEY");
1591 WRITE_NODE_FIELD(pk_eclass);
1592 WRITE_OID_FIELD(pk_opfamily);
1593 WRITE_INT_FIELD(pk_strategy);
1594 WRITE_BOOL_FIELD(pk_nulls_first);
1598 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1600 WRITE_NODE_TYPE("RESTRICTINFO");
1602 /* NB: this isn't a complete set of fields */
1603 WRITE_NODE_FIELD(clause);
1604 WRITE_BOOL_FIELD(is_pushed_down);
1605 WRITE_BOOL_FIELD(outerjoin_delayed);
1606 WRITE_BOOL_FIELD(can_join);
1607 WRITE_BOOL_FIELD(pseudoconstant);
1608 WRITE_BITMAPSET_FIELD(clause_relids);
1609 WRITE_BITMAPSET_FIELD(required_relids);
1610 WRITE_BITMAPSET_FIELD(left_relids);
1611 WRITE_BITMAPSET_FIELD(right_relids);
1612 WRITE_NODE_FIELD(orclause);
1613 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1614 WRITE_FLOAT_FIELD(this_selec, "%.4f");
1615 WRITE_NODE_FIELD(mergeopfamilies);
1616 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1617 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1618 WRITE_NODE_FIELD(left_em);
1619 WRITE_NODE_FIELD(right_em);
1620 WRITE_BOOL_FIELD(outer_is_left);
1621 WRITE_OID_FIELD(hashjoinoperator);
1625 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1627 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1628 WRITE_BITMAPSET_FIELD(other_relids);
1629 WRITE_BOOL_FIELD(isouterjoin);
1630 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1631 WRITE_NODE_FIELD(cheapest_total_innerpath);
1635 _outFlattenedSubLink(StringInfo str, FlattenedSubLink *node)
1637 WRITE_NODE_TYPE("FLATTENEDSUBLINK");
1639 WRITE_ENUM_FIELD(jointype, JoinType);
1640 WRITE_BITMAPSET_FIELD(lefthand);
1641 WRITE_BITMAPSET_FIELD(righthand);
1642 WRITE_NODE_FIELD(quals);
1646 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1648 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1650 WRITE_NODE_FIELD(phexpr);
1651 WRITE_BITMAPSET_FIELD(phrels);
1652 WRITE_UINT_FIELD(phid);
1653 WRITE_UINT_FIELD(phlevelsup);
1657 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1659 WRITE_NODE_TYPE("SPECIALJOININFO");
1661 WRITE_BITMAPSET_FIELD(min_lefthand);
1662 WRITE_BITMAPSET_FIELD(min_righthand);
1663 WRITE_BITMAPSET_FIELD(syn_lefthand);
1664 WRITE_BITMAPSET_FIELD(syn_righthand);
1665 WRITE_ENUM_FIELD(jointype, JoinType);
1666 WRITE_BOOL_FIELD(lhs_strict);
1667 WRITE_BOOL_FIELD(delay_upper_joins);
1668 WRITE_NODE_FIELD(join_quals);
1672 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1674 WRITE_NODE_TYPE("APPENDRELINFO");
1676 WRITE_UINT_FIELD(parent_relid);
1677 WRITE_UINT_FIELD(child_relid);
1678 WRITE_OID_FIELD(parent_reltype);
1679 WRITE_OID_FIELD(child_reltype);
1680 WRITE_NODE_FIELD(translated_vars);
1681 WRITE_OID_FIELD(parent_reloid);
1685 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1687 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1689 WRITE_UINT_FIELD(phid);
1690 WRITE_NODE_FIELD(ph_var);
1691 WRITE_BITMAPSET_FIELD(ph_eval_at);
1692 WRITE_BITMAPSET_FIELD(ph_needed);
1693 WRITE_INT_FIELD(ph_width);
1697 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1699 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1701 WRITE_NODE_FIELD(item);
1702 WRITE_UINT_FIELD(abslevel);
1705 /*****************************************************************************
1707 * Stuff from parsenodes.h.
1709 *****************************************************************************/
1712 _outCreateStmt(StringInfo str, CreateStmt *node)
1714 WRITE_NODE_TYPE("CREATESTMT");
1716 WRITE_NODE_FIELD(relation);
1717 WRITE_NODE_FIELD(tableElts);
1718 WRITE_NODE_FIELD(inhRelations);
1719 WRITE_NODE_FIELD(constraints);
1720 WRITE_NODE_FIELD(options);
1721 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1722 WRITE_STRING_FIELD(tablespacename);
1726 _outIndexStmt(StringInfo str, IndexStmt *node)
1728 WRITE_NODE_TYPE("INDEXSTMT");
1730 WRITE_STRING_FIELD(idxname);
1731 WRITE_NODE_FIELD(relation);
1732 WRITE_STRING_FIELD(accessMethod);
1733 WRITE_STRING_FIELD(tableSpace);
1734 WRITE_NODE_FIELD(indexParams);
1735 WRITE_NODE_FIELD(options);
1736 WRITE_NODE_FIELD(whereClause);
1737 WRITE_BOOL_FIELD(unique);
1738 WRITE_BOOL_FIELD(primary);
1739 WRITE_BOOL_FIELD(isconstraint);
1740 WRITE_BOOL_FIELD(concurrent);
1744 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1746 WRITE_NODE_TYPE("NOTIFY");
1748 WRITE_STRING_FIELD(conditionname);
1752 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1754 WRITE_NODE_TYPE("DECLARECURSOR");
1756 WRITE_STRING_FIELD(portalname);
1757 WRITE_INT_FIELD(options);
1758 WRITE_NODE_FIELD(query);
1762 _outSelectStmt(StringInfo str, SelectStmt *node)
1764 WRITE_NODE_TYPE("SELECT");
1766 WRITE_NODE_FIELD(distinctClause);
1767 WRITE_NODE_FIELD(intoClause);
1768 WRITE_NODE_FIELD(targetList);
1769 WRITE_NODE_FIELD(fromClause);
1770 WRITE_NODE_FIELD(whereClause);
1771 WRITE_NODE_FIELD(groupClause);
1772 WRITE_NODE_FIELD(havingClause);
1773 WRITE_NODE_FIELD(windowClause);
1774 WRITE_NODE_FIELD(withClause);
1775 WRITE_NODE_FIELD(valuesLists);
1776 WRITE_NODE_FIELD(sortClause);
1777 WRITE_NODE_FIELD(limitOffset);
1778 WRITE_NODE_FIELD(limitCount);
1779 WRITE_NODE_FIELD(lockingClause);
1780 WRITE_ENUM_FIELD(op, SetOperation);
1781 WRITE_BOOL_FIELD(all);
1782 WRITE_NODE_FIELD(larg);
1783 WRITE_NODE_FIELD(rarg);
1787 _outFuncCall(StringInfo str, FuncCall *node)
1789 WRITE_NODE_TYPE("FUNCCALL");
1791 WRITE_NODE_FIELD(funcname);
1792 WRITE_NODE_FIELD(args);
1793 WRITE_BOOL_FIELD(agg_star);
1794 WRITE_BOOL_FIELD(agg_distinct);
1795 WRITE_BOOL_FIELD(func_variadic);
1796 WRITE_NODE_FIELD(over);
1797 WRITE_LOCATION_FIELD(location);
1801 _outDefElem(StringInfo str, DefElem *node)
1803 WRITE_NODE_TYPE("DEFELEM");
1805 WRITE_STRING_FIELD(defname);
1806 WRITE_NODE_FIELD(arg);
1810 _outLockingClause(StringInfo str, LockingClause *node)
1812 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1814 WRITE_NODE_FIELD(lockedRels);
1815 WRITE_BOOL_FIELD(forUpdate);
1816 WRITE_BOOL_FIELD(noWait);
1820 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1822 WRITE_NODE_TYPE("XMLSERIALIZE");
1824 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1825 WRITE_NODE_FIELD(expr);
1826 WRITE_NODE_FIELD(typename);
1827 WRITE_LOCATION_FIELD(location);
1831 _outColumnDef(StringInfo str, ColumnDef *node)
1833 WRITE_NODE_TYPE("COLUMNDEF");
1835 WRITE_STRING_FIELD(colname);
1836 WRITE_NODE_FIELD(typename);
1837 WRITE_INT_FIELD(inhcount);
1838 WRITE_BOOL_FIELD(is_local);
1839 WRITE_BOOL_FIELD(is_not_null);
1840 WRITE_NODE_FIELD(raw_default);
1841 WRITE_STRING_FIELD(cooked_default);
1842 WRITE_NODE_FIELD(constraints);
1846 _outTypeName(StringInfo str, TypeName *node)
1848 WRITE_NODE_TYPE("TYPENAME");
1850 WRITE_NODE_FIELD(names);
1851 WRITE_OID_FIELD(typeid);
1852 WRITE_BOOL_FIELD(setof);
1853 WRITE_BOOL_FIELD(pct_type);
1854 WRITE_NODE_FIELD(typmods);
1855 WRITE_INT_FIELD(typemod);
1856 WRITE_NODE_FIELD(arrayBounds);
1857 WRITE_LOCATION_FIELD(location);
1861 _outTypeCast(StringInfo str, TypeCast *node)
1863 WRITE_NODE_TYPE("TYPECAST");
1865 WRITE_NODE_FIELD(arg);
1866 WRITE_NODE_FIELD(typename);
1867 WRITE_LOCATION_FIELD(location);
1871 _outIndexElem(StringInfo str, IndexElem *node)
1873 WRITE_NODE_TYPE("INDEXELEM");
1875 WRITE_STRING_FIELD(name);
1876 WRITE_NODE_FIELD(expr);
1877 WRITE_NODE_FIELD(opclass);
1878 WRITE_ENUM_FIELD(ordering, SortByDir);
1879 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1883 _outQuery(StringInfo str, Query *node)
1885 WRITE_NODE_TYPE("QUERY");
1887 WRITE_ENUM_FIELD(commandType, CmdType);
1888 WRITE_ENUM_FIELD(querySource, QuerySource);
1889 WRITE_BOOL_FIELD(canSetTag);
1892 * Hack to work around missing outfuncs routines for a lot of the
1893 * utility-statement node types. (The only one we actually *need* for
1894 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1895 * for the meantime do this to avoid getting lots of warnings when running
1896 * with debug_print_parse on.
1898 if (node->utilityStmt)
1900 switch (nodeTag(node->utilityStmt))
1905 case T_DeclareCursorStmt:
1906 WRITE_NODE_FIELD(utilityStmt);
1909 appendStringInfo(str, " :utilityStmt ?");
1914 appendStringInfo(str, " :utilityStmt <>");
1916 WRITE_INT_FIELD(resultRelation);
1917 WRITE_NODE_FIELD(intoClause);
1918 WRITE_BOOL_FIELD(hasAggs);
1919 WRITE_BOOL_FIELD(hasWindowFuncs);
1920 WRITE_BOOL_FIELD(hasSubLinks);
1921 WRITE_BOOL_FIELD(hasDistinctOn);
1922 WRITE_BOOL_FIELD(hasRecursive);
1923 WRITE_NODE_FIELD(cteList);
1924 WRITE_NODE_FIELD(rtable);
1925 WRITE_NODE_FIELD(jointree);
1926 WRITE_NODE_FIELD(targetList);
1927 WRITE_NODE_FIELD(returningList);
1928 WRITE_NODE_FIELD(groupClause);
1929 WRITE_NODE_FIELD(havingQual);
1930 WRITE_NODE_FIELD(windowClause);
1931 WRITE_NODE_FIELD(distinctClause);
1932 WRITE_NODE_FIELD(sortClause);
1933 WRITE_NODE_FIELD(limitOffset);
1934 WRITE_NODE_FIELD(limitCount);
1935 WRITE_NODE_FIELD(rowMarks);
1936 WRITE_NODE_FIELD(setOperations);
1940 _outSortGroupClause(StringInfo str, SortGroupClause *node)
1942 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
1944 WRITE_UINT_FIELD(tleSortGroupRef);
1945 WRITE_OID_FIELD(eqop);
1946 WRITE_OID_FIELD(sortop);
1947 WRITE_BOOL_FIELD(nulls_first);
1951 _outWindowClause(StringInfo str, WindowClause *node)
1953 WRITE_NODE_TYPE("WINDOWCLAUSE");
1955 WRITE_STRING_FIELD(name);
1956 WRITE_STRING_FIELD(refname);
1957 WRITE_NODE_FIELD(partitionClause);
1958 WRITE_NODE_FIELD(orderClause);
1959 WRITE_INT_FIELD(frameOptions);
1960 WRITE_UINT_FIELD(winref);
1961 WRITE_BOOL_FIELD(copiedOrder);
1965 _outRowMarkClause(StringInfo str, RowMarkClause *node)
1967 WRITE_NODE_TYPE("ROWMARKCLAUSE");
1969 WRITE_UINT_FIELD(rti);
1970 WRITE_UINT_FIELD(prti);
1971 WRITE_BOOL_FIELD(forUpdate);
1972 WRITE_BOOL_FIELD(noWait);
1973 WRITE_BOOL_FIELD(isParent);
1977 _outWithClause(StringInfo str, WithClause *node)
1979 WRITE_NODE_TYPE("WITHCLAUSE");
1981 WRITE_NODE_FIELD(ctes);
1982 WRITE_BOOL_FIELD(recursive);
1983 WRITE_LOCATION_FIELD(location);
1987 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
1989 WRITE_NODE_TYPE("COMMONTABLEEXPR");
1991 WRITE_STRING_FIELD(ctename);
1992 WRITE_NODE_FIELD(aliascolnames);
1993 WRITE_NODE_FIELD(ctequery);
1994 WRITE_LOCATION_FIELD(location);
1995 WRITE_BOOL_FIELD(cterecursive);
1996 WRITE_INT_FIELD(cterefcount);
1997 WRITE_NODE_FIELD(ctecolnames);
1998 WRITE_NODE_FIELD(ctecoltypes);
1999 WRITE_NODE_FIELD(ctecoltypmods);
2003 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2005 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2007 WRITE_ENUM_FIELD(op, SetOperation);
2008 WRITE_BOOL_FIELD(all);
2009 WRITE_NODE_FIELD(larg);
2010 WRITE_NODE_FIELD(rarg);
2011 WRITE_NODE_FIELD(colTypes);
2012 WRITE_NODE_FIELD(colTypmods);
2013 WRITE_NODE_FIELD(groupClauses);
2017 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2019 WRITE_NODE_TYPE("RTE");
2021 /* put alias + eref first to make dump more legible */
2022 WRITE_NODE_FIELD(alias);
2023 WRITE_NODE_FIELD(eref);
2024 WRITE_ENUM_FIELD(rtekind, RTEKind);
2026 switch (node->rtekind)
2030 WRITE_OID_FIELD(relid);
2033 WRITE_NODE_FIELD(subquery);
2036 WRITE_ENUM_FIELD(jointype, JoinType);
2037 WRITE_NODE_FIELD(joinaliasvars);
2040 WRITE_NODE_FIELD(funcexpr);
2041 WRITE_NODE_FIELD(funccoltypes);
2042 WRITE_NODE_FIELD(funccoltypmods);
2045 WRITE_NODE_FIELD(values_lists);
2048 WRITE_STRING_FIELD(ctename);
2049 WRITE_UINT_FIELD(ctelevelsup);
2050 WRITE_BOOL_FIELD(self_reference);
2051 WRITE_NODE_FIELD(ctecoltypes);
2052 WRITE_NODE_FIELD(ctecoltypmods);
2055 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2059 WRITE_BOOL_FIELD(inh);
2060 WRITE_BOOL_FIELD(inFromCl);
2061 WRITE_UINT_FIELD(requiredPerms);
2062 WRITE_OID_FIELD(checkAsUser);
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_FlattenedSubLink:
2653 _outFlattenedSubLink(str, obj);
2655 case T_PlaceHolderVar:
2656 _outPlaceHolderVar(str, obj);
2658 case T_SpecialJoinInfo:
2659 _outSpecialJoinInfo(str, obj);
2661 case T_AppendRelInfo:
2662 _outAppendRelInfo(str, obj);
2664 case T_PlaceHolderInfo:
2665 _outPlaceHolderInfo(str, obj);
2667 case T_PlannerParamItem:
2668 _outPlannerParamItem(str, obj);
2672 _outCreateStmt(str, obj);
2675 _outIndexStmt(str, obj);
2678 _outNotifyStmt(str, obj);
2680 case T_DeclareCursorStmt:
2681 _outDeclareCursorStmt(str, obj);
2684 _outSelectStmt(str, obj);
2687 _outColumnDef(str, obj);
2690 _outTypeName(str, obj);
2693 _outTypeCast(str, obj);
2696 _outIndexElem(str, obj);
2699 _outQuery(str, obj);
2701 case T_SortGroupClause:
2702 _outSortGroupClause(str, obj);
2704 case T_WindowClause:
2705 _outWindowClause(str, obj);
2707 case T_RowMarkClause:
2708 _outRowMarkClause(str, obj);
2711 _outWithClause(str, obj);
2713 case T_CommonTableExpr:
2714 _outCommonTableExpr(str, obj);
2716 case T_SetOperationStmt:
2717 _outSetOperationStmt(str, obj);
2719 case T_RangeTblEntry:
2720 _outRangeTblEntry(str, obj);
2723 _outAExpr(str, obj);
2726 _outColumnRef(str, obj);
2729 _outParamRef(str, obj);
2732 _outAConst(str, obj);
2735 _outA_Star(str, obj);
2738 _outA_Indices(str, obj);
2740 case T_A_Indirection:
2741 _outA_Indirection(str, obj);
2744 _outA_ArrayExpr(str, obj);
2747 _outResTarget(str, obj);
2750 _outSortBy(str, obj);
2753 _outWindowDef(str, obj);
2755 case T_RangeSubselect:
2756 _outRangeSubselect(str, obj);
2758 case T_RangeFunction:
2759 _outRangeFunction(str, obj);
2762 _outConstraint(str, obj);
2764 case T_FkConstraint:
2765 _outFkConstraint(str, obj);
2768 _outFuncCall(str, obj);
2771 _outDefElem(str, obj);
2773 case T_LockingClause:
2774 _outLockingClause(str, obj);
2776 case T_XmlSerialize:
2777 _outXmlSerialize(str, obj);
2783 * This should be an ERROR, but it's too useful to be able to
2784 * dump structures that _outNode only understands part of.
2786 elog(WARNING, "could not dump unrecognized node type: %d",
2787 (int) nodeTag(obj));
2790 appendStringInfoChar(str, '}');
2796 * returns the ascii representation of the Node as a palloc'd string
2799 nodeToString(void *obj)
2803 /* see stringinfo.h for an explanation of this maneuver */
2804 initStringInfo(&str);
2805 _outNode(&str, obj);