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