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