]> granicus.if.org Git - postgresql/blob - src/backend/nodes/outfuncs.c
Implement SKIP LOCKED for row-level locks
[postgresql] / src / backend / nodes / outfuncs.c
1 /*-------------------------------------------------------------------------
2  *
3  * outfuncs.c
4  *        Output functions for Postgres tree nodes.
5  *
6  * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  *        src/backend/nodes/outfuncs.c
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, const 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, const char *s)
111 {
112         if (s == NULL || *s == '\0')
113         {
114                 appendStringInfoString(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, const List *node)
143 {
144         const 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, const 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                 appendStringInfoChar(str, ']');
218         }
219         else
220         {
221                 s = (char *) DatumGetPointer(value);
222                 if (!PointerIsValid(s))
223                         appendStringInfoString(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                         appendStringInfoChar(str, ']');
230                 }
231         }
232 }
233
234
235 /*
236  *      Stuff from plannodes.h
237  */
238
239 static void
240 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
241 {
242         WRITE_NODE_TYPE("PLANNEDSTMT");
243
244         WRITE_ENUM_FIELD(commandType, CmdType);
245         WRITE_UINT_FIELD(queryId);
246         WRITE_BOOL_FIELD(hasReturning);
247         WRITE_BOOL_FIELD(hasModifyingCTE);
248         WRITE_BOOL_FIELD(canSetTag);
249         WRITE_BOOL_FIELD(transientPlan);
250         WRITE_NODE_FIELD(planTree);
251         WRITE_NODE_FIELD(rtable);
252         WRITE_NODE_FIELD(resultRelations);
253         WRITE_NODE_FIELD(utilityStmt);
254         WRITE_NODE_FIELD(subplans);
255         WRITE_BITMAPSET_FIELD(rewindPlanIDs);
256         WRITE_NODE_FIELD(rowMarks);
257         WRITE_NODE_FIELD(relationOids);
258         WRITE_NODE_FIELD(invalItems);
259         WRITE_INT_FIELD(nParamExec);
260 }
261
262 /*
263  * print the basic stuff of all nodes that inherit from Plan
264  */
265 static void
266 _outPlanInfo(StringInfo str, const Plan *node)
267 {
268         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
269         WRITE_FLOAT_FIELD(total_cost, "%.2f");
270         WRITE_FLOAT_FIELD(plan_rows, "%.0f");
271         WRITE_INT_FIELD(plan_width);
272         WRITE_NODE_FIELD(targetlist);
273         WRITE_NODE_FIELD(qual);
274         WRITE_NODE_FIELD(lefttree);
275         WRITE_NODE_FIELD(righttree);
276         WRITE_NODE_FIELD(initPlan);
277         WRITE_BITMAPSET_FIELD(extParam);
278         WRITE_BITMAPSET_FIELD(allParam);
279 }
280
281 /*
282  * print the basic stuff of all nodes that inherit from Scan
283  */
284 static void
285 _outScanInfo(StringInfo str, const Scan *node)
286 {
287         _outPlanInfo(str, (const Plan *) node);
288
289         WRITE_UINT_FIELD(scanrelid);
290 }
291
292 /*
293  * print the basic stuff of all nodes that inherit from Join
294  */
295 static void
296 _outJoinPlanInfo(StringInfo str, const Join *node)
297 {
298         _outPlanInfo(str, (const Plan *) node);
299
300         WRITE_ENUM_FIELD(jointype, JoinType);
301         WRITE_NODE_FIELD(joinqual);
302 }
303
304
305 static void
306 _outPlan(StringInfo str, const Plan *node)
307 {
308         WRITE_NODE_TYPE("PLAN");
309
310         _outPlanInfo(str, (const Plan *) node);
311 }
312
313 static void
314 _outResult(StringInfo str, const Result *node)
315 {
316         WRITE_NODE_TYPE("RESULT");
317
318         _outPlanInfo(str, (const Plan *) node);
319
320         WRITE_NODE_FIELD(resconstantqual);
321 }
322
323 static void
324 _outModifyTable(StringInfo str, const ModifyTable *node)
325 {
326         WRITE_NODE_TYPE("MODIFYTABLE");
327
328         _outPlanInfo(str, (const Plan *) node);
329
330         WRITE_ENUM_FIELD(operation, CmdType);
331         WRITE_BOOL_FIELD(canSetTag);
332         WRITE_NODE_FIELD(resultRelations);
333         WRITE_INT_FIELD(resultRelIndex);
334         WRITE_NODE_FIELD(plans);
335         WRITE_NODE_FIELD(withCheckOptionLists);
336         WRITE_NODE_FIELD(returningLists);
337         WRITE_NODE_FIELD(fdwPrivLists);
338         WRITE_NODE_FIELD(rowMarks);
339         WRITE_INT_FIELD(epqParam);
340 }
341
342 static void
343 _outAppend(StringInfo str, const Append *node)
344 {
345         WRITE_NODE_TYPE("APPEND");
346
347         _outPlanInfo(str, (const Plan *) node);
348
349         WRITE_NODE_FIELD(appendplans);
350 }
351
352 static void
353 _outMergeAppend(StringInfo str, const MergeAppend *node)
354 {
355         int                     i;
356
357         WRITE_NODE_TYPE("MERGEAPPEND");
358
359         _outPlanInfo(str, (const Plan *) node);
360
361         WRITE_NODE_FIELD(mergeplans);
362
363         WRITE_INT_FIELD(numCols);
364
365         appendStringInfoString(str, " :sortColIdx");
366         for (i = 0; i < node->numCols; i++)
367                 appendStringInfo(str, " %d", node->sortColIdx[i]);
368
369         appendStringInfoString(str, " :sortOperators");
370         for (i = 0; i < node->numCols; i++)
371                 appendStringInfo(str, " %u", node->sortOperators[i]);
372
373         appendStringInfoString(str, " :collations");
374         for (i = 0; i < node->numCols; i++)
375                 appendStringInfo(str, " %u", node->collations[i]);
376
377         appendStringInfoString(str, " :nullsFirst");
378         for (i = 0; i < node->numCols; i++)
379                 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
380 }
381
382 static void
383 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
384 {
385         int                     i;
386
387         WRITE_NODE_TYPE("RECURSIVEUNION");
388
389         _outPlanInfo(str, (const Plan *) node);
390
391         WRITE_INT_FIELD(wtParam);
392         WRITE_INT_FIELD(numCols);
393
394         appendStringInfoString(str, " :dupColIdx");
395         for (i = 0; i < node->numCols; i++)
396                 appendStringInfo(str, " %d", node->dupColIdx[i]);
397
398         appendStringInfoString(str, " :dupOperators");
399         for (i = 0; i < node->numCols; i++)
400                 appendStringInfo(str, " %u", node->dupOperators[i]);
401
402         WRITE_LONG_FIELD(numGroups);
403 }
404
405 static void
406 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
407 {
408         WRITE_NODE_TYPE("BITMAPAND");
409
410         _outPlanInfo(str, (const Plan *) node);
411
412         WRITE_NODE_FIELD(bitmapplans);
413 }
414
415 static void
416 _outBitmapOr(StringInfo str, const BitmapOr *node)
417 {
418         WRITE_NODE_TYPE("BITMAPOR");
419
420         _outPlanInfo(str, (const Plan *) node);
421
422         WRITE_NODE_FIELD(bitmapplans);
423 }
424
425 static void
426 _outScan(StringInfo str, const Scan *node)
427 {
428         WRITE_NODE_TYPE("SCAN");
429
430         _outScanInfo(str, node);
431 }
432
433 static void
434 _outSeqScan(StringInfo str, const SeqScan *node)
435 {
436         WRITE_NODE_TYPE("SEQSCAN");
437
438         _outScanInfo(str, (const Scan *) node);
439 }
440
441 static void
442 _outIndexScan(StringInfo str, const IndexScan *node)
443 {
444         WRITE_NODE_TYPE("INDEXSCAN");
445
446         _outScanInfo(str, (const Scan *) node);
447
448         WRITE_OID_FIELD(indexid);
449         WRITE_NODE_FIELD(indexqual);
450         WRITE_NODE_FIELD(indexqualorig);
451         WRITE_NODE_FIELD(indexorderby);
452         WRITE_NODE_FIELD(indexorderbyorig);
453         WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
454 }
455
456 static void
457 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
458 {
459         WRITE_NODE_TYPE("INDEXONLYSCAN");
460
461         _outScanInfo(str, (const Scan *) node);
462
463         WRITE_OID_FIELD(indexid);
464         WRITE_NODE_FIELD(indexqual);
465         WRITE_NODE_FIELD(indexorderby);
466         WRITE_NODE_FIELD(indextlist);
467         WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
468 }
469
470 static void
471 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
472 {
473         WRITE_NODE_TYPE("BITMAPINDEXSCAN");
474
475         _outScanInfo(str, (const Scan *) node);
476
477         WRITE_OID_FIELD(indexid);
478         WRITE_NODE_FIELD(indexqual);
479         WRITE_NODE_FIELD(indexqualorig);
480 }
481
482 static void
483 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
484 {
485         WRITE_NODE_TYPE("BITMAPHEAPSCAN");
486
487         _outScanInfo(str, (const Scan *) node);
488
489         WRITE_NODE_FIELD(bitmapqualorig);
490 }
491
492 static void
493 _outTidScan(StringInfo str, const TidScan *node)
494 {
495         WRITE_NODE_TYPE("TIDSCAN");
496
497         _outScanInfo(str, (const Scan *) node);
498
499         WRITE_NODE_FIELD(tidquals);
500 }
501
502 static void
503 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
504 {
505         WRITE_NODE_TYPE("SUBQUERYSCAN");
506
507         _outScanInfo(str, (const Scan *) node);
508
509         WRITE_NODE_FIELD(subplan);
510 }
511
512 static void
513 _outFunctionScan(StringInfo str, const FunctionScan *node)
514 {
515         WRITE_NODE_TYPE("FUNCTIONSCAN");
516
517         _outScanInfo(str, (const Scan *) node);
518
519         WRITE_NODE_FIELD(functions);
520         WRITE_BOOL_FIELD(funcordinality);
521 }
522
523 static void
524 _outValuesScan(StringInfo str, const ValuesScan *node)
525 {
526         WRITE_NODE_TYPE("VALUESSCAN");
527
528         _outScanInfo(str, (const Scan *) node);
529
530         WRITE_NODE_FIELD(values_lists);
531 }
532
533 static void
534 _outCteScan(StringInfo str, const CteScan *node)
535 {
536         WRITE_NODE_TYPE("CTESCAN");
537
538         _outScanInfo(str, (const Scan *) node);
539
540         WRITE_INT_FIELD(ctePlanId);
541         WRITE_INT_FIELD(cteParam);
542 }
543
544 static void
545 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
546 {
547         WRITE_NODE_TYPE("WORKTABLESCAN");
548
549         _outScanInfo(str, (const Scan *) node);
550
551         WRITE_INT_FIELD(wtParam);
552 }
553
554 static void
555 _outForeignScan(StringInfo str, const ForeignScan *node)
556 {
557         WRITE_NODE_TYPE("FOREIGNSCAN");
558
559         _outScanInfo(str, (const Scan *) node);
560
561         WRITE_NODE_FIELD(fdw_exprs);
562         WRITE_NODE_FIELD(fdw_private);
563         WRITE_BOOL_FIELD(fsSystemCol);
564 }
565
566 static void
567 _outJoin(StringInfo str, const Join *node)
568 {
569         WRITE_NODE_TYPE("JOIN");
570
571         _outJoinPlanInfo(str, (const Join *) node);
572 }
573
574 static void
575 _outNestLoop(StringInfo str, const NestLoop *node)
576 {
577         WRITE_NODE_TYPE("NESTLOOP");
578
579         _outJoinPlanInfo(str, (const Join *) node);
580
581         WRITE_NODE_FIELD(nestParams);
582 }
583
584 static void
585 _outMergeJoin(StringInfo str, const MergeJoin *node)
586 {
587         int                     numCols;
588         int                     i;
589
590         WRITE_NODE_TYPE("MERGEJOIN");
591
592         _outJoinPlanInfo(str, (const Join *) node);
593
594         WRITE_NODE_FIELD(mergeclauses);
595
596         numCols = list_length(node->mergeclauses);
597
598         appendStringInfoString(str, " :mergeFamilies");
599         for (i = 0; i < numCols; i++)
600                 appendStringInfo(str, " %u", node->mergeFamilies[i]);
601
602         appendStringInfoString(str, " :mergeCollations");
603         for (i = 0; i < numCols; i++)
604                 appendStringInfo(str, " %u", node->mergeCollations[i]);
605
606         appendStringInfoString(str, " :mergeStrategies");
607         for (i = 0; i < numCols; i++)
608                 appendStringInfo(str, " %d", node->mergeStrategies[i]);
609
610         appendStringInfoString(str, " :mergeNullsFirst");
611         for (i = 0; i < numCols; i++)
612                 appendStringInfo(str, " %d", (int) node->mergeNullsFirst[i]);
613 }
614
615 static void
616 _outHashJoin(StringInfo str, const HashJoin *node)
617 {
618         WRITE_NODE_TYPE("HASHJOIN");
619
620         _outJoinPlanInfo(str, (const Join *) node);
621
622         WRITE_NODE_FIELD(hashclauses);
623 }
624
625 static void
626 _outAgg(StringInfo str, const Agg *node)
627 {
628         int                     i;
629
630         WRITE_NODE_TYPE("AGG");
631
632         _outPlanInfo(str, (const Plan *) node);
633
634         WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
635         WRITE_INT_FIELD(numCols);
636
637         appendStringInfoString(str, " :grpColIdx");
638         for (i = 0; i < node->numCols; i++)
639                 appendStringInfo(str, " %d", node->grpColIdx[i]);
640
641         appendStringInfoString(str, " :grpOperators");
642         for (i = 0; i < node->numCols; i++)
643                 appendStringInfo(str, " %u", node->grpOperators[i]);
644
645         WRITE_LONG_FIELD(numGroups);
646 }
647
648 static void
649 _outWindowAgg(StringInfo str, const WindowAgg *node)
650 {
651         int                     i;
652
653         WRITE_NODE_TYPE("WINDOWAGG");
654
655         _outPlanInfo(str, (const Plan *) node);
656
657         WRITE_UINT_FIELD(winref);
658         WRITE_INT_FIELD(partNumCols);
659
660         appendStringInfoString(str, " :partColIdx");
661         for (i = 0; i < node->partNumCols; i++)
662                 appendStringInfo(str, " %d", node->partColIdx[i]);
663
664         appendStringInfoString(str, " :partOperations");
665         for (i = 0; i < node->partNumCols; i++)
666                 appendStringInfo(str, " %u", node->partOperators[i]);
667
668         WRITE_INT_FIELD(ordNumCols);
669
670         appendStringInfoString(str, " :ordColIdx");
671         for (i = 0; i < node->ordNumCols; i++)
672                 appendStringInfo(str, " %d", node->ordColIdx[i]);
673
674         appendStringInfoString(str, " :ordOperations");
675         for (i = 0; i < node->ordNumCols; i++)
676                 appendStringInfo(str, " %u", node->ordOperators[i]);
677
678         WRITE_INT_FIELD(frameOptions);
679         WRITE_NODE_FIELD(startOffset);
680         WRITE_NODE_FIELD(endOffset);
681 }
682
683 static void
684 _outGroup(StringInfo str, const Group *node)
685 {
686         int                     i;
687
688         WRITE_NODE_TYPE("GROUP");
689
690         _outPlanInfo(str, (const Plan *) node);
691
692         WRITE_INT_FIELD(numCols);
693
694         appendStringInfoString(str, " :grpColIdx");
695         for (i = 0; i < node->numCols; i++)
696                 appendStringInfo(str, " %d", node->grpColIdx[i]);
697
698         appendStringInfoString(str, " :grpOperators");
699         for (i = 0; i < node->numCols; i++)
700                 appendStringInfo(str, " %u", node->grpOperators[i]);
701 }
702
703 static void
704 _outMaterial(StringInfo str, const Material *node)
705 {
706         WRITE_NODE_TYPE("MATERIAL");
707
708         _outPlanInfo(str, (const Plan *) node);
709 }
710
711 static void
712 _outSort(StringInfo str, const Sort *node)
713 {
714         int                     i;
715
716         WRITE_NODE_TYPE("SORT");
717
718         _outPlanInfo(str, (const Plan *) node);
719
720         WRITE_INT_FIELD(numCols);
721
722         appendStringInfoString(str, " :sortColIdx");
723         for (i = 0; i < node->numCols; i++)
724                 appendStringInfo(str, " %d", node->sortColIdx[i]);
725
726         appendStringInfoString(str, " :sortOperators");
727         for (i = 0; i < node->numCols; i++)
728                 appendStringInfo(str, " %u", node->sortOperators[i]);
729
730         appendStringInfoString(str, " :collations");
731         for (i = 0; i < node->numCols; i++)
732                 appendStringInfo(str, " %u", node->collations[i]);
733
734         appendStringInfoString(str, " :nullsFirst");
735         for (i = 0; i < node->numCols; i++)
736                 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
737 }
738
739 static void
740 _outUnique(StringInfo str, const Unique *node)
741 {
742         int                     i;
743
744         WRITE_NODE_TYPE("UNIQUE");
745
746         _outPlanInfo(str, (const Plan *) node);
747
748         WRITE_INT_FIELD(numCols);
749
750         appendStringInfoString(str, " :uniqColIdx");
751         for (i = 0; i < node->numCols; i++)
752                 appendStringInfo(str, " %d", node->uniqColIdx[i]);
753
754         appendStringInfoString(str, " :uniqOperators");
755         for (i = 0; i < node->numCols; i++)
756                 appendStringInfo(str, " %u", node->uniqOperators[i]);
757 }
758
759 static void
760 _outHash(StringInfo str, const Hash *node)
761 {
762         WRITE_NODE_TYPE("HASH");
763
764         _outPlanInfo(str, (const Plan *) node);
765
766         WRITE_OID_FIELD(skewTable);
767         WRITE_INT_FIELD(skewColumn);
768         WRITE_BOOL_FIELD(skewInherit);
769         WRITE_OID_FIELD(skewColType);
770         WRITE_INT_FIELD(skewColTypmod);
771 }
772
773 static void
774 _outSetOp(StringInfo str, const SetOp *node)
775 {
776         int                     i;
777
778         WRITE_NODE_TYPE("SETOP");
779
780         _outPlanInfo(str, (const Plan *) node);
781
782         WRITE_ENUM_FIELD(cmd, SetOpCmd);
783         WRITE_ENUM_FIELD(strategy, SetOpStrategy);
784         WRITE_INT_FIELD(numCols);
785
786         appendStringInfoString(str, " :dupColIdx");
787         for (i = 0; i < node->numCols; i++)
788                 appendStringInfo(str, " %d", node->dupColIdx[i]);
789
790         appendStringInfoString(str, " :dupOperators");
791         for (i = 0; i < node->numCols; i++)
792                 appendStringInfo(str, " %u", node->dupOperators[i]);
793
794         WRITE_INT_FIELD(flagColIdx);
795         WRITE_INT_FIELD(firstFlag);
796         WRITE_LONG_FIELD(numGroups);
797 }
798
799 static void
800 _outLockRows(StringInfo str, const LockRows *node)
801 {
802         WRITE_NODE_TYPE("LOCKROWS");
803
804         _outPlanInfo(str, (const Plan *) node);
805
806         WRITE_NODE_FIELD(rowMarks);
807         WRITE_INT_FIELD(epqParam);
808 }
809
810 static void
811 _outLimit(StringInfo str, const Limit *node)
812 {
813         WRITE_NODE_TYPE("LIMIT");
814
815         _outPlanInfo(str, (const Plan *) node);
816
817         WRITE_NODE_FIELD(limitOffset);
818         WRITE_NODE_FIELD(limitCount);
819 }
820
821 static void
822 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
823 {
824         WRITE_NODE_TYPE("NESTLOOPPARAM");
825
826         WRITE_INT_FIELD(paramno);
827         WRITE_NODE_FIELD(paramval);
828 }
829
830 static void
831 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
832 {
833         WRITE_NODE_TYPE("PLANROWMARK");
834
835         WRITE_UINT_FIELD(rti);
836         WRITE_UINT_FIELD(prti);
837         WRITE_UINT_FIELD(rowmarkId);
838         WRITE_ENUM_FIELD(markType, RowMarkType);
839         WRITE_BOOL_FIELD(waitPolicy);
840         WRITE_BOOL_FIELD(isParent);
841 }
842
843 static void
844 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
845 {
846         WRITE_NODE_TYPE("PLANINVALITEM");
847
848         WRITE_INT_FIELD(cacheId);
849         WRITE_UINT_FIELD(hashValue);
850 }
851
852 /*****************************************************************************
853  *
854  *      Stuff from primnodes.h.
855  *
856  *****************************************************************************/
857
858 static void
859 _outAlias(StringInfo str, const Alias *node)
860 {
861         WRITE_NODE_TYPE("ALIAS");
862
863         WRITE_STRING_FIELD(aliasname);
864         WRITE_NODE_FIELD(colnames);
865 }
866
867 static void
868 _outRangeVar(StringInfo str, const RangeVar *node)
869 {
870         WRITE_NODE_TYPE("RANGEVAR");
871
872         /*
873          * we deliberately ignore catalogname here, since it is presently not
874          * semantically meaningful
875          */
876         WRITE_STRING_FIELD(schemaname);
877         WRITE_STRING_FIELD(relname);
878         WRITE_ENUM_FIELD(inhOpt, InhOption);
879         WRITE_CHAR_FIELD(relpersistence);
880         WRITE_NODE_FIELD(alias);
881         WRITE_LOCATION_FIELD(location);
882 }
883
884 static void
885 _outIntoClause(StringInfo str, const IntoClause *node)
886 {
887         WRITE_NODE_TYPE("INTOCLAUSE");
888
889         WRITE_NODE_FIELD(rel);
890         WRITE_NODE_FIELD(colNames);
891         WRITE_NODE_FIELD(options);
892         WRITE_ENUM_FIELD(onCommit, OnCommitAction);
893         WRITE_STRING_FIELD(tableSpaceName);
894         WRITE_NODE_FIELD(viewQuery);
895         WRITE_BOOL_FIELD(skipData);
896 }
897
898 static void
899 _outVar(StringInfo str, const Var *node)
900 {
901         WRITE_NODE_TYPE("VAR");
902
903         WRITE_UINT_FIELD(varno);
904         WRITE_INT_FIELD(varattno);
905         WRITE_OID_FIELD(vartype);
906         WRITE_INT_FIELD(vartypmod);
907         WRITE_OID_FIELD(varcollid);
908         WRITE_UINT_FIELD(varlevelsup);
909         WRITE_UINT_FIELD(varnoold);
910         WRITE_INT_FIELD(varoattno);
911         WRITE_LOCATION_FIELD(location);
912 }
913
914 static void
915 _outConst(StringInfo str, const Const *node)
916 {
917         WRITE_NODE_TYPE("CONST");
918
919         WRITE_OID_FIELD(consttype);
920         WRITE_INT_FIELD(consttypmod);
921         WRITE_OID_FIELD(constcollid);
922         WRITE_INT_FIELD(constlen);
923         WRITE_BOOL_FIELD(constbyval);
924         WRITE_BOOL_FIELD(constisnull);
925         WRITE_LOCATION_FIELD(location);
926
927         appendStringInfoString(str, " :constvalue ");
928         if (node->constisnull)
929                 appendStringInfoString(str, "<>");
930         else
931                 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
932 }
933
934 static void
935 _outParam(StringInfo str, const Param *node)
936 {
937         WRITE_NODE_TYPE("PARAM");
938
939         WRITE_ENUM_FIELD(paramkind, ParamKind);
940         WRITE_INT_FIELD(paramid);
941         WRITE_OID_FIELD(paramtype);
942         WRITE_INT_FIELD(paramtypmod);
943         WRITE_OID_FIELD(paramcollid);
944         WRITE_LOCATION_FIELD(location);
945 }
946
947 static void
948 _outAggref(StringInfo str, const Aggref *node)
949 {
950         WRITE_NODE_TYPE("AGGREF");
951
952         WRITE_OID_FIELD(aggfnoid);
953         WRITE_OID_FIELD(aggtype);
954         WRITE_OID_FIELD(aggcollid);
955         WRITE_OID_FIELD(inputcollid);
956         WRITE_NODE_FIELD(aggdirectargs);
957         WRITE_NODE_FIELD(args);
958         WRITE_NODE_FIELD(aggorder);
959         WRITE_NODE_FIELD(aggdistinct);
960         WRITE_NODE_FIELD(aggfilter);
961         WRITE_BOOL_FIELD(aggstar);
962         WRITE_BOOL_FIELD(aggvariadic);
963         WRITE_CHAR_FIELD(aggkind);
964         WRITE_UINT_FIELD(agglevelsup);
965         WRITE_LOCATION_FIELD(location);
966 }
967
968 static void
969 _outWindowFunc(StringInfo str, const WindowFunc *node)
970 {
971         WRITE_NODE_TYPE("WINDOWFUNC");
972
973         WRITE_OID_FIELD(winfnoid);
974         WRITE_OID_FIELD(wintype);
975         WRITE_OID_FIELD(wincollid);
976         WRITE_OID_FIELD(inputcollid);
977         WRITE_NODE_FIELD(args);
978         WRITE_NODE_FIELD(aggfilter);
979         WRITE_UINT_FIELD(winref);
980         WRITE_BOOL_FIELD(winstar);
981         WRITE_BOOL_FIELD(winagg);
982         WRITE_LOCATION_FIELD(location);
983 }
984
985 static void
986 _outArrayRef(StringInfo str, const ArrayRef *node)
987 {
988         WRITE_NODE_TYPE("ARRAYREF");
989
990         WRITE_OID_FIELD(refarraytype);
991         WRITE_OID_FIELD(refelemtype);
992         WRITE_INT_FIELD(reftypmod);
993         WRITE_OID_FIELD(refcollid);
994         WRITE_NODE_FIELD(refupperindexpr);
995         WRITE_NODE_FIELD(reflowerindexpr);
996         WRITE_NODE_FIELD(refexpr);
997         WRITE_NODE_FIELD(refassgnexpr);
998 }
999
1000 static void
1001 _outFuncExpr(StringInfo str, const FuncExpr *node)
1002 {
1003         WRITE_NODE_TYPE("FUNCEXPR");
1004
1005         WRITE_OID_FIELD(funcid);
1006         WRITE_OID_FIELD(funcresulttype);
1007         WRITE_BOOL_FIELD(funcretset);
1008         WRITE_BOOL_FIELD(funcvariadic);
1009         WRITE_ENUM_FIELD(funcformat, CoercionForm);
1010         WRITE_OID_FIELD(funccollid);
1011         WRITE_OID_FIELD(inputcollid);
1012         WRITE_NODE_FIELD(args);
1013         WRITE_LOCATION_FIELD(location);
1014 }
1015
1016 static void
1017 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1018 {
1019         WRITE_NODE_TYPE("NAMEDARGEXPR");
1020
1021         WRITE_NODE_FIELD(arg);
1022         WRITE_STRING_FIELD(name);
1023         WRITE_INT_FIELD(argnumber);
1024         WRITE_LOCATION_FIELD(location);
1025 }
1026
1027 static void
1028 _outOpExpr(StringInfo str, const OpExpr *node)
1029 {
1030         WRITE_NODE_TYPE("OPEXPR");
1031
1032         WRITE_OID_FIELD(opno);
1033         WRITE_OID_FIELD(opfuncid);
1034         WRITE_OID_FIELD(opresulttype);
1035         WRITE_BOOL_FIELD(opretset);
1036         WRITE_OID_FIELD(opcollid);
1037         WRITE_OID_FIELD(inputcollid);
1038         WRITE_NODE_FIELD(args);
1039         WRITE_LOCATION_FIELD(location);
1040 }
1041
1042 static void
1043 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1044 {
1045         WRITE_NODE_TYPE("DISTINCTEXPR");
1046
1047         WRITE_OID_FIELD(opno);
1048         WRITE_OID_FIELD(opfuncid);
1049         WRITE_OID_FIELD(opresulttype);
1050         WRITE_BOOL_FIELD(opretset);
1051         WRITE_OID_FIELD(opcollid);
1052         WRITE_OID_FIELD(inputcollid);
1053         WRITE_NODE_FIELD(args);
1054         WRITE_LOCATION_FIELD(location);
1055 }
1056
1057 static void
1058 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1059 {
1060         WRITE_NODE_TYPE("NULLIFEXPR");
1061
1062         WRITE_OID_FIELD(opno);
1063         WRITE_OID_FIELD(opfuncid);
1064         WRITE_OID_FIELD(opresulttype);
1065         WRITE_BOOL_FIELD(opretset);
1066         WRITE_OID_FIELD(opcollid);
1067         WRITE_OID_FIELD(inputcollid);
1068         WRITE_NODE_FIELD(args);
1069         WRITE_LOCATION_FIELD(location);
1070 }
1071
1072 static void
1073 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1074 {
1075         WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1076
1077         WRITE_OID_FIELD(opno);
1078         WRITE_OID_FIELD(opfuncid);
1079         WRITE_BOOL_FIELD(useOr);
1080         WRITE_OID_FIELD(inputcollid);
1081         WRITE_NODE_FIELD(args);
1082         WRITE_LOCATION_FIELD(location);
1083 }
1084
1085 static void
1086 _outBoolExpr(StringInfo str, const BoolExpr *node)
1087 {
1088         char       *opstr = NULL;
1089
1090         WRITE_NODE_TYPE("BOOLEXPR");
1091
1092         /* do-it-yourself enum representation */
1093         switch (node->boolop)
1094         {
1095                 case AND_EXPR:
1096                         opstr = "and";
1097                         break;
1098                 case OR_EXPR:
1099                         opstr = "or";
1100                         break;
1101                 case NOT_EXPR:
1102                         opstr = "not";
1103                         break;
1104         }
1105         appendStringInfoString(str, " :boolop ");
1106         _outToken(str, opstr);
1107
1108         WRITE_NODE_FIELD(args);
1109         WRITE_LOCATION_FIELD(location);
1110 }
1111
1112 static void
1113 _outSubLink(StringInfo str, const SubLink *node)
1114 {
1115         WRITE_NODE_TYPE("SUBLINK");
1116
1117         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1118         WRITE_INT_FIELD(subLinkId);
1119         WRITE_NODE_FIELD(testexpr);
1120         WRITE_NODE_FIELD(operName);
1121         WRITE_NODE_FIELD(subselect);
1122         WRITE_LOCATION_FIELD(location);
1123 }
1124
1125 static void
1126 _outSubPlan(StringInfo str, const SubPlan *node)
1127 {
1128         WRITE_NODE_TYPE("SUBPLAN");
1129
1130         WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1131         WRITE_NODE_FIELD(testexpr);
1132         WRITE_NODE_FIELD(paramIds);
1133         WRITE_INT_FIELD(plan_id);
1134         WRITE_STRING_FIELD(plan_name);
1135         WRITE_OID_FIELD(firstColType);
1136         WRITE_INT_FIELD(firstColTypmod);
1137         WRITE_OID_FIELD(firstColCollation);
1138         WRITE_BOOL_FIELD(useHashTable);
1139         WRITE_BOOL_FIELD(unknownEqFalse);
1140         WRITE_NODE_FIELD(setParam);
1141         WRITE_NODE_FIELD(parParam);
1142         WRITE_NODE_FIELD(args);
1143         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1144         WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1145 }
1146
1147 static void
1148 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1149 {
1150         WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1151
1152         WRITE_NODE_FIELD(subplans);
1153 }
1154
1155 static void
1156 _outFieldSelect(StringInfo str, const FieldSelect *node)
1157 {
1158         WRITE_NODE_TYPE("FIELDSELECT");
1159
1160         WRITE_NODE_FIELD(arg);
1161         WRITE_INT_FIELD(fieldnum);
1162         WRITE_OID_FIELD(resulttype);
1163         WRITE_INT_FIELD(resulttypmod);
1164         WRITE_OID_FIELD(resultcollid);
1165 }
1166
1167 static void
1168 _outFieldStore(StringInfo str, const FieldStore *node)
1169 {
1170         WRITE_NODE_TYPE("FIELDSTORE");
1171
1172         WRITE_NODE_FIELD(arg);
1173         WRITE_NODE_FIELD(newvals);
1174         WRITE_NODE_FIELD(fieldnums);
1175         WRITE_OID_FIELD(resulttype);
1176 }
1177
1178 static void
1179 _outRelabelType(StringInfo str, const RelabelType *node)
1180 {
1181         WRITE_NODE_TYPE("RELABELTYPE");
1182
1183         WRITE_NODE_FIELD(arg);
1184         WRITE_OID_FIELD(resulttype);
1185         WRITE_INT_FIELD(resulttypmod);
1186         WRITE_OID_FIELD(resultcollid);
1187         WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1188         WRITE_LOCATION_FIELD(location);
1189 }
1190
1191 static void
1192 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1193 {
1194         WRITE_NODE_TYPE("COERCEVIAIO");
1195
1196         WRITE_NODE_FIELD(arg);
1197         WRITE_OID_FIELD(resulttype);
1198         WRITE_OID_FIELD(resultcollid);
1199         WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1200         WRITE_LOCATION_FIELD(location);
1201 }
1202
1203 static void
1204 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1205 {
1206         WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1207
1208         WRITE_NODE_FIELD(arg);
1209         WRITE_OID_FIELD(elemfuncid);
1210         WRITE_OID_FIELD(resulttype);
1211         WRITE_INT_FIELD(resulttypmod);
1212         WRITE_OID_FIELD(resultcollid);
1213         WRITE_BOOL_FIELD(isExplicit);
1214         WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1215         WRITE_LOCATION_FIELD(location);
1216 }
1217
1218 static void
1219 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1220 {
1221         WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1222
1223         WRITE_NODE_FIELD(arg);
1224         WRITE_OID_FIELD(resulttype);
1225         WRITE_ENUM_FIELD(convertformat, CoercionForm);
1226         WRITE_LOCATION_FIELD(location);
1227 }
1228
1229 static void
1230 _outCollateExpr(StringInfo str, const CollateExpr *node)
1231 {
1232         WRITE_NODE_TYPE("COLLATE");
1233
1234         WRITE_NODE_FIELD(arg);
1235         WRITE_OID_FIELD(collOid);
1236         WRITE_LOCATION_FIELD(location);
1237 }
1238
1239 static void
1240 _outCaseExpr(StringInfo str, const CaseExpr *node)
1241 {
1242         WRITE_NODE_TYPE("CASE");
1243
1244         WRITE_OID_FIELD(casetype);
1245         WRITE_OID_FIELD(casecollid);
1246         WRITE_NODE_FIELD(arg);
1247         WRITE_NODE_FIELD(args);
1248         WRITE_NODE_FIELD(defresult);
1249         WRITE_LOCATION_FIELD(location);
1250 }
1251
1252 static void
1253 _outCaseWhen(StringInfo str, const CaseWhen *node)
1254 {
1255         WRITE_NODE_TYPE("WHEN");
1256
1257         WRITE_NODE_FIELD(expr);
1258         WRITE_NODE_FIELD(result);
1259         WRITE_LOCATION_FIELD(location);
1260 }
1261
1262 static void
1263 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1264 {
1265         WRITE_NODE_TYPE("CASETESTEXPR");
1266
1267         WRITE_OID_FIELD(typeId);
1268         WRITE_INT_FIELD(typeMod);
1269         WRITE_OID_FIELD(collation);
1270 }
1271
1272 static void
1273 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1274 {
1275         WRITE_NODE_TYPE("ARRAY");
1276
1277         WRITE_OID_FIELD(array_typeid);
1278         WRITE_OID_FIELD(array_collid);
1279         WRITE_OID_FIELD(element_typeid);
1280         WRITE_NODE_FIELD(elements);
1281         WRITE_BOOL_FIELD(multidims);
1282         WRITE_LOCATION_FIELD(location);
1283 }
1284
1285 static void
1286 _outRowExpr(StringInfo str, const RowExpr *node)
1287 {
1288         WRITE_NODE_TYPE("ROW");
1289
1290         WRITE_NODE_FIELD(args);
1291         WRITE_OID_FIELD(row_typeid);
1292         WRITE_ENUM_FIELD(row_format, CoercionForm);
1293         WRITE_NODE_FIELD(colnames);
1294         WRITE_LOCATION_FIELD(location);
1295 }
1296
1297 static void
1298 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1299 {
1300         WRITE_NODE_TYPE("ROWCOMPARE");
1301
1302         WRITE_ENUM_FIELD(rctype, RowCompareType);
1303         WRITE_NODE_FIELD(opnos);
1304         WRITE_NODE_FIELD(opfamilies);
1305         WRITE_NODE_FIELD(inputcollids);
1306         WRITE_NODE_FIELD(largs);
1307         WRITE_NODE_FIELD(rargs);
1308 }
1309
1310 static void
1311 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1312 {
1313         WRITE_NODE_TYPE("COALESCE");
1314
1315         WRITE_OID_FIELD(coalescetype);
1316         WRITE_OID_FIELD(coalescecollid);
1317         WRITE_NODE_FIELD(args);
1318         WRITE_LOCATION_FIELD(location);
1319 }
1320
1321 static void
1322 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1323 {
1324         WRITE_NODE_TYPE("MINMAX");
1325
1326         WRITE_OID_FIELD(minmaxtype);
1327         WRITE_OID_FIELD(minmaxcollid);
1328         WRITE_OID_FIELD(inputcollid);
1329         WRITE_ENUM_FIELD(op, MinMaxOp);
1330         WRITE_NODE_FIELD(args);
1331         WRITE_LOCATION_FIELD(location);
1332 }
1333
1334 static void
1335 _outXmlExpr(StringInfo str, const XmlExpr *node)
1336 {
1337         WRITE_NODE_TYPE("XMLEXPR");
1338
1339         WRITE_ENUM_FIELD(op, XmlExprOp);
1340         WRITE_STRING_FIELD(name);
1341         WRITE_NODE_FIELD(named_args);
1342         WRITE_NODE_FIELD(arg_names);
1343         WRITE_NODE_FIELD(args);
1344         WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1345         WRITE_OID_FIELD(type);
1346         WRITE_INT_FIELD(typmod);
1347         WRITE_LOCATION_FIELD(location);
1348 }
1349
1350 static void
1351 _outNullTest(StringInfo str, const NullTest *node)
1352 {
1353         WRITE_NODE_TYPE("NULLTEST");
1354
1355         WRITE_NODE_FIELD(arg);
1356         WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1357         WRITE_BOOL_FIELD(argisrow);
1358 }
1359
1360 static void
1361 _outBooleanTest(StringInfo str, const BooleanTest *node)
1362 {
1363         WRITE_NODE_TYPE("BOOLEANTEST");
1364
1365         WRITE_NODE_FIELD(arg);
1366         WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1367 }
1368
1369 static void
1370 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1371 {
1372         WRITE_NODE_TYPE("COERCETODOMAIN");
1373
1374         WRITE_NODE_FIELD(arg);
1375         WRITE_OID_FIELD(resulttype);
1376         WRITE_INT_FIELD(resulttypmod);
1377         WRITE_OID_FIELD(resultcollid);
1378         WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1379         WRITE_LOCATION_FIELD(location);
1380 }
1381
1382 static void
1383 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1384 {
1385         WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1386
1387         WRITE_OID_FIELD(typeId);
1388         WRITE_INT_FIELD(typeMod);
1389         WRITE_OID_FIELD(collation);
1390         WRITE_LOCATION_FIELD(location);
1391 }
1392
1393 static void
1394 _outSetToDefault(StringInfo str, const SetToDefault *node)
1395 {
1396         WRITE_NODE_TYPE("SETTODEFAULT");
1397
1398         WRITE_OID_FIELD(typeId);
1399         WRITE_INT_FIELD(typeMod);
1400         WRITE_OID_FIELD(collation);
1401         WRITE_LOCATION_FIELD(location);
1402 }
1403
1404 static void
1405 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1406 {
1407         WRITE_NODE_TYPE("CURRENTOFEXPR");
1408
1409         WRITE_UINT_FIELD(cvarno);
1410         WRITE_STRING_FIELD(cursor_name);
1411         WRITE_INT_FIELD(cursor_param);
1412 }
1413
1414 static void
1415 _outTargetEntry(StringInfo str, const TargetEntry *node)
1416 {
1417         WRITE_NODE_TYPE("TARGETENTRY");
1418
1419         WRITE_NODE_FIELD(expr);
1420         WRITE_INT_FIELD(resno);
1421         WRITE_STRING_FIELD(resname);
1422         WRITE_UINT_FIELD(ressortgroupref);
1423         WRITE_OID_FIELD(resorigtbl);
1424         WRITE_INT_FIELD(resorigcol);
1425         WRITE_BOOL_FIELD(resjunk);
1426 }
1427
1428 static void
1429 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1430 {
1431         WRITE_NODE_TYPE("RANGETBLREF");
1432
1433         WRITE_INT_FIELD(rtindex);
1434 }
1435
1436 static void
1437 _outJoinExpr(StringInfo str, const JoinExpr *node)
1438 {
1439         WRITE_NODE_TYPE("JOINEXPR");
1440
1441         WRITE_ENUM_FIELD(jointype, JoinType);
1442         WRITE_BOOL_FIELD(isNatural);
1443         WRITE_NODE_FIELD(larg);
1444         WRITE_NODE_FIELD(rarg);
1445         WRITE_NODE_FIELD(usingClause);
1446         WRITE_NODE_FIELD(quals);
1447         WRITE_NODE_FIELD(alias);
1448         WRITE_INT_FIELD(rtindex);
1449 }
1450
1451 static void
1452 _outFromExpr(StringInfo str, const FromExpr *node)
1453 {
1454         WRITE_NODE_TYPE("FROMEXPR");
1455
1456         WRITE_NODE_FIELD(fromlist);
1457         WRITE_NODE_FIELD(quals);
1458 }
1459
1460 /*****************************************************************************
1461  *
1462  *      Stuff from relation.h.
1463  *
1464  *****************************************************************************/
1465
1466 /*
1467  * print the basic stuff of all nodes that inherit from Path
1468  *
1469  * Note we do NOT print the parent, else we'd be in infinite recursion.
1470  * We can print the parent's relids for identification purposes, though.
1471  * We also do not print the whole of param_info, since it's printed by
1472  * _outRelOptInfo; it's sufficient and less cluttering to print just the
1473  * required outer relids.
1474  */
1475 static void
1476 _outPathInfo(StringInfo str, const Path *node)
1477 {
1478         WRITE_ENUM_FIELD(pathtype, NodeTag);
1479         appendStringInfoString(str, " :parent_relids ");
1480         _outBitmapset(str, node->parent->relids);
1481         appendStringInfoString(str, " :required_outer ");
1482         if (node->param_info)
1483                 _outBitmapset(str, node->param_info->ppi_req_outer);
1484         else
1485                 _outBitmapset(str, NULL);
1486         WRITE_FLOAT_FIELD(rows, "%.0f");
1487         WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1488         WRITE_FLOAT_FIELD(total_cost, "%.2f");
1489         WRITE_NODE_FIELD(pathkeys);
1490 }
1491
1492 /*
1493  * print the basic stuff of all nodes that inherit from JoinPath
1494  */
1495 static void
1496 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1497 {
1498         _outPathInfo(str, (const Path *) node);
1499
1500         WRITE_ENUM_FIELD(jointype, JoinType);
1501         WRITE_NODE_FIELD(outerjoinpath);
1502         WRITE_NODE_FIELD(innerjoinpath);
1503         WRITE_NODE_FIELD(joinrestrictinfo);
1504 }
1505
1506 static void
1507 _outPath(StringInfo str, const Path *node)
1508 {
1509         WRITE_NODE_TYPE("PATH");
1510
1511         _outPathInfo(str, (const Path *) node);
1512 }
1513
1514 static void
1515 _outIndexPath(StringInfo str, const IndexPath *node)
1516 {
1517         WRITE_NODE_TYPE("INDEXPATH");
1518
1519         _outPathInfo(str, (const Path *) node);
1520
1521         WRITE_NODE_FIELD(indexinfo);
1522         WRITE_NODE_FIELD(indexclauses);
1523         WRITE_NODE_FIELD(indexquals);
1524         WRITE_NODE_FIELD(indexqualcols);
1525         WRITE_NODE_FIELD(indexorderbys);
1526         WRITE_NODE_FIELD(indexorderbycols);
1527         WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1528         WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1529         WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1530 }
1531
1532 static void
1533 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1534 {
1535         WRITE_NODE_TYPE("BITMAPHEAPPATH");
1536
1537         _outPathInfo(str, (const Path *) node);
1538
1539         WRITE_NODE_FIELD(bitmapqual);
1540 }
1541
1542 static void
1543 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1544 {
1545         WRITE_NODE_TYPE("BITMAPANDPATH");
1546
1547         _outPathInfo(str, (const Path *) node);
1548
1549         WRITE_NODE_FIELD(bitmapquals);
1550         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1551 }
1552
1553 static void
1554 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1555 {
1556         WRITE_NODE_TYPE("BITMAPORPATH");
1557
1558         _outPathInfo(str, (const Path *) node);
1559
1560         WRITE_NODE_FIELD(bitmapquals);
1561         WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1562 }
1563
1564 static void
1565 _outTidPath(StringInfo str, const TidPath *node)
1566 {
1567         WRITE_NODE_TYPE("TIDPATH");
1568
1569         _outPathInfo(str, (const Path *) node);
1570
1571         WRITE_NODE_FIELD(tidquals);
1572 }
1573
1574 static void
1575 _outForeignPath(StringInfo str, const ForeignPath *node)
1576 {
1577         WRITE_NODE_TYPE("FOREIGNPATH");
1578
1579         _outPathInfo(str, (const Path *) node);
1580
1581         WRITE_NODE_FIELD(fdw_private);
1582 }
1583
1584 static void
1585 _outAppendPath(StringInfo str, const AppendPath *node)
1586 {
1587         WRITE_NODE_TYPE("APPENDPATH");
1588
1589         _outPathInfo(str, (const Path *) node);
1590
1591         WRITE_NODE_FIELD(subpaths);
1592 }
1593
1594 static void
1595 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1596 {
1597         WRITE_NODE_TYPE("MERGEAPPENDPATH");
1598
1599         _outPathInfo(str, (const Path *) node);
1600
1601         WRITE_NODE_FIELD(subpaths);
1602         WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1603 }
1604
1605 static void
1606 _outResultPath(StringInfo str, const ResultPath *node)
1607 {
1608         WRITE_NODE_TYPE("RESULTPATH");
1609
1610         _outPathInfo(str, (const Path *) node);
1611
1612         WRITE_NODE_FIELD(quals);
1613 }
1614
1615 static void
1616 _outMaterialPath(StringInfo str, const MaterialPath *node)
1617 {
1618         WRITE_NODE_TYPE("MATERIALPATH");
1619
1620         _outPathInfo(str, (const Path *) node);
1621
1622         WRITE_NODE_FIELD(subpath);
1623 }
1624
1625 static void
1626 _outUniquePath(StringInfo str, const UniquePath *node)
1627 {
1628         WRITE_NODE_TYPE("UNIQUEPATH");
1629
1630         _outPathInfo(str, (const Path *) node);
1631
1632         WRITE_NODE_FIELD(subpath);
1633         WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1634         WRITE_NODE_FIELD(in_operators);
1635         WRITE_NODE_FIELD(uniq_exprs);
1636 }
1637
1638 static void
1639 _outNestPath(StringInfo str, const NestPath *node)
1640 {
1641         WRITE_NODE_TYPE("NESTPATH");
1642
1643         _outJoinPathInfo(str, (const JoinPath *) node);
1644 }
1645
1646 static void
1647 _outMergePath(StringInfo str, const MergePath *node)
1648 {
1649         WRITE_NODE_TYPE("MERGEPATH");
1650
1651         _outJoinPathInfo(str, (const JoinPath *) node);
1652
1653         WRITE_NODE_FIELD(path_mergeclauses);
1654         WRITE_NODE_FIELD(outersortkeys);
1655         WRITE_NODE_FIELD(innersortkeys);
1656         WRITE_BOOL_FIELD(materialize_inner);
1657 }
1658
1659 static void
1660 _outHashPath(StringInfo str, const HashPath *node)
1661 {
1662         WRITE_NODE_TYPE("HASHPATH");
1663
1664         _outJoinPathInfo(str, (const JoinPath *) node);
1665
1666         WRITE_NODE_FIELD(path_hashclauses);
1667         WRITE_INT_FIELD(num_batches);
1668 }
1669
1670 static void
1671 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
1672 {
1673         WRITE_NODE_TYPE("PLANNERGLOBAL");
1674
1675         /* NB: this isn't a complete set of fields */
1676         WRITE_NODE_FIELD(subplans);
1677         WRITE_BITMAPSET_FIELD(rewindPlanIDs);
1678         WRITE_NODE_FIELD(finalrtable);
1679         WRITE_NODE_FIELD(finalrowmarks);
1680         WRITE_NODE_FIELD(resultRelations);
1681         WRITE_NODE_FIELD(relationOids);
1682         WRITE_NODE_FIELD(invalItems);
1683         WRITE_INT_FIELD(nParamExec);
1684         WRITE_UINT_FIELD(lastPHId);
1685         WRITE_UINT_FIELD(lastRowMarkId);
1686         WRITE_BOOL_FIELD(transientPlan);
1687 }
1688
1689 static void
1690 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
1691 {
1692         WRITE_NODE_TYPE("PLANNERINFO");
1693
1694         /* NB: this isn't a complete set of fields */
1695         WRITE_NODE_FIELD(parse);
1696         WRITE_NODE_FIELD(glob);
1697         WRITE_UINT_FIELD(query_level);
1698         WRITE_NODE_FIELD(plan_params);
1699         WRITE_BITMAPSET_FIELD(all_baserels);
1700         WRITE_BITMAPSET_FIELD(nullable_baserels);
1701         WRITE_NODE_FIELD(join_rel_list);
1702         WRITE_INT_FIELD(join_cur_level);
1703         WRITE_NODE_FIELD(init_plans);
1704         WRITE_NODE_FIELD(cte_plan_ids);
1705         WRITE_NODE_FIELD(multiexpr_params);
1706         WRITE_NODE_FIELD(eq_classes);
1707         WRITE_NODE_FIELD(canon_pathkeys);
1708         WRITE_NODE_FIELD(left_join_clauses);
1709         WRITE_NODE_FIELD(right_join_clauses);
1710         WRITE_NODE_FIELD(full_join_clauses);
1711         WRITE_NODE_FIELD(join_info_list);
1712         WRITE_NODE_FIELD(lateral_info_list);
1713         WRITE_NODE_FIELD(append_rel_list);
1714         WRITE_NODE_FIELD(rowMarks);
1715         WRITE_NODE_FIELD(placeholder_list);
1716         WRITE_NODE_FIELD(query_pathkeys);
1717         WRITE_NODE_FIELD(group_pathkeys);
1718         WRITE_NODE_FIELD(window_pathkeys);
1719         WRITE_NODE_FIELD(distinct_pathkeys);
1720         WRITE_NODE_FIELD(sort_pathkeys);
1721         WRITE_NODE_FIELD(minmax_aggs);
1722         WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
1723         WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
1724         WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1725         WRITE_BOOL_FIELD(hasInheritedTarget);
1726         WRITE_BOOL_FIELD(hasJoinRTEs);
1727         WRITE_BOOL_FIELD(hasLateralRTEs);
1728         WRITE_BOOL_FIELD(hasHavingQual);
1729         WRITE_BOOL_FIELD(hasPseudoConstantQuals);
1730         WRITE_BOOL_FIELD(hasRecursion);
1731         WRITE_INT_FIELD(wt_param_id);
1732         WRITE_BITMAPSET_FIELD(curOuterRels);
1733         WRITE_NODE_FIELD(curOuterParams);
1734 }
1735
1736 static void
1737 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
1738 {
1739         WRITE_NODE_TYPE("RELOPTINFO");
1740
1741         /* NB: this isn't a complete set of fields */
1742         WRITE_ENUM_FIELD(reloptkind, RelOptKind);
1743         WRITE_BITMAPSET_FIELD(relids);
1744         WRITE_FLOAT_FIELD(rows, "%.0f");
1745         WRITE_INT_FIELD(width);
1746         WRITE_BOOL_FIELD(consider_startup);
1747         WRITE_NODE_FIELD(reltargetlist);
1748         WRITE_NODE_FIELD(pathlist);
1749         WRITE_NODE_FIELD(ppilist);
1750         WRITE_NODE_FIELD(cheapest_startup_path);
1751         WRITE_NODE_FIELD(cheapest_total_path);
1752         WRITE_NODE_FIELD(cheapest_unique_path);
1753         WRITE_NODE_FIELD(cheapest_parameterized_paths);
1754         WRITE_UINT_FIELD(relid);
1755         WRITE_UINT_FIELD(reltablespace);
1756         WRITE_ENUM_FIELD(rtekind, RTEKind);
1757         WRITE_INT_FIELD(min_attr);
1758         WRITE_INT_FIELD(max_attr);
1759         WRITE_NODE_FIELD(lateral_vars);
1760         WRITE_BITMAPSET_FIELD(lateral_relids);
1761         WRITE_BITMAPSET_FIELD(lateral_referencers);
1762         WRITE_NODE_FIELD(indexlist);
1763         WRITE_UINT_FIELD(pages);
1764         WRITE_FLOAT_FIELD(tuples, "%.0f");
1765         WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
1766         WRITE_NODE_FIELD(subplan);
1767         WRITE_NODE_FIELD(subroot);
1768         WRITE_NODE_FIELD(subplan_params);
1769         /* we don't try to print fdwroutine or fdw_private */
1770         WRITE_NODE_FIELD(baserestrictinfo);
1771         WRITE_NODE_FIELD(joininfo);
1772         WRITE_BOOL_FIELD(has_eclass_joins);
1773 }
1774
1775 static void
1776 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
1777 {
1778         WRITE_NODE_TYPE("INDEXOPTINFO");
1779
1780         /* NB: this isn't a complete set of fields */
1781         WRITE_OID_FIELD(indexoid);
1782         /* Do NOT print rel field, else infinite recursion */
1783         WRITE_UINT_FIELD(pages);
1784         WRITE_FLOAT_FIELD(tuples, "%.0f");
1785         WRITE_INT_FIELD(tree_height);
1786         WRITE_INT_FIELD(ncolumns);
1787         /* array fields aren't really worth the trouble to print */
1788         WRITE_OID_FIELD(relam);
1789         /* indexprs is redundant since we print indextlist */
1790         WRITE_NODE_FIELD(indpred);
1791         WRITE_NODE_FIELD(indextlist);
1792         WRITE_BOOL_FIELD(predOK);
1793         WRITE_BOOL_FIELD(unique);
1794         WRITE_BOOL_FIELD(immediate);
1795         WRITE_BOOL_FIELD(hypothetical);
1796         /* we don't bother with fields copied from the pg_am entry */
1797 }
1798
1799 static void
1800 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
1801 {
1802         /*
1803          * To simplify reading, we just chase up to the topmost merged EC and
1804          * print that, without bothering to show the merge-ees separately.
1805          */
1806         while (node->ec_merged)
1807                 node = node->ec_merged;
1808
1809         WRITE_NODE_TYPE("EQUIVALENCECLASS");
1810
1811         WRITE_NODE_FIELD(ec_opfamilies);
1812         WRITE_OID_FIELD(ec_collation);
1813         WRITE_NODE_FIELD(ec_members);
1814         WRITE_NODE_FIELD(ec_sources);
1815         WRITE_NODE_FIELD(ec_derives);
1816         WRITE_BITMAPSET_FIELD(ec_relids);
1817         WRITE_BOOL_FIELD(ec_has_const);
1818         WRITE_BOOL_FIELD(ec_has_volatile);
1819         WRITE_BOOL_FIELD(ec_below_outer_join);
1820         WRITE_BOOL_FIELD(ec_broken);
1821         WRITE_UINT_FIELD(ec_sortref);
1822 }
1823
1824 static void
1825 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
1826 {
1827         WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
1828
1829         WRITE_NODE_FIELD(em_expr);
1830         WRITE_BITMAPSET_FIELD(em_relids);
1831         WRITE_BITMAPSET_FIELD(em_nullable_relids);
1832         WRITE_BOOL_FIELD(em_is_const);
1833         WRITE_BOOL_FIELD(em_is_child);
1834         WRITE_OID_FIELD(em_datatype);
1835 }
1836
1837 static void
1838 _outPathKey(StringInfo str, const PathKey *node)
1839 {
1840         WRITE_NODE_TYPE("PATHKEY");
1841
1842         WRITE_NODE_FIELD(pk_eclass);
1843         WRITE_OID_FIELD(pk_opfamily);
1844         WRITE_INT_FIELD(pk_strategy);
1845         WRITE_BOOL_FIELD(pk_nulls_first);
1846 }
1847
1848 static void
1849 _outParamPathInfo(StringInfo str, const ParamPathInfo *node)
1850 {
1851         WRITE_NODE_TYPE("PARAMPATHINFO");
1852
1853         WRITE_BITMAPSET_FIELD(ppi_req_outer);
1854         WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
1855         WRITE_NODE_FIELD(ppi_clauses);
1856 }
1857
1858 static void
1859 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
1860 {
1861         WRITE_NODE_TYPE("RESTRICTINFO");
1862
1863         /* NB: this isn't a complete set of fields */
1864         WRITE_NODE_FIELD(clause);
1865         WRITE_BOOL_FIELD(is_pushed_down);
1866         WRITE_BOOL_FIELD(outerjoin_delayed);
1867         WRITE_BOOL_FIELD(can_join);
1868         WRITE_BOOL_FIELD(pseudoconstant);
1869         WRITE_BITMAPSET_FIELD(clause_relids);
1870         WRITE_BITMAPSET_FIELD(required_relids);
1871         WRITE_BITMAPSET_FIELD(outer_relids);
1872         WRITE_BITMAPSET_FIELD(nullable_relids);
1873         WRITE_BITMAPSET_FIELD(left_relids);
1874         WRITE_BITMAPSET_FIELD(right_relids);
1875         WRITE_NODE_FIELD(orclause);
1876         /* don't write parent_ec, leads to infinite recursion in plan tree dump */
1877         WRITE_FLOAT_FIELD(norm_selec, "%.4f");
1878         WRITE_FLOAT_FIELD(outer_selec, "%.4f");
1879         WRITE_NODE_FIELD(mergeopfamilies);
1880         /* don't write left_ec, leads to infinite recursion in plan tree dump */
1881         /* don't write right_ec, leads to infinite recursion in plan tree dump */
1882         WRITE_NODE_FIELD(left_em);
1883         WRITE_NODE_FIELD(right_em);
1884         WRITE_BOOL_FIELD(outer_is_left);
1885         WRITE_OID_FIELD(hashjoinoperator);
1886 }
1887
1888 static void
1889 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
1890 {
1891         WRITE_NODE_TYPE("PLACEHOLDERVAR");
1892
1893         WRITE_NODE_FIELD(phexpr);
1894         WRITE_BITMAPSET_FIELD(phrels);
1895         WRITE_UINT_FIELD(phid);
1896         WRITE_UINT_FIELD(phlevelsup);
1897 }
1898
1899 static void
1900 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
1901 {
1902         WRITE_NODE_TYPE("SPECIALJOININFO");
1903
1904         WRITE_BITMAPSET_FIELD(min_lefthand);
1905         WRITE_BITMAPSET_FIELD(min_righthand);
1906         WRITE_BITMAPSET_FIELD(syn_lefthand);
1907         WRITE_BITMAPSET_FIELD(syn_righthand);
1908         WRITE_ENUM_FIELD(jointype, JoinType);
1909         WRITE_BOOL_FIELD(lhs_strict);
1910         WRITE_BOOL_FIELD(delay_upper_joins);
1911         WRITE_NODE_FIELD(join_quals);
1912 }
1913
1914 static void
1915 _outLateralJoinInfo(StringInfo str, const LateralJoinInfo *node)
1916 {
1917         WRITE_NODE_TYPE("LATERALJOININFO");
1918
1919         WRITE_BITMAPSET_FIELD(lateral_lhs);
1920         WRITE_BITMAPSET_FIELD(lateral_rhs);
1921 }
1922
1923 static void
1924 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
1925 {
1926         WRITE_NODE_TYPE("APPENDRELINFO");
1927
1928         WRITE_UINT_FIELD(parent_relid);
1929         WRITE_UINT_FIELD(child_relid);
1930         WRITE_OID_FIELD(parent_reltype);
1931         WRITE_OID_FIELD(child_reltype);
1932         WRITE_NODE_FIELD(translated_vars);
1933         WRITE_OID_FIELD(parent_reloid);
1934 }
1935
1936 static void
1937 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
1938 {
1939         WRITE_NODE_TYPE("PLACEHOLDERINFO");
1940
1941         WRITE_UINT_FIELD(phid);
1942         WRITE_NODE_FIELD(ph_var);
1943         WRITE_BITMAPSET_FIELD(ph_eval_at);
1944         WRITE_BITMAPSET_FIELD(ph_lateral);
1945         WRITE_BITMAPSET_FIELD(ph_needed);
1946         WRITE_INT_FIELD(ph_width);
1947 }
1948
1949 static void
1950 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
1951 {
1952         WRITE_NODE_TYPE("MINMAXAGGINFO");
1953
1954         WRITE_OID_FIELD(aggfnoid);
1955         WRITE_OID_FIELD(aggsortop);
1956         WRITE_NODE_FIELD(target);
1957         /* We intentionally omit subroot --- too large, not interesting enough */
1958         WRITE_NODE_FIELD(path);
1959         WRITE_FLOAT_FIELD(pathcost, "%.2f");
1960         WRITE_NODE_FIELD(param);
1961 }
1962
1963 static void
1964 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
1965 {
1966         WRITE_NODE_TYPE("PLANNERPARAMITEM");
1967
1968         WRITE_NODE_FIELD(item);
1969         WRITE_INT_FIELD(paramId);
1970 }
1971
1972 /*****************************************************************************
1973  *
1974  *      Stuff from parsenodes.h.
1975  *
1976  *****************************************************************************/
1977
1978 /*
1979  * print the basic stuff of all nodes that inherit from CreateStmt
1980  */
1981 static void
1982 _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
1983 {
1984         WRITE_NODE_FIELD(relation);
1985         WRITE_NODE_FIELD(tableElts);
1986         WRITE_NODE_FIELD(inhRelations);
1987         WRITE_NODE_FIELD(ofTypename);
1988         WRITE_NODE_FIELD(constraints);
1989         WRITE_NODE_FIELD(options);
1990         WRITE_ENUM_FIELD(oncommit, OnCommitAction);
1991         WRITE_STRING_FIELD(tablespacename);
1992         WRITE_BOOL_FIELD(if_not_exists);
1993 }
1994
1995 static void
1996 _outCreateStmt(StringInfo str, const CreateStmt *node)
1997 {
1998         WRITE_NODE_TYPE("CREATESTMT");
1999
2000         _outCreateStmtInfo(str, (const CreateStmt *) node);
2001 }
2002
2003 static void
2004 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
2005 {
2006         WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
2007
2008         _outCreateStmtInfo(str, (const CreateStmt *) node);
2009
2010         WRITE_STRING_FIELD(servername);
2011         WRITE_NODE_FIELD(options);
2012 }
2013
2014 static void
2015 _outImportForeignSchemaStmt(StringInfo str, const ImportForeignSchemaStmt *node)
2016 {
2017         WRITE_NODE_TYPE("IMPORTFOREIGNSCHEMASTMT");
2018
2019         WRITE_STRING_FIELD(server_name);
2020         WRITE_STRING_FIELD(remote_schema);
2021         WRITE_STRING_FIELD(local_schema);
2022         WRITE_ENUM_FIELD(list_type, ImportForeignSchemaType);
2023         WRITE_NODE_FIELD(table_list);
2024         WRITE_NODE_FIELD(options);
2025 }
2026
2027 static void
2028 _outIndexStmt(StringInfo str, const IndexStmt *node)
2029 {
2030         WRITE_NODE_TYPE("INDEXSTMT");
2031
2032         WRITE_STRING_FIELD(idxname);
2033         WRITE_NODE_FIELD(relation);
2034         WRITE_STRING_FIELD(accessMethod);
2035         WRITE_STRING_FIELD(tableSpace);
2036         WRITE_NODE_FIELD(indexParams);
2037         WRITE_NODE_FIELD(options);
2038         WRITE_NODE_FIELD(whereClause);
2039         WRITE_NODE_FIELD(excludeOpNames);
2040         WRITE_STRING_FIELD(idxcomment);
2041         WRITE_OID_FIELD(indexOid);
2042         WRITE_OID_FIELD(oldNode);
2043         WRITE_BOOL_FIELD(unique);
2044         WRITE_BOOL_FIELD(primary);
2045         WRITE_BOOL_FIELD(isconstraint);
2046         WRITE_BOOL_FIELD(deferrable);
2047         WRITE_BOOL_FIELD(initdeferred);
2048         WRITE_BOOL_FIELD(concurrent);
2049 }
2050
2051 static void
2052 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
2053 {
2054         WRITE_NODE_TYPE("NOTIFY");
2055
2056         WRITE_STRING_FIELD(conditionname);
2057         WRITE_STRING_FIELD(payload);
2058 }
2059
2060 static void
2061 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2062 {
2063         WRITE_NODE_TYPE("DECLARECURSOR");
2064
2065         WRITE_STRING_FIELD(portalname);
2066         WRITE_INT_FIELD(options);
2067         WRITE_NODE_FIELD(query);
2068 }
2069
2070 static void
2071 _outSelectStmt(StringInfo str, const SelectStmt *node)
2072 {
2073         WRITE_NODE_TYPE("SELECT");
2074
2075         WRITE_NODE_FIELD(distinctClause);
2076         WRITE_NODE_FIELD(intoClause);
2077         WRITE_NODE_FIELD(targetList);
2078         WRITE_NODE_FIELD(fromClause);
2079         WRITE_NODE_FIELD(whereClause);
2080         WRITE_NODE_FIELD(groupClause);
2081         WRITE_NODE_FIELD(havingClause);
2082         WRITE_NODE_FIELD(windowClause);
2083         WRITE_NODE_FIELD(valuesLists);
2084         WRITE_NODE_FIELD(sortClause);
2085         WRITE_NODE_FIELD(limitOffset);
2086         WRITE_NODE_FIELD(limitCount);
2087         WRITE_NODE_FIELD(lockingClause);
2088         WRITE_NODE_FIELD(withClause);
2089         WRITE_ENUM_FIELD(op, SetOperation);
2090         WRITE_BOOL_FIELD(all);
2091         WRITE_NODE_FIELD(larg);
2092         WRITE_NODE_FIELD(rarg);
2093 }
2094
2095 static void
2096 _outFuncCall(StringInfo str, const FuncCall *node)
2097 {
2098         WRITE_NODE_TYPE("FUNCCALL");
2099
2100         WRITE_NODE_FIELD(funcname);
2101         WRITE_NODE_FIELD(args);
2102         WRITE_NODE_FIELD(agg_order);
2103         WRITE_NODE_FIELD(agg_filter);
2104         WRITE_BOOL_FIELD(agg_within_group);
2105         WRITE_BOOL_FIELD(agg_star);
2106         WRITE_BOOL_FIELD(agg_distinct);
2107         WRITE_BOOL_FIELD(func_variadic);
2108         WRITE_NODE_FIELD(over);
2109         WRITE_LOCATION_FIELD(location);
2110 }
2111
2112 static void
2113 _outDefElem(StringInfo str, const DefElem *node)
2114 {
2115         WRITE_NODE_TYPE("DEFELEM");
2116
2117         WRITE_STRING_FIELD(defnamespace);
2118         WRITE_STRING_FIELD(defname);
2119         WRITE_NODE_FIELD(arg);
2120         WRITE_ENUM_FIELD(defaction, DefElemAction);
2121 }
2122
2123 static void
2124 _outTableLikeClause(StringInfo str, const TableLikeClause *node)
2125 {
2126         WRITE_NODE_TYPE("TABLELIKECLAUSE");
2127
2128         WRITE_NODE_FIELD(relation);
2129         WRITE_UINT_FIELD(options);
2130 }
2131
2132 static void
2133 _outLockingClause(StringInfo str, const LockingClause *node)
2134 {
2135         WRITE_NODE_TYPE("LOCKINGCLAUSE");
2136
2137         WRITE_NODE_FIELD(lockedRels);
2138         WRITE_ENUM_FIELD(strength, LockClauseStrength);
2139         WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2140 }
2141
2142 static void
2143 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2144 {
2145         WRITE_NODE_TYPE("XMLSERIALIZE");
2146
2147         WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2148         WRITE_NODE_FIELD(expr);
2149         WRITE_NODE_FIELD(typeName);
2150         WRITE_LOCATION_FIELD(location);
2151 }
2152
2153 static void
2154 _outColumnDef(StringInfo str, const ColumnDef *node)
2155 {
2156         WRITE_NODE_TYPE("COLUMNDEF");
2157
2158         WRITE_STRING_FIELD(colname);
2159         WRITE_NODE_FIELD(typeName);
2160         WRITE_INT_FIELD(inhcount);
2161         WRITE_BOOL_FIELD(is_local);
2162         WRITE_BOOL_FIELD(is_not_null);
2163         WRITE_BOOL_FIELD(is_from_type);
2164         WRITE_CHAR_FIELD(storage);
2165         WRITE_NODE_FIELD(raw_default);
2166         WRITE_NODE_FIELD(cooked_default);
2167         WRITE_NODE_FIELD(collClause);
2168         WRITE_OID_FIELD(collOid);
2169         WRITE_NODE_FIELD(constraints);
2170         WRITE_NODE_FIELD(fdwoptions);
2171         WRITE_LOCATION_FIELD(location);
2172 }
2173
2174 static void
2175 _outTypeName(StringInfo str, const TypeName *node)
2176 {
2177         WRITE_NODE_TYPE("TYPENAME");
2178
2179         WRITE_NODE_FIELD(names);
2180         WRITE_OID_FIELD(typeOid);
2181         WRITE_BOOL_FIELD(setof);
2182         WRITE_BOOL_FIELD(pct_type);
2183         WRITE_NODE_FIELD(typmods);
2184         WRITE_INT_FIELD(typemod);
2185         WRITE_NODE_FIELD(arrayBounds);
2186         WRITE_LOCATION_FIELD(location);
2187 }
2188
2189 static void
2190 _outTypeCast(StringInfo str, const TypeCast *node)
2191 {
2192         WRITE_NODE_TYPE("TYPECAST");
2193
2194         WRITE_NODE_FIELD(arg);
2195         WRITE_NODE_FIELD(typeName);
2196         WRITE_LOCATION_FIELD(location);
2197 }
2198
2199 static void
2200 _outCollateClause(StringInfo str, const CollateClause *node)
2201 {
2202         WRITE_NODE_TYPE("COLLATECLAUSE");
2203
2204         WRITE_NODE_FIELD(arg);
2205         WRITE_NODE_FIELD(collname);
2206         WRITE_LOCATION_FIELD(location);
2207 }
2208
2209 static void
2210 _outIndexElem(StringInfo str, const IndexElem *node)
2211 {
2212         WRITE_NODE_TYPE("INDEXELEM");
2213
2214         WRITE_STRING_FIELD(name);
2215         WRITE_NODE_FIELD(expr);
2216         WRITE_STRING_FIELD(indexcolname);
2217         WRITE_NODE_FIELD(collation);
2218         WRITE_NODE_FIELD(opclass);
2219         WRITE_ENUM_FIELD(ordering, SortByDir);
2220         WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2221 }
2222
2223 static void
2224 _outQuery(StringInfo str, const Query *node)
2225 {
2226         WRITE_NODE_TYPE("QUERY");
2227
2228         WRITE_ENUM_FIELD(commandType, CmdType);
2229         WRITE_ENUM_FIELD(querySource, QuerySource);
2230         /* we intentionally do not print the queryId field */
2231         WRITE_BOOL_FIELD(canSetTag);
2232
2233         /*
2234          * Hack to work around missing outfuncs routines for a lot of the
2235          * utility-statement node types.  (The only one we actually *need* for
2236          * rules support is NotifyStmt.)  Someday we ought to support 'em all, but
2237          * for the meantime do this to avoid getting lots of warnings when running
2238          * with debug_print_parse on.
2239          */
2240         if (node->utilityStmt)
2241         {
2242                 switch (nodeTag(node->utilityStmt))
2243                 {
2244                         case T_CreateStmt:
2245                         case T_IndexStmt:
2246                         case T_NotifyStmt:
2247                         case T_DeclareCursorStmt:
2248                                 WRITE_NODE_FIELD(utilityStmt);
2249                                 break;
2250                         default:
2251                                 appendStringInfoString(str, " :utilityStmt ?");
2252                                 break;
2253                 }
2254         }
2255         else
2256                 appendStringInfoString(str, " :utilityStmt <>");
2257
2258         WRITE_INT_FIELD(resultRelation);
2259         WRITE_BOOL_FIELD(hasAggs);
2260         WRITE_BOOL_FIELD(hasWindowFuncs);
2261         WRITE_BOOL_FIELD(hasSubLinks);
2262         WRITE_BOOL_FIELD(hasDistinctOn);
2263         WRITE_BOOL_FIELD(hasRecursive);
2264         WRITE_BOOL_FIELD(hasModifyingCTE);
2265         WRITE_BOOL_FIELD(hasForUpdate);
2266         WRITE_BOOL_FIELD(hasRowSecurity);
2267         WRITE_NODE_FIELD(cteList);
2268         WRITE_NODE_FIELD(rtable);
2269         WRITE_NODE_FIELD(jointree);
2270         WRITE_NODE_FIELD(targetList);
2271         WRITE_NODE_FIELD(withCheckOptions);
2272         WRITE_NODE_FIELD(returningList);
2273         WRITE_NODE_FIELD(groupClause);
2274         WRITE_NODE_FIELD(havingQual);
2275         WRITE_NODE_FIELD(windowClause);
2276         WRITE_NODE_FIELD(distinctClause);
2277         WRITE_NODE_FIELD(sortClause);
2278         WRITE_NODE_FIELD(limitOffset);
2279         WRITE_NODE_FIELD(limitCount);
2280         WRITE_NODE_FIELD(rowMarks);
2281         WRITE_NODE_FIELD(setOperations);
2282         WRITE_NODE_FIELD(constraintDeps);
2283 }
2284
2285 static void
2286 _outWithCheckOption(StringInfo str, const WithCheckOption *node)
2287 {
2288         WRITE_NODE_TYPE("WITHCHECKOPTION");
2289
2290         WRITE_STRING_FIELD(viewname);
2291         WRITE_NODE_FIELD(qual);
2292         WRITE_BOOL_FIELD(cascaded);
2293 }
2294
2295 static void
2296 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2297 {
2298         WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2299
2300         WRITE_UINT_FIELD(tleSortGroupRef);
2301         WRITE_OID_FIELD(eqop);
2302         WRITE_OID_FIELD(sortop);
2303         WRITE_BOOL_FIELD(nulls_first);
2304         WRITE_BOOL_FIELD(hashable);
2305 }
2306
2307 static void
2308 _outWindowClause(StringInfo str, const WindowClause *node)
2309 {
2310         WRITE_NODE_TYPE("WINDOWCLAUSE");
2311
2312         WRITE_STRING_FIELD(name);
2313         WRITE_STRING_FIELD(refname);
2314         WRITE_NODE_FIELD(partitionClause);
2315         WRITE_NODE_FIELD(orderClause);
2316         WRITE_INT_FIELD(frameOptions);
2317         WRITE_NODE_FIELD(startOffset);
2318         WRITE_NODE_FIELD(endOffset);
2319         WRITE_UINT_FIELD(winref);
2320         WRITE_BOOL_FIELD(copiedOrder);
2321 }
2322
2323 static void
2324 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
2325 {
2326         WRITE_NODE_TYPE("ROWMARKCLAUSE");
2327
2328         WRITE_UINT_FIELD(rti);
2329         WRITE_ENUM_FIELD(strength, LockClauseStrength);
2330         WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2331         WRITE_BOOL_FIELD(pushedDown);
2332 }
2333
2334 static void
2335 _outWithClause(StringInfo str, const WithClause *node)
2336 {
2337         WRITE_NODE_TYPE("WITHCLAUSE");
2338
2339         WRITE_NODE_FIELD(ctes);
2340         WRITE_BOOL_FIELD(recursive);
2341         WRITE_LOCATION_FIELD(location);
2342 }
2343
2344 static void
2345 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
2346 {
2347         WRITE_NODE_TYPE("COMMONTABLEEXPR");
2348
2349         WRITE_STRING_FIELD(ctename);
2350         WRITE_NODE_FIELD(aliascolnames);
2351         WRITE_NODE_FIELD(ctequery);
2352         WRITE_LOCATION_FIELD(location);
2353         WRITE_BOOL_FIELD(cterecursive);
2354         WRITE_INT_FIELD(cterefcount);
2355         WRITE_NODE_FIELD(ctecolnames);
2356         WRITE_NODE_FIELD(ctecoltypes);
2357         WRITE_NODE_FIELD(ctecoltypmods);
2358         WRITE_NODE_FIELD(ctecolcollations);
2359 }
2360
2361 static void
2362 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
2363 {
2364         WRITE_NODE_TYPE("SETOPERATIONSTMT");
2365
2366         WRITE_ENUM_FIELD(op, SetOperation);
2367         WRITE_BOOL_FIELD(all);
2368         WRITE_NODE_FIELD(larg);
2369         WRITE_NODE_FIELD(rarg);
2370         WRITE_NODE_FIELD(colTypes);
2371         WRITE_NODE_FIELD(colTypmods);
2372         WRITE_NODE_FIELD(colCollations);
2373         WRITE_NODE_FIELD(groupClauses);
2374 }
2375
2376 static void
2377 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
2378 {
2379         WRITE_NODE_TYPE("RTE");
2380
2381         /* put alias + eref first to make dump more legible */
2382         WRITE_NODE_FIELD(alias);
2383         WRITE_NODE_FIELD(eref);
2384         WRITE_ENUM_FIELD(rtekind, RTEKind);
2385
2386         switch (node->rtekind)
2387         {
2388                 case RTE_RELATION:
2389                         WRITE_OID_FIELD(relid);
2390                         WRITE_CHAR_FIELD(relkind);
2391                         break;
2392                 case RTE_SUBQUERY:
2393                         WRITE_NODE_FIELD(subquery);
2394                         WRITE_BOOL_FIELD(security_barrier);
2395                         break;
2396                 case RTE_JOIN:
2397                         WRITE_ENUM_FIELD(jointype, JoinType);
2398                         WRITE_NODE_FIELD(joinaliasvars);
2399                         break;
2400                 case RTE_FUNCTION:
2401                         WRITE_NODE_FIELD(functions);
2402                         WRITE_BOOL_FIELD(funcordinality);
2403                         break;
2404                 case RTE_VALUES:
2405                         WRITE_NODE_FIELD(values_lists);
2406                         WRITE_NODE_FIELD(values_collations);
2407                         break;
2408                 case RTE_CTE:
2409                         WRITE_STRING_FIELD(ctename);
2410                         WRITE_UINT_FIELD(ctelevelsup);
2411                         WRITE_BOOL_FIELD(self_reference);
2412                         WRITE_NODE_FIELD(ctecoltypes);
2413                         WRITE_NODE_FIELD(ctecoltypmods);
2414                         WRITE_NODE_FIELD(ctecolcollations);
2415                         break;
2416                 default:
2417                         elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2418                         break;
2419         }
2420
2421         WRITE_BOOL_FIELD(lateral);
2422         WRITE_BOOL_FIELD(inh);
2423         WRITE_BOOL_FIELD(inFromCl);
2424         WRITE_UINT_FIELD(requiredPerms);
2425         WRITE_OID_FIELD(checkAsUser);
2426         WRITE_BITMAPSET_FIELD(selectedCols);
2427         WRITE_BITMAPSET_FIELD(modifiedCols);
2428         WRITE_NODE_FIELD(securityQuals);
2429 }
2430
2431 static void
2432 _outRangeTblFunction(StringInfo str, const RangeTblFunction *node)
2433 {
2434         WRITE_NODE_TYPE("RANGETBLFUNCTION");
2435
2436         WRITE_NODE_FIELD(funcexpr);
2437         WRITE_INT_FIELD(funccolcount);
2438         WRITE_NODE_FIELD(funccolnames);
2439         WRITE_NODE_FIELD(funccoltypes);
2440         WRITE_NODE_FIELD(funccoltypmods);
2441         WRITE_NODE_FIELD(funccolcollations);
2442         WRITE_BITMAPSET_FIELD(funcparams);
2443 }
2444
2445 static void
2446 _outAExpr(StringInfo str, const A_Expr *node)
2447 {
2448         WRITE_NODE_TYPE("AEXPR");
2449
2450         switch (node->kind)
2451         {
2452                 case AEXPR_OP:
2453                         appendStringInfoChar(str, ' ');
2454                         WRITE_NODE_FIELD(name);
2455                         break;
2456                 case AEXPR_OP_ANY:
2457                         appendStringInfoChar(str, ' ');
2458                         WRITE_NODE_FIELD(name);
2459                         appendStringInfoString(str, " ANY ");
2460                         break;
2461                 case AEXPR_OP_ALL:
2462                         appendStringInfoChar(str, ' ');
2463                         WRITE_NODE_FIELD(name);
2464                         appendStringInfoString(str, " ALL ");
2465                         break;
2466                 case AEXPR_DISTINCT:
2467                         appendStringInfoString(str, " DISTINCT ");
2468                         WRITE_NODE_FIELD(name);
2469                         break;
2470                 case AEXPR_NULLIF:
2471                         appendStringInfoString(str, " NULLIF ");
2472                         WRITE_NODE_FIELD(name);
2473                         break;
2474                 case AEXPR_OF:
2475                         appendStringInfoString(str, " OF ");
2476                         WRITE_NODE_FIELD(name);
2477                         break;
2478                 case AEXPR_IN:
2479                         appendStringInfoString(str, " IN ");
2480                         WRITE_NODE_FIELD(name);
2481                         break;
2482                 default:
2483                         appendStringInfoString(str, " ??");
2484                         break;
2485         }
2486
2487         WRITE_NODE_FIELD(lexpr);
2488         WRITE_NODE_FIELD(rexpr);
2489         WRITE_LOCATION_FIELD(location);
2490 }
2491
2492 static void
2493 _outValue(StringInfo str, const Value *value)
2494 {
2495         switch (value->type)
2496         {
2497                 case T_Integer:
2498                         appendStringInfo(str, "%ld", value->val.ival);
2499                         break;
2500                 case T_Float:
2501
2502                         /*
2503                          * We assume the value is a valid numeric literal and so does not
2504                          * need quoting.
2505                          */
2506                         appendStringInfoString(str, value->val.str);
2507                         break;
2508                 case T_String:
2509
2510                         /*
2511                          * We use _outToken to provide escaping of the string's content,
2512                          * but we don't want it to do anything with an empty string.
2513                          */
2514                         appendStringInfoChar(str, '"');
2515                         if (value->val.str[0] != '\0')
2516                                 _outToken(str, value->val.str);
2517                         appendStringInfoChar(str, '"');
2518                         break;
2519                 case T_BitString:
2520                         /* internal representation already has leading 'b' */
2521                         appendStringInfoString(str, value->val.str);
2522                         break;
2523                 case T_Null:
2524                         /* this is seen only within A_Const, not in transformed trees */
2525                         appendStringInfoString(str, "NULL");
2526                         break;
2527                 default:
2528                         elog(ERROR, "unrecognized node type: %d", (int) value->type);
2529                         break;
2530         }
2531 }
2532
2533 static void
2534 _outColumnRef(StringInfo str, const ColumnRef *node)
2535 {
2536         WRITE_NODE_TYPE("COLUMNREF");
2537
2538         WRITE_NODE_FIELD(fields);
2539         WRITE_LOCATION_FIELD(location);
2540 }
2541
2542 static void
2543 _outParamRef(StringInfo str, const ParamRef *node)
2544 {
2545         WRITE_NODE_TYPE("PARAMREF");
2546
2547         WRITE_INT_FIELD(number);
2548         WRITE_LOCATION_FIELD(location);
2549 }
2550
2551 static void
2552 _outAConst(StringInfo str, const A_Const *node)
2553 {
2554         WRITE_NODE_TYPE("A_CONST");
2555
2556         appendStringInfoString(str, " :val ");
2557         _outValue(str, &(node->val));
2558         WRITE_LOCATION_FIELD(location);
2559 }
2560
2561 static void
2562 _outA_Star(StringInfo str, const A_Star *node)
2563 {
2564         WRITE_NODE_TYPE("A_STAR");
2565 }
2566
2567 static void
2568 _outA_Indices(StringInfo str, const A_Indices *node)
2569 {
2570         WRITE_NODE_TYPE("A_INDICES");
2571
2572         WRITE_NODE_FIELD(lidx);
2573         WRITE_NODE_FIELD(uidx);
2574 }
2575
2576 static void
2577 _outA_Indirection(StringInfo str, const A_Indirection *node)
2578 {
2579         WRITE_NODE_TYPE("A_INDIRECTION");
2580
2581         WRITE_NODE_FIELD(arg);
2582         WRITE_NODE_FIELD(indirection);
2583 }
2584
2585 static void
2586 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
2587 {
2588         WRITE_NODE_TYPE("A_ARRAYEXPR");
2589
2590         WRITE_NODE_FIELD(elements);
2591         WRITE_LOCATION_FIELD(location);
2592 }
2593
2594 static void
2595 _outResTarget(StringInfo str, const ResTarget *node)
2596 {
2597         WRITE_NODE_TYPE("RESTARGET");
2598
2599         WRITE_STRING_FIELD(name);
2600         WRITE_NODE_FIELD(indirection);
2601         WRITE_NODE_FIELD(val);
2602         WRITE_LOCATION_FIELD(location);
2603 }
2604
2605 static void
2606 _outMultiAssignRef(StringInfo str, const MultiAssignRef *node)
2607 {
2608         WRITE_NODE_TYPE("MULTIASSIGNREF");
2609
2610         WRITE_NODE_FIELD(source);
2611         WRITE_INT_FIELD(colno);
2612         WRITE_INT_FIELD(ncolumns);
2613 }
2614
2615 static void
2616 _outSortBy(StringInfo str, const SortBy *node)
2617 {
2618         WRITE_NODE_TYPE("SORTBY");
2619
2620         WRITE_NODE_FIELD(node);
2621         WRITE_ENUM_FIELD(sortby_dir, SortByDir);
2622         WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
2623         WRITE_NODE_FIELD(useOp);
2624         WRITE_LOCATION_FIELD(location);
2625 }
2626
2627 static void
2628 _outWindowDef(StringInfo str, const WindowDef *node)
2629 {
2630         WRITE_NODE_TYPE("WINDOWDEF");
2631
2632         WRITE_STRING_FIELD(name);
2633         WRITE_STRING_FIELD(refname);
2634         WRITE_NODE_FIELD(partitionClause);
2635         WRITE_NODE_FIELD(orderClause);
2636         WRITE_INT_FIELD(frameOptions);
2637         WRITE_NODE_FIELD(startOffset);
2638         WRITE_NODE_FIELD(endOffset);
2639         WRITE_LOCATION_FIELD(location);
2640 }
2641
2642 static void
2643 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
2644 {
2645         WRITE_NODE_TYPE("RANGESUBSELECT");
2646
2647         WRITE_BOOL_FIELD(lateral);
2648         WRITE_NODE_FIELD(subquery);
2649         WRITE_NODE_FIELD(alias);
2650 }
2651
2652 static void
2653 _outRangeFunction(StringInfo str, const RangeFunction *node)
2654 {
2655         WRITE_NODE_TYPE("RANGEFUNCTION");
2656
2657         WRITE_BOOL_FIELD(lateral);
2658         WRITE_BOOL_FIELD(ordinality);
2659         WRITE_BOOL_FIELD(is_rowsfrom);
2660         WRITE_NODE_FIELD(functions);
2661         WRITE_NODE_FIELD(alias);
2662         WRITE_NODE_FIELD(coldeflist);
2663 }
2664
2665 static void
2666 _outConstraint(StringInfo str, const Constraint *node)
2667 {
2668         WRITE_NODE_TYPE("CONSTRAINT");
2669
2670         WRITE_STRING_FIELD(conname);
2671         WRITE_BOOL_FIELD(deferrable);
2672         WRITE_BOOL_FIELD(initdeferred);
2673         WRITE_LOCATION_FIELD(location);
2674
2675         appendStringInfoString(str, " :contype ");
2676         switch (node->contype)
2677         {
2678                 case CONSTR_NULL:
2679                         appendStringInfoString(str, "NULL");
2680                         break;
2681
2682                 case CONSTR_NOTNULL:
2683                         appendStringInfoString(str, "NOT_NULL");
2684                         break;
2685
2686                 case CONSTR_DEFAULT:
2687                         appendStringInfoString(str, "DEFAULT");
2688                         WRITE_NODE_FIELD(raw_expr);
2689                         WRITE_STRING_FIELD(cooked_expr);
2690                         break;
2691
2692                 case CONSTR_CHECK:
2693                         appendStringInfoString(str, "CHECK");
2694                         WRITE_BOOL_FIELD(is_no_inherit);
2695                         WRITE_NODE_FIELD(raw_expr);
2696                         WRITE_STRING_FIELD(cooked_expr);
2697                         break;
2698
2699                 case CONSTR_PRIMARY:
2700                         appendStringInfoString(str, "PRIMARY_KEY");
2701                         WRITE_NODE_FIELD(keys);
2702                         WRITE_NODE_FIELD(options);
2703                         WRITE_STRING_FIELD(indexname);
2704                         WRITE_STRING_FIELD(indexspace);
2705                         /* access_method and where_clause not currently used */
2706                         break;
2707
2708                 case CONSTR_UNIQUE:
2709                         appendStringInfoString(str, "UNIQUE");
2710                         WRITE_NODE_FIELD(keys);
2711                         WRITE_NODE_FIELD(options);
2712                         WRITE_STRING_FIELD(indexname);
2713                         WRITE_STRING_FIELD(indexspace);
2714                         /* access_method and where_clause not currently used */
2715                         break;
2716
2717                 case CONSTR_EXCLUSION:
2718                         appendStringInfoString(str, "EXCLUSION");
2719                         WRITE_NODE_FIELD(exclusions);
2720                         WRITE_NODE_FIELD(options);
2721                         WRITE_STRING_FIELD(indexname);
2722                         WRITE_STRING_FIELD(indexspace);
2723                         WRITE_STRING_FIELD(access_method);
2724                         WRITE_NODE_FIELD(where_clause);
2725                         break;
2726
2727                 case CONSTR_FOREIGN:
2728                         appendStringInfoString(str, "FOREIGN_KEY");
2729                         WRITE_NODE_FIELD(pktable);
2730                         WRITE_NODE_FIELD(fk_attrs);
2731                         WRITE_NODE_FIELD(pk_attrs);
2732                         WRITE_CHAR_FIELD(fk_matchtype);
2733                         WRITE_CHAR_FIELD(fk_upd_action);
2734                         WRITE_CHAR_FIELD(fk_del_action);
2735                         WRITE_NODE_FIELD(old_conpfeqop);
2736                         WRITE_OID_FIELD(old_pktable_oid);
2737                         WRITE_BOOL_FIELD(skip_validation);
2738                         WRITE_BOOL_FIELD(initially_valid);
2739                         break;
2740
2741                 case CONSTR_ATTR_DEFERRABLE:
2742                         appendStringInfoString(str, "ATTR_DEFERRABLE");
2743                         break;
2744
2745                 case CONSTR_ATTR_NOT_DEFERRABLE:
2746                         appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
2747                         break;
2748
2749                 case CONSTR_ATTR_DEFERRED:
2750                         appendStringInfoString(str, "ATTR_DEFERRED");
2751                         break;
2752
2753                 case CONSTR_ATTR_IMMEDIATE:
2754                         appendStringInfoString(str, "ATTR_IMMEDIATE");
2755                         break;
2756
2757                 default:
2758                         appendStringInfo(str, "<unrecognized_constraint %d>",
2759                                                          (int) node->contype);
2760                         break;
2761         }
2762 }
2763
2764
2765 /*
2766  * _outNode -
2767  *        converts a Node into ascii string and append it to 'str'
2768  */
2769 static void
2770 _outNode(StringInfo str, const void *obj)
2771 {
2772         if (obj == NULL)
2773                 appendStringInfoString(str, "<>");
2774         else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
2775                 _outList(str, obj);
2776         else if (IsA(obj, Integer) ||
2777                          IsA(obj, Float) ||
2778                          IsA(obj, String) ||
2779                          IsA(obj, BitString))
2780         {
2781                 /* nodeRead does not want to see { } around these! */
2782                 _outValue(str, obj);
2783         }
2784         else
2785         {
2786                 appendStringInfoChar(str, '{');
2787                 switch (nodeTag(obj))
2788                 {
2789                         case T_PlannedStmt:
2790                                 _outPlannedStmt(str, obj);
2791                                 break;
2792                         case T_Plan:
2793                                 _outPlan(str, obj);
2794                                 break;
2795                         case T_Result:
2796                                 _outResult(str, obj);
2797                                 break;
2798                         case T_ModifyTable:
2799                                 _outModifyTable(str, obj);
2800                                 break;
2801                         case T_Append:
2802                                 _outAppend(str, obj);
2803                                 break;
2804                         case T_MergeAppend:
2805                                 _outMergeAppend(str, obj);
2806                                 break;
2807                         case T_RecursiveUnion:
2808                                 _outRecursiveUnion(str, obj);
2809                                 break;
2810                         case T_BitmapAnd:
2811                                 _outBitmapAnd(str, obj);
2812                                 break;
2813                         case T_BitmapOr:
2814                                 _outBitmapOr(str, obj);
2815                                 break;
2816                         case T_Scan:
2817                                 _outScan(str, obj);
2818                                 break;
2819                         case T_SeqScan:
2820                                 _outSeqScan(str, obj);
2821                                 break;
2822                         case T_IndexScan:
2823                                 _outIndexScan(str, obj);
2824                                 break;
2825                         case T_IndexOnlyScan:
2826                                 _outIndexOnlyScan(str, obj);
2827                                 break;
2828                         case T_BitmapIndexScan:
2829                                 _outBitmapIndexScan(str, obj);
2830                                 break;
2831                         case T_BitmapHeapScan:
2832                                 _outBitmapHeapScan(str, obj);
2833                                 break;
2834                         case T_TidScan:
2835                                 _outTidScan(str, obj);
2836                                 break;
2837                         case T_SubqueryScan:
2838                                 _outSubqueryScan(str, obj);
2839                                 break;
2840                         case T_FunctionScan:
2841                                 _outFunctionScan(str, obj);
2842                                 break;
2843                         case T_ValuesScan:
2844                                 _outValuesScan(str, obj);
2845                                 break;
2846                         case T_CteScan:
2847                                 _outCteScan(str, obj);
2848                                 break;
2849                         case T_WorkTableScan:
2850                                 _outWorkTableScan(str, obj);
2851                                 break;
2852                         case T_ForeignScan:
2853                                 _outForeignScan(str, obj);
2854                                 break;
2855                         case T_Join:
2856                                 _outJoin(str, obj);
2857                                 break;
2858                         case T_NestLoop:
2859                                 _outNestLoop(str, obj);
2860                                 break;
2861                         case T_MergeJoin:
2862                                 _outMergeJoin(str, obj);
2863                                 break;
2864                         case T_HashJoin:
2865                                 _outHashJoin(str, obj);
2866                                 break;
2867                         case T_Agg:
2868                                 _outAgg(str, obj);
2869                                 break;
2870                         case T_WindowAgg:
2871                                 _outWindowAgg(str, obj);
2872                                 break;
2873                         case T_Group:
2874                                 _outGroup(str, obj);
2875                                 break;
2876                         case T_Material:
2877                                 _outMaterial(str, obj);
2878                                 break;
2879                         case T_Sort:
2880                                 _outSort(str, obj);
2881                                 break;
2882                         case T_Unique:
2883                                 _outUnique(str, obj);
2884                                 break;
2885                         case T_Hash:
2886                                 _outHash(str, obj);
2887                                 break;
2888                         case T_SetOp:
2889                                 _outSetOp(str, obj);
2890                                 break;
2891                         case T_LockRows:
2892                                 _outLockRows(str, obj);
2893                                 break;
2894                         case T_Limit:
2895                                 _outLimit(str, obj);
2896                                 break;
2897                         case T_NestLoopParam:
2898                                 _outNestLoopParam(str, obj);
2899                                 break;
2900                         case T_PlanRowMark:
2901                                 _outPlanRowMark(str, obj);
2902                                 break;
2903                         case T_PlanInvalItem:
2904                                 _outPlanInvalItem(str, obj);
2905                                 break;
2906                         case T_Alias:
2907                                 _outAlias(str, obj);
2908                                 break;
2909                         case T_RangeVar:
2910                                 _outRangeVar(str, obj);
2911                                 break;
2912                         case T_IntoClause:
2913                                 _outIntoClause(str, obj);
2914                                 break;
2915                         case T_Var:
2916                                 _outVar(str, obj);
2917                                 break;
2918                         case T_Const:
2919                                 _outConst(str, obj);
2920                                 break;
2921                         case T_Param:
2922                                 _outParam(str, obj);
2923                                 break;
2924                         case T_Aggref:
2925                                 _outAggref(str, obj);
2926                                 break;
2927                         case T_WindowFunc:
2928                                 _outWindowFunc(str, obj);
2929                                 break;
2930                         case T_ArrayRef:
2931                                 _outArrayRef(str, obj);
2932                                 break;
2933                         case T_FuncExpr:
2934                                 _outFuncExpr(str, obj);
2935                                 break;
2936                         case T_NamedArgExpr:
2937                                 _outNamedArgExpr(str, obj);
2938                                 break;
2939                         case T_OpExpr:
2940                                 _outOpExpr(str, obj);
2941                                 break;
2942                         case T_DistinctExpr:
2943                                 _outDistinctExpr(str, obj);
2944                                 break;
2945                         case T_NullIfExpr:
2946                                 _outNullIfExpr(str, obj);
2947                                 break;
2948                         case T_ScalarArrayOpExpr:
2949                                 _outScalarArrayOpExpr(str, obj);
2950                                 break;
2951                         case T_BoolExpr:
2952                                 _outBoolExpr(str, obj);
2953                                 break;
2954                         case T_SubLink:
2955                                 _outSubLink(str, obj);
2956                                 break;
2957                         case T_SubPlan:
2958                                 _outSubPlan(str, obj);
2959                                 break;
2960                         case T_AlternativeSubPlan:
2961                                 _outAlternativeSubPlan(str, obj);
2962                                 break;
2963                         case T_FieldSelect:
2964                                 _outFieldSelect(str, obj);
2965                                 break;
2966                         case T_FieldStore:
2967                                 _outFieldStore(str, obj);
2968                                 break;
2969                         case T_RelabelType:
2970                                 _outRelabelType(str, obj);
2971                                 break;
2972                         case T_CoerceViaIO:
2973                                 _outCoerceViaIO(str, obj);
2974                                 break;
2975                         case T_ArrayCoerceExpr:
2976                                 _outArrayCoerceExpr(str, obj);
2977                                 break;
2978                         case T_ConvertRowtypeExpr:
2979                                 _outConvertRowtypeExpr(str, obj);
2980                                 break;
2981                         case T_CollateExpr:
2982                                 _outCollateExpr(str, obj);
2983                                 break;
2984                         case T_CaseExpr:
2985                                 _outCaseExpr(str, obj);
2986                                 break;
2987                         case T_CaseWhen:
2988                                 _outCaseWhen(str, obj);
2989                                 break;
2990                         case T_CaseTestExpr:
2991                                 _outCaseTestExpr(str, obj);
2992                                 break;
2993                         case T_ArrayExpr:
2994                                 _outArrayExpr(str, obj);
2995                                 break;
2996                         case T_RowExpr:
2997                                 _outRowExpr(str, obj);
2998                                 break;
2999                         case T_RowCompareExpr:
3000                                 _outRowCompareExpr(str, obj);
3001                                 break;
3002                         case T_CoalesceExpr:
3003                                 _outCoalesceExpr(str, obj);
3004                                 break;
3005                         case T_MinMaxExpr:
3006                                 _outMinMaxExpr(str, obj);
3007                                 break;
3008                         case T_XmlExpr:
3009                                 _outXmlExpr(str, obj);
3010                                 break;
3011                         case T_NullTest:
3012                                 _outNullTest(str, obj);
3013                                 break;
3014                         case T_BooleanTest:
3015                                 _outBooleanTest(str, obj);
3016                                 break;
3017                         case T_CoerceToDomain:
3018                                 _outCoerceToDomain(str, obj);
3019                                 break;
3020                         case T_CoerceToDomainValue:
3021                                 _outCoerceToDomainValue(str, obj);
3022                                 break;
3023                         case T_SetToDefault:
3024                                 _outSetToDefault(str, obj);
3025                                 break;
3026                         case T_CurrentOfExpr:
3027                                 _outCurrentOfExpr(str, obj);
3028                                 break;
3029                         case T_TargetEntry:
3030                                 _outTargetEntry(str, obj);
3031                                 break;
3032                         case T_RangeTblRef:
3033                                 _outRangeTblRef(str, obj);
3034                                 break;
3035                         case T_JoinExpr:
3036                                 _outJoinExpr(str, obj);
3037                                 break;
3038                         case T_FromExpr:
3039                                 _outFromExpr(str, obj);
3040                                 break;
3041
3042                         case T_Path:
3043                                 _outPath(str, obj);
3044                                 break;
3045                         case T_IndexPath:
3046                                 _outIndexPath(str, obj);
3047                                 break;
3048                         case T_BitmapHeapPath:
3049                                 _outBitmapHeapPath(str, obj);
3050                                 break;
3051                         case T_BitmapAndPath:
3052                                 _outBitmapAndPath(str, obj);
3053                                 break;
3054                         case T_BitmapOrPath:
3055                                 _outBitmapOrPath(str, obj);
3056                                 break;
3057                         case T_TidPath:
3058                                 _outTidPath(str, obj);
3059                                 break;
3060                         case T_ForeignPath:
3061                                 _outForeignPath(str, obj);
3062                                 break;
3063                         case T_AppendPath:
3064                                 _outAppendPath(str, obj);
3065                                 break;
3066                         case T_MergeAppendPath:
3067                                 _outMergeAppendPath(str, obj);
3068                                 break;
3069                         case T_ResultPath:
3070                                 _outResultPath(str, obj);
3071                                 break;
3072                         case T_MaterialPath:
3073                                 _outMaterialPath(str, obj);
3074                                 break;
3075                         case T_UniquePath:
3076                                 _outUniquePath(str, obj);
3077                                 break;
3078                         case T_NestPath:
3079                                 _outNestPath(str, obj);
3080                                 break;
3081                         case T_MergePath:
3082                                 _outMergePath(str, obj);
3083                                 break;
3084                         case T_HashPath:
3085                                 _outHashPath(str, obj);
3086                                 break;
3087                         case T_PlannerGlobal:
3088                                 _outPlannerGlobal(str, obj);
3089                                 break;
3090                         case T_PlannerInfo:
3091                                 _outPlannerInfo(str, obj);
3092                                 break;
3093                         case T_RelOptInfo:
3094                                 _outRelOptInfo(str, obj);
3095                                 break;
3096                         case T_IndexOptInfo:
3097                                 _outIndexOptInfo(str, obj);
3098                                 break;
3099                         case T_EquivalenceClass:
3100                                 _outEquivalenceClass(str, obj);
3101                                 break;
3102                         case T_EquivalenceMember:
3103                                 _outEquivalenceMember(str, obj);
3104                                 break;
3105                         case T_PathKey:
3106                                 _outPathKey(str, obj);
3107                                 break;
3108                         case T_ParamPathInfo:
3109                                 _outParamPathInfo(str, obj);
3110                                 break;
3111                         case T_RestrictInfo:
3112                                 _outRestrictInfo(str, obj);
3113                                 break;
3114                         case T_PlaceHolderVar:
3115                                 _outPlaceHolderVar(str, obj);
3116                                 break;
3117                         case T_SpecialJoinInfo:
3118                                 _outSpecialJoinInfo(str, obj);
3119                                 break;
3120                         case T_LateralJoinInfo:
3121                                 _outLateralJoinInfo(str, obj);
3122                                 break;
3123                         case T_AppendRelInfo:
3124                                 _outAppendRelInfo(str, obj);
3125                                 break;
3126                         case T_PlaceHolderInfo:
3127                                 _outPlaceHolderInfo(str, obj);
3128                                 break;
3129                         case T_MinMaxAggInfo:
3130                                 _outMinMaxAggInfo(str, obj);
3131                                 break;
3132                         case T_PlannerParamItem:
3133                                 _outPlannerParamItem(str, obj);
3134                                 break;
3135
3136                         case T_CreateStmt:
3137                                 _outCreateStmt(str, obj);
3138                                 break;
3139                         case T_CreateForeignTableStmt:
3140                                 _outCreateForeignTableStmt(str, obj);
3141                                 break;
3142                         case T_ImportForeignSchemaStmt:
3143                                 _outImportForeignSchemaStmt(str, obj);
3144                                 break;
3145                         case T_IndexStmt:
3146                                 _outIndexStmt(str, obj);
3147                                 break;
3148                         case T_NotifyStmt:
3149                                 _outNotifyStmt(str, obj);
3150                                 break;
3151                         case T_DeclareCursorStmt:
3152                                 _outDeclareCursorStmt(str, obj);
3153                                 break;
3154                         case T_SelectStmt:
3155                                 _outSelectStmt(str, obj);
3156                                 break;
3157                         case T_ColumnDef:
3158                                 _outColumnDef(str, obj);
3159                                 break;
3160                         case T_TypeName:
3161                                 _outTypeName(str, obj);
3162                                 break;
3163                         case T_TypeCast:
3164                                 _outTypeCast(str, obj);
3165                                 break;
3166                         case T_CollateClause:
3167                                 _outCollateClause(str, obj);
3168                                 break;
3169                         case T_IndexElem:
3170                                 _outIndexElem(str, obj);
3171                                 break;
3172                         case T_Query:
3173                                 _outQuery(str, obj);
3174                                 break;
3175                         case T_WithCheckOption:
3176                                 _outWithCheckOption(str, obj);
3177                                 break;
3178                         case T_SortGroupClause:
3179                                 _outSortGroupClause(str, obj);
3180                                 break;
3181                         case T_WindowClause:
3182                                 _outWindowClause(str, obj);
3183                                 break;
3184                         case T_RowMarkClause:
3185                                 _outRowMarkClause(str, obj);
3186                                 break;
3187                         case T_WithClause:
3188                                 _outWithClause(str, obj);
3189                                 break;
3190                         case T_CommonTableExpr:
3191                                 _outCommonTableExpr(str, obj);
3192                                 break;
3193                         case T_SetOperationStmt:
3194                                 _outSetOperationStmt(str, obj);
3195                                 break;
3196                         case T_RangeTblEntry:
3197                                 _outRangeTblEntry(str, obj);
3198                                 break;
3199                         case T_RangeTblFunction:
3200                                 _outRangeTblFunction(str, obj);
3201                                 break;
3202                         case T_A_Expr:
3203                                 _outAExpr(str, obj);
3204                                 break;
3205                         case T_ColumnRef:
3206                                 _outColumnRef(str, obj);
3207                                 break;
3208                         case T_ParamRef:
3209                                 _outParamRef(str, obj);
3210                                 break;
3211                         case T_A_Const:
3212                                 _outAConst(str, obj);
3213                                 break;
3214                         case T_A_Star:
3215                                 _outA_Star(str, obj);
3216                                 break;
3217                         case T_A_Indices:
3218                                 _outA_Indices(str, obj);
3219                                 break;
3220                         case T_A_Indirection:
3221                                 _outA_Indirection(str, obj);
3222                                 break;
3223                         case T_A_ArrayExpr:
3224                                 _outA_ArrayExpr(str, obj);
3225                                 break;
3226                         case T_ResTarget:
3227                                 _outResTarget(str, obj);
3228                                 break;
3229                         case T_MultiAssignRef:
3230                                 _outMultiAssignRef(str, obj);
3231                                 break;
3232                         case T_SortBy:
3233                                 _outSortBy(str, obj);
3234                                 break;
3235                         case T_WindowDef:
3236                                 _outWindowDef(str, obj);
3237                                 break;
3238                         case T_RangeSubselect:
3239                                 _outRangeSubselect(str, obj);
3240                                 break;
3241                         case T_RangeFunction:
3242                                 _outRangeFunction(str, obj);
3243                                 break;
3244                         case T_Constraint:
3245                                 _outConstraint(str, obj);
3246                                 break;
3247                         case T_FuncCall:
3248                                 _outFuncCall(str, obj);
3249                                 break;
3250                         case T_DefElem:
3251                                 _outDefElem(str, obj);
3252                                 break;
3253                         case T_TableLikeClause:
3254                                 _outTableLikeClause(str, obj);
3255                                 break;
3256                         case T_LockingClause:
3257                                 _outLockingClause(str, obj);
3258                                 break;
3259                         case T_XmlSerialize:
3260                                 _outXmlSerialize(str, obj);
3261                                 break;
3262
3263                         default:
3264
3265                                 /*
3266                                  * This should be an ERROR, but it's too useful to be able to
3267                                  * dump structures that _outNode only understands part of.
3268                                  */
3269                                 elog(WARNING, "could not dump unrecognized node type: %d",
3270                                          (int) nodeTag(obj));
3271                                 break;
3272                 }
3273                 appendStringInfoChar(str, '}');
3274         }
3275 }
3276
3277 /*
3278  * nodeToString -
3279  *         returns the ascii representation of the Node as a palloc'd string
3280  */
3281 char *
3282 nodeToString(const void *obj)
3283 {
3284         StringInfoData str;
3285
3286         /* see stringinfo.h for an explanation of this maneuver */
3287         initStringInfo(&str);
3288         _outNode(&str, obj);
3289         return str.data;
3290 }