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