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, " :collations");
369 for (i = 0; i < node->numCols; i++)
370 appendStringInfo(str, " %u", node->collations[i]);
372 appendStringInfo(str, " :nullsFirst");
373 for (i = 0; i < node->numCols; i++)
374 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
378 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
382 WRITE_NODE_TYPE("RECURSIVEUNION");
384 _outPlanInfo(str, (Plan *) node);
386 WRITE_INT_FIELD(wtParam);
387 WRITE_INT_FIELD(numCols);
389 appendStringInfo(str, " :dupColIdx");
390 for (i = 0; i < node->numCols; i++)
391 appendStringInfo(str, " %d", node->dupColIdx[i]);
393 appendStringInfo(str, " :dupOperators");
394 for (i = 0; i < node->numCols; i++)
395 appendStringInfo(str, " %u", node->dupOperators[i]);
397 WRITE_LONG_FIELD(numGroups);
401 _outBitmapAnd(StringInfo str, BitmapAnd *node)
403 WRITE_NODE_TYPE("BITMAPAND");
405 _outPlanInfo(str, (Plan *) node);
407 WRITE_NODE_FIELD(bitmapplans);
411 _outBitmapOr(StringInfo str, BitmapOr *node)
413 WRITE_NODE_TYPE("BITMAPOR");
415 _outPlanInfo(str, (Plan *) node);
417 WRITE_NODE_FIELD(bitmapplans);
421 _outScan(StringInfo str, Scan *node)
423 WRITE_NODE_TYPE("SCAN");
425 _outScanInfo(str, (Scan *) node);
429 _outSeqScan(StringInfo str, SeqScan *node)
431 WRITE_NODE_TYPE("SEQSCAN");
433 _outScanInfo(str, (Scan *) node);
437 _outIndexScan(StringInfo str, IndexScan *node)
439 WRITE_NODE_TYPE("INDEXSCAN");
441 _outScanInfo(str, (Scan *) node);
443 WRITE_OID_FIELD(indexid);
444 WRITE_NODE_FIELD(indexqual);
445 WRITE_NODE_FIELD(indexqualorig);
446 WRITE_NODE_FIELD(indexorderby);
447 WRITE_NODE_FIELD(indexorderbyorig);
448 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
452 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
454 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
456 _outScanInfo(str, (Scan *) node);
458 WRITE_OID_FIELD(indexid);
459 WRITE_NODE_FIELD(indexqual);
460 WRITE_NODE_FIELD(indexqualorig);
464 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
466 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
468 _outScanInfo(str, (Scan *) node);
470 WRITE_NODE_FIELD(bitmapqualorig);
474 _outTidScan(StringInfo str, TidScan *node)
476 WRITE_NODE_TYPE("TIDSCAN");
478 _outScanInfo(str, (Scan *) node);
480 WRITE_NODE_FIELD(tidquals);
484 _outSubqueryScan(StringInfo str, SubqueryScan *node)
486 WRITE_NODE_TYPE("SUBQUERYSCAN");
488 _outScanInfo(str, (Scan *) node);
490 WRITE_NODE_FIELD(subplan);
491 WRITE_NODE_FIELD(subrtable);
492 WRITE_NODE_FIELD(subrowmark);
496 _outFunctionScan(StringInfo str, FunctionScan *node)
498 WRITE_NODE_TYPE("FUNCTIONSCAN");
500 _outScanInfo(str, (Scan *) node);
502 WRITE_NODE_FIELD(funcexpr);
503 WRITE_NODE_FIELD(funccolnames);
504 WRITE_NODE_FIELD(funccoltypes);
505 WRITE_NODE_FIELD(funccoltypmods);
506 WRITE_NODE_FIELD(funccolcollations);
510 _outValuesScan(StringInfo str, ValuesScan *node)
512 WRITE_NODE_TYPE("VALUESSCAN");
514 _outScanInfo(str, (Scan *) node);
516 WRITE_NODE_FIELD(values_lists);
520 _outCteScan(StringInfo str, CteScan *node)
522 WRITE_NODE_TYPE("CTESCAN");
524 _outScanInfo(str, (Scan *) node);
526 WRITE_INT_FIELD(ctePlanId);
527 WRITE_INT_FIELD(cteParam);
531 _outWorkTableScan(StringInfo str, WorkTableScan *node)
533 WRITE_NODE_TYPE("WORKTABLESCAN");
535 _outScanInfo(str, (Scan *) node);
537 WRITE_INT_FIELD(wtParam);
541 _outJoin(StringInfo str, Join *node)
543 WRITE_NODE_TYPE("JOIN");
545 _outJoinPlanInfo(str, (Join *) node);
549 _outNestLoop(StringInfo str, NestLoop *node)
551 WRITE_NODE_TYPE("NESTLOOP");
553 _outJoinPlanInfo(str, (Join *) node);
555 WRITE_NODE_FIELD(nestParams);
559 _outMergeJoin(StringInfo str, MergeJoin *node)
564 WRITE_NODE_TYPE("MERGEJOIN");
566 _outJoinPlanInfo(str, (Join *) node);
568 WRITE_NODE_FIELD(mergeclauses);
570 numCols = list_length(node->mergeclauses);
572 appendStringInfo(str, " :mergeFamilies");
573 for (i = 0; i < numCols; i++)
574 appendStringInfo(str, " %u", node->mergeFamilies[i]);
576 appendStringInfo(str, " :mergeCollations");
577 for (i = 0; i < numCols; i++)
578 appendStringInfo(str, " %u", node->mergeCollations[i]);
580 appendStringInfo(str, " :mergeStrategies");
581 for (i = 0; i < numCols; i++)
582 appendStringInfo(str, " %d", node->mergeStrategies[i]);
584 appendStringInfo(str, " :mergeNullsFirst");
585 for (i = 0; i < numCols; i++)
586 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
590 _outHashJoin(StringInfo str, HashJoin *node)
592 WRITE_NODE_TYPE("HASHJOIN");
594 _outJoinPlanInfo(str, (Join *) node);
596 WRITE_NODE_FIELD(hashclauses);
600 _outAgg(StringInfo str, Agg *node)
604 WRITE_NODE_TYPE("AGG");
606 _outPlanInfo(str, (Plan *) node);
608 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
609 WRITE_INT_FIELD(numCols);
611 appendStringInfo(str, " :grpColIdx");
612 for (i = 0; i < node->numCols; i++)
613 appendStringInfo(str, " %d", node->grpColIdx[i]);
615 appendStringInfo(str, " :grpOperators");
616 for (i = 0; i < node->numCols; i++)
617 appendStringInfo(str, " %u", node->grpOperators[i]);
619 WRITE_LONG_FIELD(numGroups);
623 _outWindowAgg(StringInfo str, WindowAgg *node)
627 WRITE_NODE_TYPE("WINDOWAGG");
629 _outPlanInfo(str, (Plan *) node);
631 WRITE_UINT_FIELD(winref);
632 WRITE_INT_FIELD(partNumCols);
634 appendStringInfo(str, " :partColIdx");
635 for (i = 0; i < node->partNumCols; i++)
636 appendStringInfo(str, " %d", node->partColIdx[i]);
638 appendStringInfo(str, " :partOperations");
639 for (i = 0; i < node->partNumCols; i++)
640 appendStringInfo(str, " %u", node->partOperators[i]);
642 WRITE_INT_FIELD(ordNumCols);
644 appendStringInfo(str, " :ordColIdx");
645 for (i = 0; i < node->ordNumCols; i++)
646 appendStringInfo(str, " %d", node->ordColIdx[i]);
648 appendStringInfo(str, " :ordOperations");
649 for (i = 0; i < node->ordNumCols; i++)
650 appendStringInfo(str, " %u", node->ordOperators[i]);
652 WRITE_INT_FIELD(frameOptions);
653 WRITE_NODE_FIELD(startOffset);
654 WRITE_NODE_FIELD(endOffset);
658 _outGroup(StringInfo str, Group *node)
662 WRITE_NODE_TYPE("GROUP");
664 _outPlanInfo(str, (Plan *) node);
666 WRITE_INT_FIELD(numCols);
668 appendStringInfo(str, " :grpColIdx");
669 for (i = 0; i < node->numCols; i++)
670 appendStringInfo(str, " %d", node->grpColIdx[i]);
672 appendStringInfo(str, " :grpOperators");
673 for (i = 0; i < node->numCols; i++)
674 appendStringInfo(str, " %u", node->grpOperators[i]);
678 _outMaterial(StringInfo str, Material *node)
680 WRITE_NODE_TYPE("MATERIAL");
682 _outPlanInfo(str, (Plan *) node);
686 _outSort(StringInfo str, Sort *node)
690 WRITE_NODE_TYPE("SORT");
692 _outPlanInfo(str, (Plan *) node);
694 WRITE_INT_FIELD(numCols);
696 appendStringInfo(str, " :sortColIdx");
697 for (i = 0; i < node->numCols; i++)
698 appendStringInfo(str, " %d", node->sortColIdx[i]);
700 appendStringInfo(str, " :sortOperators");
701 for (i = 0; i < node->numCols; i++)
702 appendStringInfo(str, " %u", node->sortOperators[i]);
704 appendStringInfo(str, " :collations");
705 for (i = 0; i < node->numCols; i++)
706 appendStringInfo(str, " %u", node->collations[i]);
708 appendStringInfo(str, " :nullsFirst");
709 for (i = 0; i < node->numCols; i++)
710 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
714 _outUnique(StringInfo str, Unique *node)
718 WRITE_NODE_TYPE("UNIQUE");
720 _outPlanInfo(str, (Plan *) node);
722 WRITE_INT_FIELD(numCols);
724 appendStringInfo(str, " :uniqColIdx");
725 for (i = 0; i < node->numCols; i++)
726 appendStringInfo(str, " %d", node->uniqColIdx[i]);
728 appendStringInfo(str, " :uniqOperators");
729 for (i = 0; i < node->numCols; i++)
730 appendStringInfo(str, " %u", node->uniqOperators[i]);
734 _outHash(StringInfo str, Hash *node)
736 WRITE_NODE_TYPE("HASH");
738 _outPlanInfo(str, (Plan *) node);
740 WRITE_OID_FIELD(skewTable);
741 WRITE_INT_FIELD(skewColumn);
742 WRITE_BOOL_FIELD(skewInherit);
743 WRITE_OID_FIELD(skewColType);
744 WRITE_INT_FIELD(skewColTypmod);
748 _outSetOp(StringInfo str, SetOp *node)
752 WRITE_NODE_TYPE("SETOP");
754 _outPlanInfo(str, (Plan *) node);
756 WRITE_ENUM_FIELD(cmd, SetOpCmd);
757 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
758 WRITE_INT_FIELD(numCols);
760 appendStringInfo(str, " :dupColIdx");
761 for (i = 0; i < node->numCols; i++)
762 appendStringInfo(str, " %d", node->dupColIdx[i]);
764 appendStringInfo(str, " :dupOperators");
765 for (i = 0; i < node->numCols; i++)
766 appendStringInfo(str, " %u", node->dupOperators[i]);
768 WRITE_INT_FIELD(flagColIdx);
769 WRITE_INT_FIELD(firstFlag);
770 WRITE_LONG_FIELD(numGroups);
774 _outLockRows(StringInfo str, LockRows *node)
776 WRITE_NODE_TYPE("LOCKROWS");
778 _outPlanInfo(str, (Plan *) node);
780 WRITE_NODE_FIELD(rowMarks);
781 WRITE_INT_FIELD(epqParam);
785 _outLimit(StringInfo str, Limit *node)
787 WRITE_NODE_TYPE("LIMIT");
789 _outPlanInfo(str, (Plan *) node);
791 WRITE_NODE_FIELD(limitOffset);
792 WRITE_NODE_FIELD(limitCount);
796 _outNestLoopParam(StringInfo str, NestLoopParam *node)
798 WRITE_NODE_TYPE("NESTLOOPPARAM");
800 WRITE_INT_FIELD(paramno);
801 WRITE_NODE_FIELD(paramval);
805 _outPlanRowMark(StringInfo str, PlanRowMark *node)
807 WRITE_NODE_TYPE("PLANROWMARK");
809 WRITE_UINT_FIELD(rti);
810 WRITE_UINT_FIELD(prti);
811 WRITE_UINT_FIELD(rowmarkId);
812 WRITE_ENUM_FIELD(markType, RowMarkType);
813 WRITE_BOOL_FIELD(noWait);
814 WRITE_BOOL_FIELD(isParent);
818 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
820 WRITE_NODE_TYPE("PLANINVALITEM");
822 WRITE_INT_FIELD(cacheId);
823 appendStringInfo(str, " :tupleId (%u,%u)",
824 ItemPointerGetBlockNumber(&node->tupleId),
825 ItemPointerGetOffsetNumber(&node->tupleId));
828 /*****************************************************************************
830 * Stuff from primnodes.h.
832 *****************************************************************************/
835 _outAlias(StringInfo str, Alias *node)
837 WRITE_NODE_TYPE("ALIAS");
839 WRITE_STRING_FIELD(aliasname);
840 WRITE_NODE_FIELD(colnames);
844 _outRangeVar(StringInfo str, RangeVar *node)
846 WRITE_NODE_TYPE("RANGEVAR");
849 * we deliberately ignore catalogname here, since it is presently not
850 * semantically meaningful
852 WRITE_STRING_FIELD(schemaname);
853 WRITE_STRING_FIELD(relname);
854 WRITE_ENUM_FIELD(inhOpt, InhOption);
855 WRITE_CHAR_FIELD(relpersistence);
856 WRITE_NODE_FIELD(alias);
857 WRITE_LOCATION_FIELD(location);
861 _outIntoClause(StringInfo str, IntoClause *node)
863 WRITE_NODE_TYPE("INTOCLAUSE");
865 WRITE_NODE_FIELD(rel);
866 WRITE_NODE_FIELD(colNames);
867 WRITE_NODE_FIELD(options);
868 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
869 WRITE_STRING_FIELD(tableSpaceName);
873 _outVar(StringInfo str, Var *node)
875 WRITE_NODE_TYPE("VAR");
877 WRITE_UINT_FIELD(varno);
878 WRITE_INT_FIELD(varattno);
879 WRITE_OID_FIELD(vartype);
880 WRITE_INT_FIELD(vartypmod);
881 WRITE_OID_FIELD(varcollid);
882 WRITE_UINT_FIELD(varlevelsup);
883 WRITE_UINT_FIELD(varnoold);
884 WRITE_INT_FIELD(varoattno);
885 WRITE_LOCATION_FIELD(location);
889 _outConst(StringInfo str, Const *node)
891 WRITE_NODE_TYPE("CONST");
893 WRITE_OID_FIELD(consttype);
894 WRITE_INT_FIELD(consttypmod);
895 WRITE_OID_FIELD(constcollid);
896 WRITE_INT_FIELD(constlen);
897 WRITE_BOOL_FIELD(constbyval);
898 WRITE_BOOL_FIELD(constisnull);
899 WRITE_LOCATION_FIELD(location);
901 appendStringInfo(str, " :constvalue ");
902 if (node->constisnull)
903 appendStringInfo(str, "<>");
905 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
909 _outParam(StringInfo str, Param *node)
911 WRITE_NODE_TYPE("PARAM");
913 WRITE_ENUM_FIELD(paramkind, ParamKind);
914 WRITE_INT_FIELD(paramid);
915 WRITE_OID_FIELD(paramtype);
916 WRITE_INT_FIELD(paramtypmod);
917 WRITE_OID_FIELD(paramcollation);
918 WRITE_LOCATION_FIELD(location);
922 _outAggref(StringInfo str, Aggref *node)
924 WRITE_NODE_TYPE("AGGREF");
926 WRITE_OID_FIELD(aggfnoid);
927 WRITE_OID_FIELD(aggtype);
928 WRITE_NODE_FIELD(args);
929 WRITE_NODE_FIELD(aggorder);
930 WRITE_NODE_FIELD(aggdistinct);
931 WRITE_BOOL_FIELD(aggstar);
932 WRITE_UINT_FIELD(agglevelsup);
933 WRITE_OID_FIELD(collid);
934 WRITE_LOCATION_FIELD(location);
938 _outWindowFunc(StringInfo str, WindowFunc *node)
940 WRITE_NODE_TYPE("WINDOWFUNC");
942 WRITE_OID_FIELD(winfnoid);
943 WRITE_OID_FIELD(wintype);
944 WRITE_NODE_FIELD(args);
945 WRITE_UINT_FIELD(winref);
946 WRITE_BOOL_FIELD(winstar);
947 WRITE_BOOL_FIELD(winagg);
948 WRITE_OID_FIELD(collid);
949 WRITE_LOCATION_FIELD(location);
953 _outArrayRef(StringInfo str, ArrayRef *node)
955 WRITE_NODE_TYPE("ARRAYREF");
957 WRITE_OID_FIELD(refarraytype);
958 WRITE_OID_FIELD(refelemtype);
959 WRITE_INT_FIELD(reftypmod);
960 WRITE_INT_FIELD(refcollid);
961 WRITE_NODE_FIELD(refupperindexpr);
962 WRITE_NODE_FIELD(reflowerindexpr);
963 WRITE_NODE_FIELD(refexpr);
964 WRITE_NODE_FIELD(refassgnexpr);
968 _outFuncExpr(StringInfo str, FuncExpr *node)
970 WRITE_NODE_TYPE("FUNCEXPR");
972 WRITE_OID_FIELD(funcid);
973 WRITE_OID_FIELD(funcresulttype);
974 WRITE_BOOL_FIELD(funcretset);
975 WRITE_ENUM_FIELD(funcformat, CoercionForm);
976 WRITE_NODE_FIELD(args);
977 WRITE_OID_FIELD(collid);
978 WRITE_LOCATION_FIELD(location);
982 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
984 WRITE_NODE_TYPE("NAMEDARGEXPR");
986 WRITE_NODE_FIELD(arg);
987 WRITE_STRING_FIELD(name);
988 WRITE_INT_FIELD(argnumber);
989 WRITE_LOCATION_FIELD(location);
993 _outOpExpr(StringInfo str, OpExpr *node)
995 WRITE_NODE_TYPE("OPEXPR");
997 WRITE_OID_FIELD(opno);
998 WRITE_OID_FIELD(opfuncid);
999 WRITE_OID_FIELD(opresulttype);
1000 WRITE_BOOL_FIELD(opretset);
1001 WRITE_NODE_FIELD(args);
1002 WRITE_OID_FIELD(collid);
1003 WRITE_LOCATION_FIELD(location);
1007 _outDistinctExpr(StringInfo str, DistinctExpr *node)
1009 WRITE_NODE_TYPE("DISTINCTEXPR");
1011 WRITE_OID_FIELD(opno);
1012 WRITE_OID_FIELD(opfuncid);
1013 WRITE_OID_FIELD(opresulttype);
1014 WRITE_BOOL_FIELD(opretset);
1015 WRITE_NODE_FIELD(args);
1016 WRITE_OID_FIELD(collid);
1017 WRITE_LOCATION_FIELD(location);
1021 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
1023 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1025 WRITE_OID_FIELD(opno);
1026 WRITE_OID_FIELD(opfuncid);
1027 WRITE_BOOL_FIELD(useOr);
1028 WRITE_NODE_FIELD(args);
1029 WRITE_OID_FIELD(collid);
1030 WRITE_LOCATION_FIELD(location);
1034 _outBoolExpr(StringInfo str, BoolExpr *node)
1038 WRITE_NODE_TYPE("BOOLEXPR");
1040 /* do-it-yourself enum representation */
1041 switch (node->boolop)
1053 appendStringInfo(str, " :boolop ");
1054 _outToken(str, opstr);
1056 WRITE_NODE_FIELD(args);
1057 WRITE_LOCATION_FIELD(location);
1061 _outSubLink(StringInfo str, SubLink *node)
1063 WRITE_NODE_TYPE("SUBLINK");
1065 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1066 WRITE_NODE_FIELD(testexpr);
1067 WRITE_NODE_FIELD(operName);
1068 WRITE_NODE_FIELD(subselect);
1069 WRITE_LOCATION_FIELD(location);
1073 _outSubPlan(StringInfo str, SubPlan *node)
1075 WRITE_NODE_TYPE("SUBPLAN");
1077 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1078 WRITE_NODE_FIELD(testexpr);
1079 WRITE_NODE_FIELD(paramIds);
1080 WRITE_INT_FIELD(plan_id);
1081 WRITE_STRING_FIELD(plan_name);
1082 WRITE_OID_FIELD(firstColType);
1083 WRITE_INT_FIELD(firstColTypmod);
1084 WRITE_OID_FIELD(firstColCollation);
1085 WRITE_BOOL_FIELD(useHashTable);
1086 WRITE_BOOL_FIELD(unknownEqFalse);
1087 WRITE_NODE_FIELD(setParam);
1088 WRITE_NODE_FIELD(parParam);
1089 WRITE_NODE_FIELD(args);
1090 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1091 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1095 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1097 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1099 WRITE_NODE_FIELD(subplans);
1103 _outFieldSelect(StringInfo str, FieldSelect *node)
1105 WRITE_NODE_TYPE("FIELDSELECT");
1107 WRITE_NODE_FIELD(arg);
1108 WRITE_INT_FIELD(fieldnum);
1109 WRITE_OID_FIELD(resulttype);
1110 WRITE_INT_FIELD(resulttypmod);
1111 WRITE_OID_FIELD(resultcollation);
1115 _outFieldStore(StringInfo str, FieldStore *node)
1117 WRITE_NODE_TYPE("FIELDSTORE");
1119 WRITE_NODE_FIELD(arg);
1120 WRITE_NODE_FIELD(newvals);
1121 WRITE_NODE_FIELD(fieldnums);
1122 WRITE_OID_FIELD(resulttype);
1126 _outRelabelType(StringInfo str, RelabelType *node)
1128 WRITE_NODE_TYPE("RELABELTYPE");
1130 WRITE_NODE_FIELD(arg);
1131 WRITE_OID_FIELD(resulttype);
1132 WRITE_INT_FIELD(resulttypmod);
1133 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1134 WRITE_LOCATION_FIELD(location);
1138 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1140 WRITE_NODE_TYPE("COERCEVIAIO");
1142 WRITE_NODE_FIELD(arg);
1143 WRITE_OID_FIELD(resulttype);
1144 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1145 WRITE_LOCATION_FIELD(location);
1149 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1151 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1153 WRITE_NODE_FIELD(arg);
1154 WRITE_OID_FIELD(elemfuncid);
1155 WRITE_OID_FIELD(resulttype);
1156 WRITE_INT_FIELD(resulttypmod);
1157 WRITE_BOOL_FIELD(isExplicit);
1158 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1159 WRITE_LOCATION_FIELD(location);
1163 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1165 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1167 WRITE_NODE_FIELD(arg);
1168 WRITE_OID_FIELD(resulttype);
1169 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1170 WRITE_LOCATION_FIELD(location);
1174 _outCaseExpr(StringInfo str, CaseExpr *node)
1176 WRITE_NODE_TYPE("CASE");
1178 WRITE_OID_FIELD(casetype);
1179 WRITE_OID_FIELD(casecollation);
1180 WRITE_NODE_FIELD(arg);
1181 WRITE_NODE_FIELD(args);
1182 WRITE_NODE_FIELD(defresult);
1183 WRITE_LOCATION_FIELD(location);
1187 _outCaseWhen(StringInfo str, CaseWhen *node)
1189 WRITE_NODE_TYPE("WHEN");
1191 WRITE_NODE_FIELD(expr);
1192 WRITE_NODE_FIELD(result);
1193 WRITE_LOCATION_FIELD(location);
1197 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1199 WRITE_NODE_TYPE("CASETESTEXPR");
1201 WRITE_OID_FIELD(typeId);
1202 WRITE_INT_FIELD(typeMod);
1203 WRITE_OID_FIELD(collation);
1207 _outArrayExpr(StringInfo str, ArrayExpr *node)
1209 WRITE_NODE_TYPE("ARRAY");
1211 WRITE_OID_FIELD(array_typeid);
1212 WRITE_OID_FIELD(element_typeid);
1213 WRITE_NODE_FIELD(elements);
1214 WRITE_BOOL_FIELD(multidims);
1215 WRITE_LOCATION_FIELD(location);
1219 _outRowExpr(StringInfo str, RowExpr *node)
1221 WRITE_NODE_TYPE("ROW");
1223 WRITE_NODE_FIELD(args);
1224 WRITE_OID_FIELD(row_typeid);
1225 WRITE_ENUM_FIELD(row_format, CoercionForm);
1226 WRITE_NODE_FIELD(colnames);
1227 WRITE_LOCATION_FIELD(location);
1231 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1233 WRITE_NODE_TYPE("ROWCOMPARE");
1235 WRITE_ENUM_FIELD(rctype, RowCompareType);
1236 WRITE_NODE_FIELD(opnos);
1237 WRITE_NODE_FIELD(opfamilies);
1238 WRITE_NODE_FIELD(collids);
1239 WRITE_NODE_FIELD(largs);
1240 WRITE_NODE_FIELD(rargs);
1244 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1246 WRITE_NODE_TYPE("COALESCE");
1248 WRITE_OID_FIELD(coalescetype);
1249 WRITE_OID_FIELD(coalescecollation);
1250 WRITE_NODE_FIELD(args);
1251 WRITE_LOCATION_FIELD(location);
1255 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1257 WRITE_NODE_TYPE("MINMAX");
1259 WRITE_OID_FIELD(minmaxtype);
1260 WRITE_ENUM_FIELD(op, MinMaxOp);
1261 WRITE_NODE_FIELD(args);
1262 WRITE_OID_FIELD(collid);
1263 WRITE_LOCATION_FIELD(location);
1267 _outXmlExpr(StringInfo str, XmlExpr *node)
1269 WRITE_NODE_TYPE("XMLEXPR");
1271 WRITE_ENUM_FIELD(op, XmlExprOp);
1272 WRITE_STRING_FIELD(name);
1273 WRITE_NODE_FIELD(named_args);
1274 WRITE_NODE_FIELD(arg_names);
1275 WRITE_NODE_FIELD(args);
1276 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1277 WRITE_OID_FIELD(type);
1278 WRITE_INT_FIELD(typmod);
1279 WRITE_LOCATION_FIELD(location);
1283 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1285 WRITE_NODE_TYPE("NULLIFEXPR");
1287 WRITE_OID_FIELD(opno);
1288 WRITE_OID_FIELD(opfuncid);
1289 WRITE_OID_FIELD(opresulttype);
1290 WRITE_BOOL_FIELD(opretset);
1291 WRITE_NODE_FIELD(args);
1292 WRITE_LOCATION_FIELD(location);
1296 _outNullTest(StringInfo str, NullTest *node)
1298 WRITE_NODE_TYPE("NULLTEST");
1300 WRITE_NODE_FIELD(arg);
1301 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1302 WRITE_BOOL_FIELD(argisrow);
1306 _outBooleanTest(StringInfo str, BooleanTest *node)
1308 WRITE_NODE_TYPE("BOOLEANTEST");
1310 WRITE_NODE_FIELD(arg);
1311 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1315 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1317 WRITE_NODE_TYPE("COERCETODOMAIN");
1319 WRITE_NODE_FIELD(arg);
1320 WRITE_OID_FIELD(resulttype);
1321 WRITE_INT_FIELD(resulttypmod);
1322 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1323 WRITE_LOCATION_FIELD(location);
1327 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1329 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1331 WRITE_OID_FIELD(typeId);
1332 WRITE_INT_FIELD(typeMod);
1333 WRITE_LOCATION_FIELD(location);
1337 _outSetToDefault(StringInfo str, SetToDefault *node)
1339 WRITE_NODE_TYPE("SETTODEFAULT");
1341 WRITE_OID_FIELD(typeId);
1342 WRITE_INT_FIELD(typeMod);
1343 WRITE_OID_FIELD(collid);
1344 WRITE_LOCATION_FIELD(location);
1348 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1350 WRITE_NODE_TYPE("CURRENTOFEXPR");
1352 WRITE_UINT_FIELD(cvarno);
1353 WRITE_STRING_FIELD(cursor_name);
1354 WRITE_INT_FIELD(cursor_param);
1358 _outTargetEntry(StringInfo str, TargetEntry *node)
1360 WRITE_NODE_TYPE("TARGETENTRY");
1362 WRITE_NODE_FIELD(expr);
1363 WRITE_INT_FIELD(resno);
1364 WRITE_STRING_FIELD(resname);
1365 WRITE_UINT_FIELD(ressortgroupref);
1366 WRITE_OID_FIELD(resorigtbl);
1367 WRITE_INT_FIELD(resorigcol);
1368 WRITE_BOOL_FIELD(resjunk);
1372 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1374 WRITE_NODE_TYPE("RANGETBLREF");
1376 WRITE_INT_FIELD(rtindex);
1380 _outJoinExpr(StringInfo str, JoinExpr *node)
1382 WRITE_NODE_TYPE("JOINEXPR");
1384 WRITE_ENUM_FIELD(jointype, JoinType);
1385 WRITE_BOOL_FIELD(isNatural);
1386 WRITE_NODE_FIELD(larg);
1387 WRITE_NODE_FIELD(rarg);
1388 WRITE_NODE_FIELD(usingClause);
1389 WRITE_NODE_FIELD(quals);
1390 WRITE_NODE_FIELD(alias);
1391 WRITE_INT_FIELD(rtindex);
1395 _outFromExpr(StringInfo str, FromExpr *node)
1397 WRITE_NODE_TYPE("FROMEXPR");
1399 WRITE_NODE_FIELD(fromlist);
1400 WRITE_NODE_FIELD(quals);
1403 /*****************************************************************************
1405 * Stuff from relation.h.
1407 *****************************************************************************/
1410 * print the basic stuff of all nodes that inherit from Path
1412 * Note we do NOT print the parent, else we'd be in infinite recursion.
1413 * We can print the parent's relids for identification purposes, though.
1416 _outPathInfo(StringInfo str, Path *node)
1418 WRITE_ENUM_FIELD(pathtype, NodeTag);
1419 appendStringInfo(str, " :parent_relids ");
1420 _outBitmapset(str, node->parent->relids);
1421 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1422 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1423 WRITE_NODE_FIELD(pathkeys);
1427 * print the basic stuff of all nodes that inherit from JoinPath
1430 _outJoinPathInfo(StringInfo str, JoinPath *node)
1432 _outPathInfo(str, (Path *) node);
1434 WRITE_ENUM_FIELD(jointype, JoinType);
1435 WRITE_NODE_FIELD(outerjoinpath);
1436 WRITE_NODE_FIELD(innerjoinpath);
1437 WRITE_NODE_FIELD(joinrestrictinfo);
1441 _outPath(StringInfo str, Path *node)
1443 WRITE_NODE_TYPE("PATH");
1445 _outPathInfo(str, (Path *) node);
1449 _outIndexPath(StringInfo str, IndexPath *node)
1451 WRITE_NODE_TYPE("INDEXPATH");
1453 _outPathInfo(str, (Path *) node);
1455 WRITE_NODE_FIELD(indexinfo);
1456 WRITE_NODE_FIELD(indexclauses);
1457 WRITE_NODE_FIELD(indexquals);
1458 WRITE_NODE_FIELD(indexorderbys);
1459 WRITE_BOOL_FIELD(isjoininner);
1460 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1461 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1462 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1463 WRITE_FLOAT_FIELD(rows, "%.0f");
1467 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1469 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1471 _outPathInfo(str, (Path *) node);
1473 WRITE_NODE_FIELD(bitmapqual);
1474 WRITE_BOOL_FIELD(isjoininner);
1475 WRITE_FLOAT_FIELD(rows, "%.0f");
1479 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1481 WRITE_NODE_TYPE("BITMAPANDPATH");
1483 _outPathInfo(str, (Path *) node);
1485 WRITE_NODE_FIELD(bitmapquals);
1486 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1490 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1492 WRITE_NODE_TYPE("BITMAPORPATH");
1494 _outPathInfo(str, (Path *) node);
1496 WRITE_NODE_FIELD(bitmapquals);
1497 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1501 _outTidPath(StringInfo str, TidPath *node)
1503 WRITE_NODE_TYPE("TIDPATH");
1505 _outPathInfo(str, (Path *) node);
1507 WRITE_NODE_FIELD(tidquals);
1511 _outAppendPath(StringInfo str, AppendPath *node)
1513 WRITE_NODE_TYPE("APPENDPATH");
1515 _outPathInfo(str, (Path *) node);
1517 WRITE_NODE_FIELD(subpaths);
1521 _outMergeAppendPath(StringInfo str, MergeAppendPath *node)
1523 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1525 _outPathInfo(str, (Path *) node);
1527 WRITE_NODE_FIELD(subpaths);
1528 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1532 _outResultPath(StringInfo str, ResultPath *node)
1534 WRITE_NODE_TYPE("RESULTPATH");
1536 _outPathInfo(str, (Path *) node);
1538 WRITE_NODE_FIELD(quals);
1542 _outMaterialPath(StringInfo str, MaterialPath *node)
1544 WRITE_NODE_TYPE("MATERIALPATH");
1546 _outPathInfo(str, (Path *) node);
1548 WRITE_NODE_FIELD(subpath);
1552 _outUniquePath(StringInfo str, UniquePath *node)
1554 WRITE_NODE_TYPE("UNIQUEPATH");
1556 _outPathInfo(str, (Path *) node);
1558 WRITE_NODE_FIELD(subpath);
1559 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1560 WRITE_NODE_FIELD(in_operators);
1561 WRITE_NODE_FIELD(uniq_exprs);
1562 WRITE_FLOAT_FIELD(rows, "%.0f");
1566 _outNestPath(StringInfo str, NestPath *node)
1568 WRITE_NODE_TYPE("NESTPATH");
1570 _outJoinPathInfo(str, (JoinPath *) node);
1574 _outMergePath(StringInfo str, MergePath *node)
1576 WRITE_NODE_TYPE("MERGEPATH");
1578 _outJoinPathInfo(str, (JoinPath *) node);
1580 WRITE_NODE_FIELD(path_mergeclauses);
1581 WRITE_NODE_FIELD(outersortkeys);
1582 WRITE_NODE_FIELD(innersortkeys);
1583 WRITE_BOOL_FIELD(materialize_inner);
1587 _outHashPath(StringInfo str, HashPath *node)
1589 WRITE_NODE_TYPE("HASHPATH");
1591 _outJoinPathInfo(str, (JoinPath *) node);
1593 WRITE_NODE_FIELD(path_hashclauses);
1594 WRITE_INT_FIELD(num_batches);
1598 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1600 WRITE_NODE_TYPE("PLANNERGLOBAL");
1602 /* NB: this isn't a complete set of fields */
1603 WRITE_NODE_FIELD(paramlist);
1604 WRITE_NODE_FIELD(subplans);
1605 WRITE_NODE_FIELD(subrtables);
1606 WRITE_NODE_FIELD(subrowmarks);
1607 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1608 WRITE_NODE_FIELD(finalrtable);
1609 WRITE_NODE_FIELD(finalrowmarks);
1610 WRITE_NODE_FIELD(relationOids);
1611 WRITE_NODE_FIELD(invalItems);
1612 WRITE_UINT_FIELD(lastPHId);
1613 WRITE_UINT_FIELD(lastRowMarkId);
1614 WRITE_BOOL_FIELD(transientPlan);
1618 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1620 WRITE_NODE_TYPE("PLANNERINFO");
1622 /* NB: this isn't a complete set of fields */
1623 WRITE_NODE_FIELD(parse);
1624 WRITE_NODE_FIELD(glob);
1625 WRITE_UINT_FIELD(query_level);
1626 WRITE_NODE_FIELD(join_rel_list);
1627 WRITE_INT_FIELD(join_cur_level);
1628 WRITE_NODE_FIELD(resultRelations);
1629 WRITE_NODE_FIELD(init_plans);
1630 WRITE_NODE_FIELD(cte_plan_ids);
1631 WRITE_NODE_FIELD(eq_classes);
1632 WRITE_NODE_FIELD(canon_pathkeys);
1633 WRITE_NODE_FIELD(left_join_clauses);
1634 WRITE_NODE_FIELD(right_join_clauses);
1635 WRITE_NODE_FIELD(full_join_clauses);
1636 WRITE_NODE_FIELD(join_info_list);
1637 WRITE_NODE_FIELD(append_rel_list);
1638 WRITE_NODE_FIELD(rowMarks);
1639 WRITE_NODE_FIELD(placeholder_list);
1640 WRITE_NODE_FIELD(query_pathkeys);
1641 WRITE_NODE_FIELD(group_pathkeys);
1642 WRITE_NODE_FIELD(window_pathkeys);
1643 WRITE_NODE_FIELD(distinct_pathkeys);
1644 WRITE_NODE_FIELD(sort_pathkeys);
1645 WRITE_NODE_FIELD(minmax_aggs);
1646 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1647 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1648 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1649 WRITE_BOOL_FIELD(hasInheritedTarget);
1650 WRITE_BOOL_FIELD(hasJoinRTEs);
1651 WRITE_BOOL_FIELD(hasHavingQual);
1652 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1653 WRITE_BOOL_FIELD(hasRecursion);
1654 WRITE_INT_FIELD(wt_param_id);
1655 WRITE_BITMAPSET_FIELD(curOuterRels);
1656 WRITE_NODE_FIELD(curOuterParams);
1660 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1662 WRITE_NODE_TYPE("RELOPTINFO");
1664 /* NB: this isn't a complete set of fields */
1665 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1666 WRITE_BITMAPSET_FIELD(relids);
1667 WRITE_FLOAT_FIELD(rows, "%.0f");
1668 WRITE_INT_FIELD(width);
1669 WRITE_NODE_FIELD(reltargetlist);
1670 WRITE_NODE_FIELD(pathlist);
1671 WRITE_NODE_FIELD(cheapest_startup_path);
1672 WRITE_NODE_FIELD(cheapest_total_path);
1673 WRITE_NODE_FIELD(cheapest_unique_path);
1674 WRITE_UINT_FIELD(relid);
1675 WRITE_UINT_FIELD(reltablespace);
1676 WRITE_ENUM_FIELD(rtekind, RTEKind);
1677 WRITE_INT_FIELD(min_attr);
1678 WRITE_INT_FIELD(max_attr);
1679 WRITE_NODE_FIELD(indexlist);
1680 WRITE_UINT_FIELD(pages);
1681 WRITE_FLOAT_FIELD(tuples, "%.0f");
1682 WRITE_NODE_FIELD(subplan);
1683 WRITE_NODE_FIELD(subrtable);
1684 WRITE_NODE_FIELD(subrowmark);
1685 WRITE_NODE_FIELD(baserestrictinfo);
1686 WRITE_NODE_FIELD(joininfo);
1687 WRITE_BOOL_FIELD(has_eclass_joins);
1688 WRITE_BITMAPSET_FIELD(index_outer_relids);
1689 WRITE_NODE_FIELD(index_inner_paths);
1693 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1695 WRITE_NODE_TYPE("INDEXOPTINFO");
1697 /* NB: this isn't a complete set of fields */
1698 WRITE_OID_FIELD(indexoid);
1699 /* Do NOT print rel field, else infinite recursion */
1700 WRITE_UINT_FIELD(pages);
1701 WRITE_FLOAT_FIELD(tuples, "%.0f");
1702 WRITE_INT_FIELD(ncolumns);
1703 WRITE_NODE_FIELD(indexprs);
1704 WRITE_NODE_FIELD(indpred);
1705 WRITE_BOOL_FIELD(predOK);
1706 WRITE_BOOL_FIELD(unique);
1710 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1713 * To simplify reading, we just chase up to the topmost merged EC and
1714 * print that, without bothering to show the merge-ees separately.
1716 while (node->ec_merged)
1717 node = node->ec_merged;
1719 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1721 WRITE_NODE_FIELD(ec_opfamilies);
1722 WRITE_NODE_FIELD(ec_members);
1723 WRITE_NODE_FIELD(ec_sources);
1724 WRITE_NODE_FIELD(ec_derives);
1725 WRITE_BITMAPSET_FIELD(ec_relids);
1726 WRITE_BOOL_FIELD(ec_has_const);
1727 WRITE_BOOL_FIELD(ec_has_volatile);
1728 WRITE_BOOL_FIELD(ec_below_outer_join);
1729 WRITE_BOOL_FIELD(ec_broken);
1730 WRITE_UINT_FIELD(ec_sortref);
1734 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1736 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1738 WRITE_NODE_FIELD(em_expr);
1739 WRITE_BITMAPSET_FIELD(em_relids);
1740 WRITE_BOOL_FIELD(em_is_const);
1741 WRITE_BOOL_FIELD(em_is_child);
1742 WRITE_OID_FIELD(em_datatype);
1746 _outPathKey(StringInfo str, PathKey *node)
1748 WRITE_NODE_TYPE("PATHKEY");
1750 WRITE_NODE_FIELD(pk_eclass);
1751 WRITE_OID_FIELD(pk_opfamily);
1752 WRITE_OID_FIELD(pk_collation);
1753 WRITE_INT_FIELD(pk_strategy);
1754 WRITE_BOOL_FIELD(pk_nulls_first);
1758 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1760 WRITE_NODE_TYPE("RESTRICTINFO");
1762 /* NB: this isn't a complete set of fields */
1763 WRITE_NODE_FIELD(clause);
1764 WRITE_BOOL_FIELD(is_pushed_down);
1765 WRITE_BOOL_FIELD(outerjoin_delayed);
1766 WRITE_BOOL_FIELD(can_join);
1767 WRITE_BOOL_FIELD(pseudoconstant);
1768 WRITE_BITMAPSET_FIELD(clause_relids);
1769 WRITE_BITMAPSET_FIELD(required_relids);
1770 WRITE_BITMAPSET_FIELD(nullable_relids);
1771 WRITE_BITMAPSET_FIELD(left_relids);
1772 WRITE_BITMAPSET_FIELD(right_relids);
1773 WRITE_NODE_FIELD(orclause);
1774 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1775 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1776 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1777 WRITE_NODE_FIELD(mergeopfamilies);
1778 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1779 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1780 WRITE_NODE_FIELD(left_em);
1781 WRITE_NODE_FIELD(right_em);
1782 WRITE_BOOL_FIELD(outer_is_left);
1783 WRITE_OID_FIELD(hashjoinoperator);
1787 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1789 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1790 WRITE_BITMAPSET_FIELD(other_relids);
1791 WRITE_BOOL_FIELD(isouterjoin);
1792 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1793 WRITE_NODE_FIELD(cheapest_total_innerpath);
1797 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1799 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1801 WRITE_NODE_FIELD(phexpr);
1802 WRITE_BITMAPSET_FIELD(phrels);
1803 WRITE_UINT_FIELD(phid);
1804 WRITE_UINT_FIELD(phlevelsup);
1808 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1810 WRITE_NODE_TYPE("SPECIALJOININFO");
1812 WRITE_BITMAPSET_FIELD(min_lefthand);
1813 WRITE_BITMAPSET_FIELD(min_righthand);
1814 WRITE_BITMAPSET_FIELD(syn_lefthand);
1815 WRITE_BITMAPSET_FIELD(syn_righthand);
1816 WRITE_ENUM_FIELD(jointype, JoinType);
1817 WRITE_BOOL_FIELD(lhs_strict);
1818 WRITE_BOOL_FIELD(delay_upper_joins);
1819 WRITE_NODE_FIELD(join_quals);
1823 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1825 WRITE_NODE_TYPE("APPENDRELINFO");
1827 WRITE_UINT_FIELD(parent_relid);
1828 WRITE_UINT_FIELD(child_relid);
1829 WRITE_OID_FIELD(parent_reltype);
1830 WRITE_OID_FIELD(child_reltype);
1831 WRITE_NODE_FIELD(translated_vars);
1832 WRITE_OID_FIELD(parent_reloid);
1836 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1838 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1840 WRITE_UINT_FIELD(phid);
1841 WRITE_NODE_FIELD(ph_var);
1842 WRITE_BITMAPSET_FIELD(ph_eval_at);
1843 WRITE_BITMAPSET_FIELD(ph_needed);
1844 WRITE_BITMAPSET_FIELD(ph_may_need);
1845 WRITE_INT_FIELD(ph_width);
1849 _outMinMaxAggInfo(StringInfo str, MinMaxAggInfo *node)
1851 WRITE_NODE_TYPE("MINMAXAGGINFO");
1853 WRITE_OID_FIELD(aggfnoid);
1854 WRITE_OID_FIELD(aggsortop);
1855 WRITE_NODE_FIELD(target);
1856 WRITE_NODE_FIELD(pathkeys);
1860 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1862 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1864 WRITE_NODE_FIELD(item);
1865 WRITE_UINT_FIELD(abslevel);
1868 /*****************************************************************************
1870 * Stuff from parsenodes.h.
1872 *****************************************************************************/
1875 _outCreateStmt(StringInfo str, CreateStmt *node)
1877 WRITE_NODE_TYPE("CREATESTMT");
1879 WRITE_NODE_FIELD(relation);
1880 WRITE_NODE_FIELD(tableElts);
1881 WRITE_NODE_FIELD(inhRelations);
1882 WRITE_NODE_FIELD(ofTypename);
1883 WRITE_NODE_FIELD(constraints);
1884 WRITE_NODE_FIELD(options);
1885 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1886 WRITE_STRING_FIELD(tablespacename);
1887 WRITE_BOOL_FIELD(if_not_exists);
1891 _outCreateForeignTableStmt(StringInfo str, CreateForeignTableStmt *node)
1893 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
1895 _outCreateStmt(str, (CreateStmt *) &node->base);
1897 WRITE_STRING_FIELD(servername);
1898 WRITE_NODE_FIELD(options);
1902 _outIndexStmt(StringInfo str, IndexStmt *node)
1904 WRITE_NODE_TYPE("INDEXSTMT");
1906 WRITE_STRING_FIELD(idxname);
1907 WRITE_NODE_FIELD(relation);
1908 WRITE_STRING_FIELD(accessMethod);
1909 WRITE_STRING_FIELD(tableSpace);
1910 WRITE_NODE_FIELD(indexParams);
1911 WRITE_NODE_FIELD(options);
1912 WRITE_NODE_FIELD(whereClause);
1913 WRITE_NODE_FIELD(excludeOpNames);
1914 WRITE_OID_FIELD(indexOid);
1915 WRITE_BOOL_FIELD(unique);
1916 WRITE_BOOL_FIELD(primary);
1917 WRITE_BOOL_FIELD(isconstraint);
1918 WRITE_BOOL_FIELD(deferrable);
1919 WRITE_BOOL_FIELD(initdeferred);
1920 WRITE_BOOL_FIELD(concurrent);
1924 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1926 WRITE_NODE_TYPE("NOTIFY");
1928 WRITE_STRING_FIELD(conditionname);
1929 WRITE_STRING_FIELD(payload);
1933 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1935 WRITE_NODE_TYPE("DECLARECURSOR");
1937 WRITE_STRING_FIELD(portalname);
1938 WRITE_INT_FIELD(options);
1939 WRITE_NODE_FIELD(query);
1943 _outSelectStmt(StringInfo str, SelectStmt *node)
1945 WRITE_NODE_TYPE("SELECT");
1947 WRITE_NODE_FIELD(distinctClause);
1948 WRITE_NODE_FIELD(intoClause);
1949 WRITE_NODE_FIELD(targetList);
1950 WRITE_NODE_FIELD(fromClause);
1951 WRITE_NODE_FIELD(whereClause);
1952 WRITE_NODE_FIELD(groupClause);
1953 WRITE_NODE_FIELD(havingClause);
1954 WRITE_NODE_FIELD(windowClause);
1955 WRITE_NODE_FIELD(withClause);
1956 WRITE_NODE_FIELD(valuesLists);
1957 WRITE_NODE_FIELD(sortClause);
1958 WRITE_NODE_FIELD(limitOffset);
1959 WRITE_NODE_FIELD(limitCount);
1960 WRITE_NODE_FIELD(lockingClause);
1961 WRITE_ENUM_FIELD(op, SetOperation);
1962 WRITE_BOOL_FIELD(all);
1963 WRITE_NODE_FIELD(larg);
1964 WRITE_NODE_FIELD(rarg);
1968 _outFuncCall(StringInfo str, FuncCall *node)
1970 WRITE_NODE_TYPE("FUNCCALL");
1972 WRITE_NODE_FIELD(funcname);
1973 WRITE_NODE_FIELD(args);
1974 WRITE_NODE_FIELD(agg_order);
1975 WRITE_BOOL_FIELD(agg_star);
1976 WRITE_BOOL_FIELD(agg_distinct);
1977 WRITE_BOOL_FIELD(func_variadic);
1978 WRITE_NODE_FIELD(over);
1979 WRITE_LOCATION_FIELD(location);
1983 _outDefElem(StringInfo str, DefElem *node)
1985 WRITE_NODE_TYPE("DEFELEM");
1987 WRITE_STRING_FIELD(defnamespace);
1988 WRITE_STRING_FIELD(defname);
1989 WRITE_NODE_FIELD(arg);
1990 WRITE_ENUM_FIELD(defaction, DefElemAction);
1994 _outInhRelation(StringInfo str, InhRelation *node)
1996 WRITE_NODE_TYPE("INHRELATION");
1998 WRITE_NODE_FIELD(relation);
1999 WRITE_UINT_FIELD(options);
2003 _outLockingClause(StringInfo str, LockingClause *node)
2005 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2007 WRITE_NODE_FIELD(lockedRels);
2008 WRITE_BOOL_FIELD(forUpdate);
2009 WRITE_BOOL_FIELD(noWait);
2013 _outXmlSerialize(StringInfo str, XmlSerialize *node)
2015 WRITE_NODE_TYPE("XMLSERIALIZE");
2017 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2018 WRITE_NODE_FIELD(expr);
2019 WRITE_NODE_FIELD(typeName);
2020 WRITE_LOCATION_FIELD(location);
2024 _outColumnDef(StringInfo str, ColumnDef *node)
2026 WRITE_NODE_TYPE("COLUMNDEF");
2028 WRITE_STRING_FIELD(colname);
2029 WRITE_NODE_FIELD(typeName);
2030 WRITE_INT_FIELD(inhcount);
2031 WRITE_BOOL_FIELD(is_local);
2032 WRITE_BOOL_FIELD(is_not_null);
2033 WRITE_INT_FIELD(storage);
2034 WRITE_NODE_FIELD(raw_default);
2035 WRITE_NODE_FIELD(cooked_default);
2036 WRITE_NODE_FIELD(constraints);
2040 _outTypeName(StringInfo str, TypeName *node)
2042 WRITE_NODE_TYPE("TYPENAME");
2044 WRITE_NODE_FIELD(names);
2045 WRITE_OID_FIELD(typeOid);
2046 WRITE_BOOL_FIELD(setof);
2047 WRITE_BOOL_FIELD(pct_type);
2048 WRITE_NODE_FIELD(typmods);
2049 WRITE_INT_FIELD(typemod);
2050 WRITE_NODE_FIELD(arrayBounds);
2051 WRITE_NODE_FIELD(collnames);
2052 WRITE_OID_FIELD(collOid);
2053 WRITE_LOCATION_FIELD(location);
2057 _outTypeCast(StringInfo str, TypeCast *node)
2059 WRITE_NODE_TYPE("TYPECAST");
2061 WRITE_NODE_FIELD(arg);
2062 WRITE_NODE_FIELD(typeName);
2063 WRITE_LOCATION_FIELD(location);
2067 _outCollateClause(StringInfo str, CollateClause *node)
2069 WRITE_NODE_TYPE("COLLATE");
2071 WRITE_NODE_FIELD(arg);
2072 WRITE_NODE_FIELD(collnames);
2073 WRITE_OID_FIELD(collOid);
2074 WRITE_LOCATION_FIELD(location);
2078 _outIndexElem(StringInfo str, IndexElem *node)
2080 WRITE_NODE_TYPE("INDEXELEM");
2082 WRITE_STRING_FIELD(name);
2083 WRITE_NODE_FIELD(expr);
2084 WRITE_STRING_FIELD(indexcolname);
2085 WRITE_NODE_FIELD(collation);
2086 WRITE_NODE_FIELD(opclass);
2087 WRITE_ENUM_FIELD(ordering, SortByDir);
2088 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2092 _outQuery(StringInfo str, Query *node)
2094 WRITE_NODE_TYPE("QUERY");
2096 WRITE_ENUM_FIELD(commandType, CmdType);
2097 WRITE_ENUM_FIELD(querySource, QuerySource);
2098 WRITE_BOOL_FIELD(canSetTag);
2101 * Hack to work around missing outfuncs routines for a lot of the
2102 * utility-statement node types. (The only one we actually *need* for
2103 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2104 * for the meantime do this to avoid getting lots of warnings when running
2105 * with debug_print_parse on.
2107 if (node->utilityStmt)
2109 switch (nodeTag(node->utilityStmt))
2114 case T_DeclareCursorStmt:
2115 WRITE_NODE_FIELD(utilityStmt);
2118 appendStringInfo(str, " :utilityStmt ?");
2123 appendStringInfo(str, " :utilityStmt <>");
2125 WRITE_INT_FIELD(resultRelation);
2126 WRITE_NODE_FIELD(intoClause);
2127 WRITE_BOOL_FIELD(hasAggs);
2128 WRITE_BOOL_FIELD(hasWindowFuncs);
2129 WRITE_BOOL_FIELD(hasSubLinks);
2130 WRITE_BOOL_FIELD(hasDistinctOn);
2131 WRITE_BOOL_FIELD(hasRecursive);
2132 WRITE_BOOL_FIELD(hasForUpdate);
2133 WRITE_NODE_FIELD(cteList);
2134 WRITE_NODE_FIELD(rtable);
2135 WRITE_NODE_FIELD(jointree);
2136 WRITE_NODE_FIELD(targetList);
2137 WRITE_NODE_FIELD(returningList);
2138 WRITE_NODE_FIELD(groupClause);
2139 WRITE_NODE_FIELD(havingQual);
2140 WRITE_NODE_FIELD(windowClause);
2141 WRITE_NODE_FIELD(distinctClause);
2142 WRITE_NODE_FIELD(sortClause);
2143 WRITE_NODE_FIELD(limitOffset);
2144 WRITE_NODE_FIELD(limitCount);
2145 WRITE_NODE_FIELD(rowMarks);
2146 WRITE_NODE_FIELD(setOperations);
2147 WRITE_NODE_FIELD(constraintDeps);
2151 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2153 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2155 WRITE_UINT_FIELD(tleSortGroupRef);
2156 WRITE_OID_FIELD(eqop);
2157 WRITE_OID_FIELD(sortop);
2158 WRITE_BOOL_FIELD(nulls_first);
2159 WRITE_BOOL_FIELD(hashable);
2163 _outWindowClause(StringInfo str, WindowClause *node)
2165 WRITE_NODE_TYPE("WINDOWCLAUSE");
2167 WRITE_STRING_FIELD(name);
2168 WRITE_STRING_FIELD(refname);
2169 WRITE_NODE_FIELD(partitionClause);
2170 WRITE_NODE_FIELD(orderClause);
2171 WRITE_INT_FIELD(frameOptions);
2172 WRITE_NODE_FIELD(startOffset);
2173 WRITE_NODE_FIELD(endOffset);
2174 WRITE_UINT_FIELD(winref);
2175 WRITE_BOOL_FIELD(copiedOrder);
2179 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2181 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2183 WRITE_UINT_FIELD(rti);
2184 WRITE_BOOL_FIELD(forUpdate);
2185 WRITE_BOOL_FIELD(noWait);
2186 WRITE_BOOL_FIELD(pushedDown);
2190 _outWithClause(StringInfo str, WithClause *node)
2192 WRITE_NODE_TYPE("WITHCLAUSE");
2194 WRITE_NODE_FIELD(ctes);
2195 WRITE_BOOL_FIELD(recursive);
2196 WRITE_LOCATION_FIELD(location);
2200 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2202 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2204 WRITE_STRING_FIELD(ctename);
2205 WRITE_NODE_FIELD(aliascolnames);
2206 WRITE_NODE_FIELD(ctequery);
2207 WRITE_LOCATION_FIELD(location);
2208 WRITE_BOOL_FIELD(cterecursive);
2209 WRITE_INT_FIELD(cterefcount);
2210 WRITE_NODE_FIELD(ctecolnames);
2211 WRITE_NODE_FIELD(ctecoltypes);
2212 WRITE_NODE_FIELD(ctecoltypmods);
2213 WRITE_NODE_FIELD(ctecolcollations);
2217 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2219 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2221 WRITE_ENUM_FIELD(op, SetOperation);
2222 WRITE_BOOL_FIELD(all);
2223 WRITE_NODE_FIELD(larg);
2224 WRITE_NODE_FIELD(rarg);
2225 WRITE_NODE_FIELD(colTypes);
2226 WRITE_NODE_FIELD(colTypmods);
2227 WRITE_NODE_FIELD(colCollations);
2228 WRITE_NODE_FIELD(groupClauses);
2232 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2234 WRITE_NODE_TYPE("RTE");
2236 /* put alias + eref first to make dump more legible */
2237 WRITE_NODE_FIELD(alias);
2238 WRITE_NODE_FIELD(eref);
2239 WRITE_ENUM_FIELD(rtekind, RTEKind);
2241 switch (node->rtekind)
2245 WRITE_OID_FIELD(relid);
2248 WRITE_NODE_FIELD(subquery);
2251 WRITE_ENUM_FIELD(jointype, JoinType);
2252 WRITE_NODE_FIELD(joinaliasvars);
2255 WRITE_NODE_FIELD(funcexpr);
2256 WRITE_NODE_FIELD(funccoltypes);
2257 WRITE_NODE_FIELD(funccoltypmods);
2258 WRITE_NODE_FIELD(funccolcollations);
2261 WRITE_NODE_FIELD(values_lists);
2264 WRITE_STRING_FIELD(ctename);
2265 WRITE_UINT_FIELD(ctelevelsup);
2266 WRITE_BOOL_FIELD(self_reference);
2267 WRITE_NODE_FIELD(ctecoltypes);
2268 WRITE_NODE_FIELD(ctecoltypmods);
2269 WRITE_NODE_FIELD(ctecolcollations);
2272 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2276 WRITE_BOOL_FIELD(inh);
2277 WRITE_BOOL_FIELD(inFromCl);
2278 WRITE_UINT_FIELD(requiredPerms);
2279 WRITE_OID_FIELD(checkAsUser);
2280 WRITE_BITMAPSET_FIELD(selectedCols);
2281 WRITE_BITMAPSET_FIELD(modifiedCols);
2285 _outAExpr(StringInfo str, A_Expr *node)
2287 WRITE_NODE_TYPE("AEXPR");
2292 appendStringInfo(str, " ");
2293 WRITE_NODE_FIELD(name);
2296 appendStringInfo(str, " AND");
2299 appendStringInfo(str, " OR");
2302 appendStringInfo(str, " NOT");
2305 appendStringInfo(str, " ");
2306 WRITE_NODE_FIELD(name);
2307 appendStringInfo(str, " ANY ");
2310 appendStringInfo(str, " ");
2311 WRITE_NODE_FIELD(name);
2312 appendStringInfo(str, " ALL ");
2314 case AEXPR_DISTINCT:
2315 appendStringInfo(str, " DISTINCT ");
2316 WRITE_NODE_FIELD(name);
2319 appendStringInfo(str, " NULLIF ");
2320 WRITE_NODE_FIELD(name);
2323 appendStringInfo(str, " OF ");
2324 WRITE_NODE_FIELD(name);
2327 appendStringInfo(str, " IN ");
2328 WRITE_NODE_FIELD(name);
2331 appendStringInfo(str, " ??");
2335 WRITE_NODE_FIELD(lexpr);
2336 WRITE_NODE_FIELD(rexpr);
2337 WRITE_LOCATION_FIELD(location);
2341 _outValue(StringInfo str, Value *value)
2343 switch (value->type)
2346 appendStringInfo(str, "%ld", value->val.ival);
2351 * We assume the value is a valid numeric literal and so does not
2354 appendStringInfoString(str, value->val.str);
2357 appendStringInfoChar(str, '"');
2358 _outToken(str, value->val.str);
2359 appendStringInfoChar(str, '"');
2362 /* internal representation already has leading 'b' */
2363 appendStringInfoString(str, value->val.str);
2366 /* this is seen only within A_Const, not in transformed trees */
2367 appendStringInfoString(str, "NULL");
2370 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2376 _outColumnRef(StringInfo str, ColumnRef *node)
2378 WRITE_NODE_TYPE("COLUMNREF");
2380 WRITE_NODE_FIELD(fields);
2381 WRITE_LOCATION_FIELD(location);
2385 _outParamRef(StringInfo str, ParamRef *node)
2387 WRITE_NODE_TYPE("PARAMREF");
2389 WRITE_INT_FIELD(number);
2390 WRITE_LOCATION_FIELD(location);
2394 _outAConst(StringInfo str, A_Const *node)
2396 WRITE_NODE_TYPE("A_CONST");
2398 appendStringInfo(str, " :val ");
2399 _outValue(str, &(node->val));
2400 WRITE_LOCATION_FIELD(location);
2404 _outA_Star(StringInfo str, A_Star *node)
2406 WRITE_NODE_TYPE("A_STAR");
2410 _outA_Indices(StringInfo str, A_Indices *node)
2412 WRITE_NODE_TYPE("A_INDICES");
2414 WRITE_NODE_FIELD(lidx);
2415 WRITE_NODE_FIELD(uidx);
2419 _outA_Indirection(StringInfo str, A_Indirection *node)
2421 WRITE_NODE_TYPE("A_INDIRECTION");
2423 WRITE_NODE_FIELD(arg);
2424 WRITE_NODE_FIELD(indirection);
2428 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2430 WRITE_NODE_TYPE("A_ARRAYEXPR");
2432 WRITE_NODE_FIELD(elements);
2433 WRITE_LOCATION_FIELD(location);
2437 _outResTarget(StringInfo str, ResTarget *node)
2439 WRITE_NODE_TYPE("RESTARGET");
2441 WRITE_STRING_FIELD(name);
2442 WRITE_NODE_FIELD(indirection);
2443 WRITE_NODE_FIELD(val);
2444 WRITE_LOCATION_FIELD(location);
2448 _outSortBy(StringInfo str, SortBy *node)
2450 WRITE_NODE_TYPE("SORTBY");
2452 WRITE_NODE_FIELD(node);
2453 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2454 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2455 WRITE_NODE_FIELD(useOp);
2456 WRITE_LOCATION_FIELD(location);
2460 _outWindowDef(StringInfo str, WindowDef *node)
2462 WRITE_NODE_TYPE("WINDOWDEF");
2464 WRITE_STRING_FIELD(name);
2465 WRITE_STRING_FIELD(refname);
2466 WRITE_NODE_FIELD(partitionClause);
2467 WRITE_NODE_FIELD(orderClause);
2468 WRITE_INT_FIELD(frameOptions);
2469 WRITE_NODE_FIELD(startOffset);
2470 WRITE_NODE_FIELD(endOffset);
2471 WRITE_LOCATION_FIELD(location);
2475 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2477 WRITE_NODE_TYPE("RANGESUBSELECT");
2479 WRITE_NODE_FIELD(subquery);
2480 WRITE_NODE_FIELD(alias);
2484 _outRangeFunction(StringInfo str, RangeFunction *node)
2486 WRITE_NODE_TYPE("RANGEFUNCTION");
2488 WRITE_NODE_FIELD(funccallnode);
2489 WRITE_NODE_FIELD(alias);
2490 WRITE_NODE_FIELD(coldeflist);
2494 _outConstraint(StringInfo str, Constraint *node)
2496 WRITE_NODE_TYPE("CONSTRAINT");
2498 WRITE_STRING_FIELD(conname);
2499 WRITE_BOOL_FIELD(deferrable);
2500 WRITE_BOOL_FIELD(initdeferred);
2501 WRITE_LOCATION_FIELD(location);
2503 appendStringInfo(str, " :contype ");
2504 switch (node->contype)
2507 appendStringInfo(str, "NULL");
2510 case CONSTR_NOTNULL:
2511 appendStringInfo(str, "NOT_NULL");
2514 case CONSTR_DEFAULT:
2515 appendStringInfo(str, "DEFAULT");
2516 WRITE_NODE_FIELD(raw_expr);
2517 WRITE_STRING_FIELD(cooked_expr);
2521 appendStringInfo(str, "CHECK");
2522 WRITE_NODE_FIELD(raw_expr);
2523 WRITE_STRING_FIELD(cooked_expr);
2526 case CONSTR_PRIMARY:
2527 appendStringInfo(str, "PRIMARY_KEY");
2528 WRITE_NODE_FIELD(keys);
2529 WRITE_NODE_FIELD(options);
2530 WRITE_STRING_FIELD(indexname);
2531 WRITE_STRING_FIELD(indexspace);
2532 /* access_method and where_clause not currently used */
2536 appendStringInfo(str, "UNIQUE");
2537 WRITE_NODE_FIELD(keys);
2538 WRITE_NODE_FIELD(options);
2539 WRITE_STRING_FIELD(indexname);
2540 WRITE_STRING_FIELD(indexspace);
2541 /* access_method and where_clause not currently used */
2544 case CONSTR_EXCLUSION:
2545 appendStringInfo(str, "EXCLUSION");
2546 WRITE_NODE_FIELD(exclusions);
2547 WRITE_NODE_FIELD(options);
2548 WRITE_STRING_FIELD(indexname);
2549 WRITE_STRING_FIELD(indexspace);
2550 WRITE_STRING_FIELD(access_method);
2551 WRITE_NODE_FIELD(where_clause);
2554 case CONSTR_FOREIGN:
2555 appendStringInfo(str, "FOREIGN_KEY");
2556 WRITE_NODE_FIELD(pktable);
2557 WRITE_NODE_FIELD(fk_attrs);
2558 WRITE_NODE_FIELD(pk_attrs);
2559 WRITE_CHAR_FIELD(fk_matchtype);
2560 WRITE_CHAR_FIELD(fk_upd_action);
2561 WRITE_CHAR_FIELD(fk_del_action);
2562 WRITE_BOOL_FIELD(skip_validation);
2565 case CONSTR_ATTR_DEFERRABLE:
2566 appendStringInfo(str, "ATTR_DEFERRABLE");
2569 case CONSTR_ATTR_NOT_DEFERRABLE:
2570 appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2573 case CONSTR_ATTR_DEFERRED:
2574 appendStringInfo(str, "ATTR_DEFERRED");
2577 case CONSTR_ATTR_IMMEDIATE:
2578 appendStringInfo(str, "ATTR_IMMEDIATE");
2582 appendStringInfo(str, "<unrecognized_constraint %d>",
2583 (int) node->contype);
2591 * converts a Node into ascii string and append it to 'str'
2594 _outNode(StringInfo str, void *obj)
2597 appendStringInfo(str, "<>");
2598 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2600 else if (IsA(obj, Integer) ||
2603 IsA(obj, BitString))
2605 /* nodeRead does not want to see { } around these! */
2606 _outValue(str, obj);
2610 appendStringInfoChar(str, '{');
2611 switch (nodeTag(obj))
2614 _outPlannedStmt(str, obj);
2620 _outResult(str, obj);
2623 _outModifyTable(str, obj);
2626 _outAppend(str, obj);
2629 _outMergeAppend(str, obj);
2631 case T_RecursiveUnion:
2632 _outRecursiveUnion(str, obj);
2635 _outBitmapAnd(str, obj);
2638 _outBitmapOr(str, obj);
2644 _outSeqScan(str, obj);
2647 _outIndexScan(str, obj);
2649 case T_BitmapIndexScan:
2650 _outBitmapIndexScan(str, obj);
2652 case T_BitmapHeapScan:
2653 _outBitmapHeapScan(str, obj);
2656 _outTidScan(str, obj);
2658 case T_SubqueryScan:
2659 _outSubqueryScan(str, obj);
2661 case T_FunctionScan:
2662 _outFunctionScan(str, obj);
2665 _outValuesScan(str, obj);
2668 _outCteScan(str, obj);
2670 case T_WorkTableScan:
2671 _outWorkTableScan(str, obj);
2677 _outNestLoop(str, obj);
2680 _outMergeJoin(str, obj);
2683 _outHashJoin(str, obj);
2689 _outWindowAgg(str, obj);
2692 _outGroup(str, obj);
2695 _outMaterial(str, obj);
2701 _outUnique(str, obj);
2707 _outSetOp(str, obj);
2710 _outLockRows(str, obj);
2713 _outLimit(str, obj);
2715 case T_NestLoopParam:
2716 _outNestLoopParam(str, obj);
2719 _outPlanRowMark(str, obj);
2721 case T_PlanInvalItem:
2722 _outPlanInvalItem(str, obj);
2725 _outAlias(str, obj);
2728 _outRangeVar(str, obj);
2731 _outIntoClause(str, obj);
2737 _outConst(str, obj);
2740 _outParam(str, obj);
2743 _outAggref(str, obj);
2746 _outWindowFunc(str, obj);
2749 _outArrayRef(str, obj);
2752 _outFuncExpr(str, obj);
2754 case T_NamedArgExpr:
2755 _outNamedArgExpr(str, obj);
2758 _outOpExpr(str, obj);
2760 case T_DistinctExpr:
2761 _outDistinctExpr(str, obj);
2763 case T_ScalarArrayOpExpr:
2764 _outScalarArrayOpExpr(str, obj);
2767 _outBoolExpr(str, obj);
2770 _outSubLink(str, obj);
2773 _outSubPlan(str, obj);
2775 case T_AlternativeSubPlan:
2776 _outAlternativeSubPlan(str, obj);
2779 _outFieldSelect(str, obj);
2782 _outFieldStore(str, obj);
2785 _outRelabelType(str, obj);
2787 case T_CollateClause:
2788 _outCollateClause(str, obj);
2791 _outCoerceViaIO(str, obj);
2793 case T_ArrayCoerceExpr:
2794 _outArrayCoerceExpr(str, obj);
2796 case T_ConvertRowtypeExpr:
2797 _outConvertRowtypeExpr(str, obj);
2800 _outCaseExpr(str, obj);
2803 _outCaseWhen(str, obj);
2805 case T_CaseTestExpr:
2806 _outCaseTestExpr(str, obj);
2809 _outArrayExpr(str, obj);
2812 _outRowExpr(str, obj);
2814 case T_RowCompareExpr:
2815 _outRowCompareExpr(str, obj);
2817 case T_CoalesceExpr:
2818 _outCoalesceExpr(str, obj);
2821 _outMinMaxExpr(str, obj);
2824 _outXmlExpr(str, obj);
2827 _outNullIfExpr(str, obj);
2830 _outNullTest(str, obj);
2833 _outBooleanTest(str, obj);
2835 case T_CoerceToDomain:
2836 _outCoerceToDomain(str, obj);
2838 case T_CoerceToDomainValue:
2839 _outCoerceToDomainValue(str, obj);
2841 case T_SetToDefault:
2842 _outSetToDefault(str, obj);
2844 case T_CurrentOfExpr:
2845 _outCurrentOfExpr(str, obj);
2848 _outTargetEntry(str, obj);
2851 _outRangeTblRef(str, obj);
2854 _outJoinExpr(str, obj);
2857 _outFromExpr(str, obj);
2864 _outIndexPath(str, obj);
2866 case T_BitmapHeapPath:
2867 _outBitmapHeapPath(str, obj);
2869 case T_BitmapAndPath:
2870 _outBitmapAndPath(str, obj);
2872 case T_BitmapOrPath:
2873 _outBitmapOrPath(str, obj);
2876 _outTidPath(str, obj);
2879 _outAppendPath(str, obj);
2881 case T_MergeAppendPath:
2882 _outMergeAppendPath(str, obj);
2885 _outResultPath(str, obj);
2887 case T_MaterialPath:
2888 _outMaterialPath(str, obj);
2891 _outUniquePath(str, obj);
2894 _outNestPath(str, obj);
2897 _outMergePath(str, obj);
2900 _outHashPath(str, obj);
2902 case T_PlannerGlobal:
2903 _outPlannerGlobal(str, obj);
2906 _outPlannerInfo(str, obj);
2909 _outRelOptInfo(str, obj);
2911 case T_IndexOptInfo:
2912 _outIndexOptInfo(str, obj);
2914 case T_EquivalenceClass:
2915 _outEquivalenceClass(str, obj);
2917 case T_EquivalenceMember:
2918 _outEquivalenceMember(str, obj);
2921 _outPathKey(str, obj);
2923 case T_RestrictInfo:
2924 _outRestrictInfo(str, obj);
2926 case T_InnerIndexscanInfo:
2927 _outInnerIndexscanInfo(str, obj);
2929 case T_PlaceHolderVar:
2930 _outPlaceHolderVar(str, obj);
2932 case T_SpecialJoinInfo:
2933 _outSpecialJoinInfo(str, obj);
2935 case T_AppendRelInfo:
2936 _outAppendRelInfo(str, obj);
2938 case T_PlaceHolderInfo:
2939 _outPlaceHolderInfo(str, obj);
2941 case T_MinMaxAggInfo:
2942 _outMinMaxAggInfo(str, obj);
2944 case T_PlannerParamItem:
2945 _outPlannerParamItem(str, obj);
2949 _outCreateStmt(str, obj);
2951 case T_CreateForeignTableStmt:
2952 _outCreateForeignTableStmt(str, obj);
2955 _outIndexStmt(str, obj);
2958 _outNotifyStmt(str, obj);
2960 case T_DeclareCursorStmt:
2961 _outDeclareCursorStmt(str, obj);
2964 _outSelectStmt(str, obj);
2967 _outColumnDef(str, obj);
2970 _outTypeName(str, obj);
2973 _outTypeCast(str, obj);
2976 _outIndexElem(str, obj);
2979 _outQuery(str, obj);
2981 case T_SortGroupClause:
2982 _outSortGroupClause(str, obj);
2984 case T_WindowClause:
2985 _outWindowClause(str, obj);
2987 case T_RowMarkClause:
2988 _outRowMarkClause(str, obj);
2991 _outWithClause(str, obj);
2993 case T_CommonTableExpr:
2994 _outCommonTableExpr(str, obj);
2996 case T_SetOperationStmt:
2997 _outSetOperationStmt(str, obj);
2999 case T_RangeTblEntry:
3000 _outRangeTblEntry(str, obj);
3003 _outAExpr(str, obj);
3006 _outColumnRef(str, obj);
3009 _outParamRef(str, obj);
3012 _outAConst(str, obj);
3015 _outA_Star(str, obj);
3018 _outA_Indices(str, obj);
3020 case T_A_Indirection:
3021 _outA_Indirection(str, obj);
3024 _outA_ArrayExpr(str, obj);
3027 _outResTarget(str, obj);
3030 _outSortBy(str, obj);
3033 _outWindowDef(str, obj);
3035 case T_RangeSubselect:
3036 _outRangeSubselect(str, obj);
3038 case T_RangeFunction:
3039 _outRangeFunction(str, obj);
3042 _outConstraint(str, obj);
3045 _outFuncCall(str, obj);
3048 _outDefElem(str, obj);
3051 _outInhRelation(str, obj);
3053 case T_LockingClause:
3054 _outLockingClause(str, obj);
3056 case T_XmlSerialize:
3057 _outXmlSerialize(str, obj);
3063 * This should be an ERROR, but it's too useful to be able to
3064 * dump structures that _outNode only understands part of.
3066 elog(WARNING, "could not dump unrecognized node type: %d",
3067 (int) nodeTag(obj));
3070 appendStringInfoChar(str, '}');
3076 * returns the ascii representation of the Node as a palloc'd string
3079 nodeToString(void *obj)
3083 /* see stringinfo.h for an explanation of this maneuver */
3084 initStringInfo(&str);
3085 _outNode(&str, obj);