1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2006, 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.274 2006/04/30 18:30:39 tgl Exp $
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/parsenodes.h"
28 #include "nodes/plannodes.h"
29 #include "nodes/relation.h"
30 #include "utils/datum.h"
34 * Macros to simplify output of different kinds of fields. Use these
35 * wherever possible to reduce the chance for silly typos. Note that these
36 * hard-wire conventions about the names of the local variables in an Out
40 /* Write the label for the node type */
41 #define WRITE_NODE_TYPE(nodelabel) \
42 appendStringInfoString(str, nodelabel)
44 /* Write an integer field (anything written as ":fldname %d") */
45 #define WRITE_INT_FIELD(fldname) \
46 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
48 /* Write an unsigned integer field (anything written as ":fldname %u") */
49 #define WRITE_UINT_FIELD(fldname) \
50 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
52 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
53 #define WRITE_OID_FIELD(fldname) \
54 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
56 /* Write a long-integer field */
57 #define WRITE_LONG_FIELD(fldname) \
58 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
60 /* Write a char field (ie, one ascii character) */
61 #define WRITE_CHAR_FIELD(fldname) \
62 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
64 /* Write an enumerated-type field as an integer code */
65 #define WRITE_ENUM_FIELD(fldname, enumtype) \
66 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
69 /* Write a float field --- caller must give format to define precision */
70 #define WRITE_FLOAT_FIELD(fldname,format) \
71 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
73 /* Write a boolean field */
74 #define WRITE_BOOL_FIELD(fldname) \
75 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
76 booltostr(node->fldname))
78 /* Write a character-string (possibly NULL) field */
79 #define WRITE_STRING_FIELD(fldname) \
80 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
81 _outToken(str, node->fldname))
83 /* Write a Node field */
84 #define WRITE_NODE_FIELD(fldname) \
85 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
86 _outNode(str, node->fldname))
88 /* Write a bitmapset field */
89 #define WRITE_BITMAPSET_FIELD(fldname) \
90 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
91 _outBitmapset(str, node->fldname))
94 #define booltostr(x) ((x) ? "true" : "false")
96 static void _outNode(StringInfo str, void *obj);
101 * Convert an ordinary string (eg, an identifier) into a form that
102 * will be decoded back to a plain token by read.c's functions.
104 * If a null or empty string is given, it is encoded as "<>".
107 _outToken(StringInfo str, char *s)
109 if (s == NULL || *s == '\0')
111 appendStringInfo(str, "<>");
116 * Look for characters or patterns that are treated specially by read.c
117 * (either in pg_strtok() or in nodeRead()), and therefore need a
118 * protective backslash.
120 /* These characters only need to be quoted at the start of the string */
123 isdigit((unsigned char) *s) ||
124 ((*s == '+' || *s == '-') &&
125 (isdigit((unsigned char) s[1]) || s[1] == '.')))
126 appendStringInfoChar(str, '\\');
129 /* These chars must be backslashed anywhere in the string */
130 if (*s == ' ' || *s == '\n' || *s == '\t' ||
131 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
133 appendStringInfoChar(str, '\\');
134 appendStringInfoChar(str, *s++);
139 _outList(StringInfo str, List *node)
143 appendStringInfoChar(str, '(');
145 if (IsA(node, IntList))
146 appendStringInfoChar(str, 'i');
147 else if (IsA(node, OidList))
148 appendStringInfoChar(str, 'o');
153 * For the sake of backward compatibility, we emit a slightly
154 * different whitespace format for lists of nodes vs. other types of
155 * lists. XXX: is this necessary?
159 _outNode(str, lfirst(lc));
161 appendStringInfoChar(str, ' ');
163 else if (IsA(node, IntList))
164 appendStringInfo(str, " %d", lfirst_int(lc));
165 else if (IsA(node, OidList))
166 appendStringInfo(str, " %u", lfirst_oid(lc));
168 elog(ERROR, "unrecognized list node type: %d",
172 appendStringInfoChar(str, ')');
177 * converts a bitmap set of integers
179 * Note: the output format is "(b int int ...)", similar to an integer List.
180 * Currently bitmapsets do not appear in any node type that is stored in
181 * rules, so there is no support in readfuncs.c for reading this format.
184 _outBitmapset(StringInfo str, Bitmapset *bms)
189 appendStringInfoChar(str, '(');
190 appendStringInfoChar(str, 'b');
191 tmpset = bms_copy(bms);
192 while ((x = bms_first_member(tmpset)) >= 0)
193 appendStringInfo(str, " %d", x);
195 appendStringInfoChar(str, ')');
199 * Print the value of a Datum given its type.
202 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
208 length = datumGetSize(value, typbyval, typlen);
212 s = (char *) (&value);
213 appendStringInfo(str, "%u [ ", (unsigned int) length);
214 for (i = 0; i < (Size) sizeof(Datum); i++)
215 appendStringInfo(str, "%d ", (int) (s[i]));
216 appendStringInfo(str, "]");
220 s = (char *) DatumGetPointer(value);
221 if (!PointerIsValid(s))
222 appendStringInfo(str, "0 [ ]");
225 appendStringInfo(str, "%u [ ", (unsigned int) length);
226 for (i = 0; i < length; i++)
227 appendStringInfo(str, "%d ", (int) (s[i]));
228 appendStringInfo(str, "]");
235 * Stuff from plannodes.h
239 * print the basic stuff of all nodes that inherit from Plan
242 _outPlanInfo(StringInfo str, Plan *node)
244 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
245 WRITE_FLOAT_FIELD(total_cost, "%.2f");
246 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
247 WRITE_INT_FIELD(plan_width);
248 WRITE_NODE_FIELD(targetlist);
249 WRITE_NODE_FIELD(qual);
250 WRITE_NODE_FIELD(lefttree);
251 WRITE_NODE_FIELD(righttree);
252 WRITE_NODE_FIELD(initPlan);
253 WRITE_BITMAPSET_FIELD(extParam);
254 WRITE_BITMAPSET_FIELD(allParam);
255 WRITE_INT_FIELD(nParamExec);
259 * print the basic stuff of all nodes that inherit from Scan
262 _outScanInfo(StringInfo str, Scan *node)
264 _outPlanInfo(str, (Plan *) node);
266 WRITE_UINT_FIELD(scanrelid);
270 * print the basic stuff of all nodes that inherit from Join
273 _outJoinPlanInfo(StringInfo str, Join *node)
275 _outPlanInfo(str, (Plan *) node);
277 WRITE_ENUM_FIELD(jointype, JoinType);
278 WRITE_NODE_FIELD(joinqual);
283 _outPlan(StringInfo str, Plan *node)
285 WRITE_NODE_TYPE("PLAN");
287 _outPlanInfo(str, (Plan *) node);
291 _outResult(StringInfo str, Result *node)
293 WRITE_NODE_TYPE("RESULT");
295 _outPlanInfo(str, (Plan *) node);
297 WRITE_NODE_FIELD(resconstantqual);
301 _outAppend(StringInfo str, Append *node)
303 WRITE_NODE_TYPE("APPEND");
305 _outPlanInfo(str, (Plan *) node);
307 WRITE_NODE_FIELD(appendplans);
308 WRITE_BOOL_FIELD(isTarget);
312 _outBitmapAnd(StringInfo str, BitmapAnd *node)
314 WRITE_NODE_TYPE("BITMAPAND");
316 _outPlanInfo(str, (Plan *) node);
318 WRITE_NODE_FIELD(bitmapplans);
322 _outBitmapOr(StringInfo str, BitmapOr *node)
324 WRITE_NODE_TYPE("BITMAPOR");
326 _outPlanInfo(str, (Plan *) node);
328 WRITE_NODE_FIELD(bitmapplans);
332 _outScan(StringInfo str, Scan *node)
334 WRITE_NODE_TYPE("SCAN");
336 _outScanInfo(str, (Scan *) node);
340 _outSeqScan(StringInfo str, SeqScan *node)
342 WRITE_NODE_TYPE("SEQSCAN");
344 _outScanInfo(str, (Scan *) node);
348 _outIndexScan(StringInfo str, IndexScan *node)
350 WRITE_NODE_TYPE("INDEXSCAN");
352 _outScanInfo(str, (Scan *) node);
354 WRITE_OID_FIELD(indexid);
355 WRITE_NODE_FIELD(indexqual);
356 WRITE_NODE_FIELD(indexqualorig);
357 WRITE_NODE_FIELD(indexstrategy);
358 WRITE_NODE_FIELD(indexsubtype);
359 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
363 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
365 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
367 _outScanInfo(str, (Scan *) node);
369 WRITE_OID_FIELD(indexid);
370 WRITE_NODE_FIELD(indexqual);
371 WRITE_NODE_FIELD(indexqualorig);
372 WRITE_NODE_FIELD(indexstrategy);
373 WRITE_NODE_FIELD(indexsubtype);
377 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
379 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
381 _outScanInfo(str, (Scan *) node);
383 WRITE_NODE_FIELD(bitmapqualorig);
387 _outTidScan(StringInfo str, TidScan *node)
389 WRITE_NODE_TYPE("TIDSCAN");
391 _outScanInfo(str, (Scan *) node);
393 WRITE_NODE_FIELD(tidquals);
397 _outSubqueryScan(StringInfo str, SubqueryScan *node)
399 WRITE_NODE_TYPE("SUBQUERYSCAN");
401 _outScanInfo(str, (Scan *) node);
403 WRITE_NODE_FIELD(subplan);
407 _outFunctionScan(StringInfo str, FunctionScan *node)
409 WRITE_NODE_TYPE("FUNCTIONSCAN");
411 _outScanInfo(str, (Scan *) node);
415 _outJoin(StringInfo str, Join *node)
417 WRITE_NODE_TYPE("JOIN");
419 _outJoinPlanInfo(str, (Join *) node);
423 _outNestLoop(StringInfo str, NestLoop *node)
425 WRITE_NODE_TYPE("NESTLOOP");
427 _outJoinPlanInfo(str, (Join *) node);
431 _outMergeJoin(StringInfo str, MergeJoin *node)
433 WRITE_NODE_TYPE("MERGEJOIN");
435 _outJoinPlanInfo(str, (Join *) node);
437 WRITE_NODE_FIELD(mergeclauses);
441 _outHashJoin(StringInfo str, HashJoin *node)
443 WRITE_NODE_TYPE("HASHJOIN");
445 _outJoinPlanInfo(str, (Join *) node);
447 WRITE_NODE_FIELD(hashclauses);
451 _outAgg(StringInfo str, Agg *node)
453 WRITE_NODE_TYPE("AGG");
455 _outPlanInfo(str, (Plan *) node);
457 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
458 WRITE_INT_FIELD(numCols);
459 WRITE_LONG_FIELD(numGroups);
463 _outGroup(StringInfo str, Group *node)
467 WRITE_NODE_TYPE("GROUP");
469 _outPlanInfo(str, (Plan *) node);
471 WRITE_INT_FIELD(numCols);
473 appendStringInfo(str, " :grpColIdx");
474 for (i = 0; i < node->numCols; i++)
475 appendStringInfo(str, " %d", node->grpColIdx[i]);
479 _outMaterial(StringInfo str, Material *node)
481 WRITE_NODE_TYPE("MATERIAL");
483 _outPlanInfo(str, (Plan *) node);
487 _outSort(StringInfo str, Sort *node)
491 WRITE_NODE_TYPE("SORT");
493 _outPlanInfo(str, (Plan *) node);
495 WRITE_INT_FIELD(numCols);
497 appendStringInfo(str, " :sortColIdx");
498 for (i = 0; i < node->numCols; i++)
499 appendStringInfo(str, " %d", node->sortColIdx[i]);
501 appendStringInfo(str, " :sortOperators");
502 for (i = 0; i < node->numCols; i++)
503 appendStringInfo(str, " %u", node->sortOperators[i]);
507 _outUnique(StringInfo str, Unique *node)
511 WRITE_NODE_TYPE("UNIQUE");
513 _outPlanInfo(str, (Plan *) node);
515 WRITE_INT_FIELD(numCols);
517 appendStringInfo(str, " :uniqColIdx");
518 for (i = 0; i < node->numCols; i++)
519 appendStringInfo(str, " %d", node->uniqColIdx[i]);
523 _outSetOp(StringInfo str, SetOp *node)
527 WRITE_NODE_TYPE("SETOP");
529 _outPlanInfo(str, (Plan *) node);
531 WRITE_ENUM_FIELD(cmd, SetOpCmd);
532 WRITE_INT_FIELD(numCols);
534 appendStringInfo(str, " :dupColIdx");
535 for (i = 0; i < node->numCols; i++)
536 appendStringInfo(str, " %d", node->dupColIdx[i]);
538 WRITE_INT_FIELD(flagColIdx);
542 _outLimit(StringInfo str, Limit *node)
544 WRITE_NODE_TYPE("LIMIT");
546 _outPlanInfo(str, (Plan *) node);
548 WRITE_NODE_FIELD(limitOffset);
549 WRITE_NODE_FIELD(limitCount);
553 _outHash(StringInfo str, Hash *node)
555 WRITE_NODE_TYPE("HASH");
557 _outPlanInfo(str, (Plan *) node);
560 /*****************************************************************************
562 * Stuff from primnodes.h.
564 *****************************************************************************/
567 _outAlias(StringInfo str, Alias *node)
569 WRITE_NODE_TYPE("ALIAS");
571 WRITE_STRING_FIELD(aliasname);
572 WRITE_NODE_FIELD(colnames);
576 _outRangeVar(StringInfo str, RangeVar *node)
578 WRITE_NODE_TYPE("RANGEVAR");
581 * we deliberately ignore catalogname here, since it is presently not
582 * semantically meaningful
584 WRITE_STRING_FIELD(schemaname);
585 WRITE_STRING_FIELD(relname);
586 WRITE_ENUM_FIELD(inhOpt, InhOption);
587 WRITE_BOOL_FIELD(istemp);
588 WRITE_NODE_FIELD(alias);
592 _outVar(StringInfo str, Var *node)
594 WRITE_NODE_TYPE("VAR");
596 WRITE_UINT_FIELD(varno);
597 WRITE_INT_FIELD(varattno);
598 WRITE_OID_FIELD(vartype);
599 WRITE_INT_FIELD(vartypmod);
600 WRITE_UINT_FIELD(varlevelsup);
601 WRITE_UINT_FIELD(varnoold);
602 WRITE_INT_FIELD(varoattno);
606 _outConst(StringInfo str, Const *node)
608 WRITE_NODE_TYPE("CONST");
610 WRITE_OID_FIELD(consttype);
611 WRITE_INT_FIELD(constlen);
612 WRITE_BOOL_FIELD(constbyval);
613 WRITE_BOOL_FIELD(constisnull);
615 appendStringInfo(str, " :constvalue ");
616 if (node->constisnull)
617 appendStringInfo(str, "<>");
619 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
623 _outParam(StringInfo str, Param *node)
625 WRITE_NODE_TYPE("PARAM");
627 WRITE_ENUM_FIELD(paramkind, ParamKind);
628 WRITE_INT_FIELD(paramid);
629 WRITE_OID_FIELD(paramtype);
633 _outAggref(StringInfo str, Aggref *node)
635 WRITE_NODE_TYPE("AGGREF");
637 WRITE_OID_FIELD(aggfnoid);
638 WRITE_OID_FIELD(aggtype);
639 WRITE_NODE_FIELD(target);
640 WRITE_UINT_FIELD(agglevelsup);
641 WRITE_BOOL_FIELD(aggstar);
642 WRITE_BOOL_FIELD(aggdistinct);
646 _outArrayRef(StringInfo str, ArrayRef *node)
648 WRITE_NODE_TYPE("ARRAYREF");
650 WRITE_OID_FIELD(refrestype);
651 WRITE_OID_FIELD(refarraytype);
652 WRITE_OID_FIELD(refelemtype);
653 WRITE_NODE_FIELD(refupperindexpr);
654 WRITE_NODE_FIELD(reflowerindexpr);
655 WRITE_NODE_FIELD(refexpr);
656 WRITE_NODE_FIELD(refassgnexpr);
660 _outFuncExpr(StringInfo str, FuncExpr *node)
662 WRITE_NODE_TYPE("FUNCEXPR");
664 WRITE_OID_FIELD(funcid);
665 WRITE_OID_FIELD(funcresulttype);
666 WRITE_BOOL_FIELD(funcretset);
667 WRITE_ENUM_FIELD(funcformat, CoercionForm);
668 WRITE_NODE_FIELD(args);
672 _outOpExpr(StringInfo str, OpExpr *node)
674 WRITE_NODE_TYPE("OPEXPR");
676 WRITE_OID_FIELD(opno);
677 WRITE_OID_FIELD(opfuncid);
678 WRITE_OID_FIELD(opresulttype);
679 WRITE_BOOL_FIELD(opretset);
680 WRITE_NODE_FIELD(args);
684 _outDistinctExpr(StringInfo str, DistinctExpr *node)
686 WRITE_NODE_TYPE("DISTINCTEXPR");
688 WRITE_OID_FIELD(opno);
689 WRITE_OID_FIELD(opfuncid);
690 WRITE_OID_FIELD(opresulttype);
691 WRITE_BOOL_FIELD(opretset);
692 WRITE_NODE_FIELD(args);
696 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
698 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
700 WRITE_OID_FIELD(opno);
701 WRITE_OID_FIELD(opfuncid);
702 WRITE_BOOL_FIELD(useOr);
703 WRITE_NODE_FIELD(args);
707 _outBoolExpr(StringInfo str, BoolExpr *node)
711 WRITE_NODE_TYPE("BOOLEXPR");
713 /* do-it-yourself enum representation */
714 switch (node->boolop)
726 appendStringInfo(str, " :boolop ");
727 _outToken(str, opstr);
729 WRITE_NODE_FIELD(args);
733 _outSubLink(StringInfo str, SubLink *node)
735 WRITE_NODE_TYPE("SUBLINK");
737 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
738 WRITE_NODE_FIELD(testexpr);
739 WRITE_NODE_FIELD(operName);
740 WRITE_NODE_FIELD(subselect);
744 _outSubPlan(StringInfo str, SubPlan *node)
746 WRITE_NODE_TYPE("SUBPLAN");
748 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
749 WRITE_NODE_FIELD(testexpr);
750 WRITE_NODE_FIELD(paramIds);
751 WRITE_NODE_FIELD(plan);
752 WRITE_INT_FIELD(plan_id);
753 WRITE_NODE_FIELD(rtable);
754 WRITE_BOOL_FIELD(useHashTable);
755 WRITE_BOOL_FIELD(unknownEqFalse);
756 WRITE_NODE_FIELD(setParam);
757 WRITE_NODE_FIELD(parParam);
758 WRITE_NODE_FIELD(args);
762 _outFieldSelect(StringInfo str, FieldSelect *node)
764 WRITE_NODE_TYPE("FIELDSELECT");
766 WRITE_NODE_FIELD(arg);
767 WRITE_INT_FIELD(fieldnum);
768 WRITE_OID_FIELD(resulttype);
769 WRITE_INT_FIELD(resulttypmod);
773 _outFieldStore(StringInfo str, FieldStore *node)
775 WRITE_NODE_TYPE("FIELDSTORE");
777 WRITE_NODE_FIELD(arg);
778 WRITE_NODE_FIELD(newvals);
779 WRITE_NODE_FIELD(fieldnums);
780 WRITE_OID_FIELD(resulttype);
784 _outRelabelType(StringInfo str, RelabelType *node)
786 WRITE_NODE_TYPE("RELABELTYPE");
788 WRITE_NODE_FIELD(arg);
789 WRITE_OID_FIELD(resulttype);
790 WRITE_INT_FIELD(resulttypmod);
791 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
795 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
797 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
799 WRITE_NODE_FIELD(arg);
800 WRITE_OID_FIELD(resulttype);
801 WRITE_ENUM_FIELD(convertformat, CoercionForm);
805 _outCaseExpr(StringInfo str, CaseExpr *node)
807 WRITE_NODE_TYPE("CASE");
809 WRITE_OID_FIELD(casetype);
810 WRITE_NODE_FIELD(arg);
811 WRITE_NODE_FIELD(args);
812 WRITE_NODE_FIELD(defresult);
816 _outCaseWhen(StringInfo str, CaseWhen *node)
818 WRITE_NODE_TYPE("WHEN");
820 WRITE_NODE_FIELD(expr);
821 WRITE_NODE_FIELD(result);
825 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
827 WRITE_NODE_TYPE("CASETESTEXPR");
829 WRITE_OID_FIELD(typeId);
830 WRITE_INT_FIELD(typeMod);
834 _outArrayExpr(StringInfo str, ArrayExpr *node)
836 WRITE_NODE_TYPE("ARRAY");
838 WRITE_OID_FIELD(array_typeid);
839 WRITE_OID_FIELD(element_typeid);
840 WRITE_NODE_FIELD(elements);
841 WRITE_BOOL_FIELD(multidims);
845 _outRowExpr(StringInfo str, RowExpr *node)
847 WRITE_NODE_TYPE("ROW");
849 WRITE_NODE_FIELD(args);
850 WRITE_OID_FIELD(row_typeid);
851 WRITE_ENUM_FIELD(row_format, CoercionForm);
855 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
857 WRITE_NODE_TYPE("ROWCOMPARE");
859 WRITE_ENUM_FIELD(rctype, RowCompareType);
860 WRITE_NODE_FIELD(opnos);
861 WRITE_NODE_FIELD(opclasses);
862 WRITE_NODE_FIELD(largs);
863 WRITE_NODE_FIELD(rargs);
867 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
869 WRITE_NODE_TYPE("COALESCE");
871 WRITE_OID_FIELD(coalescetype);
872 WRITE_NODE_FIELD(args);
876 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
878 WRITE_NODE_TYPE("MINMAX");
880 WRITE_OID_FIELD(minmaxtype);
881 WRITE_ENUM_FIELD(op, MinMaxOp);
882 WRITE_NODE_FIELD(args);
886 _outNullIfExpr(StringInfo str, NullIfExpr *node)
888 WRITE_NODE_TYPE("NULLIFEXPR");
890 WRITE_OID_FIELD(opno);
891 WRITE_OID_FIELD(opfuncid);
892 WRITE_OID_FIELD(opresulttype);
893 WRITE_BOOL_FIELD(opretset);
894 WRITE_NODE_FIELD(args);
898 _outNullTest(StringInfo str, NullTest *node)
900 WRITE_NODE_TYPE("NULLTEST");
902 WRITE_NODE_FIELD(arg);
903 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
907 _outBooleanTest(StringInfo str, BooleanTest *node)
909 WRITE_NODE_TYPE("BOOLEANTEST");
911 WRITE_NODE_FIELD(arg);
912 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
916 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
918 WRITE_NODE_TYPE("COERCETODOMAIN");
920 WRITE_NODE_FIELD(arg);
921 WRITE_OID_FIELD(resulttype);
922 WRITE_INT_FIELD(resulttypmod);
923 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
927 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
929 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
931 WRITE_OID_FIELD(typeId);
932 WRITE_INT_FIELD(typeMod);
936 _outSetToDefault(StringInfo str, SetToDefault *node)
938 WRITE_NODE_TYPE("SETTODEFAULT");
940 WRITE_OID_FIELD(typeId);
941 WRITE_INT_FIELD(typeMod);
945 _outTargetEntry(StringInfo str, TargetEntry *node)
947 WRITE_NODE_TYPE("TARGETENTRY");
949 WRITE_NODE_FIELD(expr);
950 WRITE_INT_FIELD(resno);
951 WRITE_STRING_FIELD(resname);
952 WRITE_UINT_FIELD(ressortgroupref);
953 WRITE_OID_FIELD(resorigtbl);
954 WRITE_INT_FIELD(resorigcol);
955 WRITE_BOOL_FIELD(resjunk);
959 _outRangeTblRef(StringInfo str, RangeTblRef *node)
961 WRITE_NODE_TYPE("RANGETBLREF");
963 WRITE_INT_FIELD(rtindex);
967 _outJoinExpr(StringInfo str, JoinExpr *node)
969 WRITE_NODE_TYPE("JOINEXPR");
971 WRITE_ENUM_FIELD(jointype, JoinType);
972 WRITE_BOOL_FIELD(isNatural);
973 WRITE_NODE_FIELD(larg);
974 WRITE_NODE_FIELD(rarg);
975 WRITE_NODE_FIELD(using);
976 WRITE_NODE_FIELD(quals);
977 WRITE_NODE_FIELD(alias);
978 WRITE_INT_FIELD(rtindex);
982 _outFromExpr(StringInfo str, FromExpr *node)
984 WRITE_NODE_TYPE("FROMEXPR");
986 WRITE_NODE_FIELD(fromlist);
987 WRITE_NODE_FIELD(quals);
990 /*****************************************************************************
992 * Stuff from relation.h.
994 *****************************************************************************/
997 * print the basic stuff of all nodes that inherit from Path
999 * Note we do NOT print the parent, else we'd be in infinite recursion
1002 _outPathInfo(StringInfo str, Path *node)
1004 WRITE_ENUM_FIELD(pathtype, NodeTag);
1005 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1006 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1007 WRITE_NODE_FIELD(pathkeys);
1011 * print the basic stuff of all nodes that inherit from JoinPath
1014 _outJoinPathInfo(StringInfo str, JoinPath *node)
1016 _outPathInfo(str, (Path *) node);
1018 WRITE_ENUM_FIELD(jointype, JoinType);
1019 WRITE_NODE_FIELD(outerjoinpath);
1020 WRITE_NODE_FIELD(innerjoinpath);
1021 WRITE_NODE_FIELD(joinrestrictinfo);
1025 _outPath(StringInfo str, Path *node)
1027 WRITE_NODE_TYPE("PATH");
1029 _outPathInfo(str, (Path *) node);
1033 _outIndexPath(StringInfo str, IndexPath *node)
1035 WRITE_NODE_TYPE("INDEXPATH");
1037 _outPathInfo(str, (Path *) node);
1039 WRITE_NODE_FIELD(indexinfo);
1040 WRITE_NODE_FIELD(indexclauses);
1041 WRITE_NODE_FIELD(indexquals);
1042 WRITE_BOOL_FIELD(isjoininner);
1043 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1044 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1045 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1046 WRITE_FLOAT_FIELD(rows, "%.0f");
1050 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1052 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1054 _outPathInfo(str, (Path *) node);
1056 WRITE_NODE_FIELD(bitmapqual);
1057 WRITE_BOOL_FIELD(isjoininner);
1058 WRITE_FLOAT_FIELD(rows, "%.0f");
1062 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1064 WRITE_NODE_TYPE("BITMAPANDPATH");
1066 _outPathInfo(str, (Path *) node);
1068 WRITE_NODE_FIELD(bitmapquals);
1069 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1073 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1075 WRITE_NODE_TYPE("BITMAPORPATH");
1077 _outPathInfo(str, (Path *) node);
1079 WRITE_NODE_FIELD(bitmapquals);
1080 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1084 _outTidPath(StringInfo str, TidPath *node)
1086 WRITE_NODE_TYPE("TIDPATH");
1088 _outPathInfo(str, (Path *) node);
1090 WRITE_NODE_FIELD(tidquals);
1094 _outAppendPath(StringInfo str, AppendPath *node)
1096 WRITE_NODE_TYPE("APPENDPATH");
1098 _outPathInfo(str, (Path *) node);
1100 WRITE_NODE_FIELD(subpaths);
1104 _outResultPath(StringInfo str, ResultPath *node)
1106 WRITE_NODE_TYPE("RESULTPATH");
1108 _outPathInfo(str, (Path *) node);
1110 WRITE_NODE_FIELD(subpath);
1111 WRITE_NODE_FIELD(constantqual);
1115 _outMaterialPath(StringInfo str, MaterialPath *node)
1117 WRITE_NODE_TYPE("MATERIALPATH");
1119 _outPathInfo(str, (Path *) node);
1121 WRITE_NODE_FIELD(subpath);
1125 _outUniquePath(StringInfo str, UniquePath *node)
1127 WRITE_NODE_TYPE("UNIQUEPATH");
1129 _outPathInfo(str, (Path *) node);
1131 WRITE_NODE_FIELD(subpath);
1132 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1133 WRITE_FLOAT_FIELD(rows, "%.0f");
1137 _outNestPath(StringInfo str, NestPath *node)
1139 WRITE_NODE_TYPE("NESTPATH");
1141 _outJoinPathInfo(str, (JoinPath *) node);
1145 _outMergePath(StringInfo str, MergePath *node)
1147 WRITE_NODE_TYPE("MERGEPATH");
1149 _outJoinPathInfo(str, (JoinPath *) node);
1151 WRITE_NODE_FIELD(path_mergeclauses);
1152 WRITE_NODE_FIELD(outersortkeys);
1153 WRITE_NODE_FIELD(innersortkeys);
1157 _outHashPath(StringInfo str, HashPath *node)
1159 WRITE_NODE_TYPE("HASHPATH");
1161 _outJoinPathInfo(str, (JoinPath *) node);
1163 WRITE_NODE_FIELD(path_hashclauses);
1167 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1169 WRITE_NODE_TYPE("PLANNERINFO");
1171 /* NB: this isn't a complete set of fields */
1172 WRITE_NODE_FIELD(parse);
1173 WRITE_NODE_FIELD(join_rel_list);
1174 WRITE_NODE_FIELD(equi_key_list);
1175 WRITE_NODE_FIELD(left_join_clauses);
1176 WRITE_NODE_FIELD(right_join_clauses);
1177 WRITE_NODE_FIELD(full_join_clauses);
1178 WRITE_NODE_FIELD(oj_info_list);
1179 WRITE_NODE_FIELD(in_info_list);
1180 WRITE_NODE_FIELD(append_rel_list);
1181 WRITE_NODE_FIELD(query_pathkeys);
1182 WRITE_NODE_FIELD(group_pathkeys);
1183 WRITE_NODE_FIELD(sort_pathkeys);
1184 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1185 WRITE_BOOL_FIELD(hasJoinRTEs);
1186 WRITE_BOOL_FIELD(hasOuterJoins);
1187 WRITE_BOOL_FIELD(hasHavingQual);
1191 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1193 WRITE_NODE_TYPE("RELOPTINFO");
1195 /* NB: this isn't a complete set of fields */
1196 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1197 WRITE_BITMAPSET_FIELD(relids);
1198 WRITE_FLOAT_FIELD(rows, "%.0f");
1199 WRITE_INT_FIELD(width);
1200 WRITE_NODE_FIELD(reltargetlist);
1201 WRITE_NODE_FIELD(pathlist);
1202 WRITE_NODE_FIELD(cheapest_startup_path);
1203 WRITE_NODE_FIELD(cheapest_total_path);
1204 WRITE_NODE_FIELD(cheapest_unique_path);
1205 WRITE_UINT_FIELD(relid);
1206 WRITE_ENUM_FIELD(rtekind, RTEKind);
1207 WRITE_INT_FIELD(min_attr);
1208 WRITE_INT_FIELD(max_attr);
1209 WRITE_NODE_FIELD(indexlist);
1210 WRITE_UINT_FIELD(pages);
1211 WRITE_FLOAT_FIELD(tuples, "%.0f");
1212 WRITE_NODE_FIELD(subplan);
1213 WRITE_NODE_FIELD(baserestrictinfo);
1214 WRITE_NODE_FIELD(joininfo);
1215 WRITE_BITMAPSET_FIELD(index_outer_relids);
1216 WRITE_NODE_FIELD(index_inner_paths);
1220 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1222 WRITE_NODE_TYPE("INDEXOPTINFO");
1224 /* NB: this isn't a complete set of fields */
1225 WRITE_OID_FIELD(indexoid);
1226 /* Do NOT print rel field, else infinite recursion */
1227 WRITE_UINT_FIELD(pages);
1228 WRITE_FLOAT_FIELD(tuples, "%.0f");
1229 WRITE_INT_FIELD(ncolumns);
1230 WRITE_NODE_FIELD(indexprs);
1231 WRITE_NODE_FIELD(indpred);
1232 WRITE_BOOL_FIELD(predOK);
1233 WRITE_BOOL_FIELD(unique);
1237 _outPathKeyItem(StringInfo str, PathKeyItem *node)
1239 WRITE_NODE_TYPE("PATHKEYITEM");
1241 WRITE_NODE_FIELD(key);
1242 WRITE_OID_FIELD(sortop);
1246 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1248 WRITE_NODE_TYPE("RESTRICTINFO");
1250 /* NB: this isn't a complete set of fields */
1251 WRITE_NODE_FIELD(clause);
1252 WRITE_BOOL_FIELD(is_pushed_down);
1253 WRITE_BOOL_FIELD(outerjoin_delayed);
1254 WRITE_BOOL_FIELD(can_join);
1255 WRITE_BITMAPSET_FIELD(clause_relids);
1256 WRITE_BITMAPSET_FIELD(required_relids);
1257 WRITE_BITMAPSET_FIELD(left_relids);
1258 WRITE_BITMAPSET_FIELD(right_relids);
1259 WRITE_NODE_FIELD(orclause);
1260 WRITE_OID_FIELD(mergejoinoperator);
1261 WRITE_OID_FIELD(left_sortop);
1262 WRITE_OID_FIELD(right_sortop);
1263 WRITE_NODE_FIELD(left_pathkey);
1264 WRITE_NODE_FIELD(right_pathkey);
1265 WRITE_OID_FIELD(hashjoinoperator);
1269 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1271 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1272 WRITE_BITMAPSET_FIELD(other_relids);
1273 WRITE_BOOL_FIELD(isouterjoin);
1274 WRITE_NODE_FIELD(best_innerpath);
1278 _outOuterJoinInfo(StringInfo str, OuterJoinInfo *node)
1280 WRITE_NODE_TYPE("OUTERJOININFO");
1282 WRITE_BITMAPSET_FIELD(min_lefthand);
1283 WRITE_BITMAPSET_FIELD(min_righthand);
1284 WRITE_BOOL_FIELD(is_full_join);
1285 WRITE_BOOL_FIELD(lhs_strict);
1289 _outInClauseInfo(StringInfo str, InClauseInfo *node)
1291 WRITE_NODE_TYPE("INCLAUSEINFO");
1293 WRITE_BITMAPSET_FIELD(lefthand);
1294 WRITE_BITMAPSET_FIELD(righthand);
1295 WRITE_NODE_FIELD(sub_targetlist);
1299 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1301 WRITE_NODE_TYPE("APPENDRELINFO");
1303 WRITE_UINT_FIELD(parent_relid);
1304 WRITE_UINT_FIELD(child_relid);
1305 WRITE_OID_FIELD(parent_reltype);
1306 WRITE_OID_FIELD(child_reltype);
1307 WRITE_NODE_FIELD(col_mappings);
1308 WRITE_NODE_FIELD(translated_vars);
1309 WRITE_OID_FIELD(parent_reloid);
1312 /*****************************************************************************
1314 * Stuff from parsenodes.h.
1316 *****************************************************************************/
1319 _outCreateStmt(StringInfo str, CreateStmt *node)
1321 WRITE_NODE_TYPE("CREATESTMT");
1323 WRITE_NODE_FIELD(relation);
1324 WRITE_NODE_FIELD(tableElts);
1325 WRITE_NODE_FIELD(inhRelations);
1326 WRITE_NODE_FIELD(constraints);
1327 WRITE_ENUM_FIELD(hasoids, ContainsOids);
1328 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1329 WRITE_STRING_FIELD(tablespacename);
1333 _outIndexStmt(StringInfo str, IndexStmt *node)
1335 WRITE_NODE_TYPE("INDEXSTMT");
1337 WRITE_STRING_FIELD(idxname);
1338 WRITE_NODE_FIELD(relation);
1339 WRITE_STRING_FIELD(accessMethod);
1340 WRITE_STRING_FIELD(tableSpace);
1341 WRITE_NODE_FIELD(indexParams);
1342 WRITE_NODE_FIELD(whereClause);
1343 WRITE_NODE_FIELD(rangetable);
1344 WRITE_BOOL_FIELD(unique);
1345 WRITE_BOOL_FIELD(primary);
1346 WRITE_BOOL_FIELD(isconstraint);
1350 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1352 WRITE_NODE_TYPE("NOTIFY");
1354 WRITE_NODE_FIELD(relation);
1358 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1360 WRITE_NODE_TYPE("DECLARECURSOR");
1362 WRITE_STRING_FIELD(portalname);
1363 WRITE_INT_FIELD(options);
1364 WRITE_NODE_FIELD(query);
1368 _outSelectStmt(StringInfo str, SelectStmt *node)
1370 WRITE_NODE_TYPE("SELECT");
1372 WRITE_NODE_FIELD(distinctClause);
1373 WRITE_NODE_FIELD(into);
1374 WRITE_NODE_FIELD(intoColNames);
1375 WRITE_ENUM_FIELD(intoHasOids, ContainsOids);
1376 WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
1377 WRITE_STRING_FIELD(intoTableSpaceName);
1378 WRITE_NODE_FIELD(targetList);
1379 WRITE_NODE_FIELD(fromClause);
1380 WRITE_NODE_FIELD(whereClause);
1381 WRITE_NODE_FIELD(groupClause);
1382 WRITE_NODE_FIELD(havingClause);
1383 WRITE_NODE_FIELD(sortClause);
1384 WRITE_NODE_FIELD(limitOffset);
1385 WRITE_NODE_FIELD(limitCount);
1386 WRITE_NODE_FIELD(lockingClause);
1387 WRITE_ENUM_FIELD(op, SetOperation);
1388 WRITE_BOOL_FIELD(all);
1389 WRITE_NODE_FIELD(larg);
1390 WRITE_NODE_FIELD(rarg);
1394 _outFuncCall(StringInfo str, FuncCall *node)
1396 WRITE_NODE_TYPE("FUNCCALL");
1398 WRITE_NODE_FIELD(funcname);
1399 WRITE_NODE_FIELD(args);
1400 WRITE_BOOL_FIELD(agg_star);
1401 WRITE_BOOL_FIELD(agg_distinct);
1402 WRITE_INT_FIELD(location);
1406 _outDefElem(StringInfo str, DefElem *node)
1408 WRITE_NODE_TYPE("DEFELEM");
1410 WRITE_STRING_FIELD(defname);
1411 WRITE_NODE_FIELD(arg);
1415 _outLockingClause(StringInfo str, LockingClause *node)
1417 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1419 WRITE_NODE_FIELD(lockedRels);
1420 WRITE_BOOL_FIELD(forUpdate);
1421 WRITE_BOOL_FIELD(noWait);
1425 _outColumnDef(StringInfo str, ColumnDef *node)
1427 WRITE_NODE_TYPE("COLUMNDEF");
1429 WRITE_STRING_FIELD(colname);
1430 WRITE_NODE_FIELD(typename);
1431 WRITE_INT_FIELD(inhcount);
1432 WRITE_BOOL_FIELD(is_local);
1433 WRITE_BOOL_FIELD(is_not_null);
1434 WRITE_NODE_FIELD(raw_default);
1435 WRITE_STRING_FIELD(cooked_default);
1436 WRITE_NODE_FIELD(constraints);
1437 WRITE_NODE_FIELD(support);
1441 _outTypeName(StringInfo str, TypeName *node)
1443 WRITE_NODE_TYPE("TYPENAME");
1445 WRITE_NODE_FIELD(names);
1446 WRITE_OID_FIELD(typeid);
1447 WRITE_BOOL_FIELD(timezone);
1448 WRITE_BOOL_FIELD(setof);
1449 WRITE_BOOL_FIELD(pct_type);
1450 WRITE_INT_FIELD(typmod);
1451 WRITE_NODE_FIELD(arrayBounds);
1452 WRITE_INT_FIELD(location);
1456 _outTypeCast(StringInfo str, TypeCast *node)
1458 WRITE_NODE_TYPE("TYPECAST");
1460 WRITE_NODE_FIELD(arg);
1461 WRITE_NODE_FIELD(typename);
1465 _outIndexElem(StringInfo str, IndexElem *node)
1467 WRITE_NODE_TYPE("INDEXELEM");
1469 WRITE_STRING_FIELD(name);
1470 WRITE_NODE_FIELD(expr);
1471 WRITE_NODE_FIELD(opclass);
1475 _outQuery(StringInfo str, Query *node)
1477 WRITE_NODE_TYPE("QUERY");
1479 WRITE_ENUM_FIELD(commandType, CmdType);
1480 WRITE_ENUM_FIELD(querySource, QuerySource);
1481 WRITE_BOOL_FIELD(canSetTag);
1484 * Hack to work around missing outfuncs routines for a lot of the
1485 * utility-statement node types. (The only one we actually *need* for
1486 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1487 * for the meantime do this to avoid getting lots of warnings when running
1488 * with debug_print_parse on.
1490 if (node->utilityStmt)
1492 switch (nodeTag(node->utilityStmt))
1497 case T_DeclareCursorStmt:
1498 WRITE_NODE_FIELD(utilityStmt);
1501 appendStringInfo(str, " :utilityStmt ?");
1506 appendStringInfo(str, " :utilityStmt <>");
1508 WRITE_INT_FIELD(resultRelation);
1509 WRITE_NODE_FIELD(into);
1510 WRITE_BOOL_FIELD(intoHasOids);
1511 WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
1512 WRITE_STRING_FIELD(intoTableSpaceName);
1513 WRITE_BOOL_FIELD(hasAggs);
1514 WRITE_BOOL_FIELD(hasSubLinks);
1515 WRITE_NODE_FIELD(rtable);
1516 WRITE_NODE_FIELD(jointree);
1517 WRITE_NODE_FIELD(targetList);
1518 WRITE_NODE_FIELD(groupClause);
1519 WRITE_NODE_FIELD(havingQual);
1520 WRITE_NODE_FIELD(distinctClause);
1521 WRITE_NODE_FIELD(sortClause);
1522 WRITE_NODE_FIELD(limitOffset);
1523 WRITE_NODE_FIELD(limitCount);
1524 WRITE_NODE_FIELD(rowMarks);
1525 WRITE_NODE_FIELD(setOperations);
1526 WRITE_NODE_FIELD(resultRelations);
1530 _outSortClause(StringInfo str, SortClause *node)
1532 WRITE_NODE_TYPE("SORTCLAUSE");
1534 WRITE_UINT_FIELD(tleSortGroupRef);
1535 WRITE_OID_FIELD(sortop);
1539 _outGroupClause(StringInfo str, GroupClause *node)
1541 WRITE_NODE_TYPE("GROUPCLAUSE");
1543 WRITE_UINT_FIELD(tleSortGroupRef);
1544 WRITE_OID_FIELD(sortop);
1548 _outRowMarkClause(StringInfo str, RowMarkClause *node)
1550 WRITE_NODE_TYPE("ROWMARKCLAUSE");
1552 WRITE_UINT_FIELD(rti);
1553 WRITE_BOOL_FIELD(forUpdate);
1554 WRITE_BOOL_FIELD(noWait);
1558 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
1560 WRITE_NODE_TYPE("SETOPERATIONSTMT");
1562 WRITE_ENUM_FIELD(op, SetOperation);
1563 WRITE_BOOL_FIELD(all);
1564 WRITE_NODE_FIELD(larg);
1565 WRITE_NODE_FIELD(rarg);
1566 WRITE_NODE_FIELD(colTypes);
1570 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
1572 WRITE_NODE_TYPE("RTE");
1574 /* put alias + eref first to make dump more legible */
1575 WRITE_NODE_FIELD(alias);
1576 WRITE_NODE_FIELD(eref);
1577 WRITE_ENUM_FIELD(rtekind, RTEKind);
1579 switch (node->rtekind)
1583 WRITE_OID_FIELD(relid);
1586 WRITE_NODE_FIELD(subquery);
1589 WRITE_NODE_FIELD(funcexpr);
1590 WRITE_NODE_FIELD(funccoltypes);
1591 WRITE_NODE_FIELD(funccoltypmods);
1594 WRITE_ENUM_FIELD(jointype, JoinType);
1595 WRITE_NODE_FIELD(joinaliasvars);
1598 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
1602 WRITE_BOOL_FIELD(inh);
1603 WRITE_BOOL_FIELD(inFromCl);
1604 WRITE_UINT_FIELD(requiredPerms);
1605 WRITE_OID_FIELD(checkAsUser);
1609 _outAExpr(StringInfo str, A_Expr *node)
1611 WRITE_NODE_TYPE("AEXPR");
1616 appendStringInfo(str, " ");
1617 WRITE_NODE_FIELD(name);
1620 appendStringInfo(str, " AND");
1623 appendStringInfo(str, " OR");
1626 appendStringInfo(str, " NOT");
1629 appendStringInfo(str, " ");
1630 WRITE_NODE_FIELD(name);
1631 appendStringInfo(str, " ANY ");
1634 appendStringInfo(str, " ");
1635 WRITE_NODE_FIELD(name);
1636 appendStringInfo(str, " ALL ");
1638 case AEXPR_DISTINCT:
1639 appendStringInfo(str, " DISTINCT ");
1640 WRITE_NODE_FIELD(name);
1643 appendStringInfo(str, " NULLIF ");
1644 WRITE_NODE_FIELD(name);
1647 appendStringInfo(str, " OF ");
1648 WRITE_NODE_FIELD(name);
1651 appendStringInfo(str, " IN ");
1652 WRITE_NODE_FIELD(name);
1655 appendStringInfo(str, " ??");
1659 WRITE_NODE_FIELD(lexpr);
1660 WRITE_NODE_FIELD(rexpr);
1661 WRITE_INT_FIELD(location);
1665 _outValue(StringInfo str, Value *value)
1667 switch (value->type)
1670 appendStringInfo(str, "%ld", value->val.ival);
1675 * We assume the value is a valid numeric literal and so does not
1678 appendStringInfoString(str, value->val.str);
1681 appendStringInfoChar(str, '"');
1682 _outToken(str, value->val.str);
1683 appendStringInfoChar(str, '"');
1686 /* internal representation already has leading 'b' */
1687 appendStringInfoString(str, value->val.str);
1690 elog(ERROR, "unrecognized node type: %d", (int) value->type);
1696 _outColumnRef(StringInfo str, ColumnRef *node)
1698 WRITE_NODE_TYPE("COLUMNREF");
1700 WRITE_NODE_FIELD(fields);
1701 WRITE_INT_FIELD(location);
1705 _outParamRef(StringInfo str, ParamRef *node)
1707 WRITE_NODE_TYPE("PARAMREF");
1709 WRITE_INT_FIELD(number);
1713 _outAConst(StringInfo str, A_Const *node)
1715 WRITE_NODE_TYPE("A_CONST");
1717 appendStringInfo(str, " :val ");
1718 _outValue(str, &(node->val));
1719 WRITE_NODE_FIELD(typename);
1723 _outA_Indices(StringInfo str, A_Indices *node)
1725 WRITE_NODE_TYPE("A_INDICES");
1727 WRITE_NODE_FIELD(lidx);
1728 WRITE_NODE_FIELD(uidx);
1732 _outA_Indirection(StringInfo str, A_Indirection *node)
1734 WRITE_NODE_TYPE("A_INDIRECTION");
1736 WRITE_NODE_FIELD(arg);
1737 WRITE_NODE_FIELD(indirection);
1741 _outResTarget(StringInfo str, ResTarget *node)
1743 WRITE_NODE_TYPE("RESTARGET");
1745 WRITE_STRING_FIELD(name);
1746 WRITE_NODE_FIELD(indirection);
1747 WRITE_NODE_FIELD(val);
1748 WRITE_INT_FIELD(location);
1752 _outConstraint(StringInfo str, Constraint *node)
1754 WRITE_NODE_TYPE("CONSTRAINT");
1756 WRITE_STRING_FIELD(name);
1758 appendStringInfo(str, " :contype ");
1759 switch (node->contype)
1761 case CONSTR_PRIMARY:
1762 appendStringInfo(str, "PRIMARY_KEY");
1763 WRITE_NODE_FIELD(keys);
1764 WRITE_STRING_FIELD(indexspace);
1768 appendStringInfo(str, "UNIQUE");
1769 WRITE_NODE_FIELD(keys);
1770 WRITE_STRING_FIELD(indexspace);
1774 appendStringInfo(str, "CHECK");
1775 WRITE_NODE_FIELD(raw_expr);
1776 WRITE_STRING_FIELD(cooked_expr);
1779 case CONSTR_DEFAULT:
1780 appendStringInfo(str, "DEFAULT");
1781 WRITE_NODE_FIELD(raw_expr);
1782 WRITE_STRING_FIELD(cooked_expr);
1785 case CONSTR_NOTNULL:
1786 appendStringInfo(str, "NOT_NULL");
1790 appendStringInfo(str, "<unrecognized_constraint>");
1796 _outFkConstraint(StringInfo str, FkConstraint *node)
1798 WRITE_NODE_TYPE("FKCONSTRAINT");
1800 WRITE_STRING_FIELD(constr_name);
1801 WRITE_NODE_FIELD(pktable);
1802 WRITE_NODE_FIELD(fk_attrs);
1803 WRITE_NODE_FIELD(pk_attrs);
1804 WRITE_CHAR_FIELD(fk_matchtype);
1805 WRITE_CHAR_FIELD(fk_upd_action);
1806 WRITE_CHAR_FIELD(fk_del_action);
1807 WRITE_BOOL_FIELD(deferrable);
1808 WRITE_BOOL_FIELD(initdeferred);
1809 WRITE_BOOL_FIELD(skip_validation);
1815 * converts a Node into ascii string and append it to 'str'
1818 _outNode(StringInfo str, void *obj)
1821 appendStringInfo(str, "<>");
1822 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
1824 else if (IsA(obj, Integer) ||
1827 IsA(obj, BitString))
1829 /* nodeRead does not want to see { } around these! */
1830 _outValue(str, obj);
1834 appendStringInfoChar(str, '{');
1835 switch (nodeTag(obj))
1841 _outResult(str, obj);
1844 _outAppend(str, obj);
1847 _outBitmapAnd(str, obj);
1850 _outBitmapOr(str, obj);
1856 _outSeqScan(str, obj);
1859 _outIndexScan(str, obj);
1861 case T_BitmapIndexScan:
1862 _outBitmapIndexScan(str, obj);
1864 case T_BitmapHeapScan:
1865 _outBitmapHeapScan(str, obj);
1868 _outTidScan(str, obj);
1870 case T_SubqueryScan:
1871 _outSubqueryScan(str, obj);
1873 case T_FunctionScan:
1874 _outFunctionScan(str, obj);
1880 _outNestLoop(str, obj);
1883 _outMergeJoin(str, obj);
1886 _outHashJoin(str, obj);
1892 _outGroup(str, obj);
1895 _outMaterial(str, obj);
1901 _outUnique(str, obj);
1904 _outSetOp(str, obj);
1907 _outLimit(str, obj);
1913 _outAlias(str, obj);
1916 _outRangeVar(str, obj);
1922 _outConst(str, obj);
1925 _outParam(str, obj);
1928 _outAggref(str, obj);
1931 _outArrayRef(str, obj);
1934 _outFuncExpr(str, obj);
1937 _outOpExpr(str, obj);
1939 case T_DistinctExpr:
1940 _outDistinctExpr(str, obj);
1942 case T_ScalarArrayOpExpr:
1943 _outScalarArrayOpExpr(str, obj);
1946 _outBoolExpr(str, obj);
1949 _outSubLink(str, obj);
1952 _outSubPlan(str, obj);
1955 _outFieldSelect(str, obj);
1958 _outFieldStore(str, obj);
1961 _outRelabelType(str, obj);
1963 case T_ConvertRowtypeExpr:
1964 _outConvertRowtypeExpr(str, obj);
1967 _outCaseExpr(str, obj);
1970 _outCaseWhen(str, obj);
1972 case T_CaseTestExpr:
1973 _outCaseTestExpr(str, obj);
1976 _outArrayExpr(str, obj);
1979 _outRowExpr(str, obj);
1981 case T_RowCompareExpr:
1982 _outRowCompareExpr(str, obj);
1984 case T_CoalesceExpr:
1985 _outCoalesceExpr(str, obj);
1988 _outMinMaxExpr(str, obj);
1991 _outNullIfExpr(str, obj);
1994 _outNullTest(str, obj);
1997 _outBooleanTest(str, obj);
1999 case T_CoerceToDomain:
2000 _outCoerceToDomain(str, obj);
2002 case T_CoerceToDomainValue:
2003 _outCoerceToDomainValue(str, obj);
2005 case T_SetToDefault:
2006 _outSetToDefault(str, obj);
2009 _outTargetEntry(str, obj);
2012 _outRangeTblRef(str, obj);
2015 _outJoinExpr(str, obj);
2018 _outFromExpr(str, obj);
2025 _outIndexPath(str, obj);
2027 case T_BitmapHeapPath:
2028 _outBitmapHeapPath(str, obj);
2030 case T_BitmapAndPath:
2031 _outBitmapAndPath(str, obj);
2033 case T_BitmapOrPath:
2034 _outBitmapOrPath(str, obj);
2037 _outTidPath(str, obj);
2040 _outAppendPath(str, obj);
2043 _outResultPath(str, obj);
2045 case T_MaterialPath:
2046 _outMaterialPath(str, obj);
2049 _outUniquePath(str, obj);
2052 _outNestPath(str, obj);
2055 _outMergePath(str, obj);
2058 _outHashPath(str, obj);
2061 _outPlannerInfo(str, obj);
2064 _outRelOptInfo(str, obj);
2066 case T_IndexOptInfo:
2067 _outIndexOptInfo(str, obj);
2070 _outPathKeyItem(str, obj);
2072 case T_RestrictInfo:
2073 _outRestrictInfo(str, obj);
2075 case T_InnerIndexscanInfo:
2076 _outInnerIndexscanInfo(str, obj);
2078 case T_OuterJoinInfo:
2079 _outOuterJoinInfo(str, obj);
2081 case T_InClauseInfo:
2082 _outInClauseInfo(str, obj);
2084 case T_AppendRelInfo:
2085 _outAppendRelInfo(str, obj);
2089 _outCreateStmt(str, obj);
2092 _outIndexStmt(str, obj);
2095 _outNotifyStmt(str, obj);
2097 case T_DeclareCursorStmt:
2098 _outDeclareCursorStmt(str, obj);
2101 _outSelectStmt(str, obj);
2104 _outColumnDef(str, obj);
2107 _outTypeName(str, obj);
2110 _outTypeCast(str, obj);
2113 _outIndexElem(str, obj);
2116 _outQuery(str, obj);
2119 _outSortClause(str, obj);
2122 _outGroupClause(str, obj);
2124 case T_RowMarkClause:
2125 _outRowMarkClause(str, obj);
2127 case T_SetOperationStmt:
2128 _outSetOperationStmt(str, obj);
2130 case T_RangeTblEntry:
2131 _outRangeTblEntry(str, obj);
2134 _outAExpr(str, obj);
2137 _outColumnRef(str, obj);
2140 _outParamRef(str, obj);
2143 _outAConst(str, obj);
2146 _outA_Indices(str, obj);
2148 case T_A_Indirection:
2149 _outA_Indirection(str, obj);
2152 _outResTarget(str, obj);
2155 _outConstraint(str, obj);
2157 case T_FkConstraint:
2158 _outFkConstraint(str, obj);
2161 _outFuncCall(str, obj);
2164 _outDefElem(str, obj);
2166 case T_LockingClause:
2167 _outLockingClause(str, obj);
2173 * This should be an ERROR, but it's too useful to be able to
2174 * dump structures that _outNode only understands part of.
2176 elog(WARNING, "could not dump unrecognized node type: %d",
2177 (int) nodeTag(obj));
2180 appendStringInfoChar(str, '}');
2186 * returns the ascii representation of the Node as a palloc'd string
2189 nodeToString(void *obj)
2193 /* see stringinfo.h for an explanation of this maneuver */
2194 initStringInfo(&str);
2195 _outNode(&str, obj);