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