1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2010, 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.388 2010/08/07 02:44:06 tgl Exp $
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify output of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire conventions about the names of the local variables in an Out
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41 appendStringInfoString(str, nodelabel)
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47 /* Write an unsigned integer field (anything written as ":fldname %u") */
48 #define WRITE_UINT_FIELD(fldname) \
49 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
51 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
52 #define WRITE_OID_FIELD(fldname) \
53 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
68 /* Write a float field --- caller must give format to define precision */
69 #define WRITE_FLOAT_FIELD(fldname,format) \
70 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75 booltostr(node->fldname))
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 _outToken(str, node->fldname))
82 /* Write a parse location field (actually same as INT case) */
83 #define WRITE_LOCATION_FIELD(fldname) \
84 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
86 /* Write a Node field */
87 #define WRITE_NODE_FIELD(fldname) \
88 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
89 _outNode(str, node->fldname))
91 /* Write a bitmapset field */
92 #define WRITE_BITMAPSET_FIELD(fldname) \
93 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
94 _outBitmapset(str, node->fldname))
97 #define booltostr(x) ((x) ? "true" : "false")
99 static void _outNode(StringInfo str, void *obj);
104 * Convert an ordinary string (eg, an identifier) into a form that
105 * will be decoded back to a plain token by read.c's functions.
107 * If a null or empty string is given, it is encoded as "<>".
110 _outToken(StringInfo str, char *s)
112 if (s == NULL || *s == '\0')
114 appendStringInfo(str, "<>");
119 * Look for characters or patterns that are treated specially by read.c
120 * (either in pg_strtok() or in nodeRead()), and therefore need a
121 * protective backslash.
123 /* These characters only need to be quoted at the start of the string */
126 isdigit((unsigned char) *s) ||
127 ((*s == '+' || *s == '-') &&
128 (isdigit((unsigned char) s[1]) || s[1] == '.')))
129 appendStringInfoChar(str, '\\');
132 /* These chars must be backslashed anywhere in the string */
133 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
136 appendStringInfoChar(str, '\\');
137 appendStringInfoChar(str, *s++);
142 _outList(StringInfo str, List *node)
146 appendStringInfoChar(str, '(');
148 if (IsA(node, IntList))
149 appendStringInfoChar(str, 'i');
150 else if (IsA(node, OidList))
151 appendStringInfoChar(str, 'o');
156 * For the sake of backward compatibility, we emit a slightly
157 * different whitespace format for lists of nodes vs. other types of
158 * lists. XXX: is this necessary?
162 _outNode(str, lfirst(lc));
164 appendStringInfoChar(str, ' ');
166 else if (IsA(node, IntList))
167 appendStringInfo(str, " %d", lfirst_int(lc));
168 else if (IsA(node, OidList))
169 appendStringInfo(str, " %u", lfirst_oid(lc));
171 elog(ERROR, "unrecognized list node type: %d",
175 appendStringInfoChar(str, ')');
180 * converts a bitmap set of integers
182 * Note: the output format is "(b int int ...)", similar to an integer List.
185 _outBitmapset(StringInfo str, Bitmapset *bms)
190 appendStringInfoChar(str, '(');
191 appendStringInfoChar(str, 'b');
192 tmpset = bms_copy(bms);
193 while ((x = bms_first_member(tmpset)) >= 0)
194 appendStringInfo(str, " %d", x);
196 appendStringInfoChar(str, ')');
200 * Print the value of a Datum given its type.
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
209 length = datumGetSize(value, typbyval, typlen);
213 s = (char *) (&value);
214 appendStringInfo(str, "%u [ ", (unsigned int) length);
215 for (i = 0; i < (Size) sizeof(Datum); i++)
216 appendStringInfo(str, "%d ", (int) (s[i]));
217 appendStringInfo(str, "]");
221 s = (char *) DatumGetPointer(value);
222 if (!PointerIsValid(s))
223 appendStringInfo(str, "0 [ ]");
226 appendStringInfo(str, "%u [ ", (unsigned int) length);
227 for (i = 0; i < length; i++)
228 appendStringInfo(str, "%d ", (int) (s[i]));
229 appendStringInfo(str, "]");
236 * Stuff from plannodes.h
240 _outPlannedStmt(StringInfo str, PlannedStmt *node)
242 WRITE_NODE_TYPE("PLANNEDSTMT");
244 WRITE_ENUM_FIELD(commandType, CmdType);
245 WRITE_BOOL_FIELD(hasReturning);
246 WRITE_BOOL_FIELD(canSetTag);
247 WRITE_NODE_FIELD(planTree);
248 WRITE_NODE_FIELD(rtable);
249 WRITE_NODE_FIELD(resultRelations);
250 WRITE_NODE_FIELD(utilityStmt);
251 WRITE_NODE_FIELD(intoClause);
252 WRITE_NODE_FIELD(subplans);
253 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
254 WRITE_NODE_FIELD(rowMarks);
255 WRITE_NODE_FIELD(relationOids);
256 WRITE_NODE_FIELD(invalItems);
257 WRITE_INT_FIELD(nParamExec);
261 * print the basic stuff of all nodes that inherit from Plan
264 _outPlanInfo(StringInfo str, Plan *node)
266 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
267 WRITE_FLOAT_FIELD(total_cost, "%.2f");
268 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
269 WRITE_INT_FIELD(plan_width);
270 WRITE_NODE_FIELD(targetlist);
271 WRITE_NODE_FIELD(qual);
272 WRITE_NODE_FIELD(lefttree);
273 WRITE_NODE_FIELD(righttree);
274 WRITE_NODE_FIELD(initPlan);
275 WRITE_BITMAPSET_FIELD(extParam);
276 WRITE_BITMAPSET_FIELD(allParam);
280 * print the basic stuff of all nodes that inherit from Scan
283 _outScanInfo(StringInfo str, Scan *node)
285 _outPlanInfo(str, (Plan *) node);
287 WRITE_UINT_FIELD(scanrelid);
291 * print the basic stuff of all nodes that inherit from Join
294 _outJoinPlanInfo(StringInfo str, Join *node)
296 _outPlanInfo(str, (Plan *) node);
298 WRITE_ENUM_FIELD(jointype, JoinType);
299 WRITE_NODE_FIELD(joinqual);
304 _outPlan(StringInfo str, Plan *node)
306 WRITE_NODE_TYPE("PLAN");
308 _outPlanInfo(str, (Plan *) node);
312 _outResult(StringInfo str, Result *node)
314 WRITE_NODE_TYPE("RESULT");
316 _outPlanInfo(str, (Plan *) node);
318 WRITE_NODE_FIELD(resconstantqual);
322 _outModifyTable(StringInfo str, ModifyTable *node)
324 WRITE_NODE_TYPE("MODIFYTABLE");
326 _outPlanInfo(str, (Plan *) node);
328 WRITE_ENUM_FIELD(operation, CmdType);
329 WRITE_NODE_FIELD(resultRelations);
330 WRITE_NODE_FIELD(plans);
331 WRITE_NODE_FIELD(returningLists);
332 WRITE_NODE_FIELD(rowMarks);
333 WRITE_INT_FIELD(epqParam);
337 _outAppend(StringInfo str, Append *node)
339 WRITE_NODE_TYPE("APPEND");
341 _outPlanInfo(str, (Plan *) node);
343 WRITE_NODE_FIELD(appendplans);
347 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
351 WRITE_NODE_TYPE("RECURSIVEUNION");
353 _outPlanInfo(str, (Plan *) node);
355 WRITE_INT_FIELD(wtParam);
356 WRITE_INT_FIELD(numCols);
358 appendStringInfo(str, " :dupColIdx");
359 for (i = 0; i < node->numCols; i++)
360 appendStringInfo(str, " %d", node->dupColIdx[i]);
362 appendStringInfo(str, " :dupOperators");
363 for (i = 0; i < node->numCols; i++)
364 appendStringInfo(str, " %u", node->dupOperators[i]);
366 WRITE_LONG_FIELD(numGroups);
370 _outBitmapAnd(StringInfo str, BitmapAnd *node)
372 WRITE_NODE_TYPE("BITMAPAND");
374 _outPlanInfo(str, (Plan *) node);
376 WRITE_NODE_FIELD(bitmapplans);
380 _outBitmapOr(StringInfo str, BitmapOr *node)
382 WRITE_NODE_TYPE("BITMAPOR");
384 _outPlanInfo(str, (Plan *) node);
386 WRITE_NODE_FIELD(bitmapplans);
390 _outScan(StringInfo str, Scan *node)
392 WRITE_NODE_TYPE("SCAN");
394 _outScanInfo(str, (Scan *) node);
398 _outSeqScan(StringInfo str, SeqScan *node)
400 WRITE_NODE_TYPE("SEQSCAN");
402 _outScanInfo(str, (Scan *) node);
406 _outIndexScan(StringInfo str, IndexScan *node)
408 WRITE_NODE_TYPE("INDEXSCAN");
410 _outScanInfo(str, (Scan *) node);
412 WRITE_OID_FIELD(indexid);
413 WRITE_NODE_FIELD(indexqual);
414 WRITE_NODE_FIELD(indexqualorig);
415 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
419 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
421 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
423 _outScanInfo(str, (Scan *) node);
425 WRITE_OID_FIELD(indexid);
426 WRITE_NODE_FIELD(indexqual);
427 WRITE_NODE_FIELD(indexqualorig);
431 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
433 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
435 _outScanInfo(str, (Scan *) node);
437 WRITE_NODE_FIELD(bitmapqualorig);
441 _outTidScan(StringInfo str, TidScan *node)
443 WRITE_NODE_TYPE("TIDSCAN");
445 _outScanInfo(str, (Scan *) node);
447 WRITE_NODE_FIELD(tidquals);
451 _outSubqueryScan(StringInfo str, SubqueryScan *node)
453 WRITE_NODE_TYPE("SUBQUERYSCAN");
455 _outScanInfo(str, (Scan *) node);
457 WRITE_NODE_FIELD(subplan);
458 WRITE_NODE_FIELD(subrtable);
459 WRITE_NODE_FIELD(subrowmark);
463 _outFunctionScan(StringInfo str, FunctionScan *node)
465 WRITE_NODE_TYPE("FUNCTIONSCAN");
467 _outScanInfo(str, (Scan *) node);
469 WRITE_NODE_FIELD(funcexpr);
470 WRITE_NODE_FIELD(funccolnames);
471 WRITE_NODE_FIELD(funccoltypes);
472 WRITE_NODE_FIELD(funccoltypmods);
476 _outValuesScan(StringInfo str, ValuesScan *node)
478 WRITE_NODE_TYPE("VALUESSCAN");
480 _outScanInfo(str, (Scan *) node);
482 WRITE_NODE_FIELD(values_lists);
486 _outCteScan(StringInfo str, CteScan *node)
488 WRITE_NODE_TYPE("CTESCAN");
490 _outScanInfo(str, (Scan *) node);
492 WRITE_INT_FIELD(ctePlanId);
493 WRITE_INT_FIELD(cteParam);
497 _outWorkTableScan(StringInfo str, WorkTableScan *node)
499 WRITE_NODE_TYPE("WORKTABLESCAN");
501 _outScanInfo(str, (Scan *) node);
503 WRITE_INT_FIELD(wtParam);
507 _outJoin(StringInfo str, Join *node)
509 WRITE_NODE_TYPE("JOIN");
511 _outJoinPlanInfo(str, (Join *) node);
515 _outNestLoop(StringInfo str, NestLoop *node)
517 WRITE_NODE_TYPE("NESTLOOP");
519 _outJoinPlanInfo(str, (Join *) node);
521 WRITE_NODE_FIELD(nestParams);
525 _outMergeJoin(StringInfo str, MergeJoin *node)
530 WRITE_NODE_TYPE("MERGEJOIN");
532 _outJoinPlanInfo(str, (Join *) node);
534 WRITE_NODE_FIELD(mergeclauses);
536 numCols = list_length(node->mergeclauses);
538 appendStringInfo(str, " :mergeFamilies");
539 for (i = 0; i < numCols; i++)
540 appendStringInfo(str, " %u", node->mergeFamilies[i]);
542 appendStringInfo(str, " :mergeStrategies");
543 for (i = 0; i < numCols; i++)
544 appendStringInfo(str, " %d", node->mergeStrategies[i]);
546 appendStringInfo(str, " :mergeNullsFirst");
547 for (i = 0; i < numCols; i++)
548 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
552 _outHashJoin(StringInfo str, HashJoin *node)
554 WRITE_NODE_TYPE("HASHJOIN");
556 _outJoinPlanInfo(str, (Join *) node);
558 WRITE_NODE_FIELD(hashclauses);
562 _outAgg(StringInfo str, Agg *node)
566 WRITE_NODE_TYPE("AGG");
568 _outPlanInfo(str, (Plan *) node);
570 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
571 WRITE_INT_FIELD(numCols);
573 appendStringInfo(str, " :grpColIdx");
574 for (i = 0; i < node->numCols; i++)
575 appendStringInfo(str, " %d", node->grpColIdx[i]);
577 appendStringInfo(str, " :grpOperators");
578 for (i = 0; i < node->numCols; i++)
579 appendStringInfo(str, " %u", node->grpOperators[i]);
581 WRITE_LONG_FIELD(numGroups);
585 _outWindowAgg(StringInfo str, WindowAgg *node)
589 WRITE_NODE_TYPE("WINDOWAGG");
591 _outPlanInfo(str, (Plan *) node);
593 WRITE_UINT_FIELD(winref);
594 WRITE_INT_FIELD(partNumCols);
596 appendStringInfo(str, " :partColIdx");
597 for (i = 0; i < node->partNumCols; i++)
598 appendStringInfo(str, " %d", node->partColIdx[i]);
600 appendStringInfo(str, " :partOperations");
601 for (i = 0; i < node->partNumCols; i++)
602 appendStringInfo(str, " %u", node->partOperators[i]);
604 WRITE_INT_FIELD(ordNumCols);
606 appendStringInfo(str, " :ordColIdx");
607 for (i = 0; i < node->ordNumCols; i++)
608 appendStringInfo(str, " %d", node->ordColIdx[i]);
610 appendStringInfo(str, " :ordOperations");
611 for (i = 0; i < node->ordNumCols; i++)
612 appendStringInfo(str, " %u", node->ordOperators[i]);
614 WRITE_INT_FIELD(frameOptions);
615 WRITE_NODE_FIELD(startOffset);
616 WRITE_NODE_FIELD(endOffset);
620 _outGroup(StringInfo str, Group *node)
624 WRITE_NODE_TYPE("GROUP");
626 _outPlanInfo(str, (Plan *) node);
628 WRITE_INT_FIELD(numCols);
630 appendStringInfo(str, " :grpColIdx");
631 for (i = 0; i < node->numCols; i++)
632 appendStringInfo(str, " %d", node->grpColIdx[i]);
634 appendStringInfo(str, " :grpOperators");
635 for (i = 0; i < node->numCols; i++)
636 appendStringInfo(str, " %u", node->grpOperators[i]);
640 _outMaterial(StringInfo str, Material *node)
642 WRITE_NODE_TYPE("MATERIAL");
644 _outPlanInfo(str, (Plan *) node);
648 _outSort(StringInfo str, Sort *node)
652 WRITE_NODE_TYPE("SORT");
654 _outPlanInfo(str, (Plan *) node);
656 WRITE_INT_FIELD(numCols);
658 appendStringInfo(str, " :sortColIdx");
659 for (i = 0; i < node->numCols; i++)
660 appendStringInfo(str, " %d", node->sortColIdx[i]);
662 appendStringInfo(str, " :sortOperators");
663 for (i = 0; i < node->numCols; i++)
664 appendStringInfo(str, " %u", node->sortOperators[i]);
666 appendStringInfo(str, " :nullsFirst");
667 for (i = 0; i < node->numCols; i++)
668 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
672 _outUnique(StringInfo str, Unique *node)
676 WRITE_NODE_TYPE("UNIQUE");
678 _outPlanInfo(str, (Plan *) node);
680 WRITE_INT_FIELD(numCols);
682 appendStringInfo(str, " :uniqColIdx");
683 for (i = 0; i < node->numCols; i++)
684 appendStringInfo(str, " %d", node->uniqColIdx[i]);
686 appendStringInfo(str, " :uniqOperators");
687 for (i = 0; i < node->numCols; i++)
688 appendStringInfo(str, " %u", node->uniqOperators[i]);
692 _outHash(StringInfo str, Hash *node)
694 WRITE_NODE_TYPE("HASH");
696 _outPlanInfo(str, (Plan *) node);
698 WRITE_OID_FIELD(skewTable);
699 WRITE_INT_FIELD(skewColumn);
700 WRITE_BOOL_FIELD(skewInherit);
701 WRITE_OID_FIELD(skewColType);
702 WRITE_INT_FIELD(skewColTypmod);
706 _outSetOp(StringInfo str, SetOp *node)
710 WRITE_NODE_TYPE("SETOP");
712 _outPlanInfo(str, (Plan *) node);
714 WRITE_ENUM_FIELD(cmd, SetOpCmd);
715 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
716 WRITE_INT_FIELD(numCols);
718 appendStringInfo(str, " :dupColIdx");
719 for (i = 0; i < node->numCols; i++)
720 appendStringInfo(str, " %d", node->dupColIdx[i]);
722 appendStringInfo(str, " :dupOperators");
723 for (i = 0; i < node->numCols; i++)
724 appendStringInfo(str, " %u", node->dupOperators[i]);
726 WRITE_INT_FIELD(flagColIdx);
727 WRITE_INT_FIELD(firstFlag);
728 WRITE_LONG_FIELD(numGroups);
732 _outLockRows(StringInfo str, LockRows *node)
734 WRITE_NODE_TYPE("LOCKROWS");
736 _outPlanInfo(str, (Plan *) node);
738 WRITE_NODE_FIELD(rowMarks);
739 WRITE_INT_FIELD(epqParam);
743 _outLimit(StringInfo str, Limit *node)
745 WRITE_NODE_TYPE("LIMIT");
747 _outPlanInfo(str, (Plan *) node);
749 WRITE_NODE_FIELD(limitOffset);
750 WRITE_NODE_FIELD(limitCount);
754 _outNestLoopParam(StringInfo str, NestLoopParam *node)
756 WRITE_NODE_TYPE("NESTLOOPPARAM");
758 WRITE_INT_FIELD(paramno);
759 WRITE_NODE_FIELD(paramval);
763 _outPlanRowMark(StringInfo str, PlanRowMark *node)
765 WRITE_NODE_TYPE("PLANROWMARK");
767 WRITE_UINT_FIELD(rti);
768 WRITE_UINT_FIELD(prti);
769 WRITE_ENUM_FIELD(markType, RowMarkType);
770 WRITE_BOOL_FIELD(noWait);
771 WRITE_BOOL_FIELD(isParent);
772 WRITE_INT_FIELD(ctidAttNo);
773 WRITE_INT_FIELD(toidAttNo);
774 WRITE_INT_FIELD(wholeAttNo);
778 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
780 WRITE_NODE_TYPE("PLANINVALITEM");
782 WRITE_INT_FIELD(cacheId);
783 appendStringInfo(str, " :tupleId (%u,%u)",
784 ItemPointerGetBlockNumber(&node->tupleId),
785 ItemPointerGetOffsetNumber(&node->tupleId));
788 /*****************************************************************************
790 * Stuff from primnodes.h.
792 *****************************************************************************/
795 _outAlias(StringInfo str, Alias *node)
797 WRITE_NODE_TYPE("ALIAS");
799 WRITE_STRING_FIELD(aliasname);
800 WRITE_NODE_FIELD(colnames);
804 _outRangeVar(StringInfo str, RangeVar *node)
806 WRITE_NODE_TYPE("RANGEVAR");
809 * we deliberately ignore catalogname here, since it is presently not
810 * semantically meaningful
812 WRITE_STRING_FIELD(schemaname);
813 WRITE_STRING_FIELD(relname);
814 WRITE_ENUM_FIELD(inhOpt, InhOption);
815 WRITE_BOOL_FIELD(istemp);
816 WRITE_NODE_FIELD(alias);
817 WRITE_LOCATION_FIELD(location);
821 _outIntoClause(StringInfo str, IntoClause *node)
823 WRITE_NODE_TYPE("INTOCLAUSE");
825 WRITE_NODE_FIELD(rel);
826 WRITE_NODE_FIELD(colNames);
827 WRITE_NODE_FIELD(options);
828 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
829 WRITE_STRING_FIELD(tableSpaceName);
833 _outVar(StringInfo str, Var *node)
835 WRITE_NODE_TYPE("VAR");
837 WRITE_UINT_FIELD(varno);
838 WRITE_INT_FIELD(varattno);
839 WRITE_OID_FIELD(vartype);
840 WRITE_INT_FIELD(vartypmod);
841 WRITE_UINT_FIELD(varlevelsup);
842 WRITE_UINT_FIELD(varnoold);
843 WRITE_INT_FIELD(varoattno);
844 WRITE_LOCATION_FIELD(location);
848 _outConst(StringInfo str, Const *node)
850 WRITE_NODE_TYPE("CONST");
852 WRITE_OID_FIELD(consttype);
853 WRITE_INT_FIELD(consttypmod);
854 WRITE_INT_FIELD(constlen);
855 WRITE_BOOL_FIELD(constbyval);
856 WRITE_BOOL_FIELD(constisnull);
857 WRITE_LOCATION_FIELD(location);
859 appendStringInfo(str, " :constvalue ");
860 if (node->constisnull)
861 appendStringInfo(str, "<>");
863 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
867 _outParam(StringInfo str, Param *node)
869 WRITE_NODE_TYPE("PARAM");
871 WRITE_ENUM_FIELD(paramkind, ParamKind);
872 WRITE_INT_FIELD(paramid);
873 WRITE_OID_FIELD(paramtype);
874 WRITE_INT_FIELD(paramtypmod);
875 WRITE_LOCATION_FIELD(location);
879 _outAggref(StringInfo str, Aggref *node)
881 WRITE_NODE_TYPE("AGGREF");
883 WRITE_OID_FIELD(aggfnoid);
884 WRITE_OID_FIELD(aggtype);
885 WRITE_NODE_FIELD(args);
886 WRITE_NODE_FIELD(aggorder);
887 WRITE_NODE_FIELD(aggdistinct);
888 WRITE_BOOL_FIELD(aggstar);
889 WRITE_UINT_FIELD(agglevelsup);
890 WRITE_LOCATION_FIELD(location);
894 _outWindowFunc(StringInfo str, WindowFunc *node)
896 WRITE_NODE_TYPE("WINDOWFUNC");
898 WRITE_OID_FIELD(winfnoid);
899 WRITE_OID_FIELD(wintype);
900 WRITE_NODE_FIELD(args);
901 WRITE_UINT_FIELD(winref);
902 WRITE_BOOL_FIELD(winstar);
903 WRITE_BOOL_FIELD(winagg);
904 WRITE_LOCATION_FIELD(location);
908 _outArrayRef(StringInfo str, ArrayRef *node)
910 WRITE_NODE_TYPE("ARRAYREF");
912 WRITE_OID_FIELD(refarraytype);
913 WRITE_OID_FIELD(refelemtype);
914 WRITE_INT_FIELD(reftypmod);
915 WRITE_NODE_FIELD(refupperindexpr);
916 WRITE_NODE_FIELD(reflowerindexpr);
917 WRITE_NODE_FIELD(refexpr);
918 WRITE_NODE_FIELD(refassgnexpr);
922 _outFuncExpr(StringInfo str, FuncExpr *node)
924 WRITE_NODE_TYPE("FUNCEXPR");
926 WRITE_OID_FIELD(funcid);
927 WRITE_OID_FIELD(funcresulttype);
928 WRITE_BOOL_FIELD(funcretset);
929 WRITE_ENUM_FIELD(funcformat, CoercionForm);
930 WRITE_NODE_FIELD(args);
931 WRITE_LOCATION_FIELD(location);
935 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
937 WRITE_NODE_TYPE("NAMEDARGEXPR");
939 WRITE_NODE_FIELD(arg);
940 WRITE_STRING_FIELD(name);
941 WRITE_INT_FIELD(argnumber);
942 WRITE_LOCATION_FIELD(location);
946 _outOpExpr(StringInfo str, OpExpr *node)
948 WRITE_NODE_TYPE("OPEXPR");
950 WRITE_OID_FIELD(opno);
951 WRITE_OID_FIELD(opfuncid);
952 WRITE_OID_FIELD(opresulttype);
953 WRITE_BOOL_FIELD(opretset);
954 WRITE_NODE_FIELD(args);
955 WRITE_LOCATION_FIELD(location);
959 _outDistinctExpr(StringInfo str, DistinctExpr *node)
961 WRITE_NODE_TYPE("DISTINCTEXPR");
963 WRITE_OID_FIELD(opno);
964 WRITE_OID_FIELD(opfuncid);
965 WRITE_OID_FIELD(opresulttype);
966 WRITE_BOOL_FIELD(opretset);
967 WRITE_NODE_FIELD(args);
968 WRITE_LOCATION_FIELD(location);
972 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
974 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
976 WRITE_OID_FIELD(opno);
977 WRITE_OID_FIELD(opfuncid);
978 WRITE_BOOL_FIELD(useOr);
979 WRITE_NODE_FIELD(args);
980 WRITE_LOCATION_FIELD(location);
984 _outBoolExpr(StringInfo str, BoolExpr *node)
988 WRITE_NODE_TYPE("BOOLEXPR");
990 /* do-it-yourself enum representation */
991 switch (node->boolop)
1003 appendStringInfo(str, " :boolop ");
1004 _outToken(str, opstr);
1006 WRITE_NODE_FIELD(args);
1007 WRITE_LOCATION_FIELD(location);
1011 _outSubLink(StringInfo str, SubLink *node)
1013 WRITE_NODE_TYPE("SUBLINK");
1015 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1016 WRITE_NODE_FIELD(testexpr);
1017 WRITE_NODE_FIELD(operName);
1018 WRITE_NODE_FIELD(subselect);
1019 WRITE_LOCATION_FIELD(location);
1023 _outSubPlan(StringInfo str, SubPlan *node)
1025 WRITE_NODE_TYPE("SUBPLAN");
1027 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1028 WRITE_NODE_FIELD(testexpr);
1029 WRITE_NODE_FIELD(paramIds);
1030 WRITE_INT_FIELD(plan_id);
1031 WRITE_STRING_FIELD(plan_name);
1032 WRITE_OID_FIELD(firstColType);
1033 WRITE_INT_FIELD(firstColTypmod);
1034 WRITE_BOOL_FIELD(useHashTable);
1035 WRITE_BOOL_FIELD(unknownEqFalse);
1036 WRITE_NODE_FIELD(setParam);
1037 WRITE_NODE_FIELD(parParam);
1038 WRITE_NODE_FIELD(args);
1039 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1040 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1044 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1046 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1048 WRITE_NODE_FIELD(subplans);
1052 _outFieldSelect(StringInfo str, FieldSelect *node)
1054 WRITE_NODE_TYPE("FIELDSELECT");
1056 WRITE_NODE_FIELD(arg);
1057 WRITE_INT_FIELD(fieldnum);
1058 WRITE_OID_FIELD(resulttype);
1059 WRITE_INT_FIELD(resulttypmod);
1063 _outFieldStore(StringInfo str, FieldStore *node)
1065 WRITE_NODE_TYPE("FIELDSTORE");
1067 WRITE_NODE_FIELD(arg);
1068 WRITE_NODE_FIELD(newvals);
1069 WRITE_NODE_FIELD(fieldnums);
1070 WRITE_OID_FIELD(resulttype);
1074 _outRelabelType(StringInfo str, RelabelType *node)
1076 WRITE_NODE_TYPE("RELABELTYPE");
1078 WRITE_NODE_FIELD(arg);
1079 WRITE_OID_FIELD(resulttype);
1080 WRITE_INT_FIELD(resulttypmod);
1081 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1082 WRITE_LOCATION_FIELD(location);
1086 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1088 WRITE_NODE_TYPE("COERCEVIAIO");
1090 WRITE_NODE_FIELD(arg);
1091 WRITE_OID_FIELD(resulttype);
1092 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1093 WRITE_LOCATION_FIELD(location);
1097 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1099 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1101 WRITE_NODE_FIELD(arg);
1102 WRITE_OID_FIELD(elemfuncid);
1103 WRITE_OID_FIELD(resulttype);
1104 WRITE_INT_FIELD(resulttypmod);
1105 WRITE_BOOL_FIELD(isExplicit);
1106 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1107 WRITE_LOCATION_FIELD(location);
1111 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1113 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1115 WRITE_NODE_FIELD(arg);
1116 WRITE_OID_FIELD(resulttype);
1117 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1118 WRITE_LOCATION_FIELD(location);
1122 _outCaseExpr(StringInfo str, CaseExpr *node)
1124 WRITE_NODE_TYPE("CASE");
1126 WRITE_OID_FIELD(casetype);
1127 WRITE_NODE_FIELD(arg);
1128 WRITE_NODE_FIELD(args);
1129 WRITE_NODE_FIELD(defresult);
1130 WRITE_LOCATION_FIELD(location);
1134 _outCaseWhen(StringInfo str, CaseWhen *node)
1136 WRITE_NODE_TYPE("WHEN");
1138 WRITE_NODE_FIELD(expr);
1139 WRITE_NODE_FIELD(result);
1140 WRITE_LOCATION_FIELD(location);
1144 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1146 WRITE_NODE_TYPE("CASETESTEXPR");
1148 WRITE_OID_FIELD(typeId);
1149 WRITE_INT_FIELD(typeMod);
1153 _outArrayExpr(StringInfo str, ArrayExpr *node)
1155 WRITE_NODE_TYPE("ARRAY");
1157 WRITE_OID_FIELD(array_typeid);
1158 WRITE_OID_FIELD(element_typeid);
1159 WRITE_NODE_FIELD(elements);
1160 WRITE_BOOL_FIELD(multidims);
1161 WRITE_LOCATION_FIELD(location);
1165 _outRowExpr(StringInfo str, RowExpr *node)
1167 WRITE_NODE_TYPE("ROW");
1169 WRITE_NODE_FIELD(args);
1170 WRITE_OID_FIELD(row_typeid);
1171 WRITE_ENUM_FIELD(row_format, CoercionForm);
1172 WRITE_NODE_FIELD(colnames);
1173 WRITE_LOCATION_FIELD(location);
1177 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1179 WRITE_NODE_TYPE("ROWCOMPARE");
1181 WRITE_ENUM_FIELD(rctype, RowCompareType);
1182 WRITE_NODE_FIELD(opnos);
1183 WRITE_NODE_FIELD(opfamilies);
1184 WRITE_NODE_FIELD(largs);
1185 WRITE_NODE_FIELD(rargs);
1189 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1191 WRITE_NODE_TYPE("COALESCE");
1193 WRITE_OID_FIELD(coalescetype);
1194 WRITE_NODE_FIELD(args);
1195 WRITE_LOCATION_FIELD(location);
1199 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1201 WRITE_NODE_TYPE("MINMAX");
1203 WRITE_OID_FIELD(minmaxtype);
1204 WRITE_ENUM_FIELD(op, MinMaxOp);
1205 WRITE_NODE_FIELD(args);
1206 WRITE_LOCATION_FIELD(location);
1210 _outXmlExpr(StringInfo str, XmlExpr *node)
1212 WRITE_NODE_TYPE("XMLEXPR");
1214 WRITE_ENUM_FIELD(op, XmlExprOp);
1215 WRITE_STRING_FIELD(name);
1216 WRITE_NODE_FIELD(named_args);
1217 WRITE_NODE_FIELD(arg_names);
1218 WRITE_NODE_FIELD(args);
1219 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1220 WRITE_OID_FIELD(type);
1221 WRITE_INT_FIELD(typmod);
1222 WRITE_LOCATION_FIELD(location);
1226 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1228 WRITE_NODE_TYPE("NULLIFEXPR");
1230 WRITE_OID_FIELD(opno);
1231 WRITE_OID_FIELD(opfuncid);
1232 WRITE_OID_FIELD(opresulttype);
1233 WRITE_BOOL_FIELD(opretset);
1234 WRITE_NODE_FIELD(args);
1235 WRITE_LOCATION_FIELD(location);
1239 _outNullTest(StringInfo str, NullTest *node)
1241 WRITE_NODE_TYPE("NULLTEST");
1243 WRITE_NODE_FIELD(arg);
1244 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1245 WRITE_BOOL_FIELD(argisrow);
1249 _outBooleanTest(StringInfo str, BooleanTest *node)
1251 WRITE_NODE_TYPE("BOOLEANTEST");
1253 WRITE_NODE_FIELD(arg);
1254 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1258 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1260 WRITE_NODE_TYPE("COERCETODOMAIN");
1262 WRITE_NODE_FIELD(arg);
1263 WRITE_OID_FIELD(resulttype);
1264 WRITE_INT_FIELD(resulttypmod);
1265 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1266 WRITE_LOCATION_FIELD(location);
1270 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1272 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1274 WRITE_OID_FIELD(typeId);
1275 WRITE_INT_FIELD(typeMod);
1276 WRITE_LOCATION_FIELD(location);
1280 _outSetToDefault(StringInfo str, SetToDefault *node)
1282 WRITE_NODE_TYPE("SETTODEFAULT");
1284 WRITE_OID_FIELD(typeId);
1285 WRITE_INT_FIELD(typeMod);
1286 WRITE_LOCATION_FIELD(location);
1290 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1292 WRITE_NODE_TYPE("CURRENTOFEXPR");
1294 WRITE_UINT_FIELD(cvarno);
1295 WRITE_STRING_FIELD(cursor_name);
1296 WRITE_INT_FIELD(cursor_param);
1300 _outTargetEntry(StringInfo str, TargetEntry *node)
1302 WRITE_NODE_TYPE("TARGETENTRY");
1304 WRITE_NODE_FIELD(expr);
1305 WRITE_INT_FIELD(resno);
1306 WRITE_STRING_FIELD(resname);
1307 WRITE_UINT_FIELD(ressortgroupref);
1308 WRITE_OID_FIELD(resorigtbl);
1309 WRITE_INT_FIELD(resorigcol);
1310 WRITE_BOOL_FIELD(resjunk);
1314 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1316 WRITE_NODE_TYPE("RANGETBLREF");
1318 WRITE_INT_FIELD(rtindex);
1322 _outJoinExpr(StringInfo str, JoinExpr *node)
1324 WRITE_NODE_TYPE("JOINEXPR");
1326 WRITE_ENUM_FIELD(jointype, JoinType);
1327 WRITE_BOOL_FIELD(isNatural);
1328 WRITE_NODE_FIELD(larg);
1329 WRITE_NODE_FIELD(rarg);
1330 WRITE_NODE_FIELD(usingClause);
1331 WRITE_NODE_FIELD(quals);
1332 WRITE_NODE_FIELD(alias);
1333 WRITE_INT_FIELD(rtindex);
1337 _outFromExpr(StringInfo str, FromExpr *node)
1339 WRITE_NODE_TYPE("FROMEXPR");
1341 WRITE_NODE_FIELD(fromlist);
1342 WRITE_NODE_FIELD(quals);
1345 /*****************************************************************************
1347 * Stuff from relation.h.
1349 *****************************************************************************/
1352 * print the basic stuff of all nodes that inherit from Path
1354 * Note we do NOT print the parent, else we'd be in infinite recursion
1357 _outPathInfo(StringInfo str, Path *node)
1359 WRITE_ENUM_FIELD(pathtype, NodeTag);
1360 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1361 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1362 WRITE_NODE_FIELD(pathkeys);
1366 * print the basic stuff of all nodes that inherit from JoinPath
1369 _outJoinPathInfo(StringInfo str, JoinPath *node)
1371 _outPathInfo(str, (Path *) node);
1373 WRITE_ENUM_FIELD(jointype, JoinType);
1374 WRITE_NODE_FIELD(outerjoinpath);
1375 WRITE_NODE_FIELD(innerjoinpath);
1376 WRITE_NODE_FIELD(joinrestrictinfo);
1380 _outPath(StringInfo str, Path *node)
1382 WRITE_NODE_TYPE("PATH");
1384 _outPathInfo(str, (Path *) node);
1388 _outIndexPath(StringInfo str, IndexPath *node)
1390 WRITE_NODE_TYPE("INDEXPATH");
1392 _outPathInfo(str, (Path *) node);
1394 WRITE_NODE_FIELD(indexinfo);
1395 WRITE_NODE_FIELD(indexclauses);
1396 WRITE_NODE_FIELD(indexquals);
1397 WRITE_BOOL_FIELD(isjoininner);
1398 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1399 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1400 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1401 WRITE_FLOAT_FIELD(rows, "%.0f");
1405 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1407 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1409 _outPathInfo(str, (Path *) node);
1411 WRITE_NODE_FIELD(bitmapqual);
1412 WRITE_BOOL_FIELD(isjoininner);
1413 WRITE_FLOAT_FIELD(rows, "%.0f");
1417 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1419 WRITE_NODE_TYPE("BITMAPANDPATH");
1421 _outPathInfo(str, (Path *) node);
1423 WRITE_NODE_FIELD(bitmapquals);
1424 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1428 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1430 WRITE_NODE_TYPE("BITMAPORPATH");
1432 _outPathInfo(str, (Path *) node);
1434 WRITE_NODE_FIELD(bitmapquals);
1435 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1439 _outTidPath(StringInfo str, TidPath *node)
1441 WRITE_NODE_TYPE("TIDPATH");
1443 _outPathInfo(str, (Path *) node);
1445 WRITE_NODE_FIELD(tidquals);
1449 _outAppendPath(StringInfo str, AppendPath *node)
1451 WRITE_NODE_TYPE("APPENDPATH");
1453 _outPathInfo(str, (Path *) node);
1455 WRITE_NODE_FIELD(subpaths);
1459 _outResultPath(StringInfo str, ResultPath *node)
1461 WRITE_NODE_TYPE("RESULTPATH");
1463 _outPathInfo(str, (Path *) node);
1465 WRITE_NODE_FIELD(quals);
1469 _outMaterialPath(StringInfo str, MaterialPath *node)
1471 WRITE_NODE_TYPE("MATERIALPATH");
1473 _outPathInfo(str, (Path *) node);
1475 WRITE_NODE_FIELD(subpath);
1479 _outUniquePath(StringInfo str, UniquePath *node)
1481 WRITE_NODE_TYPE("UNIQUEPATH");
1483 _outPathInfo(str, (Path *) node);
1485 WRITE_NODE_FIELD(subpath);
1486 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1487 WRITE_NODE_FIELD(in_operators);
1488 WRITE_NODE_FIELD(uniq_exprs);
1489 WRITE_FLOAT_FIELD(rows, "%.0f");
1493 _outNestPath(StringInfo str, NestPath *node)
1495 WRITE_NODE_TYPE("NESTPATH");
1497 _outJoinPathInfo(str, (JoinPath *) node);
1501 _outMergePath(StringInfo str, MergePath *node)
1503 WRITE_NODE_TYPE("MERGEPATH");
1505 _outJoinPathInfo(str, (JoinPath *) node);
1507 WRITE_NODE_FIELD(path_mergeclauses);
1508 WRITE_NODE_FIELD(outersortkeys);
1509 WRITE_NODE_FIELD(innersortkeys);
1510 WRITE_BOOL_FIELD(materialize_inner);
1514 _outHashPath(StringInfo str, HashPath *node)
1516 WRITE_NODE_TYPE("HASHPATH");
1518 _outJoinPathInfo(str, (JoinPath *) node);
1520 WRITE_NODE_FIELD(path_hashclauses);
1521 WRITE_INT_FIELD(num_batches);
1525 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1527 WRITE_NODE_TYPE("PLANNERGLOBAL");
1529 /* NB: this isn't a complete set of fields */
1530 WRITE_NODE_FIELD(paramlist);
1531 WRITE_NODE_FIELD(subplans);
1532 WRITE_NODE_FIELD(subrtables);
1533 WRITE_NODE_FIELD(subrowmarks);
1534 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1535 WRITE_NODE_FIELD(finalrtable);
1536 WRITE_NODE_FIELD(finalrowmarks);
1537 WRITE_NODE_FIELD(relationOids);
1538 WRITE_NODE_FIELD(invalItems);
1539 WRITE_UINT_FIELD(lastPHId);
1540 WRITE_BOOL_FIELD(transientPlan);
1544 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1546 WRITE_NODE_TYPE("PLANNERINFO");
1548 /* NB: this isn't a complete set of fields */
1549 WRITE_NODE_FIELD(parse);
1550 WRITE_NODE_FIELD(glob);
1551 WRITE_UINT_FIELD(query_level);
1552 WRITE_NODE_FIELD(join_rel_list);
1553 WRITE_INT_FIELD(join_cur_level);
1554 WRITE_NODE_FIELD(resultRelations);
1555 WRITE_NODE_FIELD(init_plans);
1556 WRITE_NODE_FIELD(cte_plan_ids);
1557 WRITE_NODE_FIELD(eq_classes);
1558 WRITE_NODE_FIELD(canon_pathkeys);
1559 WRITE_NODE_FIELD(left_join_clauses);
1560 WRITE_NODE_FIELD(right_join_clauses);
1561 WRITE_NODE_FIELD(full_join_clauses);
1562 WRITE_NODE_FIELD(join_info_list);
1563 WRITE_NODE_FIELD(append_rel_list);
1564 WRITE_NODE_FIELD(rowMarks);
1565 WRITE_NODE_FIELD(placeholder_list);
1566 WRITE_NODE_FIELD(query_pathkeys);
1567 WRITE_NODE_FIELD(group_pathkeys);
1568 WRITE_NODE_FIELD(window_pathkeys);
1569 WRITE_NODE_FIELD(distinct_pathkeys);
1570 WRITE_NODE_FIELD(sort_pathkeys);
1571 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1572 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1573 WRITE_BOOL_FIELD(hasInheritedTarget);
1574 WRITE_BOOL_FIELD(hasJoinRTEs);
1575 WRITE_BOOL_FIELD(hasHavingQual);
1576 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1577 WRITE_BOOL_FIELD(hasRecursion);
1578 WRITE_INT_FIELD(wt_param_id);
1579 WRITE_BITMAPSET_FIELD(curOuterRels);
1580 WRITE_NODE_FIELD(curOuterParams);
1584 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1586 WRITE_NODE_TYPE("RELOPTINFO");
1588 /* NB: this isn't a complete set of fields */
1589 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1590 WRITE_BITMAPSET_FIELD(relids);
1591 WRITE_FLOAT_FIELD(rows, "%.0f");
1592 WRITE_INT_FIELD(width);
1593 WRITE_NODE_FIELD(reltargetlist);
1594 WRITE_NODE_FIELD(pathlist);
1595 WRITE_NODE_FIELD(cheapest_startup_path);
1596 WRITE_NODE_FIELD(cheapest_total_path);
1597 WRITE_NODE_FIELD(cheapest_unique_path);
1598 WRITE_UINT_FIELD(relid);
1599 WRITE_UINT_FIELD(reltablespace);
1600 WRITE_ENUM_FIELD(rtekind, RTEKind);
1601 WRITE_INT_FIELD(min_attr);
1602 WRITE_INT_FIELD(max_attr);
1603 WRITE_NODE_FIELD(indexlist);
1604 WRITE_UINT_FIELD(pages);
1605 WRITE_FLOAT_FIELD(tuples, "%.0f");
1606 WRITE_NODE_FIELD(subplan);
1607 WRITE_NODE_FIELD(subrtable);
1608 WRITE_NODE_FIELD(subrowmark);
1609 WRITE_NODE_FIELD(baserestrictinfo);
1610 WRITE_NODE_FIELD(joininfo);
1611 WRITE_BOOL_FIELD(has_eclass_joins);
1612 WRITE_BITMAPSET_FIELD(index_outer_relids);
1613 WRITE_NODE_FIELD(index_inner_paths);
1617 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1619 WRITE_NODE_TYPE("INDEXOPTINFO");
1621 /* NB: this isn't a complete set of fields */
1622 WRITE_OID_FIELD(indexoid);
1623 /* Do NOT print rel field, else infinite recursion */
1624 WRITE_UINT_FIELD(pages);
1625 WRITE_FLOAT_FIELD(tuples, "%.0f");
1626 WRITE_INT_FIELD(ncolumns);
1627 WRITE_NODE_FIELD(indexprs);
1628 WRITE_NODE_FIELD(indpred);
1629 WRITE_BOOL_FIELD(predOK);
1630 WRITE_BOOL_FIELD(unique);
1634 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1637 * To simplify reading, we just chase up to the topmost merged EC and
1638 * print that, without bothering to show the merge-ees separately.
1640 while (node->ec_merged)
1641 node = node->ec_merged;
1643 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1645 WRITE_NODE_FIELD(ec_opfamilies);
1646 WRITE_NODE_FIELD(ec_members);
1647 WRITE_NODE_FIELD(ec_sources);
1648 WRITE_NODE_FIELD(ec_derives);
1649 WRITE_BITMAPSET_FIELD(ec_relids);
1650 WRITE_BOOL_FIELD(ec_has_const);
1651 WRITE_BOOL_FIELD(ec_has_volatile);
1652 WRITE_BOOL_FIELD(ec_below_outer_join);
1653 WRITE_BOOL_FIELD(ec_broken);
1654 WRITE_UINT_FIELD(ec_sortref);
1658 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1660 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1662 WRITE_NODE_FIELD(em_expr);
1663 WRITE_BITMAPSET_FIELD(em_relids);
1664 WRITE_BOOL_FIELD(em_is_const);
1665 WRITE_BOOL_FIELD(em_is_child);
1666 WRITE_OID_FIELD(em_datatype);
1670 _outPathKey(StringInfo str, PathKey *node)
1672 WRITE_NODE_TYPE("PATHKEY");
1674 WRITE_NODE_FIELD(pk_eclass);
1675 WRITE_OID_FIELD(pk_opfamily);
1676 WRITE_INT_FIELD(pk_strategy);
1677 WRITE_BOOL_FIELD(pk_nulls_first);
1681 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1683 WRITE_NODE_TYPE("RESTRICTINFO");
1685 /* NB: this isn't a complete set of fields */
1686 WRITE_NODE_FIELD(clause);
1687 WRITE_BOOL_FIELD(is_pushed_down);
1688 WRITE_BOOL_FIELD(outerjoin_delayed);
1689 WRITE_BOOL_FIELD(can_join);
1690 WRITE_BOOL_FIELD(pseudoconstant);
1691 WRITE_BITMAPSET_FIELD(clause_relids);
1692 WRITE_BITMAPSET_FIELD(required_relids);
1693 WRITE_BITMAPSET_FIELD(nullable_relids);
1694 WRITE_BITMAPSET_FIELD(left_relids);
1695 WRITE_BITMAPSET_FIELD(right_relids);
1696 WRITE_NODE_FIELD(orclause);
1697 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1698 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1699 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1700 WRITE_NODE_FIELD(mergeopfamilies);
1701 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1702 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1703 WRITE_NODE_FIELD(left_em);
1704 WRITE_NODE_FIELD(right_em);
1705 WRITE_BOOL_FIELD(outer_is_left);
1706 WRITE_OID_FIELD(hashjoinoperator);
1710 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1712 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1713 WRITE_BITMAPSET_FIELD(other_relids);
1714 WRITE_BOOL_FIELD(isouterjoin);
1715 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1716 WRITE_NODE_FIELD(cheapest_total_innerpath);
1720 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1722 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1724 WRITE_NODE_FIELD(phexpr);
1725 WRITE_BITMAPSET_FIELD(phrels);
1726 WRITE_UINT_FIELD(phid);
1727 WRITE_UINT_FIELD(phlevelsup);
1731 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1733 WRITE_NODE_TYPE("SPECIALJOININFO");
1735 WRITE_BITMAPSET_FIELD(min_lefthand);
1736 WRITE_BITMAPSET_FIELD(min_righthand);
1737 WRITE_BITMAPSET_FIELD(syn_lefthand);
1738 WRITE_BITMAPSET_FIELD(syn_righthand);
1739 WRITE_ENUM_FIELD(jointype, JoinType);
1740 WRITE_BOOL_FIELD(lhs_strict);
1741 WRITE_BOOL_FIELD(delay_upper_joins);
1742 WRITE_NODE_FIELD(join_quals);
1746 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1748 WRITE_NODE_TYPE("APPENDRELINFO");
1750 WRITE_UINT_FIELD(parent_relid);
1751 WRITE_UINT_FIELD(child_relid);
1752 WRITE_OID_FIELD(parent_reltype);
1753 WRITE_OID_FIELD(child_reltype);
1754 WRITE_NODE_FIELD(translated_vars);
1755 WRITE_OID_FIELD(parent_reloid);
1759 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1761 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1763 WRITE_UINT_FIELD(phid);
1764 WRITE_NODE_FIELD(ph_var);
1765 WRITE_BITMAPSET_FIELD(ph_eval_at);
1766 WRITE_BITMAPSET_FIELD(ph_needed);
1767 WRITE_INT_FIELD(ph_width);
1771 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1773 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1775 WRITE_NODE_FIELD(item);
1776 WRITE_UINT_FIELD(abslevel);
1779 /*****************************************************************************
1781 * Stuff from parsenodes.h.
1783 *****************************************************************************/
1786 _outCreateStmt(StringInfo str, CreateStmt *node)
1788 WRITE_NODE_TYPE("CREATESTMT");
1790 WRITE_NODE_FIELD(relation);
1791 WRITE_NODE_FIELD(tableElts);
1792 WRITE_NODE_FIELD(inhRelations);
1793 WRITE_NODE_FIELD(ofTypename);
1794 WRITE_NODE_FIELD(constraints);
1795 WRITE_NODE_FIELD(options);
1796 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1797 WRITE_STRING_FIELD(tablespacename);
1798 WRITE_BOOL_FIELD(if_not_exists);
1802 _outIndexStmt(StringInfo str, IndexStmt *node)
1804 WRITE_NODE_TYPE("INDEXSTMT");
1806 WRITE_STRING_FIELD(idxname);
1807 WRITE_NODE_FIELD(relation);
1808 WRITE_STRING_FIELD(accessMethod);
1809 WRITE_STRING_FIELD(tableSpace);
1810 WRITE_NODE_FIELD(indexParams);
1811 WRITE_NODE_FIELD(options);
1812 WRITE_NODE_FIELD(whereClause);
1813 WRITE_NODE_FIELD(excludeOpNames);
1814 WRITE_BOOL_FIELD(unique);
1815 WRITE_BOOL_FIELD(primary);
1816 WRITE_BOOL_FIELD(isconstraint);
1817 WRITE_BOOL_FIELD(deferrable);
1818 WRITE_BOOL_FIELD(initdeferred);
1819 WRITE_BOOL_FIELD(concurrent);
1823 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1825 WRITE_NODE_TYPE("NOTIFY");
1827 WRITE_STRING_FIELD(conditionname);
1828 WRITE_STRING_FIELD(payload);
1832 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1834 WRITE_NODE_TYPE("DECLARECURSOR");
1836 WRITE_STRING_FIELD(portalname);
1837 WRITE_INT_FIELD(options);
1838 WRITE_NODE_FIELD(query);
1842 _outSelectStmt(StringInfo str, SelectStmt *node)
1844 WRITE_NODE_TYPE("SELECT");
1846 WRITE_NODE_FIELD(distinctClause);
1847 WRITE_NODE_FIELD(intoClause);
1848 WRITE_NODE_FIELD(targetList);
1849 WRITE_NODE_FIELD(fromClause);
1850 WRITE_NODE_FIELD(whereClause);
1851 WRITE_NODE_FIELD(groupClause);
1852 WRITE_NODE_FIELD(havingClause);
1853 WRITE_NODE_FIELD(windowClause);
1854 WRITE_NODE_FIELD(withClause);
1855 WRITE_NODE_FIELD(valuesLists);
1856 WRITE_NODE_FIELD(sortClause);
1857 WRITE_NODE_FIELD(limitOffset);
1858 WRITE_NODE_FIELD(limitCount);
1859 WRITE_NODE_FIELD(lockingClause);
1860 WRITE_ENUM_FIELD(op, SetOperation);
1861 WRITE_BOOL_FIELD(all);
1862 WRITE_NODE_FIELD(larg);
1863 WRITE_NODE_FIELD(rarg);
1867 _outFuncCall(StringInfo str, FuncCall *node)
1869 WRITE_NODE_TYPE("FUNCCALL");
1871 WRITE_NODE_FIELD(funcname);
1872 WRITE_NODE_FIELD(args);
1873 WRITE_NODE_FIELD(agg_order);
1874 WRITE_BOOL_FIELD(agg_star);
1875 WRITE_BOOL_FIELD(agg_distinct);
1876 WRITE_BOOL_FIELD(func_variadic);
1877 WRITE_NODE_FIELD(over);
1878 WRITE_LOCATION_FIELD(location);
1882 _outDefElem(StringInfo str, DefElem *node)
1884 WRITE_NODE_TYPE("DEFELEM");
1886 WRITE_STRING_FIELD(defnamespace);
1887 WRITE_STRING_FIELD(defname);
1888 WRITE_NODE_FIELD(arg);
1889 WRITE_ENUM_FIELD(defaction, DefElemAction);
1893 _outLockingClause(StringInfo str, LockingClause *node)
1895 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1897 WRITE_NODE_FIELD(lockedRels);
1898 WRITE_BOOL_FIELD(forUpdate);
1899 WRITE_BOOL_FIELD(noWait);
1903 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1905 WRITE_NODE_TYPE("XMLSERIALIZE");
1907 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1908 WRITE_NODE_FIELD(expr);
1909 WRITE_NODE_FIELD(typeName);
1910 WRITE_LOCATION_FIELD(location);
1914 _outColumnDef(StringInfo str, ColumnDef *node)
1916 WRITE_NODE_TYPE("COLUMNDEF");
1918 WRITE_STRING_FIELD(colname);
1919 WRITE_NODE_FIELD(typeName);
1920 WRITE_INT_FIELD(inhcount);
1921 WRITE_BOOL_FIELD(is_local);
1922 WRITE_BOOL_FIELD(is_not_null);
1923 WRITE_INT_FIELD(storage);
1924 WRITE_NODE_FIELD(raw_default);
1925 WRITE_NODE_FIELD(cooked_default);
1926 WRITE_NODE_FIELD(constraints);
1930 _outTypeName(StringInfo str, TypeName *node)
1932 WRITE_NODE_TYPE("TYPENAME");
1934 WRITE_NODE_FIELD(names);
1935 WRITE_OID_FIELD(typeOid);
1936 WRITE_BOOL_FIELD(setof);
1937 WRITE_BOOL_FIELD(pct_type);
1938 WRITE_NODE_FIELD(typmods);
1939 WRITE_INT_FIELD(typemod);
1940 WRITE_NODE_FIELD(arrayBounds);
1941 WRITE_LOCATION_FIELD(location);
1945 _outTypeCast(StringInfo str, TypeCast *node)
1947 WRITE_NODE_TYPE("TYPECAST");
1949 WRITE_NODE_FIELD(arg);
1950 WRITE_NODE_FIELD(typeName);
1951 WRITE_LOCATION_FIELD(location);
1955 _outIndexElem(StringInfo str, IndexElem *node)
1957 WRITE_NODE_TYPE("INDEXELEM");
1959 WRITE_STRING_FIELD(name);
1960 WRITE_NODE_FIELD(expr);
1961 WRITE_STRING_FIELD(indexcolname);
1962 WRITE_NODE_FIELD(opclass);
1963 WRITE_ENUM_FIELD(ordering, SortByDir);
1964 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1968 _outQuery(StringInfo str, Query *node)
1970 WRITE_NODE_TYPE("QUERY");
1972 WRITE_ENUM_FIELD(commandType, CmdType);
1973 WRITE_ENUM_FIELD(querySource, QuerySource);
1974 WRITE_BOOL_FIELD(canSetTag);
1977 * Hack to work around missing outfuncs routines for a lot of the
1978 * utility-statement node types. (The only one we actually *need* for
1979 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1980 * for the meantime do this to avoid getting lots of warnings when running
1981 * with debug_print_parse on.
1983 if (node->utilityStmt)
1985 switch (nodeTag(node->utilityStmt))
1990 case T_DeclareCursorStmt:
1991 WRITE_NODE_FIELD(utilityStmt);
1994 appendStringInfo(str, " :utilityStmt ?");
1999 appendStringInfo(str, " :utilityStmt <>");
2001 WRITE_INT_FIELD(resultRelation);
2002 WRITE_NODE_FIELD(intoClause);
2003 WRITE_BOOL_FIELD(hasAggs);
2004 WRITE_BOOL_FIELD(hasWindowFuncs);
2005 WRITE_BOOL_FIELD(hasSubLinks);
2006 WRITE_BOOL_FIELD(hasDistinctOn);
2007 WRITE_BOOL_FIELD(hasRecursive);
2008 WRITE_BOOL_FIELD(hasForUpdate);
2009 WRITE_NODE_FIELD(cteList);
2010 WRITE_NODE_FIELD(rtable);
2011 WRITE_NODE_FIELD(jointree);
2012 WRITE_NODE_FIELD(targetList);
2013 WRITE_NODE_FIELD(returningList);
2014 WRITE_NODE_FIELD(groupClause);
2015 WRITE_NODE_FIELD(havingQual);
2016 WRITE_NODE_FIELD(windowClause);
2017 WRITE_NODE_FIELD(distinctClause);
2018 WRITE_NODE_FIELD(sortClause);
2019 WRITE_NODE_FIELD(limitOffset);
2020 WRITE_NODE_FIELD(limitCount);
2021 WRITE_NODE_FIELD(rowMarks);
2022 WRITE_NODE_FIELD(setOperations);
2023 WRITE_NODE_FIELD(constraintDeps);
2027 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2029 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2031 WRITE_UINT_FIELD(tleSortGroupRef);
2032 WRITE_OID_FIELD(eqop);
2033 WRITE_OID_FIELD(sortop);
2034 WRITE_BOOL_FIELD(nulls_first);
2038 _outWindowClause(StringInfo str, WindowClause *node)
2040 WRITE_NODE_TYPE("WINDOWCLAUSE");
2042 WRITE_STRING_FIELD(name);
2043 WRITE_STRING_FIELD(refname);
2044 WRITE_NODE_FIELD(partitionClause);
2045 WRITE_NODE_FIELD(orderClause);
2046 WRITE_INT_FIELD(frameOptions);
2047 WRITE_NODE_FIELD(startOffset);
2048 WRITE_NODE_FIELD(endOffset);
2049 WRITE_UINT_FIELD(winref);
2050 WRITE_BOOL_FIELD(copiedOrder);
2054 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2056 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2058 WRITE_UINT_FIELD(rti);
2059 WRITE_BOOL_FIELD(forUpdate);
2060 WRITE_BOOL_FIELD(noWait);
2061 WRITE_BOOL_FIELD(pushedDown);
2065 _outWithClause(StringInfo str, WithClause *node)
2067 WRITE_NODE_TYPE("WITHCLAUSE");
2069 WRITE_NODE_FIELD(ctes);
2070 WRITE_BOOL_FIELD(recursive);
2071 WRITE_LOCATION_FIELD(location);
2075 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2077 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2079 WRITE_STRING_FIELD(ctename);
2080 WRITE_NODE_FIELD(aliascolnames);
2081 WRITE_NODE_FIELD(ctequery);
2082 WRITE_LOCATION_FIELD(location);
2083 WRITE_BOOL_FIELD(cterecursive);
2084 WRITE_INT_FIELD(cterefcount);
2085 WRITE_NODE_FIELD(ctecolnames);
2086 WRITE_NODE_FIELD(ctecoltypes);
2087 WRITE_NODE_FIELD(ctecoltypmods);
2091 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2093 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2095 WRITE_ENUM_FIELD(op, SetOperation);
2096 WRITE_BOOL_FIELD(all);
2097 WRITE_NODE_FIELD(larg);
2098 WRITE_NODE_FIELD(rarg);
2099 WRITE_NODE_FIELD(colTypes);
2100 WRITE_NODE_FIELD(colTypmods);
2101 WRITE_NODE_FIELD(groupClauses);
2105 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2107 WRITE_NODE_TYPE("RTE");
2109 /* put alias + eref first to make dump more legible */
2110 WRITE_NODE_FIELD(alias);
2111 WRITE_NODE_FIELD(eref);
2112 WRITE_ENUM_FIELD(rtekind, RTEKind);
2114 switch (node->rtekind)
2118 WRITE_OID_FIELD(relid);
2121 WRITE_NODE_FIELD(subquery);
2124 WRITE_ENUM_FIELD(jointype, JoinType);
2125 WRITE_NODE_FIELD(joinaliasvars);
2128 WRITE_NODE_FIELD(funcexpr);
2129 WRITE_NODE_FIELD(funccoltypes);
2130 WRITE_NODE_FIELD(funccoltypmods);
2133 WRITE_NODE_FIELD(values_lists);
2136 WRITE_STRING_FIELD(ctename);
2137 WRITE_UINT_FIELD(ctelevelsup);
2138 WRITE_BOOL_FIELD(self_reference);
2139 WRITE_NODE_FIELD(ctecoltypes);
2140 WRITE_NODE_FIELD(ctecoltypmods);
2143 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2147 WRITE_BOOL_FIELD(inh);
2148 WRITE_BOOL_FIELD(inFromCl);
2149 WRITE_UINT_FIELD(requiredPerms);
2150 WRITE_OID_FIELD(checkAsUser);
2151 WRITE_BITMAPSET_FIELD(selectedCols);
2152 WRITE_BITMAPSET_FIELD(modifiedCols);
2156 _outAExpr(StringInfo str, A_Expr *node)
2158 WRITE_NODE_TYPE("AEXPR");
2163 appendStringInfo(str, " ");
2164 WRITE_NODE_FIELD(name);
2167 appendStringInfo(str, " AND");
2170 appendStringInfo(str, " OR");
2173 appendStringInfo(str, " NOT");
2176 appendStringInfo(str, " ");
2177 WRITE_NODE_FIELD(name);
2178 appendStringInfo(str, " ANY ");
2181 appendStringInfo(str, " ");
2182 WRITE_NODE_FIELD(name);
2183 appendStringInfo(str, " ALL ");
2185 case AEXPR_DISTINCT:
2186 appendStringInfo(str, " DISTINCT ");
2187 WRITE_NODE_FIELD(name);
2190 appendStringInfo(str, " NULLIF ");
2191 WRITE_NODE_FIELD(name);
2194 appendStringInfo(str, " OF ");
2195 WRITE_NODE_FIELD(name);
2198 appendStringInfo(str, " IN ");
2199 WRITE_NODE_FIELD(name);
2202 appendStringInfo(str, " ??");
2206 WRITE_NODE_FIELD(lexpr);
2207 WRITE_NODE_FIELD(rexpr);
2208 WRITE_LOCATION_FIELD(location);
2212 _outValue(StringInfo str, Value *value)
2214 switch (value->type)
2217 appendStringInfo(str, "%ld", value->val.ival);
2222 * We assume the value is a valid numeric literal and so does not
2225 appendStringInfoString(str, value->val.str);
2228 appendStringInfoChar(str, '"');
2229 _outToken(str, value->val.str);
2230 appendStringInfoChar(str, '"');
2233 /* internal representation already has leading 'b' */
2234 appendStringInfoString(str, value->val.str);
2237 /* this is seen only within A_Const, not in transformed trees */
2238 appendStringInfoString(str, "NULL");
2241 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2247 _outColumnRef(StringInfo str, ColumnRef *node)
2249 WRITE_NODE_TYPE("COLUMNREF");
2251 WRITE_NODE_FIELD(fields);
2252 WRITE_LOCATION_FIELD(location);
2256 _outParamRef(StringInfo str, ParamRef *node)
2258 WRITE_NODE_TYPE("PARAMREF");
2260 WRITE_INT_FIELD(number);
2261 WRITE_LOCATION_FIELD(location);
2265 _outAConst(StringInfo str, A_Const *node)
2267 WRITE_NODE_TYPE("A_CONST");
2269 appendStringInfo(str, " :val ");
2270 _outValue(str, &(node->val));
2271 WRITE_LOCATION_FIELD(location);
2275 _outA_Star(StringInfo str, A_Star *node)
2277 WRITE_NODE_TYPE("A_STAR");
2281 _outA_Indices(StringInfo str, A_Indices *node)
2283 WRITE_NODE_TYPE("A_INDICES");
2285 WRITE_NODE_FIELD(lidx);
2286 WRITE_NODE_FIELD(uidx);
2290 _outA_Indirection(StringInfo str, A_Indirection *node)
2292 WRITE_NODE_TYPE("A_INDIRECTION");
2294 WRITE_NODE_FIELD(arg);
2295 WRITE_NODE_FIELD(indirection);
2299 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2301 WRITE_NODE_TYPE("A_ARRAYEXPR");
2303 WRITE_NODE_FIELD(elements);
2304 WRITE_LOCATION_FIELD(location);
2308 _outResTarget(StringInfo str, ResTarget *node)
2310 WRITE_NODE_TYPE("RESTARGET");
2312 WRITE_STRING_FIELD(name);
2313 WRITE_NODE_FIELD(indirection);
2314 WRITE_NODE_FIELD(val);
2315 WRITE_LOCATION_FIELD(location);
2319 _outSortBy(StringInfo str, SortBy *node)
2321 WRITE_NODE_TYPE("SORTBY");
2323 WRITE_NODE_FIELD(node);
2324 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2325 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2326 WRITE_NODE_FIELD(useOp);
2327 WRITE_LOCATION_FIELD(location);
2331 _outWindowDef(StringInfo str, WindowDef *node)
2333 WRITE_NODE_TYPE("WINDOWDEF");
2335 WRITE_STRING_FIELD(name);
2336 WRITE_STRING_FIELD(refname);
2337 WRITE_NODE_FIELD(partitionClause);
2338 WRITE_NODE_FIELD(orderClause);
2339 WRITE_INT_FIELD(frameOptions);
2340 WRITE_NODE_FIELD(startOffset);
2341 WRITE_NODE_FIELD(endOffset);
2342 WRITE_LOCATION_FIELD(location);
2346 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2348 WRITE_NODE_TYPE("RANGESUBSELECT");
2350 WRITE_NODE_FIELD(subquery);
2351 WRITE_NODE_FIELD(alias);
2355 _outRangeFunction(StringInfo str, RangeFunction *node)
2357 WRITE_NODE_TYPE("RANGEFUNCTION");
2359 WRITE_NODE_FIELD(funccallnode);
2360 WRITE_NODE_FIELD(alias);
2361 WRITE_NODE_FIELD(coldeflist);
2365 _outConstraint(StringInfo str, Constraint *node)
2367 WRITE_NODE_TYPE("CONSTRAINT");
2369 WRITE_STRING_FIELD(conname);
2370 WRITE_BOOL_FIELD(deferrable);
2371 WRITE_BOOL_FIELD(initdeferred);
2372 WRITE_LOCATION_FIELD(location);
2374 appendStringInfo(str, " :contype ");
2375 switch (node->contype)
2378 appendStringInfo(str, "NULL");
2381 case CONSTR_NOTNULL:
2382 appendStringInfo(str, "NOT_NULL");
2385 case CONSTR_DEFAULT:
2386 appendStringInfo(str, "DEFAULT");
2387 WRITE_NODE_FIELD(raw_expr);
2388 WRITE_STRING_FIELD(cooked_expr);
2392 appendStringInfo(str, "CHECK");
2393 WRITE_NODE_FIELD(raw_expr);
2394 WRITE_STRING_FIELD(cooked_expr);
2397 case CONSTR_PRIMARY:
2398 appendStringInfo(str, "PRIMARY_KEY");
2399 WRITE_NODE_FIELD(keys);
2400 WRITE_NODE_FIELD(options);
2401 WRITE_STRING_FIELD(indexspace);
2402 /* access_method and where_clause not currently used */
2406 appendStringInfo(str, "UNIQUE");
2407 WRITE_NODE_FIELD(keys);
2408 WRITE_NODE_FIELD(options);
2409 WRITE_STRING_FIELD(indexspace);
2410 /* access_method and where_clause not currently used */
2413 case CONSTR_EXCLUSION:
2414 appendStringInfo(str, "EXCLUSION");
2415 WRITE_NODE_FIELD(exclusions);
2416 WRITE_NODE_FIELD(options);
2417 WRITE_STRING_FIELD(indexspace);
2418 WRITE_STRING_FIELD(access_method);
2419 WRITE_NODE_FIELD(where_clause);
2422 case CONSTR_FOREIGN:
2423 appendStringInfo(str, "FOREIGN_KEY");
2424 WRITE_NODE_FIELD(pktable);
2425 WRITE_NODE_FIELD(fk_attrs);
2426 WRITE_NODE_FIELD(pk_attrs);
2427 WRITE_CHAR_FIELD(fk_matchtype);
2428 WRITE_CHAR_FIELD(fk_upd_action);
2429 WRITE_CHAR_FIELD(fk_del_action);
2430 WRITE_BOOL_FIELD(skip_validation);
2433 case CONSTR_ATTR_DEFERRABLE:
2434 appendStringInfo(str, "ATTR_DEFERRABLE");
2437 case CONSTR_ATTR_NOT_DEFERRABLE:
2438 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2441 case CONSTR_ATTR_DEFERRED:
2442 appendStringInfo(str, "ATTR_DEFERRED");
2445 case CONSTR_ATTR_IMMEDIATE:
2446 appendStringInfo(str, "ATTR_IMMEDIATE");
2450 appendStringInfo(str, "<unrecognized_constraint %d>",
2451 (int) node->contype);
2459 * converts a Node into ascii string and append it to 'str'
2462 _outNode(StringInfo str, void *obj)
2465 appendStringInfo(str, "<>");
2466 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2468 else if (IsA(obj, Integer) ||
2471 IsA(obj, BitString))
2473 /* nodeRead does not want to see { } around these! */
2474 _outValue(str, obj);
2478 appendStringInfoChar(str, '{');
2479 switch (nodeTag(obj))
2482 _outPlannedStmt(str, obj);
2488 _outResult(str, obj);
2491 _outModifyTable(str, obj);
2494 _outAppend(str, obj);
2496 case T_RecursiveUnion:
2497 _outRecursiveUnion(str, obj);
2500 _outBitmapAnd(str, obj);
2503 _outBitmapOr(str, obj);
2509 _outSeqScan(str, obj);
2512 _outIndexScan(str, obj);
2514 case T_BitmapIndexScan:
2515 _outBitmapIndexScan(str, obj);
2517 case T_BitmapHeapScan:
2518 _outBitmapHeapScan(str, obj);
2521 _outTidScan(str, obj);
2523 case T_SubqueryScan:
2524 _outSubqueryScan(str, obj);
2526 case T_FunctionScan:
2527 _outFunctionScan(str, obj);
2530 _outValuesScan(str, obj);
2533 _outCteScan(str, obj);
2535 case T_WorkTableScan:
2536 _outWorkTableScan(str, obj);
2542 _outNestLoop(str, obj);
2545 _outMergeJoin(str, obj);
2548 _outHashJoin(str, obj);
2554 _outWindowAgg(str, obj);
2557 _outGroup(str, obj);
2560 _outMaterial(str, obj);
2566 _outUnique(str, obj);
2572 _outSetOp(str, obj);
2575 _outLockRows(str, obj);
2578 _outLimit(str, obj);
2580 case T_NestLoopParam:
2581 _outNestLoopParam(str, obj);
2584 _outPlanRowMark(str, obj);
2586 case T_PlanInvalItem:
2587 _outPlanInvalItem(str, obj);
2590 _outAlias(str, obj);
2593 _outRangeVar(str, obj);
2596 _outIntoClause(str, obj);
2602 _outConst(str, obj);
2605 _outParam(str, obj);
2608 _outAggref(str, obj);
2611 _outWindowFunc(str, obj);
2614 _outArrayRef(str, obj);
2617 _outFuncExpr(str, obj);
2619 case T_NamedArgExpr:
2620 _outNamedArgExpr(str, obj);
2623 _outOpExpr(str, obj);
2625 case T_DistinctExpr:
2626 _outDistinctExpr(str, obj);
2628 case T_ScalarArrayOpExpr:
2629 _outScalarArrayOpExpr(str, obj);
2632 _outBoolExpr(str, obj);
2635 _outSubLink(str, obj);
2638 _outSubPlan(str, obj);
2640 case T_AlternativeSubPlan:
2641 _outAlternativeSubPlan(str, obj);
2644 _outFieldSelect(str, obj);
2647 _outFieldStore(str, obj);
2650 _outRelabelType(str, obj);
2653 _outCoerceViaIO(str, obj);
2655 case T_ArrayCoerceExpr:
2656 _outArrayCoerceExpr(str, obj);
2658 case T_ConvertRowtypeExpr:
2659 _outConvertRowtypeExpr(str, obj);
2662 _outCaseExpr(str, obj);
2665 _outCaseWhen(str, obj);
2667 case T_CaseTestExpr:
2668 _outCaseTestExpr(str, obj);
2671 _outArrayExpr(str, obj);
2674 _outRowExpr(str, obj);
2676 case T_RowCompareExpr:
2677 _outRowCompareExpr(str, obj);
2679 case T_CoalesceExpr:
2680 _outCoalesceExpr(str, obj);
2683 _outMinMaxExpr(str, obj);
2686 _outXmlExpr(str, obj);
2689 _outNullIfExpr(str, obj);
2692 _outNullTest(str, obj);
2695 _outBooleanTest(str, obj);
2697 case T_CoerceToDomain:
2698 _outCoerceToDomain(str, obj);
2700 case T_CoerceToDomainValue:
2701 _outCoerceToDomainValue(str, obj);
2703 case T_SetToDefault:
2704 _outSetToDefault(str, obj);
2706 case T_CurrentOfExpr:
2707 _outCurrentOfExpr(str, obj);
2710 _outTargetEntry(str, obj);
2713 _outRangeTblRef(str, obj);
2716 _outJoinExpr(str, obj);
2719 _outFromExpr(str, obj);
2726 _outIndexPath(str, obj);
2728 case T_BitmapHeapPath:
2729 _outBitmapHeapPath(str, obj);
2731 case T_BitmapAndPath:
2732 _outBitmapAndPath(str, obj);
2734 case T_BitmapOrPath:
2735 _outBitmapOrPath(str, obj);
2738 _outTidPath(str, obj);
2741 _outAppendPath(str, obj);
2744 _outResultPath(str, obj);
2746 case T_MaterialPath:
2747 _outMaterialPath(str, obj);
2750 _outUniquePath(str, obj);
2753 _outNestPath(str, obj);
2756 _outMergePath(str, obj);
2759 _outHashPath(str, obj);
2761 case T_PlannerGlobal:
2762 _outPlannerGlobal(str, obj);
2765 _outPlannerInfo(str, obj);
2768 _outRelOptInfo(str, obj);
2770 case T_IndexOptInfo:
2771 _outIndexOptInfo(str, obj);
2773 case T_EquivalenceClass:
2774 _outEquivalenceClass(str, obj);
2776 case T_EquivalenceMember:
2777 _outEquivalenceMember(str, obj);
2780 _outPathKey(str, obj);
2782 case T_RestrictInfo:
2783 _outRestrictInfo(str, obj);
2785 case T_InnerIndexscanInfo:
2786 _outInnerIndexscanInfo(str, obj);
2788 case T_PlaceHolderVar:
2789 _outPlaceHolderVar(str, obj);
2791 case T_SpecialJoinInfo:
2792 _outSpecialJoinInfo(str, obj);
2794 case T_AppendRelInfo:
2795 _outAppendRelInfo(str, obj);
2797 case T_PlaceHolderInfo:
2798 _outPlaceHolderInfo(str, obj);
2800 case T_PlannerParamItem:
2801 _outPlannerParamItem(str, obj);
2805 _outCreateStmt(str, obj);
2808 _outIndexStmt(str, obj);
2811 _outNotifyStmt(str, obj);
2813 case T_DeclareCursorStmt:
2814 _outDeclareCursorStmt(str, obj);
2817 _outSelectStmt(str, obj);
2820 _outColumnDef(str, obj);
2823 _outTypeName(str, obj);
2826 _outTypeCast(str, obj);
2829 _outIndexElem(str, obj);
2832 _outQuery(str, obj);
2834 case T_SortGroupClause:
2835 _outSortGroupClause(str, obj);
2837 case T_WindowClause:
2838 _outWindowClause(str, obj);
2840 case T_RowMarkClause:
2841 _outRowMarkClause(str, obj);
2844 _outWithClause(str, obj);
2846 case T_CommonTableExpr:
2847 _outCommonTableExpr(str, obj);
2849 case T_SetOperationStmt:
2850 _outSetOperationStmt(str, obj);
2852 case T_RangeTblEntry:
2853 _outRangeTblEntry(str, obj);
2856 _outAExpr(str, obj);
2859 _outColumnRef(str, obj);
2862 _outParamRef(str, obj);
2865 _outAConst(str, obj);
2868 _outA_Star(str, obj);
2871 _outA_Indices(str, obj);
2873 case T_A_Indirection:
2874 _outA_Indirection(str, obj);
2877 _outA_ArrayExpr(str, obj);
2880 _outResTarget(str, obj);
2883 _outSortBy(str, obj);
2886 _outWindowDef(str, obj);
2888 case T_RangeSubselect:
2889 _outRangeSubselect(str, obj);
2891 case T_RangeFunction:
2892 _outRangeFunction(str, obj);
2895 _outConstraint(str, obj);
2898 _outFuncCall(str, obj);
2901 _outDefElem(str, obj);
2903 case T_LockingClause:
2904 _outLockingClause(str, obj);
2906 case T_XmlSerialize:
2907 _outXmlSerialize(str, obj);
2913 * This should be an ERROR, but it's too useful to be able to
2914 * dump structures that _outNode only understands part of.
2916 elog(WARNING, "could not dump unrecognized node type: %d",
2917 (int) nodeTag(obj));
2920 appendStringInfoChar(str, '}');
2926 * returns the ascii representation of the Node as a palloc'd string
2929 nodeToString(void *obj)
2933 /* see stringinfo.h for an explanation of this maneuver */
2934 initStringInfo(&str);
2935 _outNode(&str, obj);