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