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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
523 | _outScan(StringInfo str, const Scan *node) |
524 | { |
525 | WRITE_NODE_TYPE("SCAN" ); |
526 | |
527 | _outScanInfo(str, node); |
528 | } |
529 | |
530 | static void |
531 | _outSeqScan(StringInfo str, const SeqScan *node) |
532 | { |
533 | WRITE_NODE_TYPE("SEQSCAN" ); |
534 | |
535 | _outScanInfo(str, (const Scan *) node); |
536 | } |
537 | |
538 | static void |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
1329 | _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node) |
1330 | { |
1331 | WRITE_NODE_TYPE("ALTERNATIVESUBPLAN" ); |
1332 | |
1333 | WRITE_NODE_FIELD(subplans); |
1334 | } |
1335 | |
1336 | static void |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
1641 | _outRangeTblRef(StringInfo str, const RangeTblRef *node) |
1642 | { |
1643 | WRITE_NODE_TYPE("RANGETBLREF" ); |
1644 | |
1645 | WRITE_INT_FIELD(rtindex); |
1646 | } |
1647 | |
1648 | static void |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 | } |
2750 | |
2751 | static void |
2752 | _outLockingClause(StringInfo str, const LockingClause *node) |
2753 | { |
2754 | WRITE_NODE_TYPE("LOCKINGCLAUSE" ); |
2755 | |
2756 | WRITE_NODE_FIELD(lockedRels); |
2757 | WRITE_ENUM_FIELD(strength, LockClauseStrength); |
2758 | WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy); |
2759 | } |
2760 | |
2761 | static void |
2762 | _outXmlSerialize(StringInfo str, const XmlSerialize *node) |
2763 | { |
2764 | WRITE_NODE_TYPE("XMLSERIALIZE" ); |
2765 | |
2766 | WRITE_ENUM_FIELD(xmloption, XmlOptionType); |
2767 | WRITE_NODE_FIELD(expr); |
2768 | WRITE_NODE_FIELD(typeName); |
2769 | WRITE_LOCATION_FIELD(location); |
2770 | } |
2771 | |
2772 | static void |
2773 | _outTriggerTransition(StringInfo str, const TriggerTransition *node) |
2774 | { |
2775 | WRITE_NODE_TYPE("TRIGGERTRANSITION" ); |
2776 | |
2777 | WRITE_STRING_FIELD(name); |
2778 | WRITE_BOOL_FIELD(isNew); |
2779 | WRITE_BOOL_FIELD(isTable); |
2780 | } |
2781 | |
2782 | static void |
2783 | _outColumnDef(StringInfo str, const ColumnDef *node) |
2784 | { |
2785 | WRITE_NODE_TYPE("COLUMNDEF" ); |
2786 | |
2787 | WRITE_STRING_FIELD(colname); |
2788 | WRITE_NODE_FIELD(typeName); |
2789 | WRITE_INT_FIELD(inhcount); |
2790 | WRITE_BOOL_FIELD(is_local); |
2791 | WRITE_BOOL_FIELD(is_not_null); |
2792 | WRITE_BOOL_FIELD(is_from_type); |
2793 | WRITE_CHAR_FIELD(storage); |
2794 | WRITE_NODE_FIELD(raw_default); |
2795 | WRITE_NODE_FIELD(cooked_default); |
2796 | WRITE_CHAR_FIELD(identity); |
2797 | WRITE_NODE_FIELD(identitySequence); |
2798 | WRITE_CHAR_FIELD(generated); |
2799 | WRITE_NODE_FIELD(collClause); |
2800 | WRITE_OID_FIELD(collOid); |
2801 | WRITE_NODE_FIELD(constraints); |
2802 | WRITE_NODE_FIELD(fdwoptions); |
2803 | WRITE_LOCATION_FIELD(location); |
2804 | } |
2805 | |
2806 | static void |
2807 | _outTypeName(StringInfo str, const TypeName *node) |
2808 | { |
2809 | WRITE_NODE_TYPE("TYPENAME" ); |
2810 | |
2811 | WRITE_NODE_FIELD(names); |
2812 | WRITE_OID_FIELD(typeOid); |
2813 | WRITE_BOOL_FIELD(setof); |
2814 | WRITE_BOOL_FIELD(pct_type); |
2815 | WRITE_NODE_FIELD(typmods); |
2816 | WRITE_INT_FIELD(typemod); |
2817 | WRITE_NODE_FIELD(arrayBounds); |
2818 | WRITE_LOCATION_FIELD(location); |
2819 | } |
2820 | |
2821 | static void |
2822 | _outTypeCast(StringInfo str, const TypeCast *node) |
2823 | { |
2824 | WRITE_NODE_TYPE("TYPECAST" ); |
2825 | |
2826 | WRITE_NODE_FIELD(arg); |
2827 | WRITE_NODE_FIELD(typeName); |
2828 | WRITE_LOCATION_FIELD(location); |
2829 | } |
2830 | |
2831 | static void |
2832 | _outCollateClause(StringInfo str, const CollateClause *node) |
2833 | { |
2834 | WRITE_NODE_TYPE("COLLATECLAUSE" ); |
2835 | |
2836 | WRITE_NODE_FIELD(arg); |
2837 | WRITE_NODE_FIELD(collname); |
2838 | WRITE_LOCATION_FIELD(location); |
2839 | } |
2840 | |
2841 | static void |
2842 | _outIndexElem(StringInfo str, const IndexElem *node) |
2843 | { |
2844 | WRITE_NODE_TYPE("INDEXELEM" ); |
2845 | |
2846 | WRITE_STRING_FIELD(name); |
2847 | WRITE_NODE_FIELD(expr); |
2848 | WRITE_STRING_FIELD(indexcolname); |
2849 | WRITE_NODE_FIELD(collation); |
2850 | WRITE_NODE_FIELD(opclass); |
2851 | WRITE_ENUM_FIELD(ordering, SortByDir); |
2852 | WRITE_ENUM_FIELD(nulls_ordering, SortByNulls); |
2853 | } |
2854 | |
2855 | static void |
2856 | _outQuery(StringInfo str, const Query *node) |
2857 | { |
2858 | WRITE_NODE_TYPE("QUERY" ); |
2859 | |
2860 | WRITE_ENUM_FIELD(commandType, CmdType); |
2861 | WRITE_ENUM_FIELD(querySource, QuerySource); |
2862 | /* we intentionally do not print the queryId field */ |
2863 | WRITE_BOOL_FIELD(canSetTag); |
2864 | |
2865 | /* |
2866 | * Hack to work around missing outfuncs routines for a lot of the |
2867 | * utility-statement node types. (The only one we actually *need* for |
2868 | * rules support is NotifyStmt.) Someday we ought to support 'em all, but |
2869 | * for the meantime do this to avoid getting lots of warnings when running |
2870 | * with debug_print_parse on. |
2871 | */ |
2872 | if (node->utilityStmt) |
2873 | { |
2874 | switch (nodeTag(node->utilityStmt)) |
2875 | { |
2876 | case T_CreateStmt: |
2877 | case T_IndexStmt: |
2878 | case T_NotifyStmt: |
2879 | case T_DeclareCursorStmt: |
2880 | WRITE_NODE_FIELD(utilityStmt); |
2881 | break; |
2882 | default: |
2883 | appendStringInfoString(str, " :utilityStmt ?" ); |
2884 | break; |
2885 | } |
2886 | } |
2887 | else |
2888 | appendStringInfoString(str, " :utilityStmt <>" ); |
2889 | |
2890 | WRITE_INT_FIELD(resultRelation); |
2891 | WRITE_BOOL_FIELD(hasAggs); |
2892 | WRITE_BOOL_FIELD(hasWindowFuncs); |
2893 | WRITE_BOOL_FIELD(hasTargetSRFs); |
2894 | WRITE_BOOL_FIELD(hasSubLinks); |
2895 | WRITE_BOOL_FIELD(hasDistinctOn); |
2896 | WRITE_BOOL_FIELD(hasRecursive); |
2897 | WRITE_BOOL_FIELD(hasModifyingCTE); |
2898 | WRITE_BOOL_FIELD(hasForUpdate); |
2899 | WRITE_BOOL_FIELD(hasRowSecurity); |
2900 | WRITE_NODE_FIELD(cteList); |
2901 | WRITE_NODE_FIELD(rtable); |
2902 | WRITE_NODE_FIELD(jointree); |
2903 | WRITE_NODE_FIELD(targetList); |
2904 | WRITE_ENUM_FIELD(override, OverridingKind); |
2905 | WRITE_NODE_FIELD(onConflict); |
2906 | WRITE_NODE_FIELD(returningList); |
2907 | WRITE_NODE_FIELD(groupClause); |
2908 | WRITE_NODE_FIELD(groupingSets); |
2909 | WRITE_NODE_FIELD(havingQual); |
2910 | WRITE_NODE_FIELD(windowClause); |
2911 | WRITE_NODE_FIELD(distinctClause); |
2912 | WRITE_NODE_FIELD(sortClause); |
2913 | WRITE_NODE_FIELD(limitOffset); |
2914 | WRITE_NODE_FIELD(limitCount); |
2915 | WRITE_NODE_FIELD(rowMarks); |
2916 | WRITE_NODE_FIELD(setOperations); |
2917 | WRITE_NODE_FIELD(constraintDeps); |
2918 | WRITE_NODE_FIELD(withCheckOptions); |
2919 | WRITE_LOCATION_FIELD(stmt_location); |
2920 | WRITE_LOCATION_FIELD(stmt_len); |
2921 | } |
2922 | |
2923 | static void |
2924 | _outWithCheckOption(StringInfo str, const WithCheckOption *node) |
2925 | { |
2926 | WRITE_NODE_TYPE("WITHCHECKOPTION" ); |
2927 | |
2928 | WRITE_ENUM_FIELD(kind, WCOKind); |
2929 | WRITE_STRING_FIELD(relname); |
2930 | WRITE_STRING_FIELD(polname); |
2931 | WRITE_NODE_FIELD(qual); |
2932 | WRITE_BOOL_FIELD(cascaded); |
2933 | } |
2934 | |
2935 | static void |
2936 | _outSortGroupClause(StringInfo str, const SortGroupClause *node) |
2937 | { |
2938 | WRITE_NODE_TYPE("SORTGROUPCLAUSE" ); |
2939 | |
2940 | WRITE_UINT_FIELD(tleSortGroupRef); |
2941 | WRITE_OID_FIELD(eqop); |
2942 | WRITE_OID_FIELD(sortop); |
2943 | WRITE_BOOL_FIELD(nulls_first); |
2944 | WRITE_BOOL_FIELD(hashable); |
2945 | } |
2946 | |
2947 | static void |
2948 | _outGroupingSet(StringInfo str, const GroupingSet *node) |
2949 | { |
2950 | WRITE_NODE_TYPE("GROUPINGSET" ); |
2951 | |
2952 | WRITE_ENUM_FIELD(kind, GroupingSetKind); |
2953 | WRITE_NODE_FIELD(content); |
2954 | WRITE_LOCATION_FIELD(location); |
2955 | } |
2956 | |
2957 | static void |
2958 | _outWindowClause(StringInfo str, const WindowClause *node) |
2959 | { |
2960 | WRITE_NODE_TYPE("WINDOWCLAUSE" ); |
2961 | |
2962 | WRITE_STRING_FIELD(name); |
2963 | WRITE_STRING_FIELD(refname); |
2964 | WRITE_NODE_FIELD(partitionClause); |
2965 | WRITE_NODE_FIELD(orderClause); |
2966 | WRITE_INT_FIELD(frameOptions); |
2967 | WRITE_NODE_FIELD(startOffset); |
2968 | WRITE_NODE_FIELD(endOffset); |
2969 | WRITE_OID_FIELD(startInRangeFunc); |
2970 | WRITE_OID_FIELD(endInRangeFunc); |
2971 | WRITE_OID_FIELD(inRangeColl); |
2972 | WRITE_BOOL_FIELD(inRangeAsc); |
2973 | WRITE_BOOL_FIELD(inRangeNullsFirst); |
2974 | WRITE_UINT_FIELD(winref); |
2975 | WRITE_BOOL_FIELD(copiedOrder); |
2976 | } |
2977 | |
2978 | static void |
2979 | _outRowMarkClause(StringInfo str, const RowMarkClause *node) |
2980 | { |
2981 | WRITE_NODE_TYPE("ROWMARKCLAUSE" ); |
2982 | |
2983 | WRITE_UINT_FIELD(rti); |
2984 | WRITE_ENUM_FIELD(strength, LockClauseStrength); |
2985 | WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy); |
2986 | WRITE_BOOL_FIELD(pushedDown); |
2987 | } |
2988 | |
2989 | static void |
2990 | _outWithClause(StringInfo str, const WithClause *node) |
2991 | { |
2992 | WRITE_NODE_TYPE("WITHCLAUSE" ); |
2993 | |
2994 | WRITE_NODE_FIELD(ctes); |
2995 | WRITE_BOOL_FIELD(recursive); |
2996 | WRITE_LOCATION_FIELD(location); |
2997 | } |
2998 | |
2999 | static void |
3000 | _outCommonTableExpr(StringInfo str, const CommonTableExpr *node) |
3001 | { |
3002 | WRITE_NODE_TYPE("COMMONTABLEEXPR" ); |
3003 | |
3004 | WRITE_STRING_FIELD(ctename); |
3005 | WRITE_NODE_FIELD(aliascolnames); |
3006 | WRITE_ENUM_FIELD(ctematerialized, CTEMaterialize); |
3007 | WRITE_NODE_FIELD(ctequery); |
3008 | WRITE_LOCATION_FIELD(location); |
3009 | WRITE_BOOL_FIELD(cterecursive); |
3010 | WRITE_INT_FIELD(cterefcount); |
3011 | WRITE_NODE_FIELD(ctecolnames); |
3012 | WRITE_NODE_FIELD(ctecoltypes); |
3013 | WRITE_NODE_FIELD(ctecoltypmods); |
3014 | WRITE_NODE_FIELD(ctecolcollations); |
3015 | } |
3016 | |
3017 | static void |
3018 | _outSetOperationStmt(StringInfo str, const SetOperationStmt *node) |
3019 | { |
3020 | WRITE_NODE_TYPE("SETOPERATIONSTMT" ); |
3021 | |
3022 | WRITE_ENUM_FIELD(op, SetOperation); |
3023 | WRITE_BOOL_FIELD(all); |
3024 | WRITE_NODE_FIELD(larg); |
3025 | WRITE_NODE_FIELD(rarg); |
3026 | WRITE_NODE_FIELD(colTypes); |
3027 | WRITE_NODE_FIELD(colTypmods); |
3028 | WRITE_NODE_FIELD(colCollations); |
3029 | WRITE_NODE_FIELD(groupClauses); |
3030 | } |
3031 | |
3032 | static void |
3033 | _outRangeTblEntry(StringInfo str, const RangeTblEntry *node) |
3034 | { |
3035 | WRITE_NODE_TYPE("RTE" ); |
3036 | |
3037 | /* put alias + eref first to make dump more legible */ |
3038 | WRITE_NODE_FIELD(alias); |
3039 | WRITE_NODE_FIELD(eref); |
3040 | WRITE_ENUM_FIELD(rtekind, RTEKind); |
3041 | |
3042 | switch (node->rtekind) |
3043 | { |
3044 | case RTE_RELATION: |
3045 | WRITE_OID_FIELD(relid); |
3046 | WRITE_CHAR_FIELD(relkind); |
3047 | WRITE_INT_FIELD(rellockmode); |
3048 | WRITE_NODE_FIELD(tablesample); |
3049 | break; |
3050 | case RTE_SUBQUERY: |
3051 | WRITE_NODE_FIELD(subquery); |
3052 | WRITE_BOOL_FIELD(security_barrier); |
3053 | break; |
3054 | case RTE_JOIN: |
3055 | WRITE_ENUM_FIELD(jointype, JoinType); |
3056 | WRITE_NODE_FIELD(joinaliasvars); |
3057 | break; |
3058 | case RTE_FUNCTION: |
3059 | WRITE_NODE_FIELD(functions); |
3060 | WRITE_BOOL_FIELD(funcordinality); |
3061 | break; |
3062 | case RTE_TABLEFUNC: |
3063 | WRITE_NODE_FIELD(tablefunc); |
3064 | break; |
3065 | case RTE_VALUES: |
3066 | WRITE_NODE_FIELD(values_lists); |
3067 | WRITE_NODE_FIELD(coltypes); |
3068 | WRITE_NODE_FIELD(coltypmods); |
3069 | WRITE_NODE_FIELD(colcollations); |
3070 | break; |
3071 | case RTE_CTE: |
3072 | WRITE_STRING_FIELD(ctename); |
3073 | WRITE_UINT_FIELD(ctelevelsup); |
3074 | WRITE_BOOL_FIELD(self_reference); |
3075 | WRITE_NODE_FIELD(coltypes); |
3076 | WRITE_NODE_FIELD(coltypmods); |
3077 | WRITE_NODE_FIELD(colcollations); |
3078 | break; |
3079 | case RTE_NAMEDTUPLESTORE: |
3080 | WRITE_STRING_FIELD(enrname); |
3081 | WRITE_FLOAT_FIELD(enrtuples, "%.0f" ); |
3082 | WRITE_OID_FIELD(relid); |
3083 | WRITE_NODE_FIELD(coltypes); |
3084 | WRITE_NODE_FIELD(coltypmods); |
3085 | WRITE_NODE_FIELD(colcollations); |
3086 | break; |
3087 | case RTE_RESULT: |
3088 | /* no extra fields */ |
3089 | break; |
3090 | default: |
3091 | elog(ERROR, "unrecognized RTE kind: %d" , (int) node->rtekind); |
3092 | break; |
3093 | } |
3094 | |
3095 | WRITE_BOOL_FIELD(lateral); |
3096 | WRITE_BOOL_FIELD(inh); |
3097 | WRITE_BOOL_FIELD(inFromCl); |
3098 | WRITE_UINT_FIELD(requiredPerms); |
3099 | WRITE_OID_FIELD(checkAsUser); |
3100 | WRITE_BITMAPSET_FIELD(selectedCols); |
3101 | WRITE_BITMAPSET_FIELD(insertedCols); |
3102 | WRITE_BITMAPSET_FIELD(updatedCols); |
3103 | WRITE_BITMAPSET_FIELD(extraUpdatedCols); |
3104 | WRITE_NODE_FIELD(securityQuals); |
3105 | } |
3106 | |
3107 | static void |
3108 | _outRangeTblFunction(StringInfo str, const RangeTblFunction *node) |
3109 | { |
3110 | WRITE_NODE_TYPE("RANGETBLFUNCTION" ); |
3111 | |
3112 | WRITE_NODE_FIELD(funcexpr); |
3113 | WRITE_INT_FIELD(funccolcount); |
3114 | WRITE_NODE_FIELD(funccolnames); |
3115 | WRITE_NODE_FIELD(funccoltypes); |
3116 | WRITE_NODE_FIELD(funccoltypmods); |
3117 | WRITE_NODE_FIELD(funccolcollations); |
3118 | WRITE_BITMAPSET_FIELD(funcparams); |
3119 | } |
3120 | |
3121 | static void |
3122 | _outTableSampleClause(StringInfo str, const TableSampleClause *node) |
3123 | { |
3124 | WRITE_NODE_TYPE("TABLESAMPLECLAUSE" ); |
3125 | |
3126 | WRITE_OID_FIELD(tsmhandler); |
3127 | WRITE_NODE_FIELD(args); |
3128 | WRITE_NODE_FIELD(repeatable); |
3129 | } |
3130 | |
3131 | static void |
3132 | _outAExpr(StringInfo str, const A_Expr *node) |
3133 | { |
3134 | WRITE_NODE_TYPE("AEXPR" ); |
3135 | |
3136 | switch (node->kind) |
3137 | { |
3138 | case AEXPR_OP: |
3139 | appendStringInfoChar(str, ' '); |
3140 | WRITE_NODE_FIELD(name); |
3141 | break; |
3142 | case AEXPR_OP_ANY: |
3143 | appendStringInfoChar(str, ' '); |
3144 | WRITE_NODE_FIELD(name); |
3145 | appendStringInfoString(str, " ANY " ); |
3146 | break; |
3147 | case AEXPR_OP_ALL: |
3148 | appendStringInfoChar(str, ' '); |
3149 | WRITE_NODE_FIELD(name); |
3150 | appendStringInfoString(str, " ALL " ); |
3151 | break; |
3152 | case AEXPR_DISTINCT: |
3153 | appendStringInfoString(str, " DISTINCT " ); |
3154 | WRITE_NODE_FIELD(name); |
3155 | break; |
3156 | case AEXPR_NOT_DISTINCT: |
3157 | appendStringInfoString(str, " NOT_DISTINCT " ); |
3158 | WRITE_NODE_FIELD(name); |
3159 | break; |
3160 | case AEXPR_NULLIF: |
3161 | appendStringInfoString(str, " NULLIF " ); |
3162 | WRITE_NODE_FIELD(name); |
3163 | break; |
3164 | case AEXPR_OF: |
3165 | appendStringInfoString(str, " OF " ); |
3166 | WRITE_NODE_FIELD(name); |
3167 | break; |
3168 | case AEXPR_IN: |
3169 | appendStringInfoString(str, " IN " ); |
3170 | WRITE_NODE_FIELD(name); |
3171 | break; |
3172 | case AEXPR_LIKE: |
3173 | appendStringInfoString(str, " LIKE " ); |
3174 | WRITE_NODE_FIELD(name); |
3175 | break; |
3176 | case AEXPR_ILIKE: |
3177 | appendStringInfoString(str, " ILIKE " ); |
3178 | WRITE_NODE_FIELD(name); |
3179 | break; |
3180 | case AEXPR_SIMILAR: |
3181 | appendStringInfoString(str, " SIMILAR " ); |
3182 | WRITE_NODE_FIELD(name); |
3183 | break; |
3184 | case AEXPR_BETWEEN: |
3185 | appendStringInfoString(str, " BETWEEN " ); |
3186 | WRITE_NODE_FIELD(name); |
3187 | break; |
3188 | case AEXPR_NOT_BETWEEN: |
3189 | appendStringInfoString(str, " NOT_BETWEEN " ); |
3190 | WRITE_NODE_FIELD(name); |
3191 | break; |
3192 | case AEXPR_BETWEEN_SYM: |
3193 | appendStringInfoString(str, " BETWEEN_SYM " ); |
3194 | WRITE_NODE_FIELD(name); |
3195 | break; |
3196 | case AEXPR_NOT_BETWEEN_SYM: |
3197 | appendStringInfoString(str, " NOT_BETWEEN_SYM " ); |
3198 | WRITE_NODE_FIELD(name); |
3199 | break; |
3200 | case AEXPR_PAREN: |
3201 | appendStringInfoString(str, " PAREN" ); |
3202 | break; |
3203 | default: |
3204 | appendStringInfoString(str, " ??" ); |
3205 | break; |
3206 | } |
3207 | |
3208 | WRITE_NODE_FIELD(lexpr); |
3209 | WRITE_NODE_FIELD(rexpr); |
3210 | WRITE_LOCATION_FIELD(location); |
3211 | } |
3212 | |
3213 | static void |
3214 | _outValue(StringInfo str, const Value *value) |
3215 | { |
3216 | switch (value->type) |
3217 | { |
3218 | case T_Integer: |
3219 | appendStringInfo(str, "%d" , value->val.ival); |
3220 | break; |
3221 | case T_Float: |
3222 | |
3223 | /* |
3224 | * We assume the value is a valid numeric literal and so does not |
3225 | * need quoting. |
3226 | */ |
3227 | appendStringInfoString(str, value->val.str); |
3228 | break; |
3229 | case T_String: |
3230 | |
3231 | /* |
3232 | * We use outToken to provide escaping of the string's content, |
3233 | * but we don't want it to do anything with an empty string. |
3234 | */ |
3235 | appendStringInfoChar(str, '"'); |
3236 | if (value->val.str[0] != '\0') |
3237 | outToken(str, value->val.str); |
3238 | appendStringInfoChar(str, '"'); |
3239 | break; |
3240 | case T_BitString: |
3241 | /* internal representation already has leading 'b' */ |
3242 | appendStringInfoString(str, value->val.str); |
3243 | break; |
3244 | case T_Null: |
3245 | /* this is seen only within A_Const, not in transformed trees */ |
3246 | appendStringInfoString(str, "NULL" ); |
3247 | break; |
3248 | default: |
3249 | elog(ERROR, "unrecognized node type: %d" , (int) value->type); |
3250 | break; |
3251 | } |
3252 | } |
3253 | |
3254 | static void |
3255 | _outColumnRef(StringInfo str, const ColumnRef *node) |
3256 | { |
3257 | WRITE_NODE_TYPE("COLUMNREF" ); |
3258 | |
3259 | WRITE_NODE_FIELD(fields); |
3260 | WRITE_LOCATION_FIELD(location); |
3261 | } |
3262 | |
3263 | static void |
3264 | _outParamRef(StringInfo str, const ParamRef *node) |
3265 | { |
3266 | WRITE_NODE_TYPE("PARAMREF" ); |
3267 | |
3268 | WRITE_INT_FIELD(number); |
3269 | WRITE_LOCATION_FIELD(location); |
3270 | } |
3271 | |
3272 | /* |
3273 | * Node types found in raw parse trees (supported for debug purposes) |
3274 | */ |
3275 | |
3276 | static void |
3277 | _outRawStmt(StringInfo str, const RawStmt *node) |
3278 | { |
3279 | WRITE_NODE_TYPE("RAWSTMT" ); |
3280 | |
3281 | WRITE_NODE_FIELD(stmt); |
3282 | WRITE_LOCATION_FIELD(stmt_location); |
3283 | WRITE_INT_FIELD(stmt_len); |
3284 | } |
3285 | |
3286 | static void |
3287 | _outAConst(StringInfo str, const A_Const *node) |
3288 | { |
3289 | WRITE_NODE_TYPE("A_CONST" ); |
3290 | |
3291 | appendStringInfoString(str, " :val " ); |
3292 | _outValue(str, &(node->val)); |
3293 | WRITE_LOCATION_FIELD(location); |
3294 | } |
3295 | |
3296 | static void |
3297 | _outA_Star(StringInfo str, const A_Star *node) |
3298 | { |
3299 | WRITE_NODE_TYPE("A_STAR" ); |
3300 | } |
3301 | |
3302 | static void |
3303 | _outA_Indices(StringInfo str, const A_Indices *node) |
3304 | { |
3305 | WRITE_NODE_TYPE("A_INDICES" ); |
3306 | |
3307 | WRITE_BOOL_FIELD(is_slice); |
3308 | WRITE_NODE_FIELD(lidx); |
3309 | WRITE_NODE_FIELD(uidx); |
3310 | } |
3311 | |
3312 | static void |
3313 | _outA_Indirection(StringInfo str, const A_Indirection *node) |
3314 | { |
3315 | WRITE_NODE_TYPE("A_INDIRECTION" ); |
3316 | |
3317 | WRITE_NODE_FIELD(arg); |
3318 | WRITE_NODE_FIELD(indirection); |
3319 | } |
3320 | |
3321 | static void |
3322 | _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node) |
3323 | { |
3324 | WRITE_NODE_TYPE("A_ARRAYEXPR" ); |
3325 | |
3326 | WRITE_NODE_FIELD(elements); |
3327 | WRITE_LOCATION_FIELD(location); |
3328 | } |
3329 | |
3330 | static void |
3331 | _outResTarget(StringInfo str, const ResTarget *node) |
3332 | { |
3333 | WRITE_NODE_TYPE("RESTARGET" ); |
3334 | |
3335 | WRITE_STRING_FIELD(name); |
3336 | WRITE_NODE_FIELD(indirection); |
3337 | WRITE_NODE_FIELD(val); |
3338 | WRITE_LOCATION_FIELD(location); |
3339 | } |
3340 | |
3341 | static void |
3342 | _outMultiAssignRef(StringInfo str, const MultiAssignRef *node) |
3343 | { |
3344 | WRITE_NODE_TYPE("MULTIASSIGNREF" ); |
3345 | |
3346 | WRITE_NODE_FIELD(source); |
3347 | WRITE_INT_FIELD(colno); |
3348 | WRITE_INT_FIELD(ncolumns); |
3349 | } |
3350 | |
3351 | static void |
3352 | _outSortBy(StringInfo str, const SortBy *node) |
3353 | { |
3354 | WRITE_NODE_TYPE("SORTBY" ); |
3355 | |
3356 | WRITE_NODE_FIELD(node); |
3357 | WRITE_ENUM_FIELD(sortby_dir, SortByDir); |
3358 | WRITE_ENUM_FIELD(sortby_nulls, SortByNulls); |
3359 | WRITE_NODE_FIELD(useOp); |
3360 | WRITE_LOCATION_FIELD(location); |
3361 | } |
3362 | |
3363 | static void |
3364 | _outWindowDef(StringInfo str, const WindowDef *node) |
3365 | { |
3366 | WRITE_NODE_TYPE("WINDOWDEF" ); |
3367 | |
3368 | WRITE_STRING_FIELD(name); |
3369 | WRITE_STRING_FIELD(refname); |
3370 | WRITE_NODE_FIELD(partitionClause); |
3371 | WRITE_NODE_FIELD(orderClause); |
3372 | WRITE_INT_FIELD(frameOptions); |
3373 | WRITE_NODE_FIELD(startOffset); |
3374 | WRITE_NODE_FIELD(endOffset); |
3375 | WRITE_LOCATION_FIELD(location); |
3376 | } |
3377 | |
3378 | static void |
3379 | _outRangeSubselect(StringInfo str, const RangeSubselect *node) |
3380 | { |
3381 | WRITE_NODE_TYPE("RANGESUBSELECT" ); |
3382 | |
3383 | WRITE_BOOL_FIELD(lateral); |
3384 | WRITE_NODE_FIELD(subquery); |
3385 | WRITE_NODE_FIELD(alias); |
3386 | } |
3387 | |
3388 | static void |
3389 | _outRangeFunction(StringInfo str, const RangeFunction *node) |
3390 | { |
3391 | WRITE_NODE_TYPE("RANGEFUNCTION" ); |
3392 | |
3393 | WRITE_BOOL_FIELD(lateral); |
3394 | WRITE_BOOL_FIELD(ordinality); |
3395 | WRITE_BOOL_FIELD(is_rowsfrom); |
3396 | WRITE_NODE_FIELD(functions); |
3397 | WRITE_NODE_FIELD(alias); |
3398 | WRITE_NODE_FIELD(coldeflist); |
3399 | } |
3400 | |
3401 | static void |
3402 | _outRangeTableSample(StringInfo str, const RangeTableSample *node) |
3403 | { |
3404 | WRITE_NODE_TYPE("RANGETABLESAMPLE" ); |
3405 | |
3406 | WRITE_NODE_FIELD(relation); |
3407 | WRITE_NODE_FIELD(method); |
3408 | WRITE_NODE_FIELD(args); |
3409 | WRITE_NODE_FIELD(repeatable); |
3410 | WRITE_LOCATION_FIELD(location); |
3411 | } |
3412 | |
3413 | static void |
3414 | _outRangeTableFunc(StringInfo str, const RangeTableFunc *node) |
3415 | { |
3416 | WRITE_NODE_TYPE("RANGETABLEFUNC" ); |
3417 | |
3418 | WRITE_BOOL_FIELD(lateral); |
3419 | WRITE_NODE_FIELD(docexpr); |
3420 | WRITE_NODE_FIELD(rowexpr); |
3421 | WRITE_NODE_FIELD(namespaces); |
3422 | WRITE_NODE_FIELD(columns); |
3423 | WRITE_NODE_FIELD(alias); |
3424 | WRITE_LOCATION_FIELD(location); |
3425 | } |
3426 | |
3427 | static void |
3428 | _outRangeTableFuncCol(StringInfo str, const RangeTableFuncCol *node) |
3429 | { |
3430 | WRITE_NODE_TYPE("RANGETABLEFUNCCOL" ); |
3431 | |
3432 | WRITE_STRING_FIELD(colname); |
3433 | WRITE_NODE_FIELD(typeName); |
3434 | WRITE_BOOL_FIELD(for_ordinality); |
3435 | WRITE_BOOL_FIELD(is_not_null); |
3436 | WRITE_NODE_FIELD(colexpr); |
3437 | WRITE_NODE_FIELD(coldefexpr); |
3438 | WRITE_LOCATION_FIELD(location); |
3439 | } |
3440 | |
3441 | static void |
3442 | _outConstraint(StringInfo str, const Constraint *node) |
3443 | { |
3444 | WRITE_NODE_TYPE("CONSTRAINT" ); |
3445 | |
3446 | WRITE_STRING_FIELD(conname); |
3447 | WRITE_BOOL_FIELD(deferrable); |
3448 | WRITE_BOOL_FIELD(initdeferred); |
3449 | WRITE_LOCATION_FIELD(location); |
3450 | |
3451 | appendStringInfoString(str, " :contype " ); |
3452 | switch (node->contype) |
3453 | { |
3454 | case CONSTR_NULL: |
3455 | appendStringInfoString(str, "NULL" ); |
3456 | break; |
3457 | |
3458 | case CONSTR_NOTNULL: |
3459 | appendStringInfoString(str, "NOT_NULL" ); |
3460 | break; |
3461 | |
3462 | case CONSTR_DEFAULT: |
3463 | appendStringInfoString(str, "DEFAULT" ); |
3464 | WRITE_NODE_FIELD(raw_expr); |
3465 | WRITE_STRING_FIELD(cooked_expr); |
3466 | break; |
3467 | |
3468 | case CONSTR_IDENTITY: |
3469 | appendStringInfoString(str, "IDENTITY" ); |
3470 | WRITE_NODE_FIELD(raw_expr); |
3471 | WRITE_STRING_FIELD(cooked_expr); |
3472 | WRITE_CHAR_FIELD(generated_when); |
3473 | break; |
3474 | |
3475 | case CONSTR_GENERATED: |
3476 | appendStringInfoString(str, "GENERATED" ); |
3477 | WRITE_NODE_FIELD(raw_expr); |
3478 | WRITE_STRING_FIELD(cooked_expr); |
3479 | WRITE_CHAR_FIELD(generated_when); |
3480 | break; |
3481 | |
3482 | case CONSTR_CHECK: |
3483 | appendStringInfoString(str, "CHECK" ); |
3484 | WRITE_BOOL_FIELD(is_no_inherit); |
3485 | WRITE_NODE_FIELD(raw_expr); |
3486 | WRITE_STRING_FIELD(cooked_expr); |
3487 | break; |
3488 | |
3489 | case CONSTR_PRIMARY: |
3490 | appendStringInfoString(str, "PRIMARY_KEY" ); |
3491 | WRITE_NODE_FIELD(keys); |
3492 | WRITE_NODE_FIELD(including); |
3493 | WRITE_NODE_FIELD(options); |
3494 | WRITE_STRING_FIELD(indexname); |
3495 | WRITE_STRING_FIELD(indexspace); |
3496 | WRITE_BOOL_FIELD(reset_default_tblspc); |
3497 | /* access_method and where_clause not currently used */ |
3498 | break; |
3499 | |
3500 | case CONSTR_UNIQUE: |
3501 | appendStringInfoString(str, "UNIQUE" ); |
3502 | WRITE_NODE_FIELD(keys); |
3503 | WRITE_NODE_FIELD(including); |
3504 | WRITE_NODE_FIELD(options); |
3505 | WRITE_STRING_FIELD(indexname); |
3506 | WRITE_STRING_FIELD(indexspace); |
3507 | WRITE_BOOL_FIELD(reset_default_tblspc); |
3508 | /* access_method and where_clause not currently used */ |
3509 | break; |
3510 | |
3511 | case CONSTR_EXCLUSION: |
3512 | appendStringInfoString(str, "EXCLUSION" ); |
3513 | WRITE_NODE_FIELD(exclusions); |
3514 | WRITE_NODE_FIELD(including); |
3515 | WRITE_NODE_FIELD(options); |
3516 | WRITE_STRING_FIELD(indexname); |
3517 | WRITE_STRING_FIELD(indexspace); |
3518 | WRITE_BOOL_FIELD(reset_default_tblspc); |
3519 | WRITE_STRING_FIELD(access_method); |
3520 | WRITE_NODE_FIELD(where_clause); |
3521 | break; |
3522 | |
3523 | case CONSTR_FOREIGN: |
3524 | appendStringInfoString(str, "FOREIGN_KEY" ); |
3525 | WRITE_NODE_FIELD(pktable); |
3526 | WRITE_NODE_FIELD(fk_attrs); |
3527 | WRITE_NODE_FIELD(pk_attrs); |
3528 | WRITE_CHAR_FIELD(fk_matchtype); |
3529 | WRITE_CHAR_FIELD(fk_upd_action); |
3530 | WRITE_CHAR_FIELD(fk_del_action); |
3531 | WRITE_NODE_FIELD(old_conpfeqop); |
3532 | WRITE_OID_FIELD(old_pktable_oid); |
3533 | WRITE_BOOL_FIELD(skip_validation); |
3534 | WRITE_BOOL_FIELD(initially_valid); |
3535 | break; |
3536 | |
3537 | case CONSTR_ATTR_DEFERRABLE: |
3538 | appendStringInfoString(str, "ATTR_DEFERRABLE" ); |
3539 | break; |
3540 | |
3541 | case CONSTR_ATTR_NOT_DEFERRABLE: |
3542 | appendStringInfoString(str, "ATTR_NOT_DEFERRABLE" ); |
3543 | break; |
3544 | |
3545 | case CONSTR_ATTR_DEFERRED: |
3546 | appendStringInfoString(str, "ATTR_DEFERRED" ); |
3547 | break; |
3548 | |
3549 | case CONSTR_ATTR_IMMEDIATE: |
3550 | appendStringInfoString(str, "ATTR_IMMEDIATE" ); |
3551 | break; |
3552 | |
3553 | default: |
3554 | appendStringInfo(str, "<unrecognized_constraint %d>" , |
3555 | (int) node->contype); |
3556 | break; |
3557 | } |
3558 | } |
3559 | |
3560 | static void |
3561 | _outForeignKeyCacheInfo(StringInfo str, const ForeignKeyCacheInfo *node) |
3562 | { |
3563 | WRITE_NODE_TYPE("FOREIGNKEYCACHEINFO" ); |
3564 | |
3565 | WRITE_OID_FIELD(conoid); |
3566 | WRITE_OID_FIELD(conrelid); |
3567 | WRITE_OID_FIELD(confrelid); |
3568 | WRITE_INT_FIELD(nkeys); |
3569 | WRITE_ATTRNUMBER_ARRAY(conkey, node->nkeys); |
3570 | WRITE_ATTRNUMBER_ARRAY(confkey, node->nkeys); |
3571 | WRITE_OID_ARRAY(conpfeqop, node->nkeys); |
3572 | } |
3573 | |
3574 | static void |
3575 | _outPartitionElem(StringInfo str, const PartitionElem *node) |
3576 | { |
3577 | WRITE_NODE_TYPE("PARTITIONELEM" ); |
3578 | |
3579 | WRITE_STRING_FIELD(name); |
3580 | WRITE_NODE_FIELD(expr); |
3581 | WRITE_NODE_FIELD(collation); |
3582 | WRITE_NODE_FIELD(opclass); |
3583 | WRITE_LOCATION_FIELD(location); |
3584 | } |
3585 | |
3586 | static void |
3587 | _outPartitionSpec(StringInfo str, const PartitionSpec *node) |
3588 | { |
3589 | WRITE_NODE_TYPE("PARTITIONSPEC" ); |
3590 | |
3591 | WRITE_STRING_FIELD(strategy); |
3592 | WRITE_NODE_FIELD(partParams); |
3593 | WRITE_LOCATION_FIELD(location); |
3594 | } |
3595 | |
3596 | static void |
3597 | _outPartitionBoundSpec(StringInfo str, const PartitionBoundSpec *node) |
3598 | { |
3599 | WRITE_NODE_TYPE("PARTITIONBOUNDSPEC" ); |
3600 | |
3601 | WRITE_CHAR_FIELD(strategy); |
3602 | WRITE_BOOL_FIELD(is_default); |
3603 | WRITE_INT_FIELD(modulus); |
3604 | WRITE_INT_FIELD(remainder); |
3605 | WRITE_NODE_FIELD(listdatums); |
3606 | WRITE_NODE_FIELD(lowerdatums); |
3607 | WRITE_NODE_FIELD(upperdatums); |
3608 | WRITE_LOCATION_FIELD(location); |
3609 | } |
3610 | |
3611 | static void |
3612 | _outPartitionRangeDatum(StringInfo str, const PartitionRangeDatum *node) |
3613 | { |
3614 | WRITE_NODE_TYPE("PARTITIONRANGEDATUM" ); |
3615 | |
3616 | WRITE_ENUM_FIELD(kind, PartitionRangeDatumKind); |
3617 | WRITE_NODE_FIELD(value); |
3618 | WRITE_LOCATION_FIELD(location); |
3619 | } |
3620 | |
3621 | /* |
3622 | * outNode - |
3623 | * converts a Node into ascii string and append it to 'str' |
3624 | */ |
3625 | void |
3626 | outNode(StringInfo str, const void *obj) |
3627 | { |
3628 | /* Guard against stack overflow due to overly complex expressions */ |
3629 | check_stack_depth(); |
3630 | |
3631 | if (obj == NULL) |
3632 | appendStringInfoString(str, "<>" ); |
3633 | else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList)) |
3634 | _outList(str, obj); |
3635 | else if (IsA(obj, Integer) || |
3636 | IsA(obj, Float) || |
3637 | IsA(obj, String) || |
3638 | IsA(obj, BitString)) |
3639 | { |
3640 | /* nodeRead does not want to see { } around these! */ |
3641 | _outValue(str, obj); |
3642 | } |
3643 | else |
3644 | { |
3645 | appendStringInfoChar(str, '{'); |
3646 | switch (nodeTag(obj)) |
3647 | { |
3648 | case T_PlannedStmt: |
3649 | _outPlannedStmt(str, obj); |
3650 | break; |
3651 | case T_Plan: |
3652 | _outPlan(str, obj); |
3653 | break; |
3654 | case T_Result: |
3655 | _outResult(str, obj); |
3656 | break; |
3657 | case T_ProjectSet: |
3658 | _outProjectSet(str, obj); |
3659 | break; |
3660 | case T_ModifyTable: |
3661 | _outModifyTable(str, obj); |
3662 | break; |
3663 | case T_Append: |
3664 | _outAppend(str, obj); |
3665 | break; |
3666 | case T_MergeAppend: |
3667 | _outMergeAppend(str, obj); |
3668 | break; |
3669 | case T_RecursiveUnion: |
3670 | _outRecursiveUnion(str, obj); |
3671 | break; |
3672 | case T_BitmapAnd: |
3673 | _outBitmapAnd(str, obj); |
3674 | break; |
3675 | case T_BitmapOr: |
3676 | _outBitmapOr(str, obj); |
3677 | break; |
3678 | case T_Gather: |
3679 | _outGather(str, obj); |
3680 | break; |
3681 | case T_GatherMerge: |
3682 | _outGatherMerge(str, obj); |
3683 | break; |
3684 | case T_Scan: |
3685 | _outScan(str, obj); |
3686 | break; |
3687 | case T_SeqScan: |
3688 | _outSeqScan(str, obj); |
3689 | break; |
3690 | case T_SampleScan: |
3691 | _outSampleScan(str, obj); |
3692 | break; |
3693 | case T_IndexScan: |
3694 | _outIndexScan(str, obj); |
3695 | break; |
3696 | case T_IndexOnlyScan: |
3697 | _outIndexOnlyScan(str, obj); |
3698 | break; |
3699 | case T_BitmapIndexScan: |
3700 | _outBitmapIndexScan(str, obj); |
3701 | break; |
3702 | case T_BitmapHeapScan: |
3703 | _outBitmapHeapScan(str, obj); |
3704 | break; |
3705 | case T_TidScan: |
3706 | _outTidScan(str, obj); |
3707 | break; |
3708 | case T_SubqueryScan: |
3709 | _outSubqueryScan(str, obj); |
3710 | break; |
3711 | case T_FunctionScan: |
3712 | _outFunctionScan(str, obj); |
3713 | break; |
3714 | case T_TableFuncScan: |
3715 | _outTableFuncScan(str, obj); |
3716 | break; |
3717 | case T_ValuesScan: |
3718 | _outValuesScan(str, obj); |
3719 | break; |
3720 | case T_CteScan: |
3721 | _outCteScan(str, obj); |
3722 | break; |
3723 | case T_NamedTuplestoreScan: |
3724 | _outNamedTuplestoreScan(str, obj); |
3725 | break; |
3726 | case T_WorkTableScan: |
3727 | _outWorkTableScan(str, obj); |
3728 | break; |
3729 | case T_ForeignScan: |
3730 | _outForeignScan(str, obj); |
3731 | break; |
3732 | case T_CustomScan: |
3733 | _outCustomScan(str, obj); |
3734 | break; |
3735 | case T_Join: |
3736 | _outJoin(str, obj); |
3737 | break; |
3738 | case T_NestLoop: |
3739 | _outNestLoop(str, obj); |
3740 | break; |
3741 | case T_MergeJoin: |
3742 | _outMergeJoin(str, obj); |
3743 | break; |
3744 | case T_HashJoin: |
3745 | _outHashJoin(str, obj); |
3746 | break; |
3747 | case T_Agg: |
3748 | _outAgg(str, obj); |
3749 | break; |
3750 | case T_WindowAgg: |
3751 | _outWindowAgg(str, obj); |
3752 | break; |
3753 | case T_Group: |
3754 | _outGroup(str, obj); |
3755 | break; |
3756 | case T_Material: |
3757 | _outMaterial(str, obj); |
3758 | break; |
3759 | case T_Sort: |
3760 | _outSort(str, obj); |
3761 | break; |
3762 | case T_Unique: |
3763 | _outUnique(str, obj); |
3764 | break; |
3765 | case T_Hash: |
3766 | _outHash(str, obj); |
3767 | break; |
3768 | case T_SetOp: |
3769 | _outSetOp(str, obj); |
3770 | break; |
3771 | case T_LockRows: |
3772 | _outLockRows(str, obj); |
3773 | break; |
3774 | case T_Limit: |
3775 | _outLimit(str, obj); |
3776 | break; |
3777 | case T_NestLoopParam: |
3778 | _outNestLoopParam(str, obj); |
3779 | break; |
3780 | case T_PlanRowMark: |
3781 | _outPlanRowMark(str, obj); |
3782 | break; |
3783 | case T_PartitionPruneInfo: |
3784 | _outPartitionPruneInfo(str, obj); |
3785 | break; |
3786 | case T_PartitionedRelPruneInfo: |
3787 | _outPartitionedRelPruneInfo(str, obj); |
3788 | break; |
3789 | case T_PartitionPruneStepOp: |
3790 | _outPartitionPruneStepOp(str, obj); |
3791 | break; |
3792 | case T_PartitionPruneStepCombine: |
3793 | _outPartitionPruneStepCombine(str, obj); |
3794 | break; |
3795 | case T_PlanInvalItem: |
3796 | _outPlanInvalItem(str, obj); |
3797 | break; |
3798 | case T_Alias: |
3799 | _outAlias(str, obj); |
3800 | break; |
3801 | case T_RangeVar: |
3802 | _outRangeVar(str, obj); |
3803 | break; |
3804 | case T_TableFunc: |
3805 | _outTableFunc(str, obj); |
3806 | break; |
3807 | case T_IntoClause: |
3808 | _outIntoClause(str, obj); |
3809 | break; |
3810 | case T_Var: |
3811 | _outVar(str, obj); |
3812 | break; |
3813 | case T_Const: |
3814 | _outConst(str, obj); |
3815 | break; |
3816 | case T_Param: |
3817 | _outParam(str, obj); |
3818 | break; |
3819 | case T_Aggref: |
3820 | _outAggref(str, obj); |
3821 | break; |
3822 | case T_GroupingFunc: |
3823 | _outGroupingFunc(str, obj); |
3824 | break; |
3825 | case T_WindowFunc: |
3826 | _outWindowFunc(str, obj); |
3827 | break; |
3828 | case T_SubscriptingRef: |
3829 | _outSubscriptingRef(str, obj); |
3830 | break; |
3831 | case T_FuncExpr: |
3832 | _outFuncExpr(str, obj); |
3833 | break; |
3834 | case T_NamedArgExpr: |
3835 | _outNamedArgExpr(str, obj); |
3836 | break; |
3837 | case T_OpExpr: |
3838 | _outOpExpr(str, obj); |
3839 | break; |
3840 | case T_DistinctExpr: |
3841 | _outDistinctExpr(str, obj); |
3842 | break; |
3843 | case T_NullIfExpr: |
3844 | _outNullIfExpr(str, obj); |
3845 | break; |
3846 | case T_ScalarArrayOpExpr: |
3847 | _outScalarArrayOpExpr(str, obj); |
3848 | break; |
3849 | case T_BoolExpr: |
3850 | _outBoolExpr(str, obj); |
3851 | break; |
3852 | case T_SubLink: |
3853 | _outSubLink(str, obj); |
3854 | break; |
3855 | case T_SubPlan: |
3856 | _outSubPlan(str, obj); |
3857 | break; |
3858 | case T_AlternativeSubPlan: |
3859 | _outAlternativeSubPlan(str, obj); |
3860 | break; |
3861 | case T_FieldSelect: |
3862 | _outFieldSelect(str, obj); |
3863 | break; |
3864 | case T_FieldStore: |
3865 | _outFieldStore(str, obj); |
3866 | break; |
3867 | case T_RelabelType: |
3868 | _outRelabelType(str, obj); |
3869 | break; |
3870 | case T_CoerceViaIO: |
3871 | _outCoerceViaIO(str, obj); |
3872 | break; |
3873 | case T_ArrayCoerceExpr: |
3874 | _outArrayCoerceExpr(str, obj); |
3875 | break; |
3876 | case T_ConvertRowtypeExpr: |
3877 | _outConvertRowtypeExpr(str, obj); |
3878 | break; |
3879 | case T_CollateExpr: |
3880 | _outCollateExpr(str, obj); |
3881 | break; |
3882 | case T_CaseExpr: |
3883 | _outCaseExpr(str, obj); |
3884 | break; |
3885 | case T_CaseWhen: |
3886 | _outCaseWhen(str, obj); |
3887 | break; |
3888 | case T_CaseTestExpr: |
3889 | _outCaseTestExpr(str, obj); |
3890 | break; |
3891 | case T_ArrayExpr: |
3892 | _outArrayExpr(str, obj); |
3893 | break; |
3894 | case T_RowExpr: |
3895 | _outRowExpr(str, obj); |
3896 | break; |
3897 | case T_RowCompareExpr: |
3898 | _outRowCompareExpr(str, obj); |
3899 | break; |
3900 | case T_CoalesceExpr: |
3901 | _outCoalesceExpr(str, obj); |
3902 | break; |
3903 | case T_MinMaxExpr: |
3904 | _outMinMaxExpr(str, obj); |
3905 | break; |
3906 | case T_SQLValueFunction: |
3907 | _outSQLValueFunction(str, obj); |
3908 | break; |
3909 | case T_XmlExpr: |
3910 | _outXmlExpr(str, obj); |
3911 | break; |
3912 | case T_NullTest: |
3913 | _outNullTest(str, obj); |
3914 | break; |
3915 | case T_BooleanTest: |
3916 | _outBooleanTest(str, obj); |
3917 | break; |
3918 | case T_CoerceToDomain: |
3919 | _outCoerceToDomain(str, obj); |
3920 | break; |
3921 | case T_CoerceToDomainValue: |
3922 | _outCoerceToDomainValue(str, obj); |
3923 | break; |
3924 | case T_SetToDefault: |
3925 | _outSetToDefault(str, obj); |
3926 | break; |
3927 | case T_CurrentOfExpr: |
3928 | _outCurrentOfExpr(str, obj); |
3929 | break; |
3930 | case T_NextValueExpr: |
3931 | _outNextValueExpr(str, obj); |
3932 | break; |
3933 | case T_InferenceElem: |
3934 | _outInferenceElem(str, obj); |
3935 | break; |
3936 | case T_TargetEntry: |
3937 | _outTargetEntry(str, obj); |
3938 | break; |
3939 | case T_RangeTblRef: |
3940 | _outRangeTblRef(str, obj); |
3941 | break; |
3942 | case T_JoinExpr: |
3943 | _outJoinExpr(str, obj); |
3944 | break; |
3945 | case T_FromExpr: |
3946 | _outFromExpr(str, obj); |
3947 | break; |
3948 | case T_OnConflictExpr: |
3949 | _outOnConflictExpr(str, obj); |
3950 | break; |
3951 | case T_Path: |
3952 | _outPath(str, obj); |
3953 | break; |
3954 | case T_IndexPath: |
3955 | _outIndexPath(str, obj); |
3956 | break; |
3957 | case T_BitmapHeapPath: |
3958 | _outBitmapHeapPath(str, obj); |
3959 | break; |
3960 | case T_BitmapAndPath: |
3961 | _outBitmapAndPath(str, obj); |
3962 | break; |
3963 | case T_BitmapOrPath: |
3964 | _outBitmapOrPath(str, obj); |
3965 | break; |
3966 | case T_TidPath: |
3967 | _outTidPath(str, obj); |
3968 | break; |
3969 | case T_SubqueryScanPath: |
3970 | _outSubqueryScanPath(str, obj); |
3971 | break; |
3972 | case T_ForeignPath: |
3973 | _outForeignPath(str, obj); |
3974 | break; |
3975 | case T_CustomPath: |
3976 | _outCustomPath(str, obj); |
3977 | break; |
3978 | case T_AppendPath: |
3979 | _outAppendPath(str, obj); |
3980 | break; |
3981 | case T_MergeAppendPath: |
3982 | _outMergeAppendPath(str, obj); |
3983 | break; |
3984 | case T_GroupResultPath: |
3985 | _outGroupResultPath(str, obj); |
3986 | break; |
3987 | case T_MaterialPath: |
3988 | _outMaterialPath(str, obj); |
3989 | break; |
3990 | case T_UniquePath: |
3991 | _outUniquePath(str, obj); |
3992 | break; |
3993 | case T_GatherPath: |
3994 | _outGatherPath(str, obj); |
3995 | break; |
3996 | case T_ProjectionPath: |
3997 | _outProjectionPath(str, obj); |
3998 | break; |
3999 | case T_ProjectSetPath: |
4000 | _outProjectSetPath(str, obj); |
4001 | break; |
4002 | case T_SortPath: |
4003 | _outSortPath(str, obj); |
4004 | break; |
4005 | case T_GroupPath: |
4006 | _outGroupPath(str, obj); |
4007 | break; |
4008 | case T_UpperUniquePath: |
4009 | _outUpperUniquePath(str, obj); |
4010 | break; |
4011 | case T_AggPath: |
4012 | _outAggPath(str, obj); |
4013 | break; |
4014 | case T_GroupingSetsPath: |
4015 | _outGroupingSetsPath(str, obj); |
4016 | break; |
4017 | case T_MinMaxAggPath: |
4018 | _outMinMaxAggPath(str, obj); |
4019 | break; |
4020 | case T_WindowAggPath: |
4021 | _outWindowAggPath(str, obj); |
4022 | break; |
4023 | case T_SetOpPath: |
4024 | _outSetOpPath(str, obj); |
4025 | break; |
4026 | case T_RecursiveUnionPath: |
4027 | _outRecursiveUnionPath(str, obj); |
4028 | break; |
4029 | case T_LockRowsPath: |
4030 | _outLockRowsPath(str, obj); |
4031 | break; |
4032 | case T_ModifyTablePath: |
4033 | _outModifyTablePath(str, obj); |
4034 | break; |
4035 | case T_LimitPath: |
4036 | _outLimitPath(str, obj); |
4037 | break; |
4038 | case T_GatherMergePath: |
4039 | _outGatherMergePath(str, obj); |
4040 | break; |
4041 | case T_NestPath: |
4042 | _outNestPath(str, obj); |
4043 | break; |
4044 | case T_MergePath: |
4045 | _outMergePath(str, obj); |
4046 | break; |
4047 | case T_HashPath: |
4048 | _outHashPath(str, obj); |
4049 | break; |
4050 | case T_PlannerGlobal: |
4051 | _outPlannerGlobal(str, obj); |
4052 | break; |
4053 | case T_PlannerInfo: |
4054 | _outPlannerInfo(str, obj); |
4055 | break; |
4056 | case T_RelOptInfo: |
4057 | _outRelOptInfo(str, obj); |
4058 | break; |
4059 | case T_IndexOptInfo: |
4060 | _outIndexOptInfo(str, obj); |
4061 | break; |
4062 | case T_ForeignKeyOptInfo: |
4063 | _outForeignKeyOptInfo(str, obj); |
4064 | break; |
4065 | case T_EquivalenceClass: |
4066 | _outEquivalenceClass(str, obj); |
4067 | break; |
4068 | case T_EquivalenceMember: |
4069 | _outEquivalenceMember(str, obj); |
4070 | break; |
4071 | case T_PathKey: |
4072 | _outPathKey(str, obj); |
4073 | break; |
4074 | case T_PathTarget: |
4075 | _outPathTarget(str, obj); |
4076 | break; |
4077 | case T_ParamPathInfo: |
4078 | _outParamPathInfo(str, obj); |
4079 | break; |
4080 | case T_RestrictInfo: |
4081 | _outRestrictInfo(str, obj); |
4082 | break; |
4083 | case T_IndexClause: |
4084 | _outIndexClause(str, obj); |
4085 | break; |
4086 | case T_PlaceHolderVar: |
4087 | _outPlaceHolderVar(str, obj); |
4088 | break; |
4089 | case T_SpecialJoinInfo: |
4090 | _outSpecialJoinInfo(str, obj); |
4091 | break; |
4092 | case T_AppendRelInfo: |
4093 | _outAppendRelInfo(str, obj); |
4094 | break; |
4095 | case T_PlaceHolderInfo: |
4096 | _outPlaceHolderInfo(str, obj); |
4097 | break; |
4098 | case T_MinMaxAggInfo: |
4099 | _outMinMaxAggInfo(str, obj); |
4100 | break; |
4101 | case T_PlannerParamItem: |
4102 | _outPlannerParamItem(str, obj); |
4103 | break; |
4104 | case T_RollupData: |
4105 | _outRollupData(str, obj); |
4106 | break; |
4107 | case T_GroupingSetData: |
4108 | _outGroupingSetData(str, obj); |
4109 | break; |
4110 | case T_StatisticExtInfo: |
4111 | _outStatisticExtInfo(str, obj); |
4112 | break; |
4113 | case T_ExtensibleNode: |
4114 | _outExtensibleNode(str, obj); |
4115 | break; |
4116 | case T_CreateStmt: |
4117 | _outCreateStmt(str, obj); |
4118 | break; |
4119 | case T_CreateForeignTableStmt: |
4120 | _outCreateForeignTableStmt(str, obj); |
4121 | break; |
4122 | case T_ImportForeignSchemaStmt: |
4123 | _outImportForeignSchemaStmt(str, obj); |
4124 | break; |
4125 | case T_IndexStmt: |
4126 | _outIndexStmt(str, obj); |
4127 | break; |
4128 | case T_CreateStatsStmt: |
4129 | _outCreateStatsStmt(str, obj); |
4130 | break; |
4131 | case T_NotifyStmt: |
4132 | _outNotifyStmt(str, obj); |
4133 | break; |
4134 | case T_DeclareCursorStmt: |
4135 | _outDeclareCursorStmt(str, obj); |
4136 | break; |
4137 | case T_SelectStmt: |
4138 | _outSelectStmt(str, obj); |
4139 | break; |
4140 | case T_ColumnDef: |
4141 | _outColumnDef(str, obj); |
4142 | break; |
4143 | case T_TypeName: |
4144 | _outTypeName(str, obj); |
4145 | break; |
4146 | case T_TypeCast: |
4147 | _outTypeCast(str, obj); |
4148 | break; |
4149 | case T_CollateClause: |
4150 | _outCollateClause(str, obj); |
4151 | break; |
4152 | case T_IndexElem: |
4153 | _outIndexElem(str, obj); |
4154 | break; |
4155 | case T_Query: |
4156 | _outQuery(str, obj); |
4157 | break; |
4158 | case T_WithCheckOption: |
4159 | _outWithCheckOption(str, obj); |
4160 | break; |
4161 | case T_SortGroupClause: |
4162 | _outSortGroupClause(str, obj); |
4163 | break; |
4164 | case T_GroupingSet: |
4165 | _outGroupingSet(str, obj); |
4166 | break; |
4167 | case T_WindowClause: |
4168 | _outWindowClause(str, obj); |
4169 | break; |
4170 | case T_RowMarkClause: |
4171 | _outRowMarkClause(str, obj); |
4172 | break; |
4173 | case T_WithClause: |
4174 | _outWithClause(str, obj); |
4175 | break; |
4176 | case T_CommonTableExpr: |
4177 | _outCommonTableExpr(str, obj); |
4178 | break; |
4179 | case T_SetOperationStmt: |
4180 | _outSetOperationStmt(str, obj); |
4181 | break; |
4182 | case T_RangeTblEntry: |
4183 | _outRangeTblEntry(str, obj); |
4184 | break; |
4185 | case T_RangeTblFunction: |
4186 | _outRangeTblFunction(str, obj); |
4187 | break; |
4188 | case T_TableSampleClause: |
4189 | _outTableSampleClause(str, obj); |
4190 | break; |
4191 | case T_A_Expr: |
4192 | _outAExpr(str, obj); |
4193 | break; |
4194 | case T_ColumnRef: |
4195 | _outColumnRef(str, obj); |
4196 | break; |
4197 | case T_ParamRef: |
4198 | _outParamRef(str, obj); |
4199 | break; |
4200 | case T_RawStmt: |
4201 | _outRawStmt(str, obj); |
4202 | break; |
4203 | case T_A_Const: |
4204 | _outAConst(str, obj); |
4205 | break; |
4206 | case T_A_Star: |
4207 | _outA_Star(str, obj); |
4208 | break; |
4209 | case T_A_Indices: |
4210 | _outA_Indices(str, obj); |
4211 | break; |
4212 | case T_A_Indirection: |
4213 | _outA_Indirection(str, obj); |
4214 | break; |
4215 | case T_A_ArrayExpr: |
4216 | _outA_ArrayExpr(str, obj); |
4217 | break; |
4218 | case T_ResTarget: |
4219 | _outResTarget(str, obj); |
4220 | break; |
4221 | case T_MultiAssignRef: |
4222 | _outMultiAssignRef(str, obj); |
4223 | break; |
4224 | case T_SortBy: |
4225 | _outSortBy(str, obj); |
4226 | break; |
4227 | case T_WindowDef: |
4228 | _outWindowDef(str, obj); |
4229 | break; |
4230 | case T_RangeSubselect: |
4231 | _outRangeSubselect(str, obj); |
4232 | break; |
4233 | case T_RangeFunction: |
4234 | _outRangeFunction(str, obj); |
4235 | break; |
4236 | case T_RangeTableSample: |
4237 | _outRangeTableSample(str, obj); |
4238 | break; |
4239 | case T_RangeTableFunc: |
4240 | _outRangeTableFunc(str, obj); |
4241 | break; |
4242 | case T_RangeTableFuncCol: |
4243 | _outRangeTableFuncCol(str, obj); |
4244 | break; |
4245 | case T_Constraint: |
4246 | _outConstraint(str, obj); |
4247 | break; |
4248 | case T_FuncCall: |
4249 | _outFuncCall(str, obj); |
4250 | break; |
4251 | case T_DefElem: |
4252 | _outDefElem(str, obj); |
4253 | break; |
4254 | case T_TableLikeClause: |
4255 | _outTableLikeClause(str, obj); |
4256 | break; |
4257 | case T_LockingClause: |
4258 | _outLockingClause(str, obj); |
4259 | break; |
4260 | case T_XmlSerialize: |
4261 | _outXmlSerialize(str, obj); |
4262 | break; |
4263 | case T_ForeignKeyCacheInfo: |
4264 | _outForeignKeyCacheInfo(str, obj); |
4265 | break; |
4266 | case T_TriggerTransition: |
4267 | _outTriggerTransition(str, obj); |
4268 | break; |
4269 | case T_PartitionElem: |
4270 | _outPartitionElem(str, obj); |
4271 | break; |
4272 | case T_PartitionSpec: |
4273 | _outPartitionSpec(str, obj); |
4274 | break; |
4275 | case T_PartitionBoundSpec: |
4276 | _outPartitionBoundSpec(str, obj); |
4277 | break; |
4278 | case T_PartitionRangeDatum: |
4279 | _outPartitionRangeDatum(str, obj); |
4280 | break; |
4281 | |
4282 | default: |
4283 | |
4284 | /* |
4285 | * This should be an ERROR, but it's too useful to be able to |
4286 | * dump structures that outNode only understands part of. |
4287 | */ |
4288 | elog(WARNING, "could not dump unrecognized node type: %d" , |
4289 | (int) nodeTag(obj)); |
4290 | break; |
4291 | } |
4292 | appendStringInfoChar(str, '}'); |
4293 | } |
4294 | } |
4295 | |
4296 | /* |
4297 | * nodeToString - |
4298 | * returns the ascii representation of the Node as a palloc'd string |
4299 | */ |
4300 | char * |
4301 | nodeToString(const void *obj) |
4302 | { |
4303 | StringInfoData str; |
4304 | |
4305 | /* see stringinfo.h for an explanation of this maneuver */ |
4306 | initStringInfo(&str); |
4307 | outNode(&str, obj); |
4308 | return str.data; |
4309 | } |
4310 | |
4311 | /* |
4312 | * bmsToString - |
4313 | * returns the ascii representation of the Bitmapset as a palloc'd string |
4314 | */ |
4315 | char * |
4316 | bmsToString(const Bitmapset *bms) |
4317 | { |
4318 | StringInfoData str; |
4319 | |
4320 | /* see stringinfo.h for an explanation of this maneuver */ |
4321 | initStringInfo(&str); |
4322 | outBitmapset(&str, bms); |
4323 | return str.data; |
4324 | } |
4325 | |