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