]> granicus.if.org Git - postgresql/blob - src/backend/nodes/outfuncs.c
cac346464bd15b998e4b56e6fb34a7271a521d07
[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.375 2009/12/15 17:57:46 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_NODE_FIELD(aggorder);
873         WRITE_NODE_FIELD(aggdistinct);
874         WRITE_BOOL_FIELD(aggstar);
875         WRITE_UINT_FIELD(agglevelsup);
876         WRITE_LOCATION_FIELD(location);
877 }
878
879 static void
880 _outWindowFunc(StringInfo str, WindowFunc *node)
881 {
882         WRITE_NODE_TYPE("WINDOWFUNC");
883
884         WRITE_OID_FIELD(winfnoid);
885         WRITE_OID_FIELD(wintype);
886         WRITE_NODE_FIELD(args);
887         WRITE_UINT_FIELD(winref);
888         WRITE_BOOL_FIELD(winstar);
889         WRITE_BOOL_FIELD(winagg);
890         WRITE_LOCATION_FIELD(location);
891 }
892
893 static void
894 _outArrayRef(StringInfo str, ArrayRef *node)
895 {
896         WRITE_NODE_TYPE("ARRAYREF");
897
898         WRITE_OID_FIELD(refarraytype);
899         WRITE_OID_FIELD(refelemtype);
900         WRITE_INT_FIELD(reftypmod);
901         WRITE_NODE_FIELD(refupperindexpr);
902         WRITE_NODE_FIELD(reflowerindexpr);
903         WRITE_NODE_FIELD(refexpr);
904         WRITE_NODE_FIELD(refassgnexpr);
905 }
906
907 static void
908 _outFuncExpr(StringInfo str, FuncExpr *node)
909 {
910         WRITE_NODE_TYPE("FUNCEXPR");
911
912         WRITE_OID_FIELD(funcid);
913         WRITE_OID_FIELD(funcresulttype);
914         WRITE_BOOL_FIELD(funcretset);
915         WRITE_ENUM_FIELD(funcformat, CoercionForm);
916         WRITE_NODE_FIELD(args);
917         WRITE_LOCATION_FIELD(location);
918 }
919
920 static void
921 _outNamedArgExpr(StringInfo str, NamedArgExpr *node)
922 {
923         WRITE_NODE_TYPE("NAMEDARGEXPR");
924
925         WRITE_NODE_FIELD(arg);
926         WRITE_STRING_FIELD(name);
927         WRITE_INT_FIELD(argnumber);
928         WRITE_LOCATION_FIELD(location);
929 }
930
931 static void
932 _outOpExpr(StringInfo str, OpExpr *node)
933 {
934         WRITE_NODE_TYPE("OPEXPR");
935
936         WRITE_OID_FIELD(opno);
937         WRITE_OID_FIELD(opfuncid);
938         WRITE_OID_FIELD(opresulttype);
939         WRITE_BOOL_FIELD(opretset);
940         WRITE_NODE_FIELD(args);
941         WRITE_LOCATION_FIELD(location);
942 }
943
944 static void
945 _outDistinctExpr(StringInfo str, DistinctExpr *node)
946 {
947         WRITE_NODE_TYPE("DISTINCTEXPR");
948
949         WRITE_OID_FIELD(opno);
950         WRITE_OID_FIELD(opfuncid);
951         WRITE_OID_FIELD(opresulttype);
952         WRITE_BOOL_FIELD(opretset);
953         WRITE_NODE_FIELD(args);
954         WRITE_LOCATION_FIELD(location);
955 }
956
957 static void
958 _outScalarArrayOpExpr(StringInfo str, ScalarArrayOpExpr *node)
959 {
960         WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
961
962         WRITE_OID_FIELD(opno);
963         WRITE_OID_FIELD(opfuncid);
964         WRITE_BOOL_FIELD(useOr);
965         WRITE_NODE_FIELD(args);
966         WRITE_LOCATION_FIELD(location);
967 }
968
969 static void
970 _outBoolExpr(StringInfo str, BoolExpr *node)
971 {
972         char       *opstr = NULL;
973
974         WRITE_NODE_TYPE("BOOLEXPR");
975
976         /* do-it-yourself enum representation */
977         switch (node->boolop)
978         {
979                 case AND_EXPR:
980                         opstr = "and";
981                         break;
982                 case OR_EXPR:
983                         opstr = "or";
984                         break;
985                 case NOT_EXPR:
986                         opstr = "not";
987                         break;
988         }
989         appendStringInfo(str, " :boolop ");
990         _outToken(str, opstr);
991
992         WRITE_NODE_FIELD(args);
993         WRITE_LOCATION_FIELD(location);
994 }
995
996 static void
997 _outSubLink(StringInfo str, SubLink *node)
998 {
999         WRITE_NODE_TYPE("SUBLINK");
1000
1001         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1002         WRITE_NODE_FIELD(testexpr);
1003         WRITE_NODE_FIELD(operName);
1004         WRITE_NODE_FIELD(subselect);
1005         WRITE_LOCATION_FIELD(location);
1006 }
1007
1008 static void
1009 _outSubPlan(StringInfo str, SubPlan *node)
1010 {
1011         WRITE_NODE_TYPE("SUBPLAN");
1012
1013         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1014         WRITE_NODE_FIELD(testexpr);
1015         WRITE_NODE_FIELD(paramIds);
1016         WRITE_INT_FIELD(plan_id);
1017         WRITE_STRING_FIELD(plan_name);
1018         WRITE_OID_FIELD(firstColType);
1019         WRITE_INT_FIELD(firstColTypmod);
1020         WRITE_BOOL_FIELD(useHashTable);
1021         WRITE_BOOL_FIELD(unknownEqFalse);
1022         WRITE_NODE_FIELD(setParam);
1023         WRITE_NODE_FIELD(parParam);
1024         WRITE_NODE_FIELD(args);
1025         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1026         WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1027 }
1028
1029 static void
1030 _outAlternativeSubPlan(StringInfo str, AlternativeSubPlan *node)
1031 {
1032         WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1033
1034         WRITE_NODE_FIELD(subplans);
1035 }
1036
1037 static void
1038 _outFieldSelect(StringInfo str, FieldSelect *node)
1039 {
1040         WRITE_NODE_TYPE("FIELDSELECT");
1041
1042         WRITE_NODE_FIELD(arg);
1043         WRITE_INT_FIELD(fieldnum);
1044         WRITE_OID_FIELD(resulttype);
1045         WRITE_INT_FIELD(resulttypmod);
1046 }
1047
1048 static void
1049 _outFieldStore(StringInfo str, FieldStore *node)
1050 {
1051         WRITE_NODE_TYPE("FIELDSTORE");
1052
1053         WRITE_NODE_FIELD(arg);
1054         WRITE_NODE_FIELD(newvals);
1055         WRITE_NODE_FIELD(fieldnums);
1056         WRITE_OID_FIELD(resulttype);
1057 }
1058
1059 static void
1060 _outRelabelType(StringInfo str, RelabelType *node)
1061 {
1062         WRITE_NODE_TYPE("RELABELTYPE");
1063
1064         WRITE_NODE_FIELD(arg);
1065         WRITE_OID_FIELD(resulttype);
1066         WRITE_INT_FIELD(resulttypmod);
1067         WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1068         WRITE_LOCATION_FIELD(location);
1069 }
1070
1071 static void
1072 _outCoerceViaIO(StringInfo str, CoerceViaIO *node)
1073 {
1074         WRITE_NODE_TYPE("COERCEVIAIO");
1075
1076         WRITE_NODE_FIELD(arg);
1077         WRITE_OID_FIELD(resulttype);
1078         WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1079         WRITE_LOCATION_FIELD(location);
1080 }
1081
1082 static void
1083 _outArrayCoerceExpr(StringInfo str, ArrayCoerceExpr *node)
1084 {
1085         WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1086
1087         WRITE_NODE_FIELD(arg);
1088         WRITE_OID_FIELD(elemfuncid);
1089         WRITE_OID_FIELD(resulttype);
1090         WRITE_INT_FIELD(resulttypmod);
1091         WRITE_BOOL_FIELD(isExplicit);
1092         WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1093         WRITE_LOCATION_FIELD(location);
1094 }
1095
1096 static void
1097 _outConvertRowtypeExpr(StringInfo str, ConvertRowtypeExpr *node)
1098 {
1099         WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1100
1101         WRITE_NODE_FIELD(arg);
1102         WRITE_OID_FIELD(resulttype);
1103         WRITE_ENUM_FIELD(convertformat, CoercionForm);
1104         WRITE_LOCATION_FIELD(location);
1105 }
1106
1107 static void
1108 _outCaseExpr(StringInfo str, CaseExpr *node)
1109 {
1110         WRITE_NODE_TYPE("CASE");
1111
1112         WRITE_OID_FIELD(casetype);
1113         WRITE_NODE_FIELD(arg);
1114         WRITE_NODE_FIELD(args);
1115         WRITE_NODE_FIELD(defresult);
1116         WRITE_LOCATION_FIELD(location);
1117 }
1118
1119 static void
1120 _outCaseWhen(StringInfo str, CaseWhen *node)
1121 {
1122         WRITE_NODE_TYPE("WHEN");
1123
1124         WRITE_NODE_FIELD(expr);
1125         WRITE_NODE_FIELD(result);
1126         WRITE_LOCATION_FIELD(location);
1127 }
1128
1129 static void
1130 _outCaseTestExpr(StringInfo str, CaseTestExpr *node)
1131 {
1132         WRITE_NODE_TYPE("CASETESTEXPR");
1133
1134         WRITE_OID_FIELD(typeId);
1135         WRITE_INT_FIELD(typeMod);
1136 }
1137
1138 static void
1139 _outArrayExpr(StringInfo str, ArrayExpr *node)
1140 {
1141         WRITE_NODE_TYPE("ARRAY");
1142
1143         WRITE_OID_FIELD(array_typeid);
1144         WRITE_OID_FIELD(element_typeid);
1145         WRITE_NODE_FIELD(elements);
1146         WRITE_BOOL_FIELD(multidims);
1147         WRITE_LOCATION_FIELD(location);
1148 }
1149
1150 static void
1151 _outRowExpr(StringInfo str, RowExpr *node)
1152 {
1153         WRITE_NODE_TYPE("ROW");
1154
1155         WRITE_NODE_FIELD(args);
1156         WRITE_OID_FIELD(row_typeid);
1157         WRITE_ENUM_FIELD(row_format, CoercionForm);
1158         WRITE_NODE_FIELD(colnames);
1159         WRITE_LOCATION_FIELD(location);
1160 }
1161
1162 static void
1163 _outRowCompareExpr(StringInfo str, RowCompareExpr *node)
1164 {
1165         WRITE_NODE_TYPE("ROWCOMPARE");
1166
1167         WRITE_ENUM_FIELD(rctype, RowCompareType);
1168         WRITE_NODE_FIELD(opnos);
1169         WRITE_NODE_FIELD(opfamilies);
1170         WRITE_NODE_FIELD(largs);
1171         WRITE_NODE_FIELD(rargs);
1172 }
1173
1174 static void
1175 _outCoalesceExpr(StringInfo str, CoalesceExpr *node)
1176 {
1177         WRITE_NODE_TYPE("COALESCE");
1178
1179         WRITE_OID_FIELD(coalescetype);
1180         WRITE_NODE_FIELD(args);
1181         WRITE_LOCATION_FIELD(location);
1182 }
1183
1184 static void
1185 _outMinMaxExpr(StringInfo str, MinMaxExpr *node)
1186 {
1187         WRITE_NODE_TYPE("MINMAX");
1188
1189         WRITE_OID_FIELD(minmaxtype);
1190         WRITE_ENUM_FIELD(op, MinMaxOp);
1191         WRITE_NODE_FIELD(args);
1192         WRITE_LOCATION_FIELD(location);
1193 }
1194
1195 static void
1196 _outXmlExpr(StringInfo str, XmlExpr *node)
1197 {
1198         WRITE_NODE_TYPE("XMLEXPR");
1199
1200         WRITE_ENUM_FIELD(op, XmlExprOp);
1201         WRITE_STRING_FIELD(name);
1202         WRITE_NODE_FIELD(named_args);
1203         WRITE_NODE_FIELD(arg_names);
1204         WRITE_NODE_FIELD(args);
1205         WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1206         WRITE_OID_FIELD(type);
1207         WRITE_INT_FIELD(typmod);
1208         WRITE_LOCATION_FIELD(location);
1209 }
1210
1211 static void
1212 _outNullIfExpr(StringInfo str, NullIfExpr *node)
1213 {
1214         WRITE_NODE_TYPE("NULLIFEXPR");
1215
1216         WRITE_OID_FIELD(opno);
1217         WRITE_OID_FIELD(opfuncid);
1218         WRITE_OID_FIELD(opresulttype);
1219         WRITE_BOOL_FIELD(opretset);
1220         WRITE_NODE_FIELD(args);
1221         WRITE_LOCATION_FIELD(location);
1222 }
1223
1224 static void
1225 _outNullTest(StringInfo str, NullTest *node)
1226 {
1227         WRITE_NODE_TYPE("NULLTEST");
1228
1229         WRITE_NODE_FIELD(arg);
1230         WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1231 }
1232
1233 static void
1234 _outBooleanTest(StringInfo str, BooleanTest *node)
1235 {
1236         WRITE_NODE_TYPE("BOOLEANTEST");
1237
1238         WRITE_NODE_FIELD(arg);
1239         WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1240 }
1241
1242 static void
1243 _outCoerceToDomain(StringInfo str, CoerceToDomain *node)
1244 {
1245         WRITE_NODE_TYPE("COERCETODOMAIN");
1246
1247         WRITE_NODE_FIELD(arg);
1248         WRITE_OID_FIELD(resulttype);
1249         WRITE_INT_FIELD(resulttypmod);
1250         WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1251         WRITE_LOCATION_FIELD(location);
1252 }
1253
1254 static void
1255 _outCoerceToDomainValue(StringInfo str, CoerceToDomainValue *node)
1256 {
1257         WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1258
1259         WRITE_OID_FIELD(typeId);
1260         WRITE_INT_FIELD(typeMod);
1261         WRITE_LOCATION_FIELD(location);
1262 }
1263
1264 static void
1265 _outSetToDefault(StringInfo str, SetToDefault *node)
1266 {
1267         WRITE_NODE_TYPE("SETTODEFAULT");
1268
1269         WRITE_OID_FIELD(typeId);
1270         WRITE_INT_FIELD(typeMod);
1271         WRITE_LOCATION_FIELD(location);
1272 }
1273
1274 static void
1275 _outCurrentOfExpr(StringInfo str, CurrentOfExpr *node)
1276 {
1277         WRITE_NODE_TYPE("CURRENTOFEXPR");
1278
1279         WRITE_UINT_FIELD(cvarno);
1280         WRITE_STRING_FIELD(cursor_name);
1281         WRITE_INT_FIELD(cursor_param);
1282 }
1283
1284 static void
1285 _outTargetEntry(StringInfo str, TargetEntry *node)
1286 {
1287         WRITE_NODE_TYPE("TARGETENTRY");
1288
1289         WRITE_NODE_FIELD(expr);
1290         WRITE_INT_FIELD(resno);
1291         WRITE_STRING_FIELD(resname);
1292         WRITE_UINT_FIELD(ressortgroupref);
1293         WRITE_OID_FIELD(resorigtbl);
1294         WRITE_INT_FIELD(resorigcol);
1295         WRITE_BOOL_FIELD(resjunk);
1296 }
1297
1298 static void
1299 _outRangeTblRef(StringInfo str, RangeTblRef *node)
1300 {
1301         WRITE_NODE_TYPE("RANGETBLREF");
1302
1303         WRITE_INT_FIELD(rtindex);
1304 }
1305
1306 static void
1307 _outJoinExpr(StringInfo str, JoinExpr *node)
1308 {
1309         WRITE_NODE_TYPE("JOINEXPR");
1310
1311         WRITE_ENUM_FIELD(jointype, JoinType);
1312         WRITE_BOOL_FIELD(isNatural);
1313         WRITE_NODE_FIELD(larg);
1314         WRITE_NODE_FIELD(rarg);
1315         WRITE_NODE_FIELD(usingClause);
1316         WRITE_NODE_FIELD(quals);
1317         WRITE_NODE_FIELD(alias);
1318         WRITE_INT_FIELD(rtindex);
1319 }
1320
1321 static void
1322 _outFromExpr(StringInfo str, FromExpr *node)
1323 {
1324         WRITE_NODE_TYPE("FROMEXPR");
1325
1326         WRITE_NODE_FIELD(fromlist);
1327         WRITE_NODE_FIELD(quals);
1328 }
1329
1330 /*****************************************************************************
1331  *
1332  *      Stuff from relation.h.
1333  *
1334  *****************************************************************************/
1335
1336 /*
1337  * print the basic stuff of all nodes that inherit from Path
1338  *
1339  * Note we do NOT print the parent, else we'd be in infinite recursion
1340  */
1341 static void
1342 _outPathInfo(StringInfo str, Path *node)
1343 {
1344         WRITE_ENUM_FIELD(pathtype, NodeTag);
1345         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1346         WRITE_FLOAT_FIELD(total_cost, "%.2f");
1347         WRITE_NODE_FIELD(pathkeys);
1348 }
1349
1350 /*
1351  * print the basic stuff of all nodes that inherit from JoinPath
1352  */
1353 static void
1354 _outJoinPathInfo(StringInfo str, JoinPath *node)
1355 {
1356         _outPathInfo(str, (Path *) node);
1357
1358         WRITE_ENUM_FIELD(jointype, JoinType);
1359         WRITE_NODE_FIELD(outerjoinpath);
1360         WRITE_NODE_FIELD(innerjoinpath);
1361         WRITE_NODE_FIELD(joinrestrictinfo);
1362 }
1363
1364 static void
1365 _outPath(StringInfo str, Path *node)
1366 {
1367         WRITE_NODE_TYPE("PATH");
1368
1369         _outPathInfo(str, (Path *) node);
1370 }
1371
1372 static void
1373 _outIndexPath(StringInfo str, IndexPath *node)
1374 {
1375         WRITE_NODE_TYPE("INDEXPATH");
1376
1377         _outPathInfo(str, (Path *) node);
1378
1379         WRITE_NODE_FIELD(indexinfo);
1380         WRITE_NODE_FIELD(indexclauses);
1381         WRITE_NODE_FIELD(indexquals);
1382         WRITE_BOOL_FIELD(isjoininner);
1383         WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1384         WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1385         WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1386         WRITE_FLOAT_FIELD(rows, "%.0f");
1387 }
1388
1389 static void
1390 _outBitmapHeapPath(StringInfo str, BitmapHeapPath *node)
1391 {
1392         WRITE_NODE_TYPE("BITMAPHEAPPATH");
1393
1394         _outPathInfo(str, (Path *) node);
1395
1396         WRITE_NODE_FIELD(bitmapqual);
1397         WRITE_BOOL_FIELD(isjoininner);
1398         WRITE_FLOAT_FIELD(rows, "%.0f");
1399 }
1400
1401 static void
1402 _outBitmapAndPath(StringInfo str, BitmapAndPath *node)
1403 {
1404         WRITE_NODE_TYPE("BITMAPANDPATH");
1405
1406         _outPathInfo(str, (Path *) node);
1407
1408         WRITE_NODE_FIELD(bitmapquals);
1409         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1410 }
1411
1412 static void
1413 _outBitmapOrPath(StringInfo str, BitmapOrPath *node)
1414 {
1415         WRITE_NODE_TYPE("BITMAPORPATH");
1416
1417         _outPathInfo(str, (Path *) node);
1418
1419         WRITE_NODE_FIELD(bitmapquals);
1420         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1421 }
1422
1423 static void
1424 _outTidPath(StringInfo str, TidPath *node)
1425 {
1426         WRITE_NODE_TYPE("TIDPATH");
1427
1428         _outPathInfo(str, (Path *) node);
1429
1430         WRITE_NODE_FIELD(tidquals);
1431 }
1432
1433 static void
1434 _outAppendPath(StringInfo str, AppendPath *node)
1435 {
1436         WRITE_NODE_TYPE("APPENDPATH");
1437
1438         _outPathInfo(str, (Path *) node);
1439
1440         WRITE_NODE_FIELD(subpaths);
1441 }
1442
1443 static void
1444 _outResultPath(StringInfo str, ResultPath *node)
1445 {
1446         WRITE_NODE_TYPE("RESULTPATH");
1447
1448         _outPathInfo(str, (Path *) node);
1449
1450         WRITE_NODE_FIELD(quals);
1451 }
1452
1453 static void
1454 _outMaterialPath(StringInfo str, MaterialPath *node)
1455 {
1456         WRITE_NODE_TYPE("MATERIALPATH");
1457
1458         _outPathInfo(str, (Path *) node);
1459
1460         WRITE_NODE_FIELD(subpath);
1461 }
1462
1463 static void
1464 _outUniquePath(StringInfo str, UniquePath *node)
1465 {
1466         WRITE_NODE_TYPE("UNIQUEPATH");
1467
1468         _outPathInfo(str, (Path *) node);
1469
1470         WRITE_NODE_FIELD(subpath);
1471         WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1472         WRITE_NODE_FIELD(in_operators);
1473         WRITE_NODE_FIELD(uniq_exprs);
1474         WRITE_FLOAT_FIELD(rows, "%.0f");
1475 }
1476
1477 static void
1478 _outNoOpPath(StringInfo str, NoOpPath *node)
1479 {
1480         WRITE_NODE_TYPE("NOOPPATH");
1481
1482         _outPathInfo(str, (Path *) node);
1483
1484         WRITE_NODE_FIELD(subpath);
1485 }
1486
1487 static void
1488 _outNestPath(StringInfo str, NestPath *node)
1489 {
1490         WRITE_NODE_TYPE("NESTPATH");
1491
1492         _outJoinPathInfo(str, (JoinPath *) node);
1493 }
1494
1495 static void
1496 _outMergePath(StringInfo str, MergePath *node)
1497 {
1498         WRITE_NODE_TYPE("MERGEPATH");
1499
1500         _outJoinPathInfo(str, (JoinPath *) node);
1501
1502         WRITE_NODE_FIELD(path_mergeclauses);
1503         WRITE_NODE_FIELD(outersortkeys);
1504         WRITE_NODE_FIELD(innersortkeys);
1505         WRITE_BOOL_FIELD(materialize_inner);
1506 }
1507
1508 static void
1509 _outHashPath(StringInfo str, HashPath *node)
1510 {
1511         WRITE_NODE_TYPE("HASHPATH");
1512
1513         _outJoinPathInfo(str, (JoinPath *) node);
1514
1515         WRITE_NODE_FIELD(path_hashclauses);
1516         WRITE_INT_FIELD(num_batches);
1517 }
1518
1519 static void
1520 _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
1521 {
1522         WRITE_NODE_TYPE("PLANNERGLOBAL");
1523
1524         /* NB: this isn't a complete set of fields */
1525         WRITE_NODE_FIELD(paramlist);
1526         WRITE_NODE_FIELD(subplans);
1527         WRITE_NODE_FIELD(subrtables);
1528         WRITE_NODE_FIELD(subrowmarks);
1529         WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1530         WRITE_NODE_FIELD(finalrtable);
1531         WRITE_NODE_FIELD(finalrowmarks);
1532         WRITE_NODE_FIELD(relationOids);
1533         WRITE_NODE_FIELD(invalItems);
1534         WRITE_UINT_FIELD(lastPHId);
1535         WRITE_BOOL_FIELD(transientPlan);
1536 }
1537
1538 static void
1539 _outPlannerInfo(StringInfo str, PlannerInfo *node)
1540 {
1541         WRITE_NODE_TYPE("PLANNERINFO");
1542
1543         /* NB: this isn't a complete set of fields */
1544         WRITE_NODE_FIELD(parse);
1545         WRITE_NODE_FIELD(glob);
1546         WRITE_UINT_FIELD(query_level);
1547         WRITE_NODE_FIELD(join_rel_list);
1548         WRITE_INT_FIELD(join_cur_level);
1549         WRITE_NODE_FIELD(resultRelations);
1550         WRITE_NODE_FIELD(init_plans);
1551         WRITE_NODE_FIELD(cte_plan_ids);
1552         WRITE_NODE_FIELD(eq_classes);
1553         WRITE_NODE_FIELD(canon_pathkeys);
1554         WRITE_NODE_FIELD(left_join_clauses);
1555         WRITE_NODE_FIELD(right_join_clauses);
1556         WRITE_NODE_FIELD(full_join_clauses);
1557         WRITE_NODE_FIELD(join_info_list);
1558         WRITE_NODE_FIELD(append_rel_list);
1559         WRITE_NODE_FIELD(rowMarks);
1560         WRITE_NODE_FIELD(placeholder_list);
1561         WRITE_NODE_FIELD(query_pathkeys);
1562         WRITE_NODE_FIELD(group_pathkeys);
1563         WRITE_NODE_FIELD(window_pathkeys);
1564         WRITE_NODE_FIELD(distinct_pathkeys);
1565         WRITE_NODE_FIELD(sort_pathkeys);
1566         WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1567         WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1568         WRITE_BOOL_FIELD(hasJoinRTEs);
1569         WRITE_BOOL_FIELD(hasHavingQual);
1570         WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1571         WRITE_BOOL_FIELD(hasRecursion);
1572         WRITE_INT_FIELD(wt_param_id);
1573 }
1574
1575 static void
1576 _outRelOptInfo(StringInfo str, RelOptInfo *node)
1577 {
1578         WRITE_NODE_TYPE("RELOPTINFO");
1579
1580         /* NB: this isn't a complete set of fields */
1581         WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1582         WRITE_BITMAPSET_FIELD(relids);
1583         WRITE_FLOAT_FIELD(rows, "%.0f");
1584         WRITE_INT_FIELD(width);
1585         WRITE_NODE_FIELD(reltargetlist);
1586         WRITE_NODE_FIELD(pathlist);
1587         WRITE_NODE_FIELD(cheapest_startup_path);
1588         WRITE_NODE_FIELD(cheapest_total_path);
1589         WRITE_NODE_FIELD(cheapest_unique_path);
1590         WRITE_UINT_FIELD(relid);
1591         WRITE_ENUM_FIELD(rtekind, RTEKind);
1592         WRITE_INT_FIELD(min_attr);
1593         WRITE_INT_FIELD(max_attr);
1594         WRITE_NODE_FIELD(indexlist);
1595         WRITE_UINT_FIELD(pages);
1596         WRITE_FLOAT_FIELD(tuples, "%.0f");
1597         WRITE_NODE_FIELD(subplan);
1598         WRITE_NODE_FIELD(subrtable);
1599         WRITE_NODE_FIELD(subrowmark);
1600         WRITE_NODE_FIELD(baserestrictinfo);
1601         WRITE_NODE_FIELD(joininfo);
1602         WRITE_BOOL_FIELD(has_eclass_joins);
1603         WRITE_BITMAPSET_FIELD(index_outer_relids);
1604         WRITE_NODE_FIELD(index_inner_paths);
1605 }
1606
1607 static void
1608 _outIndexOptInfo(StringInfo str, IndexOptInfo *node)
1609 {
1610         WRITE_NODE_TYPE("INDEXOPTINFO");
1611
1612         /* NB: this isn't a complete set of fields */
1613         WRITE_OID_FIELD(indexoid);
1614         /* Do NOT print rel field, else infinite recursion */
1615         WRITE_UINT_FIELD(pages);
1616         WRITE_FLOAT_FIELD(tuples, "%.0f");
1617         WRITE_INT_FIELD(ncolumns);
1618         WRITE_NODE_FIELD(indexprs);
1619         WRITE_NODE_FIELD(indpred);
1620         WRITE_BOOL_FIELD(predOK);
1621         WRITE_BOOL_FIELD(unique);
1622 }
1623
1624 static void
1625 _outEquivalenceClass(StringInfo str, EquivalenceClass *node)
1626 {
1627         /*
1628          * To simplify reading, we just chase up to the topmost merged EC and
1629          * print that, without bothering to show the merge-ees separately.
1630          */
1631         while (node->ec_merged)
1632                 node = node->ec_merged;
1633
1634         WRITE_NODE_TYPE("EQUIVALENCECLASS");
1635
1636         WRITE_NODE_FIELD(ec_opfamilies);
1637         WRITE_NODE_FIELD(ec_members);
1638         WRITE_NODE_FIELD(ec_sources);
1639         WRITE_NODE_FIELD(ec_derives);
1640         WRITE_BITMAPSET_FIELD(ec_relids);
1641         WRITE_BOOL_FIELD(ec_has_const);
1642         WRITE_BOOL_FIELD(ec_has_volatile);
1643         WRITE_BOOL_FIELD(ec_below_outer_join);
1644         WRITE_BOOL_FIELD(ec_broken);
1645         WRITE_UINT_FIELD(ec_sortref);
1646 }
1647
1648 static void
1649 _outEquivalenceMember(StringInfo str, EquivalenceMember *node)
1650 {
1651         WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1652
1653         WRITE_NODE_FIELD(em_expr);
1654         WRITE_BITMAPSET_FIELD(em_relids);
1655         WRITE_BOOL_FIELD(em_is_const);
1656         WRITE_BOOL_FIELD(em_is_child);
1657         WRITE_OID_FIELD(em_datatype);
1658 }
1659
1660 static void
1661 _outPathKey(StringInfo str, PathKey *node)
1662 {
1663         WRITE_NODE_TYPE("PATHKEY");
1664
1665         WRITE_NODE_FIELD(pk_eclass);
1666         WRITE_OID_FIELD(pk_opfamily);
1667         WRITE_INT_FIELD(pk_strategy);
1668         WRITE_BOOL_FIELD(pk_nulls_first);
1669 }
1670
1671 static void
1672 _outRestrictInfo(StringInfo str, RestrictInfo *node)
1673 {
1674         WRITE_NODE_TYPE("RESTRICTINFO");
1675
1676         /* NB: this isn't a complete set of fields */
1677         WRITE_NODE_FIELD(clause);
1678         WRITE_BOOL_FIELD(is_pushed_down);
1679         WRITE_BOOL_FIELD(outerjoin_delayed);
1680         WRITE_BOOL_FIELD(can_join);
1681         WRITE_BOOL_FIELD(pseudoconstant);
1682         WRITE_BITMAPSET_FIELD(clause_relids);
1683         WRITE_BITMAPSET_FIELD(required_relids);
1684         WRITE_BITMAPSET_FIELD(nullable_relids);
1685         WRITE_BITMAPSET_FIELD(left_relids);
1686         WRITE_BITMAPSET_FIELD(right_relids);
1687         WRITE_NODE_FIELD(orclause);
1688         /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1689         WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1690         WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1691         WRITE_NODE_FIELD(mergeopfamilies);
1692         /* don't write left_ec, leads to infinite recursion in plan tree dump */
1693         /* don't write right_ec, leads to infinite recursion in plan tree dump */
1694         WRITE_NODE_FIELD(left_em);
1695         WRITE_NODE_FIELD(right_em);
1696         WRITE_BOOL_FIELD(outer_is_left);
1697         WRITE_OID_FIELD(hashjoinoperator);
1698 }
1699
1700 static void
1701 _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
1702 {
1703         WRITE_NODE_TYPE("INNERINDEXSCANINFO");
1704         WRITE_BITMAPSET_FIELD(other_relids);
1705         WRITE_BOOL_FIELD(isouterjoin);
1706         WRITE_NODE_FIELD(cheapest_startup_innerpath);
1707         WRITE_NODE_FIELD(cheapest_total_innerpath);
1708 }
1709
1710 static void
1711 _outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
1712 {
1713         WRITE_NODE_TYPE("PLACEHOLDERVAR");
1714
1715         WRITE_NODE_FIELD(phexpr);
1716         WRITE_BITMAPSET_FIELD(phrels);
1717         WRITE_UINT_FIELD(phid);
1718         WRITE_UINT_FIELD(phlevelsup);
1719 }
1720
1721 static void
1722 _outSpecialJoinInfo(StringInfo str, SpecialJoinInfo *node)
1723 {
1724         WRITE_NODE_TYPE("SPECIALJOININFO");
1725
1726         WRITE_BITMAPSET_FIELD(min_lefthand);
1727         WRITE_BITMAPSET_FIELD(min_righthand);
1728         WRITE_BITMAPSET_FIELD(syn_lefthand);
1729         WRITE_BITMAPSET_FIELD(syn_righthand);
1730         WRITE_ENUM_FIELD(jointype, JoinType);
1731         WRITE_BOOL_FIELD(lhs_strict);
1732         WRITE_BOOL_FIELD(delay_upper_joins);
1733         WRITE_NODE_FIELD(join_quals);
1734 }
1735
1736 static void
1737 _outAppendRelInfo(StringInfo str, AppendRelInfo *node)
1738 {
1739         WRITE_NODE_TYPE("APPENDRELINFO");
1740
1741         WRITE_UINT_FIELD(parent_relid);
1742         WRITE_UINT_FIELD(child_relid);
1743         WRITE_OID_FIELD(parent_reltype);
1744         WRITE_OID_FIELD(child_reltype);
1745         WRITE_NODE_FIELD(translated_vars);
1746         WRITE_OID_FIELD(parent_reloid);
1747 }
1748
1749 static void
1750 _outPlaceHolderInfo(StringInfo str, PlaceHolderInfo *node)
1751 {
1752         WRITE_NODE_TYPE("PLACEHOLDERINFO");
1753
1754         WRITE_UINT_FIELD(phid);
1755         WRITE_NODE_FIELD(ph_var);
1756         WRITE_BITMAPSET_FIELD(ph_eval_at);
1757         WRITE_BITMAPSET_FIELD(ph_needed);
1758         WRITE_INT_FIELD(ph_width);
1759 }
1760
1761 static void
1762 _outPlannerParamItem(StringInfo str, PlannerParamItem *node)
1763 {
1764         WRITE_NODE_TYPE("PLANNERPARAMITEM");
1765
1766         WRITE_NODE_FIELD(item);
1767         WRITE_UINT_FIELD(abslevel);
1768 }
1769
1770 /*****************************************************************************
1771  *
1772  *      Stuff from parsenodes.h.
1773  *
1774  *****************************************************************************/
1775
1776 static void
1777 _outCreateStmt(StringInfo str, CreateStmt *node)
1778 {
1779         WRITE_NODE_TYPE("CREATESTMT");
1780
1781         WRITE_NODE_FIELD(relation);
1782         WRITE_NODE_FIELD(tableElts);
1783         WRITE_NODE_FIELD(inhRelations);
1784         WRITE_NODE_FIELD(constraints);
1785         WRITE_NODE_FIELD(options);
1786         WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1787         WRITE_STRING_FIELD(tablespacename);
1788 }
1789
1790 static void
1791 _outIndexStmt(StringInfo str, IndexStmt *node)
1792 {
1793         WRITE_NODE_TYPE("INDEXSTMT");
1794
1795         WRITE_STRING_FIELD(idxname);
1796         WRITE_NODE_FIELD(relation);
1797         WRITE_STRING_FIELD(accessMethod);
1798         WRITE_STRING_FIELD(tableSpace);
1799         WRITE_NODE_FIELD(indexParams);
1800         WRITE_NODE_FIELD(options);
1801         WRITE_NODE_FIELD(whereClause);
1802         WRITE_NODE_FIELD(excludeOpNames);
1803         WRITE_BOOL_FIELD(unique);
1804         WRITE_BOOL_FIELD(primary);
1805         WRITE_BOOL_FIELD(isconstraint);
1806         WRITE_BOOL_FIELD(deferrable);
1807         WRITE_BOOL_FIELD(initdeferred);
1808         WRITE_BOOL_FIELD(concurrent);
1809 }
1810
1811 static void
1812 _outNotifyStmt(StringInfo str, NotifyStmt *node)
1813 {
1814         WRITE_NODE_TYPE("NOTIFY");
1815
1816         WRITE_STRING_FIELD(conditionname);
1817 }
1818
1819 static void
1820 _outDeclareCursorStmt(StringInfo str, DeclareCursorStmt *node)
1821 {
1822         WRITE_NODE_TYPE("DECLARECURSOR");
1823
1824         WRITE_STRING_FIELD(portalname);
1825         WRITE_INT_FIELD(options);
1826         WRITE_NODE_FIELD(query);
1827 }
1828
1829 static void
1830 _outSelectStmt(StringInfo str, SelectStmt *node)
1831 {
1832         WRITE_NODE_TYPE("SELECT");
1833
1834         WRITE_NODE_FIELD(distinctClause);
1835         WRITE_NODE_FIELD(intoClause);
1836         WRITE_NODE_FIELD(targetList);
1837         WRITE_NODE_FIELD(fromClause);
1838         WRITE_NODE_FIELD(whereClause);
1839         WRITE_NODE_FIELD(groupClause);
1840         WRITE_NODE_FIELD(havingClause);
1841         WRITE_NODE_FIELD(windowClause);
1842         WRITE_NODE_FIELD(withClause);
1843         WRITE_NODE_FIELD(valuesLists);
1844         WRITE_NODE_FIELD(sortClause);
1845         WRITE_NODE_FIELD(limitOffset);
1846         WRITE_NODE_FIELD(limitCount);
1847         WRITE_NODE_FIELD(lockingClause);
1848         WRITE_ENUM_FIELD(op, SetOperation);
1849         WRITE_BOOL_FIELD(all);
1850         WRITE_NODE_FIELD(larg);
1851         WRITE_NODE_FIELD(rarg);
1852 }
1853
1854 static void
1855 _outFuncCall(StringInfo str, FuncCall *node)
1856 {
1857         WRITE_NODE_TYPE("FUNCCALL");
1858
1859         WRITE_NODE_FIELD(funcname);
1860         WRITE_NODE_FIELD(args);
1861         WRITE_NODE_FIELD(agg_order);
1862         WRITE_BOOL_FIELD(agg_star);
1863         WRITE_BOOL_FIELD(agg_distinct);
1864         WRITE_BOOL_FIELD(func_variadic);
1865         WRITE_NODE_FIELD(over);
1866         WRITE_LOCATION_FIELD(location);
1867 }
1868
1869 static void
1870 _outDefElem(StringInfo str, DefElem *node)
1871 {
1872         WRITE_NODE_TYPE("DEFELEM");
1873
1874         WRITE_STRING_FIELD(defnamespace);
1875         WRITE_STRING_FIELD(defname);
1876         WRITE_NODE_FIELD(arg);
1877         WRITE_ENUM_FIELD(defaction, DefElemAction);
1878 }
1879
1880 static void
1881 _outLockingClause(StringInfo str, LockingClause *node)
1882 {
1883         WRITE_NODE_TYPE("LOCKINGCLAUSE");
1884
1885         WRITE_NODE_FIELD(lockedRels);
1886         WRITE_BOOL_FIELD(forUpdate);
1887         WRITE_BOOL_FIELD(noWait);
1888 }
1889
1890 static void
1891 _outXmlSerialize(StringInfo str, XmlSerialize *node)
1892 {
1893         WRITE_NODE_TYPE("XMLSERIALIZE");
1894
1895         WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1896         WRITE_NODE_FIELD(expr);
1897         WRITE_NODE_FIELD(typeName);
1898         WRITE_LOCATION_FIELD(location);
1899 }
1900
1901 static void
1902 _outColumnDef(StringInfo str, ColumnDef *node)
1903 {
1904         WRITE_NODE_TYPE("COLUMNDEF");
1905
1906         WRITE_STRING_FIELD(colname);
1907         WRITE_NODE_FIELD(typeName);
1908         WRITE_INT_FIELD(inhcount);
1909         WRITE_BOOL_FIELD(is_local);
1910         WRITE_BOOL_FIELD(is_not_null);
1911         WRITE_INT_FIELD(storage);
1912         WRITE_NODE_FIELD(raw_default);
1913         WRITE_NODE_FIELD(cooked_default);
1914         WRITE_NODE_FIELD(constraints);
1915 }
1916
1917 static void
1918 _outTypeName(StringInfo str, TypeName *node)
1919 {
1920         WRITE_NODE_TYPE("TYPENAME");
1921
1922         WRITE_NODE_FIELD(names);
1923         WRITE_OID_FIELD(typeOid);
1924         WRITE_BOOL_FIELD(setof);
1925         WRITE_BOOL_FIELD(pct_type);
1926         WRITE_NODE_FIELD(typmods);
1927         WRITE_INT_FIELD(typemod);
1928         WRITE_NODE_FIELD(arrayBounds);
1929         WRITE_LOCATION_FIELD(location);
1930 }
1931
1932 static void
1933 _outTypeCast(StringInfo str, TypeCast *node)
1934 {
1935         WRITE_NODE_TYPE("TYPECAST");
1936
1937         WRITE_NODE_FIELD(arg);
1938         WRITE_NODE_FIELD(typeName);
1939         WRITE_LOCATION_FIELD(location);
1940 }
1941
1942 static void
1943 _outIndexElem(StringInfo str, IndexElem *node)
1944 {
1945         WRITE_NODE_TYPE("INDEXELEM");
1946
1947         WRITE_STRING_FIELD(name);
1948         WRITE_NODE_FIELD(expr);
1949         WRITE_NODE_FIELD(opclass);
1950         WRITE_ENUM_FIELD(ordering, SortByDir);
1951         WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
1952 }
1953
1954 static void
1955 _outQuery(StringInfo str, Query *node)
1956 {
1957         WRITE_NODE_TYPE("QUERY");
1958
1959         WRITE_ENUM_FIELD(commandType, CmdType);
1960         WRITE_ENUM_FIELD(querySource, QuerySource);
1961         WRITE_BOOL_FIELD(canSetTag);
1962
1963         /*
1964          * Hack to work around missing outfuncs routines for a lot of the
1965          * utility-statement node types.  (The only one we actually *need* for
1966          * rules support is NotifyStmt.)  Someday we ought to support 'em all, but
1967          * for the meantime do this to avoid getting lots of warnings when running
1968          * with debug_print_parse on.
1969          */
1970         if (node->utilityStmt)
1971         {
1972                 switch (nodeTag(node->utilityStmt))
1973                 {
1974                         case T_CreateStmt:
1975                         case T_IndexStmt:
1976                         case T_NotifyStmt:
1977                         case T_DeclareCursorStmt:
1978                                 WRITE_NODE_FIELD(utilityStmt);
1979                                 break;
1980                         default:
1981                                 appendStringInfo(str, " :utilityStmt ?");
1982                                 break;
1983                 }
1984         }
1985         else
1986                 appendStringInfo(str, " :utilityStmt <>");
1987
1988         WRITE_INT_FIELD(resultRelation);
1989         WRITE_NODE_FIELD(intoClause);
1990         WRITE_BOOL_FIELD(hasAggs);
1991         WRITE_BOOL_FIELD(hasWindowFuncs);
1992         WRITE_BOOL_FIELD(hasSubLinks);
1993         WRITE_BOOL_FIELD(hasDistinctOn);
1994         WRITE_BOOL_FIELD(hasRecursive);
1995         WRITE_BOOL_FIELD(hasForUpdate);
1996         WRITE_NODE_FIELD(cteList);
1997         WRITE_NODE_FIELD(rtable);
1998         WRITE_NODE_FIELD(jointree);
1999         WRITE_NODE_FIELD(targetList);
2000         WRITE_NODE_FIELD(returningList);
2001         WRITE_NODE_FIELD(groupClause);
2002         WRITE_NODE_FIELD(havingQual);
2003         WRITE_NODE_FIELD(windowClause);
2004         WRITE_NODE_FIELD(distinctClause);
2005         WRITE_NODE_FIELD(sortClause);
2006         WRITE_NODE_FIELD(limitOffset);
2007         WRITE_NODE_FIELD(limitCount);
2008         WRITE_NODE_FIELD(rowMarks);
2009         WRITE_NODE_FIELD(setOperations);
2010 }
2011
2012 static void
2013 _outSortGroupClause(StringInfo str, SortGroupClause *node)
2014 {
2015         WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2016
2017         WRITE_UINT_FIELD(tleSortGroupRef);
2018         WRITE_OID_FIELD(eqop);
2019         WRITE_OID_FIELD(sortop);
2020         WRITE_BOOL_FIELD(nulls_first);
2021 }
2022
2023 static void
2024 _outWindowClause(StringInfo str, WindowClause *node)
2025 {
2026         WRITE_NODE_TYPE("WINDOWCLAUSE");
2027
2028         WRITE_STRING_FIELD(name);
2029         WRITE_STRING_FIELD(refname);
2030         WRITE_NODE_FIELD(partitionClause);
2031         WRITE_NODE_FIELD(orderClause);
2032         WRITE_INT_FIELD(frameOptions);
2033         WRITE_UINT_FIELD(winref);
2034         WRITE_BOOL_FIELD(copiedOrder);
2035 }
2036
2037 static void
2038 _outRowMarkClause(StringInfo str, RowMarkClause *node)
2039 {
2040         WRITE_NODE_TYPE("ROWMARKCLAUSE");
2041
2042         WRITE_UINT_FIELD(rti);
2043         WRITE_BOOL_FIELD(forUpdate);
2044         WRITE_BOOL_FIELD(noWait);
2045         WRITE_BOOL_FIELD(pushedDown);
2046 }
2047
2048 static void
2049 _outWithClause(StringInfo str, WithClause *node)
2050 {
2051         WRITE_NODE_TYPE("WITHCLAUSE");
2052
2053         WRITE_NODE_FIELD(ctes);
2054         WRITE_BOOL_FIELD(recursive);
2055         WRITE_LOCATION_FIELD(location);
2056 }
2057
2058 static void
2059 _outCommonTableExpr(StringInfo str, CommonTableExpr *node)
2060 {
2061         WRITE_NODE_TYPE("COMMONTABLEEXPR");
2062
2063         WRITE_STRING_FIELD(ctename);
2064         WRITE_NODE_FIELD(aliascolnames);
2065         WRITE_NODE_FIELD(ctequery);
2066         WRITE_LOCATION_FIELD(location);
2067         WRITE_BOOL_FIELD(cterecursive);
2068         WRITE_INT_FIELD(cterefcount);
2069         WRITE_NODE_FIELD(ctecolnames);
2070         WRITE_NODE_FIELD(ctecoltypes);
2071         WRITE_NODE_FIELD(ctecoltypmods);
2072 }
2073
2074 static void
2075 _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
2076 {
2077         WRITE_NODE_TYPE("SETOPERATIONSTMT");
2078
2079         WRITE_ENUM_FIELD(op, SetOperation);
2080         WRITE_BOOL_FIELD(all);
2081         WRITE_NODE_FIELD(larg);
2082         WRITE_NODE_FIELD(rarg);
2083         WRITE_NODE_FIELD(colTypes);
2084         WRITE_NODE_FIELD(colTypmods);
2085         WRITE_NODE_FIELD(groupClauses);
2086 }
2087
2088 static void
2089 _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
2090 {
2091         WRITE_NODE_TYPE("RTE");
2092
2093         /* put alias + eref first to make dump more legible */
2094         WRITE_NODE_FIELD(alias);
2095         WRITE_NODE_FIELD(eref);
2096         WRITE_ENUM_FIELD(rtekind, RTEKind);
2097
2098         switch (node->rtekind)
2099         {
2100                 case RTE_RELATION:
2101                 case RTE_SPECIAL:
2102                         WRITE_OID_FIELD(relid);
2103                         break;
2104                 case RTE_SUBQUERY:
2105                         WRITE_NODE_FIELD(subquery);
2106                         break;
2107                 case RTE_JOIN:
2108                         WRITE_ENUM_FIELD(jointype, JoinType);
2109                         WRITE_NODE_FIELD(joinaliasvars);
2110                         break;
2111                 case RTE_FUNCTION:
2112                         WRITE_NODE_FIELD(funcexpr);
2113                         WRITE_NODE_FIELD(funccoltypes);
2114                         WRITE_NODE_FIELD(funccoltypmods);
2115                         break;
2116                 case RTE_VALUES:
2117                         WRITE_NODE_FIELD(values_lists);
2118                         break;
2119                 case RTE_CTE:
2120                         WRITE_STRING_FIELD(ctename);
2121                         WRITE_UINT_FIELD(ctelevelsup);
2122                         WRITE_BOOL_FIELD(self_reference);
2123                         WRITE_NODE_FIELD(ctecoltypes);
2124                         WRITE_NODE_FIELD(ctecoltypmods);
2125                         break;
2126                 default:
2127                         elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2128                         break;
2129         }
2130
2131         WRITE_BOOL_FIELD(inh);
2132         WRITE_BOOL_FIELD(inFromCl);
2133         WRITE_UINT_FIELD(requiredPerms);
2134         WRITE_OID_FIELD(checkAsUser);
2135         WRITE_BITMAPSET_FIELD(selectedCols);
2136         WRITE_BITMAPSET_FIELD(modifiedCols);
2137 }
2138
2139 static void
2140 _outAExpr(StringInfo str, A_Expr *node)
2141 {
2142         WRITE_NODE_TYPE("AEXPR");
2143
2144         switch (node->kind)
2145         {
2146                 case AEXPR_OP:
2147                         appendStringInfo(str, " ");
2148                         WRITE_NODE_FIELD(name);
2149                         break;
2150                 case AEXPR_AND:
2151                         appendStringInfo(str, " AND");
2152                         break;
2153                 case AEXPR_OR:
2154                         appendStringInfo(str, " OR");
2155                         break;
2156                 case AEXPR_NOT:
2157                         appendStringInfo(str, " NOT");
2158                         break;
2159                 case AEXPR_OP_ANY:
2160                         appendStringInfo(str, " ");
2161                         WRITE_NODE_FIELD(name);
2162                         appendStringInfo(str, " ANY ");
2163                         break;
2164                 case AEXPR_OP_ALL:
2165                         appendStringInfo(str, " ");
2166                         WRITE_NODE_FIELD(name);
2167                         appendStringInfo(str, " ALL ");
2168                         break;
2169                 case AEXPR_DISTINCT:
2170                         appendStringInfo(str, " DISTINCT ");
2171                         WRITE_NODE_FIELD(name);
2172                         break;
2173                 case AEXPR_NULLIF:
2174                         appendStringInfo(str, " NULLIF ");
2175                         WRITE_NODE_FIELD(name);
2176                         break;
2177                 case AEXPR_OF:
2178                         appendStringInfo(str, " OF ");
2179                         WRITE_NODE_FIELD(name);
2180                         break;
2181                 case AEXPR_IN:
2182                         appendStringInfo(str, " IN ");
2183                         WRITE_NODE_FIELD(name);
2184                         break;
2185                 default:
2186                         appendStringInfo(str, " ??");
2187                         break;
2188         }
2189
2190         WRITE_NODE_FIELD(lexpr);
2191         WRITE_NODE_FIELD(rexpr);
2192         WRITE_LOCATION_FIELD(location);
2193 }
2194
2195 static void
2196 _outValue(StringInfo str, Value *value)
2197 {
2198         switch (value->type)
2199         {
2200                 case T_Integer:
2201                         appendStringInfo(str, "%ld", value->val.ival);
2202                         break;
2203                 case T_Float:
2204
2205                         /*
2206                          * We assume the value is a valid numeric literal and so does not
2207                          * need quoting.
2208                          */
2209                         appendStringInfoString(str, value->val.str);
2210                         break;
2211                 case T_String:
2212                         appendStringInfoChar(str, '"');
2213                         _outToken(str, value->val.str);
2214                         appendStringInfoChar(str, '"');
2215                         break;
2216                 case T_BitString:
2217                         /* internal representation already has leading 'b' */
2218                         appendStringInfoString(str, value->val.str);
2219                         break;
2220                 case T_Null:
2221                         /* this is seen only within A_Const, not in transformed trees */
2222                         appendStringInfoString(str, "NULL");
2223                         break;
2224                 default:
2225                         elog(ERROR, "unrecognized node type: %d", (int) value->type);
2226                         break;
2227         }
2228 }
2229
2230 static void
2231 _outColumnRef(StringInfo str, ColumnRef *node)
2232 {
2233         WRITE_NODE_TYPE("COLUMNREF");
2234
2235         WRITE_NODE_FIELD(fields);
2236         WRITE_LOCATION_FIELD(location);
2237 }
2238
2239 static void
2240 _outParamRef(StringInfo str, ParamRef *node)
2241 {
2242         WRITE_NODE_TYPE("PARAMREF");
2243
2244         WRITE_INT_FIELD(number);
2245         WRITE_LOCATION_FIELD(location);
2246 }
2247
2248 static void
2249 _outAConst(StringInfo str, A_Const *node)
2250 {
2251         WRITE_NODE_TYPE("A_CONST");
2252
2253         appendStringInfo(str, " :val ");
2254         _outValue(str, &(node->val));
2255         WRITE_LOCATION_FIELD(location);
2256 }
2257
2258 static void
2259 _outA_Star(StringInfo str, A_Star *node)
2260 {
2261         WRITE_NODE_TYPE("A_STAR");
2262 }
2263
2264 static void
2265 _outA_Indices(StringInfo str, A_Indices *node)
2266 {
2267         WRITE_NODE_TYPE("A_INDICES");
2268
2269         WRITE_NODE_FIELD(lidx);
2270         WRITE_NODE_FIELD(uidx);
2271 }
2272
2273 static void
2274 _outA_Indirection(StringInfo str, A_Indirection *node)
2275 {
2276         WRITE_NODE_TYPE("A_INDIRECTION");
2277
2278         WRITE_NODE_FIELD(arg);
2279         WRITE_NODE_FIELD(indirection);
2280 }
2281
2282 static void
2283 _outA_ArrayExpr(StringInfo str, A_ArrayExpr *node)
2284 {
2285         WRITE_NODE_TYPE("A_ARRAYEXPR");
2286
2287         WRITE_NODE_FIELD(elements);
2288         WRITE_LOCATION_FIELD(location);
2289 }
2290
2291 static void
2292 _outResTarget(StringInfo str, ResTarget *node)
2293 {
2294         WRITE_NODE_TYPE("RESTARGET");
2295
2296         WRITE_STRING_FIELD(name);
2297         WRITE_NODE_FIELD(indirection);
2298         WRITE_NODE_FIELD(val);
2299         WRITE_LOCATION_FIELD(location);
2300 }
2301
2302 static void
2303 _outSortBy(StringInfo str, SortBy *node)
2304 {
2305         WRITE_NODE_TYPE("SORTBY");
2306
2307         WRITE_NODE_FIELD(node);
2308         WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2309         WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2310         WRITE_NODE_FIELD(useOp);
2311         WRITE_LOCATION_FIELD(location);
2312 }
2313
2314 static void
2315 _outWindowDef(StringInfo str, WindowDef *node)
2316 {
2317         WRITE_NODE_TYPE("WINDOWDEF");
2318
2319         WRITE_STRING_FIELD(name);
2320         WRITE_STRING_FIELD(refname);
2321         WRITE_NODE_FIELD(partitionClause);
2322         WRITE_NODE_FIELD(orderClause);
2323         WRITE_INT_FIELD(frameOptions);
2324         WRITE_LOCATION_FIELD(location);
2325 }
2326
2327 static void
2328 _outRangeSubselect(StringInfo str, RangeSubselect *node)
2329 {
2330         WRITE_NODE_TYPE("RANGESUBSELECT");
2331
2332         WRITE_NODE_FIELD(subquery);
2333         WRITE_NODE_FIELD(alias);
2334 }
2335
2336 static void
2337 _outRangeFunction(StringInfo str, RangeFunction *node)
2338 {
2339         WRITE_NODE_TYPE("RANGEFUNCTION");
2340
2341         WRITE_NODE_FIELD(funccallnode);
2342         WRITE_NODE_FIELD(alias);
2343         WRITE_NODE_FIELD(coldeflist);
2344 }
2345
2346 static void
2347 _outConstraint(StringInfo str, Constraint *node)
2348 {
2349         WRITE_NODE_TYPE("CONSTRAINT");
2350
2351         WRITE_STRING_FIELD(conname);
2352         WRITE_BOOL_FIELD(deferrable);
2353         WRITE_BOOL_FIELD(initdeferred);
2354         WRITE_LOCATION_FIELD(location);
2355
2356         appendStringInfo(str, " :contype ");
2357         switch (node->contype)
2358         {
2359                 case CONSTR_NULL:
2360                         appendStringInfo(str, "NULL");
2361                         break;
2362
2363                 case CONSTR_NOTNULL:
2364                         appendStringInfo(str, "NOT_NULL");
2365                         break;
2366
2367                 case CONSTR_DEFAULT:
2368                         appendStringInfo(str, "DEFAULT");
2369                         WRITE_NODE_FIELD(raw_expr);
2370                         WRITE_STRING_FIELD(cooked_expr);
2371                         break;
2372
2373                 case CONSTR_CHECK:
2374                         appendStringInfo(str, "CHECK");
2375                         WRITE_NODE_FIELD(raw_expr);
2376                         WRITE_STRING_FIELD(cooked_expr);
2377                         break;
2378
2379                 case CONSTR_PRIMARY:
2380                         appendStringInfo(str, "PRIMARY_KEY");
2381                         WRITE_NODE_FIELD(keys);
2382                         WRITE_NODE_FIELD(options);
2383                         WRITE_STRING_FIELD(indexspace);
2384                         /* access_method and where_clause not currently used */
2385                         break;
2386
2387                 case CONSTR_UNIQUE:
2388                         appendStringInfo(str, "UNIQUE");
2389                         WRITE_NODE_FIELD(keys);
2390                         WRITE_NODE_FIELD(options);
2391                         WRITE_STRING_FIELD(indexspace);
2392                         /* access_method and where_clause not currently used */
2393                         break;
2394
2395                 case CONSTR_EXCLUSION:
2396                         appendStringInfo(str, "EXCLUSION");
2397                         WRITE_NODE_FIELD(exclusions);
2398                         WRITE_NODE_FIELD(options);
2399                         WRITE_STRING_FIELD(indexspace);
2400                         WRITE_STRING_FIELD(access_method);
2401                         WRITE_NODE_FIELD(where_clause);
2402                         break;
2403
2404                 case CONSTR_FOREIGN:
2405                         appendStringInfo(str, "FOREIGN_KEY");
2406                         WRITE_NODE_FIELD(pktable);
2407                         WRITE_NODE_FIELD(fk_attrs);
2408                         WRITE_NODE_FIELD(pk_attrs);
2409                         WRITE_CHAR_FIELD(fk_matchtype);
2410                         WRITE_CHAR_FIELD(fk_upd_action);
2411                         WRITE_CHAR_FIELD(fk_del_action);
2412                         WRITE_BOOL_FIELD(skip_validation);
2413                         break;
2414
2415                 case CONSTR_ATTR_DEFERRABLE:
2416                         appendStringInfo(str, "ATTR_DEFERRABLE");
2417                         break;
2418
2419                 case CONSTR_ATTR_NOT_DEFERRABLE:
2420                         appendStringInfo(str, "ATTR_NOT_DEFERRABLE");
2421                         break;
2422
2423                 case CONSTR_ATTR_DEFERRED:
2424                         appendStringInfo(str, "ATTR_DEFERRED");
2425                         break;
2426
2427                 case CONSTR_ATTR_IMMEDIATE:
2428                         appendStringInfo(str, "ATTR_IMMEDIATE");
2429                         break;
2430
2431                 default:
2432                         appendStringInfo(str, "<unrecognized_constraint %d>",
2433                                                          (int) node->contype);
2434                         break;
2435         }
2436 }
2437
2438
2439 /*
2440  * _outNode -
2441  *        converts a Node into ascii string and append it to 'str'
2442  */
2443 static void
2444 _outNode(StringInfo str, void *obj)
2445 {
2446         if (obj == NULL)
2447                 appendStringInfo(str, "<>");
2448         else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2449                 _outList(str, obj);
2450         else if (IsA(obj, Integer) ||
2451                          IsA(obj, Float) ||
2452                          IsA(obj, String) ||
2453                          IsA(obj, BitString))
2454         {
2455                 /* nodeRead does not want to see { } around these! */
2456                 _outValue(str, obj);
2457         }
2458         else
2459         {
2460                 appendStringInfoChar(str, '{');
2461                 switch (nodeTag(obj))
2462                 {
2463                         case T_PlannedStmt:
2464                                 _outPlannedStmt(str, obj);
2465                                 break;
2466                         case T_Plan:
2467                                 _outPlan(str, obj);
2468                                 break;
2469                         case T_Result:
2470                                 _outResult(str, obj);
2471                                 break;
2472                         case T_ModifyTable:
2473                                 _outModifyTable(str, obj);
2474                                 break;
2475                         case T_Append:
2476                                 _outAppend(str, obj);
2477                                 break;
2478                         case T_RecursiveUnion:
2479                                 _outRecursiveUnion(str, obj);
2480                                 break;
2481                         case T_BitmapAnd:
2482                                 _outBitmapAnd(str, obj);
2483                                 break;
2484                         case T_BitmapOr:
2485                                 _outBitmapOr(str, obj);
2486                                 break;
2487                         case T_Scan:
2488                                 _outScan(str, obj);
2489                                 break;
2490                         case T_SeqScan:
2491                                 _outSeqScan(str, obj);
2492                                 break;
2493                         case T_IndexScan:
2494                                 _outIndexScan(str, obj);
2495                                 break;
2496                         case T_BitmapIndexScan:
2497                                 _outBitmapIndexScan(str, obj);
2498                                 break;
2499                         case T_BitmapHeapScan:
2500                                 _outBitmapHeapScan(str, obj);
2501                                 break;
2502                         case T_TidScan:
2503                                 _outTidScan(str, obj);
2504                                 break;
2505                         case T_SubqueryScan:
2506                                 _outSubqueryScan(str, obj);
2507                                 break;
2508                         case T_FunctionScan:
2509                                 _outFunctionScan(str, obj);
2510                                 break;
2511                         case T_ValuesScan:
2512                                 _outValuesScan(str, obj);
2513                                 break;
2514                         case T_CteScan:
2515                                 _outCteScan(str, obj);
2516                                 break;
2517                         case T_WorkTableScan:
2518                                 _outWorkTableScan(str, obj);
2519                                 break;
2520                         case T_Join:
2521                                 _outJoin(str, obj);
2522                                 break;
2523                         case T_NestLoop:
2524                                 _outNestLoop(str, obj);
2525                                 break;
2526                         case T_MergeJoin:
2527                                 _outMergeJoin(str, obj);
2528                                 break;
2529                         case T_HashJoin:
2530                                 _outHashJoin(str, obj);
2531                                 break;
2532                         case T_Agg:
2533                                 _outAgg(str, obj);
2534                                 break;
2535                         case T_WindowAgg:
2536                                 _outWindowAgg(str, obj);
2537                                 break;
2538                         case T_Group:
2539                                 _outGroup(str, obj);
2540                                 break;
2541                         case T_Material:
2542                                 _outMaterial(str, obj);
2543                                 break;
2544                         case T_Sort:
2545                                 _outSort(str, obj);
2546                                 break;
2547                         case T_Unique:
2548                                 _outUnique(str, obj);
2549                                 break;
2550                         case T_Hash:
2551                                 _outHash(str, obj);
2552                                 break;
2553                         case T_SetOp:
2554                                 _outSetOp(str, obj);
2555                                 break;
2556                         case T_LockRows:
2557                                 _outLockRows(str, obj);
2558                                 break;
2559                         case T_Limit:
2560                                 _outLimit(str, obj);
2561                                 break;
2562                         case T_PlanRowMark:
2563                                 _outPlanRowMark(str, obj);
2564                                 break;
2565                         case T_PlanInvalItem:
2566                                 _outPlanInvalItem(str, obj);
2567                                 break;
2568                         case T_Alias:
2569                                 _outAlias(str, obj);
2570                                 break;
2571                         case T_RangeVar:
2572                                 _outRangeVar(str, obj);
2573                                 break;
2574                         case T_IntoClause:
2575                                 _outIntoClause(str, obj);
2576                                 break;
2577                         case T_Var:
2578                                 _outVar(str, obj);
2579                                 break;
2580                         case T_Const:
2581                                 _outConst(str, obj);
2582                                 break;
2583                         case T_Param:
2584                                 _outParam(str, obj);
2585                                 break;
2586                         case T_Aggref:
2587                                 _outAggref(str, obj);
2588                                 break;
2589                         case T_WindowFunc:
2590                                 _outWindowFunc(str, obj);
2591                                 break;
2592                         case T_ArrayRef:
2593                                 _outArrayRef(str, obj);
2594                                 break;
2595                         case T_FuncExpr:
2596                                 _outFuncExpr(str, obj);
2597                                 break;
2598                         case T_NamedArgExpr:
2599                                 _outNamedArgExpr(str, obj);
2600                                 break;
2601                         case T_OpExpr:
2602                                 _outOpExpr(str, obj);
2603                                 break;
2604                         case T_DistinctExpr:
2605                                 _outDistinctExpr(str, obj);
2606                                 break;
2607                         case T_ScalarArrayOpExpr:
2608                                 _outScalarArrayOpExpr(str, obj);
2609                                 break;
2610                         case T_BoolExpr:
2611                                 _outBoolExpr(str, obj);
2612                                 break;
2613                         case T_SubLink:
2614                                 _outSubLink(str, obj);
2615                                 break;
2616                         case T_SubPlan:
2617                                 _outSubPlan(str, obj);
2618                                 break;
2619                         case T_AlternativeSubPlan:
2620                                 _outAlternativeSubPlan(str, obj);
2621                                 break;
2622                         case T_FieldSelect:
2623                                 _outFieldSelect(str, obj);
2624                                 break;
2625                         case T_FieldStore:
2626                                 _outFieldStore(str, obj);
2627                                 break;
2628                         case T_RelabelType:
2629                                 _outRelabelType(str, obj);
2630                                 break;
2631                         case T_CoerceViaIO:
2632                                 _outCoerceViaIO(str, obj);
2633                                 break;
2634                         case T_ArrayCoerceExpr:
2635                                 _outArrayCoerceExpr(str, obj);
2636                                 break;
2637                         case T_ConvertRowtypeExpr:
2638                                 _outConvertRowtypeExpr(str, obj);
2639                                 break;
2640                         case T_CaseExpr:
2641                                 _outCaseExpr(str, obj);
2642                                 break;
2643                         case T_CaseWhen:
2644                                 _outCaseWhen(str, obj);
2645                                 break;
2646                         case T_CaseTestExpr:
2647                                 _outCaseTestExpr(str, obj);
2648                                 break;
2649                         case T_ArrayExpr:
2650                                 _outArrayExpr(str, obj);
2651                                 break;
2652                         case T_RowExpr:
2653                                 _outRowExpr(str, obj);
2654                                 break;
2655                         case T_RowCompareExpr:
2656                                 _outRowCompareExpr(str, obj);
2657                                 break;
2658                         case T_CoalesceExpr:
2659                                 _outCoalesceExpr(str, obj);
2660                                 break;
2661                         case T_MinMaxExpr:
2662                                 _outMinMaxExpr(str, obj);
2663                                 break;
2664                         case T_XmlExpr:
2665                                 _outXmlExpr(str, obj);
2666                                 break;
2667                         case T_NullIfExpr:
2668                                 _outNullIfExpr(str, obj);
2669                                 break;
2670                         case T_NullTest:
2671                                 _outNullTest(str, obj);
2672                                 break;
2673                         case T_BooleanTest:
2674                                 _outBooleanTest(str, obj);
2675                                 break;
2676                         case T_CoerceToDomain:
2677                                 _outCoerceToDomain(str, obj);
2678                                 break;
2679                         case T_CoerceToDomainValue:
2680                                 _outCoerceToDomainValue(str, obj);
2681                                 break;
2682                         case T_SetToDefault:
2683                                 _outSetToDefault(str, obj);
2684                                 break;
2685                         case T_CurrentOfExpr:
2686                                 _outCurrentOfExpr(str, obj);
2687                                 break;
2688                         case T_TargetEntry:
2689                                 _outTargetEntry(str, obj);
2690                                 break;
2691                         case T_RangeTblRef:
2692                                 _outRangeTblRef(str, obj);
2693                                 break;
2694                         case T_JoinExpr:
2695                                 _outJoinExpr(str, obj);
2696                                 break;
2697                         case T_FromExpr:
2698                                 _outFromExpr(str, obj);
2699                                 break;
2700
2701                         case T_Path:
2702                                 _outPath(str, obj);
2703                                 break;
2704                         case T_IndexPath:
2705                                 _outIndexPath(str, obj);
2706                                 break;
2707                         case T_BitmapHeapPath:
2708                                 _outBitmapHeapPath(str, obj);
2709                                 break;
2710                         case T_BitmapAndPath:
2711                                 _outBitmapAndPath(str, obj);
2712                                 break;
2713                         case T_BitmapOrPath:
2714                                 _outBitmapOrPath(str, obj);
2715                                 break;
2716                         case T_TidPath:
2717                                 _outTidPath(str, obj);
2718                                 break;
2719                         case T_AppendPath:
2720                                 _outAppendPath(str, obj);
2721                                 break;
2722                         case T_ResultPath:
2723                                 _outResultPath(str, obj);
2724                                 break;
2725                         case T_MaterialPath:
2726                                 _outMaterialPath(str, obj);
2727                                 break;
2728                         case T_UniquePath:
2729                                 _outUniquePath(str, obj);
2730                                 break;
2731                         case T_NoOpPath:
2732                                 _outNoOpPath(str, obj);
2733                                 break;
2734                         case T_NestPath:
2735                                 _outNestPath(str, obj);
2736                                 break;
2737                         case T_MergePath:
2738                                 _outMergePath(str, obj);
2739                                 break;
2740                         case T_HashPath:
2741                                 _outHashPath(str, obj);
2742                                 break;
2743                         case T_PlannerGlobal:
2744                                 _outPlannerGlobal(str, obj);
2745                                 break;
2746                         case T_PlannerInfo:
2747                                 _outPlannerInfo(str, obj);
2748                                 break;
2749                         case T_RelOptInfo:
2750                                 _outRelOptInfo(str, obj);
2751                                 break;
2752                         case T_IndexOptInfo:
2753                                 _outIndexOptInfo(str, obj);
2754                                 break;
2755                         case T_EquivalenceClass:
2756                                 _outEquivalenceClass(str, obj);
2757                                 break;
2758                         case T_EquivalenceMember:
2759                                 _outEquivalenceMember(str, obj);
2760                                 break;
2761                         case T_PathKey:
2762                                 _outPathKey(str, obj);
2763                                 break;
2764                         case T_RestrictInfo:
2765                                 _outRestrictInfo(str, obj);
2766                                 break;
2767                         case T_InnerIndexscanInfo:
2768                                 _outInnerIndexscanInfo(str, obj);
2769                                 break;
2770                         case T_PlaceHolderVar:
2771                                 _outPlaceHolderVar(str, obj);
2772                                 break;
2773                         case T_SpecialJoinInfo:
2774                                 _outSpecialJoinInfo(str, obj);
2775                                 break;
2776                         case T_AppendRelInfo:
2777                                 _outAppendRelInfo(str, obj);
2778                                 break;
2779                         case T_PlaceHolderInfo:
2780                                 _outPlaceHolderInfo(str, obj);
2781                                 break;
2782                         case T_PlannerParamItem:
2783                                 _outPlannerParamItem(str, obj);
2784                                 break;
2785
2786                         case T_CreateStmt:
2787                                 _outCreateStmt(str, obj);
2788                                 break;
2789                         case T_IndexStmt:
2790                                 _outIndexStmt(str, obj);
2791                                 break;
2792                         case T_NotifyStmt:
2793                                 _outNotifyStmt(str, obj);
2794                                 break;
2795                         case T_DeclareCursorStmt:
2796                                 _outDeclareCursorStmt(str, obj);
2797                                 break;
2798                         case T_SelectStmt:
2799                                 _outSelectStmt(str, obj);
2800                                 break;
2801                         case T_ColumnDef:
2802                                 _outColumnDef(str, obj);
2803                                 break;
2804                         case T_TypeName:
2805                                 _outTypeName(str, obj);
2806                                 break;
2807                         case T_TypeCast:
2808                                 _outTypeCast(str, obj);
2809                                 break;
2810                         case T_IndexElem:
2811                                 _outIndexElem(str, obj);
2812                                 break;
2813                         case T_Query:
2814                                 _outQuery(str, obj);
2815                                 break;
2816                         case T_SortGroupClause:
2817                                 _outSortGroupClause(str, obj);
2818                                 break;
2819                         case T_WindowClause:
2820                                 _outWindowClause(str, obj);
2821                                 break;
2822                         case T_RowMarkClause:
2823                                 _outRowMarkClause(str, obj);
2824                                 break;
2825                         case T_WithClause:
2826                                 _outWithClause(str, obj);
2827                                 break;
2828                         case T_CommonTableExpr:
2829                                 _outCommonTableExpr(str, obj);
2830                                 break;
2831                         case T_SetOperationStmt:
2832                                 _outSetOperationStmt(str, obj);
2833                                 break;
2834                         case T_RangeTblEntry:
2835                                 _outRangeTblEntry(str, obj);
2836                                 break;
2837                         case T_A_Expr:
2838                                 _outAExpr(str, obj);
2839                                 break;
2840                         case T_ColumnRef:
2841                                 _outColumnRef(str, obj);
2842                                 break;
2843                         case T_ParamRef:
2844                                 _outParamRef(str, obj);
2845                                 break;
2846                         case T_A_Const:
2847                                 _outAConst(str, obj);
2848                                 break;
2849                         case T_A_Star:
2850                                 _outA_Star(str, obj);
2851                                 break;
2852                         case T_A_Indices:
2853                                 _outA_Indices(str, obj);
2854                                 break;
2855                         case T_A_Indirection:
2856                                 _outA_Indirection(str, obj);
2857                                 break;
2858                         case T_A_ArrayExpr:
2859                                 _outA_ArrayExpr(str, obj);
2860                                 break;
2861                         case T_ResTarget:
2862                                 _outResTarget(str, obj);
2863                                 break;
2864                         case T_SortBy:
2865                                 _outSortBy(str, obj);
2866                                 break;
2867                         case T_WindowDef:
2868                                 _outWindowDef(str, obj);
2869                                 break;
2870                         case T_RangeSubselect:
2871                                 _outRangeSubselect(str, obj);
2872                                 break;
2873                         case T_RangeFunction:
2874                                 _outRangeFunction(str, obj);
2875                                 break;
2876                         case T_Constraint:
2877                                 _outConstraint(str, obj);
2878                                 break;
2879                         case T_FuncCall:
2880                                 _outFuncCall(str, obj);
2881                                 break;
2882                         case T_DefElem:
2883                                 _outDefElem(str, obj);
2884                                 break;
2885                         case T_LockingClause:
2886                                 _outLockingClause(str, obj);
2887                                 break;
2888                         case T_XmlSerialize:
2889                                 _outXmlSerialize(str, obj);
2890                                 break;
2891
2892                         default:
2893
2894                                 /*
2895                                  * This should be an ERROR, but it's too useful to be able to
2896                                  * dump structures that _outNode only understands part of.
2897                                  */
2898                                 elog(WARNING, "could not dump unrecognized node type: %d",
2899                                          (int) nodeTag(obj));
2900                                 break;
2901                 }
2902                 appendStringInfoChar(str, '}');
2903         }
2904 }
2905
2906 /*
2907  * nodeToString -
2908  *         returns the ascii representation of the Node as a palloc'd string
2909  */
2910 char *
2911 nodeToString(void *obj)
2912 {
2913         StringInfoData str;
2914
2915         /* see stringinfo.h for an explanation of this maneuver */
2916         initStringInfo(&str);
2917         _outNode(&str, obj);
2918         return str.data;
2919 }