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