1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.351 2009/02/02 19:31:39 alvherre Exp $
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify output of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire conventions about the names of the local variables in an Out
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41 appendStringInfoString(str, nodelabel)
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47 /* Write an unsigned integer field (anything written as ":fldname %u") */
48 #define WRITE_UINT_FIELD(fldname) \
49 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
51 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
52 #define WRITE_OID_FIELD(fldname) \
53 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
68 /* Write a float field --- caller must give format to define precision */
69 #define WRITE_FLOAT_FIELD(fldname,format) \
70 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75 booltostr(node->fldname))
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 _outToken(str, node->fldname))
82 /* Write a parse location field (actually same as INT case) */
83 #define WRITE_LOCATION_FIELD(fldname) \
84 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
86 /* Write a Node field */
87 #define WRITE_NODE_FIELD(fldname) \
88 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
89 _outNode(str, node->fldname))
91 /* Write a bitmapset field */
92 #define WRITE_BITMAPSET_FIELD(fldname) \
93 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
94 _outBitmapset(str, node->fldname))
97 #define booltostr(x) ((x) ? "true" : "false")
99 static void _outNode(StringInfo str, void *obj);
104 * Convert an ordinary string (eg, an identifier) into a form that
105 * will be decoded back to a plain token by read.c's functions.
107 * If a null or empty string is given, it is encoded as "<>".
110 _outToken(StringInfo str, char *s)
112 if (s == NULL || *s == '\0')
114 appendStringInfo(str, "<>");
119 * Look for characters or patterns that are treated specially by read.c
120 * (either in pg_strtok() or in nodeRead()), and therefore need a
121 * protective backslash.
123 /* These characters only need to be quoted at the start of the string */
126 isdigit((unsigned char) *s) ||
127 ((*s == '+' || *s == '-') &&
128 (isdigit((unsigned char) s[1]) || s[1] == '.')))
129 appendStringInfoChar(str, '\\');
132 /* These chars must be backslashed anywhere in the string */
133 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
136 appendStringInfoChar(str, '\\');
137 appendStringInfoChar(str, *s++);
142 _outList(StringInfo str, List *node)
146 appendStringInfoChar(str, '(');
148 if (IsA(node, IntList))
149 appendStringInfoChar(str, 'i');
150 else if (IsA(node, OidList))
151 appendStringInfoChar(str, 'o');
156 * For the sake of backward compatibility, we emit a slightly
157 * different whitespace format for lists of nodes vs. other types of
158 * lists. XXX: is this necessary?
162 _outNode(str, lfirst(lc));
164 appendStringInfoChar(str, ' ');
166 else if (IsA(node, IntList))
167 appendStringInfo(str, " %d", lfirst_int(lc));
168 else if (IsA(node, OidList))
169 appendStringInfo(str, " %u", lfirst_oid(lc));
171 elog(ERROR, "unrecognized list node type: %d",
175 appendStringInfoChar(str, ')');
180 * converts a bitmap set of integers
182 * Note: the output format is "(b int int ...)", similar to an integer List.
185 _outBitmapset(StringInfo str, Bitmapset *bms)
190 appendStringInfoChar(str, '(');
191 appendStringInfoChar(str, 'b');
192 tmpset = bms_copy(bms);
193 while ((x = bms_first_member(tmpset)) >= 0)
194 appendStringInfo(str, " %d", x);
196 appendStringInfoChar(str, ')');
200 * Print the value of a Datum given its type.
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
209 length = datumGetSize(value, typbyval, typlen);
213 s = (char *) (&value);
214 appendStringInfo(str, "%u [ ", (unsigned int) length);
215 for (i = 0; i < (Size) sizeof(Datum); i++)
216 appendStringInfo(str, "%d ", (int) (s[i]));
217 appendStringInfo(str, "]");
221 s = (char *) DatumGetPointer(value);
222 if (!PointerIsValid(s))
223 appendStringInfo(str, "0 [ ]");
226 appendStringInfo(str, "%u [ ", (unsigned int) length);
227 for (i = 0; i < length; i++)
228 appendStringInfo(str, "%d ", (int) (s[i]));
229 appendStringInfo(str, "]");
236 * Stuff from plannodes.h
240 _outPlannedStmt(StringInfo str, PlannedStmt *node)
242 WRITE_NODE_TYPE("PLANNEDSTMT");
244 WRITE_ENUM_FIELD(commandType, CmdType);
245 WRITE_BOOL_FIELD(canSetTag);
246 WRITE_NODE_FIELD(planTree);
247 WRITE_NODE_FIELD(rtable);
248 WRITE_NODE_FIELD(resultRelations);
249 WRITE_NODE_FIELD(utilityStmt);
250 WRITE_NODE_FIELD(intoClause);
251 WRITE_NODE_FIELD(subplans);
252 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
253 WRITE_NODE_FIELD(returningLists);
254 WRITE_NODE_FIELD(rowMarks);
255 WRITE_NODE_FIELD(relationOids);
256 WRITE_NODE_FIELD(invalItems);
257 WRITE_INT_FIELD(nParamExec);
261 * print the basic stuff of all nodes that inherit from Plan
264 _outPlanInfo(StringInfo str, Plan *node)
266 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
267 WRITE_FLOAT_FIELD(total_cost, "%.2f");
268 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
269 WRITE_INT_FIELD(plan_width);
270 WRITE_NODE_FIELD(targetlist);
271 WRITE_NODE_FIELD(qual);
272 WRITE_NODE_FIELD(lefttree);
273 WRITE_NODE_FIELD(righttree);
274 WRITE_NODE_FIELD(initPlan);
275 WRITE_BITMAPSET_FIELD(extParam);
276 WRITE_BITMAPSET_FIELD(allParam);
280 * print the basic stuff of all nodes that inherit from Scan
283 _outScanInfo(StringInfo str, Scan *node)
285 _outPlanInfo(str, (Plan *) node);
287 WRITE_UINT_FIELD(scanrelid);
291 * print the basic stuff of all nodes that inherit from Join
294 _outJoinPlanInfo(StringInfo str, Join *node)
296 _outPlanInfo(str, (Plan *) node);
298 WRITE_ENUM_FIELD(jointype, JoinType);
299 WRITE_NODE_FIELD(joinqual);
304 _outPlan(StringInfo str, Plan *node)
306 WRITE_NODE_TYPE("PLAN");
308 _outPlanInfo(str, (Plan *) node);
312 _outResult(StringInfo str, Result *node)
314 WRITE_NODE_TYPE("RESULT");
316 _outPlanInfo(str, (Plan *) node);
318 WRITE_NODE_FIELD(resconstantqual);
322 _outAppend(StringInfo str, Append *node)
324 WRITE_NODE_TYPE("APPEND");
326 _outPlanInfo(str, (Plan *) node);
328 WRITE_NODE_FIELD(appendplans);
329 WRITE_BOOL_FIELD(isTarget);
333 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
337 WRITE_NODE_TYPE("RECURSIVEUNION");
339 _outPlanInfo(str, (Plan *) node);
341 WRITE_INT_FIELD(wtParam);
342 WRITE_INT_FIELD(numCols);
344 appendStringInfo(str, " :dupColIdx");
345 for (i = 0; i < node->numCols; i++)
346 appendStringInfo(str, " %d", node->dupColIdx[i]);
348 appendStringInfo(str, " :dupOperators");
349 for (i = 0; i < node->numCols; i++)
350 appendStringInfo(str, " %u", node->dupOperators[i]);
352 WRITE_LONG_FIELD(numGroups);
356 _outBitmapAnd(StringInfo str, BitmapAnd *node)
358 WRITE_NODE_TYPE("BITMAPAND");
360 _outPlanInfo(str, (Plan *) node);
362 WRITE_NODE_FIELD(bitmapplans);
366 _outBitmapOr(StringInfo str, BitmapOr *node)
368 WRITE_NODE_TYPE("BITMAPOR");
370 _outPlanInfo(str, (Plan *) node);
372 WRITE_NODE_FIELD(bitmapplans);
376 _outScan(StringInfo str, Scan *node)
378 WRITE_NODE_TYPE("SCAN");
380 _outScanInfo(str, (Scan *) node);
384 _outSeqScan(StringInfo str, SeqScan *node)
386 WRITE_NODE_TYPE("SEQSCAN");
388 _outScanInfo(str, (Scan *) node);
392 _outIndexScan(StringInfo str, IndexScan *node)
394 WRITE_NODE_TYPE("INDEXSCAN");
396 _outScanInfo(str, (Scan *) node);
398 WRITE_OID_FIELD(indexid);
399 WRITE_NODE_FIELD(indexqual);
400 WRITE_NODE_FIELD(indexqualorig);
401 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
405 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
407 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
409 _outScanInfo(str, (Scan *) node);
411 WRITE_OID_FIELD(indexid);
412 WRITE_NODE_FIELD(indexqual);
413 WRITE_NODE_FIELD(indexqualorig);
417 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
419 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
421 _outScanInfo(str, (Scan *) node);
423 WRITE_NODE_FIELD(bitmapqualorig);
427 _outTidScan(StringInfo str, TidScan *node)
429 WRITE_NODE_TYPE("TIDSCAN");
431 _outScanInfo(str, (Scan *) node);
433 WRITE_NODE_FIELD(tidquals);
437 _outSubqueryScan(StringInfo str, SubqueryScan *node)
439 WRITE_NODE_TYPE("SUBQUERYSCAN");
441 _outScanInfo(str, (Scan *) node);
443 WRITE_NODE_FIELD(subplan);
444 WRITE_NODE_FIELD(subrtable);
448 _outFunctionScan(StringInfo str, FunctionScan *node)
450 WRITE_NODE_TYPE("FUNCTIONSCAN");
452 _outScanInfo(str, (Scan *) node);
454 WRITE_NODE_FIELD(funcexpr);
455 WRITE_NODE_FIELD(funccolnames);
456 WRITE_NODE_FIELD(funccoltypes);
457 WRITE_NODE_FIELD(funccoltypmods);
461 _outValuesScan(StringInfo str, ValuesScan *node)
463 WRITE_NODE_TYPE("VALUESSCAN");
465 _outScanInfo(str, (Scan *) node);
467 WRITE_NODE_FIELD(values_lists);
471 _outCteScan(StringInfo str, CteScan *node)
473 WRITE_NODE_TYPE("CTESCAN");
475 _outScanInfo(str, (Scan *) node);
477 WRITE_INT_FIELD(ctePlanId);
478 WRITE_INT_FIELD(cteParam);
482 _outWorkTableScan(StringInfo str, WorkTableScan *node)
484 WRITE_NODE_TYPE("WORKTABLESCAN");
486 _outScanInfo(str, (Scan *) node);
488 WRITE_INT_FIELD(wtParam);
492 _outJoin(StringInfo str, Join *node)
494 WRITE_NODE_TYPE("JOIN");
496 _outJoinPlanInfo(str, (Join *) node);
500 _outNestLoop(StringInfo str, NestLoop *node)
502 WRITE_NODE_TYPE("NESTLOOP");
504 _outJoinPlanInfo(str, (Join *) node);
508 _outMergeJoin(StringInfo str, MergeJoin *node)
513 WRITE_NODE_TYPE("MERGEJOIN");
515 _outJoinPlanInfo(str, (Join *) node);
517 WRITE_NODE_FIELD(mergeclauses);
519 numCols = list_length(node->mergeclauses);
521 appendStringInfo(str, " :mergeFamilies");
522 for (i = 0; i < numCols; i++)
523 appendStringInfo(str, " %u", node->mergeFamilies[i]);
525 appendStringInfo(str, " :mergeStrategies");
526 for (i = 0; i < numCols; i++)
527 appendStringInfo(str, " %d", node->mergeStrategies[i]);
529 appendStringInfo(str, " :mergeNullsFirst");
530 for (i = 0; i < numCols; i++)
531 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
535 _outHashJoin(StringInfo str, HashJoin *node)
537 WRITE_NODE_TYPE("HASHJOIN");
539 _outJoinPlanInfo(str, (Join *) node);
541 WRITE_NODE_FIELD(hashclauses);
545 _outAgg(StringInfo str, Agg *node)
549 WRITE_NODE_TYPE("AGG");
551 _outPlanInfo(str, (Plan *) node);
553 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
554 WRITE_INT_FIELD(numCols);
556 appendStringInfo(str, " :grpColIdx");
557 for (i = 0; i < node->numCols; i++)
558 appendStringInfo(str, " %d", node->grpColIdx[i]);
560 appendStringInfo(str, " :grpOperators");
561 for (i = 0; i < node->numCols; i++)
562 appendStringInfo(str, " %u", node->grpOperators[i]);
564 WRITE_LONG_FIELD(numGroups);
568 _outWindowAgg(StringInfo str, WindowAgg *node)
572 WRITE_NODE_TYPE("WINDOWAGG");
574 _outPlanInfo(str, (Plan *) node);
576 WRITE_UINT_FIELD(winref);
577 WRITE_INT_FIELD(partNumCols);
579 appendStringInfo(str, " :partColIdx");
580 for (i = 0; i < node->partNumCols; i++)
581 appendStringInfo(str, " %d", node->partColIdx[i]);
583 appendStringInfo(str, " :partOperations");
584 for (i = 0; i < node->partNumCols; i++)
585 appendStringInfo(str, " %u", node->partOperators[i]);
587 WRITE_INT_FIELD(ordNumCols);
589 appendStringInfo(str, " :ordColIdx");
590 for (i = 0; i< node->ordNumCols; i++)
591 appendStringInfo(str, " %d", node->ordColIdx[i]);
593 appendStringInfo(str, " :ordOperations");
594 for (i = 0; i < node->ordNumCols; i++)
595 appendStringInfo(str, " %u", node->ordOperators[i]);
597 WRITE_INT_FIELD(frameOptions);
601 _outGroup(StringInfo str, Group *node)
605 WRITE_NODE_TYPE("GROUP");
607 _outPlanInfo(str, (Plan *) node);
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]);
621 _outMaterial(StringInfo str, Material *node)
623 WRITE_NODE_TYPE("MATERIAL");
625 _outPlanInfo(str, (Plan *) node);
629 _outSort(StringInfo str, Sort *node)
633 WRITE_NODE_TYPE("SORT");
635 _outPlanInfo(str, (Plan *) node);
637 WRITE_INT_FIELD(numCols);
639 appendStringInfo(str, " :sortColIdx");
640 for (i = 0; i < node->numCols; i++)
641 appendStringInfo(str, " %d", node->sortColIdx[i]);
643 appendStringInfo(str, " :sortOperators");
644 for (i = 0; i < node->numCols; i++)
645 appendStringInfo(str, " %u", node->sortOperators[i]);
647 appendStringInfo(str, " :nullsFirst");
648 for (i = 0; i < node->numCols; i++)
649 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
653 _outUnique(StringInfo str, Unique *node)
657 WRITE_NODE_TYPE("UNIQUE");
659 _outPlanInfo(str, (Plan *) node);
661 WRITE_INT_FIELD(numCols);
663 appendStringInfo(str, " :uniqColIdx");
664 for (i = 0; i < node->numCols; i++)
665 appendStringInfo(str, " %d", node->uniqColIdx[i]);
667 appendStringInfo(str, " :uniqOperators");
668 for (i = 0; i < node->numCols; i++)
669 appendStringInfo(str, " %u", node->uniqOperators[i]);
673 _outHash(StringInfo str, Hash *node)
675 WRITE_NODE_TYPE("HASH");
677 _outPlanInfo(str, (Plan *) node);
681 _outSetOp(StringInfo str, SetOp *node)
685 WRITE_NODE_TYPE("SETOP");
687 _outPlanInfo(str, (Plan *) node);
689 WRITE_ENUM_FIELD(cmd, SetOpCmd);
690 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
691 WRITE_INT_FIELD(numCols);
693 appendStringInfo(str, " :dupColIdx");
694 for (i = 0; i < node->numCols; i++)
695 appendStringInfo(str, " %d", node->dupColIdx[i]);
697 appendStringInfo(str, " :dupOperators");
698 for (i = 0; i < node->numCols; i++)
699 appendStringInfo(str, " %u", node->dupOperators[i]);
701 WRITE_INT_FIELD(flagColIdx);
702 WRITE_INT_FIELD(firstFlag);
703 WRITE_LONG_FIELD(numGroups);
707 _outLimit(StringInfo str, Limit *node)
709 WRITE_NODE_TYPE("LIMIT");
711 _outPlanInfo(str, (Plan *) node);
713 WRITE_NODE_FIELD(limitOffset);
714 WRITE_NODE_FIELD(limitCount);
718 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
720 WRITE_NODE_TYPE("PLANINVALITEM");
722 WRITE_INT_FIELD(cacheId);
723 appendStringInfo(str, " :tupleId (%u,%u)",
724 ItemPointerGetBlockNumber(&node->tupleId),
725 ItemPointerGetOffsetNumber(&node->tupleId));
728 /*****************************************************************************
730 * Stuff from primnodes.h.
732 *****************************************************************************/
735 _outAlias(StringInfo str, Alias *node)
737 WRITE_NODE_TYPE("ALIAS");
739 WRITE_STRING_FIELD(aliasname);
740 WRITE_NODE_FIELD(colnames);
744 _outRangeVar(StringInfo str, RangeVar *node)
746 WRITE_NODE_TYPE("RANGEVAR");
749 * we deliberately ignore catalogname here, since it is presently not
750 * semantically meaningful
752 WRITE_STRING_FIELD(schemaname);
753 WRITE_STRING_FIELD(relname);
754 WRITE_ENUM_FIELD(inhOpt, InhOption);
755 WRITE_BOOL_FIELD(istemp);
756 WRITE_NODE_FIELD(alias);
757 WRITE_LOCATION_FIELD(location);
761 _outIntoClause(StringInfo str, IntoClause *node)
763 WRITE_NODE_TYPE("INTOCLAUSE");
765 WRITE_NODE_FIELD(rel);
766 WRITE_NODE_FIELD(colNames);
767 WRITE_NODE_FIELD(options);
768 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
769 WRITE_STRING_FIELD(tableSpaceName);
773 _outVar(StringInfo str, Var *node)
775 WRITE_NODE_TYPE("VAR");
777 WRITE_UINT_FIELD(varno);
778 WRITE_INT_FIELD(varattno);
779 WRITE_OID_FIELD(vartype);
780 WRITE_INT_FIELD(vartypmod);
781 WRITE_UINT_FIELD(varlevelsup);
782 WRITE_UINT_FIELD(varnoold);
783 WRITE_INT_FIELD(varoattno);
784 WRITE_LOCATION_FIELD(location);
788 _outConst(StringInfo str, Const *node)
790 WRITE_NODE_TYPE("CONST");
792 WRITE_OID_FIELD(consttype);
793 WRITE_INT_FIELD(consttypmod);
794 WRITE_INT_FIELD(constlen);
795 WRITE_BOOL_FIELD(constbyval);
796 WRITE_BOOL_FIELD(constisnull);
797 WRITE_LOCATION_FIELD(location);
799 appendStringInfo(str, " :constvalue ");
800 if (node->constisnull)
801 appendStringInfo(str, "<>");
803 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
807 _outParam(StringInfo str, Param *node)
809 WRITE_NODE_TYPE("PARAM");
811 WRITE_ENUM_FIELD(paramkind, ParamKind);
812 WRITE_INT_FIELD(paramid);
813 WRITE_OID_FIELD(paramtype);
814 WRITE_INT_FIELD(paramtypmod);
815 WRITE_LOCATION_FIELD(location);
819 _outAggref(StringInfo str, Aggref *node)
821 WRITE_NODE_TYPE("AGGREF");
823 WRITE_OID_FIELD(aggfnoid);
824 WRITE_OID_FIELD(aggtype);
825 WRITE_NODE_FIELD(args);
826 WRITE_UINT_FIELD(agglevelsup);
827 WRITE_BOOL_FIELD(aggstar);
828 WRITE_BOOL_FIELD(aggdistinct);
829 WRITE_LOCATION_FIELD(location);
833 _outWindowFunc(StringInfo str, WindowFunc *node)
835 WRITE_NODE_TYPE("WINDOWFUNC");
837 WRITE_OID_FIELD(winfnoid);
838 WRITE_OID_FIELD(wintype);
839 WRITE_NODE_FIELD(args);
840 WRITE_UINT_FIELD(winref);
841 WRITE_BOOL_FIELD(winstar);
842 WRITE_BOOL_FIELD(winagg);
843 WRITE_LOCATION_FIELD(location);
847 _outArrayRef(StringInfo str, ArrayRef *node)
849 WRITE_NODE_TYPE("ARRAYREF");
851 WRITE_OID_FIELD(refarraytype);
852 WRITE_OID_FIELD(refelemtype);
853 WRITE_INT_FIELD(reftypmod);
854 WRITE_NODE_FIELD(refupperindexpr);
855 WRITE_NODE_FIELD(reflowerindexpr);
856 WRITE_NODE_FIELD(refexpr);
857 WRITE_NODE_FIELD(refassgnexpr);
861 _outFuncExpr(StringInfo str, FuncExpr *node)
863 WRITE_NODE_TYPE("FUNCEXPR");
865 WRITE_OID_FIELD(funcid);
866 WRITE_OID_FIELD(funcresulttype);
867 WRITE_BOOL_FIELD(funcretset);
868 WRITE_ENUM_FIELD(funcformat, CoercionForm);
869 WRITE_NODE_FIELD(args);
870 WRITE_LOCATION_FIELD(location);
874 _outOpExpr(StringInfo str, OpExpr *node)
876 WRITE_NODE_TYPE("OPEXPR");
878 WRITE_OID_FIELD(opno);
879 WRITE_OID_FIELD(opfuncid);
880 WRITE_OID_FIELD(opresulttype);
881 WRITE_BOOL_FIELD(opretset);
882 WRITE_NODE_FIELD(args);
883 WRITE_LOCATION_FIELD(location);
887 _outDistinctExpr(StringInfo str, DistinctExpr *node)
889 WRITE_NODE_TYPE("DISTINCTEXPR");
891 WRITE_OID_FIELD(opno);
892 WRITE_OID_FIELD(opfuncid);
893 WRITE_OID_FIELD(opresulttype);
894 WRITE_BOOL_FIELD(opretset);
895 WRITE_NODE_FIELD(args);
896 WRITE_LOCATION_FIELD(location);
900 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
902 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
904 WRITE_OID_FIELD(opno);
905 WRITE_OID_FIELD(opfuncid);
906 WRITE_BOOL_FIELD(useOr);
907 WRITE_NODE_FIELD(args);
908 WRITE_LOCATION_FIELD(location);
912 _outBoolExpr(StringInfo str, BoolExpr *node)
916 WRITE_NODE_TYPE("BOOLEXPR");
918 /* do-it-yourself enum representation */
919 switch (node->boolop)
931 appendStringInfo(str, " :boolop ");
932 _outToken(str, opstr);
934 WRITE_NODE_FIELD(args);
935 WRITE_LOCATION_FIELD(location);
939 _outSubLink(StringInfo str, SubLink *node)
941 WRITE_NODE_TYPE("SUBLINK");
943 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
944 WRITE_NODE_FIELD(testexpr);
945 WRITE_NODE_FIELD(operName);
946 WRITE_NODE_FIELD(subselect);
947 WRITE_LOCATION_FIELD(location);
951 _outSubPlan(StringInfo str, SubPlan *node)
953 WRITE_NODE_TYPE("SUBPLAN");
955 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
956 WRITE_NODE_FIELD(testexpr);
957 WRITE_NODE_FIELD(paramIds);
958 WRITE_INT_FIELD(plan_id);
959 WRITE_OID_FIELD(firstColType);
960 WRITE_BOOL_FIELD(useHashTable);
961 WRITE_BOOL_FIELD(unknownEqFalse);
962 WRITE_NODE_FIELD(setParam);
963 WRITE_NODE_FIELD(parParam);
964 WRITE_NODE_FIELD(args);
965 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
966 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
970 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
972 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
974 WRITE_NODE_FIELD(subplans);
978 _outFieldSelect(StringInfo str, FieldSelect *node)
980 WRITE_NODE_TYPE("FIELDSELECT");
982 WRITE_NODE_FIELD(arg);
983 WRITE_INT_FIELD(fieldnum);
984 WRITE_OID_FIELD(resulttype);
985 WRITE_INT_FIELD(resulttypmod);
989 _outFieldStore(StringInfo str, FieldStore *node)
991 WRITE_NODE_TYPE("FIELDSTORE");
993 WRITE_NODE_FIELD(arg);
994 WRITE_NODE_FIELD(newvals);
995 WRITE_NODE_FIELD(fieldnums);
996 WRITE_OID_FIELD(resulttype);
1000 _outRelabelType(StringInfo str, RelabelType *node)
1002 WRITE_NODE_TYPE("RELABELTYPE");
1004 WRITE_NODE_FIELD(arg);
1005 WRITE_OID_FIELD(resulttype);
1006 WRITE_INT_FIELD(resulttypmod);
1007 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1008 WRITE_LOCATION_FIELD(location);
1012 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1014 WRITE_NODE_TYPE("COERCEVIAIO");
1016 WRITE_NODE_FIELD(arg);
1017 WRITE_OID_FIELD(resulttype);
1018 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1019 WRITE_LOCATION_FIELD(location);
1023 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1025 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1027 WRITE_NODE_FIELD(arg);
1028 WRITE_OID_FIELD(elemfuncid);
1029 WRITE_OID_FIELD(resulttype);
1030 WRITE_INT_FIELD(resulttypmod);
1031 WRITE_BOOL_FIELD(isExplicit);
1032 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1033 WRITE_LOCATION_FIELD(location);
1037 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1039 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1041 WRITE_NODE_FIELD(arg);
1042 WRITE_OID_FIELD(resulttype);
1043 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1044 WRITE_LOCATION_FIELD(location);
1048 _outCaseExpr(StringInfo str, CaseExpr *node)
1050 WRITE_NODE_TYPE("CASE");
1052 WRITE_OID_FIELD(casetype);
1053 WRITE_NODE_FIELD(arg);
1054 WRITE_NODE_FIELD(args);
1055 WRITE_NODE_FIELD(defresult);
1056 WRITE_LOCATION_FIELD(location);
1060 _outCaseWhen(StringInfo str, CaseWhen *node)
1062 WRITE_NODE_TYPE("WHEN");
1064 WRITE_NODE_FIELD(expr);
1065 WRITE_NODE_FIELD(result);
1066 WRITE_LOCATION_FIELD(location);
1070 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1072 WRITE_NODE_TYPE("CASETESTEXPR");
1074 WRITE_OID_FIELD(typeId);
1075 WRITE_INT_FIELD(typeMod);
1079 _outArrayExpr(StringInfo str, ArrayExpr *node)
1081 WRITE_NODE_TYPE("ARRAY");
1083 WRITE_OID_FIELD(array_typeid);
1084 WRITE_OID_FIELD(element_typeid);
1085 WRITE_NODE_FIELD(elements);
1086 WRITE_BOOL_FIELD(multidims);
1087 WRITE_LOCATION_FIELD(location);
1091 _outRowExpr(StringInfo str, RowExpr *node)
1093 WRITE_NODE_TYPE("ROW");
1095 WRITE_NODE_FIELD(args);
1096 WRITE_OID_FIELD(row_typeid);
1097 WRITE_ENUM_FIELD(row_format, CoercionForm);
1098 WRITE_NODE_FIELD(colnames);
1099 WRITE_LOCATION_FIELD(location);
1103 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1105 WRITE_NODE_TYPE("ROWCOMPARE");
1107 WRITE_ENUM_FIELD(rctype, RowCompareType);
1108 WRITE_NODE_FIELD(opnos);
1109 WRITE_NODE_FIELD(opfamilies);
1110 WRITE_NODE_FIELD(largs);
1111 WRITE_NODE_FIELD(rargs);
1115 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1117 WRITE_NODE_TYPE("COALESCE");
1119 WRITE_OID_FIELD(coalescetype);
1120 WRITE_NODE_FIELD(args);
1121 WRITE_LOCATION_FIELD(location);
1125 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1127 WRITE_NODE_TYPE("MINMAX");
1129 WRITE_OID_FIELD(minmaxtype);
1130 WRITE_ENUM_FIELD(op, MinMaxOp);
1131 WRITE_NODE_FIELD(args);
1132 WRITE_LOCATION_FIELD(location);
1136 _outXmlExpr(StringInfo str, XmlExpr *node)
1138 WRITE_NODE_TYPE("XMLEXPR");
1140 WRITE_ENUM_FIELD(op, XmlExprOp);
1141 WRITE_STRING_FIELD(name);
1142 WRITE_NODE_FIELD(named_args);
1143 WRITE_NODE_FIELD(arg_names);
1144 WRITE_NODE_FIELD(args);
1145 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1146 WRITE_OID_FIELD(type);
1147 WRITE_INT_FIELD(typmod);
1148 WRITE_LOCATION_FIELD(location);
1152 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1154 WRITE_NODE_TYPE("NULLIFEXPR");
1156 WRITE_OID_FIELD(opno);
1157 WRITE_OID_FIELD(opfuncid);
1158 WRITE_OID_FIELD(opresulttype);
1159 WRITE_BOOL_FIELD(opretset);
1160 WRITE_NODE_FIELD(args);
1161 WRITE_LOCATION_FIELD(location);
1165 _outNullTest(StringInfo str, NullTest *node)
1167 WRITE_NODE_TYPE("NULLTEST");
1169 WRITE_NODE_FIELD(arg);
1170 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1174 _outBooleanTest(StringInfo str, BooleanTest *node)
1176 WRITE_NODE_TYPE("BOOLEANTEST");
1178 WRITE_NODE_FIELD(arg);
1179 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1183 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1185 WRITE_NODE_TYPE("COERCETODOMAIN");
1187 WRITE_NODE_FIELD(arg);
1188 WRITE_OID_FIELD(resulttype);
1189 WRITE_INT_FIELD(resulttypmod);
1190 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1191 WRITE_LOCATION_FIELD(location);
1195 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1197 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1199 WRITE_OID_FIELD(typeId);
1200 WRITE_INT_FIELD(typeMod);
1201 WRITE_LOCATION_FIELD(location);
1205 _outSetToDefault(StringInfo str, SetToDefault *node)
1207 WRITE_NODE_TYPE("SETTODEFAULT");
1209 WRITE_OID_FIELD(typeId);
1210 WRITE_INT_FIELD(typeMod);
1211 WRITE_LOCATION_FIELD(location);
1215 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1217 WRITE_NODE_TYPE("CURRENTOFEXPR");
1219 WRITE_UINT_FIELD(cvarno);
1220 WRITE_STRING_FIELD(cursor_name);
1221 WRITE_INT_FIELD(cursor_param);
1225 _outTargetEntry(StringInfo str, TargetEntry *node)
1227 WRITE_NODE_TYPE("TARGETENTRY");
1229 WRITE_NODE_FIELD(expr);
1230 WRITE_INT_FIELD(resno);
1231 WRITE_STRING_FIELD(resname);
1232 WRITE_UINT_FIELD(ressortgroupref);
1233 WRITE_OID_FIELD(resorigtbl);
1234 WRITE_INT_FIELD(resorigcol);
1235 WRITE_BOOL_FIELD(resjunk);
1239 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1241 WRITE_NODE_TYPE("RANGETBLREF");
1243 WRITE_INT_FIELD(rtindex);
1247 _outJoinExpr(StringInfo str, JoinExpr *node)
1249 WRITE_NODE_TYPE("JOINEXPR");
1251 WRITE_ENUM_FIELD(jointype, JoinType);
1252 WRITE_BOOL_FIELD(isNatural);
1253 WRITE_NODE_FIELD(larg);
1254 WRITE_NODE_FIELD(rarg);
1255 WRITE_NODE_FIELD(using);
1256 WRITE_NODE_FIELD(quals);
1257 WRITE_NODE_FIELD(alias);
1258 WRITE_INT_FIELD(rtindex);
1262 _outFromExpr(StringInfo str, FromExpr *node)
1264 WRITE_NODE_TYPE("FROMEXPR");
1266 WRITE_NODE_FIELD(fromlist);
1267 WRITE_NODE_FIELD(quals);
1270 /*****************************************************************************
1272 * Stuff from relation.h.
1274 *****************************************************************************/
1277 * print the basic stuff of all nodes that inherit from Path
1279 * Note we do NOT print the parent, else we'd be in infinite recursion
1282 _outPathInfo(StringInfo str, Path *node)
1284 WRITE_ENUM_FIELD(pathtype, NodeTag);
1285 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1286 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1287 WRITE_NODE_FIELD(pathkeys);
1291 * print the basic stuff of all nodes that inherit from JoinPath
1294 _outJoinPathInfo(StringInfo str, JoinPath *node)
1296 _outPathInfo(str, (Path *) node);
1298 WRITE_ENUM_FIELD(jointype, JoinType);
1299 WRITE_NODE_FIELD(outerjoinpath);
1300 WRITE_NODE_FIELD(innerjoinpath);
1301 WRITE_NODE_FIELD(joinrestrictinfo);
1305 _outPath(StringInfo str, Path *node)
1307 WRITE_NODE_TYPE("PATH");
1309 _outPathInfo(str, (Path *) node);
1313 _outIndexPath(StringInfo str, IndexPath *node)
1315 WRITE_NODE_TYPE("INDEXPATH");
1317 _outPathInfo(str, (Path *) node);
1319 WRITE_NODE_FIELD(indexinfo);
1320 WRITE_NODE_FIELD(indexclauses);
1321 WRITE_NODE_FIELD(indexquals);
1322 WRITE_BOOL_FIELD(isjoininner);
1323 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1324 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1325 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1326 WRITE_FLOAT_FIELD(rows, "%.0f");
1330 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1332 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1334 _outPathInfo(str, (Path *) node);
1336 WRITE_NODE_FIELD(bitmapqual);
1337 WRITE_BOOL_FIELD(isjoininner);
1338 WRITE_FLOAT_FIELD(rows, "%.0f");
1342 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1344 WRITE_NODE_TYPE("BITMAPANDPATH");
1346 _outPathInfo(str, (Path *) node);
1348 WRITE_NODE_FIELD(bitmapquals);
1349 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1353 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1355 WRITE_NODE_TYPE("BITMAPORPATH");
1357 _outPathInfo(str, (Path *) node);
1359 WRITE_NODE_FIELD(bitmapquals);
1360 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1364 _outTidPath(StringInfo str, TidPath *node)
1366 WRITE_NODE_TYPE("TIDPATH");
1368 _outPathInfo(str, (Path *) node);
1370 WRITE_NODE_FIELD(tidquals);
1374 _outAppendPath(StringInfo str, AppendPath *node)
1376 WRITE_NODE_TYPE("APPENDPATH");
1378 _outPathInfo(str, (Path *) node);
1380 WRITE_NODE_FIELD(subpaths);
1384 _outResultPath(StringInfo str, ResultPath *node)
1386 WRITE_NODE_TYPE("RESULTPATH");
1388 _outPathInfo(str, (Path *) node);
1390 WRITE_NODE_FIELD(quals);
1394 _outMaterialPath(StringInfo str, MaterialPath *node)
1396 WRITE_NODE_TYPE("MATERIALPATH");
1398 _outPathInfo(str, (Path *) node);
1400 WRITE_NODE_FIELD(subpath);
1404 _outUniquePath(StringInfo str, UniquePath *node)
1406 WRITE_NODE_TYPE("UNIQUEPATH");
1408 _outPathInfo(str, (Path *) node);
1410 WRITE_NODE_FIELD(subpath);
1411 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1412 WRITE_NODE_FIELD(in_operators);
1413 WRITE_NODE_FIELD(uniq_exprs);
1414 WRITE_FLOAT_FIELD(rows, "%.0f");
1418 _outNestPath(StringInfo str, NestPath *node)
1420 WRITE_NODE_TYPE("NESTPATH");
1422 _outJoinPathInfo(str, (JoinPath *) node);
1426 _outMergePath(StringInfo str, MergePath *node)
1428 WRITE_NODE_TYPE("MERGEPATH");
1430 _outJoinPathInfo(str, (JoinPath *) node);
1432 WRITE_NODE_FIELD(path_mergeclauses);
1433 WRITE_NODE_FIELD(outersortkeys);
1434 WRITE_NODE_FIELD(innersortkeys);
1438 _outHashPath(StringInfo str, HashPath *node)
1440 WRITE_NODE_TYPE("HASHPATH");
1442 _outJoinPathInfo(str, (JoinPath *) node);
1444 WRITE_NODE_FIELD(path_hashclauses);
1448 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1450 WRITE_NODE_TYPE("PLANNERGLOBAL");
1452 /* NB: this isn't a complete set of fields */
1453 WRITE_NODE_FIELD(paramlist);
1454 WRITE_NODE_FIELD(subplans);
1455 WRITE_NODE_FIELD(subrtables);
1456 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1457 WRITE_NODE_FIELD(finalrtable);
1458 WRITE_NODE_FIELD(relationOids);
1459 WRITE_NODE_FIELD(invalItems);
1460 WRITE_UINT_FIELD(lastPHId);
1461 WRITE_BOOL_FIELD(transientPlan);
1465 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1467 WRITE_NODE_TYPE("PLANNERINFO");
1469 /* NB: this isn't a complete set of fields */
1470 WRITE_NODE_FIELD(parse);
1471 WRITE_NODE_FIELD(glob);
1472 WRITE_UINT_FIELD(query_level);
1473 WRITE_NODE_FIELD(join_rel_list);
1474 WRITE_NODE_FIELD(resultRelations);
1475 WRITE_NODE_FIELD(returningLists);
1476 WRITE_NODE_FIELD(init_plans);
1477 WRITE_NODE_FIELD(cte_plan_ids);
1478 WRITE_NODE_FIELD(eq_classes);
1479 WRITE_NODE_FIELD(canon_pathkeys);
1480 WRITE_NODE_FIELD(left_join_clauses);
1481 WRITE_NODE_FIELD(right_join_clauses);
1482 WRITE_NODE_FIELD(full_join_clauses);
1483 WRITE_NODE_FIELD(join_info_list);
1484 WRITE_NODE_FIELD(append_rel_list);
1485 WRITE_NODE_FIELD(placeholder_list);
1486 WRITE_NODE_FIELD(query_pathkeys);
1487 WRITE_NODE_FIELD(group_pathkeys);
1488 WRITE_NODE_FIELD(window_pathkeys);
1489 WRITE_NODE_FIELD(distinct_pathkeys);
1490 WRITE_NODE_FIELD(sort_pathkeys);
1491 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1492 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1493 WRITE_BOOL_FIELD(hasJoinRTEs);
1494 WRITE_BOOL_FIELD(hasHavingQual);
1495 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1496 WRITE_BOOL_FIELD(hasRecursion);
1497 WRITE_INT_FIELD(wt_param_id);
1501 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1503 WRITE_NODE_TYPE("RELOPTINFO");
1505 /* NB: this isn't a complete set of fields */
1506 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1507 WRITE_BITMAPSET_FIELD(relids);
1508 WRITE_FLOAT_FIELD(rows, "%.0f");
1509 WRITE_INT_FIELD(width);
1510 WRITE_NODE_FIELD(reltargetlist);
1511 WRITE_NODE_FIELD(pathlist);
1512 WRITE_NODE_FIELD(cheapest_startup_path);
1513 WRITE_NODE_FIELD(cheapest_total_path);
1514 WRITE_NODE_FIELD(cheapest_unique_path);
1515 WRITE_UINT_FIELD(relid);
1516 WRITE_ENUM_FIELD(rtekind, RTEKind);
1517 WRITE_INT_FIELD(min_attr);
1518 WRITE_INT_FIELD(max_attr);
1519 WRITE_NODE_FIELD(indexlist);
1520 WRITE_UINT_FIELD(pages);
1521 WRITE_FLOAT_FIELD(tuples, "%.0f");
1522 WRITE_NODE_FIELD(subplan);
1523 WRITE_NODE_FIELD(subrtable);
1524 WRITE_NODE_FIELD(baserestrictinfo);
1525 WRITE_NODE_FIELD(joininfo);
1526 WRITE_BOOL_FIELD(has_eclass_joins);
1527 WRITE_BITMAPSET_FIELD(index_outer_relids);
1528 WRITE_NODE_FIELD(index_inner_paths);
1532 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1534 WRITE_NODE_TYPE("INDEXOPTINFO");
1536 /* NB: this isn't a complete set of fields */
1537 WRITE_OID_FIELD(indexoid);
1538 /* Do NOT print rel field, else infinite recursion */
1539 WRITE_UINT_FIELD(pages);
1540 WRITE_FLOAT_FIELD(tuples, "%.0f");
1541 WRITE_INT_FIELD(ncolumns);
1542 WRITE_NODE_FIELD(indexprs);
1543 WRITE_NODE_FIELD(indpred);
1544 WRITE_BOOL_FIELD(predOK);
1545 WRITE_BOOL_FIELD(unique);
1549 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1552 * To simplify reading, we just chase up to the topmost merged EC and
1553 * print that, without bothering to show the merge-ees separately.
1555 while (node->ec_merged)
1556 node = node->ec_merged;
1558 WRITE_NODE_TYPE("EQUIVALENCECLASS");
1560 WRITE_NODE_FIELD(ec_opfamilies);
1561 WRITE_NODE_FIELD(ec_members);
1562 WRITE_NODE_FIELD(ec_sources);
1563 WRITE_NODE_FIELD(ec_derives);
1564 WRITE_BITMAPSET_FIELD(ec_relids);
1565 WRITE_BOOL_FIELD(ec_has_const);
1566 WRITE_BOOL_FIELD(ec_has_volatile);
1567 WRITE_BOOL_FIELD(ec_below_outer_join);
1568 WRITE_BOOL_FIELD(ec_broken);
1569 WRITE_UINT_FIELD(ec_sortref);
1573 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1575 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1577 WRITE_NODE_FIELD(em_expr);
1578 WRITE_BITMAPSET_FIELD(em_relids);
1579 WRITE_BOOL_FIELD(em_is_const);
1580 WRITE_BOOL_FIELD(em_is_child);
1581 WRITE_OID_FIELD(em_datatype);
1585 _outPathKey(StringInfo str, PathKey *node)
1587 WRITE_NODE_TYPE("PATHKEY");
1589 WRITE_NODE_FIELD(pk_eclass);
1590 WRITE_OID_FIELD(pk_opfamily);
1591 WRITE_INT_FIELD(pk_strategy);
1592 WRITE_BOOL_FIELD(pk_nulls_first);
1596 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1598 WRITE_NODE_TYPE("RESTRICTINFO");
1600 /* NB: this isn't a complete set of fields */
1601 WRITE_NODE_FIELD(clause);
1602 WRITE_BOOL_FIELD(is_pushed_down);
1603 WRITE_BOOL_FIELD(outerjoin_delayed);
1604 WRITE_BOOL_FIELD(can_join);
1605 WRITE_BOOL_FIELD(pseudoconstant);
1606 WRITE_BITMAPSET_FIELD(clause_relids);
1607 WRITE_BITMAPSET_FIELD(required_relids);
1608 WRITE_BITMAPSET_FIELD(left_relids);
1609 WRITE_BITMAPSET_FIELD(right_relids);
1610 WRITE_NODE_FIELD(orclause);
1611 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1612 WRITE_FLOAT_FIELD(this_selec, "%.4f");
1613 WRITE_NODE_FIELD(mergeopfamilies);
1614 /* don't write left_ec, leads to infinite recursion in plan tree dump */
1615 /* don't write right_ec, leads to infinite recursion in plan tree dump */
1616 WRITE_NODE_FIELD(left_em);
1617 WRITE_NODE_FIELD(right_em);
1618 WRITE_BOOL_FIELD(outer_is_left);
1619 WRITE_OID_FIELD(hashjoinoperator);
1623 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1625 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1626 WRITE_BITMAPSET_FIELD(other_relids);
1627 WRITE_BOOL_FIELD(isouterjoin);
1628 WRITE_NODE_FIELD(cheapest_startup_innerpath);
1629 WRITE_NODE_FIELD(cheapest_total_innerpath);
1633 _outFlattenedSubLink(StringInfo str, FlattenedSubLink *node)
1635 WRITE_NODE_TYPE("FLATTENEDSUBLINK");
1637 WRITE_ENUM_FIELD(jointype, JoinType);
1638 WRITE_BITMAPSET_FIELD(lefthand);
1639 WRITE_BITMAPSET_FIELD(righthand);
1640 WRITE_NODE_FIELD(quals);
1644 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1646 WRITE_NODE_TYPE("PLACEHOLDERVAR");
1648 WRITE_NODE_FIELD(phexpr);
1649 WRITE_BITMAPSET_FIELD(phrels);
1650 WRITE_UINT_FIELD(phid);
1651 WRITE_UINT_FIELD(phlevelsup);
1655 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1657 WRITE_NODE_TYPE("SPECIALJOININFO");
1659 WRITE_BITMAPSET_FIELD(min_lefthand);
1660 WRITE_BITMAPSET_FIELD(min_righthand);
1661 WRITE_BITMAPSET_FIELD(syn_lefthand);
1662 WRITE_BITMAPSET_FIELD(syn_righthand);
1663 WRITE_ENUM_FIELD(jointype, JoinType);
1664 WRITE_BOOL_FIELD(lhs_strict);
1665 WRITE_BOOL_FIELD(delay_upper_joins);
1666 WRITE_NODE_FIELD(join_quals);
1670 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1672 WRITE_NODE_TYPE("APPENDRELINFO");
1674 WRITE_UINT_FIELD(parent_relid);
1675 WRITE_UINT_FIELD(child_relid);
1676 WRITE_OID_FIELD(parent_reltype);
1677 WRITE_OID_FIELD(child_reltype);
1678 WRITE_NODE_FIELD(translated_vars);
1679 WRITE_OID_FIELD(parent_reloid);
1683 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1685 WRITE_NODE_TYPE("PLACEHOLDERINFO");
1687 WRITE_UINT_FIELD(phid);
1688 WRITE_NODE_FIELD(ph_var);
1689 WRITE_BITMAPSET_FIELD(ph_eval_at);
1690 WRITE_BITMAPSET_FIELD(ph_needed);
1691 WRITE_INT_FIELD(ph_width);
1695 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1697 WRITE_NODE_TYPE("PLANNERPARAMITEM");
1699 WRITE_NODE_FIELD(item);
1700 WRITE_UINT_FIELD(abslevel);
1703 /*****************************************************************************
1705 * Stuff from parsenodes.h.
1707 *****************************************************************************/
1710 _outCreateStmt(StringInfo str, CreateStmt *node)
1712 WRITE_NODE_TYPE("CREATESTMT");
1714 WRITE_NODE_FIELD(relation);
1715 WRITE_NODE_FIELD(tableElts);
1716 WRITE_NODE_FIELD(inhRelations);
1717 WRITE_NODE_FIELD(constraints);
1718 WRITE_NODE_FIELD(options);
1719 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1720 WRITE_STRING_FIELD(tablespacename);
1724 _outIndexStmt(StringInfo str, IndexStmt *node)
1726 WRITE_NODE_TYPE("INDEXSTMT");
1728 WRITE_STRING_FIELD(idxname);
1729 WRITE_NODE_FIELD(relation);
1730 WRITE_STRING_FIELD(accessMethod);
1731 WRITE_STRING_FIELD(tableSpace);
1732 WRITE_NODE_FIELD(indexParams);
1733 WRITE_NODE_FIELD(options);
1734 WRITE_NODE_FIELD(whereClause);
1735 WRITE_BOOL_FIELD(unique);
1736 WRITE_BOOL_FIELD(primary);
1737 WRITE_BOOL_FIELD(isconstraint);
1738 WRITE_BOOL_FIELD(concurrent);
1742 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1744 WRITE_NODE_TYPE("NOTIFY");
1746 WRITE_STRING_FIELD(conditionname);
1750 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1752 WRITE_NODE_TYPE("DECLARECURSOR");
1754 WRITE_STRING_FIELD(portalname);
1755 WRITE_INT_FIELD(options);
1756 WRITE_NODE_FIELD(query);
1760 _outSelectStmt(StringInfo str, SelectStmt *node)
1762 WRITE_NODE_TYPE("SELECT");
1764 WRITE_NODE_FIELD(distinctClause);
1765 WRITE_NODE_FIELD(intoClause);
1766 WRITE_NODE_FIELD(targetList);
1767 WRITE_NODE_FIELD(fromClause);
1768 WRITE_NODE_FIELD(whereClause);
1769 WRITE_NODE_FIELD(groupClause);
1770 WRITE_NODE_FIELD(havingClause);
1771 WRITE_NODE_FIELD(windowClause);
1772 WRITE_NODE_FIELD(withClause);
1773 WRITE_NODE_FIELD(valuesLists);
1774 WRITE_NODE_FIELD(sortClause);
1775 WRITE_NODE_FIELD(limitOffset);
1776 WRITE_NODE_FIELD(limitCount);
1777 WRITE_NODE_FIELD(lockingClause);
1778 WRITE_ENUM_FIELD(op, SetOperation);
1779 WRITE_BOOL_FIELD(all);
1780 WRITE_NODE_FIELD(larg);
1781 WRITE_NODE_FIELD(rarg);
1785 _outFuncCall(StringInfo str, FuncCall *node)
1787 WRITE_NODE_TYPE("FUNCCALL");
1789 WRITE_NODE_FIELD(funcname);
1790 WRITE_NODE_FIELD(args);
1791 WRITE_BOOL_FIELD(agg_star);
1792 WRITE_BOOL_FIELD(agg_distinct);
1793 WRITE_BOOL_FIELD(func_variadic);
1794 WRITE_NODE_FIELD(over);
1795 WRITE_LOCATION_FIELD(location);
1799 _outDefElem(StringInfo str, DefElem *node)
1801 WRITE_NODE_TYPE("DEFELEM");
1803 WRITE_STRING_FIELD(defname);
1804 WRITE_NODE_FIELD(arg);
1808 _outReloptElem(StringInfo str, ReloptElem *node)
1810 WRITE_NODE_TYPE("RELOPTELEM");
1812 WRITE_STRING_FIELD(nmspc);
1813 WRITE_STRING_FIELD(optname);
1814 WRITE_NODE_FIELD(arg);
1818 _outLockingClause(StringInfo str, LockingClause *node)
1820 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1822 WRITE_NODE_FIELD(lockedRels);
1823 WRITE_BOOL_FIELD(forUpdate);
1824 WRITE_BOOL_FIELD(noWait);
1828 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1830 WRITE_NODE_TYPE("XMLSERIALIZE");
1832 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1833 WRITE_NODE_FIELD(expr);
1834 WRITE_NODE_FIELD(typename);
1835 WRITE_LOCATION_FIELD(location);
1839 _outColumnDef(StringInfo str, ColumnDef *node)
1841 WRITE_NODE_TYPE("COLUMNDEF");
1843 WRITE_STRING_FIELD(colname);
1844 WRITE_NODE_FIELD(typename);
1845 WRITE_INT_FIELD(inhcount);
1846 WRITE_BOOL_FIELD(is_local);
1847 WRITE_BOOL_FIELD(is_not_null);
1848 WRITE_NODE_FIELD(raw_default);
1849 WRITE_STRING_FIELD(cooked_default);
1850 WRITE_NODE_FIELD(constraints);
1854 _outTypeName(StringInfo str, TypeName *node)
1856 WRITE_NODE_TYPE("TYPENAME");
1858 WRITE_NODE_FIELD(names);
1859 WRITE_OID_FIELD(typeid);
1860 WRITE_BOOL_FIELD(setof);
1861 WRITE_BOOL_FIELD(pct_type);
1862 WRITE_NODE_FIELD(typmods);
1863 WRITE_INT_FIELD(typemod);
1864 WRITE_NODE_FIELD(arrayBounds);
1865 WRITE_LOCATION_FIELD(location);
1869 _outTypeCast(StringInfo str, TypeCast *node)
1871 WRITE_NODE_TYPE("TYPECAST");
1873 WRITE_NODE_FIELD(arg);
1874 WRITE_NODE_FIELD(typename);
1875 WRITE_LOCATION_FIELD(location);
1879 _outIndexElem(StringInfo str, IndexElem *node)
1881 WRITE_NODE_TYPE("INDEXELEM");
1883 WRITE_STRING_FIELD(name);
1884 WRITE_NODE_FIELD(expr);
1885 WRITE_NODE_FIELD(opclass);
1886 WRITE_ENUM_FIELD(ordering, SortByDir);
1887 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1891 _outQuery(StringInfo str, Query *node)
1893 WRITE_NODE_TYPE("QUERY");
1895 WRITE_ENUM_FIELD(commandType, CmdType);
1896 WRITE_ENUM_FIELD(querySource, QuerySource);
1897 WRITE_BOOL_FIELD(canSetTag);
1900 * Hack to work around missing outfuncs routines for a lot of the
1901 * utility-statement node types. (The only one we actually *need* for
1902 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1903 * for the meantime do this to avoid getting lots of warnings when running
1904 * with debug_print_parse on.
1906 if (node->utilityStmt)
1908 switch (nodeTag(node->utilityStmt))
1913 case T_DeclareCursorStmt:
1914 WRITE_NODE_FIELD(utilityStmt);
1917 appendStringInfo(str, " :utilityStmt ?");
1922 appendStringInfo(str, " :utilityStmt <>");
1924 WRITE_INT_FIELD(resultRelation);
1925 WRITE_NODE_FIELD(intoClause);
1926 WRITE_BOOL_FIELD(hasAggs);
1927 WRITE_BOOL_FIELD(hasWindowFuncs);
1928 WRITE_BOOL_FIELD(hasSubLinks);
1929 WRITE_BOOL_FIELD(hasDistinctOn);
1930 WRITE_BOOL_FIELD(hasRecursive);
1931 WRITE_NODE_FIELD(cteList);
1932 WRITE_NODE_FIELD(rtable);
1933 WRITE_NODE_FIELD(jointree);
1934 WRITE_NODE_FIELD(targetList);
1935 WRITE_NODE_FIELD(returningList);
1936 WRITE_NODE_FIELD(groupClause);
1937 WRITE_NODE_FIELD(havingQual);
1938 WRITE_NODE_FIELD(windowClause);
1939 WRITE_NODE_FIELD(distinctClause);
1940 WRITE_NODE_FIELD(sortClause);
1941 WRITE_NODE_FIELD(limitOffset);
1942 WRITE_NODE_FIELD(limitCount);
1943 WRITE_NODE_FIELD(rowMarks);
1944 WRITE_NODE_FIELD(setOperations);
1948 _outSortGroupClause(StringInfo str, SortGroupClause *node)
1950 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
1952 WRITE_UINT_FIELD(tleSortGroupRef);
1953 WRITE_OID_FIELD(eqop);
1954 WRITE_OID_FIELD(sortop);
1955 WRITE_BOOL_FIELD(nulls_first);
1959 _outWindowClause(StringInfo str, WindowClause *node)
1961 WRITE_NODE_TYPE("WINDOWCLAUSE");
1963 WRITE_STRING_FIELD(name);
1964 WRITE_STRING_FIELD(refname);
1965 WRITE_NODE_FIELD(partitionClause);
1966 WRITE_NODE_FIELD(orderClause);
1967 WRITE_INT_FIELD(frameOptions);
1968 WRITE_UINT_FIELD(winref);
1969 WRITE_BOOL_FIELD(copiedOrder);
1973 _outRowMarkClause(StringInfo str, RowMarkClause *node)
1975 WRITE_NODE_TYPE("ROWMARKCLAUSE");
1977 WRITE_UINT_FIELD(rti);
1978 WRITE_UINT_FIELD(prti);
1979 WRITE_BOOL_FIELD(forUpdate);
1980 WRITE_BOOL_FIELD(noWait);
1981 WRITE_BOOL_FIELD(isParent);
1985 _outWithClause(StringInfo str, WithClause *node)
1987 WRITE_NODE_TYPE("WITHCLAUSE");
1989 WRITE_NODE_FIELD(ctes);
1990 WRITE_BOOL_FIELD(recursive);
1991 WRITE_LOCATION_FIELD(location);
1995 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
1997 WRITE_NODE_TYPE("COMMONTABLEEXPR");
1999 WRITE_STRING_FIELD(ctename);
2000 WRITE_NODE_FIELD(aliascolnames);
2001 WRITE_NODE_FIELD(ctequery);
2002 WRITE_LOCATION_FIELD(location);
2003 WRITE_BOOL_FIELD(cterecursive);
2004 WRITE_INT_FIELD(cterefcount);
2005 WRITE_NODE_FIELD(ctecolnames);
2006 WRITE_NODE_FIELD(ctecoltypes);
2007 WRITE_NODE_FIELD(ctecoltypmods);
2011 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2013 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2015 WRITE_ENUM_FIELD(op, SetOperation);
2016 WRITE_BOOL_FIELD(all);
2017 WRITE_NODE_FIELD(larg);
2018 WRITE_NODE_FIELD(rarg);
2019 WRITE_NODE_FIELD(colTypes);
2020 WRITE_NODE_FIELD(colTypmods);
2021 WRITE_NODE_FIELD(groupClauses);
2025 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2027 WRITE_NODE_TYPE("RTE");
2029 /* put alias + eref first to make dump more legible */
2030 WRITE_NODE_FIELD(alias);
2031 WRITE_NODE_FIELD(eref);
2032 WRITE_ENUM_FIELD(rtekind, RTEKind);
2034 switch (node->rtekind)
2038 WRITE_OID_FIELD(relid);
2041 WRITE_NODE_FIELD(subquery);
2044 WRITE_ENUM_FIELD(jointype, JoinType);
2045 WRITE_NODE_FIELD(joinaliasvars);
2048 WRITE_NODE_FIELD(funcexpr);
2049 WRITE_NODE_FIELD(funccoltypes);
2050 WRITE_NODE_FIELD(funccoltypmods);
2053 WRITE_NODE_FIELD(values_lists);
2056 WRITE_STRING_FIELD(ctename);
2057 WRITE_UINT_FIELD(ctelevelsup);
2058 WRITE_BOOL_FIELD(self_reference);
2059 WRITE_NODE_FIELD(ctecoltypes);
2060 WRITE_NODE_FIELD(ctecoltypmods);
2063 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2067 WRITE_BOOL_FIELD(inh);
2068 WRITE_BOOL_FIELD(inFromCl);
2069 WRITE_UINT_FIELD(requiredPerms);
2070 WRITE_OID_FIELD(checkAsUser);
2071 WRITE_BITMAPSET_FIELD(selectedCols);
2072 WRITE_BITMAPSET_FIELD(modifiedCols);
2076 _outAExpr(StringInfo str, A_Expr *node)
2078 WRITE_NODE_TYPE("AEXPR");
2083 appendStringInfo(str, " ");
2084 WRITE_NODE_FIELD(name);
2087 appendStringInfo(str, " AND");
2090 appendStringInfo(str, " OR");
2093 appendStringInfo(str, " NOT");
2096 appendStringInfo(str, " ");
2097 WRITE_NODE_FIELD(name);
2098 appendStringInfo(str, " ANY ");
2101 appendStringInfo(str, " ");
2102 WRITE_NODE_FIELD(name);
2103 appendStringInfo(str, " ALL ");
2105 case AEXPR_DISTINCT:
2106 appendStringInfo(str, " DISTINCT ");
2107 WRITE_NODE_FIELD(name);
2110 appendStringInfo(str, " NULLIF ");
2111 WRITE_NODE_FIELD(name);
2114 appendStringInfo(str, " OF ");
2115 WRITE_NODE_FIELD(name);
2118 appendStringInfo(str, " IN ");
2119 WRITE_NODE_FIELD(name);
2122 appendStringInfo(str, " ??");
2126 WRITE_NODE_FIELD(lexpr);
2127 WRITE_NODE_FIELD(rexpr);
2128 WRITE_LOCATION_FIELD(location);
2132 _outValue(StringInfo str, Value *value)
2134 switch (value->type)
2137 appendStringInfo(str, "%ld", value->val.ival);
2142 * We assume the value is a valid numeric literal and so does not
2145 appendStringInfoString(str, value->val.str);
2148 appendStringInfoChar(str, '"');
2149 _outToken(str, value->val.str);
2150 appendStringInfoChar(str, '"');
2153 /* internal representation already has leading 'b' */
2154 appendStringInfoString(str, value->val.str);
2157 /* this is seen only within A_Const, not in transformed trees */
2158 appendStringInfoString(str, "NULL");
2161 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2167 _outColumnRef(StringInfo str, ColumnRef *node)
2169 WRITE_NODE_TYPE("COLUMNREF");
2171 WRITE_NODE_FIELD(fields);
2172 WRITE_LOCATION_FIELD(location);
2176 _outParamRef(StringInfo str, ParamRef *node)
2178 WRITE_NODE_TYPE("PARAMREF");
2180 WRITE_INT_FIELD(number);
2181 WRITE_LOCATION_FIELD(location);
2185 _outAConst(StringInfo str, A_Const *node)
2187 WRITE_NODE_TYPE("A_CONST");
2189 appendStringInfo(str, " :val ");
2190 _outValue(str, &(node->val));
2191 WRITE_LOCATION_FIELD(location);
2195 _outA_Star(StringInfo str, A_Star *node)
2197 WRITE_NODE_TYPE("A_STAR");
2201 _outA_Indices(StringInfo str, A_Indices *node)
2203 WRITE_NODE_TYPE("A_INDICES");
2205 WRITE_NODE_FIELD(lidx);
2206 WRITE_NODE_FIELD(uidx);
2210 _outA_Indirection(StringInfo str, A_Indirection *node)
2212 WRITE_NODE_TYPE("A_INDIRECTION");
2214 WRITE_NODE_FIELD(arg);
2215 WRITE_NODE_FIELD(indirection);
2219 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2221 WRITE_NODE_TYPE("A_ARRAYEXPR");
2223 WRITE_NODE_FIELD(elements);
2224 WRITE_LOCATION_FIELD(location);
2228 _outResTarget(StringInfo str, ResTarget *node)
2230 WRITE_NODE_TYPE("RESTARGET");
2232 WRITE_STRING_FIELD(name);
2233 WRITE_NODE_FIELD(indirection);
2234 WRITE_NODE_FIELD(val);
2235 WRITE_LOCATION_FIELD(location);
2239 _outSortBy(StringInfo str, SortBy *node)
2241 WRITE_NODE_TYPE("SORTBY");
2243 WRITE_NODE_FIELD(node);
2244 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2245 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2246 WRITE_NODE_FIELD(useOp);
2247 WRITE_LOCATION_FIELD(location);
2251 _outWindowDef(StringInfo str, WindowDef *node)
2253 WRITE_NODE_TYPE("WINDOWDEF");
2255 WRITE_STRING_FIELD(name);
2256 WRITE_STRING_FIELD(refname);
2257 WRITE_NODE_FIELD(partitionClause);
2258 WRITE_NODE_FIELD(orderClause);
2259 WRITE_INT_FIELD(frameOptions);
2260 WRITE_LOCATION_FIELD(location);
2264 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2266 WRITE_NODE_TYPE("RANGESUBSELECT");
2268 WRITE_NODE_FIELD(subquery);
2269 WRITE_NODE_FIELD(alias);
2273 _outRangeFunction(StringInfo str, RangeFunction *node)
2275 WRITE_NODE_TYPE("RANGEFUNCTION");
2277 WRITE_NODE_FIELD(funccallnode);
2278 WRITE_NODE_FIELD(alias);
2279 WRITE_NODE_FIELD(coldeflist);
2283 _outConstraint(StringInfo str, Constraint *node)
2285 WRITE_NODE_TYPE("CONSTRAINT");
2287 WRITE_STRING_FIELD(name);
2289 appendStringInfo(str, " :contype ");
2290 switch (node->contype)
2292 case CONSTR_PRIMARY:
2293 appendStringInfo(str, "PRIMARY_KEY");
2294 WRITE_NODE_FIELD(keys);
2295 WRITE_NODE_FIELD(options);
2296 WRITE_STRING_FIELD(indexspace);
2300 appendStringInfo(str, "UNIQUE");
2301 WRITE_NODE_FIELD(keys);
2302 WRITE_NODE_FIELD(options);
2303 WRITE_STRING_FIELD(indexspace);
2307 appendStringInfo(str, "CHECK");
2308 WRITE_NODE_FIELD(raw_expr);
2309 WRITE_STRING_FIELD(cooked_expr);
2312 case CONSTR_DEFAULT:
2313 appendStringInfo(str, "DEFAULT");
2314 WRITE_NODE_FIELD(raw_expr);
2315 WRITE_STRING_FIELD(cooked_expr);
2318 case CONSTR_NOTNULL:
2319 appendStringInfo(str, "NOT_NULL");
2323 appendStringInfo(str, "<unrecognized_constraint>");
2329 _outFkConstraint(StringInfo str, FkConstraint *node)
2331 WRITE_NODE_TYPE("FKCONSTRAINT");
2333 WRITE_STRING_FIELD(constr_name);
2334 WRITE_NODE_FIELD(pktable);
2335 WRITE_NODE_FIELD(fk_attrs);
2336 WRITE_NODE_FIELD(pk_attrs);
2337 WRITE_CHAR_FIELD(fk_matchtype);
2338 WRITE_CHAR_FIELD(fk_upd_action);
2339 WRITE_CHAR_FIELD(fk_del_action);
2340 WRITE_BOOL_FIELD(deferrable);
2341 WRITE_BOOL_FIELD(initdeferred);
2342 WRITE_BOOL_FIELD(skip_validation);
2348 * converts a Node into ascii string and append it to 'str'
2351 _outNode(StringInfo str, void *obj)
2354 appendStringInfo(str, "<>");
2355 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2357 else if (IsA(obj, Integer) ||
2360 IsA(obj, BitString))
2362 /* nodeRead does not want to see { } around these! */
2363 _outValue(str, obj);
2367 appendStringInfoChar(str, '{');
2368 switch (nodeTag(obj))
2371 _outPlannedStmt(str, obj);
2377 _outResult(str, obj);
2380 _outAppend(str, obj);
2382 case T_RecursiveUnion:
2383 _outRecursiveUnion(str, obj);
2386 _outBitmapAnd(str, obj);
2389 _outBitmapOr(str, obj);
2395 _outSeqScan(str, obj);
2398 _outIndexScan(str, obj);
2400 case T_BitmapIndexScan:
2401 _outBitmapIndexScan(str, obj);
2403 case T_BitmapHeapScan:
2404 _outBitmapHeapScan(str, obj);
2407 _outTidScan(str, obj);
2409 case T_SubqueryScan:
2410 _outSubqueryScan(str, obj);
2412 case T_FunctionScan:
2413 _outFunctionScan(str, obj);
2416 _outValuesScan(str, obj);
2419 _outCteScan(str, obj);
2421 case T_WorkTableScan:
2422 _outWorkTableScan(str, obj);
2428 _outNestLoop(str, obj);
2431 _outMergeJoin(str, obj);
2434 _outHashJoin(str, obj);
2440 _outWindowAgg(str, obj);
2443 _outGroup(str, obj);
2446 _outMaterial(str, obj);
2452 _outUnique(str, obj);
2458 _outSetOp(str, obj);
2461 _outLimit(str, obj);
2463 case T_PlanInvalItem:
2464 _outPlanInvalItem(str, obj);
2467 _outAlias(str, obj);
2470 _outRangeVar(str, obj);
2473 _outIntoClause(str, obj);
2479 _outConst(str, obj);
2482 _outParam(str, obj);
2485 _outAggref(str, obj);
2488 _outWindowFunc(str, obj);
2491 _outArrayRef(str, obj);
2494 _outFuncExpr(str, obj);
2497 _outOpExpr(str, obj);
2499 case T_DistinctExpr:
2500 _outDistinctExpr(str, obj);
2502 case T_ScalarArrayOpExpr:
2503 _outScalarArrayOpExpr(str, obj);
2506 _outBoolExpr(str, obj);
2509 _outSubLink(str, obj);
2512 _outSubPlan(str, obj);
2514 case T_AlternativeSubPlan:
2515 _outAlternativeSubPlan(str, obj);
2518 _outFieldSelect(str, obj);
2521 _outFieldStore(str, obj);
2524 _outRelabelType(str, obj);
2527 _outCoerceViaIO(str, obj);
2529 case T_ArrayCoerceExpr:
2530 _outArrayCoerceExpr(str, obj);
2532 case T_ConvertRowtypeExpr:
2533 _outConvertRowtypeExpr(str, obj);
2536 _outCaseExpr(str, obj);
2539 _outCaseWhen(str, obj);
2541 case T_CaseTestExpr:
2542 _outCaseTestExpr(str, obj);
2545 _outArrayExpr(str, obj);
2548 _outRowExpr(str, obj);
2550 case T_RowCompareExpr:
2551 _outRowCompareExpr(str, obj);
2553 case T_CoalesceExpr:
2554 _outCoalesceExpr(str, obj);
2557 _outMinMaxExpr(str, obj);
2560 _outXmlExpr(str, obj);
2563 _outNullIfExpr(str, obj);
2566 _outNullTest(str, obj);
2569 _outBooleanTest(str, obj);
2571 case T_CoerceToDomain:
2572 _outCoerceToDomain(str, obj);
2574 case T_CoerceToDomainValue:
2575 _outCoerceToDomainValue(str, obj);
2577 case T_SetToDefault:
2578 _outSetToDefault(str, obj);
2580 case T_CurrentOfExpr:
2581 _outCurrentOfExpr(str, obj);
2584 _outTargetEntry(str, obj);
2587 _outRangeTblRef(str, obj);
2590 _outJoinExpr(str, obj);
2593 _outFromExpr(str, obj);
2600 _outIndexPath(str, obj);
2602 case T_BitmapHeapPath:
2603 _outBitmapHeapPath(str, obj);
2605 case T_BitmapAndPath:
2606 _outBitmapAndPath(str, obj);
2608 case T_BitmapOrPath:
2609 _outBitmapOrPath(str, obj);
2612 _outTidPath(str, obj);
2615 _outAppendPath(str, obj);
2618 _outResultPath(str, obj);
2620 case T_MaterialPath:
2621 _outMaterialPath(str, obj);
2624 _outUniquePath(str, obj);
2627 _outNestPath(str, obj);
2630 _outMergePath(str, obj);
2633 _outHashPath(str, obj);
2635 case T_PlannerGlobal:
2636 _outPlannerGlobal(str, obj);
2639 _outPlannerInfo(str, obj);
2642 _outRelOptInfo(str, obj);
2644 case T_IndexOptInfo:
2645 _outIndexOptInfo(str, obj);
2647 case T_EquivalenceClass:
2648 _outEquivalenceClass(str, obj);
2650 case T_EquivalenceMember:
2651 _outEquivalenceMember(str, obj);
2654 _outPathKey(str, obj);
2656 case T_RestrictInfo:
2657 _outRestrictInfo(str, obj);
2659 case T_InnerIndexscanInfo:
2660 _outInnerIndexscanInfo(str, obj);
2662 case T_FlattenedSubLink:
2663 _outFlattenedSubLink(str, obj);
2665 case T_PlaceHolderVar:
2666 _outPlaceHolderVar(str, obj);
2668 case T_SpecialJoinInfo:
2669 _outSpecialJoinInfo(str, obj);
2671 case T_AppendRelInfo:
2672 _outAppendRelInfo(str, obj);
2674 case T_PlaceHolderInfo:
2675 _outPlaceHolderInfo(str, obj);
2677 case T_PlannerParamItem:
2678 _outPlannerParamItem(str, obj);
2682 _outCreateStmt(str, obj);
2685 _outIndexStmt(str, obj);
2688 _outNotifyStmt(str, obj);
2690 case T_DeclareCursorStmt:
2691 _outDeclareCursorStmt(str, obj);
2694 _outSelectStmt(str, obj);
2697 _outColumnDef(str, obj);
2700 _outTypeName(str, obj);
2703 _outTypeCast(str, obj);
2706 _outIndexElem(str, obj);
2709 _outQuery(str, obj);
2711 case T_SortGroupClause:
2712 _outSortGroupClause(str, obj);
2714 case T_WindowClause:
2715 _outWindowClause(str, obj);
2717 case T_RowMarkClause:
2718 _outRowMarkClause(str, obj);
2721 _outWithClause(str, obj);
2723 case T_CommonTableExpr:
2724 _outCommonTableExpr(str, obj);
2726 case T_SetOperationStmt:
2727 _outSetOperationStmt(str, obj);
2729 case T_RangeTblEntry:
2730 _outRangeTblEntry(str, obj);
2733 _outAExpr(str, obj);
2736 _outColumnRef(str, obj);
2739 _outParamRef(str, obj);
2742 _outAConst(str, obj);
2745 _outA_Star(str, obj);
2748 _outA_Indices(str, obj);
2750 case T_A_Indirection:
2751 _outA_Indirection(str, obj);
2754 _outA_ArrayExpr(str, obj);
2757 _outResTarget(str, obj);
2760 _outSortBy(str, obj);
2763 _outWindowDef(str, obj);
2765 case T_RangeSubselect:
2766 _outRangeSubselect(str, obj);
2768 case T_RangeFunction:
2769 _outRangeFunction(str, obj);
2772 _outConstraint(str, obj);
2774 case T_FkConstraint:
2775 _outFkConstraint(str, obj);
2778 _outFuncCall(str, obj);
2781 _outDefElem(str, obj);
2784 _outReloptElem(str, obj);
2786 case T_LockingClause:
2787 _outLockingClause(str, obj);
2789 case T_XmlSerialize:
2790 _outXmlSerialize(str, obj);
2796 * This should be an ERROR, but it's too useful to be able to
2797 * dump structures that _outNode only understands part of.
2799 elog(WARNING, "could not dump unrecognized node type: %d",
2800 (int) nodeTag(obj));
2803 appendStringInfoChar(str, '}');
2809 * returns the ascii representation of the Node as a palloc'd string
2812 nodeToString(void *obj)
2816 /* see stringinfo.h for an explanation of this maneuver */
2817 initStringInfo(&str);
2818 _outNode(&str, obj);