PostgreSQL Source Code  git master
outfuncs.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * outfuncs.c
4  * Output functions for Postgres tree nodes.
5  *
6  * Portions Copyright (c) 1996-2022, 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). In addition, plan nodes should have input and
17  * output functions so that they can be sent to parallel workers.
18  *
19  * For use in debugging, we also provide output functions for nodes
20  * that appear in raw parsetrees and planner Paths. These node types
21  * need not have input functions. Output support for raw parsetrees
22  * is somewhat incomplete, too; in particular, utility statements are
23  * almost entirely unsupported. We try to support everything that can
24  * appear in a raw SELECT, though.
25  *
26  *-------------------------------------------------------------------------
27  */
28 #include "postgres.h"
29 
30 #include <ctype.h>
31 
32 #include "lib/stringinfo.h"
33 #include "miscadmin.h"
34 #include "nodes/extensible.h"
35 #include "nodes/pathnodes.h"
36 #include "nodes/plannodes.h"
37 #include "utils/datum.h"
38 #include "utils/rel.h"
39 
40 static void outChar(StringInfo str, char c);
41 
42 
43 /*
44  * Macros to simplify output of different kinds of fields. Use these
45  * wherever possible to reduce the chance for silly typos. Note that these
46  * hard-wire conventions about the names of the local variables in an Out
47  * routine.
48  */
49 
50 /* Write the label for the node type */
51 #define WRITE_NODE_TYPE(nodelabel) \
52  appendStringInfoString(str, nodelabel)
53 
54 /* Write an integer field (anything written as ":fldname %d") */
55 #define WRITE_INT_FIELD(fldname) \
56  appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
57 
58 /* Write an unsigned integer field (anything written as ":fldname %u") */
59 #define WRITE_UINT_FIELD(fldname) \
60  appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
61 
62 /* Write an unsigned integer field (anything written with UINT64_FORMAT) */
63 #define WRITE_UINT64_FIELD(fldname) \
64  appendStringInfo(str, " :" CppAsString(fldname) " " UINT64_FORMAT, \
65  node->fldname)
66 
67 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
68 #define WRITE_OID_FIELD(fldname) \
69  appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
70 
71 /* Write a long-integer field */
72 #define WRITE_LONG_FIELD(fldname) \
73  appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
74 
75 /* Write a char field (ie, one ascii character) */
76 #define WRITE_CHAR_FIELD(fldname) \
77  (appendStringInfo(str, " :" CppAsString(fldname) " "), \
78  outChar(str, node->fldname))
79 
80 /* Write an enumerated-type field as an integer code */
81 #define WRITE_ENUM_FIELD(fldname, enumtype) \
82  appendStringInfo(str, " :" CppAsString(fldname) " %d", \
83  (int) node->fldname)
84 
85 /* Write a float field --- caller must give format to define precision */
86 #define WRITE_FLOAT_FIELD(fldname,format) \
87  appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
88 
89 /* Write a boolean field */
90 #define WRITE_BOOL_FIELD(fldname) \
91  appendStringInfo(str, " :" CppAsString(fldname) " %s", \
92  booltostr(node->fldname))
93 
94 /* Write a character-string (possibly NULL) field */
95 #define WRITE_STRING_FIELD(fldname) \
96  (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
97  outToken(str, node->fldname))
98 
99 /* Write a parse location field (actually same as INT case) */
100 #define WRITE_LOCATION_FIELD(fldname) \
101  appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
102 
103 /* Write a Node field */
104 #define WRITE_NODE_FIELD(fldname) \
105  (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
106  outNode(str, node->fldname))
107 
108 /* Write a bitmapset field */
109 #define WRITE_BITMAPSET_FIELD(fldname) \
110  (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
111  outBitmapset(str, node->fldname))
112 
113 #define WRITE_ATTRNUMBER_ARRAY(fldname, len) \
114  do { \
115  appendStringInfoString(str, " :" CppAsString(fldname) " "); \
116  for (int i = 0; i < len; i++) \
117  appendStringInfo(str, " %d", node->fldname[i]); \
118  } while(0)
119 
120 #define WRITE_OID_ARRAY(fldname, len) \
121  do { \
122  appendStringInfoString(str, " :" CppAsString(fldname) " "); \
123  for (int i = 0; i < len; i++) \
124  appendStringInfo(str, " %u", node->fldname[i]); \
125  } while(0)
126 
127 /*
128  * This macro supports the case that the field is NULL. For the other array
129  * macros, that is currently not needed.
130  */
131 #define WRITE_INDEX_ARRAY(fldname, len) \
132  do { \
133  appendStringInfoString(str, " :" CppAsString(fldname) " "); \
134  if (node->fldname) \
135  for (int i = 0; i < len; i++) \
136  appendStringInfo(str, " %u", node->fldname[i]); \
137  else \
138  appendStringInfoString(str, "<>"); \
139  } while(0)
140 
141 #define WRITE_INT_ARRAY(fldname, len) \
142  do { \
143  appendStringInfoString(str, " :" CppAsString(fldname) " "); \
144  for (int i = 0; i < len; i++) \
145  appendStringInfo(str, " %d", node->fldname[i]); \
146  } while(0)
147 
148 #define WRITE_BOOL_ARRAY(fldname, len) \
149  do { \
150  appendStringInfoString(str, " :" CppAsString(fldname) " "); \
151  for (int i = 0; i < len; i++) \
152  appendStringInfo(str, " %s", booltostr(node->fldname[i])); \
153  } while(0)
154 
155 
156 #define booltostr(x) ((x) ? "true" : "false")
157 
158 
159 /*
160  * outToken
161  * Convert an ordinary string (eg, an identifier) into a form that
162  * will be decoded back to a plain token by read.c's functions.
163  *
164  * If a null or empty string is given, it is encoded as "<>".
165  */
166 void
167 outToken(StringInfo str, const char *s)
168 {
169  if (s == NULL || *s == '\0')
170  {
172  return;
173  }
174 
175  /*
176  * Look for characters or patterns that are treated specially by read.c
177  * (either in pg_strtok() or in nodeRead()), and therefore need a
178  * protective backslash.
179  */
180  /* These characters only need to be quoted at the start of the string */
181  if (*s == '<' ||
182  *s == '"' ||
183  isdigit((unsigned char) *s) ||
184  ((*s == '+' || *s == '-') &&
185  (isdigit((unsigned char) s[1]) || s[1] == '.')))
186  appendStringInfoChar(str, '\\');
187  while (*s)
188  {
189  /* These chars must be backslashed anywhere in the string */
190  if (*s == ' ' || *s == '\n' || *s == '\t' ||
191  *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
192  *s == '\\')
193  appendStringInfoChar(str, '\\');
194  appendStringInfoChar(str, *s++);
195  }
196 }
197 
198 /*
199  * Convert one char. Goes through outToken() so that special characters are
200  * escaped.
201  */
202 static void
204 {
205  char in[2];
206 
207  in[0] = c;
208  in[1] = '\0';
209 
210  outToken(str, in);
211 }
212 
213 static void
215 {
216  const ListCell *lc;
217 
219 
220  if (IsA(node, IntList))
222  else if (IsA(node, OidList))
224 
225  foreach(lc, node)
226  {
227  /*
228  * For the sake of backward compatibility, we emit a slightly
229  * different whitespace format for lists of nodes vs. other types of
230  * lists. XXX: is this necessary?
231  */
232  if (IsA(node, List))
233  {
234  outNode(str, lfirst(lc));
235  if (lnext(node, lc))
237  }
238  else if (IsA(node, IntList))
239  appendStringInfo(str, " %d", lfirst_int(lc));
240  else if (IsA(node, OidList))
241  appendStringInfo(str, " %u", lfirst_oid(lc));
242  else
243  elog(ERROR, "unrecognized list node type: %d",
244  (int) node->type);
245  }
246 
248 }
249 
250 /*
251  * outBitmapset -
252  * converts a bitmap set of integers
253  *
254  * Note: the output format is "(b int int ...)", similar to an integer List.
255  */
256 void
258 {
259  int x;
260 
263  x = -1;
264  while ((x = bms_next_member(bms, x)) >= 0)
265  appendStringInfo(str, " %d", x);
267 }
268 
269 /*
270  * Print the value of a Datum given its type.
271  */
272 void
273 outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
274 {
275  Size length,
276  i;
277  char *s;
278 
279  length = datumGetSize(value, typbyval, typlen);
280 
281  if (typbyval)
282  {
283  s = (char *) (&value);
284  appendStringInfo(str, "%u [ ", (unsigned int) length);
285  for (i = 0; i < (Size) sizeof(Datum); i++)
286  appendStringInfo(str, "%d ", (int) (s[i]));
288  }
289  else
290  {
291  s = (char *) DatumGetPointer(value);
292  if (!PointerIsValid(s))
293  appendStringInfoString(str, "0 [ ]");
294  else
295  {
296  appendStringInfo(str, "%u [ ", (unsigned int) length);
297  for (i = 0; i < length; i++)
298  appendStringInfo(str, "%d ", (int) (s[i]));
300  }
301  }
302 }
303 
304 
305 /*
306  * Stuff from plannodes.h
307  */
308 
309 static void
311 {
312  WRITE_NODE_TYPE("PLANNEDSTMT");
313 
314  WRITE_ENUM_FIELD(commandType, CmdType);
315  WRITE_UINT64_FIELD(queryId);
316  WRITE_BOOL_FIELD(hasReturning);
317  WRITE_BOOL_FIELD(hasModifyingCTE);
318  WRITE_BOOL_FIELD(canSetTag);
319  WRITE_BOOL_FIELD(transientPlan);
320  WRITE_BOOL_FIELD(dependsOnRole);
321  WRITE_BOOL_FIELD(parallelModeNeeded);
322  WRITE_INT_FIELD(jitFlags);
323  WRITE_NODE_FIELD(planTree);
324  WRITE_NODE_FIELD(rtable);
325  WRITE_NODE_FIELD(resultRelations);
326  WRITE_NODE_FIELD(appendRelations);
327  WRITE_NODE_FIELD(subplans);
328  WRITE_BITMAPSET_FIELD(rewindPlanIDs);
329  WRITE_NODE_FIELD(rowMarks);
330  WRITE_NODE_FIELD(relationOids);
331  WRITE_NODE_FIELD(invalItems);
332  WRITE_NODE_FIELD(paramExecTypes);
333  WRITE_NODE_FIELD(utilityStmt);
334  WRITE_LOCATION_FIELD(stmt_location);
335  WRITE_INT_FIELD(stmt_len);
336 }
337 
338 /*
339  * print the basic stuff of all nodes that inherit from Plan
340  */
341 static void
343 {
344  WRITE_FLOAT_FIELD(startup_cost, "%.2f");
345  WRITE_FLOAT_FIELD(total_cost, "%.2f");
346  WRITE_FLOAT_FIELD(plan_rows, "%.0f");
347  WRITE_INT_FIELD(plan_width);
348  WRITE_BOOL_FIELD(parallel_aware);
349  WRITE_BOOL_FIELD(parallel_safe);
350  WRITE_BOOL_FIELD(async_capable);
351  WRITE_INT_FIELD(plan_node_id);
352  WRITE_NODE_FIELD(targetlist);
353  WRITE_NODE_FIELD(qual);
354  WRITE_NODE_FIELD(lefttree);
355  WRITE_NODE_FIELD(righttree);
356  WRITE_NODE_FIELD(initPlan);
357  WRITE_BITMAPSET_FIELD(extParam);
358  WRITE_BITMAPSET_FIELD(allParam);
359 }
360 
361 /*
362  * print the basic stuff of all nodes that inherit from Scan
363  */
364 static void
366 {
367  _outPlanInfo(str, (const Plan *) node);
368 
369  WRITE_UINT_FIELD(scanrelid);
370 }
371 
372 /*
373  * print the basic stuff of all nodes that inherit from Join
374  */
375 static void
377 {
378  _outPlanInfo(str, (const Plan *) node);
379 
380  WRITE_ENUM_FIELD(jointype, JoinType);
381  WRITE_BOOL_FIELD(inner_unique);
382  WRITE_NODE_FIELD(joinqual);
383 }
384 
385 
386 static void
388 {
389  WRITE_NODE_TYPE("PLAN");
390 
391  _outPlanInfo(str, (const Plan *) node);
392 }
393 
394 static void
396 {
397  WRITE_NODE_TYPE("RESULT");
398 
399  _outPlanInfo(str, (const Plan *) node);
400 
401  WRITE_NODE_FIELD(resconstantqual);
402 }
403 
404 static void
406 {
407  WRITE_NODE_TYPE("PROJECTSET");
408 
409  _outPlanInfo(str, (const Plan *) node);
410 }
411 
412 static void
414 {
415  WRITE_NODE_TYPE("MODIFYTABLE");
416 
417  _outPlanInfo(str, (const Plan *) node);
418 
419  WRITE_ENUM_FIELD(operation, CmdType);
420  WRITE_BOOL_FIELD(canSetTag);
421  WRITE_UINT_FIELD(nominalRelation);
422  WRITE_UINT_FIELD(rootRelation);
423  WRITE_BOOL_FIELD(partColsUpdated);
424  WRITE_NODE_FIELD(resultRelations);
425  WRITE_NODE_FIELD(updateColnosLists);
426  WRITE_NODE_FIELD(withCheckOptionLists);
427  WRITE_NODE_FIELD(returningLists);
428  WRITE_NODE_FIELD(fdwPrivLists);
429  WRITE_BITMAPSET_FIELD(fdwDirectModifyPlans);
430  WRITE_NODE_FIELD(rowMarks);
431  WRITE_INT_FIELD(epqParam);
432  WRITE_ENUM_FIELD(onConflictAction, OnConflictAction);
433  WRITE_NODE_FIELD(arbiterIndexes);
434  WRITE_NODE_FIELD(onConflictSet);
435  WRITE_NODE_FIELD(onConflictCols);
436  WRITE_NODE_FIELD(onConflictWhere);
437  WRITE_UINT_FIELD(exclRelRTI);
438  WRITE_NODE_FIELD(exclRelTlist);
439  WRITE_NODE_FIELD(mergeActionLists);
440 }
441 
442 static void
444 {
445  WRITE_NODE_TYPE("APPEND");
446 
447  _outPlanInfo(str, (const Plan *) node);
448 
449  WRITE_BITMAPSET_FIELD(apprelids);
450  WRITE_NODE_FIELD(appendplans);
451  WRITE_INT_FIELD(nasyncplans);
452  WRITE_INT_FIELD(first_partial_plan);
453  WRITE_NODE_FIELD(part_prune_info);
454 }
455 
456 static void
458 {
459  WRITE_NODE_TYPE("MERGEAPPEND");
460 
461  _outPlanInfo(str, (const Plan *) node);
462 
463  WRITE_BITMAPSET_FIELD(apprelids);
464  WRITE_NODE_FIELD(mergeplans);
465  WRITE_INT_FIELD(numCols);
466  WRITE_ATTRNUMBER_ARRAY(sortColIdx, node->numCols);
467  WRITE_OID_ARRAY(sortOperators, node->numCols);
468  WRITE_OID_ARRAY(collations, node->numCols);
469  WRITE_BOOL_ARRAY(nullsFirst, node->numCols);
470  WRITE_NODE_FIELD(part_prune_info);
471 }
472 
473 static void
475 {
476  WRITE_NODE_TYPE("RECURSIVEUNION");
477 
478  _outPlanInfo(str, (const Plan *) node);
479 
480  WRITE_INT_FIELD(wtParam);
481  WRITE_INT_FIELD(numCols);
482  WRITE_ATTRNUMBER_ARRAY(dupColIdx, node->numCols);
483  WRITE_OID_ARRAY(dupOperators, node->numCols);
484  WRITE_OID_ARRAY(dupCollations, node->numCols);
485  WRITE_LONG_FIELD(numGroups);
486 }
487 
488 static void
490 {
491  WRITE_NODE_TYPE("BITMAPAND");
492 
493  _outPlanInfo(str, (const Plan *) node);
494 
495  WRITE_NODE_FIELD(bitmapplans);
496 }
497 
498 static void
500 {
501  WRITE_NODE_TYPE("BITMAPOR");
502 
503  _outPlanInfo(str, (const Plan *) node);
504 
505  WRITE_BOOL_FIELD(isshared);
506  WRITE_NODE_FIELD(bitmapplans);
507 }
508 
509 static void
511 {
512  WRITE_NODE_TYPE("GATHER");
513 
514  _outPlanInfo(str, (const Plan *) node);
515 
516  WRITE_INT_FIELD(num_workers);
517  WRITE_INT_FIELD(rescan_param);
518  WRITE_BOOL_FIELD(single_copy);
519  WRITE_BOOL_FIELD(invisible);
520  WRITE_BITMAPSET_FIELD(initParam);
521 }
522 
523 static void
525 {
526  WRITE_NODE_TYPE("GATHERMERGE");
527 
528  _outPlanInfo(str, (const Plan *) node);
529 
530  WRITE_INT_FIELD(num_workers);
531  WRITE_INT_FIELD(rescan_param);
532  WRITE_INT_FIELD(numCols);
533  WRITE_ATTRNUMBER_ARRAY(sortColIdx, node->numCols);
534  WRITE_OID_ARRAY(sortOperators, node->numCols);
535  WRITE_OID_ARRAY(collations, node->numCols);
536  WRITE_BOOL_ARRAY(nullsFirst, node->numCols);
537  WRITE_BITMAPSET_FIELD(initParam);
538 }
539 
540 static void
542 {
543  WRITE_NODE_TYPE("SCAN");
544 
545  _outScanInfo(str, node);
546 }
547 
548 static void
550 {
551  WRITE_NODE_TYPE("SEQSCAN");
552 
553  _outScanInfo(str, (const Scan *) node);
554 }
555 
556 static void
558 {
559  WRITE_NODE_TYPE("SAMPLESCAN");
560 
561  _outScanInfo(str, (const Scan *) node);
562 
563  WRITE_NODE_FIELD(tablesample);
564 }
565 
566 static void
568 {
569  WRITE_NODE_TYPE("INDEXSCAN");
570 
571  _outScanInfo(str, (const Scan *) node);
572 
573  WRITE_OID_FIELD(indexid);
574  WRITE_NODE_FIELD(indexqual);
575  WRITE_NODE_FIELD(indexqualorig);
576  WRITE_NODE_FIELD(indexorderby);
577  WRITE_NODE_FIELD(indexorderbyorig);
578  WRITE_NODE_FIELD(indexorderbyops);
579  WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
580 }
581 
582 static void
584 {
585  WRITE_NODE_TYPE("INDEXONLYSCAN");
586 
587  _outScanInfo(str, (const Scan *) node);
588 
589  WRITE_OID_FIELD(indexid);
590  WRITE_NODE_FIELD(indexqual);
591  WRITE_NODE_FIELD(recheckqual);
592  WRITE_NODE_FIELD(indexorderby);
593  WRITE_NODE_FIELD(indextlist);
594  WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
595 }
596 
597 static void
599 {
600  WRITE_NODE_TYPE("BITMAPINDEXSCAN");
601 
602  _outScanInfo(str, (const Scan *) node);
603 
604  WRITE_OID_FIELD(indexid);
605  WRITE_BOOL_FIELD(isshared);
606  WRITE_NODE_FIELD(indexqual);
607  WRITE_NODE_FIELD(indexqualorig);
608 }
609 
610 static void
612 {
613  WRITE_NODE_TYPE("BITMAPHEAPSCAN");
614 
615  _outScanInfo(str, (const Scan *) node);
616 
617  WRITE_NODE_FIELD(bitmapqualorig);
618 }
619 
620 static void
622 {
623  WRITE_NODE_TYPE("TIDSCAN");
624 
625  _outScanInfo(str, (const Scan *) node);
626 
627  WRITE_NODE_FIELD(tidquals);
628 }
629 
630 static void
632 {
633  WRITE_NODE_TYPE("TIDRANGESCAN");
634 
635  _outScanInfo(str, (const Scan *) node);
636 
637  WRITE_NODE_FIELD(tidrangequals);
638 }
639 
640 static void
642 {
643  WRITE_NODE_TYPE("SUBQUERYSCAN");
644 
645  _outScanInfo(str, (const Scan *) node);
646 
647  WRITE_NODE_FIELD(subplan);
649 }
650 
651 static void
653 {
654  WRITE_NODE_TYPE("FUNCTIONSCAN");
655 
656  _outScanInfo(str, (const Scan *) node);
657 
659  WRITE_BOOL_FIELD(funcordinality);
660 }
661 
662 static void
664 {
665  WRITE_NODE_TYPE("TABLEFUNCSCAN");
666 
667  _outScanInfo(str, (const Scan *) node);
668 
669  WRITE_NODE_FIELD(tablefunc);
670 }
671 
672 static void
674 {
675  WRITE_NODE_TYPE("VALUESSCAN");
676 
677  _outScanInfo(str, (const Scan *) node);
678 
679  WRITE_NODE_FIELD(values_lists);
680 }
681 
682 static void
684 {
685  WRITE_NODE_TYPE("CTESCAN");
686 
687  _outScanInfo(str, (const Scan *) node);
688 
689  WRITE_INT_FIELD(ctePlanId);
690  WRITE_INT_FIELD(cteParam);
691 }
692 
693 static void
695 {
696  WRITE_NODE_TYPE("NAMEDTUPLESTORESCAN");
697 
698  _outScanInfo(str, (const Scan *) node);
699 
700  WRITE_STRING_FIELD(enrname);
701 }
702 
703 static void
705 {
706  WRITE_NODE_TYPE("WORKTABLESCAN");
707 
708  _outScanInfo(str, (const Scan *) node);
709 
710  WRITE_INT_FIELD(wtParam);
711 }
712 
713 static void
715 {
716  WRITE_NODE_TYPE("FOREIGNSCAN");
717 
718  _outScanInfo(str, (const Scan *) node);
719 
720  WRITE_ENUM_FIELD(operation, CmdType);
721  WRITE_UINT_FIELD(resultRelation);
722  WRITE_OID_FIELD(fs_server);
723  WRITE_NODE_FIELD(fdw_exprs);
724  WRITE_NODE_FIELD(fdw_private);
725  WRITE_NODE_FIELD(fdw_scan_tlist);
726  WRITE_NODE_FIELD(fdw_recheck_quals);
727  WRITE_BITMAPSET_FIELD(fs_relids);
728  WRITE_BOOL_FIELD(fsSystemCol);
729 }
730 
731 static void
733 {
734  WRITE_NODE_TYPE("CUSTOMSCAN");
735 
736  _outScanInfo(str, (const Scan *) node);
737 
738  WRITE_UINT_FIELD(flags);
739  WRITE_NODE_FIELD(custom_plans);
740  WRITE_NODE_FIELD(custom_exprs);
741  WRITE_NODE_FIELD(custom_private);
742  WRITE_NODE_FIELD(custom_scan_tlist);
743  WRITE_BITMAPSET_FIELD(custom_relids);
744  /* CustomName is a key to lookup CustomScanMethods */
745  appendStringInfoString(str, " :methods ");
746  outToken(str, node->methods->CustomName);
747 }
748 
749 static void
751 {
752  WRITE_NODE_TYPE("JOIN");
753 
754  _outJoinPlanInfo(str, (const Join *) node);
755 }
756 
757 static void
759 {
760  WRITE_NODE_TYPE("NESTLOOP");
761 
762  _outJoinPlanInfo(str, (const Join *) node);
763 
764  WRITE_NODE_FIELD(nestParams);
765 }
766 
767 static void
769 {
770  int numCols;
771 
772  WRITE_NODE_TYPE("MERGEJOIN");
773 
774  _outJoinPlanInfo(str, (const Join *) node);
775 
776  WRITE_BOOL_FIELD(skip_mark_restore);
777  WRITE_NODE_FIELD(mergeclauses);
778 
779  numCols = list_length(node->mergeclauses);
780 
781  WRITE_OID_ARRAY(mergeFamilies, numCols);
782  WRITE_OID_ARRAY(mergeCollations, numCols);
783  WRITE_INT_ARRAY(mergeStrategies, numCols);
784  WRITE_BOOL_ARRAY(mergeNullsFirst, numCols);
785 }
786 
787 static void
789 {
790  WRITE_NODE_TYPE("HASHJOIN");
791 
792  _outJoinPlanInfo(str, (const Join *) node);
793 
794  WRITE_NODE_FIELD(hashclauses);
795  WRITE_NODE_FIELD(hashoperators);
796  WRITE_NODE_FIELD(hashcollations);
797  WRITE_NODE_FIELD(hashkeys);
798 }
799 
800 static void
801 _outAgg(StringInfo str, const Agg *node)
802 {
803  WRITE_NODE_TYPE("AGG");
804 
805  _outPlanInfo(str, (const Plan *) node);
806 
807  WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
808  WRITE_ENUM_FIELD(aggsplit, AggSplit);
809  WRITE_INT_FIELD(numCols);
810  WRITE_ATTRNUMBER_ARRAY(grpColIdx, node->numCols);
811  WRITE_OID_ARRAY(grpOperators, node->numCols);
812  WRITE_OID_ARRAY(grpCollations, node->numCols);
813  WRITE_LONG_FIELD(numGroups);
814  WRITE_UINT64_FIELD(transitionSpace);
815  WRITE_BITMAPSET_FIELD(aggParams);
816  WRITE_NODE_FIELD(groupingSets);
817  WRITE_NODE_FIELD(chain);
818 }
819 
820 static void
822 {
823  WRITE_NODE_TYPE("WINDOWAGG");
824 
825  _outPlanInfo(str, (const Plan *) node);
826 
827  WRITE_UINT_FIELD(winref);
828  WRITE_INT_FIELD(partNumCols);
829  WRITE_ATTRNUMBER_ARRAY(partColIdx, node->partNumCols);
830  WRITE_OID_ARRAY(partOperators, node->partNumCols);
831  WRITE_OID_ARRAY(partCollations, node->partNumCols);
832  WRITE_INT_FIELD(ordNumCols);
833  WRITE_ATTRNUMBER_ARRAY(ordColIdx, node->ordNumCols);
834  WRITE_OID_ARRAY(ordOperators, node->ordNumCols);
835  WRITE_OID_ARRAY(ordCollations, node->ordNumCols);
836  WRITE_INT_FIELD(frameOptions);
837  WRITE_NODE_FIELD(startOffset);
838  WRITE_NODE_FIELD(endOffset);
839  WRITE_NODE_FIELD(runCondition);
840  WRITE_NODE_FIELD(runConditionOrig);
841  WRITE_OID_FIELD(startInRangeFunc);
842  WRITE_OID_FIELD(endInRangeFunc);
843  WRITE_OID_FIELD(inRangeColl);
844  WRITE_BOOL_FIELD(inRangeAsc);
845  WRITE_BOOL_FIELD(inRangeNullsFirst);
846  WRITE_BOOL_FIELD(topWindow);
847 }
848 
849 static void
851 {
852  WRITE_NODE_TYPE("GROUP");
853 
854  _outPlanInfo(str, (const Plan *) node);
855 
856  WRITE_INT_FIELD(numCols);
857  WRITE_ATTRNUMBER_ARRAY(grpColIdx, node->numCols);
858  WRITE_OID_ARRAY(grpOperators, node->numCols);
859  WRITE_OID_ARRAY(grpCollations, node->numCols);
860 }
861 
862 static void
864 {
865  WRITE_NODE_TYPE("MATERIAL");
866 
867  _outPlanInfo(str, (const Plan *) node);
868 }
869 
870 static void
872 {
873  WRITE_NODE_TYPE("MEMOIZE");
874 
875  _outPlanInfo(str, (const Plan *) node);
876 
877  WRITE_INT_FIELD(numKeys);
878  WRITE_OID_ARRAY(hashOperators, node->numKeys);
879  WRITE_OID_ARRAY(collations, node->numKeys);
880  WRITE_NODE_FIELD(param_exprs);
881  WRITE_BOOL_FIELD(singlerow);
882  WRITE_BOOL_FIELD(binary_mode);
883  WRITE_UINT_FIELD(est_entries);
884  WRITE_BITMAPSET_FIELD(keyparamids);
885 }
886 
887 static void
889 {
890  _outPlanInfo(str, (const Plan *) node);
891 
892  WRITE_INT_FIELD(numCols);
893  WRITE_ATTRNUMBER_ARRAY(sortColIdx, node->numCols);
894  WRITE_OID_ARRAY(sortOperators, node->numCols);
895  WRITE_OID_ARRAY(collations, node->numCols);
896  WRITE_BOOL_ARRAY(nullsFirst, node->numCols);
897 }
898 
899 static void
901 {
902  WRITE_NODE_TYPE("SORT");
903 
904  _outSortInfo(str, node);
905 }
906 
907 static void
909 {
910  WRITE_NODE_TYPE("INCREMENTALSORT");
911 
912  _outSortInfo(str, (const Sort *) node);
913 
914  WRITE_INT_FIELD(nPresortedCols);
915 }
916 
917 static void
919 {
920  WRITE_NODE_TYPE("UNIQUE");
921 
922  _outPlanInfo(str, (const Plan *) node);
923 
924  WRITE_INT_FIELD(numCols);
925  WRITE_ATTRNUMBER_ARRAY(uniqColIdx, node->numCols);
926  WRITE_OID_ARRAY(uniqOperators, node->numCols);
927  WRITE_OID_ARRAY(uniqCollations, node->numCols);
928 }
929 
930 static void
932 {
933  WRITE_NODE_TYPE("HASH");
934 
935  _outPlanInfo(str, (const Plan *) node);
936 
937  WRITE_NODE_FIELD(hashkeys);
938  WRITE_OID_FIELD(skewTable);
939  WRITE_INT_FIELD(skewColumn);
940  WRITE_BOOL_FIELD(skewInherit);
941  WRITE_FLOAT_FIELD(rows_total, "%.0f");
942 }
943 
944 static void
946 {
947  WRITE_NODE_TYPE("SETOP");
948 
949  _outPlanInfo(str, (const Plan *) node);
950 
952  WRITE_ENUM_FIELD(strategy, SetOpStrategy);
953  WRITE_INT_FIELD(numCols);
954  WRITE_ATTRNUMBER_ARRAY(dupColIdx, node->numCols);
955  WRITE_OID_ARRAY(dupOperators, node->numCols);
956  WRITE_OID_ARRAY(dupCollations, node->numCols);
957  WRITE_INT_FIELD(flagColIdx);
958  WRITE_INT_FIELD(firstFlag);
959  WRITE_LONG_FIELD(numGroups);
960 }
961 
962 static void
964 {
965  WRITE_NODE_TYPE("LOCKROWS");
966 
967  _outPlanInfo(str, (const Plan *) node);
968 
969  WRITE_NODE_FIELD(rowMarks);
970  WRITE_INT_FIELD(epqParam);
971 }
972 
973 static void
975 {
976  WRITE_NODE_TYPE("LIMIT");
977 
978  _outPlanInfo(str, (const Plan *) node);
979 
980  WRITE_NODE_FIELD(limitOffset);
981  WRITE_NODE_FIELD(limitCount);
982  WRITE_ENUM_FIELD(limitOption, LimitOption);
983  WRITE_INT_FIELD(uniqNumCols);
984  WRITE_ATTRNUMBER_ARRAY(uniqColIdx, node->uniqNumCols);
985  WRITE_OID_ARRAY(uniqOperators, node->uniqNumCols);
986  WRITE_OID_ARRAY(uniqCollations, node->uniqNumCols);
987 }
988 
989 static void
991 {
992  WRITE_NODE_TYPE("NESTLOOPPARAM");
993 
994  WRITE_INT_FIELD(paramno);
995  WRITE_NODE_FIELD(paramval);
996 }
997 
998 static void
1000 {
1001  WRITE_NODE_TYPE("PLANROWMARK");
1002 
1003  WRITE_UINT_FIELD(rti);
1004  WRITE_UINT_FIELD(prti);
1005  WRITE_UINT_FIELD(rowmarkId);
1006  WRITE_ENUM_FIELD(markType, RowMarkType);
1007  WRITE_INT_FIELD(allMarkTypes);
1009  WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
1010  WRITE_BOOL_FIELD(isParent);
1011 }
1012 
1013 static void
1015 {
1016  WRITE_NODE_TYPE("PARTITIONPRUNEINFO");
1017 
1018  WRITE_NODE_FIELD(prune_infos);
1019  WRITE_BITMAPSET_FIELD(other_subplans);
1020 }
1021 
1022 static void
1024 {
1025  WRITE_NODE_TYPE("PARTITIONEDRELPRUNEINFO");
1026 
1027  WRITE_UINT_FIELD(rtindex);
1028  WRITE_BITMAPSET_FIELD(present_parts);
1029  WRITE_INT_FIELD(nparts);
1030  WRITE_INT_ARRAY(subplan_map, node->nparts);
1031  WRITE_INT_ARRAY(subpart_map, node->nparts);
1032  WRITE_OID_ARRAY(relid_map, node->nparts);
1033  WRITE_NODE_FIELD(initial_pruning_steps);
1034  WRITE_NODE_FIELD(exec_pruning_steps);
1035  WRITE_BITMAPSET_FIELD(execparamids);
1036 }
1037 
1038 static void
1040 {
1041  WRITE_NODE_TYPE("PARTITIONPRUNESTEPOP");
1042 
1043  WRITE_INT_FIELD(step.step_id);
1044  WRITE_INT_FIELD(opstrategy);
1045  WRITE_NODE_FIELD(exprs);
1046  WRITE_NODE_FIELD(cmpfns);
1047  WRITE_BITMAPSET_FIELD(nullkeys);
1048 }
1049 
1050 static void
1052 {
1053  WRITE_NODE_TYPE("PARTITIONPRUNESTEPCOMBINE");
1054 
1055  WRITE_INT_FIELD(step.step_id);
1057  WRITE_NODE_FIELD(source_stepids);
1058 }
1059 
1060 static void
1062 {
1063  WRITE_NODE_TYPE("PLANINVALITEM");
1064 
1065  WRITE_INT_FIELD(cacheId);
1066  WRITE_UINT_FIELD(hashValue);
1067 }
1068 
1069 /*****************************************************************************
1070  *
1071  * Stuff from primnodes.h.
1072  *
1073  *****************************************************************************/
1074 
1075 static void
1077 {
1078  WRITE_NODE_TYPE("ALIAS");
1079 
1080  WRITE_STRING_FIELD(aliasname);
1081  WRITE_NODE_FIELD(colnames);
1082 }
1083 
1084 static void
1086 {
1087  WRITE_NODE_TYPE("RANGEVAR");
1088 
1089  /*
1090  * we deliberately ignore catalogname here, since it is presently not
1091  * semantically meaningful
1092  */
1093  WRITE_STRING_FIELD(schemaname);
1095  WRITE_BOOL_FIELD(inh);
1096  WRITE_CHAR_FIELD(relpersistence);
1097  WRITE_NODE_FIELD(alias);
1098  WRITE_LOCATION_FIELD(location);
1099 }
1100 
1101 static void
1103 {
1104  WRITE_NODE_TYPE("TABLEFUNC");
1105 
1106  WRITE_ENUM_FIELD(functype, TableFuncType);
1107  WRITE_NODE_FIELD(ns_uris);
1108  WRITE_NODE_FIELD(ns_names);
1109  WRITE_NODE_FIELD(docexpr);
1110  WRITE_NODE_FIELD(rowexpr);
1111  WRITE_NODE_FIELD(colnames);
1112  WRITE_NODE_FIELD(coltypes);
1113  WRITE_NODE_FIELD(coltypmods);
1114  WRITE_NODE_FIELD(colcollations);
1115  WRITE_NODE_FIELD(colexprs);
1116  WRITE_NODE_FIELD(coldefexprs);
1117  WRITE_NODE_FIELD(colvalexprs);
1118  WRITE_BITMAPSET_FIELD(notnulls);
1119  WRITE_NODE_FIELD(plan);
1120  WRITE_INT_FIELD(ordinalitycol);
1121  WRITE_LOCATION_FIELD(location);
1122 }
1123 
1124 static void
1126 {
1127  WRITE_NODE_TYPE("INTOCLAUSE");
1128 
1129  WRITE_NODE_FIELD(rel);
1130  WRITE_NODE_FIELD(colNames);
1131  WRITE_STRING_FIELD(accessMethod);
1133  WRITE_ENUM_FIELD(onCommit, OnCommitAction);
1134  WRITE_STRING_FIELD(tableSpaceName);
1135  WRITE_NODE_FIELD(viewQuery);
1136  WRITE_BOOL_FIELD(skipData);
1137 }
1138 
1139 static void
1140 _outVar(StringInfo str, const Var *node)
1141 {
1142  WRITE_NODE_TYPE("VAR");
1143 
1144  WRITE_INT_FIELD(varno);
1145  WRITE_INT_FIELD(varattno);
1146  WRITE_OID_FIELD(vartype);
1147  WRITE_INT_FIELD(vartypmod);
1148  WRITE_OID_FIELD(varcollid);
1149  WRITE_UINT_FIELD(varlevelsup);
1150  WRITE_UINT_FIELD(varnosyn);
1151  WRITE_INT_FIELD(varattnosyn);
1152  WRITE_LOCATION_FIELD(location);
1153 }
1154 
1155 static void
1157 {
1158  WRITE_NODE_TYPE("CONST");
1159 
1160  WRITE_OID_FIELD(consttype);
1161  WRITE_INT_FIELD(consttypmod);
1162  WRITE_OID_FIELD(constcollid);
1163  WRITE_INT_FIELD(constlen);
1164  WRITE_BOOL_FIELD(constbyval);
1165  WRITE_BOOL_FIELD(constisnull);
1166  WRITE_LOCATION_FIELD(location);
1167 
1168  appendStringInfoString(str, " :constvalue ");
1169  if (node->constisnull)
1170  appendStringInfoString(str, "<>");
1171  else
1172  outDatum(str, node->constvalue, node->constlen, node->constbyval);
1173 }
1174 
1175 static void
1177 {
1178  WRITE_NODE_TYPE("PARAM");
1179 
1180  WRITE_ENUM_FIELD(paramkind, ParamKind);
1181  WRITE_INT_FIELD(paramid);
1182  WRITE_OID_FIELD(paramtype);
1183  WRITE_INT_FIELD(paramtypmod);
1184  WRITE_OID_FIELD(paramcollid);
1185  WRITE_LOCATION_FIELD(location);
1186 }
1187 
1188 static void
1190 {
1191  WRITE_NODE_TYPE("AGGREF");
1192 
1193  WRITE_OID_FIELD(aggfnoid);
1194  WRITE_OID_FIELD(aggtype);
1195  WRITE_OID_FIELD(aggcollid);
1196  WRITE_OID_FIELD(inputcollid);
1197  WRITE_OID_FIELD(aggtranstype);
1198  WRITE_NODE_FIELD(aggargtypes);
1199  WRITE_NODE_FIELD(aggdirectargs);
1201  WRITE_NODE_FIELD(aggorder);
1202  WRITE_NODE_FIELD(aggdistinct);
1203  WRITE_NODE_FIELD(aggfilter);
1204  WRITE_BOOL_FIELD(aggstar);
1205  WRITE_BOOL_FIELD(aggvariadic);
1206  WRITE_CHAR_FIELD(aggkind);
1207  WRITE_UINT_FIELD(agglevelsup);
1208  WRITE_ENUM_FIELD(aggsplit, AggSplit);
1209  WRITE_INT_FIELD(aggno);
1210  WRITE_INT_FIELD(aggtransno);
1211  WRITE_LOCATION_FIELD(location);
1212 }
1213 
1214 static void
1216 {
1217  WRITE_NODE_TYPE("GROUPINGFUNC");
1218 
1220  WRITE_NODE_FIELD(refs);
1221  WRITE_NODE_FIELD(cols);
1222  WRITE_UINT_FIELD(agglevelsup);
1223  WRITE_LOCATION_FIELD(location);
1224 }
1225 
1226 static void
1228 {
1229  WRITE_NODE_TYPE("WINDOWFUNC");
1230 
1231  WRITE_OID_FIELD(winfnoid);
1232  WRITE_OID_FIELD(wintype);
1233  WRITE_OID_FIELD(wincollid);
1234  WRITE_OID_FIELD(inputcollid);
1236  WRITE_NODE_FIELD(aggfilter);
1237  WRITE_UINT_FIELD(winref);
1238  WRITE_BOOL_FIELD(winstar);
1239  WRITE_BOOL_FIELD(winagg);
1240  WRITE_LOCATION_FIELD(location);
1241 }
1242 
1243 static void
1245 {
1246  WRITE_NODE_TYPE("SUBSCRIPTINGREF");
1247 
1248  WRITE_OID_FIELD(refcontainertype);
1249  WRITE_OID_FIELD(refelemtype);
1250  WRITE_OID_FIELD(refrestype);
1251  WRITE_INT_FIELD(reftypmod);
1252  WRITE_OID_FIELD(refcollid);
1253  WRITE_NODE_FIELD(refupperindexpr);
1254  WRITE_NODE_FIELD(reflowerindexpr);
1255  WRITE_NODE_FIELD(refexpr);
1256  WRITE_NODE_FIELD(refassgnexpr);
1257 }
1258 
1259 static void
1261 {
1262  WRITE_NODE_TYPE("FUNCEXPR");
1263 
1264  WRITE_OID_FIELD(funcid);
1265  WRITE_OID_FIELD(funcresulttype);
1266  WRITE_BOOL_FIELD(funcretset);
1267  WRITE_BOOL_FIELD(funcvariadic);
1268  WRITE_ENUM_FIELD(funcformat, CoercionForm);
1269  WRITE_OID_FIELD(funccollid);
1270  WRITE_OID_FIELD(inputcollid);
1272  WRITE_LOCATION_FIELD(location);
1273 }
1274 
1275 static void
1277 {
1278  WRITE_NODE_TYPE("NAMEDARGEXPR");
1279 
1282  WRITE_INT_FIELD(argnumber);
1283  WRITE_LOCATION_FIELD(location);
1284 }
1285 
1286 static void
1288 {
1289  WRITE_NODE_TYPE("OPEXPR");
1290 
1291  WRITE_OID_FIELD(opno);
1292  WRITE_OID_FIELD(opfuncid);
1293  WRITE_OID_FIELD(opresulttype);
1294  WRITE_BOOL_FIELD(opretset);
1295  WRITE_OID_FIELD(opcollid);
1296  WRITE_OID_FIELD(inputcollid);
1298  WRITE_LOCATION_FIELD(location);
1299 }
1300 
1301 static void
1303 {
1304  WRITE_NODE_TYPE("DISTINCTEXPR");
1305 
1306  WRITE_OID_FIELD(opno);
1307  WRITE_OID_FIELD(opfuncid);
1308  WRITE_OID_FIELD(opresulttype);
1309  WRITE_BOOL_FIELD(opretset);
1310  WRITE_OID_FIELD(opcollid);
1311  WRITE_OID_FIELD(inputcollid);
1313  WRITE_LOCATION_FIELD(location);
1314 }
1315 
1316 static void
1318 {
1319  WRITE_NODE_TYPE("NULLIFEXPR");
1320 
1321  WRITE_OID_FIELD(opno);
1322  WRITE_OID_FIELD(opfuncid);
1323  WRITE_OID_FIELD(opresulttype);
1324  WRITE_BOOL_FIELD(opretset);
1325  WRITE_OID_FIELD(opcollid);
1326  WRITE_OID_FIELD(inputcollid);
1328  WRITE_LOCATION_FIELD(location);
1329 }
1330 
1331 static void
1333 {
1334  WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1335 
1336  WRITE_OID_FIELD(opno);
1337  WRITE_OID_FIELD(opfuncid);
1338  WRITE_OID_FIELD(hashfuncid);
1339  WRITE_OID_FIELD(negfuncid);
1340  WRITE_BOOL_FIELD(useOr);
1341  WRITE_OID_FIELD(inputcollid);
1343  WRITE_LOCATION_FIELD(location);
1344 }
1345 
1346 static void
1348 {
1349  char *opstr = NULL;
1350 
1351  WRITE_NODE_TYPE("BOOLEXPR");
1352 
1353  /* do-it-yourself enum representation */
1354  switch (node->boolop)
1355  {
1356  case AND_EXPR:
1357  opstr = "and";
1358  break;
1359  case OR_EXPR:
1360  opstr = "or";
1361  break;
1362  case NOT_EXPR:
1363  opstr = "not";
1364  break;
1365  }
1366  appendStringInfoString(str, " :boolop ");
1367  outToken(str, opstr);
1368 
1370  WRITE_LOCATION_FIELD(location);
1371 }
1372 
1373 static void
1375 {
1376  WRITE_NODE_TYPE("SUBLINK");
1377 
1378  WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1379  WRITE_INT_FIELD(subLinkId);
1380  WRITE_NODE_FIELD(testexpr);
1381  WRITE_NODE_FIELD(operName);
1382  WRITE_NODE_FIELD(subselect);
1383  WRITE_LOCATION_FIELD(location);
1384 }
1385 
1386 static void
1388 {
1389  WRITE_NODE_TYPE("SUBPLAN");
1390 
1391  WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1392  WRITE_NODE_FIELD(testexpr);
1393  WRITE_NODE_FIELD(paramIds);
1394  WRITE_INT_FIELD(plan_id);
1395  WRITE_STRING_FIELD(plan_name);
1396  WRITE_OID_FIELD(firstColType);
1397  WRITE_INT_FIELD(firstColTypmod);
1398  WRITE_OID_FIELD(firstColCollation);
1399  WRITE_BOOL_FIELD(useHashTable);
1400  WRITE_BOOL_FIELD(unknownEqFalse);
1401  WRITE_BOOL_FIELD(parallel_safe);
1402  WRITE_NODE_FIELD(setParam);
1403  WRITE_NODE_FIELD(parParam);
1405  WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1406  WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1407 }
1408 
1409 static void
1411 {
1412  WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1413 
1414  WRITE_NODE_FIELD(subplans);
1415 }
1416 
1417 static void
1419 {
1420  WRITE_NODE_TYPE("FIELDSELECT");
1421 
1423  WRITE_INT_FIELD(fieldnum);
1424  WRITE_OID_FIELD(resulttype);
1425  WRITE_INT_FIELD(resulttypmod);
1426  WRITE_OID_FIELD(resultcollid);
1427 }
1428 
1429 static void
1431 {
1432  WRITE_NODE_TYPE("FIELDSTORE");
1433 
1435  WRITE_NODE_FIELD(newvals);
1436  WRITE_NODE_FIELD(fieldnums);
1437  WRITE_OID_FIELD(resulttype);
1438 }
1439 
1440 static void
1442 {
1443  WRITE_NODE_TYPE("RELABELTYPE");
1444 
1446  WRITE_OID_FIELD(resulttype);
1447  WRITE_INT_FIELD(resulttypmod);
1448  WRITE_OID_FIELD(resultcollid);
1449  WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1450  WRITE_LOCATION_FIELD(location);
1451 }
1452 
1453 static void
1455 {
1456  WRITE_NODE_TYPE("COERCEVIAIO");
1457 
1459  WRITE_OID_FIELD(resulttype);
1460  WRITE_OID_FIELD(resultcollid);
1461  WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1462  WRITE_LOCATION_FIELD(location);
1463 }
1464 
1465 static void
1467 {
1468  WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1469 
1471  WRITE_NODE_FIELD(elemexpr);
1472  WRITE_OID_FIELD(resulttype);
1473  WRITE_INT_FIELD(resulttypmod);
1474  WRITE_OID_FIELD(resultcollid);
1475  WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1476  WRITE_LOCATION_FIELD(location);
1477 }
1478 
1479 static void
1481 {
1482  WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1483 
1485  WRITE_OID_FIELD(resulttype);
1486  WRITE_ENUM_FIELD(convertformat, CoercionForm);
1487  WRITE_LOCATION_FIELD(location);
1488 }
1489 
1490 static void
1492 {
1493  WRITE_NODE_TYPE("COLLATEEXPR");
1494 
1496  WRITE_OID_FIELD(collOid);
1497  WRITE_LOCATION_FIELD(location);
1498 }
1499 
1500 static void
1502 {
1503  WRITE_NODE_TYPE("CASEEXPR");
1504 
1505  WRITE_OID_FIELD(casetype);
1506  WRITE_OID_FIELD(casecollid);
1509  WRITE_NODE_FIELD(defresult);
1510  WRITE_LOCATION_FIELD(location);
1511 }
1512 
1513 static void
1515 {
1516  WRITE_NODE_TYPE("CASEWHEN");
1517 
1518  WRITE_NODE_FIELD(expr);
1519  WRITE_NODE_FIELD(result);
1520  WRITE_LOCATION_FIELD(location);
1521 }
1522 
1523 static void
1525 {
1526  WRITE_NODE_TYPE("CASETESTEXPR");
1527 
1528  WRITE_OID_FIELD(typeId);
1529  WRITE_INT_FIELD(typeMod);
1530  WRITE_OID_FIELD(collation);
1531 }
1532 
1533 static void
1535 {
1536  WRITE_NODE_TYPE("ARRAYEXPR");
1537 
1538  WRITE_OID_FIELD(array_typeid);
1539  WRITE_OID_FIELD(array_collid);
1540  WRITE_OID_FIELD(element_typeid);
1541  WRITE_NODE_FIELD(elements);
1542  WRITE_BOOL_FIELD(multidims);
1543  WRITE_LOCATION_FIELD(location);
1544 }
1545 
1546 static void
1548 {
1549  WRITE_NODE_TYPE("ROWEXPR");
1550 
1552  WRITE_OID_FIELD(row_typeid);
1553  WRITE_ENUM_FIELD(row_format, CoercionForm);
1554  WRITE_NODE_FIELD(colnames);
1555  WRITE_LOCATION_FIELD(location);
1556 }
1557 
1558 static void
1560 {
1561  WRITE_NODE_TYPE("ROWCOMPAREEXPR");
1562 
1564  WRITE_NODE_FIELD(opnos);
1565  WRITE_NODE_FIELD(opfamilies);
1566  WRITE_NODE_FIELD(inputcollids);
1567  WRITE_NODE_FIELD(largs);
1568  WRITE_NODE_FIELD(rargs);
1569 }
1570 
1571 static void
1573 {
1574  WRITE_NODE_TYPE("COALESCEEXPR");
1575 
1576  WRITE_OID_FIELD(coalescetype);
1577  WRITE_OID_FIELD(coalescecollid);
1579  WRITE_LOCATION_FIELD(location);
1580 }
1581 
1582 static void
1584 {
1585  WRITE_NODE_TYPE("MINMAXEXPR");
1586 
1587  WRITE_OID_FIELD(minmaxtype);
1588  WRITE_OID_FIELD(minmaxcollid);
1589  WRITE_OID_FIELD(inputcollid);
1592  WRITE_LOCATION_FIELD(location);
1593 }
1594 
1595 static void
1597 {
1598  WRITE_NODE_TYPE("SQLVALUEFUNCTION");
1599 
1602  WRITE_INT_FIELD(typmod);
1603  WRITE_LOCATION_FIELD(location);
1604 }
1605 
1606 static void
1608 {
1609  WRITE_NODE_TYPE("XMLEXPR");
1610 
1613  WRITE_NODE_FIELD(named_args);
1614  WRITE_NODE_FIELD(arg_names);
1618  WRITE_INT_FIELD(typmod);
1619  WRITE_LOCATION_FIELD(location);
1620 }
1621 
1622 static void
1624 {
1625  WRITE_NODE_TYPE("NULLTEST");
1626 
1628  WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1629  WRITE_BOOL_FIELD(argisrow);
1630  WRITE_LOCATION_FIELD(location);
1631 }
1632 
1633 static void
1635 {
1636  WRITE_NODE_TYPE("BOOLEANTEST");
1637 
1639  WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1640  WRITE_LOCATION_FIELD(location);
1641 }
1642 
1643 static void
1645 {
1646  WRITE_NODE_TYPE("COERCETODOMAIN");
1647 
1649  WRITE_OID_FIELD(resulttype);
1650  WRITE_INT_FIELD(resulttypmod);
1651  WRITE_OID_FIELD(resultcollid);
1652  WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1653  WRITE_LOCATION_FIELD(location);
1654 }
1655 
1656 static void
1658 {
1659  WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1660 
1661  WRITE_OID_FIELD(typeId);
1662  WRITE_INT_FIELD(typeMod);
1663  WRITE_OID_FIELD(collation);
1664  WRITE_LOCATION_FIELD(location);
1665 }
1666 
1667 static void
1669 {
1670  WRITE_NODE_TYPE("SETTODEFAULT");
1671 
1672  WRITE_OID_FIELD(typeId);
1673  WRITE_INT_FIELD(typeMod);
1674  WRITE_OID_FIELD(collation);
1675  WRITE_LOCATION_FIELD(location);
1676 }
1677 
1678 static void
1680 {
1681  WRITE_NODE_TYPE("CURRENTOFEXPR");
1682 
1683  WRITE_UINT_FIELD(cvarno);
1684  WRITE_STRING_FIELD(cursor_name);
1685  WRITE_INT_FIELD(cursor_param);
1686 }
1687 
1688 static void
1690 {
1691  WRITE_NODE_TYPE("NEXTVALUEEXPR");
1692 
1693  WRITE_OID_FIELD(seqid);
1694  WRITE_OID_FIELD(typeId);
1695 }
1696 
1697 static void
1699 {
1700  WRITE_NODE_TYPE("INFERENCEELEM");
1701 
1702  WRITE_NODE_FIELD(expr);
1703  WRITE_OID_FIELD(infercollid);
1704  WRITE_OID_FIELD(inferopclass);
1705 }
1706 
1707 static void
1709 {
1710  WRITE_NODE_TYPE("TARGETENTRY");
1711 
1712  WRITE_NODE_FIELD(expr);
1713  WRITE_INT_FIELD(resno);
1714  WRITE_STRING_FIELD(resname);
1715  WRITE_UINT_FIELD(ressortgroupref);
1716  WRITE_OID_FIELD(resorigtbl);
1717  WRITE_INT_FIELD(resorigcol);
1718  WRITE_BOOL_FIELD(resjunk);
1719 }
1720 
1721 static void
1723 {
1724  WRITE_NODE_TYPE("RANGETBLREF");
1725 
1726  WRITE_INT_FIELD(rtindex);
1727 }
1728 
1729 static void
1731 {
1732  WRITE_NODE_TYPE("JOINEXPR");
1733 
1734  WRITE_ENUM_FIELD(jointype, JoinType);
1735  WRITE_BOOL_FIELD(isNatural);
1736  WRITE_NODE_FIELD(larg);
1737  WRITE_NODE_FIELD(rarg);
1738  WRITE_NODE_FIELD(usingClause);
1739  WRITE_NODE_FIELD(join_using_alias);
1740  WRITE_NODE_FIELD(quals);
1741  WRITE_NODE_FIELD(alias);
1742  WRITE_INT_FIELD(rtindex);
1743 }
1744 
1745 static void
1747 {
1748  WRITE_NODE_TYPE("FROMEXPR");
1749 
1750  WRITE_NODE_FIELD(fromlist);
1751  WRITE_NODE_FIELD(quals);
1752 }
1753 
1754 static void
1756 {
1757  WRITE_NODE_TYPE("ONCONFLICTEXPR");
1758 
1760  WRITE_NODE_FIELD(arbiterElems);
1761  WRITE_NODE_FIELD(arbiterWhere);
1762  WRITE_OID_FIELD(constraint);
1763  WRITE_NODE_FIELD(onConflictSet);
1764  WRITE_NODE_FIELD(onConflictWhere);
1765  WRITE_INT_FIELD(exclRelIndex);
1766  WRITE_NODE_FIELD(exclRelTlist);
1767 }
1768 
1769 static void
1771 {
1772  WRITE_NODE_TYPE("JSONFORMAT");
1773 
1776  WRITE_LOCATION_FIELD(location);
1777 }
1778 
1779 static void
1781 {
1782  WRITE_NODE_TYPE("JSONRETURNING");
1783 
1785  WRITE_OID_FIELD(typid);
1786  WRITE_INT_FIELD(typmod);
1787 }
1788 
1789 static void
1791 {
1792  WRITE_NODE_TYPE("JSONVALUEEXPR");
1793 
1794  WRITE_NODE_FIELD(raw_expr);
1795  WRITE_NODE_FIELD(formatted_expr);
1797 }
1798 
1799 static void
1801 {
1802  WRITE_NODE_TYPE("JSONCONSTRUCTOREXPR");
1803 
1806  WRITE_NODE_FIELD(func);
1807  WRITE_NODE_FIELD(coercion);
1808  WRITE_NODE_FIELD(returning);
1809  WRITE_BOOL_FIELD(absent_on_null);
1810  WRITE_BOOL_FIELD(unique);
1811  WRITE_LOCATION_FIELD(location);
1812 }
1813 
1814 static void
1816 {
1817  WRITE_NODE_TYPE("JSONISPREDICATE");
1818 
1819  WRITE_NODE_FIELD(expr);
1821  WRITE_ENUM_FIELD(item_type, JsonValueType);
1822  WRITE_BOOL_FIELD(unique_keys);
1823  WRITE_LOCATION_FIELD(location);
1824 }
1825 
1826 static void
1828 {
1829  WRITE_NODE_TYPE("JSONBEHAVIOR");
1830 
1832  WRITE_NODE_FIELD(default_expr);
1833 }
1834 
1835 static void
1837 {
1838  WRITE_NODE_TYPE("JSONEXPR");
1839 
1841  WRITE_NODE_FIELD(formatted_expr);
1842  WRITE_NODE_FIELD(result_coercion);
1844  WRITE_NODE_FIELD(path_spec);
1845  WRITE_NODE_FIELD(passing_names);
1846  WRITE_NODE_FIELD(passing_values);
1847  WRITE_NODE_FIELD(returning);
1848  WRITE_NODE_FIELD(on_empty);
1849  WRITE_NODE_FIELD(on_error);
1850  WRITE_NODE_FIELD(coercions);
1851  WRITE_ENUM_FIELD(wrapper, JsonWrapper);
1852  WRITE_BOOL_FIELD(omit_quotes);
1853  WRITE_LOCATION_FIELD(location);
1854 }
1855 
1856 static void
1858 {
1859  WRITE_NODE_TYPE("JSONCOERCION");
1860 
1861  WRITE_NODE_FIELD(expr);
1862  WRITE_BOOL_FIELD(via_populate);
1863  WRITE_BOOL_FIELD(via_io);
1864  WRITE_OID_FIELD(collation);
1865 }
1866 
1867 static void
1869 {
1870  WRITE_NODE_TYPE("JSONITEMCOERCIONS");
1871 
1872  WRITE_NODE_FIELD(null);
1873  WRITE_NODE_FIELD(string);
1875  WRITE_NODE_FIELD(boolean);
1877  WRITE_NODE_FIELD(time);
1878  WRITE_NODE_FIELD(timetz);
1880  WRITE_NODE_FIELD(timestamptz);
1881  WRITE_NODE_FIELD(composite);
1882 }
1883 
1884 static void
1886 {
1887  WRITE_NODE_TYPE("JSONTABLEPARENT");
1888 
1889  WRITE_NODE_FIELD(path);
1891  WRITE_NODE_FIELD(child);
1892  WRITE_BOOL_FIELD(outerJoin);
1893  WRITE_INT_FIELD(colMin);
1894  WRITE_INT_FIELD(colMax);
1895  WRITE_BOOL_FIELD(errorOnError);
1896 }
1897 
1898 static void
1900 {
1901  WRITE_NODE_TYPE("JSONTABLESIBLING");
1902 
1903  WRITE_NODE_FIELD(larg);
1904  WRITE_NODE_FIELD(rarg);
1905  WRITE_BOOL_FIELD(cross);
1906 }
1907 
1908 /*****************************************************************************
1909  *
1910  * Stuff from pathnodes.h.
1911  *
1912  *****************************************************************************/
1913 
1914 /*
1915  * print the basic stuff of all nodes that inherit from Path
1916  *
1917  * Note we do NOT print the parent, else we'd be in infinite recursion.
1918  * We can print the parent's relids for identification purposes, though.
1919  * We print the pathtarget only if it's not the default one for the rel.
1920  * We also do not print the whole of param_info, since it's printed by
1921  * _outRelOptInfo; it's sufficient and less cluttering to print just the
1922  * required outer relids.
1923  */
1924 static void
1926 {
1927  WRITE_ENUM_FIELD(pathtype, NodeTag);
1928  appendStringInfoString(str, " :parent_relids ");
1929  outBitmapset(str, node->parent->relids);
1930  if (node->pathtarget != node->parent->reltarget)
1931  WRITE_NODE_FIELD(pathtarget);
1932  appendStringInfoString(str, " :required_outer ");
1933  if (node->param_info)
1935  else
1936  outBitmapset(str, NULL);
1937  WRITE_BOOL_FIELD(parallel_aware);
1938  WRITE_BOOL_FIELD(parallel_safe);
1939  WRITE_INT_FIELD(parallel_workers);
1940  WRITE_FLOAT_FIELD(rows, "%.0f");
1941  WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1942  WRITE_FLOAT_FIELD(total_cost, "%.2f");
1943  WRITE_NODE_FIELD(pathkeys);
1944 }
1945 
1946 /*
1947  * print the basic stuff of all nodes that inherit from JoinPath
1948  */
1949 static void
1951 {
1952  _outPathInfo(str, (const Path *) node);
1953 
1954  WRITE_ENUM_FIELD(jointype, JoinType);
1955  WRITE_BOOL_FIELD(inner_unique);
1956  WRITE_NODE_FIELD(outerjoinpath);
1957  WRITE_NODE_FIELD(innerjoinpath);
1958  WRITE_NODE_FIELD(joinrestrictinfo);
1959 }
1960 
1961 static void
1963 {
1964  WRITE_NODE_TYPE("PATH");
1965 
1966  _outPathInfo(str, (const Path *) node);
1967 }
1968 
1969 static void
1971 {
1972  WRITE_NODE_TYPE("INDEXPATH");
1973 
1974  _outPathInfo(str, (const Path *) node);
1975 
1976  WRITE_NODE_FIELD(indexinfo);
1977  WRITE_NODE_FIELD(indexclauses);
1978  WRITE_NODE_FIELD(indexorderbys);
1979  WRITE_NODE_FIELD(indexorderbycols);
1980  WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1981  WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1982  WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1983 }
1984 
1985 static void
1987 {
1988  WRITE_NODE_TYPE("BITMAPHEAPPATH");
1989 
1990  _outPathInfo(str, (const Path *) node);
1991 
1992  WRITE_NODE_FIELD(bitmapqual);
1993 }
1994 
1995 static void
1997 {
1998  WRITE_NODE_TYPE("BITMAPANDPATH");
1999 
2000  _outPathInfo(str, (const Path *) node);
2001 
2002  WRITE_NODE_FIELD(bitmapquals);
2003  WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
2004 }
2005 
2006 static void
2008 {
2009  WRITE_NODE_TYPE("BITMAPORPATH");
2010 
2011  _outPathInfo(str, (const Path *) node);
2012 
2013  WRITE_NODE_FIELD(bitmapquals);
2014  WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
2015 }
2016 
2017 static void
2019 {
2020  WRITE_NODE_TYPE("TIDPATH");
2021 
2022  _outPathInfo(str, (const Path *) node);
2023 
2024  WRITE_NODE_FIELD(tidquals);
2025 }
2026 
2027 static void
2029 {
2030  WRITE_NODE_TYPE("TIDRANGEPATH");
2031 
2032  _outPathInfo(str, (const Path *) node);
2033 
2034  WRITE_NODE_FIELD(tidrangequals);
2035 }
2036 
2037 static void
2039 {
2040  WRITE_NODE_TYPE("SUBQUERYSCANPATH");
2041 
2042  _outPathInfo(str, (const Path *) node);
2043 
2045 }
2046 
2047 static void
2049 {
2050  WRITE_NODE_TYPE("FOREIGNPATH");
2051 
2052  _outPathInfo(str, (const Path *) node);
2053 
2054  WRITE_NODE_FIELD(fdw_outerpath);
2055  WRITE_NODE_FIELD(fdw_private);
2056 }
2057 
2058 static void
2060 {
2061  WRITE_NODE_TYPE("CUSTOMPATH");
2062 
2063  _outPathInfo(str, (const Path *) node);
2064 
2065  WRITE_UINT_FIELD(flags);
2066  WRITE_NODE_FIELD(custom_paths);
2067  WRITE_NODE_FIELD(custom_private);
2068  appendStringInfoString(str, " :methods ");
2069  outToken(str, node->methods->CustomName);
2070 }
2071 
2072 static void
2074 {
2075  WRITE_NODE_TYPE("APPENDPATH");
2076 
2077  _outPathInfo(str, (const Path *) node);
2078 
2079  WRITE_NODE_FIELD(subpaths);
2080  WRITE_INT_FIELD(first_partial_path);
2081  WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
2082 }
2083 
2084 static void
2086 {
2087  WRITE_NODE_TYPE("MERGEAPPENDPATH");
2088 
2089  _outPathInfo(str, (const Path *) node);
2090 
2091  WRITE_NODE_FIELD(subpaths);
2092  WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
2093 }
2094 
2095 static void
2097 {
2098  WRITE_NODE_TYPE("GROUPRESULTPATH");
2099 
2100  _outPathInfo(str, (const Path *) node);
2101 
2102  WRITE_NODE_FIELD(quals);
2103 }
2104 
2105 static void
2107 {
2108  WRITE_NODE_TYPE("MATERIALPATH");
2109 
2110  _outPathInfo(str, (const Path *) node);
2111 
2113 }
2114 
2115 static void
2117 {
2118  WRITE_NODE_TYPE("MEMOIZEPATH");
2119 
2120  _outPathInfo(str, (const Path *) node);
2121 
2123  WRITE_NODE_FIELD(hash_operators);
2124  WRITE_NODE_FIELD(param_exprs);
2125  WRITE_BOOL_FIELD(singlerow);
2126  WRITE_BOOL_FIELD(binary_mode);
2127  WRITE_FLOAT_FIELD(calls, "%.0f");
2128  WRITE_UINT_FIELD(est_entries);
2129 }
2130 
2131 static void
2133 {
2134  WRITE_NODE_TYPE("UNIQUEPATH");
2135 
2136  _outPathInfo(str, (const Path *) node);
2137 
2140  WRITE_NODE_FIELD(in_operators);
2141  WRITE_NODE_FIELD(uniq_exprs);
2142 }
2143 
2144 static void
2146 {
2147  WRITE_NODE_TYPE("GATHERPATH");
2148 
2149  _outPathInfo(str, (const Path *) node);
2150 
2152  WRITE_BOOL_FIELD(single_copy);
2153  WRITE_INT_FIELD(num_workers);
2154 }
2155 
2156 static void
2158 {
2159  WRITE_NODE_TYPE("PROJECTIONPATH");
2160 
2161  _outPathInfo(str, (const Path *) node);
2162 
2164  WRITE_BOOL_FIELD(dummypp);
2165 }
2166 
2167 static void
2169 {
2170  WRITE_NODE_TYPE("PROJECTSETPATH");
2171 
2172  _outPathInfo(str, (const Path *) node);
2173 
2175 }
2176 
2177 static void
2179 {
2180  _outPathInfo(str, (const Path *) node);
2181 
2183 }
2184 
2185 static void
2187 {
2188  WRITE_NODE_TYPE("SORTPATH");
2189 
2190  _outSortPathInfo(str, node);
2191 }
2192 
2193 static void
2195 {
2196  WRITE_NODE_TYPE("INCREMENTALSORTPATH");
2197 
2198  _outSortPathInfo(str, (const SortPath *) node);
2199 
2200  WRITE_INT_FIELD(nPresortedCols);
2201 }
2202 
2203 static void
2205 {
2206  WRITE_NODE_TYPE("GROUPPATH");
2207 
2208  _outPathInfo(str, (const Path *) node);
2209 
2211  WRITE_NODE_FIELD(groupClause);
2212  WRITE_NODE_FIELD(qual);
2213 }
2214 
2215 static void
2217 {
2218  WRITE_NODE_TYPE("UPPERUNIQUEPATH");
2219 
2220  _outPathInfo(str, (const Path *) node);
2221 
2223  WRITE_INT_FIELD(numkeys);
2224 }
2225 
2226 static void
2228 {
2229  WRITE_NODE_TYPE("AGGPATH");
2230 
2231  _outPathInfo(str, (const Path *) node);
2232 
2234  WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
2235  WRITE_ENUM_FIELD(aggsplit, AggSplit);
2236  WRITE_FLOAT_FIELD(numGroups, "%.0f");
2237  WRITE_UINT64_FIELD(transitionSpace);
2238  WRITE_NODE_FIELD(groupClause);
2239  WRITE_NODE_FIELD(qual);
2240 }
2241 
2242 static void
2244 {
2245  WRITE_NODE_TYPE("ROLLUP");
2246 
2247  WRITE_NODE_FIELD(groupClause);
2248  WRITE_NODE_FIELD(gsets);
2249  WRITE_NODE_FIELD(gsets_data);
2250  WRITE_FLOAT_FIELD(numGroups, "%.0f");
2251  WRITE_BOOL_FIELD(hashable);
2252  WRITE_BOOL_FIELD(is_hashed);
2253 }
2254 
2255 static void
2257 {
2258  WRITE_NODE_TYPE("GSDATA");
2259 
2260  WRITE_NODE_FIELD(set);
2261  WRITE_FLOAT_FIELD(numGroups, "%.0f");
2262 }
2263 
2264 static void
2266 {
2267  WRITE_NODE_TYPE("GROUPINGSETSPATH");
2268 
2269  _outPathInfo(str, (const Path *) node);
2270 
2272  WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
2273  WRITE_NODE_FIELD(rollups);
2274  WRITE_NODE_FIELD(qual);
2275  WRITE_UINT64_FIELD(transitionSpace);
2276 }
2277 
2278 static void
2280 {
2281  WRITE_NODE_TYPE("MINMAXAGGPATH");
2282 
2283  _outPathInfo(str, (const Path *) node);
2284 
2285  WRITE_NODE_FIELD(mmaggregates);
2286  WRITE_NODE_FIELD(quals);
2287 }
2288 
2289 static void
2291 {
2292  WRITE_NODE_TYPE("WINDOWAGGPATH");
2293 
2294  _outPathInfo(str, (const Path *) node);
2295 
2297  WRITE_NODE_FIELD(winclause);
2298  WRITE_NODE_FIELD(qual);
2299  WRITE_BOOL_FIELD(topwindow);
2300 }
2301 
2302 static void
2304 {
2305  WRITE_NODE_TYPE("SETOPPATH");
2306 
2307  _outPathInfo(str, (const Path *) node);
2308 
2310  WRITE_ENUM_FIELD(cmd, SetOpCmd);
2311  WRITE_ENUM_FIELD(strategy, SetOpStrategy);
2312  WRITE_NODE_FIELD(distinctList);
2313  WRITE_INT_FIELD(flagColIdx);
2314  WRITE_INT_FIELD(firstFlag);
2315  WRITE_FLOAT_FIELD(numGroups, "%.0f");
2316 }
2317 
2318 static void
2320 {
2321  WRITE_NODE_TYPE("RECURSIVEUNIONPATH");
2322 
2323  _outPathInfo(str, (const Path *) node);
2324 
2325  WRITE_NODE_FIELD(leftpath);
2326  WRITE_NODE_FIELD(rightpath);
2327  WRITE_NODE_FIELD(distinctList);
2328  WRITE_INT_FIELD(wtParam);
2329  WRITE_FLOAT_FIELD(numGroups, "%.0f");
2330 }
2331 
2332 static void
2334 {
2335  WRITE_NODE_TYPE("LOCKROWSPATH");
2336 
2337  _outPathInfo(str, (const Path *) node);
2338 
2340  WRITE_NODE_FIELD(rowMarks);
2341  WRITE_INT_FIELD(epqParam);
2342 }
2343 
2344 static void
2346 {
2347  WRITE_NODE_TYPE("MODIFYTABLEPATH");
2348 
2349  _outPathInfo(str, (const Path *) node);
2350 
2352  WRITE_ENUM_FIELD(operation, CmdType);
2353  WRITE_BOOL_FIELD(canSetTag);
2354  WRITE_UINT_FIELD(nominalRelation);
2355  WRITE_UINT_FIELD(rootRelation);
2356  WRITE_BOOL_FIELD(partColsUpdated);
2357  WRITE_NODE_FIELD(resultRelations);
2358  WRITE_NODE_FIELD(updateColnosLists);
2359  WRITE_NODE_FIELD(withCheckOptionLists);
2360  WRITE_NODE_FIELD(returningLists);
2361  WRITE_NODE_FIELD(rowMarks);
2362  WRITE_NODE_FIELD(onconflict);
2363  WRITE_INT_FIELD(epqParam);
2364  WRITE_NODE_FIELD(mergeActionLists);
2365 }
2366 
2367 static void
2369 {
2370  WRITE_NODE_TYPE("LIMITPATH");
2371 
2372  _outPathInfo(str, (const Path *) node);
2373 
2375  WRITE_NODE_FIELD(limitOffset);
2376  WRITE_NODE_FIELD(limitCount);
2377  WRITE_ENUM_FIELD(limitOption, LimitOption);
2378 }
2379 
2380 static void
2382 {
2383  WRITE_NODE_TYPE("GATHERMERGEPATH");
2384 
2385  _outPathInfo(str, (const Path *) node);
2386 
2388  WRITE_INT_FIELD(num_workers);
2389 }
2390 
2391 static void
2393 {
2394  WRITE_NODE_TYPE("NESTPATH");
2395 
2396  _outJoinPathInfo(str, (const JoinPath *) node);
2397 }
2398 
2399 static void
2401 {
2402  WRITE_NODE_TYPE("MERGEPATH");
2403 
2404  _outJoinPathInfo(str, (const JoinPath *) node);
2405 
2406  WRITE_NODE_FIELD(path_mergeclauses);
2407  WRITE_NODE_FIELD(outersortkeys);
2408  WRITE_NODE_FIELD(innersortkeys);
2409  WRITE_BOOL_FIELD(skip_mark_restore);
2410  WRITE_BOOL_FIELD(materialize_inner);
2411 }
2412 
2413 static void
2415 {
2416  WRITE_NODE_TYPE("HASHPATH");
2417 
2418  _outJoinPathInfo(str, (const JoinPath *) node);
2419 
2420  WRITE_NODE_FIELD(path_hashclauses);
2421  WRITE_INT_FIELD(num_batches);
2422  WRITE_FLOAT_FIELD(inner_rows_total, "%.0f");
2423 }
2424 
2425 static void
2427 {
2428  WRITE_NODE_TYPE("PLANNERGLOBAL");
2429 
2430  /* NB: this isn't a complete set of fields */
2431  WRITE_NODE_FIELD(subplans);
2432  WRITE_BITMAPSET_FIELD(rewindPlanIDs);
2433  WRITE_NODE_FIELD(finalrtable);
2434  WRITE_NODE_FIELD(finalrowmarks);
2435  WRITE_NODE_FIELD(resultRelations);
2436  WRITE_NODE_FIELD(appendRelations);
2437  WRITE_NODE_FIELD(relationOids);
2438  WRITE_NODE_FIELD(invalItems);
2439  WRITE_NODE_FIELD(paramExecTypes);
2440  WRITE_UINT_FIELD(lastPHId);
2441  WRITE_UINT_FIELD(lastRowMarkId);
2442  WRITE_INT_FIELD(lastPlanNodeId);
2443  WRITE_BOOL_FIELD(transientPlan);
2444  WRITE_BOOL_FIELD(dependsOnRole);
2445  WRITE_BOOL_FIELD(parallelModeOK);
2446  WRITE_BOOL_FIELD(parallelModeNeeded);
2447  WRITE_CHAR_FIELD(maxParallelHazard);
2448 }
2449 
2450 static void
2452 {
2453  WRITE_NODE_TYPE("PLANNERINFO");
2454 
2455  /* NB: this isn't a complete set of fields */
2457  WRITE_NODE_FIELD(glob);
2458  WRITE_UINT_FIELD(query_level);
2459  WRITE_NODE_FIELD(plan_params);
2460  WRITE_BITMAPSET_FIELD(outer_params);
2461  WRITE_BITMAPSET_FIELD(all_baserels);
2462  WRITE_BITMAPSET_FIELD(nullable_baserels);
2463  WRITE_NODE_FIELD(join_rel_list);
2464  WRITE_INT_FIELD(join_cur_level);
2465  WRITE_NODE_FIELD(init_plans);
2466  WRITE_NODE_FIELD(cte_plan_ids);
2467  WRITE_NODE_FIELD(multiexpr_params);
2468  WRITE_NODE_FIELD(eq_classes);
2469  WRITE_BOOL_FIELD(ec_merging_done);
2470  WRITE_NODE_FIELD(canon_pathkeys);
2471  WRITE_NODE_FIELD(left_join_clauses);
2472  WRITE_NODE_FIELD(right_join_clauses);
2473  WRITE_NODE_FIELD(full_join_clauses);
2474  WRITE_NODE_FIELD(join_info_list);
2475  WRITE_BITMAPSET_FIELD(all_result_relids);
2476  WRITE_BITMAPSET_FIELD(leaf_result_relids);
2477  WRITE_NODE_FIELD(append_rel_list);
2478  WRITE_NODE_FIELD(row_identity_vars);
2479  WRITE_NODE_FIELD(rowMarks);
2480  WRITE_NODE_FIELD(placeholder_list);
2481  WRITE_NODE_FIELD(fkey_list);
2482  WRITE_NODE_FIELD(query_pathkeys);
2483  WRITE_NODE_FIELD(group_pathkeys);
2484  WRITE_NODE_FIELD(window_pathkeys);
2485  WRITE_NODE_FIELD(distinct_pathkeys);
2486  WRITE_NODE_FIELD(sort_pathkeys);
2487  WRITE_NODE_FIELD(processed_tlist);
2488  WRITE_NODE_FIELD(update_colnos);
2489  WRITE_NODE_FIELD(minmax_aggs);
2490  WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
2491  WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
2492  WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
2493  WRITE_UINT_FIELD(qual_security_level);
2494  WRITE_BOOL_FIELD(hasJoinRTEs);
2495  WRITE_BOOL_FIELD(hasLateralRTEs);
2496  WRITE_BOOL_FIELD(hasHavingQual);
2497  WRITE_BOOL_FIELD(hasPseudoConstantQuals);
2498  WRITE_BOOL_FIELD(hasAlternativeSubPlans);
2499  WRITE_BOOL_FIELD(hasRecursion);
2500  WRITE_INT_FIELD(wt_param_id);
2501  WRITE_BITMAPSET_FIELD(curOuterRels);
2502  WRITE_NODE_FIELD(curOuterParams);
2503  WRITE_BOOL_FIELD(partColsUpdated);
2504 }
2505 
2506 static void
2508 {
2509  WRITE_NODE_TYPE("RELOPTINFO");
2510 
2511  /* NB: this isn't a complete set of fields */
2512  WRITE_ENUM_FIELD(reloptkind, RelOptKind);
2513  WRITE_BITMAPSET_FIELD(relids);
2514  WRITE_FLOAT_FIELD(rows, "%.0f");
2515  WRITE_BOOL_FIELD(consider_startup);
2516  WRITE_BOOL_FIELD(consider_param_startup);
2517  WRITE_BOOL_FIELD(consider_parallel);
2518  WRITE_NODE_FIELD(reltarget);
2519  WRITE_NODE_FIELD(pathlist);
2520  WRITE_NODE_FIELD(ppilist);
2521  WRITE_NODE_FIELD(partial_pathlist);
2522  WRITE_NODE_FIELD(cheapest_startup_path);
2523  WRITE_NODE_FIELD(cheapest_total_path);
2524  WRITE_NODE_FIELD(cheapest_unique_path);
2525  WRITE_NODE_FIELD(cheapest_parameterized_paths);
2526  WRITE_BITMAPSET_FIELD(direct_lateral_relids);
2527  WRITE_BITMAPSET_FIELD(lateral_relids);
2528  WRITE_UINT_FIELD(relid);
2529  WRITE_OID_FIELD(reltablespace);
2530  WRITE_ENUM_FIELD(rtekind, RTEKind);
2531  WRITE_INT_FIELD(min_attr);
2532  WRITE_INT_FIELD(max_attr);
2533  WRITE_NODE_FIELD(lateral_vars);
2534  WRITE_BITMAPSET_FIELD(lateral_referencers);
2535  WRITE_NODE_FIELD(indexlist);
2536  WRITE_NODE_FIELD(statlist);
2537  WRITE_UINT_FIELD(pages);
2538  WRITE_FLOAT_FIELD(tuples, "%.0f");
2539  WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
2540  WRITE_BITMAPSET_FIELD(eclass_indexes);
2541  WRITE_NODE_FIELD(subroot);
2542  WRITE_NODE_FIELD(subplan_params);
2543  WRITE_INT_FIELD(rel_parallel_workers);
2544  WRITE_UINT_FIELD(amflags);
2545  WRITE_OID_FIELD(serverid);
2546  WRITE_OID_FIELD(userid);
2547  WRITE_BOOL_FIELD(useridiscurrent);
2548  /* we don't try to print fdwroutine or fdw_private */
2549  /* can't print unique_for_rels/non_unique_for_rels; BMSes aren't Nodes */
2550  WRITE_NODE_FIELD(baserestrictinfo);
2551  WRITE_UINT_FIELD(baserestrict_min_security);
2552  WRITE_NODE_FIELD(joininfo);
2553  WRITE_BOOL_FIELD(has_eclass_joins);
2554  WRITE_BOOL_FIELD(consider_partitionwise_join);
2555  WRITE_BITMAPSET_FIELD(top_parent_relids);
2556  WRITE_BOOL_FIELD(partbounds_merged);
2557  WRITE_BITMAPSET_FIELD(live_parts);
2558  WRITE_BITMAPSET_FIELD(all_partrels);
2559 }
2560 
2561 static void
2563 {
2564  WRITE_NODE_TYPE("INDEXOPTINFO");
2565 
2566  /* NB: this isn't a complete set of fields */
2567  WRITE_OID_FIELD(indexoid);
2568  /* Do NOT print rel field, else infinite recursion */
2569  WRITE_UINT_FIELD(pages);
2570  WRITE_FLOAT_FIELD(tuples, "%.0f");
2571  WRITE_INT_FIELD(tree_height);
2572  WRITE_INT_FIELD(ncolumns);
2573  /* array fields aren't really worth the trouble to print */
2574  WRITE_OID_FIELD(relam);
2575  /* indexprs is redundant since we print indextlist */
2576  WRITE_NODE_FIELD(indpred);
2577  WRITE_NODE_FIELD(indextlist);
2578  WRITE_NODE_FIELD(indrestrictinfo);
2579  WRITE_BOOL_FIELD(predOK);
2580  WRITE_BOOL_FIELD(unique);
2581  WRITE_BOOL_FIELD(immediate);
2582  WRITE_BOOL_FIELD(hypothetical);
2583  /* we don't bother with fields copied from the index AM's API struct */
2584 }
2585 
2586 static void
2588 {
2589  int i;
2590 
2591  WRITE_NODE_TYPE("FOREIGNKEYOPTINFO");
2592 
2593  WRITE_UINT_FIELD(con_relid);
2594  WRITE_UINT_FIELD(ref_relid);
2595  WRITE_INT_FIELD(nkeys);
2596  WRITE_ATTRNUMBER_ARRAY(conkey, node->nkeys);
2597  WRITE_ATTRNUMBER_ARRAY(confkey, node->nkeys);
2598  WRITE_OID_ARRAY(conpfeqop, node->nkeys);
2599  WRITE_INT_FIELD(nmatched_ec);
2600  WRITE_INT_FIELD(nconst_ec);
2601  WRITE_INT_FIELD(nmatched_rcols);
2602  WRITE_INT_FIELD(nmatched_ri);
2603  /* for compactness, just print the number of matches per column: */
2604  appendStringInfoString(str, " :eclass");
2605  for (i = 0; i < node->nkeys; i++)
2606  appendStringInfo(str, " %d", (node->eclass[i] != NULL));
2607  appendStringInfoString(str, " :rinfos");
2608  for (i = 0; i < node->nkeys; i++)
2609  appendStringInfo(str, " %d", list_length(node->rinfos[i]));
2610 }
2611 
2612 static void
2614 {
2615  WRITE_NODE_TYPE("STATISTICEXTINFO");
2616 
2617  /* NB: this isn't a complete set of fields */
2618  WRITE_OID_FIELD(statOid);
2619  /* don't write rel, leads to infinite recursion in plan tree dump */
2620  WRITE_CHAR_FIELD(kind);
2621  WRITE_BITMAPSET_FIELD(keys);
2622 }
2623 
2624 static void
2626 {
2627  /*
2628  * To simplify reading, we just chase up to the topmost merged EC and
2629  * print that, without bothering to show the merge-ees separately.
2630  */
2631  while (node->ec_merged)
2632  node = node->ec_merged;
2633 
2634  WRITE_NODE_TYPE("EQUIVALENCECLASS");
2635 
2636  WRITE_NODE_FIELD(ec_opfamilies);
2637  WRITE_OID_FIELD(ec_collation);
2638  WRITE_NODE_FIELD(ec_members);
2639  WRITE_NODE_FIELD(ec_sources);
2640  WRITE_NODE_FIELD(ec_derives);
2641  WRITE_BITMAPSET_FIELD(ec_relids);
2642  WRITE_BOOL_FIELD(ec_has_const);
2643  WRITE_BOOL_FIELD(ec_has_volatile);
2644  WRITE_BOOL_FIELD(ec_below_outer_join);
2645  WRITE_BOOL_FIELD(ec_broken);
2646  WRITE_UINT_FIELD(ec_sortref);
2647  WRITE_UINT_FIELD(ec_min_security);
2648  WRITE_UINT_FIELD(ec_max_security);
2649 }
2650 
2651 static void
2653 {
2654  WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
2655 
2656  WRITE_NODE_FIELD(em_expr);
2657  WRITE_BITMAPSET_FIELD(em_relids);
2658  WRITE_BITMAPSET_FIELD(em_nullable_relids);
2659  WRITE_BOOL_FIELD(em_is_const);
2660  WRITE_BOOL_FIELD(em_is_child);
2661  WRITE_OID_FIELD(em_datatype);
2662 }
2663 
2664 static void
2666 {
2667  WRITE_NODE_TYPE("PATHKEY");
2668 
2669  WRITE_NODE_FIELD(pk_eclass);
2670  WRITE_OID_FIELD(pk_opfamily);
2671  WRITE_INT_FIELD(pk_strategy);
2672  WRITE_BOOL_FIELD(pk_nulls_first);
2673 }
2674 
2675 static void
2677 {
2678  WRITE_NODE_TYPE("PATHTARGET");
2679 
2680  WRITE_NODE_FIELD(exprs);
2681  WRITE_INDEX_ARRAY(sortgrouprefs, list_length(node->exprs));
2682  WRITE_FLOAT_FIELD(cost.startup, "%.2f");
2683  WRITE_FLOAT_FIELD(cost.per_tuple, "%.2f");
2684  WRITE_INT_FIELD(width);
2685  WRITE_ENUM_FIELD(has_volatile_expr, VolatileFunctionStatus);
2686 }
2687 
2688 static void
2690 {
2691  WRITE_NODE_TYPE("PARAMPATHINFO");
2692 
2693  WRITE_BITMAPSET_FIELD(ppi_req_outer);
2694  WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
2695  WRITE_NODE_FIELD(ppi_clauses);
2696 }
2697 
2698 static void
2700 {
2701  WRITE_NODE_TYPE("RESTRICTINFO");
2702 
2703  /* NB: this isn't a complete set of fields */
2704  WRITE_NODE_FIELD(clause);
2705  WRITE_BOOL_FIELD(is_pushed_down);
2706  WRITE_BOOL_FIELD(outerjoin_delayed);
2707  WRITE_BOOL_FIELD(can_join);
2708  WRITE_BOOL_FIELD(pseudoconstant);
2709  WRITE_BOOL_FIELD(leakproof);
2711  WRITE_UINT_FIELD(security_level);
2712  WRITE_BITMAPSET_FIELD(clause_relids);
2713  WRITE_BITMAPSET_FIELD(required_relids);
2714  WRITE_BITMAPSET_FIELD(outer_relids);
2715  WRITE_BITMAPSET_FIELD(nullable_relids);
2716  WRITE_BITMAPSET_FIELD(left_relids);
2717  WRITE_BITMAPSET_FIELD(right_relids);
2718  WRITE_NODE_FIELD(orclause);
2719  /* don't write parent_ec, leads to infinite recursion in plan tree dump */
2720  WRITE_FLOAT_FIELD(norm_selec, "%.4f");
2721  WRITE_FLOAT_FIELD(outer_selec, "%.4f");
2722  WRITE_NODE_FIELD(mergeopfamilies);
2723  /* don't write left_ec, leads to infinite recursion in plan tree dump */
2724  /* don't write right_ec, leads to infinite recursion in plan tree dump */
2725  WRITE_NODE_FIELD(left_em);
2726  WRITE_NODE_FIELD(right_em);
2727  WRITE_BOOL_FIELD(outer_is_left);
2728  WRITE_OID_FIELD(hashjoinoperator);
2729  WRITE_OID_FIELD(left_hasheqoperator);
2730  WRITE_OID_FIELD(right_hasheqoperator);
2731 }
2732 
2733 static void
2735 {
2736  WRITE_NODE_TYPE("INDEXCLAUSE");
2737 
2738  WRITE_NODE_FIELD(rinfo);
2739  WRITE_NODE_FIELD(indexquals);
2740  WRITE_BOOL_FIELD(lossy);
2741  WRITE_INT_FIELD(indexcol);
2742  WRITE_NODE_FIELD(indexcols);
2743 }
2744 
2745 static void
2747 {
2748  WRITE_NODE_TYPE("PLACEHOLDERVAR");
2749 
2750  WRITE_NODE_FIELD(phexpr);
2751  WRITE_BITMAPSET_FIELD(phrels);
2752  WRITE_UINT_FIELD(phid);
2753  WRITE_UINT_FIELD(phlevelsup);
2754 }
2755 
2756 static void
2758 {
2759  WRITE_NODE_TYPE("SPECIALJOININFO");
2760 
2761  WRITE_BITMAPSET_FIELD(min_lefthand);
2762  WRITE_BITMAPSET_FIELD(min_righthand);
2763  WRITE_BITMAPSET_FIELD(syn_lefthand);
2764  WRITE_BITMAPSET_FIELD(syn_righthand);
2765  WRITE_ENUM_FIELD(jointype, JoinType);
2766  WRITE_BOOL_FIELD(lhs_strict);
2767  WRITE_BOOL_FIELD(delay_upper_joins);
2768  WRITE_BOOL_FIELD(semi_can_btree);
2769  WRITE_BOOL_FIELD(semi_can_hash);
2770  WRITE_NODE_FIELD(semi_operators);
2771  WRITE_NODE_FIELD(semi_rhs_exprs);
2772 }
2773 
2774 static void
2776 {
2777  WRITE_NODE_TYPE("APPENDRELINFO");
2778 
2779  WRITE_UINT_FIELD(parent_relid);
2780  WRITE_UINT_FIELD(child_relid);
2781  WRITE_OID_FIELD(parent_reltype);
2782  WRITE_OID_FIELD(child_reltype);
2783  WRITE_NODE_FIELD(translated_vars);
2784  WRITE_INT_FIELD(num_child_cols);
2785  WRITE_ATTRNUMBER_ARRAY(parent_colnos, node->num_child_cols);
2786  WRITE_OID_FIELD(parent_reloid);
2787 }
2788 
2789 static void
2791 {
2792  WRITE_NODE_TYPE("ROWIDENTITYVARINFO");
2793 
2794  WRITE_NODE_FIELD(rowidvar);
2795  WRITE_INT_FIELD(rowidwidth);
2796  WRITE_STRING_FIELD(rowidname);
2797  WRITE_BITMAPSET_FIELD(rowidrels);
2798 }
2799 
2800 static void
2802 {
2803  WRITE_NODE_TYPE("PLACEHOLDERINFO");
2804 
2805  WRITE_UINT_FIELD(phid);
2806  WRITE_NODE_FIELD(ph_var);
2807  WRITE_BITMAPSET_FIELD(ph_eval_at);
2808  WRITE_BITMAPSET_FIELD(ph_lateral);
2809  WRITE_BITMAPSET_FIELD(ph_needed);
2810  WRITE_INT_FIELD(ph_width);
2811 }
2812 
2813 static void
2815 {
2816  WRITE_NODE_TYPE("MINMAXAGGINFO");
2817 
2818  WRITE_OID_FIELD(aggfnoid);
2819  WRITE_OID_FIELD(aggsortop);
2820  WRITE_NODE_FIELD(target);
2821  /* We intentionally omit subroot --- too large, not interesting enough */
2822  WRITE_NODE_FIELD(path);
2823  WRITE_FLOAT_FIELD(pathcost, "%.2f");
2824  WRITE_NODE_FIELD(param);
2825 }
2826 
2827 static void
2829 {
2830  WRITE_NODE_TYPE("PLANNERPARAMITEM");
2831 
2832  WRITE_NODE_FIELD(item);
2833  WRITE_INT_FIELD(paramId);
2834 }
2835 
2836 /*****************************************************************************
2837  *
2838  * Stuff from extensible.h
2839  *
2840  *****************************************************************************/
2841 
2842 static void
2844 {
2845  const ExtensibleNodeMethods *methods;
2846 
2847  methods = GetExtensibleNodeMethods(node->extnodename, false);
2848 
2849  WRITE_NODE_TYPE("EXTENSIBLENODE");
2850 
2851  WRITE_STRING_FIELD(extnodename);
2852 
2853  /* serialize the private fields */
2854  methods->nodeOut(str, node);
2855 }
2856 
2857 /*****************************************************************************
2858  *
2859  * Stuff from parsenodes.h.
2860  *
2861  *****************************************************************************/
2862 
2863 /*
2864  * print the basic stuff of all nodes that inherit from CreateStmt
2865  */
2866 static void
2868 {
2869  WRITE_NODE_FIELD(relation);
2870  WRITE_NODE_FIELD(tableElts);
2871  WRITE_NODE_FIELD(inhRelations);
2872  WRITE_NODE_FIELD(partspec);
2873  WRITE_NODE_FIELD(partbound);
2874  WRITE_NODE_FIELD(ofTypename);
2875  WRITE_NODE_FIELD(constraints);
2877  WRITE_ENUM_FIELD(oncommit, OnCommitAction);
2878  WRITE_STRING_FIELD(tablespacename);
2879  WRITE_STRING_FIELD(accessMethod);
2880  WRITE_BOOL_FIELD(if_not_exists);
2881 }
2882 
2883 static void
2885 {
2886  WRITE_NODE_TYPE("CREATESTMT");
2887 
2888  _outCreateStmtInfo(str, (const CreateStmt *) node);
2889 }
2890 
2891 static void
2893 {
2894  WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
2895 
2896  _outCreateStmtInfo(str, (const CreateStmt *) node);
2897 
2898  WRITE_STRING_FIELD(servername);
2900 }
2901 
2902 static void
2904 {
2905  WRITE_NODE_TYPE("IMPORTFOREIGNSCHEMASTMT");
2906 
2907  WRITE_STRING_FIELD(server_name);
2908  WRITE_STRING_FIELD(remote_schema);
2909  WRITE_STRING_FIELD(local_schema);
2911  WRITE_NODE_FIELD(table_list);
2913 }
2914 
2915 static void
2917 {
2918  WRITE_NODE_TYPE("INDEXSTMT");
2919 
2920  WRITE_STRING_FIELD(idxname);
2921  WRITE_NODE_FIELD(relation);
2922  WRITE_STRING_FIELD(accessMethod);
2923  WRITE_STRING_FIELD(tableSpace);
2924  WRITE_NODE_FIELD(indexParams);
2925  WRITE_NODE_FIELD(indexIncludingParams);
2927  WRITE_NODE_FIELD(whereClause);
2928  WRITE_NODE_FIELD(excludeOpNames);
2929  WRITE_STRING_FIELD(idxcomment);
2930  WRITE_OID_FIELD(indexOid);
2931  WRITE_OID_FIELD(oldNode);
2932  WRITE_UINT_FIELD(oldCreateSubid);
2933  WRITE_UINT_FIELD(oldFirstRelfilenodeSubid);
2934  WRITE_BOOL_FIELD(unique);
2935  WRITE_BOOL_FIELD(nulls_not_distinct);
2936  WRITE_BOOL_FIELD(primary);
2937  WRITE_BOOL_FIELD(isconstraint);
2938  WRITE_BOOL_FIELD(deferrable);
2939  WRITE_BOOL_FIELD(initdeferred);
2940  WRITE_BOOL_FIELD(transformed);
2941  WRITE_BOOL_FIELD(concurrent);
2942  WRITE_BOOL_FIELD(if_not_exists);
2943  WRITE_BOOL_FIELD(reset_default_tblspc);
2944 }
2945 
2946 static void
2948 {
2949  WRITE_NODE_TYPE("CREATESTATSSTMT");
2950 
2951  WRITE_NODE_FIELD(defnames);
2952  WRITE_NODE_FIELD(stat_types);
2953  WRITE_NODE_FIELD(exprs);
2954  WRITE_NODE_FIELD(relations);
2955  WRITE_STRING_FIELD(stxcomment);
2956  WRITE_BOOL_FIELD(transformed);
2957  WRITE_BOOL_FIELD(if_not_exists);
2958 }
2959 
2960 static void
2962 {
2963  WRITE_NODE_TYPE("ALTERSTATSSTMT");
2964 
2965  WRITE_NODE_FIELD(defnames);
2966  WRITE_INT_FIELD(stxstattarget);
2967  WRITE_BOOL_FIELD(missing_ok);
2968 }
2969 
2970 static void
2972 {
2973  WRITE_NODE_TYPE("NOTIFYSTMT");
2974 
2975  WRITE_STRING_FIELD(conditionname);
2976  WRITE_STRING_FIELD(payload);
2977 }
2978 
2979 static void
2981 {
2982  WRITE_NODE_TYPE("DECLARECURSORSTMT");
2983 
2984  WRITE_STRING_FIELD(portalname);
2986  WRITE_NODE_FIELD(query);
2987 }
2988 
2989 static void
2991 {
2992  WRITE_NODE_TYPE("SELECT");
2993 
2994  WRITE_NODE_FIELD(distinctClause);
2995  WRITE_NODE_FIELD(intoClause);
2996  WRITE_NODE_FIELD(targetList);
2997  WRITE_NODE_FIELD(fromClause);
2998  WRITE_NODE_FIELD(whereClause);
2999  WRITE_NODE_FIELD(groupClause);
3000  WRITE_BOOL_FIELD(groupDistinct);
3001  WRITE_NODE_FIELD(havingClause);
3002  WRITE_NODE_FIELD(windowClause);
3003  WRITE_NODE_FIELD(valuesLists);
3004  WRITE_NODE_FIELD(sortClause);
3005  WRITE_NODE_FIELD(limitOffset);
3006  WRITE_NODE_FIELD(limitCount);
3007  WRITE_ENUM_FIELD(limitOption, LimitOption);
3008  WRITE_NODE_FIELD(lockingClause);
3009  WRITE_NODE_FIELD(withClause);
3011  WRITE_BOOL_FIELD(all);
3012  WRITE_NODE_FIELD(larg);
3013  WRITE_NODE_FIELD(rarg);
3014 }
3015 
3016 static void
3018 {
3019  WRITE_NODE_TYPE("RETURN");
3020 
3021  WRITE_NODE_FIELD(returnval);
3022 }
3023 
3024 static void
3026 {
3027  WRITE_NODE_TYPE("PLASSIGN");
3028 
3030  WRITE_NODE_FIELD(indirection);
3031  WRITE_INT_FIELD(nnames);
3033  WRITE_LOCATION_FIELD(location);
3034 }
3035 
3036 static void
3038 {
3039  WRITE_NODE_TYPE("FUNCCALL");
3040 
3041  WRITE_NODE_FIELD(funcname);
3043  WRITE_NODE_FIELD(agg_order);
3044  WRITE_NODE_FIELD(agg_filter);
3045  WRITE_NODE_FIELD(over);
3046  WRITE_BOOL_FIELD(agg_within_group);
3047  WRITE_BOOL_FIELD(agg_star);
3048  WRITE_BOOL_FIELD(agg_distinct);
3049  WRITE_BOOL_FIELD(func_variadic);
3050  WRITE_ENUM_FIELD(funcformat, CoercionForm);
3051  WRITE_LOCATION_FIELD(location);
3052 }
3053 
3054 static void
3056 {
3057  WRITE_NODE_TYPE("DEFELEM");
3058 
3059  WRITE_STRING_FIELD(defnamespace);
3060  WRITE_STRING_FIELD(defname);
3062  WRITE_ENUM_FIELD(defaction, DefElemAction);
3063  WRITE_LOCATION_FIELD(location);
3064 }
3065 
3066 static void
3068 {
3069  WRITE_NODE_TYPE("TABLELIKECLAUSE");
3070 
3071  WRITE_NODE_FIELD(relation);
3073  WRITE_OID_FIELD(relationOid);
3074 }
3075 
3076 static void
3078 {
3079  WRITE_NODE_TYPE("LOCKINGCLAUSE");
3080 
3081  WRITE_NODE_FIELD(lockedRels);
3083  WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
3084 }
3085 
3086 static void
3088 {
3089  WRITE_NODE_TYPE("XMLSERIALIZE");
3090 
3092  WRITE_NODE_FIELD(expr);
3093  WRITE_NODE_FIELD(typeName);
3094  WRITE_LOCATION_FIELD(location);
3095 }
3096 
3097 static void
3099 {
3100  WRITE_NODE_TYPE("TRIGGERTRANSITION");
3101 
3103  WRITE_BOOL_FIELD(isNew);
3104  WRITE_BOOL_FIELD(isTable);
3105 }
3106 
3107 static void
3109 {
3110  WRITE_NODE_TYPE("COLUMNDEF");
3111 
3112  WRITE_STRING_FIELD(colname);
3113  WRITE_NODE_FIELD(typeName);
3114  WRITE_STRING_FIELD(compression);
3115  WRITE_INT_FIELD(inhcount);
3116  WRITE_BOOL_FIELD(is_local);
3117  WRITE_BOOL_FIELD(is_not_null);
3118  WRITE_BOOL_FIELD(is_from_type);
3119  WRITE_CHAR_FIELD(storage);
3120  WRITE_NODE_FIELD(raw_default);
3121  WRITE_NODE_FIELD(cooked_default);
3122  WRITE_CHAR_FIELD(identity);
3123  WRITE_NODE_FIELD(identitySequence);
3124  WRITE_CHAR_FIELD(generated);
3125  WRITE_NODE_FIELD(collClause);
3126  WRITE_OID_FIELD(collOid);
3127  WRITE_NODE_FIELD(constraints);
3128  WRITE_NODE_FIELD(fdwoptions);
3129  WRITE_LOCATION_FIELD(location);
3130 }
3131 
3132 static void
3134 {
3135  WRITE_NODE_TYPE("TYPENAME");
3136 
3137  WRITE_NODE_FIELD(names);
3138  WRITE_OID_FIELD(typeOid);
3139  WRITE_BOOL_FIELD(setof);
3140  WRITE_BOOL_FIELD(pct_type);
3141  WRITE_NODE_FIELD(typmods);
3142  WRITE_INT_FIELD(typemod);
3143  WRITE_NODE_FIELD(arrayBounds);
3144  WRITE_LOCATION_FIELD(location);
3145 }
3146 
3147 static void
3149 {
3150  WRITE_NODE_TYPE("TYPECAST");
3151 
3153  WRITE_NODE_FIELD(typeName);
3154  WRITE_LOCATION_FIELD(location);
3155 }
3156 
3157 static void
3159 {
3160  WRITE_NODE_TYPE("COLLATECLAUSE");
3161 
3163  WRITE_NODE_FIELD(collname);
3164  WRITE_LOCATION_FIELD(location);
3165 }
3166 
3167 static void
3169 {
3170  WRITE_NODE_TYPE("INDEXELEM");
3171 
3173  WRITE_NODE_FIELD(expr);
3174  WRITE_STRING_FIELD(indexcolname);
3175  WRITE_NODE_FIELD(collation);
3176  WRITE_NODE_FIELD(opclass);
3177  WRITE_NODE_FIELD(opclassopts);
3178  WRITE_ENUM_FIELD(ordering, SortByDir);
3179  WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
3180 }
3181 
3182 static void
3184 {
3185  WRITE_NODE_TYPE("STATSELEM");
3186 
3188  WRITE_NODE_FIELD(expr);
3189 }
3190 
3191 static void
3193 {
3194  WRITE_NODE_TYPE("QUERY");
3195 
3196  WRITE_ENUM_FIELD(commandType, CmdType);
3197  WRITE_ENUM_FIELD(querySource, QuerySource);
3198  /* we intentionally do not print the queryId field */
3199  WRITE_BOOL_FIELD(canSetTag);
3200 
3201  /*
3202  * Hack to work around missing outfuncs routines for a lot of the
3203  * utility-statement node types. (The only one we actually *need* for
3204  * rules support is NotifyStmt.) Someday we ought to support 'em all, but
3205  * for the meantime do this to avoid getting lots of warnings when running
3206  * with debug_print_parse on.
3207  */
3208  if (node->utilityStmt)
3209  {
3210  switch (nodeTag(node->utilityStmt))
3211  {
3212  case T_CreateStmt:
3213  case T_IndexStmt:
3214  case T_NotifyStmt:
3215  case T_DeclareCursorStmt:
3216  WRITE_NODE_FIELD(utilityStmt);
3217  break;
3218  default:
3219  appendStringInfoString(str, " :utilityStmt ?");
3220  break;
3221  }
3222  }
3223  else
3224  appendStringInfoString(str, " :utilityStmt <>");
3225 
3226  WRITE_INT_FIELD(resultRelation);
3227  WRITE_BOOL_FIELD(hasAggs);
3228  WRITE_BOOL_FIELD(hasWindowFuncs);
3229  WRITE_BOOL_FIELD(hasTargetSRFs);
3230  WRITE_BOOL_FIELD(hasSubLinks);
3231  WRITE_BOOL_FIELD(hasDistinctOn);
3232  WRITE_BOOL_FIELD(hasRecursive);
3233  WRITE_BOOL_FIELD(hasModifyingCTE);
3234  WRITE_BOOL_FIELD(hasForUpdate);
3235  WRITE_BOOL_FIELD(hasRowSecurity);
3236  WRITE_BOOL_FIELD(isReturn);
3237  WRITE_NODE_FIELD(cteList);
3238  WRITE_NODE_FIELD(rtable);
3239  WRITE_NODE_FIELD(jointree);
3240  WRITE_NODE_FIELD(targetList);
3241  WRITE_ENUM_FIELD(override, OverridingKind);
3242  WRITE_NODE_FIELD(onConflict);
3243  WRITE_NODE_FIELD(returningList);
3244  WRITE_NODE_FIELD(groupClause);
3245  WRITE_BOOL_FIELD(groupDistinct);
3246  WRITE_NODE_FIELD(groupingSets);
3247  WRITE_NODE_FIELD(havingQual);
3248  WRITE_NODE_FIELD(windowClause);
3249  WRITE_NODE_FIELD(distinctClause);
3250  WRITE_NODE_FIELD(sortClause);
3251  WRITE_NODE_FIELD(limitOffset);
3252  WRITE_NODE_FIELD(limitCount);
3253  WRITE_ENUM_FIELD(limitOption, LimitOption);
3254  WRITE_NODE_FIELD(rowMarks);
3255  WRITE_NODE_FIELD(setOperations);
3256  WRITE_NODE_FIELD(constraintDeps);
3257  WRITE_NODE_FIELD(withCheckOptions);
3258  WRITE_NODE_FIELD(mergeActionList);
3259  WRITE_BOOL_FIELD(mergeUseOuterJoin);
3260  WRITE_LOCATION_FIELD(stmt_location);
3261  WRITE_INT_FIELD(stmt_len);
3262 }
3263 
3264 static void
3266 {
3267  WRITE_NODE_TYPE("WITHCHECKOPTION");
3268 
3269  WRITE_ENUM_FIELD(kind, WCOKind);
3271  WRITE_STRING_FIELD(polname);
3272  WRITE_NODE_FIELD(qual);
3273  WRITE_BOOL_FIELD(cascaded);
3274 }
3275 
3276 static void
3278 {
3279  WRITE_NODE_TYPE("SORTGROUPCLAUSE");
3280 
3281  WRITE_UINT_FIELD(tleSortGroupRef);
3282  WRITE_OID_FIELD(eqop);
3283  WRITE_OID_FIELD(sortop);
3284  WRITE_BOOL_FIELD(nulls_first);
3285  WRITE_BOOL_FIELD(hashable);
3286 }
3287 
3288 static void
3290 {
3291  WRITE_NODE_TYPE("GROUPINGSET");
3292 
3294  WRITE_NODE_FIELD(content);
3295  WRITE_LOCATION_FIELD(location);
3296 }
3297 
3298 static void
3300 {
3301  WRITE_NODE_TYPE("WINDOWCLAUSE");
3302 
3304  WRITE_STRING_FIELD(refname);
3305  WRITE_NODE_FIELD(partitionClause);
3306  WRITE_NODE_FIELD(orderClause);
3307  WRITE_INT_FIELD(frameOptions);
3308  WRITE_NODE_FIELD(startOffset);
3309  WRITE_NODE_FIELD(endOffset);
3310  WRITE_NODE_FIELD(runCondition);
3311  WRITE_OID_FIELD(startInRangeFunc);
3312  WRITE_OID_FIELD(endInRangeFunc);
3313  WRITE_OID_FIELD(inRangeColl);
3314  WRITE_BOOL_FIELD(inRangeAsc);
3315  WRITE_BOOL_FIELD(inRangeNullsFirst);
3316  WRITE_UINT_FIELD(winref);
3317  WRITE_BOOL_FIELD(copiedOrder);
3318 }
3319 
3320 static void
3322 {
3323  WRITE_NODE_TYPE("ROWMARKCLAUSE");
3324 
3325  WRITE_UINT_FIELD(rti);
3327  WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
3328  WRITE_BOOL_FIELD(pushedDown);
3329 }
3330 
3331 static void
3333 {
3334  WRITE_NODE_TYPE("WITHCLAUSE");
3335 
3336  WRITE_NODE_FIELD(ctes);
3337  WRITE_BOOL_FIELD(recursive);
3338  WRITE_LOCATION_FIELD(location);
3339 }
3340 
3341 static void
3343 {
3344  WRITE_NODE_TYPE("CTESEARCHCLAUSE");
3345 
3346  WRITE_NODE_FIELD(search_col_list);
3347  WRITE_BOOL_FIELD(search_breadth_first);
3348  WRITE_STRING_FIELD(search_seq_column);
3349  WRITE_LOCATION_FIELD(location);
3350 }
3351 
3352 static void
3354 {
3355  WRITE_NODE_TYPE("CTECYCLECLAUSE");
3356 
3357  WRITE_NODE_FIELD(cycle_col_list);
3358  WRITE_STRING_FIELD(cycle_mark_column);
3359  WRITE_NODE_FIELD(cycle_mark_value);
3360  WRITE_NODE_FIELD(cycle_mark_default);
3361  WRITE_STRING_FIELD(cycle_path_column);
3362  WRITE_LOCATION_FIELD(location);
3363  WRITE_OID_FIELD(cycle_mark_type);
3364  WRITE_INT_FIELD(cycle_mark_typmod);
3365  WRITE_OID_FIELD(cycle_mark_collation);
3366  WRITE_OID_FIELD(cycle_mark_neop);
3367 }
3368 
3369 static void
3371 {
3372  WRITE_NODE_TYPE("COMMONTABLEEXPR");
3373 
3374  WRITE_STRING_FIELD(ctename);
3375  WRITE_NODE_FIELD(aliascolnames);
3376  WRITE_ENUM_FIELD(ctematerialized, CTEMaterialize);
3377  WRITE_NODE_FIELD(ctequery);
3378  WRITE_NODE_FIELD(search_clause);
3379  WRITE_NODE_FIELD(cycle_clause);
3380  WRITE_LOCATION_FIELD(location);
3381  WRITE_BOOL_FIELD(cterecursive);
3382  WRITE_INT_FIELD(cterefcount);
3383  WRITE_NODE_FIELD(ctecolnames);
3384  WRITE_NODE_FIELD(ctecoltypes);
3385  WRITE_NODE_FIELD(ctecoltypmods);
3386  WRITE_NODE_FIELD(ctecolcollations);
3387 }
3388 
3389 static void
3391 {
3392  WRITE_NODE_TYPE("MERGEWHENCLAUSE");
3393 
3394  WRITE_BOOL_FIELD(matched);
3395  WRITE_ENUM_FIELD(commandType, CmdType);
3396  WRITE_ENUM_FIELD(override, OverridingKind);
3397  WRITE_NODE_FIELD(condition);
3398  WRITE_NODE_FIELD(targetList);
3400 }
3401 
3402 static void
3404 {
3405  WRITE_NODE_TYPE("MERGEACTION");
3406 
3407  WRITE_BOOL_FIELD(matched);
3408  WRITE_ENUM_FIELD(commandType, CmdType);
3409  WRITE_ENUM_FIELD(override, OverridingKind);
3410  WRITE_NODE_FIELD(qual);
3411  WRITE_NODE_FIELD(targetList);
3412  WRITE_NODE_FIELD(updateColnos);
3413 }
3414 
3415 static void
3417 {
3418  WRITE_NODE_TYPE("SETOPERATIONSTMT");
3419 
3421  WRITE_BOOL_FIELD(all);
3422  WRITE_NODE_FIELD(larg);
3423  WRITE_NODE_FIELD(rarg);
3424  WRITE_NODE_FIELD(colTypes);
3425  WRITE_NODE_FIELD(colTypmods);
3426  WRITE_NODE_FIELD(colCollations);
3427  WRITE_NODE_FIELD(groupClauses);
3428 }
3429 
3430 static void
3432 {
3433  WRITE_NODE_TYPE("RANGETBLENTRY");
3434 
3435  /* put alias + eref first to make dump more legible */
3436  WRITE_NODE_FIELD(alias);
3437  WRITE_NODE_FIELD(eref);
3438  WRITE_ENUM_FIELD(rtekind, RTEKind);
3439 
3440  switch (node->rtekind)
3441  {
3442  case RTE_RELATION:
3443  WRITE_OID_FIELD(relid);
3444  WRITE_CHAR_FIELD(relkind);
3445  WRITE_INT_FIELD(rellockmode);
3446  WRITE_NODE_FIELD(tablesample);
3447  break;
3448  case RTE_SUBQUERY:
3449  WRITE_NODE_FIELD(subquery);
3450  WRITE_BOOL_FIELD(security_barrier);
3451  break;
3452  case RTE_JOIN:
3453  WRITE_ENUM_FIELD(jointype, JoinType);
3454  WRITE_INT_FIELD(joinmergedcols);
3455  WRITE_NODE_FIELD(joinaliasvars);
3456  WRITE_NODE_FIELD(joinleftcols);
3457  WRITE_NODE_FIELD(joinrightcols);
3458  WRITE_NODE_FIELD(join_using_alias);
3459  break;
3460  case RTE_FUNCTION:
3462  WRITE_BOOL_FIELD(funcordinality);
3463  break;
3464  case RTE_TABLEFUNC:
3465  WRITE_NODE_FIELD(tablefunc);
3466  break;
3467  case RTE_VALUES:
3468  WRITE_NODE_FIELD(values_lists);
3469  WRITE_NODE_FIELD(coltypes);
3470  WRITE_NODE_FIELD(coltypmods);
3471  WRITE_NODE_FIELD(colcollations);
3472  break;
3473  case RTE_CTE:
3474  WRITE_STRING_FIELD(ctename);
3475  WRITE_UINT_FIELD(ctelevelsup);
3476  WRITE_BOOL_FIELD(self_reference);
3477  WRITE_NODE_FIELD(coltypes);
3478  WRITE_NODE_FIELD(coltypmods);
3479  WRITE_NODE_FIELD(colcollations);
3480  break;
3481  case RTE_NAMEDTUPLESTORE:
3482  WRITE_STRING_FIELD(enrname);
3483  WRITE_FLOAT_FIELD(enrtuples, "%.0f");
3484  WRITE_OID_FIELD(relid);
3485  WRITE_NODE_FIELD(coltypes);
3486  WRITE_NODE_FIELD(coltypmods);
3487  WRITE_NODE_FIELD(colcollations);
3488  break;
3489  case RTE_RESULT:
3490  /* no extra fields */
3491  break;
3492  default:
3493  elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
3494  break;
3495  }
3496 
3497  WRITE_BOOL_FIELD(lateral);
3498  WRITE_BOOL_FIELD(inh);
3499  WRITE_BOOL_FIELD(inFromCl);
3500  WRITE_UINT_FIELD(requiredPerms);
3501  WRITE_OID_FIELD(checkAsUser);
3502  WRITE_BITMAPSET_FIELD(selectedCols);
3503  WRITE_BITMAPSET_FIELD(insertedCols);
3504  WRITE_BITMAPSET_FIELD(updatedCols);
3505  WRITE_BITMAPSET_FIELD(extraUpdatedCols);
3506  WRITE_NODE_FIELD(securityQuals);
3507 }
3508 
3509 static void
3511 {
3512  WRITE_NODE_TYPE("RANGETBLFUNCTION");
3513 
3514  WRITE_NODE_FIELD(funcexpr);
3515  WRITE_INT_FIELD(funccolcount);
3516  WRITE_NODE_FIELD(funccolnames);
3517  WRITE_NODE_FIELD(funccoltypes);
3518  WRITE_NODE_FIELD(funccoltypmods);
3519  WRITE_NODE_FIELD(funccolcollations);
3520  WRITE_BITMAPSET_FIELD(funcparams);
3521 }
3522 
3523 static void
3525 {
3526  WRITE_NODE_TYPE("TABLESAMPLECLAUSE");
3527 
3528  WRITE_OID_FIELD(tsmhandler);
3530  WRITE_NODE_FIELD(repeatable);
3531 }
3532 
3533 static void
3535 {
3536  WRITE_NODE_TYPE("AEXPR");
3537 
3538  switch (node->kind)
3539  {
3540  case AEXPR_OP:
3541  appendStringInfoChar(str, ' ');
3543  break;
3544  case AEXPR_OP_ANY:
3545  appendStringInfoChar(str, ' ');
3547  appendStringInfoString(str, " ANY ");
3548  break;
3549  case AEXPR_OP_ALL:
3550  appendStringInfoChar(str, ' ');
3552  appendStringInfoString(str, " ALL ");
3553  break;
3554  case AEXPR_DISTINCT:
3555  appendStringInfoString(str, " DISTINCT ");
3557  break;
3558  case AEXPR_NOT_DISTINCT:
3559  appendStringInfoString(str, " NOT_DISTINCT ");
3561  break;
3562  case AEXPR_NULLIF:
3563  appendStringInfoString(str, " NULLIF ");
3565  break;
3566  case AEXPR_IN:
3567  appendStringInfoString(str, " IN ");
3569  break;
3570  case AEXPR_LIKE:
3571  appendStringInfoString(str, " LIKE ");
3573  break;
3574  case AEXPR_ILIKE:
3575  appendStringInfoString(str, " ILIKE ");
3577  break;
3578  case AEXPR_SIMILAR:
3579  appendStringInfoString(str, " SIMILAR ");
3581  break;
3582  case AEXPR_BETWEEN:
3583  appendStringInfoString(str, " BETWEEN ");
3585  break;
3586  case AEXPR_NOT_BETWEEN:
3587  appendStringInfoString(str, " NOT_BETWEEN ");
3589  break;
3590  case AEXPR_BETWEEN_SYM:
3591  appendStringInfoString(str, " BETWEEN_SYM ");
3593  break;
3594  case AEXPR_NOT_BETWEEN_SYM:
3595  appendStringInfoString(str, " NOT_BETWEEN_SYM ");
3597  break;
3598  default:
3599  appendStringInfoString(str, " ??");
3600  break;
3601  }
3602 
3603  WRITE_NODE_FIELD(lexpr);
3604  WRITE_NODE_FIELD(rexpr);
3605  WRITE_LOCATION_FIELD(location);
3606 }
3607 
3608 static void
3610 {
3611  appendStringInfo(str, "%d", node->ival);
3612 }
3613 
3614 static void
3616 {
3617  /*
3618  * We assume the value is a valid numeric literal and so does not need
3619  * quoting.
3620  */
3622 }
3623 
3624 static void
3626 {
3627  appendStringInfoString(str, node->boolval ? "true" : "false");
3628 }
3629 
3630 static void
3632 {
3633  /*
3634  * We use outToken to provide escaping of the string's content, but we
3635  * don't want it to do anything with an empty string.
3636  */
3637  appendStringInfoChar(str, '"');
3638  if (node->sval[0] != '\0')
3639  outToken(str, node->sval);
3640  appendStringInfoChar(str, '"');
3641 }
3642 
3643 static void
3645 {
3646  /* internal representation already has leading 'b' */
3648 }
3649 
3650 static void
3652 {
3653  WRITE_NODE_TYPE("COLUMNREF");
3654 
3655  WRITE_NODE_FIELD(fields);
3656  WRITE_LOCATION_FIELD(location);
3657 }
3658 
3659 static void
3661 {
3662  WRITE_NODE_TYPE("PARAMREF");
3663 
3664  WRITE_INT_FIELD(number);
3665  WRITE_LOCATION_FIELD(location);
3666 }
3667 
3668 /*
3669  * Node types found in raw parse trees (supported for debug purposes)
3670  */
3671 
3672 static void
3674 {
3675  WRITE_NODE_TYPE("RAWSTMT");
3676 
3677  WRITE_NODE_FIELD(stmt);
3678  WRITE_LOCATION_FIELD(stmt_location);
3679  WRITE_INT_FIELD(stmt_len);
3680 }
3681 
3682 static void
3684 {
3685  WRITE_NODE_TYPE("A_CONST");
3686 
3687  if (node->isnull)
3688  appendStringInfoString(str, "NULL");
3689  else
3690  {
3691  appendStringInfoString(str, " :val ");
3692  outNode(str, &node->val);
3693  }
3694  WRITE_LOCATION_FIELD(location);
3695 }
3696 
3697 static void
3699 {
3700  WRITE_NODE_TYPE("A_STAR");
3701 }
3702 
3703 static void
3705 {
3706  WRITE_NODE_TYPE("A_INDICES");
3707 
3708  WRITE_BOOL_FIELD(is_slice);
3709  WRITE_NODE_FIELD(lidx);
3710  WRITE_NODE_FIELD(uidx);
3711 }
3712 
3713 static void
3715 {
3716  WRITE_NODE_TYPE("A_INDIRECTION");
3717 
3719  WRITE_NODE_FIELD(indirection);
3720 }
3721 
3722 static void
3724 {
3725  WRITE_NODE_TYPE("A_ARRAYEXPR");
3726 
3727  WRITE_NODE_FIELD(elements);
3728  WRITE_LOCATION_FIELD(location);
3729 }
3730 
3731 static void
3733 {
3734  WRITE_NODE_TYPE("RESTARGET");
3735 
3737  WRITE_NODE_FIELD(indirection);
3739  WRITE_LOCATION_FIELD(location);
3740 }
3741 
3742 static void
3744 {
3745  WRITE_NODE_TYPE("MULTIASSIGNREF");
3746 
3748  WRITE_INT_FIELD(colno);
3749  WRITE_INT_FIELD(ncolumns);
3750 }
3751 
3752 static void
3754 {
3755  WRITE_NODE_TYPE("SORTBY");
3756 
3757  WRITE_NODE_FIELD(node);
3758  WRITE_ENUM_FIELD(sortby_dir, SortByDir);
3759  WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
3760  WRITE_NODE_FIELD(useOp);
3761  WRITE_LOCATION_FIELD(location);
3762 }
3763 
3764 static void
3766 {
3767  WRITE_NODE_TYPE("WINDOWDEF");
3768 
3770  WRITE_STRING_FIELD(refname);
3771  WRITE_NODE_FIELD(partitionClause);
3772  WRITE_NODE_FIELD(orderClause);
3773  WRITE_INT_FIELD(frameOptions);
3774  WRITE_NODE_FIELD(startOffset);
3775  WRITE_NODE_FIELD(endOffset);
3776  WRITE_LOCATION_FIELD(location);
3777 }
3778 
3779 static void
3781 {
3782  WRITE_NODE_TYPE("RANGESUBSELECT");
3783 
3784  WRITE_BOOL_FIELD(lateral);
3785  WRITE_NODE_FIELD(subquery);
3786  WRITE_NODE_FIELD(alias);
3787 }
3788 
3789 static void
3791 {
3792  WRITE_NODE_TYPE("RANGEFUNCTION");
3793 
3794  WRITE_BOOL_FIELD(lateral);
3795  WRITE_BOOL_FIELD(ordinality);
3796  WRITE_BOOL_FIELD(is_rowsfrom);
3798  WRITE_NODE_FIELD(alias);
3799  WRITE_NODE_FIELD(coldeflist);
3800 }
3801 
3802 static void
3804 {
3805  WRITE_NODE_TYPE("RANGETABLESAMPLE");
3806 
3807  WRITE_NODE_FIELD(relation);
3808  WRITE_NODE_FIELD(method);
3810  WRITE_NODE_FIELD(repeatable);
3811  WRITE_LOCATION_FIELD(location);
3812 }
3813 
3814 static void
3816 {
3817  WRITE_NODE_TYPE("RANGETABLEFUNC");
3818 
3819  WRITE_BOOL_FIELD(lateral);
3820  WRITE_NODE_FIELD(docexpr);
3821  WRITE_NODE_FIELD(rowexpr);
3822  WRITE_NODE_FIELD(namespaces);
3823  WRITE_NODE_FIELD(columns);
3824  WRITE_NODE_FIELD(alias);
3825  WRITE_LOCATION_FIELD(location);
3826 }
3827 
3828 static void
3830 {
3831  WRITE_NODE_TYPE("RANGETABLEFUNCCOL");
3832 
3833  WRITE_STRING_FIELD(colname);
3834  WRITE_NODE_FIELD(typeName);
3835  WRITE_BOOL_FIELD(for_ordinality);
3836  WRITE_BOOL_FIELD(is_not_null);
3837  WRITE_NODE_FIELD(colexpr);
3838  WRITE_NODE_FIELD(coldefexpr);
3839  WRITE_LOCATION_FIELD(location);
3840 }
3841 
3842 static void
3844 {
3845  WRITE_NODE_TYPE("CONSTRAINT");
3846 
3847  WRITE_STRING_FIELD(conname);
3848  WRITE_BOOL_FIELD(deferrable);
3849  WRITE_BOOL_FIELD(initdeferred);
3850  WRITE_LOCATION_FIELD(location);
3851 
3852  appendStringInfoString(str, " :contype ");
3853  switch (node->contype)
3854  {
3855  case CONSTR_NULL:
3856  appendStringInfoString(str, "NULL");
3857  break;
3858 
3859  case CONSTR_NOTNULL:
3860  appendStringInfoString(str, "NOT_NULL");
3861  break;
3862 
3863  case CONSTR_DEFAULT:
3864  appendStringInfoString(str, "DEFAULT");
3865  WRITE_NODE_FIELD(raw_expr);
3866  WRITE_STRING_FIELD(cooked_expr);
3867  break;
3868 
3869  case CONSTR_IDENTITY:
3870  appendStringInfoString(str, "IDENTITY");
3871  WRITE_NODE_FIELD(raw_expr);
3872  WRITE_STRING_FIELD(cooked_expr);
3873  WRITE_CHAR_FIELD(generated_when);
3874  break;
3875 
3876  case CONSTR_GENERATED:
3877  appendStringInfoString(str, "GENERATED");
3878  WRITE_NODE_FIELD(raw_expr);
3879  WRITE_STRING_FIELD(cooked_expr);
3880  WRITE_CHAR_FIELD(generated_when);
3881  break;
3882 
3883  case CONSTR_CHECK:
3884  appendStringInfoString(str, "CHECK");
3885  WRITE_BOOL_FIELD(is_no_inherit);
3886  WRITE_NODE_FIELD(raw_expr);
3887  WRITE_STRING_FIELD(cooked_expr);
3888  break;
3889 
3890  case CONSTR_PRIMARY:
3891  appendStringInfoString(str, "PRIMARY_KEY");
3892  WRITE_NODE_FIELD(keys);
3893  WRITE_NODE_FIELD(including);
3895  WRITE_STRING_FIELD(indexname);
3896  WRITE_STRING_FIELD(indexspace);
3897  WRITE_BOOL_FIELD(reset_default_tblspc);
3898  /* access_method and where_clause not currently used */
3899  break;
3900 
3901  case CONSTR_UNIQUE:
3902  appendStringInfoString(str, "UNIQUE");
3903  WRITE_BOOL_FIELD(nulls_not_distinct);
3904  WRITE_NODE_FIELD(keys);
3905  WRITE_NODE_FIELD(including);
3907  WRITE_STRING_FIELD(indexname);
3908  WRITE_STRING_FIELD(indexspace);
3909  WRITE_BOOL_FIELD(reset_default_tblspc);
3910  /* access_method and where_clause not currently used */
3911  break;
3912 
3913  case CONSTR_EXCLUSION:
3914  appendStringInfoString(str, "EXCLUSION");
3915  WRITE_NODE_FIELD(exclusions);
3916  WRITE_NODE_FIELD(including);
3918  WRITE_STRING_FIELD(indexname);
3919  WRITE_STRING_FIELD(indexspace);
3920  WRITE_BOOL_FIELD(reset_default_tblspc);
3921  WRITE_STRING_FIELD(access_method);
3922  WRITE_NODE_FIELD(where_clause);
3923  break;
3924 
3925  case CONSTR_FOREIGN:
3926  appendStringInfoString(str, "FOREIGN_KEY");
3927  WRITE_NODE_FIELD(pktable);
3928  WRITE_NODE_FIELD(fk_attrs);
3929  WRITE_NODE_FIELD(pk_attrs);
3930  WRITE_CHAR_FIELD(fk_matchtype);
3931  WRITE_CHAR_FIELD(fk_upd_action);
3932  WRITE_CHAR_FIELD(fk_del_action);
3933  WRITE_NODE_FIELD(fk_del_set_cols);
3934  WRITE_NODE_FIELD(old_conpfeqop);
3935  WRITE_OID_FIELD(old_pktable_oid);
3936  WRITE_BOOL_FIELD(skip_validation);
3937  WRITE_BOOL_FIELD(initially_valid);
3938  break;
3939 
3941  appendStringInfoString(str, "ATTR_DEFERRABLE");
3942  break;
3943 
3945  appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
3946  break;
3947 
3948  case CONSTR_ATTR_DEFERRED:
3949  appendStringInfoString(str, "ATTR_DEFERRED");
3950  break;
3951 
3952  case CONSTR_ATTR_IMMEDIATE:
3953  appendStringInfoString(str, "ATTR_IMMEDIATE");
3954  break;
3955 
3956  default:
3957  appendStringInfo(str, "<unrecognized_constraint %d>",
3958  (int) node->contype);
3959  break;
3960  }
3961 }
3962 
3963 static void
3965 {
3966  WRITE_NODE_TYPE("FOREIGNKEYCACHEINFO");
3967 
3968  WRITE_OID_FIELD(conoid);
3969  WRITE_OID_FIELD(conrelid);
3970  WRITE_OID_FIELD(confrelid);
3971  WRITE_INT_FIELD(nkeys);
3972  WRITE_ATTRNUMBER_ARRAY(conkey, node->nkeys);
3973  WRITE_ATTRNUMBER_ARRAY(confkey, node->nkeys);
3974  WRITE_OID_ARRAY(conpfeqop, node->nkeys);
3975 }
3976 
3977 static void
3979 {
3980  WRITE_NODE_TYPE("PARTITIONELEM");
3981 
3983  WRITE_NODE_FIELD(expr);
3984  WRITE_NODE_FIELD(collation);
3985  WRITE_NODE_FIELD(opclass);
3986  WRITE_LOCATION_FIELD(location);
3987 }
3988 
3989 static void
3991 {
3992  WRITE_NODE_TYPE("PARTITIONSPEC");
3993 
3994  WRITE_STRING_FIELD(strategy);
3995  WRITE_NODE_FIELD(partParams);
3996  WRITE_LOCATION_FIELD(location);
3997 }
3998 
3999 static void
4001 {
4002  WRITE_NODE_TYPE("PARTITIONBOUNDSPEC");
4003 
4004  WRITE_CHAR_FIELD(strategy);
4005  WRITE_BOOL_FIELD(is_default);
4006  WRITE_INT_FIELD(modulus);
4007  WRITE_INT_FIELD(remainder);
4008  WRITE_NODE_FIELD(listdatums);
4009  WRITE_NODE_FIELD(lowerdatums);
4010  WRITE_NODE_FIELD(upperdatums);
4011  WRITE_LOCATION_FIELD(location);
4012 }
4013 
4014 static void
4016 {
4017  WRITE_NODE_TYPE("PARTITIONRANGEDATUM");
4018 
4021  WRITE_LOCATION_FIELD(location);
4022 }
4023 
4024 /*
4025  * outNode -
4026  * converts a Node into ascii string and append it to 'str'
4027  */
4028 void
4029 outNode(StringInfo str, const void *obj)
4030 {
4031  /* Guard against stack overflow due to overly complex expressions */
4033 
4034  if (obj == NULL)
4035  appendStringInfoString(str, "<>");
4036  else if (IsA(obj, List) || IsA(obj, IntList) || IsA(obj, OidList))
4037  _outList(str, obj);
4038  /* nodeRead does not want to see { } around these! */
4039  else if (IsA(obj, Integer))
4040  _outInteger(str, (Integer *) obj);
4041  else if (IsA(obj, Float))
4042  _outFloat(str, (Float *) obj);
4043  else if (IsA(obj, Boolean))
4044  _outBoolean(str, (Boolean *) obj);
4045  else if (IsA(obj, String))
4046  _outString(str, (String *) obj);
4047  else if (IsA(obj, BitString))
4048  _outBitString(str, (BitString *) obj);
4049  else
4050  {
4051  appendStringInfoChar(str, '{');
4052  switch (nodeTag(obj))
4053  {
4054  case T_PlannedStmt:
4055  _outPlannedStmt(str, obj);
4056  break;
4057  case T_Plan:
4058  _outPlan(str, obj);
4059  break;
4060  case T_Result:
4061  _outResult(str, obj);
4062  break;
4063  case T_ProjectSet:
4064  _outProjectSet(str, obj);
4065  break;
4066  case T_ModifyTable:
4067  _outModifyTable(str, obj);
4068  break;
4069  case T_Append:
4070  _outAppend(str, obj);
4071  break;
4072  case T_MergeAppend:
4073  _outMergeAppend(str, obj);
4074  break;
4075  case T_RecursiveUnion:
4076  _outRecursiveUnion(str, obj);
4077  break;
4078  case T_BitmapAnd:
4079  _outBitmapAnd(str, obj);
4080  break;
4081  case T_BitmapOr:
4082  _outBitmapOr(str, obj);
4083  break;
4084  case T_Gather:
4085  _outGather(str, obj);
4086  break;
4087  case T_GatherMerge:
4088  _outGatherMerge(str, obj);
4089  break;
4090  case T_Scan:
4091  _outScan(str, obj);
4092  break;
4093  case T_SeqScan:
4094  _outSeqScan(str, obj);
4095  break;
4096  case T_SampleScan:
4097  _outSampleScan(str, obj);
4098  break;
4099  case T_IndexScan:
4100  _outIndexScan(str, obj);
4101  break;
4102  case T_IndexOnlyScan:
4103  _outIndexOnlyScan(str, obj);
4104  break;
4105  case T_BitmapIndexScan:
4106  _outBitmapIndexScan(str, obj);
4107  break;
4108  case T_BitmapHeapScan:
4109  _outBitmapHeapScan(str, obj);
4110  break;
4111  case T_TidScan:
4112  _outTidScan(str, obj);
4113  break;
4114  case T_TidRangeScan:
4115  _outTidRangeScan(str, obj);
4116  break;
4117  case T_SubqueryScan:
4118  _outSubqueryScan(str, obj);
4119  break;
4120  case T_FunctionScan:
4121  _outFunctionScan(str, obj);
4122  break;
4123  case T_TableFuncScan:
4124  _outTableFuncScan(str, obj);
4125  break;
4126  case T_ValuesScan:
4127  _outValuesScan(str, obj);
4128  break;
4129  case T_CteScan:
4130  _outCteScan(str, obj);
4131  break;
4132  case T_NamedTuplestoreScan:
4134  break;
4135  case T_WorkTableScan:
4136  _outWorkTableScan(str, obj);
4137  break;
4138  case T_ForeignScan:
4139  _outForeignScan(str, obj);
4140  break;
4141  case T_CustomScan:
4142  _outCustomScan(str, obj);
4143  break;
4144  case T_Join:
4145  _outJoin(str, obj);
4146  break;
4147  case T_NestLoop:
4148  _outNestLoop(str, obj);
4149  break;
4150  case T_MergeJoin:
4151  _outMergeJoin(str, obj);
4152  break;
4153  case T_HashJoin:
4154  _outHashJoin(str, obj);
4155  break;
4156  case T_Agg:
4157  _outAgg(str, obj);
4158  break;
4159  case T_WindowAgg:
4160  _outWindowAgg(str, obj);
4161  break;
4162  case T_Group:
4163  _outGroup(str, obj);
4164  break;
4165  case T_Material:
4166  _outMaterial(str, obj);
4167  break;
4168  case T_Memoize:
4169  _outMemoize(str, obj);
4170  break;
4171  case T_Sort:
4172  _outSort(str, obj);
4173  break;
4174  case T_IncrementalSort:
4175  _outIncrementalSort(str, obj);
4176  break;
4177  case T_Unique:
4178  _outUnique(str, obj);
4179  break;
4180  case T_Hash:
4181  _outHash(str, obj);
4182  break;
4183  case T_SetOp:
4184  _outSetOp(str, obj);
4185  break;
4186  case T_LockRows:
4187  _outLockRows(str, obj);
4188  break;
4189  case T_Limit:
4190  _outLimit(str, obj);
4191  break;
4192  case T_NestLoopParam:
4193  _outNestLoopParam(str, obj);
4194  break;
4195  case T_PlanRowMark:
4196  _outPlanRowMark(str, obj);
4197  break;
4198  case T_PartitionPruneInfo:
4200  break;
4203  break;
4206  break;
4209  break;
4210  case T_PlanInvalItem:
4211  _outPlanInvalItem(str, obj);
4212  break;
4213  case T_Alias:
4214  _outAlias(str, obj);
4215  break;
4216  case T_RangeVar:
4217  _outRangeVar(str, obj);
4218  break;
4219  case T_TableFunc:
4220  _outTableFunc(str, obj);
4221  break;
4222  case T_IntoClause:
4223  _outIntoClause(str, obj);
4224  break;
4225  case T_Var:
4226  _outVar(str, obj);
4227  break;
4228  case T_Const:
4229  _outConst(str, obj);
4230  break;
4231  case T_Param:
4232  _outParam(str, obj);
4233  break;
4234  case T_Aggref:
4235  _outAggref(str, obj);
4236  break;
4237  case T_GroupingFunc:
4238  _outGroupingFunc(str, obj);
4239  break;
4240  case T_WindowFunc:
4241  _outWindowFunc(str, obj);
4242  break;
4243  case T_SubscriptingRef:
4244  _outSubscriptingRef(str, obj);
4245  break;
4246  case T_FuncExpr:
4247  _outFuncExpr(str, obj);
4248  break;
4249  case T_NamedArgExpr:
4250  _outNamedArgExpr(str, obj);
4251  break;
4252  case T_OpExpr:
4253  _outOpExpr(str, obj);
4254  break;
4255  case T_DistinctExpr:
4256  _outDistinctExpr(str, obj);
4257  break;
4258  case T_NullIfExpr:
4259  _outNullIfExpr(str, obj);
4260  break;
4261  case T_ScalarArrayOpExpr:
4262  _outScalarArrayOpExpr(str, obj);
4263  break;
4264  case T_BoolExpr:
4265  _outBoolExpr(str, obj);
4266  break;
4267  case T_SubLink:
4268  _outSubLink(str, obj);
4269  break;
4270  case T_SubPlan:
4271  _outSubPlan(str, obj);
4272  break;
4273  case T_AlternativeSubPlan:
4275  break;
4276  case T_FieldSelect:
4277  _outFieldSelect(str, obj);
4278  break;
4279  case T_FieldStore:
4280  _outFieldStore(str, obj);
4281  break;
4282  case T_RelabelType:
4283  _outRelabelType(str, obj);
4284  break;
4285  case T_CoerceViaIO:
4286  _outCoerceViaIO(str, obj);
4287  break;
4288  case T_ArrayCoerceExpr:
4289  _outArrayCoerceExpr(str, obj);
4290  break;
4291  case T_ConvertRowtypeExpr:
4293  break;
4294  case T_CollateExpr:
4295  _outCollateExpr(str, obj);
4296  break;
4297  case T_CaseExpr:
4298  _outCaseExpr(str, obj);
4299  break;
4300  case T_CaseWhen:
4301  _outCaseWhen(str, obj);
4302  break;
4303  case T_CaseTestExpr:
4304  _outCaseTestExpr(str, obj);
4305  break;
4306  case T_ArrayExpr:
4307  _outArrayExpr(str, obj);
4308  break;
4309  case T_RowExpr:
4310  _outRowExpr(str, obj);
4311  break;
4312  case T_RowCompareExpr:
4313  _outRowCompareExpr(str, obj);
4314  break;
4315  case T_CoalesceExpr:
4316  _outCoalesceExpr(str, obj);
4317  break;
4318  case T_MinMaxExpr:
4319  _outMinMaxExpr(str, obj);
4320  break;
4321  case T_SQLValueFunction:
4322  _outSQLValueFunction(str, obj);
4323  break;
4324  case T_XmlExpr:
4325  _outXmlExpr(str, obj);
4326  break;
4327  case T_NullTest:
4328  _outNullTest(str, obj);
4329  break;
4330  case T_BooleanTest:
4331  _outBooleanTest(str, obj);
4332  break;
4333  case T_CoerceToDomain:
4334  _outCoerceToDomain(str, obj);
4335  break;
4336  case T_CoerceToDomainValue:
4338  break;
4339  case T_SetToDefault:
4340  _outSetToDefault(str, obj);
4341  break;
4342  case T_CurrentOfExpr:
4343  _outCurrentOfExpr(str, obj);
4344  break;
4345  case T_NextValueExpr:
4346  _outNextValueExpr(str, obj);
4347  break;
4348  case T_InferenceElem:
4349  _outInferenceElem(str, obj);
4350  break;
4351  case T_TargetEntry:
4352  _outTargetEntry(str, obj);
4353  break;
4354  case T_RangeTblRef:
4355  _outRangeTblRef(str, obj);
4356  break;
4357  case T_JoinExpr:
4358  _outJoinExpr(str, obj);
4359  break;
4360  case T_FromExpr:
4361  _outFromExpr(str, obj);
4362  break;
4363  case T_OnConflictExpr:
4364  _outOnConflictExpr(str, obj);
4365  break;
4366  case T_Path:
4367  _outPath(str, obj);
4368  break;
4369  case T_IndexPath:
4370  _outIndexPath(str, obj);
4371  break;
4372  case T_BitmapHeapPath:
4373  _outBitmapHeapPath(str, obj);
4374  break;
4375  case T_BitmapAndPath:
4376  _outBitmapAndPath(str, obj);
4377  break;
4378  case T_BitmapOrPath:
4379  _outBitmapOrPath(str, obj);
4380  break;
4381  case T_TidPath:
4382  _outTidPath(str, obj);
4383  break;
4384  case T_TidRangePath:
4385  _outTidRangePath(str, obj);
4386  break;
4387  case T_SubqueryScanPath:
4388  _outSubqueryScanPath(str, obj);
4389  break;
4390  case T_ForeignPath:
4391  _outForeignPath(str, obj);
4392  break;
4393  case T_CustomPath:
4394  _outCustomPath(str, obj);
4395  break;
4396  case T_AppendPath:
4397  _outAppendPath(str, obj);
4398  break;
4399  case T_MergeAppendPath:
4400  _outMergeAppendPath(str, obj);
4401  break;
4402  case T_GroupResultPath:
4403  _outGroupResultPath(str, obj);
4404  break;
4405  case T_MaterialPath:
4406  _outMaterialPath(str, obj);
4407  break;
4408  case T_MemoizePath:
4409  _outMemoizePath(str, obj);
4410  break;
4411  case T_UniquePath:
4412  _outUniquePath(str, obj);
4413  break;
4414  case T_GatherPath:
4415  _outGatherPath(str, obj);
4416  break;
4417  case T_ProjectionPath:
4418  _outProjectionPath(str, obj);
4419  break;
4420  case T_ProjectSetPath:
4421  _outProjectSetPath(str, obj);
4422  break;
4423  case T_SortPath:
4424  _outSortPath(str, obj);
4425  break;
4426  case T_IncrementalSortPath:
4428  break;
4429  case T_GroupPath:
4430  _outGroupPath(str, obj);
4431  break;
4432  case T_UpperUniquePath:
4433  _outUpperUniquePath(str, obj);
4434  break;
4435  case T_AggPath:
4436  _outAggPath(str, obj);
4437  break;
4438  case T_GroupingSetsPath:
4439  _outGroupingSetsPath(str, obj);
4440  break;
4441  case T_MinMaxAggPath:
4442  _outMinMaxAggPath(str, obj);
4443  break;
4444  case T_WindowAggPath:
4445  _outWindowAggPath(str, obj);
4446  break;
4447  case T_SetOpPath:
4448  _outSetOpPath(str, obj);
4449  break;
4450  case T_RecursiveUnionPath:
4452  break;
4453  case T_LockRowsPath:
4454  _outLockRowsPath(str, obj);
4455  break;
4456  case T_ModifyTablePath:
4457  _outModifyTablePath(str, obj);
4458  break;
4459  case T_LimitPath:
4460  _outLimitPath(str, obj);
4461  break;
4462  case T_GatherMergePath:
4463  _outGatherMergePath(str, obj);
4464  break;
4465  case T_NestPath:
4466  _outNestPath(str, obj);
4467  break;
4468  case T_MergePath:
4469  _outMergePath(str, obj);
4470  break;
4471  case T_HashPath:
4472  _outHashPath(str, obj);
4473  break;
4474  case T_PlannerGlobal:
4475  _outPlannerGlobal(str, obj);
4476  break;
4477  case T_PlannerInfo:
4478  _outPlannerInfo(str, obj);
4479  break;
4480  case T_RelOptInfo:
4481  _outRelOptInfo(str, obj);
4482  break;
4483  case T_IndexOptInfo:
4484  _outIndexOptInfo(str, obj);
4485  break;
4486  case T_ForeignKeyOptInfo:
4487  _outForeignKeyOptInfo(str, obj);
4488  break;
4489  case T_EquivalenceClass:
4490  _outEquivalenceClass(str, obj);
4491  break;
4492  case T_EquivalenceMember:
4493  _outEquivalenceMember(str, obj);
4494  break;
4495  case T_PathKey:
4496  _outPathKey(str, obj);
4497  break;
4498  case T_PathTarget:
4499  _outPathTarget(str, obj);
4500  break;
4501  case T_ParamPathInfo:
4502  _outParamPathInfo(str, obj);
4503  break;
4504  case T_RestrictInfo:
4505  _outRestrictInfo(str, obj);
4506  break;
4507  case T_IndexClause:
4508  _outIndexClause(str, obj);
4509  break;
4510  case T_PlaceHolderVar:
4511  _outPlaceHolderVar(str, obj);
4512  break;
4513  case T_SpecialJoinInfo:
4514  _outSpecialJoinInfo(str, obj);
4515  break;
4516  case T_AppendRelInfo:
4517  _outAppendRelInfo(str, obj);
4518  break;
4519  case T_RowIdentityVarInfo:
4521  break;
4522  case T_PlaceHolderInfo:
4523  _outPlaceHolderInfo(str, obj);
4524  break;
4525  case T_MinMaxAggInfo:
4526  _outMinMaxAggInfo(str, obj);
4527  break;
4528  case T_PlannerParamItem:
4529  _outPlannerParamItem(str, obj);
4530  break;
4531  case T_RollupData:
4532  _outRollupData(str, obj);
4533  break;
4534  case T_GroupingSetData:
4535  _outGroupingSetData(str, obj);
4536  break;
4537  case T_StatisticExtInfo:
4538  _outStatisticExtInfo(str, obj);
4539  break;
4540  case T_ExtensibleNode:
4541  _outExtensibleNode(str, obj);
4542  break;
4543  case T_CreateStmt:
4544  _outCreateStmt(str, obj);
4545  break;
4548  break;
4551  break;
4552  case T_IndexStmt:
4553  _outIndexStmt(str, obj);
4554  break;
4555  case T_CreateStatsStmt:
4556  _outCreateStatsStmt(str, obj);
4557  break;
4558  case T_AlterStatsStmt:
4559  _outAlterStatsStmt(str, obj);
4560  break;
4561  case T_NotifyStmt:
4562  _outNotifyStmt(str, obj);
4563  break;
4564  case T_DeclareCursorStmt:
4565  _outDeclareCursorStmt(str, obj);
4566  break;
4567  case T_SelectStmt:
4568  _outSelectStmt(str, obj);
4569  break;
4570  case T_ReturnStmt:
4571  _outReturnStmt(str, obj);
4572  break;
4573  case T_PLAssignStmt:
4574  _outPLAssignStmt(str, obj);
4575  break;
4576  case T_ColumnDef:
4577  _outColumnDef(str, obj);
4578  break;
4579  case T_TypeName:
4580  _outTypeName(str, obj);
4581  break;
4582  case T_TypeCast:
4583  _outTypeCast(str, obj);
4584  break;
4585  case T_CollateClause:
4586  _outCollateClause(str, obj);
4587  break;
4588  case T_IndexElem:
4589  _outIndexElem(str, obj);
4590  break;
4591  case T_StatsElem:
4592  _outStatsElem(str, obj);
4593  break;
4594  case T_Query:
4595  _outQuery(str, obj);
4596  break;
4597  case T_WithCheckOption:
4598  _outWithCheckOption(str, obj);
4599  break;
4600  case T_SortGroupClause:
4601  _outSortGroupClause(str, obj);
4602  break;
4603  case T_GroupingSet:
4604  _outGroupingSet(str, obj);
4605  break;
4606  case T_WindowClause:
4607  _outWindowClause(str, obj);
4608  break;
4609  case T_RowMarkClause:
4610  _outRowMarkClause(str, obj);
4611  break;
4612  case T_WithClause:
4613  _outWithClause(str, obj);
4614  break;
4615  case T_CTESearchClause:
4616  _outCTESearchClause(str, obj);
4617  break;
4618  case T_CTECycleClause:
4619  _outCTECycleClause(str, obj);
4620  break;
4621  case T_CommonTableExpr:
4622  _outCommonTableExpr(str, obj);
4623  break;
4624  case T_MergeWhenClause:
4625  _outMergeWhenClause(str, obj);
4626  break;
4627  case T_MergeAction:
4628  _outMergeAction(str, obj);
4629  break;
4630  case T_SetOperationStmt:
4631  _outSetOperationStmt(str, obj);
4632  break;
4633  case T_RangeTblEntry:
4634  _outRangeTblEntry(str, obj);
4635  break;
4636  case T_RangeTblFunction:
4637  _outRangeTblFunction(str, obj);
4638  break;
4639  case T_TableSampleClause:
4640  _outTableSampleClause(str, obj);
4641  break;
4642  case T_A_Expr:
4643  _outA_Expr(str, obj);
4644  break;
4645  case T_ColumnRef:
4646  _outColumnRef(str, obj);
4647  break;
4648  case T_ParamRef:
4649  _outParamRef(str, obj);
4650  break;
4651  case T_RawStmt:
4652  _outRawStmt(str, obj);
4653  break;
4654  case T_A_Const:
4655  _outA_Const(str, obj);
4656  break;
4657  case T_A_Star:
4658  _outA_Star(str, obj);
4659  break;
4660  case T_A_Indices:
4661  _outA_Indices(str, obj);
4662  break;
4663  case T_A_Indirection:
4664  _outA_Indirection(str, obj);
4665  break;
4666  case T_A_ArrayExpr:
4667  _outA_ArrayExpr(str, obj);
4668  break;
4669  case T_ResTarget:
4670  _outResTarget(str, obj);
4671  break;
4672  case T_MultiAssignRef:
4673  _outMultiAssignRef(str, obj);
4674  break;
4675  case T_SortBy:
4676  _outSortBy(str, obj);
4677  break;
4678  case T_WindowDef:
4679  _outWindowDef(str, obj);
4680  break;
4681  case T_RangeSubselect:
4682  _outRangeSubselect(str, obj);
4683  break;
4684  case T_RangeFunction:
4685  _outRangeFunction(str, obj);
4686  break;
4687  case T_RangeTableSample:
4688  _outRangeTableSample(str, obj);
4689  break;
4690  case T_RangeTableFunc:
4691  _outRangeTableFunc(str, obj);
4692  break;
4693  case T_RangeTableFuncCol:
4694  _outRangeTableFuncCol(str, obj);
4695  break;
4696  case T_Constraint:
4697  _outConstraint(str, obj);
4698  break;
4699  case T_FuncCall:
4700  _outFuncCall(str, obj);
4701  break;
4702  case T_DefElem:
4703  _outDefElem(str, obj);
4704  break;
4705  case T_TableLikeClause:
4706  _outTableLikeClause(str, obj);
4707  break;
4708  case T_LockingClause:
4709  _outLockingClause(str, obj);
4710  break;
4711  case T_XmlSerialize:
4712  _outXmlSerialize(str, obj);
4713  break;
4714  case T_ForeignKeyCacheInfo:
4716  break;
4717  case T_TriggerTransition:
4718  _outTriggerTransition(str, obj);
4719  break;
4720  case T_PartitionElem:
4721  _outPartitionElem(str, obj);
4722  break;
4723  case T_PartitionSpec:
4724  _outPartitionSpec(str, obj);
4725  break;
4726  case T_PartitionBoundSpec:
4728  break;
4729  case T_PartitionRangeDatum:
4731  break;
4732  case T_JsonFormat:
4733  _outJsonFormat(str, obj);
4734  break;
4735  case T_JsonReturning:
4736  _outJsonReturning(str, obj);
4737  break;
4738  case T_JsonValueExpr:
4739  _outJsonValueExpr(str, obj);
4740  break;
4741  case T_JsonConstructorExpr:
4743  break;
4744  case T_JsonIsPredicate:
4745  _outJsonIsPredicate(str, obj);
4746  break;
4747  case T_JsonBehavior:
4748  _outJsonBehavior(str, obj);
4749  break;
4750  case T_JsonExpr:
4751  _outJsonExpr(str, obj);
4752  break;
4753  case T_JsonCoercion:
4754  _outJsonCoercion(str, obj);
4755  break;
4756  case T_JsonItemCoercions:
4757  _outJsonItemCoercions(str, obj);
4758  break;
4759  case T_JsonTableParent:
4760  _outJsonTableParent(str, obj);
4761  break;
4762  case T_JsonTableSibling:
4763  _outJsonTableSibling(str, obj);
4764  break;
4765 
4766  default:
4767 
4768  /*
4769  * This should be an ERROR, but it's too useful to be able to
4770  * dump structures that outNode only understands part of.
4771  */
4772  elog(WARNING, "could not dump unrecognized node type: %d",
4773  (int) nodeTag(obj));
4774  break;
4775  }
4776  appendStringInfoChar(str, '}');
4777  }
4778 }
4779 
4780 /*
4781  * nodeToString -
4782  * returns the ascii representation of the Node as a palloc'd string
4783  */
4784 char *
4785 nodeToString(const void *obj)
4786 {
4788 
4789  /* see stringinfo.h for an explanation of this maneuver */
4790  initStringInfo(&str);
4791  outNode(&str, obj);
4792  return str.data;
4793 }
4794 
4795 /*
4796  * bmsToString -
4797  * returns the ascii representation of the Bitmapset as a palloc'd string
4798  */
4799 char *
4801 {
4803 
4804  /* see stringinfo.h for an explanation of this maneuver */
4805  initStringInfo(&str);
4806  outBitmapset(&str, bms);
4807  return str.data;
4808 }
int bms_next_member(const Bitmapset *a, int prevbit)
Definition: bitmapset.c:1045
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define PointerIsValid(pointer)
Definition: c.h:698
size_t Size
Definition: c.h:540
Size datumGetSize(Datum value, bool typByVal, int typLen)
Definition: datum.c:65
#define WARNING
Definition: elog.h:30
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
const char * name
Definition: encode.c:561
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
Definition: extensible.c:125
Datum format_type(PG_FUNCTION_ARGS)
Definition: format_type.c:60
static struct @151 value
long val
Definition: informix.c:664
int x
Definition: isn.c:71
int i
Definition: isn.c:73
LockWaitPolicy
Definition: lockoptions.h:37
LockClauseStrength
Definition: lockoptions.h:22
Datum subpath(PG_FUNCTION_ARGS)
Definition: ltree_op.c:241
SetOpCmd
Definition: nodes.h:850
SetOpStrategy
Definition: nodes.h:858
#define IsA(nodeptr, _type_)
Definition: nodes.h:624
#define nodeTag(nodeptr)
Definition: nodes.h:578
OnConflictAction
Definition: nodes.h:870
CmdType
Definition: nodes.h:719
AggStrategy
Definition: nodes.h:806
NodeTag
Definition: nodes.h:27
@ T_LockingClause
Definition: nodes.h:491
@ T_Unique
Definition: nodes.h:84
@ T_RangeTblEntry
Definition: nodes.h:479
@ T_FieldStore
Definition: nodes.h:175
@ T_AlternativeSubPlan
Definition: nodes.h:173
@ T_CoalesceExpr
Definition: nodes.h:187
@ T_PathKey
Definition: nodes.h:281
@ T_PartitionPruneInfo
Definition: nodes.h:94
@ T_ModifyTablePath
Definition: nodes.h:276
@ T_ExtensibleNode
Definition: nodes.h:324
@ T_SortPath
Definition: nodes.h:265
@ T_NamedTuplestoreScan
Definition: nodes.h:69
@ T_RangeVar
Definition: nodes.h:155
@ T_RangeTableFunc
Definition: nodes.h:471
@ T_Constraint
Definition: nodes.h:477
@ T_CreateStmt
Definition: nodes.h:349
@ T_RangeFunction
Definition: nodes.h:469
@ T_SubqueryScanPath
Definition: nodes.h:249
@ T_GroupResultPath
Definition: nodes.h:257
@ T_XmlSerialize
Definition: nodes.h:493
@ T_DefElem
Definition: nodes.h:478
@ T_WithCheckOption
Definition: nodes.h:482
@ T_ColumnDef
Definition: nodes.h:474
@ T_PlannerParamItem
Definition: nodes.h:292
@ T_HashPath
Definition: nodes.h:254
@ T_CTESearchClause
Definition: nodes.h:497
@ T_IndexOptInfo
Definition: nodes.h:239
@ T_OnConflictExpr
Definition: nodes.h:203
@ T_SubLink
Definition: nodes.h:171
@ T_RangeTblRef
Definition: nodes.h:200
@ T_InferenceElem
Definition: nodes.h:198
@ T_SortGroupClause
Definition: nodes.h:483
@ T_GroupPath
Definition: nodes.h:267
@ T_CoerceToDomainValue
Definition: nodes.h:194
@ T_WindowFunc
Definition: nodes.h:162
@ T_ImportForeignSchemaStmt
Definition: nodes.h:427
@ T_FieldSelect
Definition: nodes.h:174
@ T_ArrayExpr
Definition: nodes.h:184
@ T_TableFunc
Definition: nodes.h:156
@ T_TidRangeScan
Definition: nodes.h:63
@ T_TableFuncScan
Definition: nodes.h:67
@ T_CollateExpr
Definition: nodes.h:180
@ T_JsonBehavior
Definition: nodes.h:525
@ T_ReturnStmt
Definition: nodes.h:337
@ T_PartitionElem
Definition: nodes.h:503
@ T_BoolExpr
Definition: nodes.h:170
@ T_MinMaxAggPath
Definition: nodes.h:271
@ T_RelOptInfo
Definition: nodes.h:238
@ T_OpExpr
Definition: nodes.h:166
@ T_CreateStatsStmt
Definition: nodes.h:445
@ T_FunctionScan
Definition: nodes.h:65
@ T_TypeName
Definition: nodes.h:473
@ T_SpecialJoinInfo
Definition: nodes.h:287
@ T_PathTarget
Definition: nodes.h:283
@ T_JoinExpr
Definition: nodes.h:201
@ T_ScalarArrayOpExpr
Definition: nodes.h:169
@ T_NestPath
Definition: nodes.h:252
@ T_CaseExpr
Definition: nodes.h:181
@ T_RelabelType
Definition: nodes.h:176
@ T_PlaceHolderInfo
Definition: nodes.h:290
@ T_JsonTableParent
Definition: nodes.h:215
@ T_XmlExpr
Definition: nodes.h:190
@ T_CreateForeignTableStmt
Definition: nodes.h:426
@ T_ForeignKeyOptInfo
Definition: nodes.h:240
@ T_GroupingSet
Definition: nodes.h:484
@ T_BitmapOr
Definition: nodes.h:54
@ T_CustomPath
Definition: nodes.h:251
@ T_Scan
Definition: nodes.h:55
@ T_Material
Definition: nodes.h:77
@ T_RawStmt
Definition: nodes.h:329
@ T_IndexOnlyScan
Definition: nodes.h:59
@ T_JsonReturning
Definition: nodes.h:206
@ T_TableSampleClause
Definition: nodes.h:481
@ T_Append
Definition: nodes.h:50
@ T_SetOperationStmt
Definition: nodes.h:342
@ T_RestrictInfo
Definition: nodes.h:284
@ T_Gather
Definition: nodes.h:85
@ T_BitmapIndexScan
Definition: nodes.h:60
@ T_Alias
Definition: nodes.h:154
@ T_ResTarget
Definition: nodes.h:462
@ T_MinMaxAggInfo
Definition: nodes.h:291
@ T_PartitionedRelPruneInfo
Definition: nodes.h:95
@ T_ConvertRowtypeExpr
Definition: nodes.h:179
@ T_RowIdentityVarInfo
Definition: nodes.h:289
@ T_IncrementalSortPath
Definition: nodes.h:266
@ T_RecursiveUnion
Definition: nodes.h:52
@ T_CommonTableExpr
Definition: nodes.h:499
@ T_TidPath
Definition: nodes.h:247
@ T_PlanInvalItem
Definition: nodes.h:98
@ T_JsonConstructorExpr
Definition: nodes.h:211
@ T_WindowClause
Definition: nodes.h:485
@ T_LockRows
Definition: nodes.h:89
@ T_MultiAssignRef
Definition: nodes.h:463
@ T_StatsElem
Definition: nodes.h:476
@ T_Hash
Definition: nodes.h:87
@ T_NotifyStmt
Definition: nodes.h:361
@ T_TidScan
Definition: nodes.h:62
@ T_AggPath
Definition: nodes.h:269
@ T_Limit
Definition: nodes.h:90
@ T_Plan
Definition: nodes.h:46
@ T_PlanRowMark
Definition: nodes.h:93
@ T_A_Indices
Definition: nodes.h:459
@ T_StatisticExtInfo
Definition: nodes.h:295
@ T_MemoizePath
Definition: nodes.h:259
@ T_JsonTableSibling
Definition: nodes.h:216
@ T_GatherMergePath
Definition: nodes.h:262
@ T_Query
Definition: nodes.h:330
@ T_A_ArrayExpr
Definition: nodes.h:461
@ T_SetOpPath
Definition: nodes.h:273
@ T_FromExpr
Definition: nodes.h:202
@ T_Memoize
Definition: nodes.h:78
@ T_TidRangePath
Definition: nodes.h:248
@ T_TriggerTransition
Definition: nodes.h:502
@ T_ParamPathInfo
Definition: nodes.h:241
@ T_Sort
Definition: nodes.h:79
@ T_BitmapAndPath
Definition: nodes.h:245
@ T_RowExpr
Definition: nodes.h:185
@ T_TargetEntry
Definition: nodes.h:199
@ T_AlterStatsStmt
Definition: nodes.h:448
@ T_ProjectionPath
Definition: nodes.h:263
@ T_PlannerInfo
Definition: nodes.h:236
@ T_FuncCall
Definition: nodes.h:457
@ T_SeqScan
Definition: nodes.h:56
@ T_ArrayCoerceExpr
Definition: nodes.h:178
@ T_A_Const
Definition: nodes.h:456
@ T_WindowAgg
Definition: nodes.h:83
@ T_CTECycleClause
Definition: nodes.h:498
@ T_MinMaxExpr
Definition: nodes.h:188
@ T_MaterialPath
Definition: nodes.h:258
@ T_A_Expr
Definition: nodes.h:453
@ T_A_Indirection
Definition: nodes.h:460
@ T_RecursiveUnionPath
Definition: nodes.h:274
@ T_ForeignPath
Definition: nodes.h:250
@ T_ForeignKeyCacheInfo
Definition: nodes.h:557
@ T_CurrentOfExpr
Definition: nodes.h:196
@ T_IndexStmt
Definition: nodes.h:355
@ T_ProjectSet
Definition: nodes.h:48
@ T_MergeJoin
Definition: nodes.h:75
@ T_SampleScan
Definition: nodes.h:57
@ T_SortBy
Definition: nodes.h:466
@ T_MergeAppendPath
Definition: nodes.h:256
@ T_ValuesScan
Definition: nodes.h:66
@ T_Aggref
Definition: nodes.h:160
@ T_GroupingSetsPath
Definition: nodes.h:270
@ T_BooleanTest
Definition: nodes.h:192