]> granicus.if.org Git - postgresql/blob - src/backend/nodes/outfuncs.c
Change the division of labor between grouping_planner and query_planner
[postgresql] / src / backend / nodes / outfuncs.c
1 /*-------------------------------------------------------------------------
2  *
3  * outfuncs.c
4  *        Output functions for Postgres tree nodes.
5  *
6  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  *        $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.260 2005/08/27 22:13:43 tgl Exp $
12  *
13  * NOTES
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.
19  *
20  *-------------------------------------------------------------------------
21  */
22 #include "postgres.h"
23
24 #include <ctype.h>
25
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"
31
32
33 /*
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
37  * routine.
38  */
39
40 /* Write the label for the node type */
41 #define WRITE_NODE_TYPE(nodelabel) \
42         appendStringInfoString(str, nodelabel)
43
44 /* Write an integer field (anything written as ":fldname %d") */
45 #define WRITE_INT_FIELD(fldname) \
46         appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
47
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)
51
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)
55
56 /* Write a long-integer field */
57 #define WRITE_LONG_FIELD(fldname) \
58         appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
59
60 /* Write a char field (ie, one ascii character) */
61 #define WRITE_CHAR_FIELD(fldname) \
62         appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
63
64 /* Write an enumerated-type field as an integer code */
65 #define WRITE_ENUM_FIELD(fldname, enumtype) \
66         appendStringInfo(str, " :" CppAsString(fldname) " %d", \
67                                          (int) node->fldname)
68
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)
72
73 /* Write a boolean field */
74 #define WRITE_BOOL_FIELD(fldname) \
75         appendStringInfo(str, " :" CppAsString(fldname) " %s", \
76                                          booltostr(node->fldname))
77
78 /* Write a character-string (possibly NULL) field */
79 #define WRITE_STRING_FIELD(fldname) \
80         (appendStringInfo(str, " :" CppAsString(fldname) " "), \
81          _outToken(str, node->fldname))
82
83 /* Write a Node field */
84 #define WRITE_NODE_FIELD(fldname) \
85         (appendStringInfo(str, " :" CppAsString(fldname) " "), \
86          _outNode(str, node->fldname))
87
88 /* Write a bitmapset field */
89 #define WRITE_BITMAPSET_FIELD(fldname) \
90         (appendStringInfo(str, " :" CppAsString(fldname) " "), \
91          _outBitmapset(str, node->fldname))
92
93
94 #define booltostr(x)  ((x) ? "true" : "false")
95
96 static void _outNode(StringInfo str, void *obj);
97
98
99 /*
100  * _outToken
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.
103  *
104  *        If a null or empty string is given, it is encoded as "<>".
105  */
106 static void
107 _outToken(StringInfo str, char *s)
108 {
109         if (s == NULL || *s == '\0')
110         {
111                 appendStringInfo(str, "<>");
112                 return;
113         }
114
115         /*
116          * Look for characters or patterns that are treated specially by
117          * read.c (either in pg_strtok() or in nodeRead()), and therefore need
118          * a protective backslash.
119          */
120         /* These characters only need to be quoted at the start of the string */
121         if (*s == '<' ||
122                 *s == '\"' ||
123                 isdigit((unsigned char) *s) ||
124                 ((*s == '+' || *s == '-') &&
125                  (isdigit((unsigned char) s[1]) || s[1] == '.')))
126                 appendStringInfoChar(str, '\\');
127         while (*s)
128         {
129                 /* These chars must be backslashed anywhere in the string */
130                 if (*s == ' ' || *s == '\n' || *s == '\t' ||
131                         *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
132                         *s == '\\')
133                         appendStringInfoChar(str, '\\');
134                 appendStringInfoChar(str, *s++);
135         }
136 }
137
138 static void
139 _outList(StringInfo str, List *node)
140 {
141         ListCell   *lc;
142
143         appendStringInfoChar(str, '(');
144
145         if (IsA(node, IntList))
146                 appendStringInfoChar(str, 'i');
147         else if (IsA(node, OidList))
148                 appendStringInfoChar(str, 'o');
149
150         foreach(lc, node)
151         {
152                 /*
153                  * For the sake of backward compatibility, we emit a slightly
154                  * different whitespace format for lists of nodes vs. other types
155                  * of lists. XXX: is this necessary?
156                  */
157                 if (IsA(node, List))
158                 {
159                         _outNode(str, lfirst(lc));
160                         if (lnext(lc))
161                                 appendStringInfoChar(str, ' ');
162                 }
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));
167                 else
168                         elog(ERROR, "unrecognized list node type: %d",
169                                  (int) node->type);
170         }
171
172         appendStringInfoChar(str, ')');
173 }
174
175 /*
176  * _outBitmapset -
177  *         converts a bitmap set of integers
178  *
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.
182  */
183 static void
184 _outBitmapset(StringInfo str, Bitmapset *bms)
185 {
186         Bitmapset  *tmpset;
187         int                     x;
188
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);
194         bms_free(tmpset);
195         appendStringInfoChar(str, ')');
196 }
197
198 /*
199  * Print the value of a Datum given its type.
200  */
201 static void
202 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
203 {
204         Size            length,
205                                 i;
206         char       *s;
207
208         length = datumGetSize(value, typbyval, typlen);
209
210         if (typbyval)
211         {
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, "]");
217         }
218         else
219         {
220                 s = (char *) DatumGetPointer(value);
221                 if (!PointerIsValid(s))
222                         appendStringInfo(str, "0 [ ]");
223                 else
224                 {
225                         appendStringInfo(str, "%u [ ", (unsigned int) length);
226                         for (i = 0; i < length; i++)
227                                 appendStringInfo(str, "%d ", (int) (s[i]));
228                         appendStringInfo(str, "]");
229                 }
230         }
231 }
232
233
234 /*
235  *      Stuff from plannodes.h
236  */
237
238 /*
239  * print the basic stuff of all nodes that inherit from Plan
240  */
241 static void
242 _outPlanInfo(StringInfo str, Plan *node)
243 {
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);
256 }
257
258 /*
259  * print the basic stuff of all nodes that inherit from Scan
260  */
261 static void
262 _outScanInfo(StringInfo str, Scan *node)
263 {
264         _outPlanInfo(str, (Plan *) node);
265
266         WRITE_UINT_FIELD(scanrelid);
267 }
268
269 /*
270  * print the basic stuff of all nodes that inherit from Join
271  */
272 static void
273 _outJoinPlanInfo(StringInfo str, Join *node)
274 {
275         _outPlanInfo(str, (Plan *) node);
276
277         WRITE_ENUM_FIELD(jointype, JoinType);
278         WRITE_NODE_FIELD(joinqual);
279 }
280
281
282 static void
283 _outPlan(StringInfo str, Plan *node)
284 {
285         WRITE_NODE_TYPE("PLAN");
286
287         _outPlanInfo(str, (Plan *) node);
288 }
289
290 static void
291 _outResult(StringInfo str, Result *node)
292 {
293         WRITE_NODE_TYPE("RESULT");
294
295         _outPlanInfo(str, (Plan *) node);
296
297         WRITE_NODE_FIELD(resconstantqual);
298 }
299
300 static void
301 _outAppend(StringInfo str, Append *node)
302 {
303         WRITE_NODE_TYPE("APPEND");
304
305         _outPlanInfo(str, (Plan *) node);
306
307         WRITE_NODE_FIELD(appendplans);
308         WRITE_BOOL_FIELD(isTarget);
309 }
310
311 static void
312 _outBitmapAnd(StringInfo str, BitmapAnd *node)
313 {
314         WRITE_NODE_TYPE("BITMAPAND");
315
316         _outPlanInfo(str, (Plan *) node);
317
318         WRITE_NODE_FIELD(bitmapplans);
319 }
320
321 static void
322 _outBitmapOr(StringInfo str, BitmapOr *node)
323 {
324         WRITE_NODE_TYPE("BITMAPOR");
325
326         _outPlanInfo(str, (Plan *) node);
327
328         WRITE_NODE_FIELD(bitmapplans);
329 }
330
331 static void
332 _outScan(StringInfo str, Scan *node)
333 {
334         WRITE_NODE_TYPE("SCAN");
335
336         _outScanInfo(str, (Scan *) node);
337 }
338
339 static void
340 _outSeqScan(StringInfo str, SeqScan *node)
341 {
342         WRITE_NODE_TYPE("SEQSCAN");
343
344         _outScanInfo(str, (Scan *) node);
345 }
346
347 static void
348 _outIndexScan(StringInfo str, IndexScan *node)
349 {
350         WRITE_NODE_TYPE("INDEXSCAN");
351
352         _outScanInfo(str, (Scan *) node);
353
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);
360 }
361
362 static void
363 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
364 {
365         WRITE_NODE_TYPE("BITMAPINDEXSCAN");
366
367         _outScanInfo(str, (Scan *) node);
368
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);
374 }
375
376 static void
377 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
378 {
379         WRITE_NODE_TYPE("BITMAPHEAPSCAN");
380
381         _outScanInfo(str, (Scan *) node);
382
383         WRITE_NODE_FIELD(bitmapqualorig);
384 }
385
386 static void
387 _outTidScan(StringInfo str, TidScan *node)
388 {
389         WRITE_NODE_TYPE("TIDSCAN");
390
391         _outScanInfo(str, (Scan *) node);
392
393         WRITE_NODE_FIELD(tideval);
394 }
395
396 static void
397 _outSubqueryScan(StringInfo str, SubqueryScan *node)
398 {
399         WRITE_NODE_TYPE("SUBQUERYSCAN");
400
401         _outScanInfo(str, (Scan *) node);
402
403         WRITE_NODE_FIELD(subplan);
404 }
405
406 static void
407 _outFunctionScan(StringInfo str, FunctionScan *node)
408 {
409         WRITE_NODE_TYPE("FUNCTIONSCAN");
410
411         _outScanInfo(str, (Scan *) node);
412 }
413
414 static void
415 _outJoin(StringInfo str, Join *node)
416 {
417         WRITE_NODE_TYPE("JOIN");
418
419         _outJoinPlanInfo(str, (Join *) node);
420 }
421
422 static void
423 _outNestLoop(StringInfo str, NestLoop *node)
424 {
425         WRITE_NODE_TYPE("NESTLOOP");
426
427         _outJoinPlanInfo(str, (Join *) node);
428 }
429
430 static void
431 _outMergeJoin(StringInfo str, MergeJoin *node)
432 {
433         WRITE_NODE_TYPE("MERGEJOIN");
434
435         _outJoinPlanInfo(str, (Join *) node);
436
437         WRITE_NODE_FIELD(mergeclauses);
438 }
439
440 static void
441 _outHashJoin(StringInfo str, HashJoin *node)
442 {
443         WRITE_NODE_TYPE("HASHJOIN");
444
445         _outJoinPlanInfo(str, (Join *) node);
446
447         WRITE_NODE_FIELD(hashclauses);
448 }
449
450 static void
451 _outAgg(StringInfo str, Agg *node)
452 {
453         WRITE_NODE_TYPE("AGG");
454
455         _outPlanInfo(str, (Plan *) node);
456
457         WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
458         WRITE_INT_FIELD(numCols);
459         WRITE_LONG_FIELD(numGroups);
460 }
461
462 static void
463 _outGroup(StringInfo str, Group *node)
464 {
465         int                     i;
466
467         WRITE_NODE_TYPE("GROUP");
468
469         _outPlanInfo(str, (Plan *) node);
470
471         WRITE_INT_FIELD(numCols);
472
473         appendStringInfo(str, " :grpColIdx");
474         for (i = 0; i < node->numCols; i++)
475                 appendStringInfo(str, " %d", node->grpColIdx[i]);
476 }
477
478 static void
479 _outMaterial(StringInfo str, Material *node)
480 {
481         WRITE_NODE_TYPE("MATERIAL");
482
483         _outPlanInfo(str, (Plan *) node);
484 }
485
486 static void
487 _outSort(StringInfo str, Sort *node)
488 {
489         int                     i;
490
491         WRITE_NODE_TYPE("SORT");
492
493         _outPlanInfo(str, (Plan *) node);
494
495         WRITE_INT_FIELD(numCols);
496
497         appendStringInfo(str, " :sortColIdx");
498         for (i = 0; i < node->numCols; i++)
499                 appendStringInfo(str, " %d", node->sortColIdx[i]);
500
501         appendStringInfo(str, " :sortOperators");
502         for (i = 0; i < node->numCols; i++)
503                 appendStringInfo(str, " %u", node->sortOperators[i]);
504 }
505
506 static void
507 _outUnique(StringInfo str, Unique *node)
508 {
509         int                     i;
510
511         WRITE_NODE_TYPE("UNIQUE");
512
513         _outPlanInfo(str, (Plan *) node);
514
515         WRITE_INT_FIELD(numCols);
516
517         appendStringInfo(str, " :uniqColIdx");
518         for (i = 0; i < node->numCols; i++)
519                 appendStringInfo(str, " %d", node->uniqColIdx[i]);
520 }
521
522 static void
523 _outSetOp(StringInfo str, SetOp *node)
524 {
525         int                     i;
526
527         WRITE_NODE_TYPE("SETOP");
528
529         _outPlanInfo(str, (Plan *) node);
530
531         WRITE_ENUM_FIELD(cmd, SetOpCmd);
532         WRITE_INT_FIELD(numCols);
533
534         appendStringInfo(str, " :dupColIdx");
535         for (i = 0; i < node->numCols; i++)
536                 appendStringInfo(str, " %d", node->dupColIdx[i]);
537
538         WRITE_INT_FIELD(flagColIdx);
539 }
540
541 static void
542 _outLimit(StringInfo str, Limit *node)
543 {
544         WRITE_NODE_TYPE("LIMIT");
545
546         _outPlanInfo(str, (Plan *) node);
547
548         WRITE_NODE_FIELD(limitOffset);
549         WRITE_NODE_FIELD(limitCount);
550 }
551
552 static void
553 _outHash(StringInfo str, Hash *node)
554 {
555         WRITE_NODE_TYPE("HASH");
556
557         _outPlanInfo(str, (Plan *) node);
558 }
559
560 /*****************************************************************************
561  *
562  *      Stuff from primnodes.h.
563  *
564  *****************************************************************************/
565
566 static void
567 _outAlias(StringInfo str, Alias *node)
568 {
569         WRITE_NODE_TYPE("ALIAS");
570
571         WRITE_STRING_FIELD(aliasname);
572         WRITE_NODE_FIELD(colnames);
573 }
574
575 static void
576 _outRangeVar(StringInfo str, RangeVar *node)
577 {
578         WRITE_NODE_TYPE("RANGEVAR");
579
580         /*
581          * we deliberately ignore catalogname here, since it is presently not
582          * semantically meaningful
583          */
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);
589 }
590
591 static void
592 _outVar(StringInfo str, Var *node)
593 {
594         WRITE_NODE_TYPE("VAR");
595
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);
603 }
604
605 static void
606 _outConst(StringInfo str, Const *node)
607 {
608         WRITE_NODE_TYPE("CONST");
609
610         WRITE_OID_FIELD(consttype);
611         WRITE_INT_FIELD(constlen);
612         WRITE_BOOL_FIELD(constbyval);
613         WRITE_BOOL_FIELD(constisnull);
614
615         appendStringInfo(str, " :constvalue ");
616         if (node->constisnull)
617                 appendStringInfo(str, "<>");
618         else
619                 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
620 }
621
622 static void
623 _outParam(StringInfo str, Param *node)
624 {
625         WRITE_NODE_TYPE("PARAM");
626
627         WRITE_INT_FIELD(paramkind);
628         WRITE_INT_FIELD(paramid);
629         WRITE_STRING_FIELD(paramname);
630         WRITE_OID_FIELD(paramtype);
631 }
632
633 static void
634 _outAggref(StringInfo str, Aggref *node)
635 {
636         WRITE_NODE_TYPE("AGGREF");
637
638         WRITE_OID_FIELD(aggfnoid);
639         WRITE_OID_FIELD(aggtype);
640         WRITE_NODE_FIELD(target);
641         WRITE_UINT_FIELD(agglevelsup);
642         WRITE_BOOL_FIELD(aggstar);
643         WRITE_BOOL_FIELD(aggdistinct);
644 }
645
646 static void
647 _outArrayRef(StringInfo str, ArrayRef *node)
648 {
649         WRITE_NODE_TYPE("ARRAYREF");
650
651         WRITE_OID_FIELD(refrestype);
652         WRITE_OID_FIELD(refarraytype);
653         WRITE_OID_FIELD(refelemtype);
654         WRITE_NODE_FIELD(refupperindexpr);
655         WRITE_NODE_FIELD(reflowerindexpr);
656         WRITE_NODE_FIELD(refexpr);
657         WRITE_NODE_FIELD(refassgnexpr);
658 }
659
660 static void
661 _outFuncExpr(StringInfo str, FuncExpr *node)
662 {
663         WRITE_NODE_TYPE("FUNCEXPR");
664
665         WRITE_OID_FIELD(funcid);
666         WRITE_OID_FIELD(funcresulttype);
667         WRITE_BOOL_FIELD(funcretset);
668         WRITE_ENUM_FIELD(funcformat, CoercionForm);
669         WRITE_NODE_FIELD(args);
670 }
671
672 static void
673 _outOpExpr(StringInfo str, OpExpr *node)
674 {
675         WRITE_NODE_TYPE("OPEXPR");
676
677         WRITE_OID_FIELD(opno);
678         WRITE_OID_FIELD(opfuncid);
679         WRITE_OID_FIELD(opresulttype);
680         WRITE_BOOL_FIELD(opretset);
681         WRITE_NODE_FIELD(args);
682 }
683
684 static void
685 _outDistinctExpr(StringInfo str, DistinctExpr *node)
686 {
687         WRITE_NODE_TYPE("DISTINCTEXPR");
688
689         WRITE_OID_FIELD(opno);
690         WRITE_OID_FIELD(opfuncid);
691         WRITE_OID_FIELD(opresulttype);
692         WRITE_BOOL_FIELD(opretset);
693         WRITE_NODE_FIELD(args);
694 }
695
696 static void
697 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
698 {
699         WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
700
701         WRITE_OID_FIELD(opno);
702         WRITE_OID_FIELD(opfuncid);
703         WRITE_BOOL_FIELD(useOr);
704         WRITE_NODE_FIELD(args);
705 }
706
707 static void
708 _outBoolExpr(StringInfo str, BoolExpr *node)
709 {
710         char       *opstr = NULL;
711
712         WRITE_NODE_TYPE("BOOLEXPR");
713
714         /* do-it-yourself enum representation */
715         switch (node->boolop)
716         {
717                 case AND_EXPR:
718                         opstr = "and";
719                         break;
720                 case OR_EXPR:
721                         opstr = "or";
722                         break;
723                 case NOT_EXPR:
724                         opstr = "not";
725                         break;
726         }
727         appendStringInfo(str, " :boolop ");
728         _outToken(str, opstr);
729
730         WRITE_NODE_FIELD(args);
731 }
732
733 static void
734 _outSubLink(StringInfo str, SubLink *node)
735 {
736         WRITE_NODE_TYPE("SUBLINK");
737
738         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
739         WRITE_BOOL_FIELD(useOr);
740         WRITE_NODE_FIELD(lefthand);
741         WRITE_NODE_FIELD(operName);
742         WRITE_NODE_FIELD(operOids);
743         WRITE_NODE_FIELD(subselect);
744 }
745
746 static void
747 _outSubPlan(StringInfo str, SubPlan *node)
748 {
749         WRITE_NODE_TYPE("SUBPLAN");
750
751         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
752         WRITE_BOOL_FIELD(useOr);
753         WRITE_NODE_FIELD(exprs);
754         WRITE_NODE_FIELD(paramIds);
755         WRITE_NODE_FIELD(plan);
756         WRITE_INT_FIELD(plan_id);
757         WRITE_NODE_FIELD(rtable);
758         WRITE_BOOL_FIELD(useHashTable);
759         WRITE_BOOL_FIELD(unknownEqFalse);
760         WRITE_NODE_FIELD(setParam);
761         WRITE_NODE_FIELD(parParam);
762         WRITE_NODE_FIELD(args);
763 }
764
765 static void
766 _outFieldSelect(StringInfo str, FieldSelect *node)
767 {
768         WRITE_NODE_TYPE("FIELDSELECT");
769
770         WRITE_NODE_FIELD(arg);
771         WRITE_INT_FIELD(fieldnum);
772         WRITE_OID_FIELD(resulttype);
773         WRITE_INT_FIELD(resulttypmod);
774 }
775
776 static void
777 _outFieldStore(StringInfo str, FieldStore *node)
778 {
779         WRITE_NODE_TYPE("FIELDSTORE");
780
781         WRITE_NODE_FIELD(arg);
782         WRITE_NODE_FIELD(newvals);
783         WRITE_NODE_FIELD(fieldnums);
784         WRITE_OID_FIELD(resulttype);
785 }
786
787 static void
788 _outRelabelType(StringInfo str, RelabelType *node)
789 {
790         WRITE_NODE_TYPE("RELABELTYPE");
791
792         WRITE_NODE_FIELD(arg);
793         WRITE_OID_FIELD(resulttype);
794         WRITE_INT_FIELD(resulttypmod);
795         WRITE_ENUM_FIELD(relabelformat, CoercionForm);
796 }
797
798 static void
799 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
800 {
801         WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
802
803         WRITE_NODE_FIELD(arg);
804         WRITE_OID_FIELD(resulttype);
805         WRITE_ENUM_FIELD(convertformat, CoercionForm);
806 }
807
808 static void
809 _outCaseExpr(StringInfo str, CaseExpr *node)
810 {
811         WRITE_NODE_TYPE("CASE");
812
813         WRITE_OID_FIELD(casetype);
814         WRITE_NODE_FIELD(arg);
815         WRITE_NODE_FIELD(args);
816         WRITE_NODE_FIELD(defresult);
817 }
818
819 static void
820 _outCaseWhen(StringInfo str, CaseWhen *node)
821 {
822         WRITE_NODE_TYPE("WHEN");
823
824         WRITE_NODE_FIELD(expr);
825         WRITE_NODE_FIELD(result);
826 }
827
828 static void
829 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
830 {
831         WRITE_NODE_TYPE("CASETESTEXPR");
832
833         WRITE_OID_FIELD(typeId);
834         WRITE_INT_FIELD(typeMod);
835 }
836
837 static void
838 _outArrayExpr(StringInfo str, ArrayExpr *node)
839 {
840         WRITE_NODE_TYPE("ARRAY");
841
842         WRITE_OID_FIELD(array_typeid);
843         WRITE_OID_FIELD(element_typeid);
844         WRITE_NODE_FIELD(elements);
845         WRITE_BOOL_FIELD(multidims);
846 }
847
848 static void
849 _outRowExpr(StringInfo str, RowExpr *node)
850 {
851         WRITE_NODE_TYPE("ROW");
852
853         WRITE_NODE_FIELD(args);
854         WRITE_OID_FIELD(row_typeid);
855         WRITE_ENUM_FIELD(row_format, CoercionForm);
856 }
857
858 static void
859 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
860 {
861         WRITE_NODE_TYPE("COALESCE");
862
863         WRITE_OID_FIELD(coalescetype);
864         WRITE_NODE_FIELD(args);
865 }
866
867 static void
868 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
869 {
870         WRITE_NODE_TYPE("MINMAX");
871
872         WRITE_OID_FIELD(minmaxtype);
873         WRITE_ENUM_FIELD(op, MinMaxOp);
874         WRITE_NODE_FIELD(args);
875 }
876
877 static void
878 _outNullIfExpr(StringInfo str, NullIfExpr *node)
879 {
880         WRITE_NODE_TYPE("NULLIFEXPR");
881
882         WRITE_OID_FIELD(opno);
883         WRITE_OID_FIELD(opfuncid);
884         WRITE_OID_FIELD(opresulttype);
885         WRITE_BOOL_FIELD(opretset);
886         WRITE_NODE_FIELD(args);
887 }
888
889 static void
890 _outNullTest(StringInfo str, NullTest *node)
891 {
892         WRITE_NODE_TYPE("NULLTEST");
893
894         WRITE_NODE_FIELD(arg);
895         WRITE_ENUM_FIELD(nulltesttype, NullTestType);
896 }
897
898 static void
899 _outBooleanTest(StringInfo str, BooleanTest *node)
900 {
901         WRITE_NODE_TYPE("BOOLEANTEST");
902
903         WRITE_NODE_FIELD(arg);
904         WRITE_ENUM_FIELD(booltesttype, BoolTestType);
905 }
906
907 static void
908 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
909 {
910         WRITE_NODE_TYPE("COERCETODOMAIN");
911
912         WRITE_NODE_FIELD(arg);
913         WRITE_OID_FIELD(resulttype);
914         WRITE_INT_FIELD(resulttypmod);
915         WRITE_ENUM_FIELD(coercionformat, CoercionForm);
916 }
917
918 static void
919 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
920 {
921         WRITE_NODE_TYPE("COERCETODOMAINVALUE");
922
923         WRITE_OID_FIELD(typeId);
924         WRITE_INT_FIELD(typeMod);
925 }
926
927 static void
928 _outSetToDefault(StringInfo str, SetToDefault *node)
929 {
930         WRITE_NODE_TYPE("SETTODEFAULT");
931
932         WRITE_OID_FIELD(typeId);
933         WRITE_INT_FIELD(typeMod);
934 }
935
936 static void
937 _outTargetEntry(StringInfo str, TargetEntry *node)
938 {
939         WRITE_NODE_TYPE("TARGETENTRY");
940
941         WRITE_NODE_FIELD(expr);
942         WRITE_INT_FIELD(resno);
943         WRITE_STRING_FIELD(resname);
944         WRITE_UINT_FIELD(ressortgroupref);
945         WRITE_OID_FIELD(resorigtbl);
946         WRITE_INT_FIELD(resorigcol);
947         WRITE_BOOL_FIELD(resjunk);
948 }
949
950 static void
951 _outRangeTblRef(StringInfo str, RangeTblRef *node)
952 {
953         WRITE_NODE_TYPE("RANGETBLREF");
954
955         WRITE_INT_FIELD(rtindex);
956 }
957
958 static void
959 _outJoinExpr(StringInfo str, JoinExpr *node)
960 {
961         WRITE_NODE_TYPE("JOINEXPR");
962
963         WRITE_ENUM_FIELD(jointype, JoinType);
964         WRITE_BOOL_FIELD(isNatural);
965         WRITE_NODE_FIELD(larg);
966         WRITE_NODE_FIELD(rarg);
967         WRITE_NODE_FIELD(using);
968         WRITE_NODE_FIELD(quals);
969         WRITE_NODE_FIELD(alias);
970         WRITE_INT_FIELD(rtindex);
971 }
972
973 static void
974 _outFromExpr(StringInfo str, FromExpr *node)
975 {
976         WRITE_NODE_TYPE("FROMEXPR");
977
978         WRITE_NODE_FIELD(fromlist);
979         WRITE_NODE_FIELD(quals);
980 }
981
982 /*****************************************************************************
983  *
984  *      Stuff from relation.h.
985  *
986  *****************************************************************************/
987
988 /*
989  * print the basic stuff of all nodes that inherit from Path
990  *
991  * Note we do NOT print the parent, else we'd be in infinite recursion
992  */
993 static void
994 _outPathInfo(StringInfo str, Path *node)
995 {
996         WRITE_ENUM_FIELD(pathtype, NodeTag);
997         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
998         WRITE_FLOAT_FIELD(total_cost, "%.2f");
999         WRITE_NODE_FIELD(pathkeys);
1000 }
1001
1002 /*
1003  * print the basic stuff of all nodes that inherit from JoinPath
1004  */
1005 static void
1006 _outJoinPathInfo(StringInfo str, JoinPath *node)
1007 {
1008         _outPathInfo(str, (Path *) node);
1009
1010         WRITE_ENUM_FIELD(jointype, JoinType);
1011         WRITE_NODE_FIELD(outerjoinpath);
1012         WRITE_NODE_FIELD(innerjoinpath);
1013         WRITE_NODE_FIELD(joinrestrictinfo);
1014 }
1015
1016 static void
1017 _outPath(StringInfo str, Path *node)
1018 {
1019         WRITE_NODE_TYPE("PATH");
1020
1021         _outPathInfo(str, (Path *) node);
1022 }
1023
1024 static void
1025 _outIndexPath(StringInfo str, IndexPath *node)
1026 {
1027         WRITE_NODE_TYPE("INDEXPATH");
1028
1029         _outPathInfo(str, (Path *) node);
1030
1031         WRITE_NODE_FIELD(indexinfo);
1032         WRITE_NODE_FIELD(indexclauses);
1033         WRITE_NODE_FIELD(indexquals);
1034         WRITE_BOOL_FIELD(isjoininner);
1035         WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1036         WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1037         WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1038         WRITE_FLOAT_FIELD(rows, "%.0f");
1039 }
1040
1041 static void
1042 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1043 {
1044         WRITE_NODE_TYPE("BITMAPHEAPPATH");
1045
1046         _outPathInfo(str, (Path *) node);
1047
1048         WRITE_NODE_FIELD(bitmapqual);
1049         WRITE_BOOL_FIELD(isjoininner);
1050         WRITE_FLOAT_FIELD(rows, "%.0f");
1051 }
1052
1053 static void
1054 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1055 {
1056         WRITE_NODE_TYPE("BITMAPANDPATH");
1057
1058         _outPathInfo(str, (Path *) node);
1059
1060         WRITE_NODE_FIELD(bitmapquals);
1061         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1062 }
1063
1064 static void
1065 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1066 {
1067         WRITE_NODE_TYPE("BITMAPORPATH");
1068
1069         _outPathInfo(str, (Path *) node);
1070
1071         WRITE_NODE_FIELD(bitmapquals);
1072         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1073 }
1074
1075 static void
1076 _outTidPath(StringInfo str, TidPath *node)
1077 {
1078         WRITE_NODE_TYPE("TIDPATH");
1079
1080         _outPathInfo(str, (Path *) node);
1081
1082         WRITE_NODE_FIELD(tideval);
1083 }
1084
1085 static void
1086 _outAppendPath(StringInfo str, AppendPath *node)
1087 {
1088         WRITE_NODE_TYPE("APPENDPATH");
1089
1090         _outPathInfo(str, (Path *) node);
1091
1092         WRITE_NODE_FIELD(subpaths);
1093 }
1094
1095 static void
1096 _outResultPath(StringInfo str, ResultPath *node)
1097 {
1098         WRITE_NODE_TYPE("RESULTPATH");
1099
1100         _outPathInfo(str, (Path *) node);
1101
1102         WRITE_NODE_FIELD(subpath);
1103         WRITE_NODE_FIELD(constantqual);
1104 }
1105
1106 static void
1107 _outMaterialPath(StringInfo str, MaterialPath *node)
1108 {
1109         WRITE_NODE_TYPE("MATERIALPATH");
1110
1111         _outPathInfo(str, (Path *) node);
1112
1113         WRITE_NODE_FIELD(subpath);
1114 }
1115
1116 static void
1117 _outUniquePath(StringInfo str, UniquePath *node)
1118 {
1119         WRITE_NODE_TYPE("UNIQUEPATH");
1120
1121         _outPathInfo(str, (Path *) node);
1122
1123         WRITE_NODE_FIELD(subpath);
1124         WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1125         WRITE_FLOAT_FIELD(rows, "%.0f");
1126 }
1127
1128 static void
1129 _outNestPath(StringInfo str, NestPath *node)
1130 {
1131         WRITE_NODE_TYPE("NESTPATH");
1132
1133         _outJoinPathInfo(str, (JoinPath *) node);
1134 }
1135
1136 static void
1137 _outMergePath(StringInfo str, MergePath *node)
1138 {
1139         WRITE_NODE_TYPE("MERGEPATH");
1140
1141         _outJoinPathInfo(str, (JoinPath *) node);
1142
1143         WRITE_NODE_FIELD(path_mergeclauses);
1144         WRITE_NODE_FIELD(outersortkeys);
1145         WRITE_NODE_FIELD(innersortkeys);
1146 }
1147
1148 static void
1149 _outHashPath(StringInfo str, HashPath *node)
1150 {
1151         WRITE_NODE_TYPE("HASHPATH");
1152
1153         _outJoinPathInfo(str, (JoinPath *) node);
1154
1155         WRITE_NODE_FIELD(path_hashclauses);
1156 }
1157
1158 static void
1159 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1160 {
1161         WRITE_NODE_TYPE("PLANNERINFO");
1162
1163         /* NB: this isn't a complete set of fields */
1164         WRITE_NODE_FIELD(parse);
1165         WRITE_NODE_FIELD(join_rel_list);
1166         WRITE_NODE_FIELD(equi_key_list);
1167         WRITE_NODE_FIELD(left_join_clauses);
1168         WRITE_NODE_FIELD(right_join_clauses);
1169         WRITE_NODE_FIELD(full_join_clauses);
1170         WRITE_NODE_FIELD(in_info_list);
1171         WRITE_NODE_FIELD(query_pathkeys);
1172         WRITE_NODE_FIELD(group_pathkeys);
1173         WRITE_NODE_FIELD(sort_pathkeys);
1174         WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1175         WRITE_BOOL_FIELD(hasJoinRTEs);
1176         WRITE_BOOL_FIELD(hasOuterJoins);
1177         WRITE_BOOL_FIELD(hasHavingQual);
1178 }
1179
1180 static void
1181 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1182 {
1183         WRITE_NODE_TYPE("RELOPTINFO");
1184
1185         /* NB: this isn't a complete set of fields */
1186         WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1187         WRITE_BITMAPSET_FIELD(relids);
1188         WRITE_FLOAT_FIELD(rows, "%.0f");
1189         WRITE_INT_FIELD(width);
1190         WRITE_NODE_FIELD(reltargetlist);
1191         WRITE_NODE_FIELD(pathlist);
1192         WRITE_NODE_FIELD(cheapest_startup_path);
1193         WRITE_NODE_FIELD(cheapest_total_path);
1194         WRITE_NODE_FIELD(cheapest_unique_path);
1195         WRITE_UINT_FIELD(relid);
1196         WRITE_ENUM_FIELD(rtekind, RTEKind);
1197         WRITE_UINT_FIELD(min_attr);
1198         WRITE_UINT_FIELD(max_attr);
1199         WRITE_NODE_FIELD(indexlist);
1200         WRITE_UINT_FIELD(pages);
1201         WRITE_FLOAT_FIELD(tuples, "%.0f");
1202         WRITE_NODE_FIELD(subplan);
1203         WRITE_NODE_FIELD(baserestrictinfo);
1204         WRITE_BITMAPSET_FIELD(outerjoinset);
1205         WRITE_NODE_FIELD(joininfo);
1206         WRITE_BITMAPSET_FIELD(index_outer_relids);
1207         WRITE_NODE_FIELD(index_inner_paths);
1208 }
1209
1210 static void
1211 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1212 {
1213         WRITE_NODE_TYPE("INDEXOPTINFO");
1214
1215         /* NB: this isn't a complete set of fields */
1216         WRITE_OID_FIELD(indexoid);
1217         /* Do NOT print rel field, else infinite recursion */
1218         WRITE_UINT_FIELD(pages);
1219         WRITE_FLOAT_FIELD(tuples, "%.0f");
1220         WRITE_INT_FIELD(ncolumns);
1221         WRITE_NODE_FIELD(indexprs);
1222         WRITE_NODE_FIELD(indpred);
1223         WRITE_BOOL_FIELD(predOK);
1224         WRITE_BOOL_FIELD(unique);
1225 }
1226
1227 static void
1228 _outPathKeyItem(StringInfo str, PathKeyItem *node)
1229 {
1230         WRITE_NODE_TYPE("PATHKEYITEM");
1231
1232         WRITE_NODE_FIELD(key);
1233         WRITE_OID_FIELD(sortop);
1234 }
1235
1236 static void
1237 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1238 {
1239         WRITE_NODE_TYPE("RESTRICTINFO");
1240
1241         /* NB: this isn't a complete set of fields */
1242         WRITE_NODE_FIELD(clause);
1243         WRITE_BOOL_FIELD(is_pushed_down);
1244         WRITE_BOOL_FIELD(can_join);
1245         WRITE_BITMAPSET_FIELD(clause_relids);
1246         WRITE_BITMAPSET_FIELD(required_relids);
1247         WRITE_BITMAPSET_FIELD(left_relids);
1248         WRITE_BITMAPSET_FIELD(right_relids);
1249         WRITE_NODE_FIELD(orclause);
1250         WRITE_OID_FIELD(mergejoinoperator);
1251         WRITE_OID_FIELD(left_sortop);
1252         WRITE_OID_FIELD(right_sortop);
1253         WRITE_NODE_FIELD(left_pathkey);
1254         WRITE_NODE_FIELD(right_pathkey);
1255         WRITE_OID_FIELD(hashjoinoperator);
1256 }
1257
1258 static void
1259 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1260 {
1261         WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1262         WRITE_BITMAPSET_FIELD(other_relids);
1263         WRITE_BOOL_FIELD(isouterjoin);
1264         WRITE_NODE_FIELD(best_innerpath);
1265 }
1266
1267 static void
1268 _outInClauseInfo(StringInfo str, InClauseInfo *node)
1269 {
1270         WRITE_NODE_TYPE("INCLAUSEINFO");
1271
1272         WRITE_BITMAPSET_FIELD(lefthand);
1273         WRITE_BITMAPSET_FIELD(righthand);
1274         WRITE_NODE_FIELD(sub_targetlist);
1275 }
1276
1277 /*****************************************************************************
1278  *
1279  *      Stuff from parsenodes.h.
1280  *
1281  *****************************************************************************/
1282
1283 static void
1284 _outCreateStmt(StringInfo str, CreateStmt *node)
1285 {
1286         WRITE_NODE_TYPE("CREATESTMT");
1287
1288         WRITE_NODE_FIELD(relation);
1289         WRITE_NODE_FIELD(tableElts);
1290         WRITE_NODE_FIELD(inhRelations);
1291         WRITE_NODE_FIELD(constraints);
1292         WRITE_ENUM_FIELD(hasoids, ContainsOids);
1293         WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1294         WRITE_STRING_FIELD(tablespacename);
1295 }
1296
1297 static void
1298 _outIndexStmt(StringInfo str, IndexStmt *node)
1299 {
1300         WRITE_NODE_TYPE("INDEXSTMT");
1301
1302         WRITE_STRING_FIELD(idxname);
1303         WRITE_NODE_FIELD(relation);
1304         WRITE_STRING_FIELD(accessMethod);
1305         WRITE_STRING_FIELD(tableSpace);
1306         WRITE_NODE_FIELD(indexParams);
1307         WRITE_NODE_FIELD(whereClause);
1308         WRITE_NODE_FIELD(rangetable);
1309         WRITE_BOOL_FIELD(unique);
1310         WRITE_BOOL_FIELD(primary);
1311         WRITE_BOOL_FIELD(isconstraint);
1312 }
1313
1314 static void
1315 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1316 {
1317         WRITE_NODE_TYPE("NOTIFY");
1318
1319         WRITE_NODE_FIELD(relation);
1320 }
1321
1322 static void
1323 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1324 {
1325         WRITE_NODE_TYPE("DECLARECURSOR");
1326
1327         WRITE_STRING_FIELD(portalname);
1328         WRITE_INT_FIELD(options);
1329         WRITE_NODE_FIELD(query);
1330 }
1331
1332 static void
1333 _outSelectStmt(StringInfo str, SelectStmt *node)
1334 {
1335         WRITE_NODE_TYPE("SELECT");
1336
1337         WRITE_NODE_FIELD(distinctClause);
1338         WRITE_NODE_FIELD(into);
1339         WRITE_NODE_FIELD(intoColNames);
1340         WRITE_ENUM_FIELD(intoHasOids, ContainsOids);
1341         WRITE_NODE_FIELD(targetList);
1342         WRITE_NODE_FIELD(fromClause);
1343         WRITE_NODE_FIELD(whereClause);
1344         WRITE_NODE_FIELD(groupClause);
1345         WRITE_NODE_FIELD(havingClause);
1346         WRITE_NODE_FIELD(sortClause);
1347         WRITE_NODE_FIELD(limitOffset);
1348         WRITE_NODE_FIELD(limitCount);
1349         WRITE_NODE_FIELD(lockingClause);
1350         WRITE_ENUM_FIELD(op, SetOperation);
1351         WRITE_BOOL_FIELD(all);
1352         WRITE_NODE_FIELD(larg);
1353         WRITE_NODE_FIELD(rarg);
1354 }
1355
1356 static void
1357 _outFuncCall(StringInfo str, FuncCall *node)
1358 {
1359         WRITE_NODE_TYPE("FUNCCALL");
1360
1361         WRITE_NODE_FIELD(funcname);
1362         WRITE_NODE_FIELD(args);
1363         WRITE_BOOL_FIELD(agg_star);
1364         WRITE_BOOL_FIELD(agg_distinct);
1365 }
1366
1367 static void
1368 _outDefElem(StringInfo str, DefElem *node)
1369 {
1370         WRITE_NODE_TYPE("DEFELEM");
1371
1372         WRITE_STRING_FIELD(defname);
1373         WRITE_NODE_FIELD(arg);
1374 }
1375
1376 static void
1377 _outLockingClause(StringInfo str, LockingClause *node)
1378 {
1379         WRITE_NODE_TYPE("LOCKINGCLAUSE");
1380
1381         WRITE_NODE_FIELD(lockedRels);
1382         WRITE_BOOL_FIELD(forUpdate);
1383         WRITE_BOOL_FIELD(nowait);
1384 }
1385
1386 static void
1387 _outColumnDef(StringInfo str, ColumnDef *node)
1388 {
1389         WRITE_NODE_TYPE("COLUMNDEF");
1390
1391         WRITE_STRING_FIELD(colname);
1392         WRITE_NODE_FIELD(typename);
1393         WRITE_INT_FIELD(inhcount);
1394         WRITE_BOOL_FIELD(is_local);
1395         WRITE_BOOL_FIELD(is_not_null);
1396         WRITE_NODE_FIELD(raw_default);
1397         WRITE_STRING_FIELD(cooked_default);
1398         WRITE_NODE_FIELD(constraints);
1399         WRITE_NODE_FIELD(support);
1400 }
1401
1402 static void
1403 _outTypeName(StringInfo str, TypeName *node)
1404 {
1405         WRITE_NODE_TYPE("TYPENAME");
1406
1407         WRITE_NODE_FIELD(names);
1408         WRITE_OID_FIELD(typeid);
1409         WRITE_BOOL_FIELD(timezone);
1410         WRITE_BOOL_FIELD(setof);
1411         WRITE_BOOL_FIELD(pct_type);
1412         WRITE_INT_FIELD(typmod);
1413         WRITE_NODE_FIELD(arrayBounds);
1414 }
1415
1416 static void
1417 _outTypeCast(StringInfo str, TypeCast *node)
1418 {
1419         WRITE_NODE_TYPE("TYPECAST");
1420
1421         WRITE_NODE_FIELD(arg);
1422         WRITE_NODE_FIELD(typename);
1423 }
1424
1425 static void
1426 _outIndexElem(StringInfo str, IndexElem *node)
1427 {
1428         WRITE_NODE_TYPE("INDEXELEM");
1429
1430         WRITE_STRING_FIELD(name);
1431         WRITE_NODE_FIELD(expr);
1432         WRITE_NODE_FIELD(opclass);
1433 }
1434
1435 static void
1436 _outQuery(StringInfo str, Query *node)
1437 {
1438         WRITE_NODE_TYPE("QUERY");
1439
1440         WRITE_ENUM_FIELD(commandType, CmdType);
1441         WRITE_ENUM_FIELD(querySource, QuerySource);
1442         WRITE_BOOL_FIELD(canSetTag);
1443
1444         /*
1445          * Hack to work around missing outfuncs routines for a lot of the
1446          * utility-statement node types.  (The only one we actually *need* for
1447          * rules support is NotifyStmt.)  Someday we ought to support 'em all,
1448          * but for the meantime do this to avoid getting lots of warnings when
1449          * running with debug_print_parse on.
1450          */
1451         if (node->utilityStmt)
1452         {
1453                 switch (nodeTag(node->utilityStmt))
1454                 {
1455                         case T_CreateStmt:
1456                         case T_IndexStmt:
1457                         case T_NotifyStmt:
1458                         case T_DeclareCursorStmt:
1459                                 WRITE_NODE_FIELD(utilityStmt);
1460                                 break;
1461                         default:
1462                                 appendStringInfo(str, " :utilityStmt ?");
1463                                 break;
1464                 }
1465         }
1466         else
1467                 appendStringInfo(str, " :utilityStmt <>");
1468
1469         WRITE_INT_FIELD(resultRelation);
1470         WRITE_NODE_FIELD(into);
1471         WRITE_BOOL_FIELD(hasAggs);
1472         WRITE_BOOL_FIELD(hasSubLinks);
1473         WRITE_NODE_FIELD(rtable);
1474         WRITE_NODE_FIELD(jointree);
1475         WRITE_NODE_FIELD(rowMarks);
1476         WRITE_BOOL_FIELD(forUpdate);
1477         WRITE_BOOL_FIELD(rowNoWait);
1478         WRITE_NODE_FIELD(targetList);
1479         WRITE_NODE_FIELD(groupClause);
1480         WRITE_NODE_FIELD(havingQual);
1481         WRITE_NODE_FIELD(distinctClause);
1482         WRITE_NODE_FIELD(sortClause);
1483         WRITE_NODE_FIELD(limitOffset);
1484         WRITE_NODE_FIELD(limitCount);
1485         WRITE_NODE_FIELD(setOperations);
1486         WRITE_NODE_FIELD(resultRelations);
1487 }
1488
1489 static void
1490 _outSortClause(StringInfo str, SortClause *node)
1491 {
1492         WRITE_NODE_TYPE("SORTCLAUSE");
1493
1494         WRITE_UINT_FIELD(tleSortGroupRef);
1495         WRITE_OID_FIELD(sortop);
1496 }
1497
1498 static void
1499 _outGroupClause(StringInfo str, GroupClause *node)
1500 {
1501         WRITE_NODE_TYPE("GROUPCLAUSE");
1502
1503         WRITE_UINT_FIELD(tleSortGroupRef);
1504         WRITE_OID_FIELD(sortop);
1505 }
1506
1507 static void
1508 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
1509 {
1510         WRITE_NODE_TYPE("SETOPERATIONSTMT");
1511
1512         WRITE_ENUM_FIELD(op, SetOperation);
1513         WRITE_BOOL_FIELD(all);
1514         WRITE_NODE_FIELD(larg);
1515         WRITE_NODE_FIELD(rarg);
1516         WRITE_NODE_FIELD(colTypes);
1517 }
1518
1519 static void
1520 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
1521 {
1522         WRITE_NODE_TYPE("RTE");
1523
1524         /* put alias + eref first to make dump more legible */
1525         WRITE_NODE_FIELD(alias);
1526         WRITE_NODE_FIELD(eref);
1527         WRITE_ENUM_FIELD(rtekind, RTEKind);
1528
1529         switch (node->rtekind)
1530         {
1531                 case RTE_RELATION:
1532                 case RTE_SPECIAL:
1533                         WRITE_OID_FIELD(relid);
1534                         break;
1535                 case RTE_SUBQUERY:
1536                         WRITE_NODE_FIELD(subquery);
1537                         break;
1538                 case RTE_FUNCTION:
1539                         WRITE_NODE_FIELD(funcexpr);
1540                         WRITE_NODE_FIELD(coldeflist);
1541                         break;
1542                 case RTE_JOIN:
1543                         WRITE_ENUM_FIELD(jointype, JoinType);
1544                         WRITE_NODE_FIELD(joinaliasvars);
1545                         break;
1546                 default:
1547                         elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
1548                         break;
1549         }
1550
1551         WRITE_BOOL_FIELD(inh);
1552         WRITE_BOOL_FIELD(inFromCl);
1553         WRITE_UINT_FIELD(requiredPerms);
1554         WRITE_OID_FIELD(checkAsUser);
1555 }
1556
1557 static void
1558 _outAExpr(StringInfo str, A_Expr *node)
1559 {
1560         WRITE_NODE_TYPE("AEXPR");
1561
1562         switch (node->kind)
1563         {
1564                 case AEXPR_OP:
1565                         appendStringInfo(str, " ");
1566                         WRITE_NODE_FIELD(name);
1567                         break;
1568                 case AEXPR_AND:
1569                         appendStringInfo(str, " AND");
1570                         break;
1571                 case AEXPR_OR:
1572                         appendStringInfo(str, " OR");
1573                         break;
1574                 case AEXPR_NOT:
1575                         appendStringInfo(str, " NOT");
1576                         break;
1577                 case AEXPR_OP_ANY:
1578                         appendStringInfo(str, " ");
1579                         WRITE_NODE_FIELD(name);
1580                         appendStringInfo(str, " ANY ");
1581                         break;
1582                 case AEXPR_OP_ALL:
1583                         appendStringInfo(str, " ");
1584                         WRITE_NODE_FIELD(name);
1585                         appendStringInfo(str, " ALL ");
1586                         break;
1587                 case AEXPR_DISTINCT:
1588                         appendStringInfo(str, " DISTINCT ");
1589                         WRITE_NODE_FIELD(name);
1590                         break;
1591                 case AEXPR_NULLIF:
1592                         appendStringInfo(str, " NULLIF ");
1593                         WRITE_NODE_FIELD(name);
1594                         break;
1595                 case AEXPR_OF:
1596                         appendStringInfo(str, " OF ");
1597                         WRITE_NODE_FIELD(name);
1598                         break;
1599                 default:
1600                         appendStringInfo(str, " ??");
1601                         break;
1602         }
1603
1604         WRITE_NODE_FIELD(lexpr);
1605         WRITE_NODE_FIELD(rexpr);
1606 }
1607
1608 static void
1609 _outValue(StringInfo str, Value *value)
1610 {
1611         switch (value->type)
1612         {
1613                 case T_Integer:
1614                         appendStringInfo(str, "%ld", value->val.ival);
1615                         break;
1616                 case T_Float:
1617
1618                         /*
1619                          * We assume the value is a valid numeric literal and so does
1620                          * not need quoting.
1621                          */
1622                         appendStringInfoString(str, value->val.str);
1623                         break;
1624                 case T_String:
1625                         appendStringInfoChar(str, '"');
1626                         _outToken(str, value->val.str);
1627                         appendStringInfoChar(str, '"');
1628                         break;
1629                 case T_BitString:
1630                         /* internal representation already has leading 'b' */
1631                         appendStringInfoString(str, value->val.str);
1632                         break;
1633                 default:
1634                         elog(ERROR, "unrecognized node type: %d", (int) value->type);
1635                         break;
1636         }
1637 }
1638
1639 static void
1640 _outColumnRef(StringInfo str, ColumnRef *node)
1641 {
1642         WRITE_NODE_TYPE("COLUMNREF");
1643
1644         WRITE_NODE_FIELD(fields);
1645 }
1646
1647 static void
1648 _outParamRef(StringInfo str, ParamRef *node)
1649 {
1650         WRITE_NODE_TYPE("PARAMREF");
1651
1652         WRITE_INT_FIELD(number);
1653 }
1654
1655 static void
1656 _outAConst(StringInfo str, A_Const *node)
1657 {
1658         WRITE_NODE_TYPE("A_CONST");
1659
1660         _outValue(str, &(node->val));
1661         WRITE_NODE_FIELD(typename);
1662 }
1663
1664 static void
1665 _outA_Indices(StringInfo str, A_Indices *node)
1666 {
1667         WRITE_NODE_TYPE("A_INDICES");
1668
1669         WRITE_NODE_FIELD(lidx);
1670         WRITE_NODE_FIELD(uidx);
1671 }
1672
1673 static void
1674 _outA_Indirection(StringInfo str, A_Indirection *node)
1675 {
1676         WRITE_NODE_TYPE("A_INDIRECTION");
1677
1678         WRITE_NODE_FIELD(arg);
1679         WRITE_NODE_FIELD(indirection);
1680 }
1681
1682 static void
1683 _outResTarget(StringInfo str, ResTarget *node)
1684 {
1685         WRITE_NODE_TYPE("RESTARGET");
1686
1687         WRITE_STRING_FIELD(name);
1688         WRITE_NODE_FIELD(indirection);
1689         WRITE_NODE_FIELD(val);
1690 }
1691
1692 static void
1693 _outConstraint(StringInfo str, Constraint *node)
1694 {
1695         WRITE_NODE_TYPE("CONSTRAINT");
1696
1697         WRITE_STRING_FIELD(name);
1698
1699         appendStringInfo(str, " :contype ");
1700         switch (node->contype)
1701         {
1702                 case CONSTR_PRIMARY:
1703                         appendStringInfo(str, "PRIMARY_KEY");
1704                         WRITE_NODE_FIELD(keys);
1705                         WRITE_STRING_FIELD(indexspace);
1706                         break;
1707
1708                 case CONSTR_UNIQUE:
1709                         appendStringInfo(str, "UNIQUE");
1710                         WRITE_NODE_FIELD(keys);
1711                         WRITE_STRING_FIELD(indexspace);
1712                         break;
1713
1714                 case CONSTR_CHECK:
1715                         appendStringInfo(str, "CHECK");
1716                         WRITE_NODE_FIELD(raw_expr);
1717                         WRITE_STRING_FIELD(cooked_expr);
1718                         break;
1719
1720                 case CONSTR_DEFAULT:
1721                         appendStringInfo(str, "DEFAULT");
1722                         WRITE_NODE_FIELD(raw_expr);
1723                         WRITE_STRING_FIELD(cooked_expr);
1724                         break;
1725
1726                 case CONSTR_NOTNULL:
1727                         appendStringInfo(str, "NOT_NULL");
1728                         break;
1729
1730                 default:
1731                         appendStringInfo(str, "<unrecognized_constraint>");
1732                         break;
1733         }
1734 }
1735
1736 static void
1737 _outFkConstraint(StringInfo str, FkConstraint *node)
1738 {
1739         WRITE_NODE_TYPE("FKCONSTRAINT");
1740
1741         WRITE_STRING_FIELD(constr_name);
1742         WRITE_NODE_FIELD(pktable);
1743         WRITE_NODE_FIELD(fk_attrs);
1744         WRITE_NODE_FIELD(pk_attrs);
1745         WRITE_CHAR_FIELD(fk_matchtype);
1746         WRITE_CHAR_FIELD(fk_upd_action);
1747         WRITE_CHAR_FIELD(fk_del_action);
1748         WRITE_BOOL_FIELD(deferrable);
1749         WRITE_BOOL_FIELD(initdeferred);
1750         WRITE_BOOL_FIELD(skip_validation);
1751 }
1752
1753
1754 /*
1755  * _outNode -
1756  *        converts a Node into ascii string and append it to 'str'
1757  */
1758 static void
1759 _outNode(StringInfo str, void *obj)
1760 {
1761         if (obj == NULL)
1762                 appendStringInfo(str, "<>");
1763         else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
1764                 _outList(str, obj);
1765         else if (IsA(obj, Integer) ||
1766                          IsA(obj, Float) ||
1767                          IsA(obj, String) ||
1768                          IsA(obj, BitString))
1769         {
1770                 /* nodeRead does not want to see { } around these! */
1771                 _outValue(str, obj);
1772         }
1773         else
1774         {
1775                 appendStringInfoChar(str, '{');
1776                 switch (nodeTag(obj))
1777                 {
1778                         case T_Plan:
1779                                 _outPlan(str, obj);
1780                                 break;
1781                         case T_Result:
1782                                 _outResult(str, obj);
1783                                 break;
1784                         case T_Append:
1785                                 _outAppend(str, obj);
1786                                 break;
1787                         case T_BitmapAnd:
1788                                 _outBitmapAnd(str, obj);
1789                                 break;
1790                         case T_BitmapOr:
1791                                 _outBitmapOr(str, obj);
1792                                 break;
1793                         case T_Scan:
1794                                 _outScan(str, obj);
1795                                 break;
1796                         case T_SeqScan:
1797                                 _outSeqScan(str, obj);
1798                                 break;
1799                         case T_IndexScan:
1800                                 _outIndexScan(str, obj);
1801                                 break;
1802                         case T_BitmapIndexScan:
1803                                 _outBitmapIndexScan(str, obj);
1804                                 break;
1805                         case T_BitmapHeapScan:
1806                                 _outBitmapHeapScan(str, obj);
1807                                 break;
1808                         case T_TidScan:
1809                                 _outTidScan(str, obj);
1810                                 break;
1811                         case T_SubqueryScan:
1812                                 _outSubqueryScan(str, obj);
1813                                 break;
1814                         case T_FunctionScan:
1815                                 _outFunctionScan(str, obj);
1816                                 break;
1817                         case T_Join:
1818                                 _outJoin(str, obj);
1819                                 break;
1820                         case T_NestLoop:
1821                                 _outNestLoop(str, obj);
1822                                 break;
1823                         case T_MergeJoin:
1824                                 _outMergeJoin(str, obj);
1825                                 break;
1826                         case T_HashJoin:
1827                                 _outHashJoin(str, obj);
1828                                 break;
1829                         case T_Agg:
1830                                 _outAgg(str, obj);
1831                                 break;
1832                         case T_Group:
1833                                 _outGroup(str, obj);
1834                                 break;
1835                         case T_Material:
1836                                 _outMaterial(str, obj);
1837                                 break;
1838                         case T_Sort:
1839                                 _outSort(str, obj);
1840                                 break;
1841                         case T_Unique:
1842                                 _outUnique(str, obj);
1843                                 break;
1844                         case T_SetOp:
1845                                 _outSetOp(str, obj);
1846                                 break;
1847                         case T_Limit:
1848                                 _outLimit(str, obj);
1849                                 break;
1850                         case T_Hash:
1851                                 _outHash(str, obj);
1852                                 break;
1853                         case T_Alias:
1854                                 _outAlias(str, obj);
1855                                 break;
1856                         case T_RangeVar:
1857                                 _outRangeVar(str, obj);
1858                                 break;
1859                         case T_Var:
1860                                 _outVar(str, obj);
1861                                 break;
1862                         case T_Const:
1863                                 _outConst(str, obj);
1864                                 break;
1865                         case T_Param:
1866                                 _outParam(str, obj);
1867                                 break;
1868                         case T_Aggref:
1869                                 _outAggref(str, obj);
1870                                 break;
1871                         case T_ArrayRef:
1872                                 _outArrayRef(str, obj);
1873                                 break;
1874                         case T_FuncExpr:
1875                                 _outFuncExpr(str, obj);
1876                                 break;
1877                         case T_OpExpr:
1878                                 _outOpExpr(str, obj);
1879                                 break;
1880                         case T_DistinctExpr:
1881                                 _outDistinctExpr(str, obj);
1882                                 break;
1883                         case T_ScalarArrayOpExpr:
1884                                 _outScalarArrayOpExpr(str, obj);
1885                                 break;
1886                         case T_BoolExpr:
1887                                 _outBoolExpr(str, obj);
1888                                 break;
1889                         case T_SubLink:
1890                                 _outSubLink(str, obj);
1891                                 break;
1892                         case T_SubPlan:
1893                                 _outSubPlan(str, obj);
1894                                 break;
1895                         case T_FieldSelect:
1896                                 _outFieldSelect(str, obj);
1897                                 break;
1898                         case T_FieldStore:
1899                                 _outFieldStore(str, obj);
1900                                 break;
1901                         case T_RelabelType:
1902                                 _outRelabelType(str, obj);
1903                                 break;
1904                         case T_ConvertRowtypeExpr:
1905                                 _outConvertRowtypeExpr(str, obj);
1906                                 break;
1907                         case T_CaseExpr:
1908                                 _outCaseExpr(str, obj);
1909                                 break;
1910                         case T_CaseWhen:
1911                                 _outCaseWhen(str, obj);
1912                                 break;
1913                         case T_CaseTestExpr:
1914                                 _outCaseTestExpr(str, obj);
1915                                 break;
1916                         case T_ArrayExpr:
1917                                 _outArrayExpr(str, obj);
1918                                 break;
1919                         case T_RowExpr:
1920                                 _outRowExpr(str, obj);
1921                                 break;
1922                         case T_CoalesceExpr:
1923                                 _outCoalesceExpr(str, obj);
1924                                 break;
1925                         case T_MinMaxExpr:
1926                                 _outMinMaxExpr(str, obj);
1927                                 break;
1928                         case T_NullIfExpr:
1929                                 _outNullIfExpr(str, obj);
1930                                 break;
1931                         case T_NullTest:
1932                                 _outNullTest(str, obj);
1933                                 break;
1934                         case T_BooleanTest:
1935                                 _outBooleanTest(str, obj);
1936                                 break;
1937                         case T_CoerceToDomain:
1938                                 _outCoerceToDomain(str, obj);
1939                                 break;
1940                         case T_CoerceToDomainValue:
1941                                 _outCoerceToDomainValue(str, obj);
1942                                 break;
1943                         case T_SetToDefault:
1944                                 _outSetToDefault(str, obj);
1945                                 break;
1946                         case T_TargetEntry:
1947                                 _outTargetEntry(str, obj);
1948                                 break;
1949                         case T_RangeTblRef:
1950                                 _outRangeTblRef(str, obj);
1951                                 break;
1952                         case T_JoinExpr:
1953                                 _outJoinExpr(str, obj);
1954                                 break;
1955                         case T_FromExpr:
1956                                 _outFromExpr(str, obj);
1957                                 break;
1958
1959                         case T_Path:
1960                                 _outPath(str, obj);
1961                                 break;
1962                         case T_IndexPath:
1963                                 _outIndexPath(str, obj);
1964                                 break;
1965                         case T_BitmapHeapPath:
1966                                 _outBitmapHeapPath(str, obj);
1967                                 break;
1968                         case T_BitmapAndPath:
1969                                 _outBitmapAndPath(str, obj);
1970                                 break;
1971                         case T_BitmapOrPath:
1972                                 _outBitmapOrPath(str, obj);
1973                                 break;
1974                         case T_TidPath:
1975                                 _outTidPath(str, obj);
1976                                 break;
1977                         case T_AppendPath:
1978                                 _outAppendPath(str, obj);
1979                                 break;
1980                         case T_ResultPath:
1981                                 _outResultPath(str, obj);
1982                                 break;
1983                         case T_MaterialPath:
1984                                 _outMaterialPath(str, obj);
1985                                 break;
1986                         case T_UniquePath:
1987                                 _outUniquePath(str, obj);
1988                                 break;
1989                         case T_NestPath:
1990                                 _outNestPath(str, obj);
1991                                 break;
1992                         case T_MergePath:
1993                                 _outMergePath(str, obj);
1994                                 break;
1995                         case T_HashPath:
1996                                 _outHashPath(str, obj);
1997                                 break;
1998                         case T_PlannerInfo:
1999                                 _outPlannerInfo(str, obj);
2000                                 break;
2001                         case T_RelOptInfo:
2002                                 _outRelOptInfo(str, obj);
2003                                 break;
2004                         case T_IndexOptInfo:
2005                                 _outIndexOptInfo(str, obj);
2006                                 break;
2007                         case T_PathKeyItem:
2008                                 _outPathKeyItem(str, obj);
2009                                 break;
2010                         case T_RestrictInfo:
2011                                 _outRestrictInfo(str, obj);
2012                                 break;
2013                         case T_InnerIndexscanInfo:
2014                                 _outInnerIndexscanInfo(str, obj);
2015                                 break;
2016                         case T_InClauseInfo:
2017                                 _outInClauseInfo(str, obj);
2018                                 break;
2019
2020                         case T_CreateStmt:
2021                                 _outCreateStmt(str, obj);
2022                                 break;
2023                         case T_IndexStmt:
2024                                 _outIndexStmt(str, obj);
2025                                 break;
2026                         case T_NotifyStmt:
2027                                 _outNotifyStmt(str, obj);
2028                                 break;
2029                         case T_DeclareCursorStmt:
2030                                 _outDeclareCursorStmt(str, obj);
2031                                 break;
2032                         case T_SelectStmt:
2033                                 _outSelectStmt(str, obj);
2034                                 break;
2035                         case T_ColumnDef:
2036                                 _outColumnDef(str, obj);
2037                                 break;
2038                         case T_TypeName:
2039                                 _outTypeName(str, obj);
2040                                 break;
2041                         case T_TypeCast:
2042                                 _outTypeCast(str, obj);
2043                                 break;
2044                         case T_IndexElem:
2045                                 _outIndexElem(str, obj);
2046                                 break;
2047                         case T_Query:
2048                                 _outQuery(str, obj);
2049                                 break;
2050                         case T_SortClause:
2051                                 _outSortClause(str, obj);
2052                                 break;
2053                         case T_GroupClause:
2054                                 _outGroupClause(str, obj);
2055                                 break;
2056                         case T_SetOperationStmt:
2057                                 _outSetOperationStmt(str, obj);
2058                                 break;
2059                         case T_RangeTblEntry:
2060                                 _outRangeTblEntry(str, obj);
2061                                 break;
2062                         case T_A_Expr:
2063                                 _outAExpr(str, obj);
2064                                 break;
2065                         case T_ColumnRef:
2066                                 _outColumnRef(str, obj);
2067                                 break;
2068                         case T_ParamRef:
2069                                 _outParamRef(str, obj);
2070                                 break;
2071                         case T_A_Const:
2072                                 _outAConst(str, obj);
2073                                 break;
2074                         case T_A_Indices:
2075                                 _outA_Indices(str, obj);
2076                                 break;
2077                         case T_A_Indirection:
2078                                 _outA_Indirection(str, obj);
2079                                 break;
2080                         case T_ResTarget:
2081                                 _outResTarget(str, obj);
2082                                 break;
2083                         case T_Constraint:
2084                                 _outConstraint(str, obj);
2085                                 break;
2086                         case T_FkConstraint:
2087                                 _outFkConstraint(str, obj);
2088                                 break;
2089                         case T_FuncCall:
2090                                 _outFuncCall(str, obj);
2091                                 break;
2092                         case T_DefElem:
2093                                 _outDefElem(str, obj);
2094                                 break;
2095                         case T_LockingClause:
2096                                 _outLockingClause(str, obj);
2097                                 break;
2098
2099                         default:
2100
2101                                 /*
2102                                  * This should be an ERROR, but it's too useful to be able
2103                                  * to dump structures that _outNode only understands part
2104                                  * of.
2105                                  */
2106                                 elog(WARNING, "could not dump unrecognized node type: %d",
2107                                          (int) nodeTag(obj));
2108                                 break;
2109                 }
2110                 appendStringInfoChar(str, '}');
2111         }
2112 }
2113
2114 /*
2115  * nodeToString -
2116  *         returns the ascii representation of the Node as a palloc'd string
2117  */
2118 char *
2119 nodeToString(void *obj)
2120 {
2121         StringInfoData str;
2122
2123         /* see stringinfo.h for an explanation of this maneuver */
2124         initStringInfo(&str);
2125         _outNode(&str, obj);
2126         return str.data;
2127 }