]> granicus.if.org Git - postgresql/blob - src/backend/nodes/outfuncs.c
Change EXPLAIN output so that subplans and initplans (particularly CTEs)
[postgresql] / src / backend / nodes / outfuncs.c
1 /*-------------------------------------------------------------------------
2  *
3  * outfuncs.c
4  *        Output functions for Postgres tree nodes.
5  *
6  * Portions Copyright (c) 1996-2009, 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.358 2009/04/05 19:59:40 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/plannodes.h"
28 #include "nodes/relation.h"
29 #include "utils/datum.h"
30
31
32 /*
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
36  * routine.
37  */
38
39 /* Write the label for the node type */
40 #define WRITE_NODE_TYPE(nodelabel) \
41         appendStringInfoString(str, nodelabel)
42
43 /* Write an integer field (anything written as ":fldname %d") */
44 #define WRITE_INT_FIELD(fldname) \
45         appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
46
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)
50
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)
54
55 /* Write a long-integer field */
56 #define WRITE_LONG_FIELD(fldname) \
57         appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
58
59 /* Write a char field (ie, one ascii character) */
60 #define WRITE_CHAR_FIELD(fldname) \
61         appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
62
63 /* Write an enumerated-type field as an integer code */
64 #define WRITE_ENUM_FIELD(fldname, enumtype) \
65         appendStringInfo(str, " :" CppAsString(fldname) " %d", \
66                                          (int) node->fldname)
67
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)
71
72 /* Write a boolean field */
73 #define WRITE_BOOL_FIELD(fldname) \
74         appendStringInfo(str, " :" CppAsString(fldname) " %s", \
75                                          booltostr(node->fldname))
76
77 /* Write a character-string (possibly NULL) field */
78 #define WRITE_STRING_FIELD(fldname) \
79         (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80          _outToken(str, node->fldname))
81
82 /* Write a parse location field (actually same as INT case) */
83 #define WRITE_LOCATION_FIELD(fldname) \
84         appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
85
86 /* Write a Node field */
87 #define WRITE_NODE_FIELD(fldname) \
88         (appendStringInfo(str, " :" CppAsString(fldname) " "), \
89          _outNode(str, node->fldname))
90
91 /* Write a bitmapset field */
92 #define WRITE_BITMAPSET_FIELD(fldname) \
93         (appendStringInfo(str, " :" CppAsString(fldname) " "), \
94          _outBitmapset(str, node->fldname))
95
96
97 #define booltostr(x)  ((x) ? "true" : "false")
98
99 static void _outNode(StringInfo str, void *obj);
100
101
102 /*
103  * _outToken
104  *        Convert an ordinary string (eg, an identifier) into a form that
105  *        will be decoded back to a plain token by read.c's functions.
106  *
107  *        If a null or empty string is given, it is encoded as "<>".
108  */
109 static void
110 _outToken(StringInfo str, char *s)
111 {
112         if (s == NULL || *s == '\0')
113         {
114                 appendStringInfo(str, "<>");
115                 return;
116         }
117
118         /*
119          * Look for characters or patterns that are treated specially by read.c
120          * (either in pg_strtok() or in nodeRead()), and therefore need a
121          * protective backslash.
122          */
123         /* These characters only need to be quoted at the start of the string */
124         if (*s == '<' ||
125                 *s == '\"' ||
126                 isdigit((unsigned char) *s) ||
127                 ((*s == '+' || *s == '-') &&
128                  (isdigit((unsigned char) s[1]) || s[1] == '.')))
129                 appendStringInfoChar(str, '\\');
130         while (*s)
131         {
132                 /* These chars must be backslashed anywhere in the string */
133                 if (*s == ' ' || *s == '\n' || *s == '\t' ||
134                         *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
135                         *s == '\\')
136                         appendStringInfoChar(str, '\\');
137                 appendStringInfoChar(str, *s++);
138         }
139 }
140
141 static void
142 _outList(StringInfo str, List *node)
143 {
144         ListCell   *lc;
145
146         appendStringInfoChar(str, '(');
147
148         if (IsA(node, IntList))
149                 appendStringInfoChar(str, 'i');
150         else if (IsA(node, OidList))
151                 appendStringInfoChar(str, 'o');
152
153         foreach(lc, node)
154         {
155                 /*
156                  * For the sake of backward compatibility, we emit a slightly
157                  * different whitespace format for lists of nodes vs. other types of
158                  * lists. XXX: is this necessary?
159                  */
160                 if (IsA(node, List))
161                 {
162                         _outNode(str, lfirst(lc));
163                         if (lnext(lc))
164                                 appendStringInfoChar(str, ' ');
165                 }
166                 else if (IsA(node, IntList))
167                         appendStringInfo(str, " %d", lfirst_int(lc));
168                 else if (IsA(node, OidList))
169                         appendStringInfo(str, " %u", lfirst_oid(lc));
170                 else
171                         elog(ERROR, "unrecognized list node type: %d",
172                                  (int) node->type);
173         }
174
175         appendStringInfoChar(str, ')');
176 }
177
178 /*
179  * _outBitmapset -
180  *         converts a bitmap set of integers
181  *
182  * Note: the output format is "(b int int ...)", similar to an integer List.
183  */
184 static void
185 _outBitmapset(StringInfo str, Bitmapset *bms)
186 {
187         Bitmapset  *tmpset;
188         int                     x;
189
190         appendStringInfoChar(str, '(');
191         appendStringInfoChar(str, 'b');
192         tmpset = bms_copy(bms);
193         while ((x = bms_first_member(tmpset)) >= 0)
194                 appendStringInfo(str, " %d", x);
195         bms_free(tmpset);
196         appendStringInfoChar(str, ')');
197 }
198
199 /*
200  * Print the value of a Datum given its type.
201  */
202 static void
203 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
204 {
205         Size            length,
206                                 i;
207         char       *s;
208
209         length = datumGetSize(value, typbyval, typlen);
210
211         if (typbyval)
212         {
213                 s = (char *) (&value);
214                 appendStringInfo(str, "%u [ ", (unsigned int) length);
215                 for (i = 0; i < (Size) sizeof(Datum); i++)
216                         appendStringInfo(str, "%d ", (int) (s[i]));
217                 appendStringInfo(str, "]");
218         }
219         else
220         {
221                 s = (char *) DatumGetPointer(value);
222                 if (!PointerIsValid(s))
223                         appendStringInfo(str, "0 [ ]");
224                 else
225                 {
226                         appendStringInfo(str, "%u [ ", (unsigned int) length);
227                         for (i = 0; i < length; i++)
228                                 appendStringInfo(str, "%d ", (int) (s[i]));
229                         appendStringInfo(str, "]");
230                 }
231         }
232 }
233
234
235 /*
236  *      Stuff from plannodes.h
237  */
238
239 static void
240 _outPlannedStmt(StringInfo str, PlannedStmt *node)
241 {
242         WRITE_NODE_TYPE("PLANNEDSTMT");
243
244         WRITE_ENUM_FIELD(commandType, CmdType);
245         WRITE_BOOL_FIELD(canSetTag);
246         WRITE_NODE_FIELD(planTree);
247         WRITE_NODE_FIELD(rtable);
248         WRITE_NODE_FIELD(resultRelations);
249         WRITE_NODE_FIELD(utilityStmt);
250         WRITE_NODE_FIELD(intoClause);
251         WRITE_NODE_FIELD(subplans);
252         WRITE_BITMAPSET_FIELD(rewindPlanIDs);
253         WRITE_NODE_FIELD(returningLists);
254         WRITE_NODE_FIELD(rowMarks);
255         WRITE_NODE_FIELD(relationOids);
256         WRITE_NODE_FIELD(invalItems);
257         WRITE_INT_FIELD(nParamExec);
258 }
259
260 /*
261  * print the basic stuff of all nodes that inherit from Plan
262  */
263 static void
264 _outPlanInfo(StringInfo str, Plan *node)
265 {
266         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
267         WRITE_FLOAT_FIELD(total_cost, "%.2f");
268         WRITE_FLOAT_FIELD(plan_rows, "%.0f");
269         WRITE_INT_FIELD(plan_width);
270         WRITE_NODE_FIELD(targetlist);
271         WRITE_NODE_FIELD(qual);
272         WRITE_NODE_FIELD(lefttree);
273         WRITE_NODE_FIELD(righttree);
274         WRITE_NODE_FIELD(initPlan);
275         WRITE_BITMAPSET_FIELD(extParam);
276         WRITE_BITMAPSET_FIELD(allParam);
277 }
278
279 /*
280  * print the basic stuff of all nodes that inherit from Scan
281  */
282 static void
283 _outScanInfo(StringInfo str, Scan *node)
284 {
285         _outPlanInfo(str, (Plan *) node);
286
287         WRITE_UINT_FIELD(scanrelid);
288 }
289
290 /*
291  * print the basic stuff of all nodes that inherit from Join
292  */
293 static void
294 _outJoinPlanInfo(StringInfo str, Join *node)
295 {
296         _outPlanInfo(str, (Plan *) node);
297
298         WRITE_ENUM_FIELD(jointype, JoinType);
299         WRITE_NODE_FIELD(joinqual);
300 }
301
302
303 static void
304 _outPlan(StringInfo str, Plan *node)
305 {
306         WRITE_NODE_TYPE("PLAN");
307
308         _outPlanInfo(str, (Plan *) node);
309 }
310
311 static void
312 _outResult(StringInfo str, Result *node)
313 {
314         WRITE_NODE_TYPE("RESULT");
315
316         _outPlanInfo(str, (Plan *) node);
317
318         WRITE_NODE_FIELD(resconstantqual);
319 }
320
321 static void
322 _outAppend(StringInfo str, Append *node)
323 {
324         WRITE_NODE_TYPE("APPEND");
325
326         _outPlanInfo(str, (Plan *) node);
327
328         WRITE_NODE_FIELD(appendplans);
329         WRITE_BOOL_FIELD(isTarget);
330 }
331
332 static void
333 _outRecursiveUnion(StringInfo str, RecursiveUnion *node)
334 {
335         int i;
336
337         WRITE_NODE_TYPE("RECURSIVEUNION");
338
339         _outPlanInfo(str, (Plan *) node);
340
341         WRITE_INT_FIELD(wtParam);
342         WRITE_INT_FIELD(numCols);
343
344         appendStringInfo(str, " :dupColIdx");
345         for (i = 0; i < node->numCols; i++)
346                 appendStringInfo(str, " %d", node->dupColIdx[i]);
347
348         appendStringInfo(str, " :dupOperators");
349         for (i = 0; i < node->numCols; i++)
350                 appendStringInfo(str, " %u", node->dupOperators[i]);
351
352         WRITE_LONG_FIELD(numGroups);
353 }
354
355 static void
356 _outBitmapAnd(StringInfo str, BitmapAnd *node)
357 {
358         WRITE_NODE_TYPE("BITMAPAND");
359
360         _outPlanInfo(str, (Plan *) node);
361
362         WRITE_NODE_FIELD(bitmapplans);
363 }
364
365 static void
366 _outBitmapOr(StringInfo str, BitmapOr *node)
367 {
368         WRITE_NODE_TYPE("BITMAPOR");
369
370         _outPlanInfo(str, (Plan *) node);
371
372         WRITE_NODE_FIELD(bitmapplans);
373 }
374
375 static void
376 _outScan(StringInfo str, Scan *node)
377 {
378         WRITE_NODE_TYPE("SCAN");
379
380         _outScanInfo(str, (Scan *) node);
381 }
382
383 static void
384 _outSeqScan(StringInfo str, SeqScan *node)
385 {
386         WRITE_NODE_TYPE("SEQSCAN");
387
388         _outScanInfo(str, (Scan *) node);
389 }
390
391 static void
392 _outIndexScan(StringInfo str, IndexScan *node)
393 {
394         WRITE_NODE_TYPE("INDEXSCAN");
395
396         _outScanInfo(str, (Scan *) node);
397
398         WRITE_OID_FIELD(indexid);
399         WRITE_NODE_FIELD(indexqual);
400         WRITE_NODE_FIELD(indexqualorig);
401         WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
402 }
403
404 static void
405 _outBitmapIndexScan(StringInfo str, BitmapIndexScan *node)
406 {
407         WRITE_NODE_TYPE("BITMAPINDEXSCAN");
408
409         _outScanInfo(str, (Scan *) node);
410
411         WRITE_OID_FIELD(indexid);
412         WRITE_NODE_FIELD(indexqual);
413         WRITE_NODE_FIELD(indexqualorig);
414 }
415
416 static void
417 _outBitmapHeapScan(StringInfo str, BitmapHeapScan *node)
418 {
419         WRITE_NODE_TYPE("BITMAPHEAPSCAN");
420
421         _outScanInfo(str, (Scan *) node);
422
423         WRITE_NODE_FIELD(bitmapqualorig);
424 }
425
426 static void
427 _outTidScan(StringInfo str, TidScan *node)
428 {
429         WRITE_NODE_TYPE("TIDSCAN");
430
431         _outScanInfo(str, (Scan *) node);
432
433         WRITE_NODE_FIELD(tidquals);
434 }
435
436 static void
437 _outSubqueryScan(StringInfo str, SubqueryScan *node)
438 {
439         WRITE_NODE_TYPE("SUBQUERYSCAN");
440
441         _outScanInfo(str, (Scan *) node);
442
443         WRITE_NODE_FIELD(subplan);
444         WRITE_NODE_FIELD(subrtable);
445 }
446
447 static void
448 _outFunctionScan(StringInfo str, FunctionScan *node)
449 {
450         WRITE_NODE_TYPE("FUNCTIONSCAN");
451
452         _outScanInfo(str, (Scan *) node);
453
454         WRITE_NODE_FIELD(funcexpr);
455         WRITE_NODE_FIELD(funccolnames);
456         WRITE_NODE_FIELD(funccoltypes);
457         WRITE_NODE_FIELD(funccoltypmods);
458 }
459
460 static void
461 _outValuesScan(StringInfo str, ValuesScan *node)
462 {
463         WRITE_NODE_TYPE("VALUESSCAN");
464
465         _outScanInfo(str, (Scan *) node);
466
467         WRITE_NODE_FIELD(values_lists);
468 }
469
470 static void
471 _outCteScan(StringInfo str, CteScan *node)
472 {
473         WRITE_NODE_TYPE("CTESCAN");
474
475         _outScanInfo(str, (Scan *) node);
476
477         WRITE_INT_FIELD(ctePlanId);
478         WRITE_INT_FIELD(cteParam);
479 }
480
481 static void
482 _outWorkTableScan(StringInfo str, WorkTableScan *node)
483 {
484         WRITE_NODE_TYPE("WORKTABLESCAN");
485
486         _outScanInfo(str, (Scan *) node);
487
488         WRITE_INT_FIELD(wtParam);
489 }
490
491 static void
492 _outJoin(StringInfo str, Join *node)
493 {
494         WRITE_NODE_TYPE("JOIN");
495
496         _outJoinPlanInfo(str, (Join *) node);
497 }
498
499 static void
500 _outNestLoop(StringInfo str, NestLoop *node)
501 {
502         WRITE_NODE_TYPE("NESTLOOP");
503
504         _outJoinPlanInfo(str, (Join *) node);
505 }
506
507 static void
508 _outMergeJoin(StringInfo str, MergeJoin *node)
509 {
510         int                     numCols;
511         int                     i;
512
513         WRITE_NODE_TYPE("MERGEJOIN");
514
515         _outJoinPlanInfo(str, (Join *) node);
516
517         WRITE_NODE_FIELD(mergeclauses);
518
519         numCols = list_length(node->mergeclauses);
520
521         appendStringInfo(str, " :mergeFamilies");
522         for (i = 0; i < numCols; i++)
523                 appendStringInfo(str, " %u", node->mergeFamilies[i]);
524
525         appendStringInfo(str, " :mergeStrategies");
526         for (i = 0; i < numCols; i++)
527                 appendStringInfo(str, " %d", node->mergeStrategies[i]);
528
529         appendStringInfo(str, " :mergeNullsFirst");
530         for (i = 0; i < numCols; i++)
531                 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
532 }
533
534 static void
535 _outHashJoin(StringInfo str, HashJoin *node)
536 {
537         WRITE_NODE_TYPE("HASHJOIN");
538
539         _outJoinPlanInfo(str, (Join *) node);
540
541         WRITE_NODE_FIELD(hashclauses);
542 }
543
544 static void
545 _outAgg(StringInfo str, Agg *node)
546 {
547         int i;
548
549         WRITE_NODE_TYPE("AGG");
550
551         _outPlanInfo(str, (Plan *) node);
552
553         WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
554         WRITE_INT_FIELD(numCols);
555
556         appendStringInfo(str, " :grpColIdx");
557         for (i = 0; i < node->numCols; i++)
558                 appendStringInfo(str, " %d", node->grpColIdx[i]);
559
560         appendStringInfo(str, " :grpOperators");
561         for (i = 0; i < node->numCols; i++)
562                 appendStringInfo(str, " %u", node->grpOperators[i]);
563
564         WRITE_LONG_FIELD(numGroups);
565 }
566
567 static void
568 _outWindowAgg(StringInfo str, WindowAgg *node)
569 {
570         int                     i;
571
572         WRITE_NODE_TYPE("WINDOWAGG");
573
574         _outPlanInfo(str, (Plan *) node);
575
576         WRITE_UINT_FIELD(winref);
577         WRITE_INT_FIELD(partNumCols);
578
579         appendStringInfo(str, " :partColIdx");
580         for (i = 0; i < node->partNumCols; i++)
581                 appendStringInfo(str, " %d", node->partColIdx[i]);
582
583         appendStringInfo(str, " :partOperations");
584         for (i = 0; i < node->partNumCols; i++)
585                 appendStringInfo(str, " %u", node->partOperators[i]);
586
587         WRITE_INT_FIELD(ordNumCols);
588
589         appendStringInfo(str, " :ordColIdx");
590         for (i = 0; i< node->ordNumCols; i++)
591                 appendStringInfo(str, " %d", node->ordColIdx[i]);
592
593         appendStringInfo(str, " :ordOperations");
594         for (i = 0; i < node->ordNumCols; i++)
595                 appendStringInfo(str, " %u", node->ordOperators[i]);
596
597         WRITE_INT_FIELD(frameOptions);
598 }
599
600 static void
601 _outGroup(StringInfo str, Group *node)
602 {
603         int                     i;
604
605         WRITE_NODE_TYPE("GROUP");
606
607         _outPlanInfo(str, (Plan *) node);
608
609         WRITE_INT_FIELD(numCols);
610
611         appendStringInfo(str, " :grpColIdx");
612         for (i = 0; i < node->numCols; i++)
613                 appendStringInfo(str, " %d", node->grpColIdx[i]);
614
615         appendStringInfo(str, " :grpOperators");
616         for (i = 0; i < node->numCols; i++)
617                 appendStringInfo(str, " %u", node->grpOperators[i]);
618 }
619
620 static void
621 _outMaterial(StringInfo str, Material *node)
622 {
623         WRITE_NODE_TYPE("MATERIAL");
624
625         _outPlanInfo(str, (Plan *) node);
626 }
627
628 static void
629 _outSort(StringInfo str, Sort *node)
630 {
631         int                     i;
632
633         WRITE_NODE_TYPE("SORT");
634
635         _outPlanInfo(str, (Plan *) node);
636
637         WRITE_INT_FIELD(numCols);
638
639         appendStringInfo(str, " :sortColIdx");
640         for (i = 0; i < node->numCols; i++)
641                 appendStringInfo(str, " %d", node->sortColIdx[i]);
642
643         appendStringInfo(str, " :sortOperators");
644         for (i = 0; i < node->numCols; i++)
645                 appendStringInfo(str, " %u", node->sortOperators[i]);
646
647         appendStringInfo(str, " :nullsFirst");
648         for (i = 0; i < node->numCols; i++)
649                 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
650 }
651
652 static void
653 _outUnique(StringInfo str, Unique *node)
654 {
655         int                     i;
656
657         WRITE_NODE_TYPE("UNIQUE");
658
659         _outPlanInfo(str, (Plan *) node);
660
661         WRITE_INT_FIELD(numCols);
662
663         appendStringInfo(str, " :uniqColIdx");
664         for (i = 0; i < node->numCols; i++)
665                 appendStringInfo(str, " %d", node->uniqColIdx[i]);
666
667         appendStringInfo(str, " :uniqOperators");
668         for (i = 0; i < node->numCols; i++)
669                 appendStringInfo(str, " %u", node->uniqOperators[i]);
670 }
671
672 static void
673 _outHash(StringInfo str, Hash *node)
674 {
675         WRITE_NODE_TYPE("HASH");
676
677         _outPlanInfo(str, (Plan *) node);
678
679         WRITE_OID_FIELD(skewTable);
680         WRITE_INT_FIELD(skewColumn);
681         WRITE_OID_FIELD(skewColType);
682         WRITE_INT_FIELD(skewColTypmod);
683 }
684
685 static void
686 _outSetOp(StringInfo str, SetOp *node)
687 {
688         int                     i;
689
690         WRITE_NODE_TYPE("SETOP");
691
692         _outPlanInfo(str, (Plan *) node);
693
694         WRITE_ENUM_FIELD(cmd, SetOpCmd);
695         WRITE_ENUM_FIELD(strategy, SetOpStrategy);
696         WRITE_INT_FIELD(numCols);
697
698         appendStringInfo(str, " :dupColIdx");
699         for (i = 0; i < node->numCols; i++)
700                 appendStringInfo(str, " %d", node->dupColIdx[i]);
701
702         appendStringInfo(str, " :dupOperators");
703         for (i = 0; i < node->numCols; i++)
704                 appendStringInfo(str, " %u", node->dupOperators[i]);
705
706         WRITE_INT_FIELD(flagColIdx);
707         WRITE_INT_FIELD(firstFlag);
708         WRITE_LONG_FIELD(numGroups);
709 }
710
711 static void
712 _outLimit(StringInfo str, Limit *node)
713 {
714         WRITE_NODE_TYPE("LIMIT");
715
716         _outPlanInfo(str, (Plan *) node);
717
718         WRITE_NODE_FIELD(limitOffset);
719         WRITE_NODE_FIELD(limitCount);
720 }
721
722 static void
723 _outPlanInvalItem(StringInfo str, PlanInvalItem *node)
724 {
725         WRITE_NODE_TYPE("PLANINVALITEM");
726
727         WRITE_INT_FIELD(cacheId);
728         appendStringInfo(str, " :tupleId (%u,%u)",
729                                          ItemPointerGetBlockNumber(&node->tupleId),
730                                          ItemPointerGetOffsetNumber(&node->tupleId));
731 }
732
733 /*****************************************************************************
734  *
735  *      Stuff from primnodes.h.
736  *
737  *****************************************************************************/
738
739 static void
740 _outAlias(StringInfo str, Alias *node)
741 {
742         WRITE_NODE_TYPE("ALIAS");
743
744         WRITE_STRING_FIELD(aliasname);
745         WRITE_NODE_FIELD(colnames);
746 }
747
748 static void
749 _outRangeVar(StringInfo str, RangeVar *node)
750 {
751         WRITE_NODE_TYPE("RANGEVAR");
752
753         /*
754          * we deliberately ignore catalogname here, since it is presently not
755          * semantically meaningful
756          */
757         WRITE_STRING_FIELD(schemaname);
758         WRITE_STRING_FIELD(relname);
759         WRITE_ENUM_FIELD(inhOpt, InhOption);
760         WRITE_BOOL_FIELD(istemp);
761         WRITE_NODE_FIELD(alias);
762         WRITE_LOCATION_FIELD(location);
763 }
764
765 static void
766 _outIntoClause(StringInfo str, IntoClause *node)
767 {
768         WRITE_NODE_TYPE("INTOCLAUSE");
769
770         WRITE_NODE_FIELD(rel);
771         WRITE_NODE_FIELD(colNames);
772         WRITE_NODE_FIELD(options);
773         WRITE_ENUM_FIELD(onCommit, OnCommitAction);
774         WRITE_STRING_FIELD(tableSpaceName);
775 }
776
777 static void
778 _outVar(StringInfo str, Var *node)
779 {
780         WRITE_NODE_TYPE("VAR");
781
782         WRITE_UINT_FIELD(varno);
783         WRITE_INT_FIELD(varattno);
784         WRITE_OID_FIELD(vartype);
785         WRITE_INT_FIELD(vartypmod);
786         WRITE_UINT_FIELD(varlevelsup);
787         WRITE_UINT_FIELD(varnoold);
788         WRITE_INT_FIELD(varoattno);
789         WRITE_LOCATION_FIELD(location);
790 }
791
792 static void
793 _outConst(StringInfo str, Const *node)
794 {
795         WRITE_NODE_TYPE("CONST");
796
797         WRITE_OID_FIELD(consttype);
798         WRITE_INT_FIELD(consttypmod);
799         WRITE_INT_FIELD(constlen);
800         WRITE_BOOL_FIELD(constbyval);
801         WRITE_BOOL_FIELD(constisnull);
802         WRITE_LOCATION_FIELD(location);
803
804         appendStringInfo(str, " :constvalue ");
805         if (node->constisnull)
806                 appendStringInfo(str, "<>");
807         else
808                 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
809 }
810
811 static void
812 _outParam(StringInfo str, Param *node)
813 {
814         WRITE_NODE_TYPE("PARAM");
815
816         WRITE_ENUM_FIELD(paramkind, ParamKind);
817         WRITE_INT_FIELD(paramid);
818         WRITE_OID_FIELD(paramtype);
819         WRITE_INT_FIELD(paramtypmod);
820         WRITE_LOCATION_FIELD(location);
821 }
822
823 static void
824 _outAggref(StringInfo str, Aggref *node)
825 {
826         WRITE_NODE_TYPE("AGGREF");
827
828         WRITE_OID_FIELD(aggfnoid);
829         WRITE_OID_FIELD(aggtype);
830         WRITE_NODE_FIELD(args);
831         WRITE_UINT_FIELD(agglevelsup);
832         WRITE_BOOL_FIELD(aggstar);
833         WRITE_BOOL_FIELD(aggdistinct);
834         WRITE_LOCATION_FIELD(location);
835 }
836
837 static void
838 _outWindowFunc(StringInfo str, WindowFunc *node)
839 {
840         WRITE_NODE_TYPE("WINDOWFUNC");
841
842         WRITE_OID_FIELD(winfnoid);
843         WRITE_OID_FIELD(wintype);
844         WRITE_NODE_FIELD(args);
845         WRITE_UINT_FIELD(winref);
846         WRITE_BOOL_FIELD(winstar);
847         WRITE_BOOL_FIELD(winagg);
848         WRITE_LOCATION_FIELD(location);
849 }
850
851 static void
852 _outArrayRef(StringInfo str, ArrayRef *node)
853 {
854         WRITE_NODE_TYPE("ARRAYREF");
855
856         WRITE_OID_FIELD(refarraytype);
857         WRITE_OID_FIELD(refelemtype);
858         WRITE_INT_FIELD(reftypmod);
859         WRITE_NODE_FIELD(refupperindexpr);
860         WRITE_NODE_FIELD(reflowerindexpr);
861         WRITE_NODE_FIELD(refexpr);
862         WRITE_NODE_FIELD(refassgnexpr);
863 }
864
865 static void
866 _outFuncExpr(StringInfo str, FuncExpr *node)
867 {
868         WRITE_NODE_TYPE("FUNCEXPR");
869
870         WRITE_OID_FIELD(funcid);
871         WRITE_OID_FIELD(funcresulttype);
872         WRITE_BOOL_FIELD(funcretset);
873         WRITE_ENUM_FIELD(funcformat, CoercionForm);
874         WRITE_NODE_FIELD(args);
875         WRITE_LOCATION_FIELD(location);
876 }
877
878 static void
879 _outOpExpr(StringInfo str, OpExpr *node)
880 {
881         WRITE_NODE_TYPE("OPEXPR");
882
883         WRITE_OID_FIELD(opno);
884         WRITE_OID_FIELD(opfuncid);
885         WRITE_OID_FIELD(opresulttype);
886         WRITE_BOOL_FIELD(opretset);
887         WRITE_NODE_FIELD(args);
888         WRITE_LOCATION_FIELD(location);
889 }
890
891 static void
892 _outDistinctExpr(StringInfo str, DistinctExpr *node)
893 {
894         WRITE_NODE_TYPE("DISTINCTEXPR");
895
896         WRITE_OID_FIELD(opno);
897         WRITE_OID_FIELD(opfuncid);
898         WRITE_OID_FIELD(opresulttype);
899         WRITE_BOOL_FIELD(opretset);
900         WRITE_NODE_FIELD(args);
901         WRITE_LOCATION_FIELD(location);
902 }
903
904 static void
905 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
906 {
907         WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
908
909         WRITE_OID_FIELD(opno);
910         WRITE_OID_FIELD(opfuncid);
911         WRITE_BOOL_FIELD(useOr);
912         WRITE_NODE_FIELD(args);
913         WRITE_LOCATION_FIELD(location);
914 }
915
916 static void
917 _outBoolExpr(StringInfo str, BoolExpr *node)
918 {
919         char       *opstr = NULL;
920
921         WRITE_NODE_TYPE("BOOLEXPR");
922
923         /* do-it-yourself enum representation */
924         switch (node->boolop)
925         {
926                 case AND_EXPR:
927                         opstr = "and";
928                         break;
929                 case OR_EXPR:
930                         opstr = "or";
931                         break;
932                 case NOT_EXPR:
933                         opstr = "not";
934                         break;
935         }
936         appendStringInfo(str, " :boolop ");
937         _outToken(str, opstr);
938
939         WRITE_NODE_FIELD(args);
940         WRITE_LOCATION_FIELD(location);
941 }
942
943 static void
944 _outSubLink(StringInfo str, SubLink *node)
945 {
946         WRITE_NODE_TYPE("SUBLINK");
947
948         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
949         WRITE_NODE_FIELD(testexpr);
950         WRITE_NODE_FIELD(operName);
951         WRITE_NODE_FIELD(subselect);
952         WRITE_LOCATION_FIELD(location);
953 }
954
955 static void
956 _outSubPlan(StringInfo str, SubPlan *node)
957 {
958         WRITE_NODE_TYPE("SUBPLAN");
959
960         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
961         WRITE_NODE_FIELD(testexpr);
962         WRITE_NODE_FIELD(paramIds);
963         WRITE_INT_FIELD(plan_id);
964         WRITE_STRING_FIELD(plan_name);
965         WRITE_OID_FIELD(firstColType);
966         WRITE_INT_FIELD(firstColTypmod);
967         WRITE_BOOL_FIELD(useHashTable);
968         WRITE_BOOL_FIELD(unknownEqFalse);
969         WRITE_NODE_FIELD(setParam);
970         WRITE_NODE_FIELD(parParam);
971         WRITE_NODE_FIELD(args);
972         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
973         WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
974 }
975
976 static void
977 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
978 {
979         WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
980
981         WRITE_NODE_FIELD(subplans);
982 }
983
984 static void
985 _outFieldSelect(StringInfo str, FieldSelect *node)
986 {
987         WRITE_NODE_TYPE("FIELDSELECT");
988
989         WRITE_NODE_FIELD(arg);
990         WRITE_INT_FIELD(fieldnum);
991         WRITE_OID_FIELD(resulttype);
992         WRITE_INT_FIELD(resulttypmod);
993 }
994
995 static void
996 _outFieldStore(StringInfo str, FieldStore *node)
997 {
998         WRITE_NODE_TYPE("FIELDSTORE");
999
1000         WRITE_NODE_FIELD(arg);
1001         WRITE_NODE_FIELD(newvals);
1002         WRITE_NODE_FIELD(fieldnums);
1003         WRITE_OID_FIELD(resulttype);
1004 }
1005
1006 static void
1007 _outRelabelType(StringInfo str, RelabelType *node)
1008 {
1009         WRITE_NODE_TYPE("RELABELTYPE");
1010
1011         WRITE_NODE_FIELD(arg);
1012         WRITE_OID_FIELD(resulttype);
1013         WRITE_INT_FIELD(resulttypmod);
1014         WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1015         WRITE_LOCATION_FIELD(location);
1016 }
1017
1018 static void
1019 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1020 {
1021         WRITE_NODE_TYPE("COERCEVIAIO");
1022
1023         WRITE_NODE_FIELD(arg);
1024         WRITE_OID_FIELD(resulttype);
1025         WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1026         WRITE_LOCATION_FIELD(location);
1027 }
1028
1029 static void
1030 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1031 {
1032         WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1033
1034         WRITE_NODE_FIELD(arg);
1035         WRITE_OID_FIELD(elemfuncid);
1036         WRITE_OID_FIELD(resulttype);
1037         WRITE_INT_FIELD(resulttypmod);
1038         WRITE_BOOL_FIELD(isExplicit);
1039         WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1040         WRITE_LOCATION_FIELD(location);
1041 }
1042
1043 static void
1044 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1045 {
1046         WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1047
1048         WRITE_NODE_FIELD(arg);
1049         WRITE_OID_FIELD(resulttype);
1050         WRITE_ENUM_FIELD(convertformat, CoercionForm);
1051         WRITE_LOCATION_FIELD(location);
1052 }
1053
1054 static void
1055 _outCaseExpr(StringInfo str, CaseExpr *node)
1056 {
1057         WRITE_NODE_TYPE("CASE");
1058
1059         WRITE_OID_FIELD(casetype);
1060         WRITE_NODE_FIELD(arg);
1061         WRITE_NODE_FIELD(args);
1062         WRITE_NODE_FIELD(defresult);
1063         WRITE_LOCATION_FIELD(location);
1064 }
1065
1066 static void
1067 _outCaseWhen(StringInfo str, CaseWhen *node)
1068 {
1069         WRITE_NODE_TYPE("WHEN");
1070
1071         WRITE_NODE_FIELD(expr);
1072         WRITE_NODE_FIELD(result);
1073         WRITE_LOCATION_FIELD(location);
1074 }
1075
1076 static void
1077 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1078 {
1079         WRITE_NODE_TYPE("CASETESTEXPR");
1080
1081         WRITE_OID_FIELD(typeId);
1082         WRITE_INT_FIELD(typeMod);
1083 }
1084
1085 static void
1086 _outArrayExpr(StringInfo str, ArrayExpr *node)
1087 {
1088         WRITE_NODE_TYPE("ARRAY");
1089
1090         WRITE_OID_FIELD(array_typeid);
1091         WRITE_OID_FIELD(element_typeid);
1092         WRITE_NODE_FIELD(elements);
1093         WRITE_BOOL_FIELD(multidims);
1094         WRITE_LOCATION_FIELD(location);
1095 }
1096
1097 static void
1098 _outRowExpr(StringInfo str, RowExpr *node)
1099 {
1100         WRITE_NODE_TYPE("ROW");
1101
1102         WRITE_NODE_FIELD(args);
1103         WRITE_OID_FIELD(row_typeid);
1104         WRITE_ENUM_FIELD(row_format, CoercionForm);
1105         WRITE_NODE_FIELD(colnames);
1106         WRITE_LOCATION_FIELD(location);
1107 }
1108
1109 static void
1110 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1111 {
1112         WRITE_NODE_TYPE("ROWCOMPARE");
1113
1114         WRITE_ENUM_FIELD(rctype, RowCompareType);
1115         WRITE_NODE_FIELD(opnos);
1116         WRITE_NODE_FIELD(opfamilies);
1117         WRITE_NODE_FIELD(largs);
1118         WRITE_NODE_FIELD(rargs);
1119 }
1120
1121 static void
1122 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1123 {
1124         WRITE_NODE_TYPE("COALESCE");
1125
1126         WRITE_OID_FIELD(coalescetype);
1127         WRITE_NODE_FIELD(args);
1128         WRITE_LOCATION_FIELD(location);
1129 }
1130
1131 static void
1132 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1133 {
1134         WRITE_NODE_TYPE("MINMAX");
1135
1136         WRITE_OID_FIELD(minmaxtype);
1137         WRITE_ENUM_FIELD(op, MinMaxOp);
1138         WRITE_NODE_FIELD(args);
1139         WRITE_LOCATION_FIELD(location);
1140 }
1141
1142 static void
1143 _outXmlExpr(StringInfo str, XmlExpr *node)
1144 {
1145         WRITE_NODE_TYPE("XMLEXPR");
1146
1147         WRITE_ENUM_FIELD(op, XmlExprOp);
1148         WRITE_STRING_FIELD(name);
1149         WRITE_NODE_FIELD(named_args);
1150         WRITE_NODE_FIELD(arg_names);
1151         WRITE_NODE_FIELD(args);
1152         WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1153         WRITE_OID_FIELD(type);
1154         WRITE_INT_FIELD(typmod);
1155         WRITE_LOCATION_FIELD(location);
1156 }
1157
1158 static void
1159 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1160 {
1161         WRITE_NODE_TYPE("NULLIFEXPR");
1162
1163         WRITE_OID_FIELD(opno);
1164         WRITE_OID_FIELD(opfuncid);
1165         WRITE_OID_FIELD(opresulttype);
1166         WRITE_BOOL_FIELD(opretset);
1167         WRITE_NODE_FIELD(args);
1168         WRITE_LOCATION_FIELD(location);
1169 }
1170
1171 static void
1172 _outNullTest(StringInfo str, NullTest *node)
1173 {
1174         WRITE_NODE_TYPE("NULLTEST");
1175
1176         WRITE_NODE_FIELD(arg);
1177         WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1178 }
1179
1180 static void
1181 _outBooleanTest(StringInfo str, BooleanTest *node)
1182 {
1183         WRITE_NODE_TYPE("BOOLEANTEST");
1184
1185         WRITE_NODE_FIELD(arg);
1186         WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1187 }
1188
1189 static void
1190 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1191 {
1192         WRITE_NODE_TYPE("COERCETODOMAIN");
1193
1194         WRITE_NODE_FIELD(arg);
1195         WRITE_OID_FIELD(resulttype);
1196         WRITE_INT_FIELD(resulttypmod);
1197         WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1198         WRITE_LOCATION_FIELD(location);
1199 }
1200
1201 static void
1202 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1203 {
1204         WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1205
1206         WRITE_OID_FIELD(typeId);
1207         WRITE_INT_FIELD(typeMod);
1208         WRITE_LOCATION_FIELD(location);
1209 }
1210
1211 static void
1212 _outSetToDefault(StringInfo str, SetToDefault *node)
1213 {
1214         WRITE_NODE_TYPE("SETTODEFAULT");
1215
1216         WRITE_OID_FIELD(typeId);
1217         WRITE_INT_FIELD(typeMod);
1218         WRITE_LOCATION_FIELD(location);
1219 }
1220
1221 static void
1222 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1223 {
1224         WRITE_NODE_TYPE("CURRENTOFEXPR");
1225
1226         WRITE_UINT_FIELD(cvarno);
1227         WRITE_STRING_FIELD(cursor_name);
1228         WRITE_INT_FIELD(cursor_param);
1229 }
1230
1231 static void
1232 _outTargetEntry(StringInfo str, TargetEntry *node)
1233 {
1234         WRITE_NODE_TYPE("TARGETENTRY");
1235
1236         WRITE_NODE_FIELD(expr);
1237         WRITE_INT_FIELD(resno);
1238         WRITE_STRING_FIELD(resname);
1239         WRITE_UINT_FIELD(ressortgroupref);
1240         WRITE_OID_FIELD(resorigtbl);
1241         WRITE_INT_FIELD(resorigcol);
1242         WRITE_BOOL_FIELD(resjunk);
1243 }
1244
1245 static void
1246 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1247 {
1248         WRITE_NODE_TYPE("RANGETBLREF");
1249
1250         WRITE_INT_FIELD(rtindex);
1251 }
1252
1253 static void
1254 _outJoinExpr(StringInfo str, JoinExpr *node)
1255 {
1256         WRITE_NODE_TYPE("JOINEXPR");
1257
1258         WRITE_ENUM_FIELD(jointype, JoinType);
1259         WRITE_BOOL_FIELD(isNatural);
1260         WRITE_NODE_FIELD(larg);
1261         WRITE_NODE_FIELD(rarg);
1262         WRITE_NODE_FIELD(using);
1263         WRITE_NODE_FIELD(quals);
1264         WRITE_NODE_FIELD(alias);
1265         WRITE_INT_FIELD(rtindex);
1266 }
1267
1268 static void
1269 _outFromExpr(StringInfo str, FromExpr *node)
1270 {
1271         WRITE_NODE_TYPE("FROMEXPR");
1272
1273         WRITE_NODE_FIELD(fromlist);
1274         WRITE_NODE_FIELD(quals);
1275 }
1276
1277 /*****************************************************************************
1278  *
1279  *      Stuff from relation.h.
1280  *
1281  *****************************************************************************/
1282
1283 /*
1284  * print the basic stuff of all nodes that inherit from Path
1285  *
1286  * Note we do NOT print the parent, else we'd be in infinite recursion
1287  */
1288 static void
1289 _outPathInfo(StringInfo str, Path *node)
1290 {
1291         WRITE_ENUM_FIELD(pathtype, NodeTag);
1292         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1293         WRITE_FLOAT_FIELD(total_cost, "%.2f");
1294         WRITE_NODE_FIELD(pathkeys);
1295 }
1296
1297 /*
1298  * print the basic stuff of all nodes that inherit from JoinPath
1299  */
1300 static void
1301 _outJoinPathInfo(StringInfo str, JoinPath *node)
1302 {
1303         _outPathInfo(str, (Path *) node);
1304
1305         WRITE_ENUM_FIELD(jointype, JoinType);
1306         WRITE_NODE_FIELD(outerjoinpath);
1307         WRITE_NODE_FIELD(innerjoinpath);
1308         WRITE_NODE_FIELD(joinrestrictinfo);
1309 }
1310
1311 static void
1312 _outPath(StringInfo str, Path *node)
1313 {
1314         WRITE_NODE_TYPE("PATH");
1315
1316         _outPathInfo(str, (Path *) node);
1317 }
1318
1319 static void
1320 _outIndexPath(StringInfo str, IndexPath *node)
1321 {
1322         WRITE_NODE_TYPE("INDEXPATH");
1323
1324         _outPathInfo(str, (Path *) node);
1325
1326         WRITE_NODE_FIELD(indexinfo);
1327         WRITE_NODE_FIELD(indexclauses);
1328         WRITE_NODE_FIELD(indexquals);
1329         WRITE_BOOL_FIELD(isjoininner);
1330         WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1331         WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1332         WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1333         WRITE_FLOAT_FIELD(rows, "%.0f");
1334 }
1335
1336 static void
1337 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1338 {
1339         WRITE_NODE_TYPE("BITMAPHEAPPATH");
1340
1341         _outPathInfo(str, (Path *) node);
1342
1343         WRITE_NODE_FIELD(bitmapqual);
1344         WRITE_BOOL_FIELD(isjoininner);
1345         WRITE_FLOAT_FIELD(rows, "%.0f");
1346 }
1347
1348 static void
1349 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1350 {
1351         WRITE_NODE_TYPE("BITMAPANDPATH");
1352
1353         _outPathInfo(str, (Path *) node);
1354
1355         WRITE_NODE_FIELD(bitmapquals);
1356         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1357 }
1358
1359 static void
1360 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1361 {
1362         WRITE_NODE_TYPE("BITMAPORPATH");
1363
1364         _outPathInfo(str, (Path *) node);
1365
1366         WRITE_NODE_FIELD(bitmapquals);
1367         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1368 }
1369
1370 static void
1371 _outTidPath(StringInfo str, TidPath *node)
1372 {
1373         WRITE_NODE_TYPE("TIDPATH");
1374
1375         _outPathInfo(str, (Path *) node);
1376
1377         WRITE_NODE_FIELD(tidquals);
1378 }
1379
1380 static void
1381 _outAppendPath(StringInfo str, AppendPath *node)
1382 {
1383         WRITE_NODE_TYPE("APPENDPATH");
1384
1385         _outPathInfo(str, (Path *) node);
1386
1387         WRITE_NODE_FIELD(subpaths);
1388 }
1389
1390 static void
1391 _outResultPath(StringInfo str, ResultPath *node)
1392 {
1393         WRITE_NODE_TYPE("RESULTPATH");
1394
1395         _outPathInfo(str, (Path *) node);
1396
1397         WRITE_NODE_FIELD(quals);
1398 }
1399
1400 static void
1401 _outMaterialPath(StringInfo str, MaterialPath *node)
1402 {
1403         WRITE_NODE_TYPE("MATERIALPATH");
1404
1405         _outPathInfo(str, (Path *) node);
1406
1407         WRITE_NODE_FIELD(subpath);
1408 }
1409
1410 static void
1411 _outUniquePath(StringInfo str, UniquePath *node)
1412 {
1413         WRITE_NODE_TYPE("UNIQUEPATH");
1414
1415         _outPathInfo(str, (Path *) node);
1416
1417         WRITE_NODE_FIELD(subpath);
1418         WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1419         WRITE_NODE_FIELD(in_operators);
1420         WRITE_NODE_FIELD(uniq_exprs);
1421         WRITE_FLOAT_FIELD(rows, "%.0f");
1422 }
1423
1424 static void
1425 _outNestPath(StringInfo str, NestPath *node)
1426 {
1427         WRITE_NODE_TYPE("NESTPATH");
1428
1429         _outJoinPathInfo(str, (JoinPath *) node);
1430 }
1431
1432 static void
1433 _outMergePath(StringInfo str, MergePath *node)
1434 {
1435         WRITE_NODE_TYPE("MERGEPATH");
1436
1437         _outJoinPathInfo(str, (JoinPath *) node);
1438
1439         WRITE_NODE_FIELD(path_mergeclauses);
1440         WRITE_NODE_FIELD(outersortkeys);
1441         WRITE_NODE_FIELD(innersortkeys);
1442 }
1443
1444 static void
1445 _outHashPath(StringInfo str, HashPath *node)
1446 {
1447         WRITE_NODE_TYPE("HASHPATH");
1448
1449         _outJoinPathInfo(str, (JoinPath *) node);
1450
1451         WRITE_NODE_FIELD(path_hashclauses);
1452         WRITE_INT_FIELD(num_batches);
1453 }
1454
1455 static void
1456 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1457 {
1458         WRITE_NODE_TYPE("PLANNERGLOBAL");
1459
1460         /* NB: this isn't a complete set of fields */
1461         WRITE_NODE_FIELD(paramlist);
1462         WRITE_NODE_FIELD(subplans);
1463         WRITE_NODE_FIELD(subrtables);
1464         WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1465         WRITE_NODE_FIELD(finalrtable);
1466         WRITE_NODE_FIELD(relationOids);
1467         WRITE_NODE_FIELD(invalItems);
1468         WRITE_UINT_FIELD(lastPHId);
1469         WRITE_BOOL_FIELD(transientPlan);
1470 }
1471
1472 static void
1473 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1474 {
1475         WRITE_NODE_TYPE("PLANNERINFO");
1476
1477         /* NB: this isn't a complete set of fields */
1478         WRITE_NODE_FIELD(parse);
1479         WRITE_NODE_FIELD(glob);
1480         WRITE_UINT_FIELD(query_level);
1481         WRITE_NODE_FIELD(join_rel_list);
1482         WRITE_NODE_FIELD(resultRelations);
1483         WRITE_NODE_FIELD(returningLists);
1484         WRITE_NODE_FIELD(init_plans);
1485         WRITE_NODE_FIELD(cte_plan_ids);
1486         WRITE_NODE_FIELD(eq_classes);
1487         WRITE_NODE_FIELD(canon_pathkeys);
1488         WRITE_NODE_FIELD(left_join_clauses);
1489         WRITE_NODE_FIELD(right_join_clauses);
1490         WRITE_NODE_FIELD(full_join_clauses);
1491         WRITE_NODE_FIELD(join_info_list);
1492         WRITE_NODE_FIELD(append_rel_list);
1493         WRITE_NODE_FIELD(placeholder_list);
1494         WRITE_NODE_FIELD(query_pathkeys);
1495         WRITE_NODE_FIELD(group_pathkeys);
1496         WRITE_NODE_FIELD(window_pathkeys);
1497         WRITE_NODE_FIELD(distinct_pathkeys);
1498         WRITE_NODE_FIELD(sort_pathkeys);
1499         WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1500         WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1501         WRITE_BOOL_FIELD(hasJoinRTEs);
1502         WRITE_BOOL_FIELD(hasHavingQual);
1503         WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1504         WRITE_BOOL_FIELD(hasRecursion);
1505         WRITE_INT_FIELD(wt_param_id);
1506 }
1507
1508 static void
1509 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1510 {
1511         WRITE_NODE_TYPE("RELOPTINFO");
1512
1513         /* NB: this isn't a complete set of fields */
1514         WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1515         WRITE_BITMAPSET_FIELD(relids);
1516         WRITE_FLOAT_FIELD(rows, "%.0f");
1517         WRITE_INT_FIELD(width);
1518         WRITE_NODE_FIELD(reltargetlist);
1519         WRITE_NODE_FIELD(pathlist);
1520         WRITE_NODE_FIELD(cheapest_startup_path);
1521         WRITE_NODE_FIELD(cheapest_total_path);
1522         WRITE_NODE_FIELD(cheapest_unique_path);
1523         WRITE_UINT_FIELD(relid);
1524         WRITE_ENUM_FIELD(rtekind, RTEKind);
1525         WRITE_INT_FIELD(min_attr);
1526         WRITE_INT_FIELD(max_attr);
1527         WRITE_NODE_FIELD(indexlist);
1528         WRITE_UINT_FIELD(pages);
1529         WRITE_FLOAT_FIELD(tuples, "%.0f");
1530         WRITE_NODE_FIELD(subplan);
1531         WRITE_NODE_FIELD(subrtable);
1532         WRITE_NODE_FIELD(baserestrictinfo);
1533         WRITE_NODE_FIELD(joininfo);
1534         WRITE_BOOL_FIELD(has_eclass_joins);
1535         WRITE_BITMAPSET_FIELD(index_outer_relids);
1536         WRITE_NODE_FIELD(index_inner_paths);
1537 }
1538
1539 static void
1540 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1541 {
1542         WRITE_NODE_TYPE("INDEXOPTINFO");
1543
1544         /* NB: this isn't a complete set of fields */
1545         WRITE_OID_FIELD(indexoid);
1546         /* Do NOT print rel field, else infinite recursion */
1547         WRITE_UINT_FIELD(pages);
1548         WRITE_FLOAT_FIELD(tuples, "%.0f");
1549         WRITE_INT_FIELD(ncolumns);
1550         WRITE_NODE_FIELD(indexprs);
1551         WRITE_NODE_FIELD(indpred);
1552         WRITE_BOOL_FIELD(predOK);
1553         WRITE_BOOL_FIELD(unique);
1554 }
1555
1556 static void
1557 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1558 {
1559         /*
1560          * To simplify reading, we just chase up to the topmost merged EC and
1561          * print that, without bothering to show the merge-ees separately.
1562          */
1563         while (node->ec_merged)
1564                 node = node->ec_merged;
1565
1566         WRITE_NODE_TYPE("EQUIVALENCECLASS");
1567
1568         WRITE_NODE_FIELD(ec_opfamilies);
1569         WRITE_NODE_FIELD(ec_members);
1570         WRITE_NODE_FIELD(ec_sources);
1571         WRITE_NODE_FIELD(ec_derives);
1572         WRITE_BITMAPSET_FIELD(ec_relids);
1573         WRITE_BOOL_FIELD(ec_has_const);
1574         WRITE_BOOL_FIELD(ec_has_volatile);
1575         WRITE_BOOL_FIELD(ec_below_outer_join);
1576         WRITE_BOOL_FIELD(ec_broken);
1577         WRITE_UINT_FIELD(ec_sortref);
1578 }
1579
1580 static void
1581 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1582 {
1583         WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1584
1585         WRITE_NODE_FIELD(em_expr);
1586         WRITE_BITMAPSET_FIELD(em_relids);
1587         WRITE_BOOL_FIELD(em_is_const);
1588         WRITE_BOOL_FIELD(em_is_child);
1589         WRITE_OID_FIELD(em_datatype);
1590 }
1591
1592 static void
1593 _outPathKey(StringInfo str, PathKey *node)
1594 {
1595         WRITE_NODE_TYPE("PATHKEY");
1596
1597         WRITE_NODE_FIELD(pk_eclass);
1598         WRITE_OID_FIELD(pk_opfamily);
1599         WRITE_INT_FIELD(pk_strategy);
1600         WRITE_BOOL_FIELD(pk_nulls_first);
1601 }
1602
1603 static void
1604 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1605 {
1606         WRITE_NODE_TYPE("RESTRICTINFO");
1607
1608         /* NB: this isn't a complete set of fields */
1609         WRITE_NODE_FIELD(clause);
1610         WRITE_BOOL_FIELD(is_pushed_down);
1611         WRITE_BOOL_FIELD(outerjoin_delayed);
1612         WRITE_BOOL_FIELD(can_join);
1613         WRITE_BOOL_FIELD(pseudoconstant);
1614         WRITE_BITMAPSET_FIELD(clause_relids);
1615         WRITE_BITMAPSET_FIELD(required_relids);
1616         WRITE_BITMAPSET_FIELD(left_relids);
1617         WRITE_BITMAPSET_FIELD(right_relids);
1618         WRITE_NODE_FIELD(orclause);
1619         /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1620         WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1621         WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1622         WRITE_NODE_FIELD(mergeopfamilies);
1623         /* don't write left_ec, leads to infinite recursion in plan tree dump */
1624         /* don't write right_ec, leads to infinite recursion in plan tree dump */
1625         WRITE_NODE_FIELD(left_em);
1626         WRITE_NODE_FIELD(right_em);
1627         WRITE_BOOL_FIELD(outer_is_left);
1628         WRITE_OID_FIELD(hashjoinoperator);
1629 }
1630
1631 static void
1632 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1633 {
1634         WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1635         WRITE_BITMAPSET_FIELD(other_relids);
1636         WRITE_BOOL_FIELD(isouterjoin);
1637         WRITE_NODE_FIELD(cheapest_startup_innerpath);
1638         WRITE_NODE_FIELD(cheapest_total_innerpath);
1639 }
1640
1641 static void
1642 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1643 {
1644         WRITE_NODE_TYPE("PLACEHOLDERVAR");
1645
1646         WRITE_NODE_FIELD(phexpr);
1647         WRITE_BITMAPSET_FIELD(phrels);
1648         WRITE_UINT_FIELD(phid);
1649         WRITE_UINT_FIELD(phlevelsup);
1650 }
1651
1652 static void
1653 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1654 {
1655         WRITE_NODE_TYPE("SPECIALJOININFO");
1656
1657         WRITE_BITMAPSET_FIELD(min_lefthand);
1658         WRITE_BITMAPSET_FIELD(min_righthand);
1659         WRITE_BITMAPSET_FIELD(syn_lefthand);
1660         WRITE_BITMAPSET_FIELD(syn_righthand);
1661         WRITE_ENUM_FIELD(jointype, JoinType);
1662         WRITE_BOOL_FIELD(lhs_strict);
1663         WRITE_BOOL_FIELD(delay_upper_joins);
1664         WRITE_NODE_FIELD(join_quals);
1665 }
1666
1667 static void
1668 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1669 {
1670         WRITE_NODE_TYPE("APPENDRELINFO");
1671
1672         WRITE_UINT_FIELD(parent_relid);
1673         WRITE_UINT_FIELD(child_relid);
1674         WRITE_OID_FIELD(parent_reltype);
1675         WRITE_OID_FIELD(child_reltype);
1676         WRITE_NODE_FIELD(translated_vars);
1677         WRITE_OID_FIELD(parent_reloid);
1678 }
1679
1680 static void
1681 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1682 {
1683         WRITE_NODE_TYPE("PLACEHOLDERINFO");
1684
1685         WRITE_UINT_FIELD(phid);
1686         WRITE_NODE_FIELD(ph_var);
1687         WRITE_BITMAPSET_FIELD(ph_eval_at);
1688         WRITE_BITMAPSET_FIELD(ph_needed);
1689         WRITE_INT_FIELD(ph_width);
1690 }
1691
1692 static void
1693 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1694 {
1695         WRITE_NODE_TYPE("PLANNERPARAMITEM");
1696
1697         WRITE_NODE_FIELD(item);
1698         WRITE_UINT_FIELD(abslevel);
1699 }
1700
1701 /*****************************************************************************
1702  *
1703  *      Stuff from parsenodes.h.
1704  *
1705  *****************************************************************************/
1706
1707 static void
1708 _outCreateStmt(StringInfo str, CreateStmt *node)
1709 {
1710         WRITE_NODE_TYPE("CREATESTMT");
1711
1712         WRITE_NODE_FIELD(relation);
1713         WRITE_NODE_FIELD(tableElts);
1714         WRITE_NODE_FIELD(inhRelations);
1715         WRITE_NODE_FIELD(constraints);
1716         WRITE_NODE_FIELD(options);
1717         WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1718         WRITE_STRING_FIELD(tablespacename);
1719 }
1720
1721 static void
1722 _outIndexStmt(StringInfo str, IndexStmt *node)
1723 {
1724         WRITE_NODE_TYPE("INDEXSTMT");
1725
1726         WRITE_STRING_FIELD(idxname);
1727         WRITE_NODE_FIELD(relation);
1728         WRITE_STRING_FIELD(accessMethod);
1729         WRITE_STRING_FIELD(tableSpace);
1730         WRITE_NODE_FIELD(indexParams);
1731         WRITE_NODE_FIELD(options);
1732         WRITE_NODE_FIELD(whereClause);
1733         WRITE_BOOL_FIELD(unique);
1734         WRITE_BOOL_FIELD(primary);
1735         WRITE_BOOL_FIELD(isconstraint);
1736         WRITE_BOOL_FIELD(concurrent);
1737 }
1738
1739 static void
1740 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1741 {
1742         WRITE_NODE_TYPE("NOTIFY");
1743
1744         WRITE_STRING_FIELD(conditionname);
1745 }
1746
1747 static void
1748 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1749 {
1750         WRITE_NODE_TYPE("DECLARECURSOR");
1751
1752         WRITE_STRING_FIELD(portalname);
1753         WRITE_INT_FIELD(options);
1754         WRITE_NODE_FIELD(query);
1755 }
1756
1757 static void
1758 _outSelectStmt(StringInfo str, SelectStmt *node)
1759 {
1760         WRITE_NODE_TYPE("SELECT");
1761
1762         WRITE_NODE_FIELD(distinctClause);
1763         WRITE_NODE_FIELD(intoClause);
1764         WRITE_NODE_FIELD(targetList);
1765         WRITE_NODE_FIELD(fromClause);
1766         WRITE_NODE_FIELD(whereClause);
1767         WRITE_NODE_FIELD(groupClause);
1768         WRITE_NODE_FIELD(havingClause);
1769         WRITE_NODE_FIELD(windowClause);
1770         WRITE_NODE_FIELD(withClause);
1771         WRITE_NODE_FIELD(valuesLists);
1772         WRITE_NODE_FIELD(sortClause);
1773         WRITE_NODE_FIELD(limitOffset);
1774         WRITE_NODE_FIELD(limitCount);
1775         WRITE_NODE_FIELD(lockingClause);
1776         WRITE_ENUM_FIELD(op, SetOperation);
1777         WRITE_BOOL_FIELD(all);
1778         WRITE_NODE_FIELD(larg);
1779         WRITE_NODE_FIELD(rarg);
1780 }
1781
1782 static void
1783 _outFuncCall(StringInfo str, FuncCall *node)
1784 {
1785         WRITE_NODE_TYPE("FUNCCALL");
1786
1787         WRITE_NODE_FIELD(funcname);
1788         WRITE_NODE_FIELD(args);
1789         WRITE_BOOL_FIELD(agg_star);
1790         WRITE_BOOL_FIELD(agg_distinct);
1791         WRITE_BOOL_FIELD(func_variadic);
1792         WRITE_NODE_FIELD(over);
1793         WRITE_LOCATION_FIELD(location);
1794 }
1795
1796 static void
1797 _outDefElem(StringInfo str, DefElem *node)
1798 {
1799         WRITE_NODE_TYPE("DEFELEM");
1800
1801         WRITE_STRING_FIELD(defnamespace);
1802         WRITE_STRING_FIELD(defname);
1803         WRITE_NODE_FIELD(arg);
1804         WRITE_ENUM_FIELD(defaction, DefElemAction);
1805 }
1806
1807 static void
1808 _outLockingClause(StringInfo str, LockingClause *node)
1809 {
1810         WRITE_NODE_TYPE("LOCKINGCLAUSE");
1811
1812         WRITE_NODE_FIELD(lockedRels);
1813         WRITE_BOOL_FIELD(forUpdate);
1814         WRITE_BOOL_FIELD(noWait);
1815 }
1816
1817 static void
1818 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1819 {
1820         WRITE_NODE_TYPE("XMLSERIALIZE");
1821
1822         WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1823         WRITE_NODE_FIELD(expr);
1824         WRITE_NODE_FIELD(typename);
1825         WRITE_LOCATION_FIELD(location);
1826 }
1827
1828 static void
1829 _outColumnDef(StringInfo str, ColumnDef *node)
1830 {
1831         WRITE_NODE_TYPE("COLUMNDEF");
1832
1833         WRITE_STRING_FIELD(colname);
1834         WRITE_NODE_FIELD(typename);
1835         WRITE_INT_FIELD(inhcount);
1836         WRITE_BOOL_FIELD(is_local);
1837         WRITE_BOOL_FIELD(is_not_null);
1838         WRITE_NODE_FIELD(raw_default);
1839         WRITE_STRING_FIELD(cooked_default);
1840         WRITE_NODE_FIELD(constraints);
1841 }
1842
1843 static void
1844 _outTypeName(StringInfo str, TypeName *node)
1845 {
1846         WRITE_NODE_TYPE("TYPENAME");
1847
1848         WRITE_NODE_FIELD(names);
1849         WRITE_OID_FIELD(typeid);
1850         WRITE_BOOL_FIELD(setof);
1851         WRITE_BOOL_FIELD(pct_type);
1852         WRITE_NODE_FIELD(typmods);
1853         WRITE_INT_FIELD(typemod);
1854         WRITE_NODE_FIELD(arrayBounds);
1855         WRITE_LOCATION_FIELD(location);
1856 }
1857
1858 static void
1859 _outTypeCast(StringInfo str, TypeCast *node)
1860 {
1861         WRITE_NODE_TYPE("TYPECAST");
1862
1863         WRITE_NODE_FIELD(arg);
1864         WRITE_NODE_FIELD(typename);
1865         WRITE_LOCATION_FIELD(location);
1866 }
1867
1868 static void
1869 _outIndexElem(StringInfo str, IndexElem *node)
1870 {
1871         WRITE_NODE_TYPE("INDEXELEM");
1872
1873         WRITE_STRING_FIELD(name);
1874         WRITE_NODE_FIELD(expr);
1875         WRITE_NODE_FIELD(opclass);
1876         WRITE_ENUM_FIELD(ordering, SortByDir);
1877         WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1878 }
1879
1880 static void
1881 _outQuery(StringInfo str, Query *node)
1882 {
1883         WRITE_NODE_TYPE("QUERY");
1884
1885         WRITE_ENUM_FIELD(commandType, CmdType);
1886         WRITE_ENUM_FIELD(querySource, QuerySource);
1887         WRITE_BOOL_FIELD(canSetTag);
1888
1889         /*
1890          * Hack to work around missing outfuncs routines for a lot of the
1891          * utility-statement node types.  (The only one we actually *need* for
1892          * rules support is NotifyStmt.)  Someday we ought to support 'em all, but
1893          * for the meantime do this to avoid getting lots of warnings when running
1894          * with debug_print_parse on.
1895          */
1896         if (node->utilityStmt)
1897         {
1898                 switch (nodeTag(node->utilityStmt))
1899                 {
1900                         case T_CreateStmt:
1901                         case T_IndexStmt:
1902                         case T_NotifyStmt:
1903                         case T_DeclareCursorStmt:
1904                                 WRITE_NODE_FIELD(utilityStmt);
1905                                 break;
1906                         default:
1907                                 appendStringInfo(str, " :utilityStmt ?");
1908                                 break;
1909                 }
1910         }
1911         else
1912                 appendStringInfo(str, " :utilityStmt <>");
1913
1914         WRITE_INT_FIELD(resultRelation);
1915         WRITE_NODE_FIELD(intoClause);
1916         WRITE_BOOL_FIELD(hasAggs);
1917         WRITE_BOOL_FIELD(hasWindowFuncs);
1918         WRITE_BOOL_FIELD(hasSubLinks);
1919         WRITE_BOOL_FIELD(hasDistinctOn);
1920         WRITE_BOOL_FIELD(hasRecursive);
1921         WRITE_NODE_FIELD(cteList);
1922         WRITE_NODE_FIELD(rtable);
1923         WRITE_NODE_FIELD(jointree);
1924         WRITE_NODE_FIELD(targetList);
1925         WRITE_NODE_FIELD(returningList);
1926         WRITE_NODE_FIELD(groupClause);
1927         WRITE_NODE_FIELD(havingQual);
1928         WRITE_NODE_FIELD(windowClause);
1929         WRITE_NODE_FIELD(distinctClause);
1930         WRITE_NODE_FIELD(sortClause);
1931         WRITE_NODE_FIELD(limitOffset);
1932         WRITE_NODE_FIELD(limitCount);
1933         WRITE_NODE_FIELD(rowMarks);
1934         WRITE_NODE_FIELD(setOperations);
1935 }
1936
1937 static void
1938 _outSortGroupClause(StringInfo str, SortGroupClause *node)
1939 {
1940         WRITE_NODE_TYPE("SORTGROUPCLAUSE");
1941
1942         WRITE_UINT_FIELD(tleSortGroupRef);
1943         WRITE_OID_FIELD(eqop);
1944         WRITE_OID_FIELD(sortop);
1945         WRITE_BOOL_FIELD(nulls_first);
1946 }
1947
1948 static void
1949 _outWindowClause(StringInfo str, WindowClause *node)
1950 {
1951         WRITE_NODE_TYPE("WINDOWCLAUSE");
1952
1953         WRITE_STRING_FIELD(name);
1954         WRITE_STRING_FIELD(refname);
1955         WRITE_NODE_FIELD(partitionClause);
1956         WRITE_NODE_FIELD(orderClause);
1957         WRITE_INT_FIELD(frameOptions);
1958         WRITE_UINT_FIELD(winref);
1959         WRITE_BOOL_FIELD(copiedOrder);
1960 }
1961
1962 static void
1963 _outRowMarkClause(StringInfo str, RowMarkClause *node)
1964 {
1965         WRITE_NODE_TYPE("ROWMARKCLAUSE");
1966
1967         WRITE_UINT_FIELD(rti);
1968         WRITE_UINT_FIELD(prti);
1969         WRITE_BOOL_FIELD(forUpdate);
1970         WRITE_BOOL_FIELD(noWait);
1971         WRITE_BOOL_FIELD(isParent);
1972 }
1973
1974 static void
1975 _outWithClause(StringInfo str, WithClause *node)
1976 {
1977         WRITE_NODE_TYPE("WITHCLAUSE");
1978
1979         WRITE_NODE_FIELD(ctes);
1980         WRITE_BOOL_FIELD(recursive);
1981         WRITE_LOCATION_FIELD(location);
1982 }
1983
1984 static void
1985 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
1986 {
1987         WRITE_NODE_TYPE("COMMONTABLEEXPR");
1988
1989         WRITE_STRING_FIELD(ctename);
1990         WRITE_NODE_FIELD(aliascolnames);
1991         WRITE_NODE_FIELD(ctequery);
1992         WRITE_LOCATION_FIELD(location);
1993         WRITE_BOOL_FIELD(cterecursive);
1994         WRITE_INT_FIELD(cterefcount);
1995         WRITE_NODE_FIELD(ctecolnames);
1996         WRITE_NODE_FIELD(ctecoltypes);
1997         WRITE_NODE_FIELD(ctecoltypmods);
1998 }
1999
2000 static void
2001 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2002 {
2003         WRITE_NODE_TYPE("SETOPERATIONSTMT");
2004
2005         WRITE_ENUM_FIELD(op, SetOperation);
2006         WRITE_BOOL_FIELD(all);
2007         WRITE_NODE_FIELD(larg);
2008         WRITE_NODE_FIELD(rarg);
2009         WRITE_NODE_FIELD(colTypes);
2010         WRITE_NODE_FIELD(colTypmods);
2011         WRITE_NODE_FIELD(groupClauses);
2012 }
2013
2014 static void
2015 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2016 {
2017         WRITE_NODE_TYPE("RTE");
2018
2019         /* put alias + eref first to make dump more legible */
2020         WRITE_NODE_FIELD(alias);
2021         WRITE_NODE_FIELD(eref);
2022         WRITE_ENUM_FIELD(rtekind, RTEKind);
2023
2024         switch (node->rtekind)
2025         {
2026                 case RTE_RELATION:
2027                 case RTE_SPECIAL:
2028                         WRITE_OID_FIELD(relid);
2029                         break;
2030                 case RTE_SUBQUERY:
2031                         WRITE_NODE_FIELD(subquery);
2032                         break;
2033                 case RTE_JOIN:
2034                         WRITE_ENUM_FIELD(jointype, JoinType);
2035                         WRITE_NODE_FIELD(joinaliasvars);
2036                         break;
2037                 case RTE_FUNCTION:
2038                         WRITE_NODE_FIELD(funcexpr);
2039                         WRITE_NODE_FIELD(funccoltypes);
2040                         WRITE_NODE_FIELD(funccoltypmods);
2041                         break;
2042                 case RTE_VALUES:
2043                         WRITE_NODE_FIELD(values_lists);
2044                         break;
2045                 case RTE_CTE:
2046                         WRITE_STRING_FIELD(ctename);
2047                         WRITE_UINT_FIELD(ctelevelsup);
2048                         WRITE_BOOL_FIELD(self_reference);
2049                         WRITE_NODE_FIELD(ctecoltypes);
2050                         WRITE_NODE_FIELD(ctecoltypmods);
2051                         break;
2052                 default:
2053                         elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2054                         break;
2055         }
2056
2057         WRITE_BOOL_FIELD(inh);
2058         WRITE_BOOL_FIELD(inFromCl);
2059         WRITE_UINT_FIELD(requiredPerms);
2060         WRITE_OID_FIELD(checkAsUser);
2061         WRITE_BITMAPSET_FIELD(selectedCols);
2062         WRITE_BITMAPSET_FIELD(modifiedCols);
2063 }
2064
2065 static void
2066 _outAExpr(StringInfo str, A_Expr *node)
2067 {
2068         WRITE_NODE_TYPE("AEXPR");
2069
2070         switch (node->kind)
2071         {
2072                 case AEXPR_OP:
2073                         appendStringInfo(str, " ");
2074                         WRITE_NODE_FIELD(name);
2075                         break;
2076                 case AEXPR_AND:
2077                         appendStringInfo(str, " AND");
2078                         break;
2079                 case AEXPR_OR:
2080                         appendStringInfo(str, " OR");
2081                         break;
2082                 case AEXPR_NOT:
2083                         appendStringInfo(str, " NOT");
2084                         break;
2085                 case AEXPR_OP_ANY:
2086                         appendStringInfo(str, " ");
2087                         WRITE_NODE_FIELD(name);
2088                         appendStringInfo(str, " ANY ");
2089                         break;
2090                 case AEXPR_OP_ALL:
2091                         appendStringInfo(str, " ");
2092                         WRITE_NODE_FIELD(name);
2093                         appendStringInfo(str, " ALL ");
2094                         break;
2095                 case AEXPR_DISTINCT:
2096                         appendStringInfo(str, " DISTINCT ");
2097                         WRITE_NODE_FIELD(name);
2098                         break;
2099                 case AEXPR_NULLIF:
2100                         appendStringInfo(str, " NULLIF ");
2101                         WRITE_NODE_FIELD(name);
2102                         break;
2103                 case AEXPR_OF:
2104                         appendStringInfo(str, " OF ");
2105                         WRITE_NODE_FIELD(name);
2106                         break;
2107                 case AEXPR_IN:
2108                         appendStringInfo(str, " IN ");
2109                         WRITE_NODE_FIELD(name);
2110                         break;
2111                 default:
2112                         appendStringInfo(str, " ??");
2113                         break;
2114         }
2115
2116         WRITE_NODE_FIELD(lexpr);
2117         WRITE_NODE_FIELD(rexpr);
2118         WRITE_LOCATION_FIELD(location);
2119 }
2120
2121 static void
2122 _outValue(StringInfo str, Value *value)
2123 {
2124         switch (value->type)
2125         {
2126                 case T_Integer:
2127                         appendStringInfo(str, "%ld", value->val.ival);
2128                         break;
2129                 case T_Float:
2130
2131                         /*
2132                          * We assume the value is a valid numeric literal and so does not
2133                          * need quoting.
2134                          */
2135                         appendStringInfoString(str, value->val.str);
2136                         break;
2137                 case T_String:
2138                         appendStringInfoChar(str, '"');
2139                         _outToken(str, value->val.str);
2140                         appendStringInfoChar(str, '"');
2141                         break;
2142                 case T_BitString:
2143                         /* internal representation already has leading 'b' */
2144                         appendStringInfoString(str, value->val.str);
2145                         break;
2146                 case T_Null:
2147                         /* this is seen only within A_Const, not in transformed trees */
2148                         appendStringInfoString(str, "NULL");
2149                         break;
2150                 default:
2151                         elog(ERROR, "unrecognized node type: %d", (int) value->type);
2152                         break;
2153         }
2154 }
2155
2156 static void
2157 _outColumnRef(StringInfo str, ColumnRef *node)
2158 {
2159         WRITE_NODE_TYPE("COLUMNREF");
2160
2161         WRITE_NODE_FIELD(fields);
2162         WRITE_LOCATION_FIELD(location);
2163 }
2164
2165 static void
2166 _outParamRef(StringInfo str, ParamRef *node)
2167 {
2168         WRITE_NODE_TYPE("PARAMREF");
2169
2170         WRITE_INT_FIELD(number);
2171         WRITE_LOCATION_FIELD(location);
2172 }
2173
2174 static void
2175 _outAConst(StringInfo str, A_Const *node)
2176 {
2177         WRITE_NODE_TYPE("A_CONST");
2178
2179         appendStringInfo(str, " :val ");
2180         _outValue(str, &(node->val));
2181         WRITE_LOCATION_FIELD(location);
2182 }
2183
2184 static void
2185 _outA_Star(StringInfo str, A_Star *node)
2186 {
2187         WRITE_NODE_TYPE("A_STAR");
2188 }
2189
2190 static void
2191 _outA_Indices(StringInfo str, A_Indices *node)
2192 {
2193         WRITE_NODE_TYPE("A_INDICES");
2194
2195         WRITE_NODE_FIELD(lidx);
2196         WRITE_NODE_FIELD(uidx);
2197 }
2198
2199 static void
2200 _outA_Indirection(StringInfo str, A_Indirection *node)
2201 {
2202         WRITE_NODE_TYPE("A_INDIRECTION");
2203
2204         WRITE_NODE_FIELD(arg);
2205         WRITE_NODE_FIELD(indirection);
2206 }
2207
2208 static void
2209 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2210 {
2211         WRITE_NODE_TYPE("A_ARRAYEXPR");
2212
2213         WRITE_NODE_FIELD(elements);
2214         WRITE_LOCATION_FIELD(location);
2215 }
2216
2217 static void
2218 _outResTarget(StringInfo str, ResTarget *node)
2219 {
2220         WRITE_NODE_TYPE("RESTARGET");
2221
2222         WRITE_STRING_FIELD(name);
2223         WRITE_NODE_FIELD(indirection);
2224         WRITE_NODE_FIELD(val);
2225         WRITE_LOCATION_FIELD(location);
2226 }
2227
2228 static void
2229 _outSortBy(StringInfo str, SortBy *node)
2230 {
2231         WRITE_NODE_TYPE("SORTBY");
2232
2233         WRITE_NODE_FIELD(node);
2234         WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2235         WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2236         WRITE_NODE_FIELD(useOp);
2237         WRITE_LOCATION_FIELD(location);
2238 }
2239
2240 static void
2241 _outWindowDef(StringInfo str, WindowDef *node)
2242 {
2243         WRITE_NODE_TYPE("WINDOWDEF");
2244
2245         WRITE_STRING_FIELD(name);
2246         WRITE_STRING_FIELD(refname);
2247         WRITE_NODE_FIELD(partitionClause);
2248         WRITE_NODE_FIELD(orderClause);
2249         WRITE_INT_FIELD(frameOptions);
2250         WRITE_LOCATION_FIELD(location);
2251 }
2252
2253 static void
2254 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2255 {
2256         WRITE_NODE_TYPE("RANGESUBSELECT");
2257
2258         WRITE_NODE_FIELD(subquery);
2259         WRITE_NODE_FIELD(alias);
2260 }
2261
2262 static void
2263 _outRangeFunction(StringInfo str, RangeFunction *node)
2264 {
2265         WRITE_NODE_TYPE("RANGEFUNCTION");
2266
2267         WRITE_NODE_FIELD(funccallnode);
2268         WRITE_NODE_FIELD(alias);
2269         WRITE_NODE_FIELD(coldeflist);
2270 }
2271
2272 static void
2273 _outConstraint(StringInfo str, Constraint *node)
2274 {
2275         WRITE_NODE_TYPE("CONSTRAINT");
2276
2277         WRITE_STRING_FIELD(name);
2278
2279         appendStringInfo(str, " :contype ");
2280         switch (node->contype)
2281         {
2282                 case CONSTR_PRIMARY:
2283                         appendStringInfo(str, "PRIMARY_KEY");
2284                         WRITE_NODE_FIELD(keys);
2285                         WRITE_NODE_FIELD(options);
2286                         WRITE_STRING_FIELD(indexspace);
2287                         break;
2288
2289                 case CONSTR_UNIQUE:
2290                         appendStringInfo(str, "UNIQUE");
2291                         WRITE_NODE_FIELD(keys);
2292                         WRITE_NODE_FIELD(options);
2293                         WRITE_STRING_FIELD(indexspace);
2294                         break;
2295
2296                 case CONSTR_CHECK:
2297                         appendStringInfo(str, "CHECK");
2298                         WRITE_NODE_FIELD(raw_expr);
2299                         WRITE_STRING_FIELD(cooked_expr);
2300                         break;
2301
2302                 case CONSTR_DEFAULT:
2303                         appendStringInfo(str, "DEFAULT");
2304                         WRITE_NODE_FIELD(raw_expr);
2305                         WRITE_STRING_FIELD(cooked_expr);
2306                         break;
2307
2308                 case CONSTR_NOTNULL:
2309                         appendStringInfo(str, "NOT_NULL");
2310                         break;
2311
2312                 default:
2313                         appendStringInfo(str, "<unrecognized_constraint>");
2314                         break;
2315         }
2316 }
2317
2318 static void
2319 _outFkConstraint(StringInfo str, FkConstraint *node)
2320 {
2321         WRITE_NODE_TYPE("FKCONSTRAINT");
2322
2323         WRITE_STRING_FIELD(constr_name);
2324         WRITE_NODE_FIELD(pktable);
2325         WRITE_NODE_FIELD(fk_attrs);
2326         WRITE_NODE_FIELD(pk_attrs);
2327         WRITE_CHAR_FIELD(fk_matchtype);
2328         WRITE_CHAR_FIELD(fk_upd_action);
2329         WRITE_CHAR_FIELD(fk_del_action);
2330         WRITE_BOOL_FIELD(deferrable);
2331         WRITE_BOOL_FIELD(initdeferred);
2332         WRITE_BOOL_FIELD(skip_validation);
2333 }
2334
2335
2336 /*
2337  * _outNode -
2338  *        converts a Node into ascii string and append it to 'str'
2339  */
2340 static void
2341 _outNode(StringInfo str, void *obj)
2342 {
2343         if (obj == NULL)
2344                 appendStringInfo(str, "<>");
2345         else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2346                 _outList(str, obj);
2347         else if (IsA(obj, Integer) ||
2348                          IsA(obj, Float) ||
2349                          IsA(obj, String) ||
2350                          IsA(obj, BitString))
2351         {
2352                 /* nodeRead does not want to see { } around these! */
2353                 _outValue(str, obj);
2354         }
2355         else
2356         {
2357                 appendStringInfoChar(str, '{');
2358                 switch (nodeTag(obj))
2359                 {
2360                         case T_PlannedStmt:
2361                                 _outPlannedStmt(str, obj);
2362                                 break;
2363                         case T_Plan:
2364                                 _outPlan(str, obj);
2365                                 break;
2366                         case T_Result:
2367                                 _outResult(str, obj);
2368                                 break;
2369                         case T_Append:
2370                                 _outAppend(str, obj);
2371                                 break;
2372                         case T_RecursiveUnion:
2373                                 _outRecursiveUnion(str, obj);
2374                                 break;
2375                         case T_BitmapAnd:
2376                                 _outBitmapAnd(str, obj);
2377                                 break;
2378                         case T_BitmapOr:
2379                                 _outBitmapOr(str, obj);
2380                                 break;
2381                         case T_Scan:
2382                                 _outScan(str, obj);
2383                                 break;
2384                         case T_SeqScan:
2385                                 _outSeqScan(str, obj);
2386                                 break;
2387                         case T_IndexScan:
2388                                 _outIndexScan(str, obj);
2389                                 break;
2390                         case T_BitmapIndexScan:
2391                                 _outBitmapIndexScan(str, obj);
2392                                 break;
2393                         case T_BitmapHeapScan:
2394                                 _outBitmapHeapScan(str, obj);
2395                                 break;
2396                         case T_TidScan:
2397                                 _outTidScan(str, obj);
2398                                 break;
2399                         case T_SubqueryScan:
2400                                 _outSubqueryScan(str, obj);
2401                                 break;
2402                         case T_FunctionScan:
2403                                 _outFunctionScan(str, obj);
2404                                 break;
2405                         case T_ValuesScan:
2406                                 _outValuesScan(str, obj);
2407                                 break;
2408                         case T_CteScan:
2409                                 _outCteScan(str, obj);
2410                                 break;
2411                         case T_WorkTableScan:
2412                                 _outWorkTableScan(str, obj);
2413                                 break;
2414                         case T_Join:
2415                                 _outJoin(str, obj);
2416                                 break;
2417                         case T_NestLoop:
2418                                 _outNestLoop(str, obj);
2419                                 break;
2420                         case T_MergeJoin:
2421                                 _outMergeJoin(str, obj);
2422                                 break;
2423                         case T_HashJoin:
2424                                 _outHashJoin(str, obj);
2425                                 break;
2426                         case T_Agg:
2427                                 _outAgg(str, obj);
2428                                 break;
2429                         case T_WindowAgg:
2430                                 _outWindowAgg(str, obj);
2431                                 break;
2432                         case T_Group:
2433                                 _outGroup(str, obj);
2434                                 break;
2435                         case T_Material:
2436                                 _outMaterial(str, obj);
2437                                 break;
2438                         case T_Sort:
2439                                 _outSort(str, obj);
2440                                 break;
2441                         case T_Unique:
2442                                 _outUnique(str, obj);
2443                                 break;
2444                         case T_Hash:
2445                                 _outHash(str, obj);
2446                                 break;
2447                         case T_SetOp:
2448                                 _outSetOp(str, obj);
2449                                 break;
2450                         case T_Limit:
2451                                 _outLimit(str, obj);
2452                                 break;
2453                         case T_PlanInvalItem:
2454                                 _outPlanInvalItem(str, obj);
2455                                 break;
2456                         case T_Alias:
2457                                 _outAlias(str, obj);
2458                                 break;
2459                         case T_RangeVar:
2460                                 _outRangeVar(str, obj);
2461                                 break;
2462                         case T_IntoClause:
2463                                 _outIntoClause(str, obj);
2464                                 break;
2465                         case T_Var:
2466                                 _outVar(str, obj);
2467                                 break;
2468                         case T_Const:
2469                                 _outConst(str, obj);
2470                                 break;
2471                         case T_Param:
2472                                 _outParam(str, obj);
2473                                 break;
2474                         case T_Aggref:
2475                                 _outAggref(str, obj);
2476                                 break;
2477                         case T_WindowFunc:
2478                                 _outWindowFunc(str, obj);
2479                                 break;
2480                         case T_ArrayRef:
2481                                 _outArrayRef(str, obj);
2482                                 break;
2483                         case T_FuncExpr:
2484                                 _outFuncExpr(str, obj);
2485                                 break;
2486                         case T_OpExpr:
2487                                 _outOpExpr(str, obj);
2488                                 break;
2489                         case T_DistinctExpr:
2490                                 _outDistinctExpr(str, obj);
2491                                 break;
2492                         case T_ScalarArrayOpExpr:
2493                                 _outScalarArrayOpExpr(str, obj);
2494                                 break;
2495                         case T_BoolExpr:
2496                                 _outBoolExpr(str, obj);
2497                                 break;
2498                         case T_SubLink:
2499                                 _outSubLink(str, obj);
2500                                 break;
2501                         case T_SubPlan:
2502                                 _outSubPlan(str, obj);
2503                                 break;
2504                         case T_AlternativeSubPlan:
2505                                 _outAlternativeSubPlan(str, obj);
2506                                 break;
2507                         case T_FieldSelect:
2508                                 _outFieldSelect(str, obj);
2509                                 break;
2510                         case T_FieldStore:
2511                                 _outFieldStore(str, obj);
2512                                 break;
2513                         case T_RelabelType:
2514                                 _outRelabelType(str, obj);
2515                                 break;
2516                         case T_CoerceViaIO:
2517                                 _outCoerceViaIO(str, obj);
2518                                 break;
2519                         case T_ArrayCoerceExpr:
2520                                 _outArrayCoerceExpr(str, obj);
2521                                 break;
2522                         case T_ConvertRowtypeExpr:
2523                                 _outConvertRowtypeExpr(str, obj);
2524                                 break;
2525                         case T_CaseExpr:
2526                                 _outCaseExpr(str, obj);
2527                                 break;
2528                         case T_CaseWhen:
2529                                 _outCaseWhen(str, obj);
2530                                 break;
2531                         case T_CaseTestExpr:
2532                                 _outCaseTestExpr(str, obj);
2533                                 break;
2534                         case T_ArrayExpr:
2535                                 _outArrayExpr(str, obj);
2536                                 break;
2537                         case T_RowExpr:
2538                                 _outRowExpr(str, obj);
2539                                 break;
2540                         case T_RowCompareExpr:
2541                                 _outRowCompareExpr(str, obj);
2542                                 break;
2543                         case T_CoalesceExpr:
2544                                 _outCoalesceExpr(str, obj);
2545                                 break;
2546                         case T_MinMaxExpr:
2547                                 _outMinMaxExpr(str, obj);
2548                                 break;
2549                         case T_XmlExpr:
2550                                 _outXmlExpr(str, obj);
2551                                 break;
2552                         case T_NullIfExpr:
2553                                 _outNullIfExpr(str, obj);
2554                                 break;
2555                         case T_NullTest:
2556                                 _outNullTest(str, obj);
2557                                 break;
2558                         case T_BooleanTest:
2559                                 _outBooleanTest(str, obj);
2560                                 break;
2561                         case T_CoerceToDomain:
2562                                 _outCoerceToDomain(str, obj);
2563                                 break;
2564                         case T_CoerceToDomainValue:
2565                                 _outCoerceToDomainValue(str, obj);
2566                                 break;
2567                         case T_SetToDefault:
2568                                 _outSetToDefault(str, obj);
2569                                 break;
2570                         case T_CurrentOfExpr:
2571                                 _outCurrentOfExpr(str, obj);
2572                                 break;
2573                         case T_TargetEntry:
2574                                 _outTargetEntry(str, obj);
2575                                 break;
2576                         case T_RangeTblRef:
2577                                 _outRangeTblRef(str, obj);
2578                                 break;
2579                         case T_JoinExpr:
2580                                 _outJoinExpr(str, obj);
2581                                 break;
2582                         case T_FromExpr:
2583                                 _outFromExpr(str, obj);
2584                                 break;
2585
2586                         case T_Path:
2587                                 _outPath(str, obj);
2588                                 break;
2589                         case T_IndexPath:
2590                                 _outIndexPath(str, obj);
2591                                 break;
2592                         case T_BitmapHeapPath:
2593                                 _outBitmapHeapPath(str, obj);
2594                                 break;
2595                         case T_BitmapAndPath:
2596                                 _outBitmapAndPath(str, obj);
2597                                 break;
2598                         case T_BitmapOrPath:
2599                                 _outBitmapOrPath(str, obj);
2600                                 break;
2601                         case T_TidPath:
2602                                 _outTidPath(str, obj);
2603                                 break;
2604                         case T_AppendPath:
2605                                 _outAppendPath(str, obj);
2606                                 break;
2607                         case T_ResultPath:
2608                                 _outResultPath(str, obj);
2609                                 break;
2610                         case T_MaterialPath:
2611                                 _outMaterialPath(str, obj);
2612                                 break;
2613                         case T_UniquePath:
2614                                 _outUniquePath(str, obj);
2615                                 break;
2616                         case T_NestPath:
2617                                 _outNestPath(str, obj);
2618                                 break;
2619                         case T_MergePath:
2620                                 _outMergePath(str, obj);
2621                                 break;
2622                         case T_HashPath:
2623                                 _outHashPath(str, obj);
2624                                 break;
2625                         case T_PlannerGlobal:
2626                                 _outPlannerGlobal(str, obj);
2627                                 break;
2628                         case T_PlannerInfo:
2629                                 _outPlannerInfo(str, obj);
2630                                 break;
2631                         case T_RelOptInfo:
2632                                 _outRelOptInfo(str, obj);
2633                                 break;
2634                         case T_IndexOptInfo:
2635                                 _outIndexOptInfo(str, obj);
2636                                 break;
2637                         case T_EquivalenceClass:
2638                                 _outEquivalenceClass(str, obj);
2639                                 break;
2640                         case T_EquivalenceMember:
2641                                 _outEquivalenceMember(str, obj);
2642                                 break;
2643                         case T_PathKey:
2644                                 _outPathKey(str, obj);
2645                                 break;
2646                         case T_RestrictInfo:
2647                                 _outRestrictInfo(str, obj);
2648                                 break;
2649                         case T_InnerIndexscanInfo:
2650                                 _outInnerIndexscanInfo(str, obj);
2651                                 break;
2652                         case T_PlaceHolderVar:
2653                                 _outPlaceHolderVar(str, obj);
2654                                 break;
2655                         case T_SpecialJoinInfo:
2656                                 _outSpecialJoinInfo(str, obj);
2657                                 break;
2658                         case T_AppendRelInfo:
2659                                 _outAppendRelInfo(str, obj);
2660                                 break;
2661                         case T_PlaceHolderInfo:
2662                                 _outPlaceHolderInfo(str, obj);
2663                                 break;
2664                         case T_PlannerParamItem:
2665                                 _outPlannerParamItem(str, obj);
2666                                 break;
2667
2668                         case T_CreateStmt:
2669                                 _outCreateStmt(str, obj);
2670                                 break;
2671                         case T_IndexStmt:
2672                                 _outIndexStmt(str, obj);
2673                                 break;
2674                         case T_NotifyStmt:
2675                                 _outNotifyStmt(str, obj);
2676                                 break;
2677                         case T_DeclareCursorStmt:
2678                                 _outDeclareCursorStmt(str, obj);
2679                                 break;
2680                         case T_SelectStmt:
2681                                 _outSelectStmt(str, obj);
2682                                 break;
2683                         case T_ColumnDef:
2684                                 _outColumnDef(str, obj);
2685                                 break;
2686                         case T_TypeName:
2687                                 _outTypeName(str, obj);
2688                                 break;
2689                         case T_TypeCast:
2690                                 _outTypeCast(str, obj);
2691                                 break;
2692                         case T_IndexElem:
2693                                 _outIndexElem(str, obj);
2694                                 break;
2695                         case T_Query:
2696                                 _outQuery(str, obj);
2697                                 break;
2698                         case T_SortGroupClause:
2699                                 _outSortGroupClause(str, obj);
2700                                 break;
2701                         case T_WindowClause:
2702                                 _outWindowClause(str, obj);
2703                                 break;
2704                         case T_RowMarkClause:
2705                                 _outRowMarkClause(str, obj);
2706                                 break;
2707                         case T_WithClause:
2708                                 _outWithClause(str, obj);
2709                                 break;
2710                         case T_CommonTableExpr:
2711                                 _outCommonTableExpr(str, obj);
2712                                 break;
2713                         case T_SetOperationStmt:
2714                                 _outSetOperationStmt(str, obj);
2715                                 break;
2716                         case T_RangeTblEntry:
2717                                 _outRangeTblEntry(str, obj);
2718                                 break;
2719                         case T_A_Expr:
2720                                 _outAExpr(str, obj);
2721                                 break;
2722                         case T_ColumnRef:
2723                                 _outColumnRef(str, obj);
2724                                 break;
2725                         case T_ParamRef:
2726                                 _outParamRef(str, obj);
2727                                 break;
2728                         case T_A_Const:
2729                                 _outAConst(str, obj);
2730                                 break;
2731                         case T_A_Star:
2732                                 _outA_Star(str, obj);
2733                                 break;
2734                         case T_A_Indices:
2735                                 _outA_Indices(str, obj);
2736                                 break;
2737                         case T_A_Indirection:
2738                                 _outA_Indirection(str, obj);
2739                                 break;
2740                         case T_A_ArrayExpr:
2741                                 _outA_ArrayExpr(str, obj);
2742                                 break;
2743                         case T_ResTarget:
2744                                 _outResTarget(str, obj);
2745                                 break;
2746                         case T_SortBy:
2747                                 _outSortBy(str, obj);
2748                                 break;
2749                         case T_WindowDef:
2750                                 _outWindowDef(str, obj);
2751                                 break;
2752                         case T_RangeSubselect:
2753                                 _outRangeSubselect(str, obj);
2754                                 break;
2755                         case T_RangeFunction:
2756                                 _outRangeFunction(str, obj);
2757                                 break;
2758                         case T_Constraint:
2759                                 _outConstraint(str, obj);
2760                                 break;
2761                         case T_FkConstraint:
2762                                 _outFkConstraint(str, obj);
2763                                 break;
2764                         case T_FuncCall:
2765                                 _outFuncCall(str, obj);
2766                                 break;
2767                         case T_DefElem:
2768                                 _outDefElem(str, obj);
2769                                 break;
2770                         case T_LockingClause:
2771                                 _outLockingClause(str, obj);
2772                                 break;
2773                         case T_XmlSerialize:
2774                                 _outXmlSerialize(str, obj);
2775                                 break;
2776
2777                         default:
2778
2779                                 /*
2780                                  * This should be an ERROR, but it's too useful to be able to
2781                                  * dump structures that _outNode only understands part of.
2782                                  */
2783                                 elog(WARNING, "could not dump unrecognized node type: %d",
2784                                          (int) nodeTag(obj));
2785                                 break;
2786                 }
2787                 appendStringInfoChar(str, '}');
2788         }
2789 }
2790
2791 /*
2792  * nodeToString -
2793  *         returns the ascii representation of the Node as a palloc'd string
2794  */
2795 char *
2796 nodeToString(void *obj)
2797 {
2798         StringInfoData str;
2799
2800         /* see stringinfo.h for an explanation of this maneuver */
2801         initStringInfo(&str);
2802         _outNode(&str, obj);
2803         return str.data;
2804 }