1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
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 _outGroup(StringInfo str
, Group
*node
)
574 WRITE_NODE_TYPE("GROUP");
576 _outPlanInfo(str
, (Plan
*) node
);
578 WRITE_INT_FIELD(numCols
);
580 appendStringInfo(str
, " :grpColIdx");
581 for (i
= 0; i
< node
->numCols
; i
++)
582 appendStringInfo(str
, " %d", node
->grpColIdx
[i
]);
584 appendStringInfo(str
, " :grpOperators");
585 for (i
= 0; i
< node
->numCols
; i
++)
586 appendStringInfo(str
, " %u", node
->grpOperators
[i
]);
590 _outMaterial(StringInfo str
, Material
*node
)
592 WRITE_NODE_TYPE("MATERIAL");
594 _outPlanInfo(str
, (Plan
*) node
);
598 _outSort(StringInfo str
, Sort
*node
)
602 WRITE_NODE_TYPE("SORT");
604 _outPlanInfo(str
, (Plan
*) node
);
606 WRITE_INT_FIELD(numCols
);
608 appendStringInfo(str
, " :sortColIdx");
609 for (i
= 0; i
< node
->numCols
; i
++)
610 appendStringInfo(str
, " %d", node
->sortColIdx
[i
]);
612 appendStringInfo(str
, " :sortOperators");
613 for (i
= 0; i
< node
->numCols
; i
++)
614 appendStringInfo(str
, " %u", node
->sortOperators
[i
]);
616 appendStringInfo(str
, " :nullsFirst");
617 for (i
= 0; i
< node
->numCols
; i
++)
618 appendStringInfo(str
, " %s", booltostr(node
->nullsFirst
[i
]));
622 _outUnique(StringInfo str
, Unique
*node
)
626 WRITE_NODE_TYPE("UNIQUE");
628 _outPlanInfo(str
, (Plan
*) node
);
630 WRITE_INT_FIELD(numCols
);
632 appendStringInfo(str
, " :uniqColIdx");
633 for (i
= 0; i
< node
->numCols
; i
++)
634 appendStringInfo(str
, " %d", node
->uniqColIdx
[i
]);
636 appendStringInfo(str
, " :uniqOperators");
637 for (i
= 0; i
< node
->numCols
; i
++)
638 appendStringInfo(str
, " %u", node
->uniqOperators
[i
]);
642 _outHash(StringInfo str
, Hash
*node
)
644 WRITE_NODE_TYPE("HASH");
646 _outPlanInfo(str
, (Plan
*) node
);
650 _outSetOp(StringInfo str
, SetOp
*node
)
654 WRITE_NODE_TYPE("SETOP");
656 _outPlanInfo(str
, (Plan
*) node
);
658 WRITE_ENUM_FIELD(cmd
, SetOpCmd
);
659 WRITE_ENUM_FIELD(strategy
, SetOpStrategy
);
660 WRITE_INT_FIELD(numCols
);
662 appendStringInfo(str
, " :dupColIdx");
663 for (i
= 0; i
< node
->numCols
; i
++)
664 appendStringInfo(str
, " %d", node
->dupColIdx
[i
]);
666 appendStringInfo(str
, " :dupOperators");
667 for (i
= 0; i
< node
->numCols
; i
++)
668 appendStringInfo(str
, " %u", node
->dupOperators
[i
]);
670 WRITE_INT_FIELD(flagColIdx
);
671 WRITE_INT_FIELD(firstFlag
);
672 WRITE_LONG_FIELD(numGroups
);
676 _outLimit(StringInfo str
, Limit
*node
)
678 WRITE_NODE_TYPE("LIMIT");
680 _outPlanInfo(str
, (Plan
*) node
);
682 WRITE_NODE_FIELD(limitOffset
);
683 WRITE_NODE_FIELD(limitCount
);
687 _outPlanInvalItem(StringInfo str
, PlanInvalItem
*node
)
689 WRITE_NODE_TYPE("PLANINVALITEM");
691 WRITE_INT_FIELD(cacheId
);
692 appendStringInfo(str
, " :tupleId (%u,%u)",
693 ItemPointerGetBlockNumber(&node
->tupleId
),
694 ItemPointerGetOffsetNumber(&node
->tupleId
));
697 /*****************************************************************************
699 * Stuff from primnodes.h.
701 *****************************************************************************/
704 _outAlias(StringInfo str
, Alias
*node
)
706 WRITE_NODE_TYPE("ALIAS");
708 WRITE_STRING_FIELD(aliasname
);
709 WRITE_NODE_FIELD(colnames
);
713 _outRangeVar(StringInfo str
, RangeVar
*node
)
715 WRITE_NODE_TYPE("RANGEVAR");
718 * we deliberately ignore catalogname here, since it is presently not
719 * semantically meaningful
721 WRITE_STRING_FIELD(schemaname
);
722 WRITE_STRING_FIELD(relname
);
723 WRITE_ENUM_FIELD(inhOpt
, InhOption
);
724 WRITE_BOOL_FIELD(istemp
);
725 WRITE_NODE_FIELD(alias
);
726 WRITE_LOCATION_FIELD(location
);
730 _outIntoClause(StringInfo str
, IntoClause
*node
)
732 WRITE_NODE_TYPE("INTOCLAUSE");
734 WRITE_NODE_FIELD(rel
);
735 WRITE_NODE_FIELD(colNames
);
736 WRITE_NODE_FIELD(options
);
737 WRITE_ENUM_FIELD(onCommit
, OnCommitAction
);
738 WRITE_STRING_FIELD(tableSpaceName
);
742 _outVar(StringInfo str
, Var
*node
)
744 WRITE_NODE_TYPE("VAR");
746 WRITE_UINT_FIELD(varno
);
747 WRITE_INT_FIELD(varattno
);
748 WRITE_OID_FIELD(vartype
);
749 WRITE_INT_FIELD(vartypmod
);
750 WRITE_UINT_FIELD(varlevelsup
);
751 WRITE_UINT_FIELD(varnoold
);
752 WRITE_INT_FIELD(varoattno
);
753 WRITE_LOCATION_FIELD(location
);
757 _outConst(StringInfo str
, Const
*node
)
759 WRITE_NODE_TYPE("CONST");
761 WRITE_OID_FIELD(consttype
);
762 WRITE_INT_FIELD(consttypmod
);
763 WRITE_INT_FIELD(constlen
);
764 WRITE_BOOL_FIELD(constbyval
);
765 WRITE_BOOL_FIELD(constisnull
);
766 WRITE_LOCATION_FIELD(location
);
768 appendStringInfo(str
, " :constvalue ");
769 if (node
->constisnull
)
770 appendStringInfo(str
, "<>");
772 _outDatum(str
, node
->constvalue
, node
->constlen
, node
->constbyval
);
776 _outParam(StringInfo str
, Param
*node
)
778 WRITE_NODE_TYPE("PARAM");
780 WRITE_ENUM_FIELD(paramkind
, ParamKind
);
781 WRITE_INT_FIELD(paramid
);
782 WRITE_OID_FIELD(paramtype
);
783 WRITE_INT_FIELD(paramtypmod
);
784 WRITE_LOCATION_FIELD(location
);
788 _outAggref(StringInfo str
, Aggref
*node
)
790 WRITE_NODE_TYPE("AGGREF");
792 WRITE_OID_FIELD(aggfnoid
);
793 WRITE_OID_FIELD(aggtype
);
794 WRITE_NODE_FIELD(args
);
795 WRITE_UINT_FIELD(agglevelsup
);
796 WRITE_BOOL_FIELD(aggstar
);
797 WRITE_BOOL_FIELD(aggdistinct
);
798 WRITE_LOCATION_FIELD(location
);
802 _outArrayRef(StringInfo str
, ArrayRef
*node
)
804 WRITE_NODE_TYPE("ARRAYREF");
806 WRITE_OID_FIELD(refarraytype
);
807 WRITE_OID_FIELD(refelemtype
);
808 WRITE_INT_FIELD(reftypmod
);
809 WRITE_NODE_FIELD(refupperindexpr
);
810 WRITE_NODE_FIELD(reflowerindexpr
);
811 WRITE_NODE_FIELD(refexpr
);
812 WRITE_NODE_FIELD(refassgnexpr
);
816 _outFuncExpr(StringInfo str
, FuncExpr
*node
)
818 WRITE_NODE_TYPE("FUNCEXPR");
820 WRITE_OID_FIELD(funcid
);
821 WRITE_OID_FIELD(funcresulttype
);
822 WRITE_BOOL_FIELD(funcretset
);
823 WRITE_ENUM_FIELD(funcformat
, CoercionForm
);
824 WRITE_NODE_FIELD(args
);
825 WRITE_LOCATION_FIELD(location
);
829 _outOpExpr(StringInfo str
, OpExpr
*node
)
831 WRITE_NODE_TYPE("OPEXPR");
833 WRITE_OID_FIELD(opno
);
834 WRITE_OID_FIELD(opfuncid
);
835 WRITE_OID_FIELD(opresulttype
);
836 WRITE_BOOL_FIELD(opretset
);
837 WRITE_NODE_FIELD(args
);
838 WRITE_LOCATION_FIELD(location
);
842 _outDistinctExpr(StringInfo str
, DistinctExpr
*node
)
844 WRITE_NODE_TYPE("DISTINCTEXPR");
846 WRITE_OID_FIELD(opno
);
847 WRITE_OID_FIELD(opfuncid
);
848 WRITE_OID_FIELD(opresulttype
);
849 WRITE_BOOL_FIELD(opretset
);
850 WRITE_NODE_FIELD(args
);
851 WRITE_LOCATION_FIELD(location
);
855 _outScalarArrayOpExpr(StringInfo str
, ScalarArrayOpExpr
*node
)
857 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
859 WRITE_OID_FIELD(opno
);
860 WRITE_OID_FIELD(opfuncid
);
861 WRITE_BOOL_FIELD(useOr
);
862 WRITE_NODE_FIELD(args
);
863 WRITE_LOCATION_FIELD(location
);
867 _outBoolExpr(StringInfo str
, BoolExpr
*node
)
871 WRITE_NODE_TYPE("BOOLEXPR");
873 /* do-it-yourself enum representation */
874 switch (node
->boolop
)
886 appendStringInfo(str
, " :boolop ");
887 _outToken(str
, opstr
);
889 WRITE_NODE_FIELD(args
);
890 WRITE_LOCATION_FIELD(location
);
894 _outSubLink(StringInfo str
, SubLink
*node
)
896 WRITE_NODE_TYPE("SUBLINK");
898 WRITE_ENUM_FIELD(subLinkType
, SubLinkType
);
899 WRITE_NODE_FIELD(testexpr
);
900 WRITE_NODE_FIELD(operName
);
901 WRITE_NODE_FIELD(subselect
);
902 WRITE_LOCATION_FIELD(location
);
906 _outSubPlan(StringInfo str
, SubPlan
*node
)
908 WRITE_NODE_TYPE("SUBPLAN");
910 WRITE_ENUM_FIELD(subLinkType
, SubLinkType
);
911 WRITE_NODE_FIELD(testexpr
);
912 WRITE_NODE_FIELD(paramIds
);
913 WRITE_INT_FIELD(plan_id
);
914 WRITE_OID_FIELD(firstColType
);
915 WRITE_BOOL_FIELD(useHashTable
);
916 WRITE_BOOL_FIELD(unknownEqFalse
);
917 WRITE_NODE_FIELD(setParam
);
918 WRITE_NODE_FIELD(parParam
);
919 WRITE_NODE_FIELD(args
);
920 WRITE_FLOAT_FIELD(startup_cost
, "%.2f");
921 WRITE_FLOAT_FIELD(per_call_cost
, "%.2f");
925 _outAlternativeSubPlan(StringInfo str
, AlternativeSubPlan
*node
)
927 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
929 WRITE_NODE_FIELD(subplans
);
933 _outFieldSelect(StringInfo str
, FieldSelect
*node
)
935 WRITE_NODE_TYPE("FIELDSELECT");
937 WRITE_NODE_FIELD(arg
);
938 WRITE_INT_FIELD(fieldnum
);
939 WRITE_OID_FIELD(resulttype
);
940 WRITE_INT_FIELD(resulttypmod
);
944 _outFieldStore(StringInfo str
, FieldStore
*node
)
946 WRITE_NODE_TYPE("FIELDSTORE");
948 WRITE_NODE_FIELD(arg
);
949 WRITE_NODE_FIELD(newvals
);
950 WRITE_NODE_FIELD(fieldnums
);
951 WRITE_OID_FIELD(resulttype
);
955 _outRelabelType(StringInfo str
, RelabelType
*node
)
957 WRITE_NODE_TYPE("RELABELTYPE");
959 WRITE_NODE_FIELD(arg
);
960 WRITE_OID_FIELD(resulttype
);
961 WRITE_INT_FIELD(resulttypmod
);
962 WRITE_ENUM_FIELD(relabelformat
, CoercionForm
);
963 WRITE_LOCATION_FIELD(location
);
967 _outCoerceViaIO(StringInfo str
, CoerceViaIO
*node
)
969 WRITE_NODE_TYPE("COERCEVIAIO");
971 WRITE_NODE_FIELD(arg
);
972 WRITE_OID_FIELD(resulttype
);
973 WRITE_ENUM_FIELD(coerceformat
, CoercionForm
);
974 WRITE_LOCATION_FIELD(location
);
978 _outArrayCoerceExpr(StringInfo str
, ArrayCoerceExpr
*node
)
980 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
982 WRITE_NODE_FIELD(arg
);
983 WRITE_OID_FIELD(elemfuncid
);
984 WRITE_OID_FIELD(resulttype
);
985 WRITE_INT_FIELD(resulttypmod
);
986 WRITE_BOOL_FIELD(isExplicit
);
987 WRITE_ENUM_FIELD(coerceformat
, CoercionForm
);
988 WRITE_LOCATION_FIELD(location
);
992 _outConvertRowtypeExpr(StringInfo str
, ConvertRowtypeExpr
*node
)
994 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
996 WRITE_NODE_FIELD(arg
);
997 WRITE_OID_FIELD(resulttype
);
998 WRITE_ENUM_FIELD(convertformat
, CoercionForm
);
999 WRITE_LOCATION_FIELD(location
);
1003 _outCaseExpr(StringInfo str
, CaseExpr
*node
)
1005 WRITE_NODE_TYPE("CASE");
1007 WRITE_OID_FIELD(casetype
);
1008 WRITE_NODE_FIELD(arg
);
1009 WRITE_NODE_FIELD(args
);
1010 WRITE_NODE_FIELD(defresult
);
1011 WRITE_LOCATION_FIELD(location
);
1015 _outCaseWhen(StringInfo str
, CaseWhen
*node
)
1017 WRITE_NODE_TYPE("WHEN");
1019 WRITE_NODE_FIELD(expr
);
1020 WRITE_NODE_FIELD(result
);
1021 WRITE_LOCATION_FIELD(location
);
1025 _outCaseTestExpr(StringInfo str
, CaseTestExpr
*node
)
1027 WRITE_NODE_TYPE("CASETESTEXPR");
1029 WRITE_OID_FIELD(typeId
);
1030 WRITE_INT_FIELD(typeMod
);
1034 _outArrayExpr(StringInfo str
, ArrayExpr
*node
)
1036 WRITE_NODE_TYPE("ARRAY");
1038 WRITE_OID_FIELD(array_typeid
);
1039 WRITE_OID_FIELD(element_typeid
);
1040 WRITE_NODE_FIELD(elements
);
1041 WRITE_BOOL_FIELD(multidims
);
1042 WRITE_LOCATION_FIELD(location
);
1046 _outRowExpr(StringInfo str
, RowExpr
*node
)
1048 WRITE_NODE_TYPE("ROW");
1050 WRITE_NODE_FIELD(args
);
1051 WRITE_OID_FIELD(row_typeid
);
1052 WRITE_ENUM_FIELD(row_format
, CoercionForm
);
1053 WRITE_NODE_FIELD(colnames
);
1054 WRITE_LOCATION_FIELD(location
);
1058 _outRowCompareExpr(StringInfo str
, RowCompareExpr
*node
)
1060 WRITE_NODE_TYPE("ROWCOMPARE");
1062 WRITE_ENUM_FIELD(rctype
, RowCompareType
);
1063 WRITE_NODE_FIELD(opnos
);
1064 WRITE_NODE_FIELD(opfamilies
);
1065 WRITE_NODE_FIELD(largs
);
1066 WRITE_NODE_FIELD(rargs
);
1070 _outCoalesceExpr(StringInfo str
, CoalesceExpr
*node
)
1072 WRITE_NODE_TYPE("COALESCE");
1074 WRITE_OID_FIELD(coalescetype
);
1075 WRITE_NODE_FIELD(args
);
1076 WRITE_LOCATION_FIELD(location
);
1080 _outMinMaxExpr(StringInfo str
, MinMaxExpr
*node
)
1082 WRITE_NODE_TYPE("MINMAX");
1084 WRITE_OID_FIELD(minmaxtype
);
1085 WRITE_ENUM_FIELD(op
, MinMaxOp
);
1086 WRITE_NODE_FIELD(args
);
1087 WRITE_LOCATION_FIELD(location
);
1091 _outXmlExpr(StringInfo str
, XmlExpr
*node
)
1093 WRITE_NODE_TYPE("XMLEXPR");
1095 WRITE_ENUM_FIELD(op
, XmlExprOp
);
1096 WRITE_STRING_FIELD(name
);
1097 WRITE_NODE_FIELD(named_args
);
1098 WRITE_NODE_FIELD(arg_names
);
1099 WRITE_NODE_FIELD(args
);
1100 WRITE_ENUM_FIELD(xmloption
, XmlOptionType
);
1101 WRITE_OID_FIELD(type
);
1102 WRITE_INT_FIELD(typmod
);
1103 WRITE_LOCATION_FIELD(location
);
1107 _outNullIfExpr(StringInfo str
, NullIfExpr
*node
)
1109 WRITE_NODE_TYPE("NULLIFEXPR");
1111 WRITE_OID_FIELD(opno
);
1112 WRITE_OID_FIELD(opfuncid
);
1113 WRITE_OID_FIELD(opresulttype
);
1114 WRITE_BOOL_FIELD(opretset
);
1115 WRITE_NODE_FIELD(args
);
1116 WRITE_LOCATION_FIELD(location
);
1120 _outNullTest(StringInfo str
, NullTest
*node
)
1122 WRITE_NODE_TYPE("NULLTEST");
1124 WRITE_NODE_FIELD(arg
);
1125 WRITE_ENUM_FIELD(nulltesttype
, NullTestType
);
1129 _outBooleanTest(StringInfo str
, BooleanTest
*node
)
1131 WRITE_NODE_TYPE("BOOLEANTEST");
1133 WRITE_NODE_FIELD(arg
);
1134 WRITE_ENUM_FIELD(booltesttype
, BoolTestType
);
1138 _outCoerceToDomain(StringInfo str
, CoerceToDomain
*node
)
1140 WRITE_NODE_TYPE("COERCETODOMAIN");
1142 WRITE_NODE_FIELD(arg
);
1143 WRITE_OID_FIELD(resulttype
);
1144 WRITE_INT_FIELD(resulttypmod
);
1145 WRITE_ENUM_FIELD(coercionformat
, CoercionForm
);
1146 WRITE_LOCATION_FIELD(location
);
1150 _outCoerceToDomainValue(StringInfo str
, CoerceToDomainValue
*node
)
1152 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1154 WRITE_OID_FIELD(typeId
);
1155 WRITE_INT_FIELD(typeMod
);
1156 WRITE_LOCATION_FIELD(location
);
1160 _outSetToDefault(StringInfo str
, SetToDefault
*node
)
1162 WRITE_NODE_TYPE("SETTODEFAULT");
1164 WRITE_OID_FIELD(typeId
);
1165 WRITE_INT_FIELD(typeMod
);
1166 WRITE_LOCATION_FIELD(location
);
1170 _outCurrentOfExpr(StringInfo str
, CurrentOfExpr
*node
)
1172 WRITE_NODE_TYPE("CURRENTOFEXPR");
1174 WRITE_UINT_FIELD(cvarno
);
1175 WRITE_STRING_FIELD(cursor_name
);
1176 WRITE_INT_FIELD(cursor_param
);
1180 _outTargetEntry(StringInfo str
, TargetEntry
*node
)
1182 WRITE_NODE_TYPE("TARGETENTRY");
1184 WRITE_NODE_FIELD(expr
);
1185 WRITE_INT_FIELD(resno
);
1186 WRITE_STRING_FIELD(resname
);
1187 WRITE_UINT_FIELD(ressortgroupref
);
1188 WRITE_OID_FIELD(resorigtbl
);
1189 WRITE_INT_FIELD(resorigcol
);
1190 WRITE_BOOL_FIELD(resjunk
);
1194 _outRangeTblRef(StringInfo str
, RangeTblRef
*node
)
1196 WRITE_NODE_TYPE("RANGETBLREF");
1198 WRITE_INT_FIELD(rtindex
);
1202 _outJoinExpr(StringInfo str
, JoinExpr
*node
)
1204 WRITE_NODE_TYPE("JOINEXPR");
1206 WRITE_ENUM_FIELD(jointype
, JoinType
);
1207 WRITE_BOOL_FIELD(isNatural
);
1208 WRITE_NODE_FIELD(larg
);
1209 WRITE_NODE_FIELD(rarg
);
1210 WRITE_NODE_FIELD(using);
1211 WRITE_NODE_FIELD(quals
);
1212 WRITE_NODE_FIELD(alias
);
1213 WRITE_INT_FIELD(rtindex
);
1217 _outFromExpr(StringInfo str
, FromExpr
*node
)
1219 WRITE_NODE_TYPE("FROMEXPR");
1221 WRITE_NODE_FIELD(fromlist
);
1222 WRITE_NODE_FIELD(quals
);
1225 /*****************************************************************************
1227 * Stuff from relation.h.
1229 *****************************************************************************/
1232 * print the basic stuff of all nodes that inherit from Path
1234 * Note we do NOT print the parent, else we'd be in infinite recursion
1237 _outPathInfo(StringInfo str
, Path
*node
)
1239 WRITE_ENUM_FIELD(pathtype
, NodeTag
);
1240 WRITE_FLOAT_FIELD(startup_cost
, "%.2f");
1241 WRITE_FLOAT_FIELD(total_cost
, "%.2f");
1242 WRITE_NODE_FIELD(pathkeys
);
1246 * print the basic stuff of all nodes that inherit from JoinPath
1249 _outJoinPathInfo(StringInfo str
, JoinPath
*node
)
1251 _outPathInfo(str
, (Path
*) node
);
1253 WRITE_ENUM_FIELD(jointype
, JoinType
);
1254 WRITE_NODE_FIELD(outerjoinpath
);
1255 WRITE_NODE_FIELD(innerjoinpath
);
1256 WRITE_NODE_FIELD(joinrestrictinfo
);
1260 _outPath(StringInfo str
, Path
*node
)
1262 WRITE_NODE_TYPE("PATH");
1264 _outPathInfo(str
, (Path
*) node
);
1268 _outIndexPath(StringInfo str
, IndexPath
*node
)
1270 WRITE_NODE_TYPE("INDEXPATH");
1272 _outPathInfo(str
, (Path
*) node
);
1274 WRITE_NODE_FIELD(indexinfo
);
1275 WRITE_NODE_FIELD(indexclauses
);
1276 WRITE_NODE_FIELD(indexquals
);
1277 WRITE_BOOL_FIELD(isjoininner
);
1278 WRITE_ENUM_FIELD(indexscandir
, ScanDirection
);
1279 WRITE_FLOAT_FIELD(indextotalcost
, "%.2f");
1280 WRITE_FLOAT_FIELD(indexselectivity
, "%.4f");
1281 WRITE_FLOAT_FIELD(rows
, "%.0f");
1285 _outBitmapHeapPath(StringInfo str
, BitmapHeapPath
*node
)
1287 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1289 _outPathInfo(str
, (Path
*) node
);
1291 WRITE_NODE_FIELD(bitmapqual
);
1292 WRITE_BOOL_FIELD(isjoininner
);
1293 WRITE_FLOAT_FIELD(rows
, "%.0f");
1297 _outBitmapAndPath(StringInfo str
, BitmapAndPath
*node
)
1299 WRITE_NODE_TYPE("BITMAPANDPATH");
1301 _outPathInfo(str
, (Path
*) node
);
1303 WRITE_NODE_FIELD(bitmapquals
);
1304 WRITE_FLOAT_FIELD(bitmapselectivity
, "%.4f");
1308 _outBitmapOrPath(StringInfo str
, BitmapOrPath
*node
)
1310 WRITE_NODE_TYPE("BITMAPORPATH");
1312 _outPathInfo(str
, (Path
*) node
);
1314 WRITE_NODE_FIELD(bitmapquals
);
1315 WRITE_FLOAT_FIELD(bitmapselectivity
, "%.4f");
1319 _outTidPath(StringInfo str
, TidPath
*node
)
1321 WRITE_NODE_TYPE("TIDPATH");
1323 _outPathInfo(str
, (Path
*) node
);
1325 WRITE_NODE_FIELD(tidquals
);
1329 _outAppendPath(StringInfo str
, AppendPath
*node
)
1331 WRITE_NODE_TYPE("APPENDPATH");
1333 _outPathInfo(str
, (Path
*) node
);
1335 WRITE_NODE_FIELD(subpaths
);
1339 _outResultPath(StringInfo str
, ResultPath
*node
)
1341 WRITE_NODE_TYPE("RESULTPATH");
1343 _outPathInfo(str
, (Path
*) node
);
1345 WRITE_NODE_FIELD(quals
);
1349 _outMaterialPath(StringInfo str
, MaterialPath
*node
)
1351 WRITE_NODE_TYPE("MATERIALPATH");
1353 _outPathInfo(str
, (Path
*) node
);
1355 WRITE_NODE_FIELD(subpath
);
1359 _outUniquePath(StringInfo str
, UniquePath
*node
)
1361 WRITE_NODE_TYPE("UNIQUEPATH");
1363 _outPathInfo(str
, (Path
*) node
);
1365 WRITE_NODE_FIELD(subpath
);
1366 WRITE_ENUM_FIELD(umethod
, UniquePathMethod
);
1367 WRITE_NODE_FIELD(in_operators
);
1368 WRITE_NODE_FIELD(uniq_exprs
);
1369 WRITE_FLOAT_FIELD(rows
, "%.0f");
1373 _outNestPath(StringInfo str
, NestPath
*node
)
1375 WRITE_NODE_TYPE("NESTPATH");
1377 _outJoinPathInfo(str
, (JoinPath
*) node
);
1381 _outMergePath(StringInfo str
, MergePath
*node
)
1383 WRITE_NODE_TYPE("MERGEPATH");
1385 _outJoinPathInfo(str
, (JoinPath
*) node
);
1387 WRITE_NODE_FIELD(path_mergeclauses
);
1388 WRITE_NODE_FIELD(outersortkeys
);
1389 WRITE_NODE_FIELD(innersortkeys
);
1393 _outHashPath(StringInfo str
, HashPath
*node
)
1395 WRITE_NODE_TYPE("HASHPATH");
1397 _outJoinPathInfo(str
, (JoinPath
*) node
);
1399 WRITE_NODE_FIELD(path_hashclauses
);
1403 _outPlannerGlobal(StringInfo str
, PlannerGlobal
*node
)
1405 WRITE_NODE_TYPE("PLANNERGLOBAL");
1407 /* NB: this isn't a complete set of fields */
1408 WRITE_NODE_FIELD(paramlist
);
1409 WRITE_NODE_FIELD(subplans
);
1410 WRITE_NODE_FIELD(subrtables
);
1411 WRITE_BITMAPSET_FIELD(rewindPlanIDs
);
1412 WRITE_NODE_FIELD(finalrtable
);
1413 WRITE_NODE_FIELD(relationOids
);
1414 WRITE_NODE_FIELD(invalItems
);
1415 WRITE_UINT_FIELD(lastPHId
);
1416 WRITE_BOOL_FIELD(transientPlan
);
1420 _outPlannerInfo(StringInfo str
, PlannerInfo
*node
)
1422 WRITE_NODE_TYPE("PLANNERINFO");
1424 /* NB: this isn't a complete set of fields */
1425 WRITE_NODE_FIELD(parse
);
1426 WRITE_NODE_FIELD(glob
);
1427 WRITE_UINT_FIELD(query_level
);
1428 WRITE_NODE_FIELD(join_rel_list
);
1429 WRITE_NODE_FIELD(resultRelations
);
1430 WRITE_NODE_FIELD(returningLists
);
1431 WRITE_NODE_FIELD(init_plans
);
1432 WRITE_NODE_FIELD(cte_plan_ids
);
1433 WRITE_NODE_FIELD(eq_classes
);
1434 WRITE_NODE_FIELD(canon_pathkeys
);
1435 WRITE_NODE_FIELD(left_join_clauses
);
1436 WRITE_NODE_FIELD(right_join_clauses
);
1437 WRITE_NODE_FIELD(full_join_clauses
);
1438 WRITE_NODE_FIELD(join_info_list
);
1439 WRITE_NODE_FIELD(append_rel_list
);
1440 WRITE_NODE_FIELD(placeholder_list
);
1441 WRITE_NODE_FIELD(query_pathkeys
);
1442 WRITE_NODE_FIELD(group_pathkeys
);
1443 WRITE_NODE_FIELD(distinct_pathkeys
);
1444 WRITE_NODE_FIELD(sort_pathkeys
);
1445 WRITE_FLOAT_FIELD(total_table_pages
, "%.0f");
1446 WRITE_FLOAT_FIELD(tuple_fraction
, "%.4f");
1447 WRITE_BOOL_FIELD(hasJoinRTEs
);
1448 WRITE_BOOL_FIELD(hasHavingQual
);
1449 WRITE_BOOL_FIELD(hasPseudoConstantQuals
);
1450 WRITE_BOOL_FIELD(hasRecursion
);
1451 WRITE_INT_FIELD(wt_param_id
);
1455 _outRelOptInfo(StringInfo str
, RelOptInfo
*node
)
1457 WRITE_NODE_TYPE("RELOPTINFO");
1459 /* NB: this isn't a complete set of fields */
1460 WRITE_ENUM_FIELD(reloptkind
, RelOptKind
);
1461 WRITE_BITMAPSET_FIELD(relids
);
1462 WRITE_FLOAT_FIELD(rows
, "%.0f");
1463 WRITE_INT_FIELD(width
);
1464 WRITE_NODE_FIELD(reltargetlist
);
1465 WRITE_NODE_FIELD(pathlist
);
1466 WRITE_NODE_FIELD(cheapest_startup_path
);
1467 WRITE_NODE_FIELD(cheapest_total_path
);
1468 WRITE_NODE_FIELD(cheapest_unique_path
);
1469 WRITE_UINT_FIELD(relid
);
1470 WRITE_ENUM_FIELD(rtekind
, RTEKind
);
1471 WRITE_INT_FIELD(min_attr
);
1472 WRITE_INT_FIELD(max_attr
);
1473 WRITE_NODE_FIELD(indexlist
);
1474 WRITE_UINT_FIELD(pages
);
1475 WRITE_FLOAT_FIELD(tuples
, "%.0f");
1476 WRITE_NODE_FIELD(subplan
);
1477 WRITE_NODE_FIELD(subrtable
);
1478 WRITE_NODE_FIELD(baserestrictinfo
);
1479 WRITE_NODE_FIELD(joininfo
);
1480 WRITE_BOOL_FIELD(has_eclass_joins
);
1481 WRITE_BITMAPSET_FIELD(index_outer_relids
);
1482 WRITE_NODE_FIELD(index_inner_paths
);
1486 _outIndexOptInfo(StringInfo str
, IndexOptInfo
*node
)
1488 WRITE_NODE_TYPE("INDEXOPTINFO");
1490 /* NB: this isn't a complete set of fields */
1491 WRITE_OID_FIELD(indexoid
);
1492 /* Do NOT print rel field, else infinite recursion */
1493 WRITE_UINT_FIELD(pages
);
1494 WRITE_FLOAT_FIELD(tuples
, "%.0f");
1495 WRITE_INT_FIELD(ncolumns
);
1496 WRITE_NODE_FIELD(indexprs
);
1497 WRITE_NODE_FIELD(indpred
);
1498 WRITE_BOOL_FIELD(predOK
);
1499 WRITE_BOOL_FIELD(unique
);
1503 _outEquivalenceClass(StringInfo str
, EquivalenceClass
*node
)
1506 * To simplify reading, we just chase up to the topmost merged EC and
1507 * print that, without bothering to show the merge-ees separately.
1509 while (node
->ec_merged
)
1510 node
= node
->ec_merged
;
1512 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1514 WRITE_NODE_FIELD(ec_opfamilies
);
1515 WRITE_NODE_FIELD(ec_members
);
1516 WRITE_NODE_FIELD(ec_sources
);
1517 WRITE_NODE_FIELD(ec_derives
);
1518 WRITE_BITMAPSET_FIELD(ec_relids
);
1519 WRITE_BOOL_FIELD(ec_has_const
);
1520 WRITE_BOOL_FIELD(ec_has_volatile
);
1521 WRITE_BOOL_FIELD(ec_below_outer_join
);
1522 WRITE_BOOL_FIELD(ec_broken
);
1523 WRITE_UINT_FIELD(ec_sortref
);
1527 _outEquivalenceMember(StringInfo str
, EquivalenceMember
*node
)
1529 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1531 WRITE_NODE_FIELD(em_expr
);
1532 WRITE_BITMAPSET_FIELD(em_relids
);
1533 WRITE_BOOL_FIELD(em_is_const
);
1534 WRITE_BOOL_FIELD(em_is_child
);
1535 WRITE_OID_FIELD(em_datatype
);
1539 _outPathKey(StringInfo str
, PathKey
*node
)
1541 WRITE_NODE_TYPE("PATHKEY");
1543 WRITE_NODE_FIELD(pk_eclass
);
1544 WRITE_OID_FIELD(pk_opfamily
);
1545 WRITE_INT_FIELD(pk_strategy
);
1546 WRITE_BOOL_FIELD(pk_nulls_first
);
1550 _outRestrictInfo(StringInfo str
, RestrictInfo
*node
)
1552 WRITE_NODE_TYPE("RESTRICTINFO");
1554 /* NB: this isn't a complete set of fields */
1555 WRITE_NODE_FIELD(clause
);
1556 WRITE_BOOL_FIELD(is_pushed_down
);
1557 WRITE_BOOL_FIELD(outerjoin_delayed
);
1558 WRITE_BOOL_FIELD(can_join
);
1559 WRITE_BOOL_FIELD(pseudoconstant
);
1560 WRITE_BITMAPSET_FIELD(clause_relids
);
1561 WRITE_BITMAPSET_FIELD(required_relids
);
1562 WRITE_BITMAPSET_FIELD(left_relids
);
1563 WRITE_BITMAPSET_FIELD(right_relids
);
1564 WRITE_NODE_FIELD(orclause
);
1565 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1566 WRITE_NODE_FIELD(mergeopfamilies
);
1567 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1568 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1569 WRITE_NODE_FIELD(left_em
);
1570 WRITE_NODE_FIELD(right_em
);
1571 WRITE_BOOL_FIELD(outer_is_left
);
1572 WRITE_OID_FIELD(hashjoinoperator
);
1576 _outInnerIndexscanInfo(StringInfo str
, InnerIndexscanInfo
*node
)
1578 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1579 WRITE_BITMAPSET_FIELD(other_relids
);
1580 WRITE_BOOL_FIELD(isouterjoin
);
1581 WRITE_NODE_FIELD(cheapest_startup_innerpath
);
1582 WRITE_NODE_FIELD(cheapest_total_innerpath
);
1586 _outFlattenedSubLink(StringInfo str
, FlattenedSubLink
*node
)
1588 WRITE_NODE_TYPE("FLATTENEDSUBLINK");
1590 WRITE_ENUM_FIELD(jointype
, JoinType
);
1591 WRITE_BITMAPSET_FIELD(lefthand
);
1592 WRITE_BITMAPSET_FIELD(righthand
);
1593 WRITE_NODE_FIELD(quals
);
1597 _outPlaceHolderVar(StringInfo str
, PlaceHolderVar
*node
)
1599 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1601 WRITE_NODE_FIELD(phexpr
);
1602 WRITE_BITMAPSET_FIELD(phrels
);
1603 WRITE_UINT_FIELD(phid
);
1604 WRITE_UINT_FIELD(phlevelsup
);
1608 _outSpecialJoinInfo(StringInfo str
, SpecialJoinInfo
*node
)
1610 WRITE_NODE_TYPE("SPECIALJOININFO");
1612 WRITE_BITMAPSET_FIELD(min_lefthand
);
1613 WRITE_BITMAPSET_FIELD(min_righthand
);
1614 WRITE_BITMAPSET_FIELD(syn_lefthand
);
1615 WRITE_BITMAPSET_FIELD(syn_righthand
);
1616 WRITE_ENUM_FIELD(jointype
, JoinType
);
1617 WRITE_BOOL_FIELD(lhs_strict
);
1618 WRITE_BOOL_FIELD(delay_upper_joins
);
1619 WRITE_NODE_FIELD(join_quals
);
1623 _outAppendRelInfo(StringInfo str
, AppendRelInfo
*node
)
1625 WRITE_NODE_TYPE("APPENDRELINFO");
1627 WRITE_UINT_FIELD(parent_relid
);
1628 WRITE_UINT_FIELD(child_relid
);
1629 WRITE_OID_FIELD(parent_reltype
);
1630 WRITE_OID_FIELD(child_reltype
);
1631 WRITE_NODE_FIELD(col_mappings
);
1632 WRITE_NODE_FIELD(translated_vars
);
1633 WRITE_OID_FIELD(parent_reloid
);
1637 _outPlaceHolderInfo(StringInfo str
, PlaceHolderInfo
*node
)
1639 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1641 WRITE_UINT_FIELD(phid
);
1642 WRITE_NODE_FIELD(ph_var
);
1643 WRITE_BITMAPSET_FIELD(ph_eval_at
);
1644 WRITE_BITMAPSET_FIELD(ph_needed
);
1645 WRITE_INT_FIELD(ph_width
);
1649 _outPlannerParamItem(StringInfo str
, PlannerParamItem
*node
)
1651 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1653 WRITE_NODE_FIELD(item
);
1654 WRITE_UINT_FIELD(abslevel
);
1657 /*****************************************************************************
1659 * Stuff from parsenodes.h.
1661 *****************************************************************************/
1664 _outCreateStmt(StringInfo str
, CreateStmt
*node
)
1666 WRITE_NODE_TYPE("CREATESTMT");
1668 WRITE_NODE_FIELD(relation
);
1669 WRITE_NODE_FIELD(tableElts
);
1670 WRITE_NODE_FIELD(inhRelations
);
1671 WRITE_NODE_FIELD(constraints
);
1672 WRITE_NODE_FIELD(options
);
1673 WRITE_ENUM_FIELD(oncommit
, OnCommitAction
);
1674 WRITE_STRING_FIELD(tablespacename
);
1678 _outIndexStmt(StringInfo str
, IndexStmt
*node
)
1680 WRITE_NODE_TYPE("INDEXSTMT");
1682 WRITE_STRING_FIELD(idxname
);
1683 WRITE_NODE_FIELD(relation
);
1684 WRITE_STRING_FIELD(accessMethod
);
1685 WRITE_STRING_FIELD(tableSpace
);
1686 WRITE_NODE_FIELD(indexParams
);
1687 WRITE_NODE_FIELD(options
);
1688 WRITE_NODE_FIELD(whereClause
);
1689 WRITE_BOOL_FIELD(unique
);
1690 WRITE_BOOL_FIELD(primary
);
1691 WRITE_BOOL_FIELD(isconstraint
);
1692 WRITE_BOOL_FIELD(concurrent
);
1696 _outNotifyStmt(StringInfo str
, NotifyStmt
*node
)
1698 WRITE_NODE_TYPE("NOTIFY");
1700 WRITE_STRING_FIELD(conditionname
);
1704 _outDeclareCursorStmt(StringInfo str
, DeclareCursorStmt
*node
)
1706 WRITE_NODE_TYPE("DECLARECURSOR");
1708 WRITE_STRING_FIELD(portalname
);
1709 WRITE_INT_FIELD(options
);
1710 WRITE_NODE_FIELD(query
);
1714 _outSelectStmt(StringInfo str
, SelectStmt
*node
)
1716 WRITE_NODE_TYPE("SELECT");
1718 WRITE_NODE_FIELD(distinctClause
);
1719 WRITE_NODE_FIELD(intoClause
);
1720 WRITE_NODE_FIELD(targetList
);
1721 WRITE_NODE_FIELD(fromClause
);
1722 WRITE_NODE_FIELD(whereClause
);
1723 WRITE_NODE_FIELD(groupClause
);
1724 WRITE_NODE_FIELD(havingClause
);
1725 WRITE_NODE_FIELD(withClause
);
1726 WRITE_NODE_FIELD(valuesLists
);
1727 WRITE_NODE_FIELD(sortClause
);
1728 WRITE_NODE_FIELD(limitOffset
);
1729 WRITE_NODE_FIELD(limitCount
);
1730 WRITE_NODE_FIELD(lockingClause
);
1731 WRITE_ENUM_FIELD(op
, SetOperation
);
1732 WRITE_BOOL_FIELD(all
);
1733 WRITE_NODE_FIELD(larg
);
1734 WRITE_NODE_FIELD(rarg
);
1738 _outFuncCall(StringInfo str
, FuncCall
*node
)
1740 WRITE_NODE_TYPE("FUNCCALL");
1742 WRITE_NODE_FIELD(funcname
);
1743 WRITE_NODE_FIELD(args
);
1744 WRITE_BOOL_FIELD(agg_star
);
1745 WRITE_BOOL_FIELD(agg_distinct
);
1746 WRITE_BOOL_FIELD(func_variadic
);
1747 WRITE_LOCATION_FIELD(location
);
1751 _outDefElem(StringInfo str
, DefElem
*node
)
1753 WRITE_NODE_TYPE("DEFELEM");
1755 WRITE_STRING_FIELD(defname
);
1756 WRITE_NODE_FIELD(arg
);
1760 _outLockingClause(StringInfo str
, LockingClause
*node
)
1762 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1764 WRITE_NODE_FIELD(lockedRels
);
1765 WRITE_BOOL_FIELD(forUpdate
);
1766 WRITE_BOOL_FIELD(noWait
);
1770 _outXmlSerialize(StringInfo str
, XmlSerialize
*node
)
1772 WRITE_NODE_TYPE("XMLSERIALIZE");
1774 WRITE_ENUM_FIELD(xmloption
, XmlOptionType
);
1775 WRITE_NODE_FIELD(expr
);
1776 WRITE_NODE_FIELD(typename
);
1777 WRITE_LOCATION_FIELD(location
);
1781 _outColumnDef(StringInfo str
, ColumnDef
*node
)
1783 WRITE_NODE_TYPE("COLUMNDEF");
1785 WRITE_STRING_FIELD(colname
);
1786 WRITE_NODE_FIELD(typename
);
1787 WRITE_INT_FIELD(inhcount
);
1788 WRITE_BOOL_FIELD(is_local
);
1789 WRITE_BOOL_FIELD(is_not_null
);
1790 WRITE_NODE_FIELD(raw_default
);
1791 WRITE_STRING_FIELD(cooked_default
);
1792 WRITE_NODE_FIELD(constraints
);
1796 _outTypeName(StringInfo str
, TypeName
*node
)
1798 WRITE_NODE_TYPE("TYPENAME");
1800 WRITE_NODE_FIELD(names
);
1801 WRITE_OID_FIELD(typeid);
1802 WRITE_BOOL_FIELD(setof
);
1803 WRITE_BOOL_FIELD(pct_type
);
1804 WRITE_NODE_FIELD(typmods
);
1805 WRITE_INT_FIELD(typemod
);
1806 WRITE_NODE_FIELD(arrayBounds
);
1807 WRITE_LOCATION_FIELD(location
);
1811 _outTypeCast(StringInfo str
, TypeCast
*node
)
1813 WRITE_NODE_TYPE("TYPECAST");
1815 WRITE_NODE_FIELD(arg
);
1816 WRITE_NODE_FIELD(typename
);
1817 WRITE_LOCATION_FIELD(location
);
1821 _outIndexElem(StringInfo str
, IndexElem
*node
)
1823 WRITE_NODE_TYPE("INDEXELEM");
1825 WRITE_STRING_FIELD(name
);
1826 WRITE_NODE_FIELD(expr
);
1827 WRITE_NODE_FIELD(opclass
);
1828 WRITE_ENUM_FIELD(ordering
, SortByDir
);
1829 WRITE_ENUM_FIELD(nulls_ordering
, SortByNulls
);
1833 _outQuery(StringInfo str
, Query
*node
)
1835 WRITE_NODE_TYPE("QUERY");
1837 WRITE_ENUM_FIELD(commandType
, CmdType
);
1838 WRITE_ENUM_FIELD(querySource
, QuerySource
);
1839 WRITE_BOOL_FIELD(canSetTag
);
1842 * Hack to work around missing outfuncs routines for a lot of the
1843 * utility-statement node types. (The only one we actually *need* for
1844 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1845 * for the meantime do this to avoid getting lots of warnings when running
1846 * with debug_print_parse on.
1848 if (node
->utilityStmt
)
1850 switch (nodeTag(node
->utilityStmt
))
1855 case T_DeclareCursorStmt
:
1856 WRITE_NODE_FIELD(utilityStmt
);
1859 appendStringInfo(str
, " :utilityStmt ?");
1864 appendStringInfo(str
, " :utilityStmt <>");
1866 WRITE_INT_FIELD(resultRelation
);
1867 WRITE_NODE_FIELD(intoClause
);
1868 WRITE_BOOL_FIELD(hasAggs
);
1869 WRITE_BOOL_FIELD(hasSubLinks
);
1870 WRITE_BOOL_FIELD(hasDistinctOn
);
1871 WRITE_BOOL_FIELD(hasRecursive
);
1872 WRITE_NODE_FIELD(cteList
);
1873 WRITE_NODE_FIELD(rtable
);
1874 WRITE_NODE_FIELD(jointree
);
1875 WRITE_NODE_FIELD(targetList
);
1876 WRITE_NODE_FIELD(returningList
);
1877 WRITE_NODE_FIELD(groupClause
);
1878 WRITE_NODE_FIELD(havingQual
);
1879 WRITE_NODE_FIELD(distinctClause
);
1880 WRITE_NODE_FIELD(sortClause
);
1881 WRITE_NODE_FIELD(limitOffset
);
1882 WRITE_NODE_FIELD(limitCount
);
1883 WRITE_NODE_FIELD(rowMarks
);
1884 WRITE_NODE_FIELD(setOperations
);
1888 _outSortGroupClause(StringInfo str
, SortGroupClause
*node
)
1890 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
1892 WRITE_UINT_FIELD(tleSortGroupRef
);
1893 WRITE_OID_FIELD(eqop
);
1894 WRITE_OID_FIELD(sortop
);
1895 WRITE_BOOL_FIELD(nulls_first
);
1899 _outRowMarkClause(StringInfo str
, RowMarkClause
*node
)
1901 WRITE_NODE_TYPE("ROWMARKCLAUSE");
1903 WRITE_UINT_FIELD(rti
);
1904 WRITE_BOOL_FIELD(forUpdate
);
1905 WRITE_BOOL_FIELD(noWait
);
1909 _outWithClause(StringInfo str
, WithClause
*node
)
1911 WRITE_NODE_TYPE("WITHCLAUSE");
1913 WRITE_NODE_FIELD(ctes
);
1914 WRITE_BOOL_FIELD(recursive
);
1915 WRITE_LOCATION_FIELD(location
);
1919 _outCommonTableExpr(StringInfo str
, CommonTableExpr
*node
)
1921 WRITE_NODE_TYPE("COMMONTABLEEXPR");
1923 WRITE_STRING_FIELD(ctename
);
1924 WRITE_NODE_FIELD(aliascolnames
);
1925 WRITE_NODE_FIELD(ctequery
);
1926 WRITE_LOCATION_FIELD(location
);
1927 WRITE_BOOL_FIELD(cterecursive
);
1928 WRITE_INT_FIELD(cterefcount
);
1929 WRITE_NODE_FIELD(ctecolnames
);
1930 WRITE_NODE_FIELD(ctecoltypes
);
1931 WRITE_NODE_FIELD(ctecoltypmods
);
1935 _outSetOperationStmt(StringInfo str
, SetOperationStmt
*node
)
1937 WRITE_NODE_TYPE("SETOPERATIONSTMT");
1939 WRITE_ENUM_FIELD(op
, SetOperation
);
1940 WRITE_BOOL_FIELD(all
);
1941 WRITE_NODE_FIELD(larg
);
1942 WRITE_NODE_FIELD(rarg
);
1943 WRITE_NODE_FIELD(colTypes
);
1944 WRITE_NODE_FIELD(colTypmods
);
1945 WRITE_NODE_FIELD(groupClauses
);
1949 _outRangeTblEntry(StringInfo str
, RangeTblEntry
*node
)
1951 WRITE_NODE_TYPE("RTE");
1953 /* put alias + eref first to make dump more legible */
1954 WRITE_NODE_FIELD(alias
);
1955 WRITE_NODE_FIELD(eref
);
1956 WRITE_ENUM_FIELD(rtekind
, RTEKind
);
1958 switch (node
->rtekind
)
1962 WRITE_OID_FIELD(relid
);
1965 WRITE_NODE_FIELD(subquery
);
1968 WRITE_ENUM_FIELD(jointype
, JoinType
);
1969 WRITE_NODE_FIELD(joinaliasvars
);
1972 WRITE_NODE_FIELD(funcexpr
);
1973 WRITE_NODE_FIELD(funccoltypes
);
1974 WRITE_NODE_FIELD(funccoltypmods
);
1977 WRITE_NODE_FIELD(values_lists
);
1980 WRITE_STRING_FIELD(ctename
);
1981 WRITE_UINT_FIELD(ctelevelsup
);
1982 WRITE_BOOL_FIELD(self_reference
);
1983 WRITE_NODE_FIELD(ctecoltypes
);
1984 WRITE_NODE_FIELD(ctecoltypmods
);
1987 elog(ERROR
, "unrecognized RTE kind: %d", (int) node
->rtekind
);
1991 WRITE_BOOL_FIELD(inh
);
1992 WRITE_BOOL_FIELD(inFromCl
);
1993 WRITE_UINT_FIELD(requiredPerms
);
1994 WRITE_OID_FIELD(checkAsUser
);
1998 _outAExpr(StringInfo str
, A_Expr
*node
)
2000 WRITE_NODE_TYPE("AEXPR");
2005 appendStringInfo(str
, " ");
2006 WRITE_NODE_FIELD(name
);
2009 appendStringInfo(str
, " AND");
2012 appendStringInfo(str
, " OR");
2015 appendStringInfo(str
, " NOT");
2018 appendStringInfo(str
, " ");
2019 WRITE_NODE_FIELD(name
);
2020 appendStringInfo(str
, " ANY ");
2023 appendStringInfo(str
, " ");
2024 WRITE_NODE_FIELD(name
);
2025 appendStringInfo(str
, " ALL ");
2027 case AEXPR_DISTINCT
:
2028 appendStringInfo(str
, " DISTINCT ");
2029 WRITE_NODE_FIELD(name
);
2032 appendStringInfo(str
, " NULLIF ");
2033 WRITE_NODE_FIELD(name
);
2036 appendStringInfo(str
, " OF ");
2037 WRITE_NODE_FIELD(name
);
2040 appendStringInfo(str
, " IN ");
2041 WRITE_NODE_FIELD(name
);
2044 appendStringInfo(str
, " ??");
2048 WRITE_NODE_FIELD(lexpr
);
2049 WRITE_NODE_FIELD(rexpr
);
2050 WRITE_LOCATION_FIELD(location
);
2054 _outValue(StringInfo str
, Value
*value
)
2056 switch (value
->type
)
2059 appendStringInfo(str
, "%ld", value
->val
.ival
);
2064 * We assume the value is a valid numeric literal and so does not
2067 appendStringInfoString(str
, value
->val
.str
);
2070 appendStringInfoChar(str
, '"');
2071 _outToken(str
, value
->val
.str
);
2072 appendStringInfoChar(str
, '"');
2075 /* internal representation already has leading 'b' */
2076 appendStringInfoString(str
, value
->val
.str
);
2079 /* this is seen only within A_Const, not in transformed trees */
2080 appendStringInfoString(str
, "NULL");
2083 elog(ERROR
, "unrecognized node type: %d", (int) value
->type
);
2089 _outColumnRef(StringInfo str
, ColumnRef
*node
)
2091 WRITE_NODE_TYPE("COLUMNREF");
2093 WRITE_NODE_FIELD(fields
);
2094 WRITE_LOCATION_FIELD(location
);
2098 _outParamRef(StringInfo str
, ParamRef
*node
)
2100 WRITE_NODE_TYPE("PARAMREF");
2102 WRITE_INT_FIELD(number
);
2103 WRITE_LOCATION_FIELD(location
);
2107 _outAConst(StringInfo str
, A_Const
*node
)
2109 WRITE_NODE_TYPE("A_CONST");
2111 appendStringInfo(str
, " :val ");
2112 _outValue(str
, &(node
->val
));
2113 WRITE_LOCATION_FIELD(location
);
2117 _outA_Star(StringInfo str
, A_Star
*node
)
2119 WRITE_NODE_TYPE("A_STAR");
2123 _outA_Indices(StringInfo str
, A_Indices
*node
)
2125 WRITE_NODE_TYPE("A_INDICES");
2127 WRITE_NODE_FIELD(lidx
);
2128 WRITE_NODE_FIELD(uidx
);
2132 _outA_Indirection(StringInfo str
, A_Indirection
*node
)
2134 WRITE_NODE_TYPE("A_INDIRECTION");
2136 WRITE_NODE_FIELD(arg
);
2137 WRITE_NODE_FIELD(indirection
);
2141 _outA_ArrayExpr(StringInfo str
, A_ArrayExpr
*node
)
2143 WRITE_NODE_TYPE("A_ARRAYEXPR");
2145 WRITE_NODE_FIELD(elements
);
2146 WRITE_LOCATION_FIELD(location
);
2150 _outResTarget(StringInfo str
, ResTarget
*node
)
2152 WRITE_NODE_TYPE("RESTARGET");
2154 WRITE_STRING_FIELD(name
);
2155 WRITE_NODE_FIELD(indirection
);
2156 WRITE_NODE_FIELD(val
);
2157 WRITE_LOCATION_FIELD(location
);
2161 _outSortBy(StringInfo str
, SortBy
*node
)
2163 WRITE_NODE_TYPE("SORTBY");
2165 WRITE_NODE_FIELD(node
);
2166 WRITE_ENUM_FIELD(sortby_dir
, SortByDir
);
2167 WRITE_ENUM_FIELD(sortby_nulls
, SortByNulls
);
2168 WRITE_NODE_FIELD(useOp
);
2169 WRITE_LOCATION_FIELD(location
);
2173 _outRangeSubselect(StringInfo str
, RangeSubselect
*node
)
2175 WRITE_NODE_TYPE("RANGESUBSELECT");
2177 WRITE_NODE_FIELD(subquery
);
2178 WRITE_NODE_FIELD(alias
);
2182 _outRangeFunction(StringInfo str
, RangeFunction
*node
)
2184 WRITE_NODE_TYPE("RANGEFUNCTION");
2186 WRITE_NODE_FIELD(funccallnode
);
2187 WRITE_NODE_FIELD(alias
);
2188 WRITE_NODE_FIELD(coldeflist
);
2192 _outConstraint(StringInfo str
, Constraint
*node
)
2194 WRITE_NODE_TYPE("CONSTRAINT");
2196 WRITE_STRING_FIELD(name
);
2198 appendStringInfo(str
, " :contype ");
2199 switch (node
->contype
)
2201 case CONSTR_PRIMARY
:
2202 appendStringInfo(str
, "PRIMARY_KEY");
2203 WRITE_NODE_FIELD(keys
);
2204 WRITE_NODE_FIELD(options
);
2205 WRITE_STRING_FIELD(indexspace
);
2209 appendStringInfo(str
, "UNIQUE");
2210 WRITE_NODE_FIELD(keys
);
2211 WRITE_NODE_FIELD(options
);
2212 WRITE_STRING_FIELD(indexspace
);
2216 appendStringInfo(str
, "CHECK");
2217 WRITE_NODE_FIELD(raw_expr
);
2218 WRITE_STRING_FIELD(cooked_expr
);
2221 case CONSTR_DEFAULT
:
2222 appendStringInfo(str
, "DEFAULT");
2223 WRITE_NODE_FIELD(raw_expr
);
2224 WRITE_STRING_FIELD(cooked_expr
);
2227 case CONSTR_NOTNULL
:
2228 appendStringInfo(str
, "NOT_NULL");
2232 appendStringInfo(str
, "<unrecognized_constraint>");
2238 _outFkConstraint(StringInfo str
, FkConstraint
*node
)
2240 WRITE_NODE_TYPE("FKCONSTRAINT");
2242 WRITE_STRING_FIELD(constr_name
);
2243 WRITE_NODE_FIELD(pktable
);
2244 WRITE_NODE_FIELD(fk_attrs
);
2245 WRITE_NODE_FIELD(pk_attrs
);
2246 WRITE_CHAR_FIELD(fk_matchtype
);
2247 WRITE_CHAR_FIELD(fk_upd_action
);
2248 WRITE_CHAR_FIELD(fk_del_action
);
2249 WRITE_BOOL_FIELD(deferrable
);
2250 WRITE_BOOL_FIELD(initdeferred
);
2251 WRITE_BOOL_FIELD(skip_validation
);
2257 * converts a Node into ascii string and append it to 'str'
2260 _outNode(StringInfo str
, void *obj
)
2263 appendStringInfo(str
, "<>");
2264 else if (IsA(obj
, List
) ||IsA(obj
, IntList
) || IsA(obj
, OidList
))
2266 else if (IsA(obj
, Integer
) ||
2269 IsA(obj
, BitString
))
2271 /* nodeRead does not want to see { } around these! */
2272 _outValue(str
, obj
);
2276 appendStringInfoChar(str
, '{');
2277 switch (nodeTag(obj
))
2280 _outPlannedStmt(str
, obj
);
2286 _outResult(str
, obj
);
2289 _outAppend(str
, obj
);
2291 case T_RecursiveUnion
:
2292 _outRecursiveUnion(str
, obj
);
2295 _outBitmapAnd(str
, obj
);
2298 _outBitmapOr(str
, obj
);
2304 _outSeqScan(str
, obj
);
2307 _outIndexScan(str
, obj
);
2309 case T_BitmapIndexScan
:
2310 _outBitmapIndexScan(str
, obj
);
2312 case T_BitmapHeapScan
:
2313 _outBitmapHeapScan(str
, obj
);
2316 _outTidScan(str
, obj
);
2318 case T_SubqueryScan
:
2319 _outSubqueryScan(str
, obj
);
2321 case T_FunctionScan
:
2322 _outFunctionScan(str
, obj
);
2325 _outValuesScan(str
, obj
);
2328 _outCteScan(str
, obj
);
2330 case T_WorkTableScan
:
2331 _outWorkTableScan(str
, obj
);
2337 _outNestLoop(str
, obj
);
2340 _outMergeJoin(str
, obj
);
2343 _outHashJoin(str
, obj
);
2349 _outGroup(str
, obj
);
2352 _outMaterial(str
, obj
);
2358 _outUnique(str
, obj
);
2364 _outSetOp(str
, obj
);
2367 _outLimit(str
, obj
);
2369 case T_PlanInvalItem
:
2370 _outPlanInvalItem(str
, obj
);
2373 _outAlias(str
, obj
);
2376 _outRangeVar(str
, obj
);
2379 _outIntoClause(str
, obj
);
2385 _outConst(str
, obj
);
2388 _outParam(str
, obj
);
2391 _outAggref(str
, obj
);
2394 _outArrayRef(str
, obj
);
2397 _outFuncExpr(str
, obj
);
2400 _outOpExpr(str
, obj
);
2402 case T_DistinctExpr
:
2403 _outDistinctExpr(str
, obj
);
2405 case T_ScalarArrayOpExpr
:
2406 _outScalarArrayOpExpr(str
, obj
);
2409 _outBoolExpr(str
, obj
);
2412 _outSubLink(str
, obj
);
2415 _outSubPlan(str
, obj
);
2417 case T_AlternativeSubPlan
:
2418 _outAlternativeSubPlan(str
, obj
);
2421 _outFieldSelect(str
, obj
);
2424 _outFieldStore(str
, obj
);
2427 _outRelabelType(str
, obj
);
2430 _outCoerceViaIO(str
, obj
);
2432 case T_ArrayCoerceExpr
:
2433 _outArrayCoerceExpr(str
, obj
);
2435 case T_ConvertRowtypeExpr
:
2436 _outConvertRowtypeExpr(str
, obj
);
2439 _outCaseExpr(str
, obj
);
2442 _outCaseWhen(str
, obj
);
2444 case T_CaseTestExpr
:
2445 _outCaseTestExpr(str
, obj
);
2448 _outArrayExpr(str
, obj
);
2451 _outRowExpr(str
, obj
);
2453 case T_RowCompareExpr
:
2454 _outRowCompareExpr(str
, obj
);
2456 case T_CoalesceExpr
:
2457 _outCoalesceExpr(str
, obj
);
2460 _outMinMaxExpr(str
, obj
);
2463 _outXmlExpr(str
, obj
);
2466 _outNullIfExpr(str
, obj
);
2469 _outNullTest(str
, obj
);
2472 _outBooleanTest(str
, obj
);
2474 case T_CoerceToDomain
:
2475 _outCoerceToDomain(str
, obj
);
2477 case T_CoerceToDomainValue
:
2478 _outCoerceToDomainValue(str
, obj
);
2480 case T_SetToDefault
:
2481 _outSetToDefault(str
, obj
);
2483 case T_CurrentOfExpr
:
2484 _outCurrentOfExpr(str
, obj
);
2487 _outTargetEntry(str
, obj
);
2490 _outRangeTblRef(str
, obj
);
2493 _outJoinExpr(str
, obj
);
2496 _outFromExpr(str
, obj
);
2503 _outIndexPath(str
, obj
);
2505 case T_BitmapHeapPath
:
2506 _outBitmapHeapPath(str
, obj
);
2508 case T_BitmapAndPath
:
2509 _outBitmapAndPath(str
, obj
);
2511 case T_BitmapOrPath
:
2512 _outBitmapOrPath(str
, obj
);
2515 _outTidPath(str
, obj
);
2518 _outAppendPath(str
, obj
);
2521 _outResultPath(str
, obj
);
2523 case T_MaterialPath
:
2524 _outMaterialPath(str
, obj
);
2527 _outUniquePath(str
, obj
);
2530 _outNestPath(str
, obj
);
2533 _outMergePath(str
, obj
);
2536 _outHashPath(str
, obj
);
2538 case T_PlannerGlobal
:
2539 _outPlannerGlobal(str
, obj
);
2542 _outPlannerInfo(str
, obj
);
2545 _outRelOptInfo(str
, obj
);
2547 case T_IndexOptInfo
:
2548 _outIndexOptInfo(str
, obj
);
2550 case T_EquivalenceClass
:
2551 _outEquivalenceClass(str
, obj
);
2553 case T_EquivalenceMember
:
2554 _outEquivalenceMember(str
, obj
);
2557 _outPathKey(str
, obj
);
2559 case T_RestrictInfo
:
2560 _outRestrictInfo(str
, obj
);
2562 case T_InnerIndexscanInfo
:
2563 _outInnerIndexscanInfo(str
, obj
);
2565 case T_FlattenedSubLink
:
2566 _outFlattenedSubLink(str
, obj
);
2568 case T_PlaceHolderVar
:
2569 _outPlaceHolderVar(str
, obj
);
2571 case T_SpecialJoinInfo
:
2572 _outSpecialJoinInfo(str
, obj
);
2574 case T_AppendRelInfo
:
2575 _outAppendRelInfo(str
, obj
);
2577 case T_PlaceHolderInfo
:
2578 _outPlaceHolderInfo(str
, obj
);
2580 case T_PlannerParamItem
:
2581 _outPlannerParamItem(str
, obj
);
2585 _outCreateStmt(str
, obj
);
2588 _outIndexStmt(str
, obj
);
2591 _outNotifyStmt(str
, obj
);
2593 case T_DeclareCursorStmt
:
2594 _outDeclareCursorStmt(str
, obj
);
2597 _outSelectStmt(str
, obj
);
2600 _outColumnDef(str
, obj
);
2603 _outTypeName(str
, obj
);
2606 _outTypeCast(str
, obj
);
2609 _outIndexElem(str
, obj
);
2612 _outQuery(str
, obj
);
2614 case T_SortGroupClause
:
2615 _outSortGroupClause(str
, obj
);
2617 case T_RowMarkClause
:
2618 _outRowMarkClause(str
, obj
);
2621 _outWithClause(str
, obj
);
2623 case T_CommonTableExpr
:
2624 _outCommonTableExpr(str
, obj
);
2626 case T_SetOperationStmt
:
2627 _outSetOperationStmt(str
, obj
);
2629 case T_RangeTblEntry
:
2630 _outRangeTblEntry(str
, obj
);
2633 _outAExpr(str
, obj
);
2636 _outColumnRef(str
, obj
);
2639 _outParamRef(str
, obj
);
2642 _outAConst(str
, obj
);
2645 _outA_Star(str
, obj
);
2648 _outA_Indices(str
, obj
);
2650 case T_A_Indirection
:
2651 _outA_Indirection(str
, obj
);
2654 _outA_ArrayExpr(str
, obj
);
2657 _outResTarget(str
, obj
);
2660 _outSortBy(str
, obj
);
2662 case T_RangeSubselect
:
2663 _outRangeSubselect(str
, obj
);
2665 case T_RangeFunction
:
2666 _outRangeFunction(str
, obj
);
2669 _outConstraint(str
, obj
);
2671 case T_FkConstraint
:
2672 _outFkConstraint(str
, obj
);
2675 _outFuncCall(str
, obj
);
2678 _outDefElem(str
, obj
);
2680 case T_LockingClause
:
2681 _outLockingClause(str
, obj
);
2683 case T_XmlSerialize
:
2684 _outXmlSerialize(str
, obj
);
2690 * This should be an ERROR, but it's too useful to be able to
2691 * dump structures that _outNode only understands part of.
2693 elog(WARNING
, "could not dump unrecognized node type: %d",
2694 (int) nodeTag(obj
));
2697 appendStringInfoChar(str
, '}');
2703 * returns the ascii representation of the Node as a palloc'd string
2706 nodeToString(void *obj
)
2710 /* see stringinfo.h for an explanation of this maneuver */
2711 initStringInfo(&str
);
2712 _outNode(&str
, obj
);