1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/nodes/outfuncs.c
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_BOOL_FIELD(transientPlan);
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(rowMarks);
256 WRITE_NODE_FIELD(relationOids);
257 WRITE_NODE_FIELD(invalItems);
258 WRITE_INT_FIELD(nParamExec);
262 * print the basic stuff of all nodes that inherit from Plan
265 _outPlanInfo(StringInfo str, Plan *node)
267 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
268 WRITE_FLOAT_FIELD(total_cost, "%.2f");
269 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
270 WRITE_INT_FIELD(plan_width);
271 WRITE_NODE_FIELD(targetlist);
272 WRITE_NODE_FIELD(qual);
273 WRITE_NODE_FIELD(lefttree);
274 WRITE_NODE_FIELD(righttree);
275 WRITE_NODE_FIELD(initPlan);
276 WRITE_BITMAPSET_FIELD(extParam);
277 WRITE_BITMAPSET_FIELD(allParam);
281 * print the basic stuff of all nodes that inherit from Scan
284 _outScanInfo(StringInfo str, Scan *node)
286 _outPlanInfo(str, (Plan *) node);
288 WRITE_UINT_FIELD(scanrelid);
292 * print the basic stuff of all nodes that inherit from Join
295 _outJoinPlanInfo(StringInfo str, Join *node)
297 _outPlanInfo(str, (Plan *) node);
299 WRITE_ENUM_FIELD(jointype, JoinType);
300 WRITE_NODE_FIELD(joinqual);
305 _outPlan(StringInfo str, Plan *node)
307 WRITE_NODE_TYPE("PLAN");
309 _outPlanInfo(str, (Plan *) node);
313 _outResult(StringInfo str, Result *node)
315 WRITE_NODE_TYPE("RESULT");
317 _outPlanInfo(str, (Plan *) node);
319 WRITE_NODE_FIELD(resconstantqual);
323 _outModifyTable(StringInfo str, ModifyTable *node)
325 WRITE_NODE_TYPE("MODIFYTABLE");
327 _outPlanInfo(str, (Plan *) node);
329 WRITE_ENUM_FIELD(operation, CmdType);
330 WRITE_NODE_FIELD(resultRelations);
331 WRITE_NODE_FIELD(plans);
332 WRITE_NODE_FIELD(returningLists);
333 WRITE_NODE_FIELD(rowMarks);
334 WRITE_INT_FIELD(epqParam);
338 _outAppend(StringInfo str, Append *node)
340 WRITE_NODE_TYPE("APPEND");
342 _outPlanInfo(str, (Plan *) node);
344 WRITE_NODE_FIELD(appendplans);
348 _outMergeAppend(StringInfo str, MergeAppend *node)
352 WRITE_NODE_TYPE("MERGEAPPEND");
354 _outPlanInfo(str, (Plan *) node);
356 WRITE_NODE_FIELD(mergeplans);
358 WRITE_INT_FIELD(numCols);
360 appendStringInfo(str, " :sortColIdx");
361 for (i = 0; i < node->numCols; i++)
362 appendStringInfo(str, " %d", node->sortColIdx[i]);
364 appendStringInfo(str, " :sortOperators");
365 for (i = 0; i < node->numCols; i++)
366 appendStringInfo(str, " %u", node->sortOperators[i]);
368 appendStringInfo(str, " :nullsFirst");
369 for (i = 0; i < node->numCols; i++)
370 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
374 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
378 WRITE_NODE_TYPE("RECURSIVEUNION");
380 _outPlanInfo(str, (Plan *) node);
382 WRITE_INT_FIELD(wtParam);
383 WRITE_INT_FIELD(numCols);
385 appendStringInfo(str, " :dupColIdx");
386 for (i = 0; i < node->numCols; i++)
387 appendStringInfo(str, " %d", node->dupColIdx[i]);
389 appendStringInfo(str, " :dupOperators");
390 for (i = 0; i < node->numCols; i++)
391 appendStringInfo(str, " %u", node->dupOperators[i]);
393 WRITE_LONG_FIELD(numGroups);
397 _outBitmapAnd(StringInfo str, BitmapAnd *node)
399 WRITE_NODE_TYPE("BITMAPAND");
401 _outPlanInfo(str, (Plan *) node);
403 WRITE_NODE_FIELD(bitmapplans);
407 _outBitmapOr(StringInfo str, BitmapOr *node)
409 WRITE_NODE_TYPE("BITMAPOR");
411 _outPlanInfo(str, (Plan *) node);
413 WRITE_NODE_FIELD(bitmapplans);
417 _outScan(StringInfo str, Scan *node)
419 WRITE_NODE_TYPE("SCAN");
421 _outScanInfo(str, (Scan *) node);
425 _outSeqScan(StringInfo str, SeqScan *node)
427 WRITE_NODE_TYPE("SEQSCAN");
429 _outScanInfo(str, (Scan *) node);
433 _outIndexScan(StringInfo str, IndexScan *node)
435 WRITE_NODE_TYPE("INDEXSCAN");
437 _outScanInfo(str, (Scan *) node);
439 WRITE_OID_FIELD(indexid);
440 WRITE_NODE_FIELD(indexqual);
441 WRITE_NODE_FIELD(indexqualorig);
442 WRITE_NODE_FIELD(indexorderby);
443 WRITE_NODE_FIELD(indexorderbyorig);
444 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
448 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
450 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
452 _outScanInfo(str, (Scan *) node);
454 WRITE_OID_FIELD(indexid);
455 WRITE_NODE_FIELD(indexqual);
456 WRITE_NODE_FIELD(indexqualorig);
460 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
462 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
464 _outScanInfo(str, (Scan *) node);
466 WRITE_NODE_FIELD(bitmapqualorig);
470 _outTidScan(StringInfo str, TidScan *node)
472 WRITE_NODE_TYPE("TIDSCAN");
474 _outScanInfo(str, (Scan *) node);
476 WRITE_NODE_FIELD(tidquals);
480 _outSubqueryScan(StringInfo str, SubqueryScan *node)
482 WRITE_NODE_TYPE("SUBQUERYSCAN");
484 _outScanInfo(str, (Scan *) node);
486 WRITE_NODE_FIELD(subplan);
487 WRITE_NODE_FIELD(subrtable);
488 WRITE_NODE_FIELD(subrowmark);
492 _outFunctionScan(StringInfo str, FunctionScan *node)
494 WRITE_NODE_TYPE("FUNCTIONSCAN");
496 _outScanInfo(str, (Scan *) node);
498 WRITE_NODE_FIELD(funcexpr);
499 WRITE_NODE_FIELD(funccolnames);
500 WRITE_NODE_FIELD(funccoltypes);
501 WRITE_NODE_FIELD(funccoltypmods);
505 _outValuesScan(StringInfo str, ValuesScan *node)
507 WRITE_NODE_TYPE("VALUESSCAN");
509 _outScanInfo(str, (Scan *) node);
511 WRITE_NODE_FIELD(values_lists);
515 _outCteScan(StringInfo str, CteScan *node)
517 WRITE_NODE_TYPE("CTESCAN");
519 _outScanInfo(str, (Scan *) node);
521 WRITE_INT_FIELD(ctePlanId);
522 WRITE_INT_FIELD(cteParam);
526 _outWorkTableScan(StringInfo str, WorkTableScan *node)
528 WRITE_NODE_TYPE("WORKTABLESCAN");
530 _outScanInfo(str, (Scan *) node);
532 WRITE_INT_FIELD(wtParam);
536 _outJoin(StringInfo str, Join *node)
538 WRITE_NODE_TYPE("JOIN");
540 _outJoinPlanInfo(str, (Join *) node);
544 _outNestLoop(StringInfo str, NestLoop *node)
546 WRITE_NODE_TYPE("NESTLOOP");
548 _outJoinPlanInfo(str, (Join *) node);
550 WRITE_NODE_FIELD(nestParams);
554 _outMergeJoin(StringInfo str, MergeJoin *node)
559 WRITE_NODE_TYPE("MERGEJOIN");
561 _outJoinPlanInfo(str, (Join *) node);
563 WRITE_NODE_FIELD(mergeclauses);
565 numCols = list_length(node->mergeclauses);
567 appendStringInfo(str, " :mergeFamilies");
568 for (i = 0; i < numCols; i++)
569 appendStringInfo(str, " %u", node->mergeFamilies[i]);
571 appendStringInfo(str, " :mergeStrategies");
572 for (i = 0; i < numCols; i++)
573 appendStringInfo(str, " %d", node->mergeStrategies[i]);
575 appendStringInfo(str, " :mergeNullsFirst");
576 for (i = 0; i < numCols; i++)
577 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
581 _outHashJoin(StringInfo str, HashJoin *node)
583 WRITE_NODE_TYPE("HASHJOIN");
585 _outJoinPlanInfo(str, (Join *) node);
587 WRITE_NODE_FIELD(hashclauses);
591 _outAgg(StringInfo str, Agg *node)
595 WRITE_NODE_TYPE("AGG");
597 _outPlanInfo(str, (Plan *) node);
599 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
600 WRITE_INT_FIELD(numCols);
602 appendStringInfo(str, " :grpColIdx");
603 for (i = 0; i < node->numCols; i++)
604 appendStringInfo(str, " %d", node->grpColIdx[i]);
606 appendStringInfo(str, " :grpOperators");
607 for (i = 0; i < node->numCols; i++)
608 appendStringInfo(str, " %u", node->grpOperators[i]);
610 WRITE_LONG_FIELD(numGroups);
614 _outWindowAgg(StringInfo str, WindowAgg *node)
618 WRITE_NODE_TYPE("WINDOWAGG");
620 _outPlanInfo(str, (Plan *) node);
622 WRITE_UINT_FIELD(winref);
623 WRITE_INT_FIELD(partNumCols);
625 appendStringInfo(str, " :partColIdx");
626 for (i = 0; i < node->partNumCols; i++)
627 appendStringInfo(str, " %d", node->partColIdx[i]);
629 appendStringInfo(str, " :partOperations");
630 for (i = 0; i < node->partNumCols; i++)
631 appendStringInfo(str, " %u", node->partOperators[i]);
633 WRITE_INT_FIELD(ordNumCols);
635 appendStringInfo(str, " :ordColIdx");
636 for (i = 0; i < node->ordNumCols; i++)
637 appendStringInfo(str, " %d", node->ordColIdx[i]);
639 appendStringInfo(str, " :ordOperations");
640 for (i = 0; i < node->ordNumCols; i++)
641 appendStringInfo(str, " %u", node->ordOperators[i]);
643 WRITE_INT_FIELD(frameOptions);
644 WRITE_NODE_FIELD(startOffset);
645 WRITE_NODE_FIELD(endOffset);
649 _outGroup(StringInfo str, Group *node)
653 WRITE_NODE_TYPE("GROUP");
655 _outPlanInfo(str, (Plan *) node);
657 WRITE_INT_FIELD(numCols);
659 appendStringInfo(str, " :grpColIdx");
660 for (i = 0; i < node->numCols; i++)
661 appendStringInfo(str, " %d", node->grpColIdx[i]);
663 appendStringInfo(str, " :grpOperators");
664 for (i = 0; i < node->numCols; i++)
665 appendStringInfo(str, " %u", node->grpOperators[i]);
669 _outMaterial(StringInfo str, Material *node)
671 WRITE_NODE_TYPE("MATERIAL");
673 _outPlanInfo(str, (Plan *) node);
677 _outSort(StringInfo str, Sort *node)
681 WRITE_NODE_TYPE("SORT");
683 _outPlanInfo(str, (Plan *) node);
685 WRITE_INT_FIELD(numCols);
687 appendStringInfo(str, " :sortColIdx");
688 for (i = 0; i < node->numCols; i++)
689 appendStringInfo(str, " %d", node->sortColIdx[i]);
691 appendStringInfo(str, " :sortOperators");
692 for (i = 0; i < node->numCols; i++)
693 appendStringInfo(str, " %u", node->sortOperators[i]);
695 appendStringInfo(str, " :nullsFirst");
696 for (i = 0; i < node->numCols; i++)
697 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
701 _outUnique(StringInfo str, Unique *node)
705 WRITE_NODE_TYPE("UNIQUE");
707 _outPlanInfo(str, (Plan *) node);
709 WRITE_INT_FIELD(numCols);
711 appendStringInfo(str, " :uniqColIdx");
712 for (i = 0; i < node->numCols; i++)
713 appendStringInfo(str, " %d", node->uniqColIdx[i]);
715 appendStringInfo(str, " :uniqOperators");
716 for (i = 0; i < node->numCols; i++)
717 appendStringInfo(str, " %u", node->uniqOperators[i]);
721 _outHash(StringInfo str, Hash *node)
723 WRITE_NODE_TYPE("HASH");
725 _outPlanInfo(str, (Plan *) node);
727 WRITE_OID_FIELD(skewTable);
728 WRITE_INT_FIELD(skewColumn);
729 WRITE_BOOL_FIELD(skewInherit);
730 WRITE_OID_FIELD(skewColType);
731 WRITE_INT_FIELD(skewColTypmod);
735 _outSetOp(StringInfo str, SetOp *node)
739 WRITE_NODE_TYPE("SETOP");
741 _outPlanInfo(str, (Plan *) node);
743 WRITE_ENUM_FIELD(cmd, SetOpCmd);
744 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
745 WRITE_INT_FIELD(numCols);
747 appendStringInfo(str, " :dupColIdx");
748 for (i = 0; i < node->numCols; i++)
749 appendStringInfo(str, " %d", node->dupColIdx[i]);
751 appendStringInfo(str, " :dupOperators");
752 for (i = 0; i < node->numCols; i++)
753 appendStringInfo(str, " %u", node->dupOperators[i]);
755 WRITE_INT_FIELD(flagColIdx);
756 WRITE_INT_FIELD(firstFlag);
757 WRITE_LONG_FIELD(numGroups);
761 _outLockRows(StringInfo str, LockRows *node)
763 WRITE_NODE_TYPE("LOCKROWS");
765 _outPlanInfo(str, (Plan *) node);
767 WRITE_NODE_FIELD(rowMarks);
768 WRITE_INT_FIELD(epqParam);
772 _outLimit(StringInfo str, Limit *node)
774 WRITE_NODE_TYPE("LIMIT");
776 _outPlanInfo(str, (Plan *) node);
778 WRITE_NODE_FIELD(limitOffset);
779 WRITE_NODE_FIELD(limitCount);
783 _outNestLoopParam(StringInfo str, NestLoopParam *node)
785 WRITE_NODE_TYPE("NESTLOOPPARAM");
787 WRITE_INT_FIELD(paramno);
788 WRITE_NODE_FIELD(paramval);
792 _outPlanRowMark(StringInfo str, PlanRowMark *node)
794 WRITE_NODE_TYPE("PLANROWMARK");
796 WRITE_UINT_FIELD(rti);
797 WRITE_UINT_FIELD(prti);
798 WRITE_ENUM_FIELD(markType, RowMarkType);
799 WRITE_BOOL_FIELD(noWait);
800 WRITE_BOOL_FIELD(isParent);
804 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
806 WRITE_NODE_TYPE("PLANINVALITEM");
808 WRITE_INT_FIELD(cacheId);
809 appendStringInfo(str, " :tupleId (%u,%u)",
810 ItemPointerGetBlockNumber(&node->tupleId),
811 ItemPointerGetOffsetNumber(&node->tupleId));
814 /*****************************************************************************
816 * Stuff from primnodes.h.
818 *****************************************************************************/
821 _outAlias(StringInfo str, Alias *node)
823 WRITE_NODE_TYPE("ALIAS");
825 WRITE_STRING_FIELD(aliasname);
826 WRITE_NODE_FIELD(colnames);
830 _outRangeVar(StringInfo str, RangeVar *node)
832 WRITE_NODE_TYPE("RANGEVAR");
835 * we deliberately ignore catalogname here, since it is presently not
836 * semantically meaningful
838 WRITE_STRING_FIELD(schemaname);
839 WRITE_STRING_FIELD(relname);
840 WRITE_ENUM_FIELD(inhOpt, InhOption);
841 WRITE_CHAR_FIELD(relpersistence);
842 WRITE_NODE_FIELD(alias);
843 WRITE_LOCATION_FIELD(location);
847 _outIntoClause(StringInfo str, IntoClause *node)
849 WRITE_NODE_TYPE("INTOCLAUSE");
851 WRITE_NODE_FIELD(rel);
852 WRITE_NODE_FIELD(colNames);
853 WRITE_NODE_FIELD(options);
854 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
855 WRITE_STRING_FIELD(tableSpaceName);
859 _outVar(StringInfo str, Var *node)
861 WRITE_NODE_TYPE("VAR");
863 WRITE_UINT_FIELD(varno);
864 WRITE_INT_FIELD(varattno);
865 WRITE_OID_FIELD(vartype);
866 WRITE_INT_FIELD(vartypmod);
867 WRITE_UINT_FIELD(varlevelsup);
868 WRITE_UINT_FIELD(varnoold);
869 WRITE_INT_FIELD(varoattno);
870 WRITE_LOCATION_FIELD(location);
874 _outConst(StringInfo str, Const *node)
876 WRITE_NODE_TYPE("CONST");
878 WRITE_OID_FIELD(consttype);
879 WRITE_INT_FIELD(consttypmod);
880 WRITE_INT_FIELD(constlen);
881 WRITE_BOOL_FIELD(constbyval);
882 WRITE_BOOL_FIELD(constisnull);
883 WRITE_LOCATION_FIELD(location);
885 appendStringInfo(str, " :constvalue ");
886 if (node->constisnull)
887 appendStringInfo(str, "<>");
889 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
893 _outParam(StringInfo str, Param *node)
895 WRITE_NODE_TYPE("PARAM");
897 WRITE_ENUM_FIELD(paramkind, ParamKind);
898 WRITE_INT_FIELD(paramid);
899 WRITE_OID_FIELD(paramtype);
900 WRITE_INT_FIELD(paramtypmod);
901 WRITE_LOCATION_FIELD(location);
905 _outAggref(StringInfo str, Aggref *node)
907 WRITE_NODE_TYPE("AGGREF");
909 WRITE_OID_FIELD(aggfnoid);
910 WRITE_OID_FIELD(aggtype);
911 WRITE_NODE_FIELD(args);
912 WRITE_NODE_FIELD(aggorder);
913 WRITE_NODE_FIELD(aggdistinct);
914 WRITE_BOOL_FIELD(aggstar);
915 WRITE_UINT_FIELD(agglevelsup);
916 WRITE_LOCATION_FIELD(location);
920 _outWindowFunc(StringInfo str, WindowFunc *node)
922 WRITE_NODE_TYPE("WINDOWFUNC");
924 WRITE_OID_FIELD(winfnoid);
925 WRITE_OID_FIELD(wintype);
926 WRITE_NODE_FIELD(args);
927 WRITE_UINT_FIELD(winref);
928 WRITE_BOOL_FIELD(winstar);
929 WRITE_BOOL_FIELD(winagg);
930 WRITE_LOCATION_FIELD(location);
934 _outArrayRef(StringInfo str, ArrayRef *node)
936 WRITE_NODE_TYPE("ARRAYREF");
938 WRITE_OID_FIELD(refarraytype);
939 WRITE_OID_FIELD(refelemtype);
940 WRITE_INT_FIELD(reftypmod);
941 WRITE_NODE_FIELD(refupperindexpr);
942 WRITE_NODE_FIELD(reflowerindexpr);
943 WRITE_NODE_FIELD(refexpr);
944 WRITE_NODE_FIELD(refassgnexpr);
948 _outFuncExpr(StringInfo str, FuncExpr *node)
950 WRITE_NODE_TYPE("FUNCEXPR");
952 WRITE_OID_FIELD(funcid);
953 WRITE_OID_FIELD(funcresulttype);
954 WRITE_BOOL_FIELD(funcretset);
955 WRITE_ENUM_FIELD(funcformat, CoercionForm);
956 WRITE_NODE_FIELD(args);
957 WRITE_LOCATION_FIELD(location);
961 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
963 WRITE_NODE_TYPE("NAMEDARGEXPR");
965 WRITE_NODE_FIELD(arg);
966 WRITE_STRING_FIELD(name);
967 WRITE_INT_FIELD(argnumber);
968 WRITE_LOCATION_FIELD(location);
972 _outOpExpr(StringInfo str, OpExpr *node)
974 WRITE_NODE_TYPE("OPEXPR");
976 WRITE_OID_FIELD(opno);
977 WRITE_OID_FIELD(opfuncid);
978 WRITE_OID_FIELD(opresulttype);
979 WRITE_BOOL_FIELD(opretset);
980 WRITE_NODE_FIELD(args);
981 WRITE_LOCATION_FIELD(location);
985 _outDistinctExpr(StringInfo str, DistinctExpr *node)
987 WRITE_NODE_TYPE("DISTINCTEXPR");
989 WRITE_OID_FIELD(opno);
990 WRITE_OID_FIELD(opfuncid);
991 WRITE_OID_FIELD(opresulttype);
992 WRITE_BOOL_FIELD(opretset);
993 WRITE_NODE_FIELD(args);
994 WRITE_LOCATION_FIELD(location);
998 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
1000 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1002 WRITE_OID_FIELD(opno);
1003 WRITE_OID_FIELD(opfuncid);
1004 WRITE_BOOL_FIELD(useOr);
1005 WRITE_NODE_FIELD(args);
1006 WRITE_LOCATION_FIELD(location);
1010 _outBoolExpr(StringInfo str, BoolExpr *node)
1014 WRITE_NODE_TYPE("BOOLEXPR");
1016 /* do-it-yourself enum representation */
1017 switch (node->boolop)
1029 appendStringInfo(str, " :boolop ");
1030 _outToken(str, opstr);
1032 WRITE_NODE_FIELD(args);
1033 WRITE_LOCATION_FIELD(location);
1037 _outSubLink(StringInfo str, SubLink *node)
1039 WRITE_NODE_TYPE("SUBLINK");
1041 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1042 WRITE_NODE_FIELD(testexpr);
1043 WRITE_NODE_FIELD(operName);
1044 WRITE_NODE_FIELD(subselect);
1045 WRITE_LOCATION_FIELD(location);
1049 _outSubPlan(StringInfo str, SubPlan *node)
1051 WRITE_NODE_TYPE("SUBPLAN");
1053 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1054 WRITE_NODE_FIELD(testexpr);
1055 WRITE_NODE_FIELD(paramIds);
1056 WRITE_INT_FIELD(plan_id);
1057 WRITE_STRING_FIELD(plan_name);
1058 WRITE_OID_FIELD(firstColType);
1059 WRITE_INT_FIELD(firstColTypmod);
1060 WRITE_BOOL_FIELD(useHashTable);
1061 WRITE_BOOL_FIELD(unknownEqFalse);
1062 WRITE_NODE_FIELD(setParam);
1063 WRITE_NODE_FIELD(parParam);
1064 WRITE_NODE_FIELD(args);
1065 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1066 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1070 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1072 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1074 WRITE_NODE_FIELD(subplans);
1078 _outFieldSelect(StringInfo str, FieldSelect *node)
1080 WRITE_NODE_TYPE("FIELDSELECT");
1082 WRITE_NODE_FIELD(arg);
1083 WRITE_INT_FIELD(fieldnum);
1084 WRITE_OID_FIELD(resulttype);
1085 WRITE_INT_FIELD(resulttypmod);
1089 _outFieldStore(StringInfo str, FieldStore *node)
1091 WRITE_NODE_TYPE("FIELDSTORE");
1093 WRITE_NODE_FIELD(arg);
1094 WRITE_NODE_FIELD(newvals);
1095 WRITE_NODE_FIELD(fieldnums);
1096 WRITE_OID_FIELD(resulttype);
1100 _outRelabelType(StringInfo str, RelabelType *node)
1102 WRITE_NODE_TYPE("RELABELTYPE");
1104 WRITE_NODE_FIELD(arg);
1105 WRITE_OID_FIELD(resulttype);
1106 WRITE_INT_FIELD(resulttypmod);
1107 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1108 WRITE_LOCATION_FIELD(location);
1112 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1114 WRITE_NODE_TYPE("COERCEVIAIO");
1116 WRITE_NODE_FIELD(arg);
1117 WRITE_OID_FIELD(resulttype);
1118 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1119 WRITE_LOCATION_FIELD(location);
1123 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1125 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1127 WRITE_NODE_FIELD(arg);
1128 WRITE_OID_FIELD(elemfuncid);
1129 WRITE_OID_FIELD(resulttype);
1130 WRITE_INT_FIELD(resulttypmod);
1131 WRITE_BOOL_FIELD(isExplicit);
1132 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1133 WRITE_LOCATION_FIELD(location);
1137 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1139 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1141 WRITE_NODE_FIELD(arg);
1142 WRITE_OID_FIELD(resulttype);
1143 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1144 WRITE_LOCATION_FIELD(location);
1148 _outCaseExpr(StringInfo str, CaseExpr *node)
1150 WRITE_NODE_TYPE("CASE");
1152 WRITE_OID_FIELD(casetype);
1153 WRITE_NODE_FIELD(arg);
1154 WRITE_NODE_FIELD(args);
1155 WRITE_NODE_FIELD(defresult);
1156 WRITE_LOCATION_FIELD(location);
1160 _outCaseWhen(StringInfo str, CaseWhen *node)
1162 WRITE_NODE_TYPE("WHEN");
1164 WRITE_NODE_FIELD(expr);
1165 WRITE_NODE_FIELD(result);
1166 WRITE_LOCATION_FIELD(location);
1170 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1172 WRITE_NODE_TYPE("CASETESTEXPR");
1174 WRITE_OID_FIELD(typeId);
1175 WRITE_INT_FIELD(typeMod);
1179 _outArrayExpr(StringInfo str, ArrayExpr *node)
1181 WRITE_NODE_TYPE("ARRAY");
1183 WRITE_OID_FIELD(array_typeid);
1184 WRITE_OID_FIELD(element_typeid);
1185 WRITE_NODE_FIELD(elements);
1186 WRITE_BOOL_FIELD(multidims);
1187 WRITE_LOCATION_FIELD(location);
1191 _outRowExpr(StringInfo str, RowExpr *node)
1193 WRITE_NODE_TYPE("ROW");
1195 WRITE_NODE_FIELD(args);
1196 WRITE_OID_FIELD(row_typeid);
1197 WRITE_ENUM_FIELD(row_format, CoercionForm);
1198 WRITE_NODE_FIELD(colnames);
1199 WRITE_LOCATION_FIELD(location);
1203 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1205 WRITE_NODE_TYPE("ROWCOMPARE");
1207 WRITE_ENUM_FIELD(rctype, RowCompareType);
1208 WRITE_NODE_FIELD(opnos);
1209 WRITE_NODE_FIELD(opfamilies);
1210 WRITE_NODE_FIELD(largs);
1211 WRITE_NODE_FIELD(rargs);
1215 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1217 WRITE_NODE_TYPE("COALESCE");
1219 WRITE_OID_FIELD(coalescetype);
1220 WRITE_NODE_FIELD(args);
1221 WRITE_LOCATION_FIELD(location);
1225 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1227 WRITE_NODE_TYPE("MINMAX");
1229 WRITE_OID_FIELD(minmaxtype);
1230 WRITE_ENUM_FIELD(op, MinMaxOp);
1231 WRITE_NODE_FIELD(args);
1232 WRITE_LOCATION_FIELD(location);
1236 _outXmlExpr(StringInfo str, XmlExpr *node)
1238 WRITE_NODE_TYPE("XMLEXPR");
1240 WRITE_ENUM_FIELD(op, XmlExprOp);
1241 WRITE_STRING_FIELD(name);
1242 WRITE_NODE_FIELD(named_args);
1243 WRITE_NODE_FIELD(arg_names);
1244 WRITE_NODE_FIELD(args);
1245 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1246 WRITE_OID_FIELD(type);
1247 WRITE_INT_FIELD(typmod);
1248 WRITE_LOCATION_FIELD(location);
1252 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1254 WRITE_NODE_TYPE("NULLIFEXPR");
1256 WRITE_OID_FIELD(opno);
1257 WRITE_OID_FIELD(opfuncid);
1258 WRITE_OID_FIELD(opresulttype);
1259 WRITE_BOOL_FIELD(opretset);
1260 WRITE_NODE_FIELD(args);
1261 WRITE_LOCATION_FIELD(location);
1265 _outNullTest(StringInfo str, NullTest *node)
1267 WRITE_NODE_TYPE("NULLTEST");
1269 WRITE_NODE_FIELD(arg);
1270 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1271 WRITE_BOOL_FIELD(argisrow);
1275 _outBooleanTest(StringInfo str, BooleanTest *node)
1277 WRITE_NODE_TYPE("BOOLEANTEST");
1279 WRITE_NODE_FIELD(arg);
1280 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1284 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1286 WRITE_NODE_TYPE("COERCETODOMAIN");
1288 WRITE_NODE_FIELD(arg);
1289 WRITE_OID_FIELD(resulttype);
1290 WRITE_INT_FIELD(resulttypmod);
1291 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1292 WRITE_LOCATION_FIELD(location);
1296 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1298 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1300 WRITE_OID_FIELD(typeId);
1301 WRITE_INT_FIELD(typeMod);
1302 WRITE_LOCATION_FIELD(location);
1306 _outSetToDefault(StringInfo str, SetToDefault *node)
1308 WRITE_NODE_TYPE("SETTODEFAULT");
1310 WRITE_OID_FIELD(typeId);
1311 WRITE_INT_FIELD(typeMod);
1312 WRITE_LOCATION_FIELD(location);
1316 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1318 WRITE_NODE_TYPE("CURRENTOFEXPR");
1320 WRITE_UINT_FIELD(cvarno);
1321 WRITE_STRING_FIELD(cursor_name);
1322 WRITE_INT_FIELD(cursor_param);
1326 _outTargetEntry(StringInfo str, TargetEntry *node)
1328 WRITE_NODE_TYPE("TARGETENTRY");
1330 WRITE_NODE_FIELD(expr);
1331 WRITE_INT_FIELD(resno);
1332 WRITE_STRING_FIELD(resname);
1333 WRITE_UINT_FIELD(ressortgroupref);
1334 WRITE_OID_FIELD(resorigtbl);
1335 WRITE_INT_FIELD(resorigcol);
1336 WRITE_BOOL_FIELD(resjunk);
1340 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1342 WRITE_NODE_TYPE("RANGETBLREF");
1344 WRITE_INT_FIELD(rtindex);
1348 _outJoinExpr(StringInfo str, JoinExpr *node)
1350 WRITE_NODE_TYPE("JOINEXPR");
1352 WRITE_ENUM_FIELD(jointype, JoinType);
1353 WRITE_BOOL_FIELD(isNatural);
1354 WRITE_NODE_FIELD(larg);
1355 WRITE_NODE_FIELD(rarg);
1356 WRITE_NODE_FIELD(usingClause);
1357 WRITE_NODE_FIELD(quals);
1358 WRITE_NODE_FIELD(alias);
1359 WRITE_INT_FIELD(rtindex);
1363 _outFromExpr(StringInfo str, FromExpr *node)
1365 WRITE_NODE_TYPE("FROMEXPR");
1367 WRITE_NODE_FIELD(fromlist);
1368 WRITE_NODE_FIELD(quals);
1371 /*****************************************************************************
1373 * Stuff from relation.h.
1375 *****************************************************************************/
1378 * print the basic stuff of all nodes that inherit from Path
1380 * Note we do NOT print the parent, else we'd be in infinite recursion.
1381 * We can print the parent's relids for identification purposes, though.
1384 _outPathInfo(StringInfo str, Path *node)
1386 WRITE_ENUM_FIELD(pathtype, NodeTag);
1387 appendStringInfo(str, " :parent_relids ");
1388 _outBitmapset(str, node->parent->relids);
1389 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1390 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1391 WRITE_NODE_FIELD(pathkeys);
1395 * print the basic stuff of all nodes that inherit from JoinPath
1398 _outJoinPathInfo(StringInfo str, JoinPath *node)
1400 _outPathInfo(str, (Path *) node);
1402 WRITE_ENUM_FIELD(jointype, JoinType);
1403 WRITE_NODE_FIELD(outerjoinpath);
1404 WRITE_NODE_FIELD(innerjoinpath);
1405 WRITE_NODE_FIELD(joinrestrictinfo);
1409 _outPath(StringInfo str, Path *node)
1411 WRITE_NODE_TYPE("PATH");
1413 _outPathInfo(str, (Path *) node);
1417 _outIndexPath(StringInfo str, IndexPath *node)
1419 WRITE_NODE_TYPE("INDEXPATH");
1421 _outPathInfo(str, (Path *) node);
1423 WRITE_NODE_FIELD(indexinfo);
1424 WRITE_NODE_FIELD(indexclauses);
1425 WRITE_NODE_FIELD(indexquals);
1426 WRITE_NODE_FIELD(indexorderbys);
1427 WRITE_BOOL_FIELD(isjoininner);
1428 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1429 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1430 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1431 WRITE_FLOAT_FIELD(rows, "%.0f");
1435 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1437 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1439 _outPathInfo(str, (Path *) node);
1441 WRITE_NODE_FIELD(bitmapqual);
1442 WRITE_BOOL_FIELD(isjoininner);
1443 WRITE_FLOAT_FIELD(rows, "%.0f");
1447 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1449 WRITE_NODE_TYPE("BITMAPANDPATH");
1451 _outPathInfo(str, (Path *) node);
1453 WRITE_NODE_FIELD(bitmapquals);
1454 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1458 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1460 WRITE_NODE_TYPE("BITMAPORPATH");
1462 _outPathInfo(str, (Path *) node);
1464 WRITE_NODE_FIELD(bitmapquals);
1465 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1469 _outTidPath(StringInfo str, TidPath *node)
1471 WRITE_NODE_TYPE("TIDPATH");
1473 _outPathInfo(str, (Path *) node);
1475 WRITE_NODE_FIELD(tidquals);
1479 _outAppendPath(StringInfo str, AppendPath *node)
1481 WRITE_NODE_TYPE("APPENDPATH");
1483 _outPathInfo(str, (Path *) node);
1485 WRITE_NODE_FIELD(subpaths);
1489 _outMergeAppendPath(StringInfo str, MergeAppendPath *node)
1491 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1493 _outPathInfo(str, (Path *) node);
1495 WRITE_NODE_FIELD(subpaths);
1496 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1500 _outResultPath(StringInfo str, ResultPath *node)
1502 WRITE_NODE_TYPE("RESULTPATH");
1504 _outPathInfo(str, (Path *) node);
1506 WRITE_NODE_FIELD(quals);
1510 _outMaterialPath(StringInfo str, MaterialPath *node)
1512 WRITE_NODE_TYPE("MATERIALPATH");
1514 _outPathInfo(str, (Path *) node);
1516 WRITE_NODE_FIELD(subpath);
1520 _outUniquePath(StringInfo str, UniquePath *node)
1522 WRITE_NODE_TYPE("UNIQUEPATH");
1524 _outPathInfo(str, (Path *) node);
1526 WRITE_NODE_FIELD(subpath);
1527 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1528 WRITE_NODE_FIELD(in_operators);
1529 WRITE_NODE_FIELD(uniq_exprs);
1530 WRITE_FLOAT_FIELD(rows, "%.0f");
1534 _outNestPath(StringInfo str, NestPath *node)
1536 WRITE_NODE_TYPE("NESTPATH");
1538 _outJoinPathInfo(str, (JoinPath *) node);
1542 _outMergePath(StringInfo str, MergePath *node)
1544 WRITE_NODE_TYPE("MERGEPATH");
1546 _outJoinPathInfo(str, (JoinPath *) node);
1548 WRITE_NODE_FIELD(path_mergeclauses);
1549 WRITE_NODE_FIELD(outersortkeys);
1550 WRITE_NODE_FIELD(innersortkeys);
1551 WRITE_BOOL_FIELD(materialize_inner);
1555 _outHashPath(StringInfo str, HashPath *node)
1557 WRITE_NODE_TYPE("HASHPATH");
1559 _outJoinPathInfo(str, (JoinPath *) node);
1561 WRITE_NODE_FIELD(path_hashclauses);
1562 WRITE_INT_FIELD(num_batches);
1566 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1568 WRITE_NODE_TYPE("PLANNERGLOBAL");
1570 /* NB: this isn't a complete set of fields */
1571 WRITE_NODE_FIELD(paramlist);
1572 WRITE_NODE_FIELD(subplans);
1573 WRITE_NODE_FIELD(subrtables);
1574 WRITE_NODE_FIELD(subrowmarks);
1575 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1576 WRITE_NODE_FIELD(finalrtable);
1577 WRITE_NODE_FIELD(finalrowmarks);
1578 WRITE_NODE_FIELD(relationOids);
1579 WRITE_NODE_FIELD(invalItems);
1580 WRITE_UINT_FIELD(lastPHId);
1581 WRITE_BOOL_FIELD(transientPlan);
1585 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1587 WRITE_NODE_TYPE("PLANNERINFO");
1589 /* NB: this isn't a complete set of fields */
1590 WRITE_NODE_FIELD(parse);
1591 WRITE_NODE_FIELD(glob);
1592 WRITE_UINT_FIELD(query_level);
1593 WRITE_NODE_FIELD(join_rel_list);
1594 WRITE_INT_FIELD(join_cur_level);
1595 WRITE_NODE_FIELD(resultRelations);
1596 WRITE_NODE_FIELD(init_plans);
1597 WRITE_NODE_FIELD(cte_plan_ids);
1598 WRITE_NODE_FIELD(eq_classes);
1599 WRITE_NODE_FIELD(canon_pathkeys);
1600 WRITE_NODE_FIELD(left_join_clauses);
1601 WRITE_NODE_FIELD(right_join_clauses);
1602 WRITE_NODE_FIELD(full_join_clauses);
1603 WRITE_NODE_FIELD(join_info_list);
1604 WRITE_NODE_FIELD(append_rel_list);
1605 WRITE_NODE_FIELD(rowMarks);
1606 WRITE_NODE_FIELD(placeholder_list);
1607 WRITE_NODE_FIELD(query_pathkeys);
1608 WRITE_NODE_FIELD(group_pathkeys);
1609 WRITE_NODE_FIELD(window_pathkeys);
1610 WRITE_NODE_FIELD(distinct_pathkeys);
1611 WRITE_NODE_FIELD(sort_pathkeys);
1612 WRITE_NODE_FIELD(minmax_aggs);
1613 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1614 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1615 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1616 WRITE_BOOL_FIELD(hasInheritedTarget);
1617 WRITE_BOOL_FIELD(hasJoinRTEs);
1618 WRITE_BOOL_FIELD(hasHavingQual);
1619 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1620 WRITE_BOOL_FIELD(hasRecursion);
1621 WRITE_INT_FIELD(wt_param_id);
1622 WRITE_BITMAPSET_FIELD(curOuterRels);
1623 WRITE_NODE_FIELD(curOuterParams);
1627 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1629 WRITE_NODE_TYPE("RELOPTINFO");
1631 /* NB: this isn't a complete set of fields */
1632 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1633 WRITE_BITMAPSET_FIELD(relids);
1634 WRITE_FLOAT_FIELD(rows, "%.0f");
1635 WRITE_INT_FIELD(width);
1636 WRITE_NODE_FIELD(reltargetlist);
1637 WRITE_NODE_FIELD(pathlist);
1638 WRITE_NODE_FIELD(cheapest_startup_path);
1639 WRITE_NODE_FIELD(cheapest_total_path);
1640 WRITE_NODE_FIELD(cheapest_unique_path);
1641 WRITE_UINT_FIELD(relid);
1642 WRITE_UINT_FIELD(reltablespace);
1643 WRITE_ENUM_FIELD(rtekind, RTEKind);
1644 WRITE_INT_FIELD(min_attr);
1645 WRITE_INT_FIELD(max_attr);
1646 WRITE_NODE_FIELD(indexlist);
1647 WRITE_UINT_FIELD(pages);
1648 WRITE_FLOAT_FIELD(tuples, "%.0f");
1649 WRITE_NODE_FIELD(subplan);
1650 WRITE_NODE_FIELD(subrtable);
1651 WRITE_NODE_FIELD(subrowmark);
1652 WRITE_NODE_FIELD(baserestrictinfo);
1653 WRITE_NODE_FIELD(joininfo);
1654 WRITE_BOOL_FIELD(has_eclass_joins);
1655 WRITE_BITMAPSET_FIELD(index_outer_relids);
1656 WRITE_NODE_FIELD(index_inner_paths);
1660 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1662 WRITE_NODE_TYPE("INDEXOPTINFO");
1664 /* NB: this isn't a complete set of fields */
1665 WRITE_OID_FIELD(indexoid);
1666 /* Do NOT print rel field, else infinite recursion */
1667 WRITE_UINT_FIELD(pages);
1668 WRITE_FLOAT_FIELD(tuples, "%.0f");
1669 WRITE_INT_FIELD(ncolumns);
1670 WRITE_NODE_FIELD(indexprs);
1671 WRITE_NODE_FIELD(indpred);
1672 WRITE_BOOL_FIELD(predOK);
1673 WRITE_BOOL_FIELD(unique);
1677 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1680 * To simplify reading, we just chase up to the topmost merged EC and
1681 * print that, without bothering to show the merge-ees separately.
1683 while (node->ec_merged)
1684 node = node->ec_merged;
1686 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1688 WRITE_NODE_FIELD(ec_opfamilies);
1689 WRITE_NODE_FIELD(ec_members);
1690 WRITE_NODE_FIELD(ec_sources);
1691 WRITE_NODE_FIELD(ec_derives);
1692 WRITE_BITMAPSET_FIELD(ec_relids);
1693 WRITE_BOOL_FIELD(ec_has_const);
1694 WRITE_BOOL_FIELD(ec_has_volatile);
1695 WRITE_BOOL_FIELD(ec_below_outer_join);
1696 WRITE_BOOL_FIELD(ec_broken);
1697 WRITE_UINT_FIELD(ec_sortref);
1701 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1703 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1705 WRITE_NODE_FIELD(em_expr);
1706 WRITE_BITMAPSET_FIELD(em_relids);
1707 WRITE_BOOL_FIELD(em_is_const);
1708 WRITE_BOOL_FIELD(em_is_child);
1709 WRITE_OID_FIELD(em_datatype);
1713 _outPathKey(StringInfo str, PathKey *node)
1715 WRITE_NODE_TYPE("PATHKEY");
1717 WRITE_NODE_FIELD(pk_eclass);
1718 WRITE_OID_FIELD(pk_opfamily);
1719 WRITE_INT_FIELD(pk_strategy);
1720 WRITE_BOOL_FIELD(pk_nulls_first);
1724 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1726 WRITE_NODE_TYPE("RESTRICTINFO");
1728 /* NB: this isn't a complete set of fields */
1729 WRITE_NODE_FIELD(clause);
1730 WRITE_BOOL_FIELD(is_pushed_down);
1731 WRITE_BOOL_FIELD(outerjoin_delayed);
1732 WRITE_BOOL_FIELD(can_join);
1733 WRITE_BOOL_FIELD(pseudoconstant);
1734 WRITE_BITMAPSET_FIELD(clause_relids);
1735 WRITE_BITMAPSET_FIELD(required_relids);
1736 WRITE_BITMAPSET_FIELD(nullable_relids);
1737 WRITE_BITMAPSET_FIELD(left_relids);
1738 WRITE_BITMAPSET_FIELD(right_relids);
1739 WRITE_NODE_FIELD(orclause);
1740 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1741 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1742 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1743 WRITE_NODE_FIELD(mergeopfamilies);
1744 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1745 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1746 WRITE_NODE_FIELD(left_em);
1747 WRITE_NODE_FIELD(right_em);
1748 WRITE_BOOL_FIELD(outer_is_left);
1749 WRITE_OID_FIELD(hashjoinoperator);
1753 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1755 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1756 WRITE_BITMAPSET_FIELD(other_relids);
1757 WRITE_BOOL_FIELD(isouterjoin);
1758 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1759 WRITE_NODE_FIELD(cheapest_total_innerpath);
1763 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1765 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1767 WRITE_NODE_FIELD(phexpr);
1768 WRITE_BITMAPSET_FIELD(phrels);
1769 WRITE_UINT_FIELD(phid);
1770 WRITE_UINT_FIELD(phlevelsup);
1774 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1776 WRITE_NODE_TYPE("SPECIALJOININFO");
1778 WRITE_BITMAPSET_FIELD(min_lefthand);
1779 WRITE_BITMAPSET_FIELD(min_righthand);
1780 WRITE_BITMAPSET_FIELD(syn_lefthand);
1781 WRITE_BITMAPSET_FIELD(syn_righthand);
1782 WRITE_ENUM_FIELD(jointype, JoinType);
1783 WRITE_BOOL_FIELD(lhs_strict);
1784 WRITE_BOOL_FIELD(delay_upper_joins);
1785 WRITE_NODE_FIELD(join_quals);
1789 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1791 WRITE_NODE_TYPE("APPENDRELINFO");
1793 WRITE_UINT_FIELD(parent_relid);
1794 WRITE_UINT_FIELD(child_relid);
1795 WRITE_OID_FIELD(parent_reltype);
1796 WRITE_OID_FIELD(child_reltype);
1797 WRITE_NODE_FIELD(translated_vars);
1798 WRITE_OID_FIELD(parent_reloid);
1802 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1804 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1806 WRITE_UINT_FIELD(phid);
1807 WRITE_NODE_FIELD(ph_var);
1808 WRITE_BITMAPSET_FIELD(ph_eval_at);
1809 WRITE_BITMAPSET_FIELD(ph_needed);
1810 WRITE_BITMAPSET_FIELD(ph_may_need);
1811 WRITE_INT_FIELD(ph_width);
1815 _outMinMaxAggInfo(StringInfo str, MinMaxAggInfo *node)
1817 WRITE_NODE_TYPE("MINMAXAGGINFO");
1819 WRITE_OID_FIELD(aggfnoid);
1820 WRITE_OID_FIELD(aggsortop);
1821 WRITE_NODE_FIELD(target);
1822 WRITE_NODE_FIELD(pathkeys);
1826 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1828 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1830 WRITE_NODE_FIELD(item);
1831 WRITE_UINT_FIELD(abslevel);
1834 /*****************************************************************************
1836 * Stuff from parsenodes.h.
1838 *****************************************************************************/
1841 _outCreateStmt(StringInfo str, CreateStmt *node)
1843 WRITE_NODE_TYPE("CREATESTMT");
1845 WRITE_NODE_FIELD(relation);
1846 WRITE_NODE_FIELD(tableElts);
1847 WRITE_NODE_FIELD(inhRelations);
1848 WRITE_NODE_FIELD(ofTypename);
1849 WRITE_NODE_FIELD(constraints);
1850 WRITE_NODE_FIELD(options);
1851 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1852 WRITE_STRING_FIELD(tablespacename);
1853 WRITE_BOOL_FIELD(if_not_exists);
1857 _outCreateForeignTableStmt(StringInfo str, CreateForeignTableStmt *node)
1859 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
1861 _outCreateStmt(str, (CreateStmt *) &node->base);
1863 WRITE_STRING_FIELD(servername);
1864 WRITE_NODE_FIELD(options);
1868 _outIndexStmt(StringInfo str, IndexStmt *node)
1870 WRITE_NODE_TYPE("INDEXSTMT");
1872 WRITE_STRING_FIELD(idxname);
1873 WRITE_NODE_FIELD(relation);
1874 WRITE_STRING_FIELD(accessMethod);
1875 WRITE_STRING_FIELD(tableSpace);
1876 WRITE_NODE_FIELD(indexParams);
1877 WRITE_NODE_FIELD(options);
1878 WRITE_NODE_FIELD(whereClause);
1879 WRITE_NODE_FIELD(excludeOpNames);
1880 WRITE_OID_FIELD(indexOid);
1881 WRITE_BOOL_FIELD(unique);
1882 WRITE_BOOL_FIELD(primary);
1883 WRITE_BOOL_FIELD(isconstraint);
1884 WRITE_BOOL_FIELD(deferrable);
1885 WRITE_BOOL_FIELD(initdeferred);
1886 WRITE_BOOL_FIELD(concurrent);
1890 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1892 WRITE_NODE_TYPE("NOTIFY");
1894 WRITE_STRING_FIELD(conditionname);
1895 WRITE_STRING_FIELD(payload);
1899 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1901 WRITE_NODE_TYPE("DECLARECURSOR");
1903 WRITE_STRING_FIELD(portalname);
1904 WRITE_INT_FIELD(options);
1905 WRITE_NODE_FIELD(query);
1909 _outSelectStmt(StringInfo str, SelectStmt *node)
1911 WRITE_NODE_TYPE("SELECT");
1913 WRITE_NODE_FIELD(distinctClause);
1914 WRITE_NODE_FIELD(intoClause);
1915 WRITE_NODE_FIELD(targetList);
1916 WRITE_NODE_FIELD(fromClause);
1917 WRITE_NODE_FIELD(whereClause);
1918 WRITE_NODE_FIELD(groupClause);
1919 WRITE_NODE_FIELD(havingClause);
1920 WRITE_NODE_FIELD(windowClause);
1921 WRITE_NODE_FIELD(withClause);
1922 WRITE_NODE_FIELD(valuesLists);
1923 WRITE_NODE_FIELD(sortClause);
1924 WRITE_NODE_FIELD(limitOffset);
1925 WRITE_NODE_FIELD(limitCount);
1926 WRITE_NODE_FIELD(lockingClause);
1927 WRITE_ENUM_FIELD(op, SetOperation);
1928 WRITE_BOOL_FIELD(all);
1929 WRITE_NODE_FIELD(larg);
1930 WRITE_NODE_FIELD(rarg);
1934 _outFuncCall(StringInfo str, FuncCall *node)
1936 WRITE_NODE_TYPE("FUNCCALL");
1938 WRITE_NODE_FIELD(funcname);
1939 WRITE_NODE_FIELD(args);
1940 WRITE_NODE_FIELD(agg_order);
1941 WRITE_BOOL_FIELD(agg_star);
1942 WRITE_BOOL_FIELD(agg_distinct);
1943 WRITE_BOOL_FIELD(func_variadic);
1944 WRITE_NODE_FIELD(over);
1945 WRITE_LOCATION_FIELD(location);
1949 _outDefElem(StringInfo str, DefElem *node)
1951 WRITE_NODE_TYPE("DEFELEM");
1953 WRITE_STRING_FIELD(defnamespace);
1954 WRITE_STRING_FIELD(defname);
1955 WRITE_NODE_FIELD(arg);
1956 WRITE_ENUM_FIELD(defaction, DefElemAction);
1960 _outInhRelation(StringInfo str, InhRelation *node)
1962 WRITE_NODE_TYPE("INHRELATION");
1964 WRITE_NODE_FIELD(relation);
1965 WRITE_UINT_FIELD(options);
1969 _outLockingClause(StringInfo str, LockingClause *node)
1971 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1973 WRITE_NODE_FIELD(lockedRels);
1974 WRITE_BOOL_FIELD(forUpdate);
1975 WRITE_BOOL_FIELD(noWait);
1979 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1981 WRITE_NODE_TYPE("XMLSERIALIZE");
1983 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1984 WRITE_NODE_FIELD(expr);
1985 WRITE_NODE_FIELD(typeName);
1986 WRITE_LOCATION_FIELD(location);
1990 _outColumnDef(StringInfo str, ColumnDef *node)
1992 WRITE_NODE_TYPE("COLUMNDEF");
1994 WRITE_STRING_FIELD(colname);
1995 WRITE_NODE_FIELD(typeName);
1996 WRITE_INT_FIELD(inhcount);
1997 WRITE_BOOL_FIELD(is_local);
1998 WRITE_BOOL_FIELD(is_not_null);
1999 WRITE_INT_FIELD(storage);
2000 WRITE_NODE_FIELD(raw_default);
2001 WRITE_NODE_FIELD(cooked_default);
2002 WRITE_NODE_FIELD(constraints);
2006 _outTypeName(StringInfo str, TypeName *node)
2008 WRITE_NODE_TYPE("TYPENAME");
2010 WRITE_NODE_FIELD(names);
2011 WRITE_OID_FIELD(typeOid);
2012 WRITE_BOOL_FIELD(setof);
2013 WRITE_BOOL_FIELD(pct_type);
2014 WRITE_NODE_FIELD(typmods);
2015 WRITE_INT_FIELD(typemod);
2016 WRITE_NODE_FIELD(arrayBounds);
2017 WRITE_LOCATION_FIELD(location);
2021 _outTypeCast(StringInfo str, TypeCast *node)
2023 WRITE_NODE_TYPE("TYPECAST");
2025 WRITE_NODE_FIELD(arg);
2026 WRITE_NODE_FIELD(typeName);
2027 WRITE_LOCATION_FIELD(location);
2031 _outIndexElem(StringInfo str, IndexElem *node)
2033 WRITE_NODE_TYPE("INDEXELEM");
2035 WRITE_STRING_FIELD(name);
2036 WRITE_NODE_FIELD(expr);
2037 WRITE_STRING_FIELD(indexcolname);
2038 WRITE_NODE_FIELD(opclass);
2039 WRITE_ENUM_FIELD(ordering, SortByDir);
2040 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2044 _outQuery(StringInfo str, Query *node)
2046 WRITE_NODE_TYPE("QUERY");
2048 WRITE_ENUM_FIELD(commandType, CmdType);
2049 WRITE_ENUM_FIELD(querySource, QuerySource);
2050 WRITE_BOOL_FIELD(canSetTag);
2053 * Hack to work around missing outfuncs routines for a lot of the
2054 * utility-statement node types. (The only one we actually *need* for
2055 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2056 * for the meantime do this to avoid getting lots of warnings when running
2057 * with debug_print_parse on.
2059 if (node->utilityStmt)
2061 switch (nodeTag(node->utilityStmt))
2066 case T_DeclareCursorStmt:
2067 WRITE_NODE_FIELD(utilityStmt);
2070 appendStringInfo(str, " :utilityStmt ?");
2075 appendStringInfo(str, " :utilityStmt <>");
2077 WRITE_INT_FIELD(resultRelation);
2078 WRITE_NODE_FIELD(intoClause);
2079 WRITE_BOOL_FIELD(hasAggs);
2080 WRITE_BOOL_FIELD(hasWindowFuncs);
2081 WRITE_BOOL_FIELD(hasSubLinks);
2082 WRITE_BOOL_FIELD(hasDistinctOn);
2083 WRITE_BOOL_FIELD(hasRecursive);
2084 WRITE_BOOL_FIELD(hasForUpdate);
2085 WRITE_NODE_FIELD(cteList);
2086 WRITE_NODE_FIELD(rtable);
2087 WRITE_NODE_FIELD(jointree);
2088 WRITE_NODE_FIELD(targetList);
2089 WRITE_NODE_FIELD(returningList);
2090 WRITE_NODE_FIELD(groupClause);
2091 WRITE_NODE_FIELD(havingQual);
2092 WRITE_NODE_FIELD(windowClause);
2093 WRITE_NODE_FIELD(distinctClause);
2094 WRITE_NODE_FIELD(sortClause);
2095 WRITE_NODE_FIELD(limitOffset);
2096 WRITE_NODE_FIELD(limitCount);
2097 WRITE_NODE_FIELD(rowMarks);
2098 WRITE_NODE_FIELD(setOperations);
2099 WRITE_NODE_FIELD(constraintDeps);
2103 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2105 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2107 WRITE_UINT_FIELD(tleSortGroupRef);
2108 WRITE_OID_FIELD(eqop);
2109 WRITE_OID_FIELD(sortop);
2110 WRITE_BOOL_FIELD(nulls_first);
2111 WRITE_BOOL_FIELD(hashable);
2115 _outWindowClause(StringInfo str, WindowClause *node)
2117 WRITE_NODE_TYPE("WINDOWCLAUSE");
2119 WRITE_STRING_FIELD(name);
2120 WRITE_STRING_FIELD(refname);
2121 WRITE_NODE_FIELD(partitionClause);
2122 WRITE_NODE_FIELD(orderClause);
2123 WRITE_INT_FIELD(frameOptions);
2124 WRITE_NODE_FIELD(startOffset);
2125 WRITE_NODE_FIELD(endOffset);
2126 WRITE_UINT_FIELD(winref);
2127 WRITE_BOOL_FIELD(copiedOrder);
2131 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2133 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2135 WRITE_UINT_FIELD(rti);
2136 WRITE_BOOL_FIELD(forUpdate);
2137 WRITE_BOOL_FIELD(noWait);
2138 WRITE_BOOL_FIELD(pushedDown);
2142 _outWithClause(StringInfo str, WithClause *node)
2144 WRITE_NODE_TYPE("WITHCLAUSE");
2146 WRITE_NODE_FIELD(ctes);
2147 WRITE_BOOL_FIELD(recursive);
2148 WRITE_LOCATION_FIELD(location);
2152 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2154 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2156 WRITE_STRING_FIELD(ctename);
2157 WRITE_NODE_FIELD(aliascolnames);
2158 WRITE_NODE_FIELD(ctequery);
2159 WRITE_LOCATION_FIELD(location);
2160 WRITE_BOOL_FIELD(cterecursive);
2161 WRITE_INT_FIELD(cterefcount);
2162 WRITE_NODE_FIELD(ctecolnames);
2163 WRITE_NODE_FIELD(ctecoltypes);
2164 WRITE_NODE_FIELD(ctecoltypmods);
2168 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2170 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2172 WRITE_ENUM_FIELD(op, SetOperation);
2173 WRITE_BOOL_FIELD(all);
2174 WRITE_NODE_FIELD(larg);
2175 WRITE_NODE_FIELD(rarg);
2176 WRITE_NODE_FIELD(colTypes);
2177 WRITE_NODE_FIELD(colTypmods);
2178 WRITE_NODE_FIELD(groupClauses);
2182 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2184 WRITE_NODE_TYPE("RTE");
2186 /* put alias + eref first to make dump more legible */
2187 WRITE_NODE_FIELD(alias);
2188 WRITE_NODE_FIELD(eref);
2189 WRITE_ENUM_FIELD(rtekind, RTEKind);
2191 switch (node->rtekind)
2195 WRITE_OID_FIELD(relid);
2198 WRITE_NODE_FIELD(subquery);
2201 WRITE_ENUM_FIELD(jointype, JoinType);
2202 WRITE_NODE_FIELD(joinaliasvars);
2205 WRITE_NODE_FIELD(funcexpr);
2206 WRITE_NODE_FIELD(funccoltypes);
2207 WRITE_NODE_FIELD(funccoltypmods);
2210 WRITE_NODE_FIELD(values_lists);
2213 WRITE_STRING_FIELD(ctename);
2214 WRITE_UINT_FIELD(ctelevelsup);
2215 WRITE_BOOL_FIELD(self_reference);
2216 WRITE_NODE_FIELD(ctecoltypes);
2217 WRITE_NODE_FIELD(ctecoltypmods);
2220 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2224 WRITE_BOOL_FIELD(inh);
2225 WRITE_BOOL_FIELD(inFromCl);
2226 WRITE_UINT_FIELD(requiredPerms);
2227 WRITE_OID_FIELD(checkAsUser);
2228 WRITE_BITMAPSET_FIELD(selectedCols);
2229 WRITE_BITMAPSET_FIELD(modifiedCols);
2233 _outAExpr(StringInfo str, A_Expr *node)
2235 WRITE_NODE_TYPE("AEXPR");
2240 appendStringInfo(str, " ");
2241 WRITE_NODE_FIELD(name);
2244 appendStringInfo(str, " AND");
2247 appendStringInfo(str, " OR");
2250 appendStringInfo(str, " NOT");
2253 appendStringInfo(str, " ");
2254 WRITE_NODE_FIELD(name);
2255 appendStringInfo(str, " ANY ");
2258 appendStringInfo(str, " ");
2259 WRITE_NODE_FIELD(name);
2260 appendStringInfo(str, " ALL ");
2262 case AEXPR_DISTINCT:
2263 appendStringInfo(str, " DISTINCT ");
2264 WRITE_NODE_FIELD(name);
2267 appendStringInfo(str, " NULLIF ");
2268 WRITE_NODE_FIELD(name);
2271 appendStringInfo(str, " OF ");
2272 WRITE_NODE_FIELD(name);
2275 appendStringInfo(str, " IN ");
2276 WRITE_NODE_FIELD(name);
2279 appendStringInfo(str, " ??");
2283 WRITE_NODE_FIELD(lexpr);
2284 WRITE_NODE_FIELD(rexpr);
2285 WRITE_LOCATION_FIELD(location);
2289 _outValue(StringInfo str, Value *value)
2291 switch (value->type)
2294 appendStringInfo(str, "%ld", value->val.ival);
2299 * We assume the value is a valid numeric literal and so does not
2302 appendStringInfoString(str, value->val.str);
2305 appendStringInfoChar(str, '"');
2306 _outToken(str, value->val.str);
2307 appendStringInfoChar(str, '"');
2310 /* internal representation already has leading 'b' */
2311 appendStringInfoString(str, value->val.str);
2314 /* this is seen only within A_Const, not in transformed trees */
2315 appendStringInfoString(str, "NULL");
2318 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2324 _outColumnRef(StringInfo str, ColumnRef *node)
2326 WRITE_NODE_TYPE("COLUMNREF");
2328 WRITE_NODE_FIELD(fields);
2329 WRITE_LOCATION_FIELD(location);
2333 _outParamRef(StringInfo str, ParamRef *node)
2335 WRITE_NODE_TYPE("PARAMREF");
2337 WRITE_INT_FIELD(number);
2338 WRITE_LOCATION_FIELD(location);
2342 _outAConst(StringInfo str, A_Const *node)
2344 WRITE_NODE_TYPE("A_CONST");
2346 appendStringInfo(str, " :val ");
2347 _outValue(str, &(node->val));
2348 WRITE_LOCATION_FIELD(location);
2352 _outA_Star(StringInfo str, A_Star *node)
2354 WRITE_NODE_TYPE("A_STAR");
2358 _outA_Indices(StringInfo str, A_Indices *node)
2360 WRITE_NODE_TYPE("A_INDICES");
2362 WRITE_NODE_FIELD(lidx);
2363 WRITE_NODE_FIELD(uidx);
2367 _outA_Indirection(StringInfo str, A_Indirection *node)
2369 WRITE_NODE_TYPE("A_INDIRECTION");
2371 WRITE_NODE_FIELD(arg);
2372 WRITE_NODE_FIELD(indirection);
2376 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2378 WRITE_NODE_TYPE("A_ARRAYEXPR");
2380 WRITE_NODE_FIELD(elements);
2381 WRITE_LOCATION_FIELD(location);
2385 _outResTarget(StringInfo str, ResTarget *node)
2387 WRITE_NODE_TYPE("RESTARGET");
2389 WRITE_STRING_FIELD(name);
2390 WRITE_NODE_FIELD(indirection);
2391 WRITE_NODE_FIELD(val);
2392 WRITE_LOCATION_FIELD(location);
2396 _outSortBy(StringInfo str, SortBy *node)
2398 WRITE_NODE_TYPE("SORTBY");
2400 WRITE_NODE_FIELD(node);
2401 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2402 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2403 WRITE_NODE_FIELD(useOp);
2404 WRITE_LOCATION_FIELD(location);
2408 _outWindowDef(StringInfo str, WindowDef *node)
2410 WRITE_NODE_TYPE("WINDOWDEF");
2412 WRITE_STRING_FIELD(name);
2413 WRITE_STRING_FIELD(refname);
2414 WRITE_NODE_FIELD(partitionClause);
2415 WRITE_NODE_FIELD(orderClause);
2416 WRITE_INT_FIELD(frameOptions);
2417 WRITE_NODE_FIELD(startOffset);
2418 WRITE_NODE_FIELD(endOffset);
2419 WRITE_LOCATION_FIELD(location);
2423 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2425 WRITE_NODE_TYPE("RANGESUBSELECT");
2427 WRITE_NODE_FIELD(subquery);
2428 WRITE_NODE_FIELD(alias);
2432 _outRangeFunction(StringInfo str, RangeFunction *node)
2434 WRITE_NODE_TYPE("RANGEFUNCTION");
2436 WRITE_NODE_FIELD(funccallnode);
2437 WRITE_NODE_FIELD(alias);
2438 WRITE_NODE_FIELD(coldeflist);
2442 _outConstraint(StringInfo str, Constraint *node)
2444 WRITE_NODE_TYPE("CONSTRAINT");
2446 WRITE_STRING_FIELD(conname);
2447 WRITE_BOOL_FIELD(deferrable);
2448 WRITE_BOOL_FIELD(initdeferred);
2449 WRITE_LOCATION_FIELD(location);
2451 appendStringInfo(str, " :contype ");
2452 switch (node->contype)
2455 appendStringInfo(str, "NULL");
2458 case CONSTR_NOTNULL:
2459 appendStringInfo(str, "NOT_NULL");
2462 case CONSTR_DEFAULT:
2463 appendStringInfo(str, "DEFAULT");
2464 WRITE_NODE_FIELD(raw_expr);
2465 WRITE_STRING_FIELD(cooked_expr);
2469 appendStringInfo(str, "CHECK");
2470 WRITE_NODE_FIELD(raw_expr);
2471 WRITE_STRING_FIELD(cooked_expr);
2474 case CONSTR_PRIMARY:
2475 appendStringInfo(str, "PRIMARY_KEY");
2476 WRITE_NODE_FIELD(keys);
2477 WRITE_NODE_FIELD(options);
2478 WRITE_STRING_FIELD(indexname);
2479 WRITE_STRING_FIELD(indexspace);
2480 /* access_method and where_clause not currently used */
2484 appendStringInfo(str, "UNIQUE");
2485 WRITE_NODE_FIELD(keys);
2486 WRITE_NODE_FIELD(options);
2487 WRITE_STRING_FIELD(indexname);
2488 WRITE_STRING_FIELD(indexspace);
2489 /* access_method and where_clause not currently used */
2492 case CONSTR_EXCLUSION:
2493 appendStringInfo(str, "EXCLUSION");
2494 WRITE_NODE_FIELD(exclusions);
2495 WRITE_NODE_FIELD(options);
2496 WRITE_STRING_FIELD(indexname);
2497 WRITE_STRING_FIELD(indexspace);
2498 WRITE_STRING_FIELD(access_method);
2499 WRITE_NODE_FIELD(where_clause);
2502 case CONSTR_FOREIGN:
2503 appendStringInfo(str, "FOREIGN_KEY");
2504 WRITE_NODE_FIELD(pktable);
2505 WRITE_NODE_FIELD(fk_attrs);
2506 WRITE_NODE_FIELD(pk_attrs);
2507 WRITE_CHAR_FIELD(fk_matchtype);
2508 WRITE_CHAR_FIELD(fk_upd_action);
2509 WRITE_CHAR_FIELD(fk_del_action);
2510 WRITE_BOOL_FIELD(skip_validation);
2513 case CONSTR_ATTR_DEFERRABLE:
2514 appendStringInfo(str, "ATTR_DEFERRABLE");
2517 case CONSTR_ATTR_NOT_DEFERRABLE:
2518 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2521 case CONSTR_ATTR_DEFERRED:
2522 appendStringInfo(str, "ATTR_DEFERRED");
2525 case CONSTR_ATTR_IMMEDIATE:
2526 appendStringInfo(str, "ATTR_IMMEDIATE");
2530 appendStringInfo(str, "<unrecognized_constraint %d>",
2531 (int) node->contype);
2539 * converts a Node into ascii string and append it to 'str'
2542 _outNode(StringInfo str, void *obj)
2545 appendStringInfo(str, "<>");
2546 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2548 else if (IsA(obj, Integer) ||
2551 IsA(obj, BitString))
2553 /* nodeRead does not want to see { } around these! */
2554 _outValue(str, obj);
2558 appendStringInfoChar(str, '{');
2559 switch (nodeTag(obj))
2562 _outPlannedStmt(str, obj);
2568 _outResult(str, obj);
2571 _outModifyTable(str, obj);
2574 _outAppend(str, obj);
2577 _outMergeAppend(str, obj);
2579 case T_RecursiveUnion:
2580 _outRecursiveUnion(str, obj);
2583 _outBitmapAnd(str, obj);
2586 _outBitmapOr(str, obj);
2592 _outSeqScan(str, obj);
2595 _outIndexScan(str, obj);
2597 case T_BitmapIndexScan:
2598 _outBitmapIndexScan(str, obj);
2600 case T_BitmapHeapScan:
2601 _outBitmapHeapScan(str, obj);
2604 _outTidScan(str, obj);
2606 case T_SubqueryScan:
2607 _outSubqueryScan(str, obj);
2609 case T_FunctionScan:
2610 _outFunctionScan(str, obj);
2613 _outValuesScan(str, obj);
2616 _outCteScan(str, obj);
2618 case T_WorkTableScan:
2619 _outWorkTableScan(str, obj);
2625 _outNestLoop(str, obj);
2628 _outMergeJoin(str, obj);
2631 _outHashJoin(str, obj);
2637 _outWindowAgg(str, obj);
2640 _outGroup(str, obj);
2643 _outMaterial(str, obj);
2649 _outUnique(str, obj);
2655 _outSetOp(str, obj);
2658 _outLockRows(str, obj);
2661 _outLimit(str, obj);
2663 case T_NestLoopParam:
2664 _outNestLoopParam(str, obj);
2667 _outPlanRowMark(str, obj);
2669 case T_PlanInvalItem:
2670 _outPlanInvalItem(str, obj);
2673 _outAlias(str, obj);
2676 _outRangeVar(str, obj);
2679 _outIntoClause(str, obj);
2685 _outConst(str, obj);
2688 _outParam(str, obj);
2691 _outAggref(str, obj);
2694 _outWindowFunc(str, obj);
2697 _outArrayRef(str, obj);
2700 _outFuncExpr(str, obj);
2702 case T_NamedArgExpr:
2703 _outNamedArgExpr(str, obj);
2706 _outOpExpr(str, obj);
2708 case T_DistinctExpr:
2709 _outDistinctExpr(str, obj);
2711 case T_ScalarArrayOpExpr:
2712 _outScalarArrayOpExpr(str, obj);
2715 _outBoolExpr(str, obj);
2718 _outSubLink(str, obj);
2721 _outSubPlan(str, obj);
2723 case T_AlternativeSubPlan:
2724 _outAlternativeSubPlan(str, obj);
2727 _outFieldSelect(str, obj);
2730 _outFieldStore(str, obj);
2733 _outRelabelType(str, obj);
2736 _outCoerceViaIO(str, obj);
2738 case T_ArrayCoerceExpr:
2739 _outArrayCoerceExpr(str, obj);
2741 case T_ConvertRowtypeExpr:
2742 _outConvertRowtypeExpr(str, obj);
2745 _outCaseExpr(str, obj);
2748 _outCaseWhen(str, obj);
2750 case T_CaseTestExpr:
2751 _outCaseTestExpr(str, obj);
2754 _outArrayExpr(str, obj);
2757 _outRowExpr(str, obj);
2759 case T_RowCompareExpr:
2760 _outRowCompareExpr(str, obj);
2762 case T_CoalesceExpr:
2763 _outCoalesceExpr(str, obj);
2766 _outMinMaxExpr(str, obj);
2769 _outXmlExpr(str, obj);
2772 _outNullIfExpr(str, obj);
2775 _outNullTest(str, obj);
2778 _outBooleanTest(str, obj);
2780 case T_CoerceToDomain:
2781 _outCoerceToDomain(str, obj);
2783 case T_CoerceToDomainValue:
2784 _outCoerceToDomainValue(str, obj);
2786 case T_SetToDefault:
2787 _outSetToDefault(str, obj);
2789 case T_CurrentOfExpr:
2790 _outCurrentOfExpr(str, obj);
2793 _outTargetEntry(str, obj);
2796 _outRangeTblRef(str, obj);
2799 _outJoinExpr(str, obj);
2802 _outFromExpr(str, obj);
2809 _outIndexPath(str, obj);
2811 case T_BitmapHeapPath:
2812 _outBitmapHeapPath(str, obj);
2814 case T_BitmapAndPath:
2815 _outBitmapAndPath(str, obj);
2817 case T_BitmapOrPath:
2818 _outBitmapOrPath(str, obj);
2821 _outTidPath(str, obj);
2824 _outAppendPath(str, obj);
2826 case T_MergeAppendPath:
2827 _outMergeAppendPath(str, obj);
2830 _outResultPath(str, obj);
2832 case T_MaterialPath:
2833 _outMaterialPath(str, obj);
2836 _outUniquePath(str, obj);
2839 _outNestPath(str, obj);
2842 _outMergePath(str, obj);
2845 _outHashPath(str, obj);
2847 case T_PlannerGlobal:
2848 _outPlannerGlobal(str, obj);
2851 _outPlannerInfo(str, obj);
2854 _outRelOptInfo(str, obj);
2856 case T_IndexOptInfo:
2857 _outIndexOptInfo(str, obj);
2859 case T_EquivalenceClass:
2860 _outEquivalenceClass(str, obj);
2862 case T_EquivalenceMember:
2863 _outEquivalenceMember(str, obj);
2866 _outPathKey(str, obj);
2868 case T_RestrictInfo:
2869 _outRestrictInfo(str, obj);
2871 case T_InnerIndexscanInfo:
2872 _outInnerIndexscanInfo(str, obj);
2874 case T_PlaceHolderVar:
2875 _outPlaceHolderVar(str, obj);
2877 case T_SpecialJoinInfo:
2878 _outSpecialJoinInfo(str, obj);
2880 case T_AppendRelInfo:
2881 _outAppendRelInfo(str, obj);
2883 case T_PlaceHolderInfo:
2884 _outPlaceHolderInfo(str, obj);
2886 case T_MinMaxAggInfo:
2887 _outMinMaxAggInfo(str, obj);
2889 case T_PlannerParamItem:
2890 _outPlannerParamItem(str, obj);
2894 _outCreateStmt(str, obj);
2896 case T_CreateForeignTableStmt:
2897 _outCreateForeignTableStmt(str, obj);
2900 _outIndexStmt(str, obj);
2903 _outNotifyStmt(str, obj);
2905 case T_DeclareCursorStmt:
2906 _outDeclareCursorStmt(str, obj);
2909 _outSelectStmt(str, obj);
2912 _outColumnDef(str, obj);
2915 _outTypeName(str, obj);
2918 _outTypeCast(str, obj);
2921 _outIndexElem(str, obj);
2924 _outQuery(str, obj);
2926 case T_SortGroupClause:
2927 _outSortGroupClause(str, obj);
2929 case T_WindowClause:
2930 _outWindowClause(str, obj);
2932 case T_RowMarkClause:
2933 _outRowMarkClause(str, obj);
2936 _outWithClause(str, obj);
2938 case T_CommonTableExpr:
2939 _outCommonTableExpr(str, obj);
2941 case T_SetOperationStmt:
2942 _outSetOperationStmt(str, obj);
2944 case T_RangeTblEntry:
2945 _outRangeTblEntry(str, obj);
2948 _outAExpr(str, obj);
2951 _outColumnRef(str, obj);
2954 _outParamRef(str, obj);
2957 _outAConst(str, obj);
2960 _outA_Star(str, obj);
2963 _outA_Indices(str, obj);
2965 case T_A_Indirection:
2966 _outA_Indirection(str, obj);
2969 _outA_ArrayExpr(str, obj);
2972 _outResTarget(str, obj);
2975 _outSortBy(str, obj);
2978 _outWindowDef(str, obj);
2980 case T_RangeSubselect:
2981 _outRangeSubselect(str, obj);
2983 case T_RangeFunction:
2984 _outRangeFunction(str, obj);
2987 _outConstraint(str, obj);
2990 _outFuncCall(str, obj);
2993 _outDefElem(str, obj);
2996 _outInhRelation(str, obj);
2998 case T_LockingClause:
2999 _outLockingClause(str, obj);
3001 case T_XmlSerialize:
3002 _outXmlSerialize(str, obj);
3008 * This should be an ERROR, but it's too useful to be able to
3009 * dump structures that _outNode only understands part of.
3011 elog(WARNING, "could not dump unrecognized node type: %d",
3012 (int) nodeTag(obj));
3015 appendStringInfoChar(str, '}');
3021 * returns the ascii representation of the Node as a palloc'd string
3024 nodeToString(void *obj)
3028 /* see stringinfo.h for an explanation of this maneuver */
3029 initStringInfo(&str);
3030 _outNode(&str, obj);