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