1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2007, 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.293 2007/01/10 18:06:03 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)
443 WRITE_NODE_TYPE("MERGEJOIN");
445 _outJoinPlanInfo(str, (Join *) node);
447 WRITE_NODE_FIELD(mergeclauses);
449 numCols = list_length(node->mergeclauses);
451 appendStringInfo(str, " :mergeFamilies");
452 for (i = 0; i < numCols; i++)
453 appendStringInfo(str, " %u", node->mergeFamilies[i]);
455 appendStringInfo(str, " :mergeStrategies");
456 for (i = 0; i < numCols; i++)
457 appendStringInfo(str, " %d", node->mergeStrategies[i]);
459 appendStringInfo(str, " :mergeNullsFirst");
460 for (i = 0; i < numCols; i++)
461 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
465 _outHashJoin(StringInfo str, HashJoin *node)
467 WRITE_NODE_TYPE("HASHJOIN");
469 _outJoinPlanInfo(str, (Join *) node);
471 WRITE_NODE_FIELD(hashclauses);
475 _outAgg(StringInfo str, Agg *node)
477 WRITE_NODE_TYPE("AGG");
479 _outPlanInfo(str, (Plan *) node);
481 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
482 WRITE_INT_FIELD(numCols);
483 WRITE_LONG_FIELD(numGroups);
487 _outGroup(StringInfo str, Group *node)
491 WRITE_NODE_TYPE("GROUP");
493 _outPlanInfo(str, (Plan *) node);
495 WRITE_INT_FIELD(numCols);
497 appendStringInfo(str, " :grpColIdx");
498 for (i = 0; i < node->numCols; i++)
499 appendStringInfo(str, " %d", node->grpColIdx[i]);
501 appendStringInfo(str, " :grpOperators");
502 for (i = 0; i < node->numCols; i++)
503 appendStringInfo(str, " %u", node->grpOperators[i]);
507 _outMaterial(StringInfo str, Material *node)
509 WRITE_NODE_TYPE("MATERIAL");
511 _outPlanInfo(str, (Plan *) node);
515 _outSort(StringInfo str, Sort *node)
519 WRITE_NODE_TYPE("SORT");
521 _outPlanInfo(str, (Plan *) node);
523 WRITE_INT_FIELD(numCols);
525 appendStringInfo(str, " :sortColIdx");
526 for (i = 0; i < node->numCols; i++)
527 appendStringInfo(str, " %d", node->sortColIdx[i]);
529 appendStringInfo(str, " :sortOperators");
530 for (i = 0; i < node->numCols; i++)
531 appendStringInfo(str, " %u", node->sortOperators[i]);
533 appendStringInfo(str, " :nullsFirst");
534 for (i = 0; i < node->numCols; i++)
535 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
539 _outUnique(StringInfo str, Unique *node)
543 WRITE_NODE_TYPE("UNIQUE");
545 _outPlanInfo(str, (Plan *) node);
547 WRITE_INT_FIELD(numCols);
549 appendStringInfo(str, " :uniqColIdx");
550 for (i = 0; i < node->numCols; i++)
551 appendStringInfo(str, " %d", node->uniqColIdx[i]);
553 appendStringInfo(str, " :uniqOperators");
554 for (i = 0; i < node->numCols; i++)
555 appendStringInfo(str, " %u", node->uniqOperators[i]);
559 _outSetOp(StringInfo str, SetOp *node)
563 WRITE_NODE_TYPE("SETOP");
565 _outPlanInfo(str, (Plan *) node);
567 WRITE_ENUM_FIELD(cmd, SetOpCmd);
568 WRITE_INT_FIELD(numCols);
570 appendStringInfo(str, " :dupColIdx");
571 for (i = 0; i < node->numCols; i++)
572 appendStringInfo(str, " %d", node->dupColIdx[i]);
574 appendStringInfo(str, " :dupOperators");
575 for (i = 0; i < node->numCols; i++)
576 appendStringInfo(str, " %d", node->dupOperators[i]);
578 WRITE_INT_FIELD(flagColIdx);
582 _outLimit(StringInfo str, Limit *node)
584 WRITE_NODE_TYPE("LIMIT");
586 _outPlanInfo(str, (Plan *) node);
588 WRITE_NODE_FIELD(limitOffset);
589 WRITE_NODE_FIELD(limitCount);
593 _outHash(StringInfo str, Hash *node)
595 WRITE_NODE_TYPE("HASH");
597 _outPlanInfo(str, (Plan *) node);
600 /*****************************************************************************
602 * Stuff from primnodes.h.
604 *****************************************************************************/
607 _outAlias(StringInfo str, Alias *node)
609 WRITE_NODE_TYPE("ALIAS");
611 WRITE_STRING_FIELD(aliasname);
612 WRITE_NODE_FIELD(colnames);
616 _outRangeVar(StringInfo str, RangeVar *node)
618 WRITE_NODE_TYPE("RANGEVAR");
621 * we deliberately ignore catalogname here, since it is presently not
622 * semantically meaningful
624 WRITE_STRING_FIELD(schemaname);
625 WRITE_STRING_FIELD(relname);
626 WRITE_ENUM_FIELD(inhOpt, InhOption);
627 WRITE_BOOL_FIELD(istemp);
628 WRITE_NODE_FIELD(alias);
632 _outVar(StringInfo str, Var *node)
634 WRITE_NODE_TYPE("VAR");
636 WRITE_UINT_FIELD(varno);
637 WRITE_INT_FIELD(varattno);
638 WRITE_OID_FIELD(vartype);
639 WRITE_INT_FIELD(vartypmod);
640 WRITE_UINT_FIELD(varlevelsup);
641 WRITE_UINT_FIELD(varnoold);
642 WRITE_INT_FIELD(varoattno);
646 _outConst(StringInfo str, Const *node)
648 WRITE_NODE_TYPE("CONST");
650 WRITE_OID_FIELD(consttype);
651 WRITE_INT_FIELD(constlen);
652 WRITE_BOOL_FIELD(constbyval);
653 WRITE_BOOL_FIELD(constisnull);
655 appendStringInfo(str, " :constvalue ");
656 if (node->constisnull)
657 appendStringInfo(str, "<>");
659 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
663 _outParam(StringInfo str, Param *node)
665 WRITE_NODE_TYPE("PARAM");
667 WRITE_ENUM_FIELD(paramkind, ParamKind);
668 WRITE_INT_FIELD(paramid);
669 WRITE_OID_FIELD(paramtype);
670 WRITE_INT_FIELD(paramtypmod);
674 _outAggref(StringInfo str, Aggref *node)
676 WRITE_NODE_TYPE("AGGREF");
678 WRITE_OID_FIELD(aggfnoid);
679 WRITE_OID_FIELD(aggtype);
680 WRITE_NODE_FIELD(args);
681 WRITE_UINT_FIELD(agglevelsup);
682 WRITE_BOOL_FIELD(aggstar);
683 WRITE_BOOL_FIELD(aggdistinct);
687 _outArrayRef(StringInfo str, ArrayRef *node)
689 WRITE_NODE_TYPE("ARRAYREF");
691 WRITE_OID_FIELD(refrestype);
692 WRITE_OID_FIELD(refarraytype);
693 WRITE_OID_FIELD(refelemtype);
694 WRITE_NODE_FIELD(refupperindexpr);
695 WRITE_NODE_FIELD(reflowerindexpr);
696 WRITE_NODE_FIELD(refexpr);
697 WRITE_NODE_FIELD(refassgnexpr);
701 _outFuncExpr(StringInfo str, FuncExpr *node)
703 WRITE_NODE_TYPE("FUNCEXPR");
705 WRITE_OID_FIELD(funcid);
706 WRITE_OID_FIELD(funcresulttype);
707 WRITE_BOOL_FIELD(funcretset);
708 WRITE_ENUM_FIELD(funcformat, CoercionForm);
709 WRITE_NODE_FIELD(args);
713 _outOpExpr(StringInfo str, OpExpr *node)
715 WRITE_NODE_TYPE("OPEXPR");
717 WRITE_OID_FIELD(opno);
718 WRITE_OID_FIELD(opfuncid);
719 WRITE_OID_FIELD(opresulttype);
720 WRITE_BOOL_FIELD(opretset);
721 WRITE_NODE_FIELD(args);
725 _outDistinctExpr(StringInfo str, DistinctExpr *node)
727 WRITE_NODE_TYPE("DISTINCTEXPR");
729 WRITE_OID_FIELD(opno);
730 WRITE_OID_FIELD(opfuncid);
731 WRITE_OID_FIELD(opresulttype);
732 WRITE_BOOL_FIELD(opretset);
733 WRITE_NODE_FIELD(args);
737 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
739 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
741 WRITE_OID_FIELD(opno);
742 WRITE_OID_FIELD(opfuncid);
743 WRITE_BOOL_FIELD(useOr);
744 WRITE_NODE_FIELD(args);
748 _outBoolExpr(StringInfo str, BoolExpr *node)
752 WRITE_NODE_TYPE("BOOLEXPR");
754 /* do-it-yourself enum representation */
755 switch (node->boolop)
767 appendStringInfo(str, " :boolop ");
768 _outToken(str, opstr);
770 WRITE_NODE_FIELD(args);
774 _outSubLink(StringInfo str, SubLink *node)
776 WRITE_NODE_TYPE("SUBLINK");
778 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
779 WRITE_NODE_FIELD(testexpr);
780 WRITE_NODE_FIELD(operName);
781 WRITE_NODE_FIELD(subselect);
785 _outSubPlan(StringInfo str, SubPlan *node)
787 WRITE_NODE_TYPE("SUBPLAN");
789 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
790 WRITE_NODE_FIELD(testexpr);
791 WRITE_NODE_FIELD(paramIds);
792 WRITE_NODE_FIELD(plan);
793 WRITE_INT_FIELD(plan_id);
794 WRITE_NODE_FIELD(rtable);
795 WRITE_BOOL_FIELD(useHashTable);
796 WRITE_BOOL_FIELD(unknownEqFalse);
797 WRITE_NODE_FIELD(setParam);
798 WRITE_NODE_FIELD(parParam);
799 WRITE_NODE_FIELD(args);
803 _outFieldSelect(StringInfo str, FieldSelect *node)
805 WRITE_NODE_TYPE("FIELDSELECT");
807 WRITE_NODE_FIELD(arg);
808 WRITE_INT_FIELD(fieldnum);
809 WRITE_OID_FIELD(resulttype);
810 WRITE_INT_FIELD(resulttypmod);
814 _outFieldStore(StringInfo str, FieldStore *node)
816 WRITE_NODE_TYPE("FIELDSTORE");
818 WRITE_NODE_FIELD(arg);
819 WRITE_NODE_FIELD(newvals);
820 WRITE_NODE_FIELD(fieldnums);
821 WRITE_OID_FIELD(resulttype);
825 _outRelabelType(StringInfo str, RelabelType *node)
827 WRITE_NODE_TYPE("RELABELTYPE");
829 WRITE_NODE_FIELD(arg);
830 WRITE_OID_FIELD(resulttype);
831 WRITE_INT_FIELD(resulttypmod);
832 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
836 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
838 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
840 WRITE_NODE_FIELD(arg);
841 WRITE_OID_FIELD(resulttype);
842 WRITE_ENUM_FIELD(convertformat, CoercionForm);
846 _outCaseExpr(StringInfo str, CaseExpr *node)
848 WRITE_NODE_TYPE("CASE");
850 WRITE_OID_FIELD(casetype);
851 WRITE_NODE_FIELD(arg);
852 WRITE_NODE_FIELD(args);
853 WRITE_NODE_FIELD(defresult);
857 _outCaseWhen(StringInfo str, CaseWhen *node)
859 WRITE_NODE_TYPE("WHEN");
861 WRITE_NODE_FIELD(expr);
862 WRITE_NODE_FIELD(result);
866 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
868 WRITE_NODE_TYPE("CASETESTEXPR");
870 WRITE_OID_FIELD(typeId);
871 WRITE_INT_FIELD(typeMod);
875 _outArrayExpr(StringInfo str, ArrayExpr *node)
877 WRITE_NODE_TYPE("ARRAY");
879 WRITE_OID_FIELD(array_typeid);
880 WRITE_OID_FIELD(element_typeid);
881 WRITE_NODE_FIELD(elements);
882 WRITE_BOOL_FIELD(multidims);
886 _outRowExpr(StringInfo str, RowExpr *node)
888 WRITE_NODE_TYPE("ROW");
890 WRITE_NODE_FIELD(args);
891 WRITE_OID_FIELD(row_typeid);
892 WRITE_ENUM_FIELD(row_format, CoercionForm);
896 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
898 WRITE_NODE_TYPE("ROWCOMPARE");
900 WRITE_ENUM_FIELD(rctype, RowCompareType);
901 WRITE_NODE_FIELD(opnos);
902 WRITE_NODE_FIELD(opfamilies);
903 WRITE_NODE_FIELD(largs);
904 WRITE_NODE_FIELD(rargs);
908 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
910 WRITE_NODE_TYPE("COALESCE");
912 WRITE_OID_FIELD(coalescetype);
913 WRITE_NODE_FIELD(args);
917 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
919 WRITE_NODE_TYPE("MINMAX");
921 WRITE_OID_FIELD(minmaxtype);
922 WRITE_ENUM_FIELD(op, MinMaxOp);
923 WRITE_NODE_FIELD(args);
927 _outXmlExpr(StringInfo str, XmlExpr *node)
929 WRITE_NODE_TYPE("XMLEXPR");
931 WRITE_ENUM_FIELD(op, XmlExprOp);
932 WRITE_STRING_FIELD(name);
933 WRITE_NODE_FIELD(named_args);
934 WRITE_NODE_FIELD(arg_names);
935 WRITE_NODE_FIELD(args);
939 _outNullIfExpr(StringInfo str, NullIfExpr *node)
941 WRITE_NODE_TYPE("NULLIFEXPR");
943 WRITE_OID_FIELD(opno);
944 WRITE_OID_FIELD(opfuncid);
945 WRITE_OID_FIELD(opresulttype);
946 WRITE_BOOL_FIELD(opretset);
947 WRITE_NODE_FIELD(args);
951 _outNullTest(StringInfo str, NullTest *node)
953 WRITE_NODE_TYPE("NULLTEST");
955 WRITE_NODE_FIELD(arg);
956 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
960 _outBooleanTest(StringInfo str, BooleanTest *node)
962 WRITE_NODE_TYPE("BOOLEANTEST");
964 WRITE_NODE_FIELD(arg);
965 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
969 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
971 WRITE_NODE_TYPE("COERCETODOMAIN");
973 WRITE_NODE_FIELD(arg);
974 WRITE_OID_FIELD(resulttype);
975 WRITE_INT_FIELD(resulttypmod);
976 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
980 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
982 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
984 WRITE_OID_FIELD(typeId);
985 WRITE_INT_FIELD(typeMod);
989 _outSetToDefault(StringInfo str, SetToDefault *node)
991 WRITE_NODE_TYPE("SETTODEFAULT");
993 WRITE_OID_FIELD(typeId);
994 WRITE_INT_FIELD(typeMod);
998 _outTargetEntry(StringInfo str, TargetEntry *node)
1000 WRITE_NODE_TYPE("TARGETENTRY");
1002 WRITE_NODE_FIELD(expr);
1003 WRITE_INT_FIELD(resno);
1004 WRITE_STRING_FIELD(resname);
1005 WRITE_UINT_FIELD(ressortgroupref);
1006 WRITE_OID_FIELD(resorigtbl);
1007 WRITE_INT_FIELD(resorigcol);
1008 WRITE_BOOL_FIELD(resjunk);
1012 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1014 WRITE_NODE_TYPE("RANGETBLREF");
1016 WRITE_INT_FIELD(rtindex);
1020 _outJoinExpr(StringInfo str, JoinExpr *node)
1022 WRITE_NODE_TYPE("JOINEXPR");
1024 WRITE_ENUM_FIELD(jointype, JoinType);
1025 WRITE_BOOL_FIELD(isNatural);
1026 WRITE_NODE_FIELD(larg);
1027 WRITE_NODE_FIELD(rarg);
1028 WRITE_NODE_FIELD(using);
1029 WRITE_NODE_FIELD(quals);
1030 WRITE_NODE_FIELD(alias);
1031 WRITE_INT_FIELD(rtindex);
1035 _outFromExpr(StringInfo str, FromExpr *node)
1037 WRITE_NODE_TYPE("FROMEXPR");
1039 WRITE_NODE_FIELD(fromlist);
1040 WRITE_NODE_FIELD(quals);
1043 /*****************************************************************************
1045 * Stuff from relation.h.
1047 *****************************************************************************/
1050 * print the basic stuff of all nodes that inherit from Path
1052 * Note we do NOT print the parent, else we'd be in infinite recursion
1055 _outPathInfo(StringInfo str, Path *node)
1057 WRITE_ENUM_FIELD(pathtype, NodeTag);
1058 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1059 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1060 WRITE_NODE_FIELD(pathkeys);
1064 * print the basic stuff of all nodes that inherit from JoinPath
1067 _outJoinPathInfo(StringInfo str, JoinPath *node)
1069 _outPathInfo(str, (Path *) node);
1071 WRITE_ENUM_FIELD(jointype, JoinType);
1072 WRITE_NODE_FIELD(outerjoinpath);
1073 WRITE_NODE_FIELD(innerjoinpath);
1074 WRITE_NODE_FIELD(joinrestrictinfo);
1078 _outPath(StringInfo str, Path *node)
1080 WRITE_NODE_TYPE("PATH");
1082 _outPathInfo(str, (Path *) node);
1086 _outIndexPath(StringInfo str, IndexPath *node)
1088 WRITE_NODE_TYPE("INDEXPATH");
1090 _outPathInfo(str, (Path *) node);
1092 WRITE_NODE_FIELD(indexinfo);
1093 WRITE_NODE_FIELD(indexclauses);
1094 WRITE_NODE_FIELD(indexquals);
1095 WRITE_BOOL_FIELD(isjoininner);
1096 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1097 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1098 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1099 WRITE_FLOAT_FIELD(rows, "%.0f");
1103 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1105 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1107 _outPathInfo(str, (Path *) node);
1109 WRITE_NODE_FIELD(bitmapqual);
1110 WRITE_BOOL_FIELD(isjoininner);
1111 WRITE_FLOAT_FIELD(rows, "%.0f");
1115 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1117 WRITE_NODE_TYPE("BITMAPANDPATH");
1119 _outPathInfo(str, (Path *) node);
1121 WRITE_NODE_FIELD(bitmapquals);
1122 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1126 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1128 WRITE_NODE_TYPE("BITMAPORPATH");
1130 _outPathInfo(str, (Path *) node);
1132 WRITE_NODE_FIELD(bitmapquals);
1133 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1137 _outTidPath(StringInfo str, TidPath *node)
1139 WRITE_NODE_TYPE("TIDPATH");
1141 _outPathInfo(str, (Path *) node);
1143 WRITE_NODE_FIELD(tidquals);
1147 _outAppendPath(StringInfo str, AppendPath *node)
1149 WRITE_NODE_TYPE("APPENDPATH");
1151 _outPathInfo(str, (Path *) node);
1153 WRITE_NODE_FIELD(subpaths);
1157 _outResultPath(StringInfo str, ResultPath *node)
1159 WRITE_NODE_TYPE("RESULTPATH");
1161 _outPathInfo(str, (Path *) node);
1163 WRITE_NODE_FIELD(quals);
1167 _outMaterialPath(StringInfo str, MaterialPath *node)
1169 WRITE_NODE_TYPE("MATERIALPATH");
1171 _outPathInfo(str, (Path *) node);
1173 WRITE_NODE_FIELD(subpath);
1177 _outUniquePath(StringInfo str, UniquePath *node)
1179 WRITE_NODE_TYPE("UNIQUEPATH");
1181 _outPathInfo(str, (Path *) node);
1183 WRITE_NODE_FIELD(subpath);
1184 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1185 WRITE_FLOAT_FIELD(rows, "%.0f");
1189 _outNestPath(StringInfo str, NestPath *node)
1191 WRITE_NODE_TYPE("NESTPATH");
1193 _outJoinPathInfo(str, (JoinPath *) node);
1197 _outMergePath(StringInfo str, MergePath *node)
1202 WRITE_NODE_TYPE("MERGEPATH");
1204 _outJoinPathInfo(str, (JoinPath *) node);
1206 WRITE_NODE_FIELD(path_mergeclauses);
1208 numCols = list_length(node->path_mergeclauses);
1210 appendStringInfo(str, " :path_mergeFamilies");
1211 for (i = 0; i < numCols; i++)
1212 appendStringInfo(str, " %u", node->path_mergeFamilies[i]);
1214 appendStringInfo(str, " :path_mergeStrategies");
1215 for (i = 0; i < numCols; i++)
1216 appendStringInfo(str, " %d", node->path_mergeStrategies[i]);
1218 appendStringInfo(str, " :path_mergeNullsFirst");
1219 for (i = 0; i < numCols; i++)
1220 appendStringInfo(str, " %d", (int) node->path_mergeNullsFirst[i]);
1222 WRITE_NODE_FIELD(outersortkeys);
1223 WRITE_NODE_FIELD(innersortkeys);
1227 _outHashPath(StringInfo str, HashPath *node)
1229 WRITE_NODE_TYPE("HASHPATH");
1231 _outJoinPathInfo(str, (JoinPath *) node);
1233 WRITE_NODE_FIELD(path_hashclauses);
1237 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1239 WRITE_NODE_TYPE("PLANNERINFO");
1241 /* NB: this isn't a complete set of fields */
1242 WRITE_NODE_FIELD(parse);
1243 WRITE_NODE_FIELD(join_rel_list);
1244 WRITE_NODE_FIELD(equi_key_list);
1245 WRITE_NODE_FIELD(left_join_clauses);
1246 WRITE_NODE_FIELD(right_join_clauses);
1247 WRITE_NODE_FIELD(full_join_clauses);
1248 WRITE_NODE_FIELD(oj_info_list);
1249 WRITE_NODE_FIELD(in_info_list);
1250 WRITE_NODE_FIELD(append_rel_list);
1251 WRITE_NODE_FIELD(query_pathkeys);
1252 WRITE_NODE_FIELD(group_pathkeys);
1253 WRITE_NODE_FIELD(sort_pathkeys);
1254 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1255 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1256 WRITE_BOOL_FIELD(hasJoinRTEs);
1257 WRITE_BOOL_FIELD(hasOuterJoins);
1258 WRITE_BOOL_FIELD(hasHavingQual);
1259 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1263 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1265 WRITE_NODE_TYPE("RELOPTINFO");
1267 /* NB: this isn't a complete set of fields */
1268 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1269 WRITE_BITMAPSET_FIELD(relids);
1270 WRITE_FLOAT_FIELD(rows, "%.0f");
1271 WRITE_INT_FIELD(width);
1272 WRITE_NODE_FIELD(reltargetlist);
1273 WRITE_NODE_FIELD(pathlist);
1274 WRITE_NODE_FIELD(cheapest_startup_path);
1275 WRITE_NODE_FIELD(cheapest_total_path);
1276 WRITE_NODE_FIELD(cheapest_unique_path);
1277 WRITE_UINT_FIELD(relid);
1278 WRITE_ENUM_FIELD(rtekind, RTEKind);
1279 WRITE_INT_FIELD(min_attr);
1280 WRITE_INT_FIELD(max_attr);
1281 WRITE_NODE_FIELD(indexlist);
1282 WRITE_UINT_FIELD(pages);
1283 WRITE_FLOAT_FIELD(tuples, "%.0f");
1284 WRITE_NODE_FIELD(subplan);
1285 WRITE_NODE_FIELD(baserestrictinfo);
1286 WRITE_NODE_FIELD(joininfo);
1287 WRITE_BITMAPSET_FIELD(index_outer_relids);
1288 WRITE_NODE_FIELD(index_inner_paths);
1292 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1294 WRITE_NODE_TYPE("INDEXOPTINFO");
1296 /* NB: this isn't a complete set of fields */
1297 WRITE_OID_FIELD(indexoid);
1298 /* Do NOT print rel field, else infinite recursion */
1299 WRITE_UINT_FIELD(pages);
1300 WRITE_FLOAT_FIELD(tuples, "%.0f");
1301 WRITE_INT_FIELD(ncolumns);
1302 WRITE_NODE_FIELD(indexprs);
1303 WRITE_NODE_FIELD(indpred);
1304 WRITE_BOOL_FIELD(predOK);
1305 WRITE_BOOL_FIELD(unique);
1309 _outPathKeyItem(StringInfo str, PathKeyItem *node)
1311 WRITE_NODE_TYPE("PATHKEYITEM");
1313 WRITE_NODE_FIELD(key);
1314 WRITE_OID_FIELD(sortop);
1315 WRITE_BOOL_FIELD(nulls_first);
1319 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1321 WRITE_NODE_TYPE("RESTRICTINFO");
1323 /* NB: this isn't a complete set of fields */
1324 WRITE_NODE_FIELD(clause);
1325 WRITE_BOOL_FIELD(is_pushed_down);
1326 WRITE_BOOL_FIELD(outerjoin_delayed);
1327 WRITE_BOOL_FIELD(can_join);
1328 WRITE_BOOL_FIELD(pseudoconstant);
1329 WRITE_BITMAPSET_FIELD(clause_relids);
1330 WRITE_BITMAPSET_FIELD(required_relids);
1331 WRITE_BITMAPSET_FIELD(left_relids);
1332 WRITE_BITMAPSET_FIELD(right_relids);
1333 WRITE_NODE_FIELD(orclause);
1334 WRITE_OID_FIELD(mergejoinoperator);
1335 WRITE_OID_FIELD(left_sortop);
1336 WRITE_OID_FIELD(right_sortop);
1337 WRITE_OID_FIELD(mergeopfamily);
1338 WRITE_NODE_FIELD(left_pathkey);
1339 WRITE_NODE_FIELD(right_pathkey);
1340 WRITE_OID_FIELD(hashjoinoperator);
1344 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1346 WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1347 WRITE_BITMAPSET_FIELD(other_relids);
1348 WRITE_BOOL_FIELD(isouterjoin);
1349 WRITE_NODE_FIELD(best_innerpath);
1353 _outOuterJoinInfo(StringInfo str, OuterJoinInfo *node)
1355 WRITE_NODE_TYPE("OUTERJOININFO");
1357 WRITE_BITMAPSET_FIELD(min_lefthand);
1358 WRITE_BITMAPSET_FIELD(min_righthand);
1359 WRITE_BOOL_FIELD(is_full_join);
1360 WRITE_BOOL_FIELD(lhs_strict);
1364 _outInClauseInfo(StringInfo str, InClauseInfo *node)
1366 WRITE_NODE_TYPE("INCLAUSEINFO");
1368 WRITE_BITMAPSET_FIELD(lefthand);
1369 WRITE_BITMAPSET_FIELD(righthand);
1370 WRITE_NODE_FIELD(sub_targetlist);
1371 WRITE_NODE_FIELD(in_operators);
1375 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1377 WRITE_NODE_TYPE("APPENDRELINFO");
1379 WRITE_UINT_FIELD(parent_relid);
1380 WRITE_UINT_FIELD(child_relid);
1381 WRITE_OID_FIELD(parent_reltype);
1382 WRITE_OID_FIELD(child_reltype);
1383 WRITE_NODE_FIELD(col_mappings);
1384 WRITE_NODE_FIELD(translated_vars);
1385 WRITE_OID_FIELD(parent_reloid);
1388 /*****************************************************************************
1390 * Stuff from parsenodes.h.
1392 *****************************************************************************/
1395 _outCreateStmt(StringInfo str, CreateStmt *node)
1397 WRITE_NODE_TYPE("CREATESTMT");
1399 WRITE_NODE_FIELD(relation);
1400 WRITE_NODE_FIELD(tableElts);
1401 WRITE_NODE_FIELD(inhRelations);
1402 WRITE_NODE_FIELD(constraints);
1403 WRITE_NODE_FIELD(options);
1404 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1405 WRITE_STRING_FIELD(tablespacename);
1409 _outIndexStmt(StringInfo str, IndexStmt *node)
1411 WRITE_NODE_TYPE("INDEXSTMT");
1413 WRITE_STRING_FIELD(idxname);
1414 WRITE_NODE_FIELD(relation);
1415 WRITE_STRING_FIELD(accessMethod);
1416 WRITE_STRING_FIELD(tableSpace);
1417 WRITE_NODE_FIELD(indexParams);
1418 WRITE_NODE_FIELD(options);
1419 WRITE_NODE_FIELD(whereClause);
1420 WRITE_NODE_FIELD(rangetable);
1421 WRITE_BOOL_FIELD(unique);
1422 WRITE_BOOL_FIELD(primary);
1423 WRITE_BOOL_FIELD(isconstraint);
1424 WRITE_BOOL_FIELD(concurrent);
1428 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1430 WRITE_NODE_TYPE("NOTIFY");
1432 WRITE_NODE_FIELD(relation);
1436 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1438 WRITE_NODE_TYPE("DECLARECURSOR");
1440 WRITE_STRING_FIELD(portalname);
1441 WRITE_INT_FIELD(options);
1442 WRITE_NODE_FIELD(query);
1446 _outSelectStmt(StringInfo str, SelectStmt *node)
1448 WRITE_NODE_TYPE("SELECT");
1450 WRITE_NODE_FIELD(distinctClause);
1451 WRITE_NODE_FIELD(into);
1452 WRITE_NODE_FIELD(intoColNames);
1453 WRITE_NODE_FIELD(intoOptions);
1454 WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
1455 WRITE_STRING_FIELD(intoTableSpaceName);
1456 WRITE_NODE_FIELD(targetList);
1457 WRITE_NODE_FIELD(fromClause);
1458 WRITE_NODE_FIELD(whereClause);
1459 WRITE_NODE_FIELD(groupClause);
1460 WRITE_NODE_FIELD(havingClause);
1461 WRITE_NODE_FIELD(valuesLists);
1462 WRITE_NODE_FIELD(sortClause);
1463 WRITE_NODE_FIELD(limitOffset);
1464 WRITE_NODE_FIELD(limitCount);
1465 WRITE_NODE_FIELD(lockingClause);
1466 WRITE_ENUM_FIELD(op, SetOperation);
1467 WRITE_BOOL_FIELD(all);
1468 WRITE_NODE_FIELD(larg);
1469 WRITE_NODE_FIELD(rarg);
1473 _outFuncCall(StringInfo str, FuncCall *node)
1475 WRITE_NODE_TYPE("FUNCCALL");
1477 WRITE_NODE_FIELD(funcname);
1478 WRITE_NODE_FIELD(args);
1479 WRITE_BOOL_FIELD(agg_star);
1480 WRITE_BOOL_FIELD(agg_distinct);
1481 WRITE_INT_FIELD(location);
1485 _outDefElem(StringInfo str, DefElem *node)
1487 WRITE_NODE_TYPE("DEFELEM");
1489 WRITE_STRING_FIELD(defname);
1490 WRITE_NODE_FIELD(arg);
1494 _outLockingClause(StringInfo str, LockingClause *node)
1496 WRITE_NODE_TYPE("LOCKINGCLAUSE");
1498 WRITE_NODE_FIELD(lockedRels);
1499 WRITE_BOOL_FIELD(forUpdate);
1500 WRITE_BOOL_FIELD(noWait);
1504 _outColumnDef(StringInfo str, ColumnDef *node)
1506 WRITE_NODE_TYPE("COLUMNDEF");
1508 WRITE_STRING_FIELD(colname);
1509 WRITE_NODE_FIELD(typename);
1510 WRITE_INT_FIELD(inhcount);
1511 WRITE_BOOL_FIELD(is_local);
1512 WRITE_BOOL_FIELD(is_not_null);
1513 WRITE_NODE_FIELD(raw_default);
1514 WRITE_STRING_FIELD(cooked_default);
1515 WRITE_NODE_FIELD(constraints);
1519 _outTypeName(StringInfo str, TypeName *node)
1521 WRITE_NODE_TYPE("TYPENAME");
1523 WRITE_NODE_FIELD(names);
1524 WRITE_OID_FIELD(typeid);
1525 WRITE_BOOL_FIELD(timezone);
1526 WRITE_BOOL_FIELD(setof);
1527 WRITE_BOOL_FIELD(pct_type);
1528 WRITE_NODE_FIELD(typmods);
1529 WRITE_INT_FIELD(typemod);
1530 WRITE_NODE_FIELD(arrayBounds);
1531 WRITE_INT_FIELD(location);
1535 _outTypeCast(StringInfo str, TypeCast *node)
1537 WRITE_NODE_TYPE("TYPECAST");
1539 WRITE_NODE_FIELD(arg);
1540 WRITE_NODE_FIELD(typename);
1544 _outIndexElem(StringInfo str, IndexElem *node)
1546 WRITE_NODE_TYPE("INDEXELEM");
1548 WRITE_STRING_FIELD(name);
1549 WRITE_NODE_FIELD(expr);
1550 WRITE_NODE_FIELD(opclass);
1551 WRITE_ENUM_FIELD(ordering, SortByDir);
1552 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1556 _outQuery(StringInfo str, Query *node)
1558 WRITE_NODE_TYPE("QUERY");
1560 WRITE_ENUM_FIELD(commandType, CmdType);
1561 WRITE_ENUM_FIELD(querySource, QuerySource);
1562 WRITE_BOOL_FIELD(canSetTag);
1565 * Hack to work around missing outfuncs routines for a lot of the
1566 * utility-statement node types. (The only one we actually *need* for
1567 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
1568 * for the meantime do this to avoid getting lots of warnings when running
1569 * with debug_print_parse on.
1571 if (node->utilityStmt)
1573 switch (nodeTag(node->utilityStmt))
1578 case T_DeclareCursorStmt:
1579 WRITE_NODE_FIELD(utilityStmt);
1582 appendStringInfo(str, " :utilityStmt ?");
1587 appendStringInfo(str, " :utilityStmt <>");
1589 WRITE_INT_FIELD(resultRelation);
1590 WRITE_NODE_FIELD(into);
1591 WRITE_NODE_FIELD(intoOptions);
1592 WRITE_ENUM_FIELD(intoOnCommit, OnCommitAction);
1593 WRITE_STRING_FIELD(intoTableSpaceName);
1594 WRITE_BOOL_FIELD(hasAggs);
1595 WRITE_BOOL_FIELD(hasSubLinks);
1596 WRITE_NODE_FIELD(rtable);
1597 WRITE_NODE_FIELD(jointree);
1598 WRITE_NODE_FIELD(targetList);
1599 WRITE_NODE_FIELD(returningList);
1600 WRITE_NODE_FIELD(groupClause);
1601 WRITE_NODE_FIELD(havingQual);
1602 WRITE_NODE_FIELD(distinctClause);
1603 WRITE_NODE_FIELD(sortClause);
1604 WRITE_NODE_FIELD(limitOffset);
1605 WRITE_NODE_FIELD(limitCount);
1606 WRITE_NODE_FIELD(rowMarks);
1607 WRITE_NODE_FIELD(setOperations);
1608 WRITE_NODE_FIELD(resultRelations);
1609 WRITE_NODE_FIELD(returningLists);
1613 _outSortClause(StringInfo str, SortClause *node)
1615 WRITE_NODE_TYPE("SORTCLAUSE");
1617 WRITE_UINT_FIELD(tleSortGroupRef);
1618 WRITE_OID_FIELD(sortop);
1619 WRITE_BOOL_FIELD(nulls_first);
1623 _outGroupClause(StringInfo str, GroupClause *node)
1625 WRITE_NODE_TYPE("GROUPCLAUSE");
1627 WRITE_UINT_FIELD(tleSortGroupRef);
1628 WRITE_OID_FIELD(sortop);
1629 WRITE_BOOL_FIELD(nulls_first);
1633 _outRowMarkClause(StringInfo str, RowMarkClause *node)
1635 WRITE_NODE_TYPE("ROWMARKCLAUSE");
1637 WRITE_UINT_FIELD(rti);
1638 WRITE_BOOL_FIELD(forUpdate);
1639 WRITE_BOOL_FIELD(noWait);
1643 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
1645 WRITE_NODE_TYPE("SETOPERATIONSTMT");
1647 WRITE_ENUM_FIELD(op, SetOperation);
1648 WRITE_BOOL_FIELD(all);
1649 WRITE_NODE_FIELD(larg);
1650 WRITE_NODE_FIELD(rarg);
1651 WRITE_NODE_FIELD(colTypes);
1652 WRITE_NODE_FIELD(colTypmods);
1656 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
1658 WRITE_NODE_TYPE("RTE");
1660 /* put alias + eref first to make dump more legible */
1661 WRITE_NODE_FIELD(alias);
1662 WRITE_NODE_FIELD(eref);
1663 WRITE_ENUM_FIELD(rtekind, RTEKind);
1665 switch (node->rtekind)
1669 WRITE_OID_FIELD(relid);
1672 WRITE_NODE_FIELD(subquery);
1675 WRITE_NODE_FIELD(funcexpr);
1676 WRITE_NODE_FIELD(funccoltypes);
1677 WRITE_NODE_FIELD(funccoltypmods);
1680 WRITE_NODE_FIELD(values_lists);
1683 WRITE_ENUM_FIELD(jointype, JoinType);
1684 WRITE_NODE_FIELD(joinaliasvars);
1687 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
1691 WRITE_BOOL_FIELD(inh);
1692 WRITE_BOOL_FIELD(inFromCl);
1693 WRITE_UINT_FIELD(requiredPerms);
1694 WRITE_OID_FIELD(checkAsUser);
1698 _outAExpr(StringInfo str, A_Expr *node)
1700 WRITE_NODE_TYPE("AEXPR");
1705 appendStringInfo(str, " ");
1706 WRITE_NODE_FIELD(name);
1709 appendStringInfo(str, " AND");
1712 appendStringInfo(str, " OR");
1715 appendStringInfo(str, " NOT");
1718 appendStringInfo(str, " ");
1719 WRITE_NODE_FIELD(name);
1720 appendStringInfo(str, " ANY ");
1723 appendStringInfo(str, " ");
1724 WRITE_NODE_FIELD(name);
1725 appendStringInfo(str, " ALL ");
1727 case AEXPR_DISTINCT:
1728 appendStringInfo(str, " DISTINCT ");
1729 WRITE_NODE_FIELD(name);
1732 appendStringInfo(str, " NULLIF ");
1733 WRITE_NODE_FIELD(name);
1736 appendStringInfo(str, " OF ");
1737 WRITE_NODE_FIELD(name);
1740 appendStringInfo(str, " IN ");
1741 WRITE_NODE_FIELD(name);
1744 appendStringInfo(str, " ??");
1748 WRITE_NODE_FIELD(lexpr);
1749 WRITE_NODE_FIELD(rexpr);
1750 WRITE_INT_FIELD(location);
1754 _outValue(StringInfo str, Value *value)
1756 switch (value->type)
1759 appendStringInfo(str, "%ld", value->val.ival);
1764 * We assume the value is a valid numeric literal and so does not
1767 appendStringInfoString(str, value->val.str);
1770 appendStringInfoChar(str, '"');
1771 _outToken(str, value->val.str);
1772 appendStringInfoChar(str, '"');
1775 /* internal representation already has leading 'b' */
1776 appendStringInfoString(str, value->val.str);
1779 elog(ERROR, "unrecognized node type: %d", (int) value->type);
1785 _outColumnRef(StringInfo str, ColumnRef *node)
1787 WRITE_NODE_TYPE("COLUMNREF");
1789 WRITE_NODE_FIELD(fields);
1790 WRITE_INT_FIELD(location);
1794 _outParamRef(StringInfo str, ParamRef *node)
1796 WRITE_NODE_TYPE("PARAMREF");
1798 WRITE_INT_FIELD(number);
1802 _outAConst(StringInfo str, A_Const *node)
1804 WRITE_NODE_TYPE("A_CONST");
1806 appendStringInfo(str, " :val ");
1807 _outValue(str, &(node->val));
1808 WRITE_NODE_FIELD(typename);
1812 _outA_Indices(StringInfo str, A_Indices *node)
1814 WRITE_NODE_TYPE("A_INDICES");
1816 WRITE_NODE_FIELD(lidx);
1817 WRITE_NODE_FIELD(uidx);
1821 _outA_Indirection(StringInfo str, A_Indirection *node)
1823 WRITE_NODE_TYPE("A_INDIRECTION");
1825 WRITE_NODE_FIELD(arg);
1826 WRITE_NODE_FIELD(indirection);
1830 _outResTarget(StringInfo str, ResTarget *node)
1832 WRITE_NODE_TYPE("RESTARGET");
1834 WRITE_STRING_FIELD(name);
1835 WRITE_NODE_FIELD(indirection);
1836 WRITE_NODE_FIELD(val);
1837 WRITE_INT_FIELD(location);
1841 _outConstraint(StringInfo str, Constraint *node)
1843 WRITE_NODE_TYPE("CONSTRAINT");
1845 WRITE_STRING_FIELD(name);
1847 appendStringInfo(str, " :contype ");
1848 switch (node->contype)
1850 case CONSTR_PRIMARY:
1851 appendStringInfo(str, "PRIMARY_KEY");
1852 WRITE_NODE_FIELD(keys);
1853 WRITE_NODE_FIELD(options);
1854 WRITE_STRING_FIELD(indexspace);
1858 appendStringInfo(str, "UNIQUE");
1859 WRITE_NODE_FIELD(keys);
1860 WRITE_NODE_FIELD(options);
1861 WRITE_STRING_FIELD(indexspace);
1865 appendStringInfo(str, "CHECK");
1866 WRITE_NODE_FIELD(raw_expr);
1867 WRITE_STRING_FIELD(cooked_expr);
1870 case CONSTR_DEFAULT:
1871 appendStringInfo(str, "DEFAULT");
1872 WRITE_NODE_FIELD(raw_expr);
1873 WRITE_STRING_FIELD(cooked_expr);
1876 case CONSTR_NOTNULL:
1877 appendStringInfo(str, "NOT_NULL");
1881 appendStringInfo(str, "<unrecognized_constraint>");
1887 _outFkConstraint(StringInfo str, FkConstraint *node)
1889 WRITE_NODE_TYPE("FKCONSTRAINT");
1891 WRITE_STRING_FIELD(constr_name);
1892 WRITE_NODE_FIELD(pktable);
1893 WRITE_NODE_FIELD(fk_attrs);
1894 WRITE_NODE_FIELD(pk_attrs);
1895 WRITE_CHAR_FIELD(fk_matchtype);
1896 WRITE_CHAR_FIELD(fk_upd_action);
1897 WRITE_CHAR_FIELD(fk_del_action);
1898 WRITE_BOOL_FIELD(deferrable);
1899 WRITE_BOOL_FIELD(initdeferred);
1900 WRITE_BOOL_FIELD(skip_validation);
1906 * converts a Node into ascii string and append it to 'str'
1909 _outNode(StringInfo str, void *obj)
1912 appendStringInfo(str, "<>");
1913 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
1915 else if (IsA(obj, Integer) ||
1918 IsA(obj, BitString))
1920 /* nodeRead does not want to see { } around these! */
1921 _outValue(str, obj);
1925 appendStringInfoChar(str, '{');
1926 switch (nodeTag(obj))
1932 _outResult(str, obj);
1935 _outAppend(str, obj);
1938 _outBitmapAnd(str, obj);
1941 _outBitmapOr(str, obj);
1947 _outSeqScan(str, obj);
1950 _outIndexScan(str, obj);
1952 case T_BitmapIndexScan:
1953 _outBitmapIndexScan(str, obj);
1955 case T_BitmapHeapScan:
1956 _outBitmapHeapScan(str, obj);
1959 _outTidScan(str, obj);
1961 case T_SubqueryScan:
1962 _outSubqueryScan(str, obj);
1964 case T_FunctionScan:
1965 _outFunctionScan(str, obj);
1968 _outValuesScan(str, obj);
1974 _outNestLoop(str, obj);
1977 _outMergeJoin(str, obj);
1980 _outHashJoin(str, obj);
1986 _outGroup(str, obj);
1989 _outMaterial(str, obj);
1995 _outUnique(str, obj);
1998 _outSetOp(str, obj);
2001 _outLimit(str, obj);
2007 _outAlias(str, obj);
2010 _outRangeVar(str, obj);
2016 _outConst(str, obj);
2019 _outParam(str, obj);
2022 _outAggref(str, obj);
2025 _outArrayRef(str, obj);
2028 _outFuncExpr(str, obj);
2031 _outOpExpr(str, obj);
2033 case T_DistinctExpr:
2034 _outDistinctExpr(str, obj);
2036 case T_ScalarArrayOpExpr:
2037 _outScalarArrayOpExpr(str, obj);
2040 _outBoolExpr(str, obj);
2043 _outSubLink(str, obj);
2046 _outSubPlan(str, obj);
2049 _outFieldSelect(str, obj);
2052 _outFieldStore(str, obj);
2055 _outRelabelType(str, obj);
2057 case T_ConvertRowtypeExpr:
2058 _outConvertRowtypeExpr(str, obj);
2061 _outCaseExpr(str, obj);
2064 _outCaseWhen(str, obj);
2066 case T_CaseTestExpr:
2067 _outCaseTestExpr(str, obj);
2070 _outArrayExpr(str, obj);
2073 _outRowExpr(str, obj);
2075 case T_RowCompareExpr:
2076 _outRowCompareExpr(str, obj);
2078 case T_CoalesceExpr:
2079 _outCoalesceExpr(str, obj);
2082 _outMinMaxExpr(str, obj);
2085 _outXmlExpr(str, obj);
2088 _outNullIfExpr(str, obj);
2091 _outNullTest(str, obj);
2094 _outBooleanTest(str, obj);
2096 case T_CoerceToDomain:
2097 _outCoerceToDomain(str, obj);
2099 case T_CoerceToDomainValue:
2100 _outCoerceToDomainValue(str, obj);
2102 case T_SetToDefault:
2103 _outSetToDefault(str, obj);
2106 _outTargetEntry(str, obj);
2109 _outRangeTblRef(str, obj);
2112 _outJoinExpr(str, obj);
2115 _outFromExpr(str, obj);
2122 _outIndexPath(str, obj);
2124 case T_BitmapHeapPath:
2125 _outBitmapHeapPath(str, obj);
2127 case T_BitmapAndPath:
2128 _outBitmapAndPath(str, obj);
2130 case T_BitmapOrPath:
2131 _outBitmapOrPath(str, obj);
2134 _outTidPath(str, obj);
2137 _outAppendPath(str, obj);
2140 _outResultPath(str, obj);
2142 case T_MaterialPath:
2143 _outMaterialPath(str, obj);
2146 _outUniquePath(str, obj);
2149 _outNestPath(str, obj);
2152 _outMergePath(str, obj);
2155 _outHashPath(str, obj);
2158 _outPlannerInfo(str, obj);
2161 _outRelOptInfo(str, obj);
2163 case T_IndexOptInfo:
2164 _outIndexOptInfo(str, obj);
2167 _outPathKeyItem(str, obj);
2169 case T_RestrictInfo:
2170 _outRestrictInfo(str, obj);
2172 case T_InnerIndexscanInfo:
2173 _outInnerIndexscanInfo(str, obj);
2175 case T_OuterJoinInfo:
2176 _outOuterJoinInfo(str, obj);
2178 case T_InClauseInfo:
2179 _outInClauseInfo(str, obj);
2181 case T_AppendRelInfo:
2182 _outAppendRelInfo(str, obj);
2186 _outCreateStmt(str, obj);
2189 _outIndexStmt(str, obj);
2192 _outNotifyStmt(str, obj);
2194 case T_DeclareCursorStmt:
2195 _outDeclareCursorStmt(str, obj);
2198 _outSelectStmt(str, obj);
2201 _outColumnDef(str, obj);
2204 _outTypeName(str, obj);
2207 _outTypeCast(str, obj);
2210 _outIndexElem(str, obj);
2213 _outQuery(str, obj);
2216 _outSortClause(str, obj);
2219 _outGroupClause(str, obj);
2221 case T_RowMarkClause:
2222 _outRowMarkClause(str, obj);
2224 case T_SetOperationStmt:
2225 _outSetOperationStmt(str, obj);
2227 case T_RangeTblEntry:
2228 _outRangeTblEntry(str, obj);
2231 _outAExpr(str, obj);
2234 _outColumnRef(str, obj);
2237 _outParamRef(str, obj);
2240 _outAConst(str, obj);
2243 _outA_Indices(str, obj);
2245 case T_A_Indirection:
2246 _outA_Indirection(str, obj);
2249 _outResTarget(str, obj);
2252 _outConstraint(str, obj);
2254 case T_FkConstraint:
2255 _outFkConstraint(str, obj);
2258 _outFuncCall(str, obj);
2261 _outDefElem(str, obj);
2263 case T_LockingClause:
2264 _outLockingClause(str, obj);
2270 * This should be an ERROR, but it's too useful to be able to
2271 * dump structures that _outNode only understands part of.
2273 elog(WARNING, "could not dump unrecognized node type: %d",
2274 (int) nodeTag(obj));
2277 appendStringInfoChar(str, '}');
2283 * returns the ascii representation of the Node as a palloc'd string
2286 nodeToString(void *obj)
2290 /* see stringinfo.h for an explanation of this maneuver */
2291 initStringInfo(&str);
2292 _outNode(&str, obj);