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