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