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