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.282 2006/08/12 02:52:04 tgl Exp $
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). For use in debugging, we also provide output
17 * functions for nodes that appear in raw parsetrees, path, and plan trees.
18 * These nodes however need not have input functions.
20 *-------------------------------------------------------------------------
26 #include "lib/stringinfo.h"
27 #include "nodes/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
33 * Macros to simplify output of different kinds of fields. Use these
34 * wherever possible to reduce the chance for silly typos. Note that these
35 * hard-wire conventions about the names of the local variables in an Out
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41 appendStringInfoString(str, nodelabel)
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47 /* Write an unsigned integer field (anything written as ":fldname %u") */
48 #define WRITE_UINT_FIELD(fldname) \
49 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
51 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
52 #define WRITE_OID_FIELD(fldname) \
53 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
68 /* Write a float field --- caller must give format to define precision */
69 #define WRITE_FLOAT_FIELD(fldname,format) \
70 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75 booltostr(node->fldname))
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 _outToken(str, node->fldname))
82 /* Write a Node field */
83 #define WRITE_NODE_FIELD(fldname) \
84 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
85 _outNode(str, node->fldname))
87 /* Write a bitmapset field */
88 #define WRITE_BITMAPSET_FIELD(fldname) \
89 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
90 _outBitmapset(str, node->fldname))
93 #define booltostr(x) ((x) ? "true" : "false")
95 static void _outNode(StringInfo str, void *obj);
100 * Convert an ordinary string (eg, an identifier) into a form that
101 * will be decoded back to a plain token by read.c's functions.
103 * If a null or empty string is given, it is encoded as "<>".
106 _outToken(StringInfo str, char *s)
108 if (s == NULL || *s == '\0')
110 appendStringInfo(str, "<>");
115 * Look for characters or patterns that are treated specially by read.c
116 * (either in pg_strtok() or in nodeRead()), and therefore need a
117 * protective backslash.
119 /* These characters only need to be quoted at the start of the string */
122 isdigit((unsigned char) *s) ||
123 ((*s == '+' || *s == '-') &&
124 (isdigit((unsigned char) s[1]) || s[1] == '.')))
125 appendStringInfoChar(str, '\\');
128 /* These chars must be backslashed anywhere in the string */
129 if (*s == ' ' || *s == '\n' || *s == '\t' ||
130 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
132 appendStringInfoChar(str, '\\');
133 appendStringInfoChar(str, *s++);
138 _outList(StringInfo str, List *node)
142 appendStringInfoChar(str, '(');
144 if (IsA(node, IntList))
145 appendStringInfoChar(str, 'i');
146 else if (IsA(node, OidList))
147 appendStringInfoChar(str, 'o');
152 * For the sake of backward compatibility, we emit a slightly
153 * different whitespace format for lists of nodes vs. other types of
154 * lists. XXX: is this necessary?
158 _outNode(str, lfirst(lc));
160 appendStringInfoChar(str, ' ');
162 else if (IsA(node, IntList))
163 appendStringInfo(str, " %d", lfirst_int(lc));
164 else if (IsA(node, OidList))
165 appendStringInfo(str, " %u", lfirst_oid(lc));
167 elog(ERROR, "unrecognized list node type: %d",
171 appendStringInfoChar(str, ')');
176 * converts a bitmap set of integers
178 * Note: the output format is "(b int int ...)", similar to an integer List.
179 * Currently bitmapsets do not appear in any node type that is stored in
180 * rules, so there is no support in readfuncs.c for reading this format.
183 _outBitmapset(StringInfo str, Bitmapset *bms)
188 appendStringInfoChar(str, '(');
189 appendStringInfoChar(str, 'b');
190 tmpset = bms_copy(bms);
191 while ((x = bms_first_member(tmpset)) >= 0)
192 appendStringInfo(str, " %d", x);
194 appendStringInfoChar(str, ')');
198 * Print the value of a Datum given its type.
201 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
207 length = datumGetSize(value, typbyval, typlen);
211 s = (char *) (&value);
212 appendStringInfo(str, "%u [ ", (unsigned int) length);
213 for (i = 0; i < (Size) sizeof(Datum); i++)
214 appendStringInfo(str, "%d ", (int) (s[i]));
215 appendStringInfo(str, "]");
219 s = (char *) DatumGetPointer(value);
220 if (!PointerIsValid(s))
221 appendStringInfo(str, "0 [ ]");
224 appendStringInfo(str, "%u [ ", (unsigned int) length);
225 for (i = 0; i < length; i++)
226 appendStringInfo(str, "%d ", (int) (s[i]));
227 appendStringInfo(str, "]");
234 * Stuff from plannodes.h
238 * print the basic stuff of all nodes that inherit from Plan
241 _outPlanInfo(StringInfo str, Plan *node)
243 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
244 WRITE_FLOAT_FIELD(total_cost, "%.2f");
245 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
246 WRITE_INT_FIELD(plan_width);
247 WRITE_NODE_FIELD(targetlist);
248 WRITE_NODE_FIELD(qual);
249 WRITE_NODE_FIELD(lefttree);
250 WRITE_NODE_FIELD(righttree);
251 WRITE_NODE_FIELD(initPlan);
252 WRITE_BITMAPSET_FIELD(extParam);
253 WRITE_BITMAPSET_FIELD(allParam);
254 WRITE_INT_FIELD(nParamExec);
258 * print the basic stuff of all nodes that inherit from Scan
261 _outScanInfo(StringInfo str, Scan *node)
263 _outPlanInfo(str, (Plan *) node);
265 WRITE_UINT_FIELD(scanrelid);
269 * print the basic stuff of all nodes that inherit from Join
272 _outJoinPlanInfo(StringInfo str, Join *node)
274 _outPlanInfo(str, (Plan *) node);
276 WRITE_ENUM_FIELD(jointype, JoinType);
277 WRITE_NODE_FIELD(joinqual);
282 _outPlan(StringInfo str, Plan *node)
284 WRITE_NODE_TYPE("PLAN");
286 _outPlanInfo(str, (Plan *) node);
290 _outResult(StringInfo str, Result *node)
292 WRITE_NODE_TYPE("RESULT");
294 _outPlanInfo(str, (Plan *) node);
296 WRITE_NODE_FIELD(resconstantqual);
300 _outAppend(StringInfo str, Append *node)
302 WRITE_NODE_TYPE("APPEND");
304 _outPlanInfo(str, (Plan *) node);
306 WRITE_NODE_FIELD(appendplans);
307 WRITE_BOOL_FIELD(isTarget);
311 _outBitmapAnd(StringInfo str, BitmapAnd *node)
313 WRITE_NODE_TYPE("BITMAPAND");
315 _outPlanInfo(str, (Plan *) node);
317 WRITE_NODE_FIELD(bitmapplans);
321 _outBitmapOr(StringInfo str, BitmapOr *node)
323 WRITE_NODE_TYPE("BITMAPOR");
325 _outPlanInfo(str, (Plan *) node);
327 WRITE_NODE_FIELD(bitmapplans);
331 _outScan(StringInfo str, Scan *node)
333 WRITE_NODE_TYPE("SCAN");
335 _outScanInfo(str, (Scan *) node);
339 _outSeqScan(StringInfo str, SeqScan *node)
341 WRITE_NODE_TYPE("SEQSCAN");
343 _outScanInfo(str, (Scan *) node);
347 _outIndexScan(StringInfo str, IndexScan *node)
349 WRITE_NODE_TYPE("INDEXSCAN");
351 _outScanInfo(str, (Scan *) node);
353 WRITE_OID_FIELD(indexid);
354 WRITE_NODE_FIELD(indexqual);
355 WRITE_NODE_FIELD(indexqualorig);
356 WRITE_NODE_FIELD(indexstrategy);
357 WRITE_NODE_FIELD(indexsubtype);
358 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
362 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
364 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
366 _outScanInfo(str, (Scan *) node);
368 WRITE_OID_FIELD(indexid);
369 WRITE_NODE_FIELD(indexqual);
370 WRITE_NODE_FIELD(indexqualorig);
371 WRITE_NODE_FIELD(indexstrategy);
372 WRITE_NODE_FIELD(indexsubtype);
376 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
378 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
380 _outScanInfo(str, (Scan *) node);
382 WRITE_NODE_FIELD(bitmapqualorig);
386 _outTidScan(StringInfo str, TidScan *node)
388 WRITE_NODE_TYPE("TIDSCAN");
390 _outScanInfo(str, (Scan *) node);
392 WRITE_NODE_FIELD(tidquals);
396 _outSubqueryScan(StringInfo str, SubqueryScan *node)
398 WRITE_NODE_TYPE("SUBQUERYSCAN");
400 _outScanInfo(str, (Scan *) node);
402 WRITE_NODE_FIELD(subplan);
406 _outFunctionScan(StringInfo str, FunctionScan *node)
408 WRITE_NODE_TYPE("FUNCTIONSCAN");
410 _outScanInfo(str, (Scan *) node);
414 _outValuesScan(StringInfo str, ValuesScan *node)
416 WRITE_NODE_TYPE("VALUESSCAN");
418 _outScanInfo(str, (Scan *) node);
422 _outJoin(StringInfo str, Join *node)
424 WRITE_NODE_TYPE("JOIN");
426 _outJoinPlanInfo(str, (Join *) node);
430 _outNestLoop(StringInfo str, NestLoop *node)
432 WRITE_NODE_TYPE("NESTLOOP");
434 _outJoinPlanInfo(str, (Join *) node);
438 _outMergeJoin(StringInfo str, MergeJoin *node)
440 WRITE_NODE_TYPE("MERGEJOIN");
442 _outJoinPlanInfo(str, (Join *) node);
444 WRITE_NODE_FIELD(mergeclauses);
448 _outHashJoin(StringInfo str, HashJoin *node)
450 WRITE_NODE_TYPE("HASHJOIN");
452 _outJoinPlanInfo(str, (Join *) node);
454 WRITE_NODE_FIELD(hashclauses);
458 _outAgg(StringInfo str, Agg *node)
460 WRITE_NODE_TYPE("AGG");
462 _outPlanInfo(str, (Plan *) node);
464 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
465 WRITE_INT_FIELD(numCols);
466 WRITE_LONG_FIELD(numGroups);
470 _outGroup(StringInfo str, Group *node)
474 WRITE_NODE_TYPE("GROUP");
476 _outPlanInfo(str, (Plan *) node);
478 WRITE_INT_FIELD(numCols);
480 appendStringInfo(str, " :grpColIdx");
481 for (i = 0; i < node->numCols; i++)
482 appendStringInfo(str, " %d", node->grpColIdx[i]);
486 _outMaterial(StringInfo str, Material *node)
488 WRITE_NODE_TYPE("MATERIAL");
490 _outPlanInfo(str, (Plan *) node);
494 _outSort(StringInfo str, Sort *node)
498 WRITE_NODE_TYPE("SORT");
500 _outPlanInfo(str, (Plan *) node);
502 WRITE_INT_FIELD(numCols);
504 appendStringInfo(str, " :sortColIdx");
505 for (i = 0; i < node->numCols; i++)
506 appendStringInfo(str, " %d", node->sortColIdx[i]);
508 appendStringInfo(str, " :sortOperators");
509 for (i = 0; i < node->numCols; i++)
510 appendStringInfo(str, " %u", node->sortOperators[i]);
514 _outUnique(StringInfo str, Unique *node)
518 WRITE_NODE_TYPE("UNIQUE");
520 _outPlanInfo(str, (Plan *) node);
522 WRITE_INT_FIELD(numCols);
524 appendStringInfo(str, " :uniqColIdx");
525 for (i = 0; i < node->numCols; i++)
526 appendStringInfo(str, " %d", node->uniqColIdx[i]);
530 _outSetOp(StringInfo str, SetOp *node)
534 WRITE_NODE_TYPE("SETOP");
536 _outPlanInfo(str, (Plan *) node);
538 WRITE_ENUM_FIELD(cmd, SetOpCmd);
539 WRITE_INT_FIELD(numCols);
541 appendStringInfo(str, " :dupColIdx");
542 for (i = 0; i < node->numCols; i++)
543 appendStringInfo(str, " %d", node->dupColIdx[i]);
545 WRITE_INT_FIELD(flagColIdx);
549 _outLimit(StringInfo str, Limit *node)
551 WRITE_NODE_TYPE("LIMIT");
553 _outPlanInfo(str, (Plan *) node);
555 WRITE_NODE_FIELD(limitOffset);
556 WRITE_NODE_FIELD(limitCount);
560 _outHash(StringInfo str, Hash *node)
562 WRITE_NODE_TYPE("HASH");
564 _outPlanInfo(str, (Plan *) node);
567 /*****************************************************************************
569 * Stuff from primnodes.h.
571 *****************************************************************************/
574 _outAlias(StringInfo str, Alias *node)
576 WRITE_NODE_TYPE("ALIAS");
578 WRITE_STRING_FIELD(aliasname);
579 WRITE_NODE_FIELD(colnames);
583 _outRangeVar(StringInfo str, RangeVar *node)
585 WRITE_NODE_TYPE("RANGEVAR");
588 * we deliberately ignore catalogname here, since it is presently not
589 * semantically meaningful
591 WRITE_STRING_FIELD(schemaname);
592 WRITE_STRING_FIELD(relname);
593 WRITE_ENUM_FIELD(inhOpt, InhOption);
594 WRITE_BOOL_FIELD(istemp);
595 WRITE_NODE_FIELD(alias);
599 _outVar(StringInfo str, Var *node)
601 WRITE_NODE_TYPE("VAR");
603 WRITE_UINT_FIELD(varno);
604 WRITE_INT_FIELD(varattno);
605 WRITE_OID_FIELD(vartype);
606 WRITE_INT_FIELD(vartypmod);
607 WRITE_UINT_FIELD(varlevelsup);
608 WRITE_UINT_FIELD(varnoold);
609 WRITE_INT_FIELD(varoattno);
613 _outConst(StringInfo str, Const *node)
615 WRITE_NODE_TYPE("CONST");
617 WRITE_OID_FIELD(consttype);
618 WRITE_INT_FIELD(constlen);
619 WRITE_BOOL_FIELD(constbyval);
620 WRITE_BOOL_FIELD(constisnull);
622 appendStringInfo(str, " :constvalue ");
623 if (node->constisnull)
624 appendStringInfo(str, "<>");
626 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
630 _outParam(StringInfo str, Param *node)
632 WRITE_NODE_TYPE("PARAM");
634 WRITE_ENUM_FIELD(paramkind, ParamKind);
635 WRITE_INT_FIELD(paramid);
636 WRITE_OID_FIELD(paramtype);
640 _outAggref(StringInfo str, Aggref *node)
642 WRITE_NODE_TYPE("AGGREF");
644 WRITE_OID_FIELD(aggfnoid);
645 WRITE_OID_FIELD(aggtype);
646 WRITE_NODE_FIELD(args);
647 WRITE_UINT_FIELD(agglevelsup);
648 WRITE_BOOL_FIELD(aggstar);
649 WRITE_BOOL_FIELD(aggdistinct);
653 _outArrayRef(StringInfo str, ArrayRef *node)
655 WRITE_NODE_TYPE("ARRAYREF");
657 WRITE_OID_FIELD(refrestype);
658 WRITE_OID_FIELD(refarraytype);
659 WRITE_OID_FIELD(refelemtype);
660 WRITE_NODE_FIELD(refupperindexpr);
661 WRITE_NODE_FIELD(reflowerindexpr);
662 WRITE_NODE_FIELD(refexpr);
663 WRITE_NODE_FIELD(refassgnexpr);
667 _outFuncExpr(StringInfo str, FuncExpr *node)
669 WRITE_NODE_TYPE("FUNCEXPR");
671 WRITE_OID_FIELD(funcid);
672 WRITE_OID_FIELD(funcresulttype);
673 WRITE_BOOL_FIELD(funcretset);
674 WRITE_ENUM_FIELD(funcformat, CoercionForm);
675 WRITE_NODE_FIELD(args);
679 _outOpExpr(StringInfo str, OpExpr *node)
681 WRITE_NODE_TYPE("OPEXPR");
683 WRITE_OID_FIELD(opno);
684 WRITE_OID_FIELD(opfuncid);
685 WRITE_OID_FIELD(opresulttype);
686 WRITE_BOOL_FIELD(opretset);
687 WRITE_NODE_FIELD(args);
691 _outDistinctExpr(StringInfo str, DistinctExpr *node)
693 WRITE_NODE_TYPE("DISTINCTEXPR");
695 WRITE_OID_FIELD(opno);
696 WRITE_OID_FIELD(opfuncid);
697 WRITE_OID_FIELD(opresulttype);
698 WRITE_BOOL_FIELD(opretset);
699 WRITE_NODE_FIELD(args);
703 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
705 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
707 WRITE_OID_FIELD(opno);
708 WRITE_OID_FIELD(opfuncid);
709 WRITE_BOOL_FIELD(useOr);
710 WRITE_NODE_FIELD(args);
714 _outBoolExpr(StringInfo str, BoolExpr *node)
718 WRITE_NODE_TYPE("BOOLEXPR");
720 /* do-it-yourself enum representation */
721 switch (node->boolop)
733 appendStringInfo(str, " :boolop ");
734 _outToken(str, opstr);
736 WRITE_NODE_FIELD(args);
740 _outSubLink(StringInfo str, SubLink *node)
742 WRITE_NODE_TYPE("SUBLINK");
744 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
745 WRITE_NODE_FIELD(testexpr);
746 WRITE_NODE_FIELD(operName);
747 WRITE_NODE_FIELD(subselect);
751 _outSubPlan(StringInfo str, SubPlan *node)
753 WRITE_NODE_TYPE("SUBPLAN");
755 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
756 WRITE_NODE_FIELD(testexpr);
757 WRITE_NODE_FIELD(paramIds);
758 WRITE_NODE_FIELD(plan);
759 WRITE_INT_FIELD(plan_id);
760 WRITE_NODE_FIELD(rtable);
761 WRITE_BOOL_FIELD(useHashTable);
762 WRITE_BOOL_FIELD(unknownEqFalse);
763 WRITE_NODE_FIELD(setParam);
764 WRITE_NODE_FIELD(parParam);
765 WRITE_NODE_FIELD(args);
769 _outFieldSelect(StringInfo str, FieldSelect *node)
771 WRITE_NODE_TYPE("FIELDSELECT");
773 WRITE_NODE_FIELD(arg);
774 WRITE_INT_FIELD(fieldnum);
775 WRITE_OID_FIELD(resulttype);
776 WRITE_INT_FIELD(resulttypmod);
780 _outFieldStore(StringInfo str, FieldStore *node)
782 WRITE_NODE_TYPE("FIELDSTORE");
784 WRITE_NODE_FIELD(arg);
785 WRITE_NODE_FIELD(newvals);
786 WRITE_NODE_FIELD(fieldnums);
787 WRITE_OID_FIELD(resulttype);
791 _outRelabelType(StringInfo str, RelabelType *node)
793 WRITE_NODE_TYPE("RELABELTYPE");
795 WRITE_NODE_FIELD(arg);
796 WRITE_OID_FIELD(resulttype);
797 WRITE_INT_FIELD(resulttypmod);
798 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
802 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
804 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
806 WRITE_NODE_FIELD(arg);
807 WRITE_OID_FIELD(resulttype);
808 WRITE_ENUM_FIELD(convertformat, CoercionForm);
812 _outCaseExpr(StringInfo str, CaseExpr *node)
814 WRITE_NODE_TYPE("CASE");
816 WRITE_OID_FIELD(casetype);
817 WRITE_NODE_FIELD(arg);
818 WRITE_NODE_FIELD(args);
819 WRITE_NODE_FIELD(defresult);
823 _outCaseWhen(StringInfo str, CaseWhen *node)
825 WRITE_NODE_TYPE("WHEN");
827 WRITE_NODE_FIELD(expr);
828 WRITE_NODE_FIELD(result);
832 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
834 WRITE_NODE_TYPE("CASETESTEXPR");
836 WRITE_OID_FIELD(typeId);
837 WRITE_INT_FIELD(typeMod);
841 _outArrayExpr(StringInfo str, ArrayExpr *node)
843 WRITE_NODE_TYPE("ARRAY");
845 WRITE_OID_FIELD(array_typeid);
846 WRITE_OID_FIELD(element_typeid);
847 WRITE_NODE_FIELD(elements);
848 WRITE_BOOL_FIELD(multidims);
852 _outRowExpr(StringInfo str, RowExpr *node)
854 WRITE_NODE_TYPE("ROW");
856 WRITE_NODE_FIELD(args);
857 WRITE_OID_FIELD(row_typeid);
858 WRITE_ENUM_FIELD(row_format, CoercionForm);
862 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
864 WRITE_NODE_TYPE("ROWCOMPARE");
866 WRITE_ENUM_FIELD(rctype, RowCompareType);
867 WRITE_NODE_FIELD(opnos);
868 WRITE_NODE_FIELD(opclasses);
869 WRITE_NODE_FIELD(largs);
870 WRITE_NODE_FIELD(rargs);
874 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
876 WRITE_NODE_TYPE("COALESCE");
878 WRITE_OID_FIELD(coalescetype);
879 WRITE_NODE_FIELD(args);
883 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
885 WRITE_NODE_TYPE("MINMAX");
887 WRITE_OID_FIELD(minmaxtype);
888 WRITE_ENUM_FIELD(op, MinMaxOp);
889 WRITE_NODE_FIELD(args);
893 _outNullIfExpr(StringInfo str, NullIfExpr *node)
895 WRITE_NODE_TYPE("NULLIFEXPR");
897 WRITE_OID_FIELD(opno);
898 WRITE_OID_FIELD(opfuncid);
899 WRITE_OID_FIELD(opresulttype);
900 WRITE_BOOL_FIELD(opretset);
901 WRITE_NODE_FIELD(args);
905 _outNullTest(StringInfo str, NullTest *node)
907 WRITE_NODE_TYPE("NULLTEST");
909 WRITE_NODE_FIELD(arg);
910 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
914 _outBooleanTest(StringInfo str, BooleanTest *node)
916 WRITE_NODE_TYPE("BOOLEANTEST");
918 WRITE_NODE_FIELD(arg);
919 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
923 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
925 WRITE_NODE_TYPE("COERCETODOMAIN");
927 WRITE_NODE_FIELD(arg);
928 WRITE_OID_FIELD(resulttype);
929 WRITE_INT_FIELD(resulttypmod);
930 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
934 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
936 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
938 WRITE_OID_FIELD(typeId);
939 WRITE_INT_FIELD(typeMod);
943 _outSetToDefault(StringInfo str, SetToDefault *node)
945 WRITE_NODE_TYPE("SETTODEFAULT");
947 WRITE_OID_FIELD(typeId);
948 WRITE_INT_FIELD(typeMod);
952 _outTargetEntry(StringInfo str, TargetEntry *node)
954 WRITE_NODE_TYPE("TARGETENTRY");
956 WRITE_NODE_FIELD(expr);
957 WRITE_INT_FIELD(resno);
958 WRITE_STRING_FIELD(resname);
959 WRITE_UINT_FIELD(ressortgroupref);
960 WRITE_OID_FIELD(resorigtbl);
961 WRITE_INT_FIELD(resorigcol);
962 WRITE_BOOL_FIELD(resjunk);
966 _outRangeTblRef(StringInfo str, RangeTblRef *node)
968 WRITE_NODE_TYPE("RANGETBLREF");
970 WRITE_INT_FIELD(rtindex);
974 _outJoinExpr(StringInfo str, JoinExpr *node)
976 WRITE_NODE_TYPE("JOINEXPR");
978 WRITE_ENUM_FIELD(jointype, JoinType);
979 WRITE_BOOL_FIELD(isNatural);
980 WRITE_NODE_FIELD(larg);
981 WRITE_NODE_FIELD(rarg);
982 WRITE_NODE_FIELD(using);
983 WRITE_NODE_FIELD(quals);
984 WRITE_NODE_FIELD(alias);
985 WRITE_INT_FIELD(rtindex);
989 _outFromExpr(StringInfo str, FromExpr *node)
991 WRITE_NODE_TYPE("FROMEXPR");
993 WRITE_NODE_FIELD(fromlist);
994 WRITE_NODE_FIELD(quals);
997 /*****************************************************************************
999 * Stuff from relation.h.
1001 *****************************************************************************/
1004 * print the basic stuff of all nodes that inherit from Path
1006 * Note we do NOT print the parent, else we'd be in infinite recursion
1009 _outPathInfo(StringInfo str, Path *node)
1011 WRITE_ENUM_FIELD(pathtype, NodeTag);
1012 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1013 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1014 WRITE_NODE_FIELD(pathkeys);
1018 * print the basic stuff of all nodes that inherit from JoinPath
1021 _outJoinPathInfo(StringInfo str, JoinPath *node)
1023 _outPathInfo(str, (Path *) node);
1025 WRITE_ENUM_FIELD(jointype, JoinType);
1026 WRITE_NODE_FIELD(outerjoinpath);
1027 WRITE_NODE_FIELD(innerjoinpath);
1028 WRITE_NODE_FIELD(joinrestrictinfo);
1032 _outPath(StringInfo str, Path *node)
1034 WRITE_NODE_TYPE("PATH");
1036 _outPathInfo(str, (Path *) node);
1040 _outIndexPath(StringInfo str, IndexPath *node)
1042 WRITE_NODE_TYPE("INDEXPATH");
1044 _outPathInfo(str, (Path *) node);
1046 WRITE_NODE_FIELD(indexinfo);
1047 WRITE_NODE_FIELD(indexclauses);
1048 WRITE_NODE_FIELD(indexquals);
1049 WRITE_BOOL_FIELD(isjoininner);
1050 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1051 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1052 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1053 WRITE_FLOAT_FIELD(rows, "%.0f");
1057 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1059 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1061 _outPathInfo(str, (Path *) node);
1063 WRITE_NODE_FIELD(bitmapqual);
1064 WRITE_BOOL_FIELD(isjoininner);
1065 WRITE_FLOAT_FIELD(rows, "%.0f");
1069 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1071 WRITE_NODE_TYPE("BITMAPANDPATH");
1073 _outPathInfo(str, (Path *) node);
1075 WRITE_NODE_FIELD(bitmapquals);
1076 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1080 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1082 WRITE_NODE_TYPE("BITMAPORPATH");
1084 _outPathInfo(str, (Path *) node);
1086 WRITE_NODE_FIELD(bitmapquals);
1087 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1091 _outTidPath(StringInfo str, TidPath *node)
1093 WRITE_NODE_TYPE("TIDPATH");
1095 _outPathInfo(str, (Path *) node);
1097 WRITE_NODE_FIELD(tidquals);
1101 _outAppendPath(StringInfo str, AppendPath *node)
1103 WRITE_NODE_TYPE("APPENDPATH");
1105 _outPathInfo(str, (Path *) node);
1107 WRITE_NODE_FIELD(subpaths);
1111 _outResultPath(StringInfo str, ResultPath *node)
1113 WRITE_NODE_TYPE("RESULTPATH");
1115 _outPathInfo(str, (Path *) node);
1117 WRITE_NODE_FIELD(quals);
1121 _outMaterialPath(StringInfo str, MaterialPath *node)
1123 WRITE_NODE_TYPE("MATERIALPATH");
1125 _outPathInfo(str, (Path *) node);
1127 WRITE_NODE_FIELD(subpath);
1131 _outUniquePath(StringInfo str, UniquePath *node)
1133 WRITE_NODE_TYPE("UNIQUEPATH");
1135 _outPathInfo(str, (Path *) node);
1137 WRITE_NODE_FIELD(subpath);
1138 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1139 WRITE_FLOAT_FIELD(rows, "%.0f");
1143 _outNestPath(StringInfo str, NestPath *node)
1145 WRITE_NODE_TYPE("NESTPATH");
1147 _outJoinPathInfo(str, (JoinPath *) node);
1151 _outMergePath(StringInfo str, MergePath *node)
1153 WRITE_NODE_TYPE("MERGEPATH");
1155 _outJoinPathInfo(str, (JoinPath *) node);
1157 WRITE_NODE_FIELD(path_mergeclauses);
1158 WRITE_NODE_FIELD(outersortkeys);
1159 WRITE_NODE_FIELD(innersortkeys);
1163 _outHashPath(StringInfo str, HashPath *node)
1165 WRITE_NODE_TYPE("HASHPATH");
1167 _outJoinPathInfo(str, (JoinPath *) node);
1169 WRITE_NODE_FIELD(path_hashclauses);
1173 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1175 WRITE_NODE_TYPE("PLANNERINFO");
1177 /* NB: this isn't a complete set of fields */
1178 WRITE_NODE_FIELD(parse);
1179 WRITE_NODE_FIELD(join_rel_list);
1180 WRITE_NODE_FIELD(equi_key_list);
1181 WRITE_NODE_FIELD(left_join_clauses);
1182 WRITE_NODE_FIELD(right_join_clauses);
1183 WRITE_NODE_FIELD(full_join_clauses);
1184 WRITE_NODE_FIELD(oj_info_list);
1185 WRITE_NODE_FIELD(in_info_list);
1186 WRITE_NODE_FIELD(append_rel_list);
1187 WRITE_NODE_FIELD(query_pathkeys);
1188 WRITE_NODE_FIELD(group_pathkeys);
1189 WRITE_NODE_FIELD(sort_pathkeys);
1190 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1191 WRITE_BOOL_FIELD(hasJoinRTEs);
1192 WRITE_BOOL_FIELD(hasOuterJoins);
1193 WRITE_BOOL_FIELD(hasHavingQual);
1194 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1198 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1200 WRITE_NODE_TYPE("RELOPTINFO");
1202 /* NB: this isn't a complete set of fields */
1203 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1204 WRITE_BITMAPSET_FIELD(relids);
1205 WRITE_FLOAT_FIELD(rows, "%.0f");
1206 WRITE_INT_FIELD(width);
1207 WRITE_NODE_FIELD(reltargetlist);
1208 WRITE_NODE_FIELD(pathlist);
1209 WRITE_NODE_FIELD(cheapest_startup_path);
1210 WRITE_NODE_FIELD(cheapest_total_path);
1211 WRITE_NODE_FIELD(cheapest_unique_path);
1212 WRITE_UINT_FIELD(relid);
1213 WRITE_ENUM_FIELD(rtekind, RTEKind);
1214 WRITE_INT_FIELD(min_attr);
1215 WRITE_INT_FIELD(max_attr);
1216 WRITE_NODE_FIELD(indexlist);
1217 WRITE_UINT_FIELD(pages);
1218 WRITE_FLOAT_FIELD(tuples, "%.0f");
1219 WRITE_NODE_FIELD(subplan);
1220 WRITE_NODE_FIELD(baserestrictinfo);
1221 WRITE_NODE_FIELD(joininfo);
1222 WRITE_BITMAPSET_FIELD(index_outer_relids);
1223 WRITE_NODE_FIELD(index_inner_paths);
1227 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1229 WRITE_NODE_TYPE("INDEXOPTINFO");
1231 /* NB: this isn't a complete set of fields */
1232 WRITE_OID_FIELD(indexoid);
1233 /* Do NOT print rel field, else infinite recursion */
1234 WRITE_UINT_FIELD(pages);
1235 WRITE_FLOAT_FIELD(tuples, "%.0f");
1236 WRITE_INT_FIELD(ncolumns);
1237 WRITE_NODE_FIELD(indexprs);
1238 WRITE_NODE_FIELD(indpred);
1239 WRITE_BOOL_FIELD(predOK);
1240 WRITE_BOOL_FIELD(unique);
1244 _outPathKeyItem(StringInfo str, PathKeyItem *node)
1246 WRITE_NODE_TYPE("PATHKEYITEM");
1248 WRITE_NODE_FIELD(key);
1249 WRITE_OID_FIELD(sortop);
1253 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1255 WRITE_NODE_TYPE("RESTRICTINFO");
1257 /* NB: this isn't a complete set of fields */
1258 WRITE_NODE_FIELD(clause);
1259 WRITE_BOOL_FIELD(is_pushed_down);
1260 WRITE_BOOL_FIELD(outerjoin_delayed);
1261 WRITE_BOOL_FIELD(can_join);
1262 WRITE_BOOL_FIELD(pseudoconstant);
1263 WRITE_BITMAPSET_FIELD(clause_relids);
1264 WRITE_BITMAPSET_FIELD(required_relids);
1265 WRITE_BITMAPSET_FIELD(left_relids);
1266 WRITE_BITMAPSET_FIELD(right_relids);
1267 WRITE_NODE_FIELD(orclause);
1268 WRITE_OID_FIELD(mergejoinoperator);
1269 WRITE_OID_FIELD(left_sortop);
1270 WRITE_OID_FIELD(right_sortop);
1271 WRITE_NODE_FIELD(left_pathkey);
1272 WRITE_NODE_FIELD(right_pathkey);
1273 WRITE_OID_FIELD(hashjoinoperator);
1277 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1279 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1280 WRITE_BITMAPSET_FIELD(other_relids);
1281 WRITE_BOOL_FIELD(isouterjoin);
1282 WRITE_NODE_FIELD(best_innerpath);
1286 _outOuterJoinInfo(StringInfo str, OuterJoinInfo *node)
1288 WRITE_NODE_TYPE("OUTERJOININFO");
1290 WRITE_BITMAPSET_FIELD(min_lefthand);
1291 WRITE_BITMAPSET_FIELD(min_righthand);
1292 WRITE_BOOL_FIELD(is_full_join);
1293 WRITE_BOOL_FIELD(lhs_strict);
1297 _outInClauseInfo(StringInfo str, InClauseInfo *node)
1299 WRITE_NODE_TYPE("INCLAUSEINFO");
1301 WRITE_BITMAPSET_FIELD(lefthand);
1302 WRITE_BITMAPSET_FIELD(righthand);
1303 WRITE_NODE_FIELD(sub_targetlist);
1307 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1309 WRITE_NODE_TYPE("APPENDRELINFO");
1311 WRITE_UINT_FIELD(parent_relid);
1312 WRITE_UINT_FIELD(child_relid);
1313 WRITE_OID_FIELD(parent_reltype);
1314 WRITE_OID_FIELD(child_reltype);
1315 WRITE_NODE_FIELD(col_mappings);
1316 WRITE_NODE_FIELD(translated_vars);
1317 WRITE_OID_FIELD(parent_reloid);
1320 /*****************************************************************************
1322 * Stuff from parsenodes.h.
1324 *****************************************************************************/
1327 _outCreateStmt(StringInfo str, CreateStmt *node)
1329 WRITE_NODE_TYPE("CREATESTMT");
1331 WRITE_NODE_FIELD(relation);
1332 WRITE_NODE_FIELD(tableElts);
1333 WRITE_NODE_FIELD(inhRelations);
1334 WRITE_NODE_FIELD(constraints);
1335 WRITE_NODE_FIELD(options);
1336 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1337 WRITE_STRING_FIELD(tablespacename);
1341 _outIndexStmt(StringInfo str, IndexStmt *node)
1343 WRITE_NODE_TYPE("INDEXSTMT");
1345 WRITE_STRING_FIELD(idxname);
1346 WRITE_NODE_FIELD(relation);
1347 WRITE_STRING_FIELD(accessMethod);
1348 WRITE_STRING_FIELD(tableSpace);
1349 WRITE_NODE_FIELD(indexParams);
1350 WRITE_NODE_FIELD(options);
1351 WRITE_NODE_FIELD(whereClause);
1352 WRITE_NODE_FIELD(rangetable);
1353 WRITE_BOOL_FIELD(unique);
1354 WRITE_BOOL_FIELD(primary);
1355 WRITE_BOOL_FIELD(isconstraint);
1359 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1361 WRITE_NODE_TYPE("NOTIFY");
1363 WRITE_NODE_FIELD(relation);
1367 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1369 WRITE_NODE_TYPE("DECLARECURSOR");
1371 WRITE_STRING_FIELD(portalname);
1372 WRITE_INT_FIELD(options);
1373 WRITE_NODE_FIELD(query);
1377 _outSelectStmt(StringInfo str, SelectStmt *node)
1379 WRITE_NODE_TYPE("SELECT");
1381 WRITE_NODE_FIELD(distinctClause);
1382 WRITE_NODE_FIELD(into);
1383 WRITE_NODE_FIELD(intoColNames);
1384 WRITE_NODE_FIELD(intoOptions);
1385 WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
1386 WRITE_STRING_FIELD(intoTableSpaceName);
1387 WRITE_NODE_FIELD(targetList);
1388 WRITE_NODE_FIELD(fromClause);
1389 WRITE_NODE_FIELD(whereClause);
1390 WRITE_NODE_FIELD(groupClause);
1391 WRITE_NODE_FIELD(havingClause);
1392 WRITE_NODE_FIELD(valuesLists);
1393 WRITE_NODE_FIELD(sortClause);
1394 WRITE_NODE_FIELD(limitOffset);
1395 WRITE_NODE_FIELD(limitCount);
1396 WRITE_NODE_FIELD(lockingClause);
1397 WRITE_ENUM_FIELD(op, SetOperation);
1398 WRITE_BOOL_FIELD(all);
1399 WRITE_NODE_FIELD(larg);
1400 WRITE_NODE_FIELD(rarg);
1404 _outFuncCall(StringInfo str, FuncCall *node)
1406 WRITE_NODE_TYPE("FUNCCALL");
1408 WRITE_NODE_FIELD(funcname);
1409 WRITE_NODE_FIELD(args);
1410 WRITE_BOOL_FIELD(agg_star);
1411 WRITE_BOOL_FIELD(agg_distinct);
1412 WRITE_INT_FIELD(location);
1416 _outDefElem(StringInfo str, DefElem *node)
1418 WRITE_NODE_TYPE("DEFELEM");
1420 WRITE_STRING_FIELD(defname);
1421 WRITE_NODE_FIELD(arg);
1425 _outLockingClause(StringInfo str, LockingClause *node)
1427 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1429 WRITE_NODE_FIELD(lockedRels);
1430 WRITE_BOOL_FIELD(forUpdate);
1431 WRITE_BOOL_FIELD(noWait);
1435 _outColumnDef(StringInfo str, ColumnDef *node)
1437 WRITE_NODE_TYPE("COLUMNDEF");
1439 WRITE_STRING_FIELD(colname);
1440 WRITE_NODE_FIELD(typename);
1441 WRITE_INT_FIELD(inhcount);
1442 WRITE_BOOL_FIELD(is_local);
1443 WRITE_BOOL_FIELD(is_not_null);
1444 WRITE_NODE_FIELD(raw_default);
1445 WRITE_STRING_FIELD(cooked_default);
1446 WRITE_NODE_FIELD(constraints);
1447 WRITE_NODE_FIELD(support);
1451 _outTypeName(StringInfo str, TypeName *node)
1453 WRITE_NODE_TYPE("TYPENAME");
1455 WRITE_NODE_FIELD(names);
1456 WRITE_OID_FIELD(typeid);
1457 WRITE_BOOL_FIELD(timezone);
1458 WRITE_BOOL_FIELD(setof);
1459 WRITE_BOOL_FIELD(pct_type);
1460 WRITE_INT_FIELD(typmod);
1461 WRITE_NODE_FIELD(arrayBounds);
1462 WRITE_INT_FIELD(location);
1466 _outTypeCast(StringInfo str, TypeCast *node)
1468 WRITE_NODE_TYPE("TYPECAST");
1470 WRITE_NODE_FIELD(arg);
1471 WRITE_NODE_FIELD(typename);
1475 _outIndexElem(StringInfo str, IndexElem *node)
1477 WRITE_NODE_TYPE("INDEXELEM");
1479 WRITE_STRING_FIELD(name);
1480 WRITE_NODE_FIELD(expr);
1481 WRITE_NODE_FIELD(opclass);
1485 _outQuery(StringInfo str, Query *node)
1487 WRITE_NODE_TYPE("QUERY");
1489 WRITE_ENUM_FIELD(commandType, CmdType);
1490 WRITE_ENUM_FIELD(querySource, QuerySource);
1491 WRITE_BOOL_FIELD(canSetTag);
1494 * Hack to work around missing outfuncs routines for a lot of the
1495 * utility-statement node types. (The only one we actually *need* for
1496 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1497 * for the meantime do this to avoid getting lots of warnings when running
1498 * with debug_print_parse on.
1500 if (node->utilityStmt)
1502 switch (nodeTag(node->utilityStmt))
1507 case T_DeclareCursorStmt:
1508 WRITE_NODE_FIELD(utilityStmt);
1511 appendStringInfo(str, " :utilityStmt ?");
1516 appendStringInfo(str, " :utilityStmt <>");
1518 WRITE_INT_FIELD(resultRelation);
1519 WRITE_NODE_FIELD(into);
1520 WRITE_NODE_FIELD(intoOptions);
1521 WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
1522 WRITE_STRING_FIELD(intoTableSpaceName);
1523 WRITE_BOOL_FIELD(hasAggs);
1524 WRITE_BOOL_FIELD(hasSubLinks);
1525 WRITE_NODE_FIELD(rtable);
1526 WRITE_NODE_FIELD(jointree);
1527 WRITE_NODE_FIELD(targetList);
1528 WRITE_NODE_FIELD(returningList);
1529 WRITE_NODE_FIELD(groupClause);
1530 WRITE_NODE_FIELD(havingQual);
1531 WRITE_NODE_FIELD(distinctClause);
1532 WRITE_NODE_FIELD(sortClause);
1533 WRITE_NODE_FIELD(limitOffset);
1534 WRITE_NODE_FIELD(limitCount);
1535 WRITE_NODE_FIELD(rowMarks);
1536 WRITE_NODE_FIELD(setOperations);
1537 WRITE_NODE_FIELD(resultRelations);
1538 WRITE_NODE_FIELD(returningLists);
1542 _outSortClause(StringInfo str, SortClause *node)
1544 WRITE_NODE_TYPE("SORTCLAUSE");
1546 WRITE_UINT_FIELD(tleSortGroupRef);
1547 WRITE_OID_FIELD(sortop);
1551 _outGroupClause(StringInfo str, GroupClause *node)
1553 WRITE_NODE_TYPE("GROUPCLAUSE");
1555 WRITE_UINT_FIELD(tleSortGroupRef);
1556 WRITE_OID_FIELD(sortop);
1560 _outRowMarkClause(StringInfo str, RowMarkClause *node)
1562 WRITE_NODE_TYPE("ROWMARKCLAUSE");
1564 WRITE_UINT_FIELD(rti);
1565 WRITE_BOOL_FIELD(forUpdate);
1566 WRITE_BOOL_FIELD(noWait);
1570 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
1572 WRITE_NODE_TYPE("SETOPERATIONSTMT");
1574 WRITE_ENUM_FIELD(op, SetOperation);
1575 WRITE_BOOL_FIELD(all);
1576 WRITE_NODE_FIELD(larg);
1577 WRITE_NODE_FIELD(rarg);
1578 WRITE_NODE_FIELD(colTypes);
1579 WRITE_NODE_FIELD(colTypmods);
1583 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
1585 WRITE_NODE_TYPE("RTE");
1587 /* put alias + eref first to make dump more legible */
1588 WRITE_NODE_FIELD(alias);
1589 WRITE_NODE_FIELD(eref);
1590 WRITE_ENUM_FIELD(rtekind, RTEKind);
1592 switch (node->rtekind)
1596 WRITE_OID_FIELD(relid);
1599 WRITE_NODE_FIELD(subquery);
1602 WRITE_NODE_FIELD(funcexpr);
1603 WRITE_NODE_FIELD(funccoltypes);
1604 WRITE_NODE_FIELD(funccoltypmods);
1607 WRITE_NODE_FIELD(values_lists);
1610 WRITE_ENUM_FIELD(jointype, JoinType);
1611 WRITE_NODE_FIELD(joinaliasvars);
1614 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
1618 WRITE_BOOL_FIELD(inh);
1619 WRITE_BOOL_FIELD(inFromCl);
1620 WRITE_UINT_FIELD(requiredPerms);
1621 WRITE_OID_FIELD(checkAsUser);
1625 _outAExpr(StringInfo str, A_Expr *node)
1627 WRITE_NODE_TYPE("AEXPR");
1632 appendStringInfo(str, " ");
1633 WRITE_NODE_FIELD(name);
1636 appendStringInfo(str, " AND");
1639 appendStringInfo(str, " OR");
1642 appendStringInfo(str, " NOT");
1645 appendStringInfo(str, " ");
1646 WRITE_NODE_FIELD(name);
1647 appendStringInfo(str, " ANY ");
1650 appendStringInfo(str, " ");
1651 WRITE_NODE_FIELD(name);
1652 appendStringInfo(str, " ALL ");
1654 case AEXPR_DISTINCT:
1655 appendStringInfo(str, " DISTINCT ");
1656 WRITE_NODE_FIELD(name);
1659 appendStringInfo(str, " NULLIF ");
1660 WRITE_NODE_FIELD(name);
1663 appendStringInfo(str, " OF ");
1664 WRITE_NODE_FIELD(name);
1667 appendStringInfo(str, " IN ");
1668 WRITE_NODE_FIELD(name);
1671 appendStringInfo(str, " ??");
1675 WRITE_NODE_FIELD(lexpr);
1676 WRITE_NODE_FIELD(rexpr);
1677 WRITE_INT_FIELD(location);
1681 _outValue(StringInfo str, Value *value)
1683 switch (value->type)
1686 appendStringInfo(str, "%ld", value->val.ival);
1691 * We assume the value is a valid numeric literal and so does not
1694 appendStringInfoString(str, value->val.str);
1697 appendStringInfoChar(str, '"');
1698 _outToken(str, value->val.str);
1699 appendStringInfoChar(str, '"');
1702 /* internal representation already has leading 'b' */
1703 appendStringInfoString(str, value->val.str);
1706 elog(ERROR, "unrecognized node type: %d", (int) value->type);
1712 _outColumnRef(StringInfo str, ColumnRef *node)
1714 WRITE_NODE_TYPE("COLUMNREF");
1716 WRITE_NODE_FIELD(fields);
1717 WRITE_INT_FIELD(location);
1721 _outParamRef(StringInfo str, ParamRef *node)
1723 WRITE_NODE_TYPE("PARAMREF");
1725 WRITE_INT_FIELD(number);
1729 _outAConst(StringInfo str, A_Const *node)
1731 WRITE_NODE_TYPE("A_CONST");
1733 appendStringInfo(str, " :val ");
1734 _outValue(str, &(node->val));
1735 WRITE_NODE_FIELD(typename);
1739 _outA_Indices(StringInfo str, A_Indices *node)
1741 WRITE_NODE_TYPE("A_INDICES");
1743 WRITE_NODE_FIELD(lidx);
1744 WRITE_NODE_FIELD(uidx);
1748 _outA_Indirection(StringInfo str, A_Indirection *node)
1750 WRITE_NODE_TYPE("A_INDIRECTION");
1752 WRITE_NODE_FIELD(arg);
1753 WRITE_NODE_FIELD(indirection);
1757 _outResTarget(StringInfo str, ResTarget *node)
1759 WRITE_NODE_TYPE("RESTARGET");
1761 WRITE_STRING_FIELD(name);
1762 WRITE_NODE_FIELD(indirection);
1763 WRITE_NODE_FIELD(val);
1764 WRITE_INT_FIELD(location);
1768 _outConstraint(StringInfo str, Constraint *node)
1770 WRITE_NODE_TYPE("CONSTRAINT");
1772 WRITE_STRING_FIELD(name);
1774 appendStringInfo(str, " :contype ");
1775 switch (node->contype)
1777 case CONSTR_PRIMARY:
1778 appendStringInfo(str, "PRIMARY_KEY");
1779 WRITE_NODE_FIELD(keys);
1780 WRITE_NODE_FIELD(options);
1781 WRITE_STRING_FIELD(indexspace);
1785 appendStringInfo(str, "UNIQUE");
1786 WRITE_NODE_FIELD(keys);
1787 WRITE_NODE_FIELD(options);
1788 WRITE_STRING_FIELD(indexspace);
1792 appendStringInfo(str, "CHECK");
1793 WRITE_NODE_FIELD(raw_expr);
1794 WRITE_STRING_FIELD(cooked_expr);
1797 case CONSTR_DEFAULT:
1798 appendStringInfo(str, "DEFAULT");
1799 WRITE_NODE_FIELD(raw_expr);
1800 WRITE_STRING_FIELD(cooked_expr);
1803 case CONSTR_NOTNULL:
1804 appendStringInfo(str, "NOT_NULL");
1808 appendStringInfo(str, "<unrecognized_constraint>");
1814 _outFkConstraint(StringInfo str, FkConstraint *node)
1816 WRITE_NODE_TYPE("FKCONSTRAINT");
1818 WRITE_STRING_FIELD(constr_name);
1819 WRITE_NODE_FIELD(pktable);
1820 WRITE_NODE_FIELD(fk_attrs);
1821 WRITE_NODE_FIELD(pk_attrs);
1822 WRITE_CHAR_FIELD(fk_matchtype);
1823 WRITE_CHAR_FIELD(fk_upd_action);
1824 WRITE_CHAR_FIELD(fk_del_action);
1825 WRITE_BOOL_FIELD(deferrable);
1826 WRITE_BOOL_FIELD(initdeferred);
1827 WRITE_BOOL_FIELD(skip_validation);
1833 * converts a Node into ascii string and append it to 'str'
1836 _outNode(StringInfo str, void *obj)
1839 appendStringInfo(str, "<>");
1840 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
1842 else if (IsA(obj, Integer) ||
1845 IsA(obj, BitString))
1847 /* nodeRead does not want to see { } around these! */
1848 _outValue(str, obj);
1852 appendStringInfoChar(str, '{');
1853 switch (nodeTag(obj))
1859 _outResult(str, obj);
1862 _outAppend(str, obj);
1865 _outBitmapAnd(str, obj);
1868 _outBitmapOr(str, obj);
1874 _outSeqScan(str, obj);
1877 _outIndexScan(str, obj);
1879 case T_BitmapIndexScan:
1880 _outBitmapIndexScan(str, obj);
1882 case T_BitmapHeapScan:
1883 _outBitmapHeapScan(str, obj);
1886 _outTidScan(str, obj);
1888 case T_SubqueryScan:
1889 _outSubqueryScan(str, obj);
1891 case T_FunctionScan:
1892 _outFunctionScan(str, obj);
1895 _outValuesScan(str, obj);
1901 _outNestLoop(str, obj);
1904 _outMergeJoin(str, obj);
1907 _outHashJoin(str, obj);
1913 _outGroup(str, obj);
1916 _outMaterial(str, obj);
1922 _outUnique(str, obj);
1925 _outSetOp(str, obj);
1928 _outLimit(str, obj);
1934 _outAlias(str, obj);
1937 _outRangeVar(str, obj);
1943 _outConst(str, obj);
1946 _outParam(str, obj);
1949 _outAggref(str, obj);
1952 _outArrayRef(str, obj);
1955 _outFuncExpr(str, obj);
1958 _outOpExpr(str, obj);
1960 case T_DistinctExpr:
1961 _outDistinctExpr(str, obj);
1963 case T_ScalarArrayOpExpr:
1964 _outScalarArrayOpExpr(str, obj);
1967 _outBoolExpr(str, obj);
1970 _outSubLink(str, obj);
1973 _outSubPlan(str, obj);
1976 _outFieldSelect(str, obj);
1979 _outFieldStore(str, obj);
1982 _outRelabelType(str, obj);
1984 case T_ConvertRowtypeExpr:
1985 _outConvertRowtypeExpr(str, obj);
1988 _outCaseExpr(str, obj);
1991 _outCaseWhen(str, obj);
1993 case T_CaseTestExpr:
1994 _outCaseTestExpr(str, obj);
1997 _outArrayExpr(str, obj);
2000 _outRowExpr(str, obj);
2002 case T_RowCompareExpr:
2003 _outRowCompareExpr(str, obj);
2005 case T_CoalesceExpr:
2006 _outCoalesceExpr(str, obj);
2009 _outMinMaxExpr(str, obj);
2012 _outNullIfExpr(str, obj);
2015 _outNullTest(str, obj);
2018 _outBooleanTest(str, obj);
2020 case T_CoerceToDomain:
2021 _outCoerceToDomain(str, obj);
2023 case T_CoerceToDomainValue:
2024 _outCoerceToDomainValue(str, obj);
2026 case T_SetToDefault:
2027 _outSetToDefault(str, obj);
2030 _outTargetEntry(str, obj);
2033 _outRangeTblRef(str, obj);
2036 _outJoinExpr(str, obj);
2039 _outFromExpr(str, obj);
2046 _outIndexPath(str, obj);
2048 case T_BitmapHeapPath:
2049 _outBitmapHeapPath(str, obj);
2051 case T_BitmapAndPath:
2052 _outBitmapAndPath(str, obj);
2054 case T_BitmapOrPath:
2055 _outBitmapOrPath(str, obj);
2058 _outTidPath(str, obj);
2061 _outAppendPath(str, obj);
2064 _outResultPath(str, obj);
2066 case T_MaterialPath:
2067 _outMaterialPath(str, obj);
2070 _outUniquePath(str, obj);
2073 _outNestPath(str, obj);
2076 _outMergePath(str, obj);
2079 _outHashPath(str, obj);
2082 _outPlannerInfo(str, obj);
2085 _outRelOptInfo(str, obj);
2087 case T_IndexOptInfo:
2088 _outIndexOptInfo(str, obj);
2091 _outPathKeyItem(str, obj);
2093 case T_RestrictInfo:
2094 _outRestrictInfo(str, obj);
2096 case T_InnerIndexscanInfo:
2097 _outInnerIndexscanInfo(str, obj);
2099 case T_OuterJoinInfo:
2100 _outOuterJoinInfo(str, obj);
2102 case T_InClauseInfo:
2103 _outInClauseInfo(str, obj);
2105 case T_AppendRelInfo:
2106 _outAppendRelInfo(str, obj);
2110 _outCreateStmt(str, obj);
2113 _outIndexStmt(str, obj);
2116 _outNotifyStmt(str, obj);
2118 case T_DeclareCursorStmt:
2119 _outDeclareCursorStmt(str, obj);
2122 _outSelectStmt(str, obj);
2125 _outColumnDef(str, obj);
2128 _outTypeName(str, obj);
2131 _outTypeCast(str, obj);
2134 _outIndexElem(str, obj);
2137 _outQuery(str, obj);
2140 _outSortClause(str, obj);
2143 _outGroupClause(str, obj);
2145 case T_RowMarkClause:
2146 _outRowMarkClause(str, obj);
2148 case T_SetOperationStmt:
2149 _outSetOperationStmt(str, obj);
2151 case T_RangeTblEntry:
2152 _outRangeTblEntry(str, obj);
2155 _outAExpr(str, obj);
2158 _outColumnRef(str, obj);
2161 _outParamRef(str, obj);
2164 _outAConst(str, obj);
2167 _outA_Indices(str, obj);
2169 case T_A_Indirection:
2170 _outA_Indirection(str, obj);
2173 _outResTarget(str, obj);
2176 _outConstraint(str, obj);
2178 case T_FkConstraint:
2179 _outFkConstraint(str, obj);
2182 _outFuncCall(str, obj);
2185 _outDefElem(str, obj);
2187 case T_LockingClause:
2188 _outLockingClause(str, obj);
2194 * This should be an ERROR, but it's too useful to be able to
2195 * dump structures that _outNode only understands part of.
2197 elog(WARNING, "could not dump unrecognized node type: %d",
2198 (int) nodeTag(obj));
2201 appendStringInfoChar(str, '}');
2207 * returns the ascii representation of the Node as a palloc'd string
2210 nodeToString(void *obj)
2214 /* see stringinfo.h for an explanation of this maneuver */
2215 initStringInfo(&str);
2216 _outNode(&str, obj);