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