1 /*-------------------------------------------------------------------------
4 * Output functions for Postgres tree nodes.
6 * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/nodes/outfuncs.c
14 * Every node type that can appear in stored rules' parsetrees *must*
15 * have an output function defined here (as well as an input function
16 * in readfuncs.c). In addition, plan nodes should have input and
17 * output functions so that they can be sent to parallel workers.
18 * For use in debugging, we also provide output functions for nodes
19 * that appear in raw parsetrees and path. These nodes however need
20 * not have input functions.
22 *-------------------------------------------------------------------------
28 #include "lib/stringinfo.h"
29 #include "nodes/extensible.h"
30 #include "nodes/plannodes.h"
31 #include "nodes/relation.h"
32 #include "utils/datum.h"
36 * Macros to simplify output of different kinds of fields. Use these
37 * wherever possible to reduce the chance for silly typos. Note that these
38 * hard-wire conventions about the names of the local variables in an Out
42 /* Write the label for the node type */
43 #define WRITE_NODE_TYPE(nodelabel) \
44 appendStringInfoString(str, nodelabel)
46 /* Write an integer field (anything written as ":fldname %d") */
47 #define WRITE_INT_FIELD(fldname) \
48 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
50 /* Write an unsigned integer field (anything written as ":fldname %u") */
51 #define WRITE_UINT_FIELD(fldname) \
52 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
54 /* Write an OID field (don't hard-wire assumption that OID is same as uint) */
55 #define WRITE_OID_FIELD(fldname) \
56 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
58 /* Write a long-integer field */
59 #define WRITE_LONG_FIELD(fldname) \
60 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
62 /* Write a char field (ie, one ascii character) */
63 #define WRITE_CHAR_FIELD(fldname) \
64 appendStringInfo(str, " :" CppAsString(fldname) " %c", node->fldname)
66 /* Write an enumerated-type field as an integer code */
67 #define WRITE_ENUM_FIELD(fldname, enumtype) \
68 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
71 /* Write a float field --- caller must give format to define precision */
72 #define WRITE_FLOAT_FIELD(fldname,format) \
73 appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
75 /* Write a boolean field */
76 #define WRITE_BOOL_FIELD(fldname) \
77 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
78 booltostr(node->fldname))
80 /* Write a character-string (possibly NULL) field */
81 #define WRITE_STRING_FIELD(fldname) \
82 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
83 _outToken(str, node->fldname))
85 /* Write a parse location field (actually same as INT case) */
86 #define WRITE_LOCATION_FIELD(fldname) \
87 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
89 /* Write a Node field */
90 #define WRITE_NODE_FIELD(fldname) \
91 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
92 _outNode(str, node->fldname))
94 /* Write a bitmapset field */
95 #define WRITE_BITMAPSET_FIELD(fldname) \
96 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
97 _outBitmapset(str, node->fldname))
100 #define booltostr(x) ((x) ? "true" : "false")
102 static void _outNode(StringInfo str, const void *obj);
107 * Convert an ordinary string (eg, an identifier) into a form that
108 * will be decoded back to a plain token by read.c's functions.
110 * If a null or empty string is given, it is encoded as "<>".
113 _outToken(StringInfo str, const char *s)
115 if (s == NULL || *s == '\0')
117 appendStringInfoString(str, "<>");
122 * Look for characters or patterns that are treated specially by read.c
123 * (either in pg_strtok() or in nodeRead()), and therefore need a
124 * protective backslash.
126 /* These characters only need to be quoted at the start of the string */
129 isdigit((unsigned char) *s) ||
130 ((*s == '+' || *s == '-') &&
131 (isdigit((unsigned char) s[1]) || s[1] == '.')))
132 appendStringInfoChar(str, '\\');
135 /* These chars must be backslashed anywhere in the string */
136 if (*s == ' ' || *s == '\n' || *s == '\t' ||
137 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
139 appendStringInfoChar(str, '\\');
140 appendStringInfoChar(str, *s++);
144 /* for use by extensions which define extensible nodes */
146 outToken(StringInfo str, const char *s)
152 _outList(StringInfo str, const List *node)
156 appendStringInfoChar(str, '(');
158 if (IsA(node, IntList))
159 appendStringInfoChar(str, 'i');
160 else if (IsA(node, OidList))
161 appendStringInfoChar(str, 'o');
166 * For the sake of backward compatibility, we emit a slightly
167 * different whitespace format for lists of nodes vs. other types of
168 * lists. XXX: is this necessary?
172 _outNode(str, lfirst(lc));
174 appendStringInfoChar(str, ' ');
176 else if (IsA(node, IntList))
177 appendStringInfo(str, " %d", lfirst_int(lc));
178 else if (IsA(node, OidList))
179 appendStringInfo(str, " %u", lfirst_oid(lc));
181 elog(ERROR, "unrecognized list node type: %d",
185 appendStringInfoChar(str, ')');
190 * converts a bitmap set of integers
192 * Note: the output format is "(b int int ...)", similar to an integer List.
195 _outBitmapset(StringInfo str, const Bitmapset *bms)
199 appendStringInfoChar(str, '(');
200 appendStringInfoChar(str, 'b');
202 while ((x = bms_next_member(bms, x)) >= 0)
203 appendStringInfo(str, " %d", x);
204 appendStringInfoChar(str, ')');
207 /* for use by extensions which define extensible nodes */
209 outBitmapset(StringInfo str, const Bitmapset *bms)
211 _outBitmapset(str, bms);
215 * Print the value of a Datum given its type.
218 _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
224 length = datumGetSize(value, typbyval, typlen);
228 s = (char *) (&value);
229 appendStringInfo(str, "%u [ ", (unsigned int) length);
230 for (i = 0; i < (Size) sizeof(Datum); i++)
231 appendStringInfo(str, "%d ", (int) (s[i]));
232 appendStringInfoChar(str, ']');
236 s = (char *) DatumGetPointer(value);
237 if (!PointerIsValid(s))
238 appendStringInfoString(str, "0 [ ]");
241 appendStringInfo(str, "%u [ ", (unsigned int) length);
242 for (i = 0; i < length; i++)
243 appendStringInfo(str, "%d ", (int) (s[i]));
244 appendStringInfoChar(str, ']');
251 * Stuff from plannodes.h
255 _outPlannedStmt(StringInfo str, const PlannedStmt *node)
257 WRITE_NODE_TYPE("PLANNEDSTMT");
259 WRITE_ENUM_FIELD(commandType, CmdType);
260 WRITE_UINT_FIELD(queryId);
261 WRITE_BOOL_FIELD(hasReturning);
262 WRITE_BOOL_FIELD(hasModifyingCTE);
263 WRITE_BOOL_FIELD(canSetTag);
264 WRITE_BOOL_FIELD(transientPlan);
265 WRITE_NODE_FIELD(planTree);
266 WRITE_NODE_FIELD(rtable);
267 WRITE_NODE_FIELD(resultRelations);
268 WRITE_NODE_FIELD(utilityStmt);
269 WRITE_NODE_FIELD(subplans);
270 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
271 WRITE_NODE_FIELD(rowMarks);
272 WRITE_NODE_FIELD(relationOids);
273 WRITE_NODE_FIELD(invalItems);
274 WRITE_INT_FIELD(nParamExec);
275 WRITE_BOOL_FIELD(hasRowSecurity);
276 WRITE_BOOL_FIELD(parallelModeNeeded);
277 WRITE_BOOL_FIELD(hasForeignJoin);
281 * print the basic stuff of all nodes that inherit from Plan
284 _outPlanInfo(StringInfo str, const Plan *node)
286 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
287 WRITE_FLOAT_FIELD(total_cost, "%.2f");
288 WRITE_FLOAT_FIELD(plan_rows, "%.0f");
289 WRITE_INT_FIELD(plan_width);
290 WRITE_BOOL_FIELD(parallel_aware);
291 WRITE_INT_FIELD(plan_node_id);
292 WRITE_NODE_FIELD(targetlist);
293 WRITE_NODE_FIELD(qual);
294 WRITE_NODE_FIELD(lefttree);
295 WRITE_NODE_FIELD(righttree);
296 WRITE_NODE_FIELD(initPlan);
297 WRITE_BITMAPSET_FIELD(extParam);
298 WRITE_BITMAPSET_FIELD(allParam);
302 * print the basic stuff of all nodes that inherit from Scan
305 _outScanInfo(StringInfo str, const Scan *node)
307 _outPlanInfo(str, (const Plan *) node);
309 WRITE_UINT_FIELD(scanrelid);
313 * print the basic stuff of all nodes that inherit from Join
316 _outJoinPlanInfo(StringInfo str, const Join *node)
318 _outPlanInfo(str, (const Plan *) node);
320 WRITE_ENUM_FIELD(jointype, JoinType);
321 WRITE_NODE_FIELD(joinqual);
326 _outPlan(StringInfo str, const Plan *node)
328 WRITE_NODE_TYPE("PLAN");
330 _outPlanInfo(str, (const Plan *) node);
334 _outResult(StringInfo str, const Result *node)
336 WRITE_NODE_TYPE("RESULT");
338 _outPlanInfo(str, (const Plan *) node);
340 WRITE_NODE_FIELD(resconstantqual);
344 _outModifyTable(StringInfo str, const ModifyTable *node)
346 WRITE_NODE_TYPE("MODIFYTABLE");
348 _outPlanInfo(str, (const Plan *) node);
350 WRITE_ENUM_FIELD(operation, CmdType);
351 WRITE_BOOL_FIELD(canSetTag);
352 WRITE_UINT_FIELD(nominalRelation);
353 WRITE_NODE_FIELD(resultRelations);
354 WRITE_INT_FIELD(resultRelIndex);
355 WRITE_NODE_FIELD(plans);
356 WRITE_NODE_FIELD(withCheckOptionLists);
357 WRITE_NODE_FIELD(returningLists);
358 WRITE_NODE_FIELD(fdwPrivLists);
359 WRITE_BITMAPSET_FIELD(fdwDirectModifyPlans);
360 WRITE_NODE_FIELD(rowMarks);
361 WRITE_INT_FIELD(epqParam);
362 WRITE_ENUM_FIELD(onConflictAction, OnConflictAction);
363 WRITE_NODE_FIELD(arbiterIndexes);
364 WRITE_NODE_FIELD(onConflictSet);
365 WRITE_NODE_FIELD(onConflictWhere);
366 WRITE_UINT_FIELD(exclRelRTI);
367 WRITE_NODE_FIELD(exclRelTlist);
371 _outAppend(StringInfo str, const Append *node)
373 WRITE_NODE_TYPE("APPEND");
375 _outPlanInfo(str, (const Plan *) node);
377 WRITE_NODE_FIELD(appendplans);
381 _outMergeAppend(StringInfo str, const MergeAppend *node)
385 WRITE_NODE_TYPE("MERGEAPPEND");
387 _outPlanInfo(str, (const Plan *) node);
389 WRITE_NODE_FIELD(mergeplans);
391 WRITE_INT_FIELD(numCols);
393 appendStringInfoString(str, " :sortColIdx");
394 for (i = 0; i < node->numCols; i++)
395 appendStringInfo(str, " %d", node->sortColIdx[i]);
397 appendStringInfoString(str, " :sortOperators");
398 for (i = 0; i < node->numCols; i++)
399 appendStringInfo(str, " %u", node->sortOperators[i]);
401 appendStringInfoString(str, " :collations");
402 for (i = 0; i < node->numCols; i++)
403 appendStringInfo(str, " %u", node->collations[i]);
405 appendStringInfoString(str, " :nullsFirst");
406 for (i = 0; i < node->numCols; i++)
407 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
411 _outRecursiveUnion(StringInfo str, const RecursiveUnion *node)
415 WRITE_NODE_TYPE("RECURSIVEUNION");
417 _outPlanInfo(str, (const Plan *) node);
419 WRITE_INT_FIELD(wtParam);
420 WRITE_INT_FIELD(numCols);
422 appendStringInfoString(str, " :dupColIdx");
423 for (i = 0; i < node->numCols; i++)
424 appendStringInfo(str, " %d", node->dupColIdx[i]);
426 appendStringInfoString(str, " :dupOperators");
427 for (i = 0; i < node->numCols; i++)
428 appendStringInfo(str, " %u", node->dupOperators[i]);
430 WRITE_LONG_FIELD(numGroups);
434 _outBitmapAnd(StringInfo str, const BitmapAnd *node)
436 WRITE_NODE_TYPE("BITMAPAND");
438 _outPlanInfo(str, (const Plan *) node);
440 WRITE_NODE_FIELD(bitmapplans);
444 _outBitmapOr(StringInfo str, const BitmapOr *node)
446 WRITE_NODE_TYPE("BITMAPOR");
448 _outPlanInfo(str, (const Plan *) node);
450 WRITE_NODE_FIELD(bitmapplans);
454 _outGather(StringInfo str, const Gather *node)
456 WRITE_NODE_TYPE("GATHER");
458 _outPlanInfo(str, (const Plan *) node);
460 WRITE_INT_FIELD(num_workers);
461 WRITE_BOOL_FIELD(single_copy);
462 WRITE_BOOL_FIELD(invisible);
466 _outScan(StringInfo str, const Scan *node)
468 WRITE_NODE_TYPE("SCAN");
470 _outScanInfo(str, node);
474 _outSeqScan(StringInfo str, const SeqScan *node)
476 WRITE_NODE_TYPE("SEQSCAN");
478 _outScanInfo(str, (const Scan *) node);
482 _outSampleScan(StringInfo str, const SampleScan *node)
484 WRITE_NODE_TYPE("SAMPLESCAN");
486 _outScanInfo(str, (const Scan *) node);
488 WRITE_NODE_FIELD(tablesample);
492 _outIndexScan(StringInfo str, const IndexScan *node)
494 WRITE_NODE_TYPE("INDEXSCAN");
496 _outScanInfo(str, (const Scan *) node);
498 WRITE_OID_FIELD(indexid);
499 WRITE_NODE_FIELD(indexqual);
500 WRITE_NODE_FIELD(indexqualorig);
501 WRITE_NODE_FIELD(indexorderby);
502 WRITE_NODE_FIELD(indexorderbyorig);
503 WRITE_NODE_FIELD(indexorderbyops);
504 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
508 _outIndexOnlyScan(StringInfo str, const IndexOnlyScan *node)
510 WRITE_NODE_TYPE("INDEXONLYSCAN");
512 _outScanInfo(str, (const Scan *) node);
514 WRITE_OID_FIELD(indexid);
515 WRITE_NODE_FIELD(indexqual);
516 WRITE_NODE_FIELD(indexorderby);
517 WRITE_NODE_FIELD(indextlist);
518 WRITE_ENUM_FIELD(indexorderdir, ScanDirection);
522 _outBitmapIndexScan(StringInfo str, const BitmapIndexScan *node)
524 WRITE_NODE_TYPE("BITMAPINDEXSCAN");
526 _outScanInfo(str, (const Scan *) node);
528 WRITE_OID_FIELD(indexid);
529 WRITE_NODE_FIELD(indexqual);
530 WRITE_NODE_FIELD(indexqualorig);
534 _outBitmapHeapScan(StringInfo str, const BitmapHeapScan *node)
536 WRITE_NODE_TYPE("BITMAPHEAPSCAN");
538 _outScanInfo(str, (const Scan *) node);
540 WRITE_NODE_FIELD(bitmapqualorig);
544 _outTidScan(StringInfo str, const TidScan *node)
546 WRITE_NODE_TYPE("TIDSCAN");
548 _outScanInfo(str, (const Scan *) node);
550 WRITE_NODE_FIELD(tidquals);
554 _outSubqueryScan(StringInfo str, const SubqueryScan *node)
556 WRITE_NODE_TYPE("SUBQUERYSCAN");
558 _outScanInfo(str, (const Scan *) node);
560 WRITE_NODE_FIELD(subplan);
564 _outFunctionScan(StringInfo str, const FunctionScan *node)
566 WRITE_NODE_TYPE("FUNCTIONSCAN");
568 _outScanInfo(str, (const Scan *) node);
570 WRITE_NODE_FIELD(functions);
571 WRITE_BOOL_FIELD(funcordinality);
575 _outValuesScan(StringInfo str, const ValuesScan *node)
577 WRITE_NODE_TYPE("VALUESSCAN");
579 _outScanInfo(str, (const Scan *) node);
581 WRITE_NODE_FIELD(values_lists);
585 _outCteScan(StringInfo str, const CteScan *node)
587 WRITE_NODE_TYPE("CTESCAN");
589 _outScanInfo(str, (const Scan *) node);
591 WRITE_INT_FIELD(ctePlanId);
592 WRITE_INT_FIELD(cteParam);
596 _outWorkTableScan(StringInfo str, const WorkTableScan *node)
598 WRITE_NODE_TYPE("WORKTABLESCAN");
600 _outScanInfo(str, (const Scan *) node);
602 WRITE_INT_FIELD(wtParam);
606 _outForeignScan(StringInfo str, const ForeignScan *node)
608 WRITE_NODE_TYPE("FOREIGNSCAN");
610 _outScanInfo(str, (const Scan *) node);
612 WRITE_ENUM_FIELD(operation, CmdType);
613 WRITE_OID_FIELD(fs_server);
614 WRITE_NODE_FIELD(fdw_exprs);
615 WRITE_NODE_FIELD(fdw_private);
616 WRITE_NODE_FIELD(fdw_scan_tlist);
617 WRITE_NODE_FIELD(fdw_recheck_quals);
618 WRITE_BITMAPSET_FIELD(fs_relids);
619 WRITE_BOOL_FIELD(fsSystemCol);
623 _outCustomScan(StringInfo str, const CustomScan *node)
625 WRITE_NODE_TYPE("CUSTOMSCAN");
627 _outScanInfo(str, (const Scan *) node);
629 WRITE_UINT_FIELD(flags);
630 WRITE_NODE_FIELD(custom_plans);
631 WRITE_NODE_FIELD(custom_exprs);
632 WRITE_NODE_FIELD(custom_private);
633 WRITE_NODE_FIELD(custom_scan_tlist);
634 WRITE_BITMAPSET_FIELD(custom_relids);
635 /* CustomName is a key to lookup CustomScanMethods */
636 appendStringInfoString(str, " :methods ");
637 _outToken(str, node->methods->CustomName);
641 _outJoin(StringInfo str, const Join *node)
643 WRITE_NODE_TYPE("JOIN");
645 _outJoinPlanInfo(str, (const Join *) node);
649 _outNestLoop(StringInfo str, const NestLoop *node)
651 WRITE_NODE_TYPE("NESTLOOP");
653 _outJoinPlanInfo(str, (const Join *) node);
655 WRITE_NODE_FIELD(nestParams);
659 _outMergeJoin(StringInfo str, const MergeJoin *node)
664 WRITE_NODE_TYPE("MERGEJOIN");
666 _outJoinPlanInfo(str, (const Join *) node);
668 WRITE_NODE_FIELD(mergeclauses);
670 numCols = list_length(node->mergeclauses);
672 appendStringInfoString(str, " :mergeFamilies");
673 for (i = 0; i < numCols; i++)
674 appendStringInfo(str, " %u", node->mergeFamilies[i]);
676 appendStringInfoString(str, " :mergeCollations");
677 for (i = 0; i < numCols; i++)
678 appendStringInfo(str, " %u", node->mergeCollations[i]);
680 appendStringInfoString(str, " :mergeStrategies");
681 for (i = 0; i < numCols; i++)
682 appendStringInfo(str, " %d", node->mergeStrategies[i]);
684 appendStringInfoString(str, " :mergeNullsFirst");
685 for (i = 0; i < numCols; i++)
686 appendStringInfo(str, " %s", booltostr(node->mergeNullsFirst[i]));
690 _outHashJoin(StringInfo str, const HashJoin *node)
692 WRITE_NODE_TYPE("HASHJOIN");
694 _outJoinPlanInfo(str, (const Join *) node);
696 WRITE_NODE_FIELD(hashclauses);
700 _outAgg(StringInfo str, const Agg *node)
704 WRITE_NODE_TYPE("AGG");
706 _outPlanInfo(str, (const Plan *) node);
708 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
709 WRITE_BOOL_FIELD(combineStates);
710 WRITE_BOOL_FIELD(finalizeAggs);
711 WRITE_BOOL_FIELD(serialStates);
712 WRITE_INT_FIELD(numCols);
714 appendStringInfoString(str, " :grpColIdx");
715 for (i = 0; i < node->numCols; i++)
716 appendStringInfo(str, " %d", node->grpColIdx[i]);
718 appendStringInfoString(str, " :grpOperators");
719 for (i = 0; i < node->numCols; i++)
720 appendStringInfo(str, " %u", node->grpOperators[i]);
722 WRITE_LONG_FIELD(numGroups);
723 WRITE_NODE_FIELD(groupingSets);
724 WRITE_NODE_FIELD(chain);
728 _outWindowAgg(StringInfo str, const WindowAgg *node)
732 WRITE_NODE_TYPE("WINDOWAGG");
734 _outPlanInfo(str, (const Plan *) node);
736 WRITE_UINT_FIELD(winref);
737 WRITE_INT_FIELD(partNumCols);
739 appendStringInfoString(str, " :partColIdx");
740 for (i = 0; i < node->partNumCols; i++)
741 appendStringInfo(str, " %d", node->partColIdx[i]);
743 appendStringInfoString(str, " :partOperations");
744 for (i = 0; i < node->partNumCols; i++)
745 appendStringInfo(str, " %u", node->partOperators[i]);
747 WRITE_INT_FIELD(ordNumCols);
749 appendStringInfoString(str, " :ordColIdx");
750 for (i = 0; i < node->ordNumCols; i++)
751 appendStringInfo(str, " %d", node->ordColIdx[i]);
753 appendStringInfoString(str, " :ordOperations");
754 for (i = 0; i < node->ordNumCols; i++)
755 appendStringInfo(str, " %u", node->ordOperators[i]);
757 WRITE_INT_FIELD(frameOptions);
758 WRITE_NODE_FIELD(startOffset);
759 WRITE_NODE_FIELD(endOffset);
763 _outGroup(StringInfo str, const Group *node)
767 WRITE_NODE_TYPE("GROUP");
769 _outPlanInfo(str, (const Plan *) node);
771 WRITE_INT_FIELD(numCols);
773 appendStringInfoString(str, " :grpColIdx");
774 for (i = 0; i < node->numCols; i++)
775 appendStringInfo(str, " %d", node->grpColIdx[i]);
777 appendStringInfoString(str, " :grpOperators");
778 for (i = 0; i < node->numCols; i++)
779 appendStringInfo(str, " %u", node->grpOperators[i]);
783 _outMaterial(StringInfo str, const Material *node)
785 WRITE_NODE_TYPE("MATERIAL");
787 _outPlanInfo(str, (const Plan *) node);
791 _outSort(StringInfo str, const Sort *node)
795 WRITE_NODE_TYPE("SORT");
797 _outPlanInfo(str, (const Plan *) node);
799 WRITE_INT_FIELD(numCols);
801 appendStringInfoString(str, " :sortColIdx");
802 for (i = 0; i < node->numCols; i++)
803 appendStringInfo(str, " %d", node->sortColIdx[i]);
805 appendStringInfoString(str, " :sortOperators");
806 for (i = 0; i < node->numCols; i++)
807 appendStringInfo(str, " %u", node->sortOperators[i]);
809 appendStringInfoString(str, " :collations");
810 for (i = 0; i < node->numCols; i++)
811 appendStringInfo(str, " %u", node->collations[i]);
813 appendStringInfoString(str, " :nullsFirst");
814 for (i = 0; i < node->numCols; i++)
815 appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
819 _outUnique(StringInfo str, const Unique *node)
823 WRITE_NODE_TYPE("UNIQUE");
825 _outPlanInfo(str, (const Plan *) node);
827 WRITE_INT_FIELD(numCols);
829 appendStringInfoString(str, " :uniqColIdx");
830 for (i = 0; i < node->numCols; i++)
831 appendStringInfo(str, " %d", node->uniqColIdx[i]);
833 appendStringInfoString(str, " :uniqOperators");
834 for (i = 0; i < node->numCols; i++)
835 appendStringInfo(str, " %u", node->uniqOperators[i]);
839 _outHash(StringInfo str, const Hash *node)
841 WRITE_NODE_TYPE("HASH");
843 _outPlanInfo(str, (const Plan *) node);
845 WRITE_OID_FIELD(skewTable);
846 WRITE_INT_FIELD(skewColumn);
847 WRITE_BOOL_FIELD(skewInherit);
848 WRITE_OID_FIELD(skewColType);
849 WRITE_INT_FIELD(skewColTypmod);
853 _outSetOp(StringInfo str, const SetOp *node)
857 WRITE_NODE_TYPE("SETOP");
859 _outPlanInfo(str, (const Plan *) node);
861 WRITE_ENUM_FIELD(cmd, SetOpCmd);
862 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
863 WRITE_INT_FIELD(numCols);
865 appendStringInfoString(str, " :dupColIdx");
866 for (i = 0; i < node->numCols; i++)
867 appendStringInfo(str, " %d", node->dupColIdx[i]);
869 appendStringInfoString(str, " :dupOperators");
870 for (i = 0; i < node->numCols; i++)
871 appendStringInfo(str, " %u", node->dupOperators[i]);
873 WRITE_INT_FIELD(flagColIdx);
874 WRITE_INT_FIELD(firstFlag);
875 WRITE_LONG_FIELD(numGroups);
879 _outLockRows(StringInfo str, const LockRows *node)
881 WRITE_NODE_TYPE("LOCKROWS");
883 _outPlanInfo(str, (const Plan *) node);
885 WRITE_NODE_FIELD(rowMarks);
886 WRITE_INT_FIELD(epqParam);
890 _outLimit(StringInfo str, const Limit *node)
892 WRITE_NODE_TYPE("LIMIT");
894 _outPlanInfo(str, (const Plan *) node);
896 WRITE_NODE_FIELD(limitOffset);
897 WRITE_NODE_FIELD(limitCount);
901 _outNestLoopParam(StringInfo str, const NestLoopParam *node)
903 WRITE_NODE_TYPE("NESTLOOPPARAM");
905 WRITE_INT_FIELD(paramno);
906 WRITE_NODE_FIELD(paramval);
910 _outPlanRowMark(StringInfo str, const PlanRowMark *node)
912 WRITE_NODE_TYPE("PLANROWMARK");
914 WRITE_UINT_FIELD(rti);
915 WRITE_UINT_FIELD(prti);
916 WRITE_UINT_FIELD(rowmarkId);
917 WRITE_ENUM_FIELD(markType, RowMarkType);
918 WRITE_INT_FIELD(allMarkTypes);
919 WRITE_ENUM_FIELD(strength, LockClauseStrength);
920 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
921 WRITE_BOOL_FIELD(isParent);
925 _outPlanInvalItem(StringInfo str, const PlanInvalItem *node)
927 WRITE_NODE_TYPE("PLANINVALITEM");
929 WRITE_INT_FIELD(cacheId);
930 WRITE_UINT_FIELD(hashValue);
933 /*****************************************************************************
935 * Stuff from primnodes.h.
937 *****************************************************************************/
940 _outAlias(StringInfo str, const Alias *node)
942 WRITE_NODE_TYPE("ALIAS");
944 WRITE_STRING_FIELD(aliasname);
945 WRITE_NODE_FIELD(colnames);
949 _outRangeVar(StringInfo str, const RangeVar *node)
951 WRITE_NODE_TYPE("RANGEVAR");
954 * we deliberately ignore catalogname here, since it is presently not
955 * semantically meaningful
957 WRITE_STRING_FIELD(schemaname);
958 WRITE_STRING_FIELD(relname);
959 WRITE_ENUM_FIELD(inhOpt, InhOption);
960 WRITE_CHAR_FIELD(relpersistence);
961 WRITE_NODE_FIELD(alias);
962 WRITE_LOCATION_FIELD(location);
966 _outIntoClause(StringInfo str, const IntoClause *node)
968 WRITE_NODE_TYPE("INTOCLAUSE");
970 WRITE_NODE_FIELD(rel);
971 WRITE_NODE_FIELD(colNames);
972 WRITE_NODE_FIELD(options);
973 WRITE_ENUM_FIELD(onCommit, OnCommitAction);
974 WRITE_STRING_FIELD(tableSpaceName);
975 WRITE_NODE_FIELD(viewQuery);
976 WRITE_BOOL_FIELD(skipData);
980 _outVar(StringInfo str, const Var *node)
982 WRITE_NODE_TYPE("VAR");
984 WRITE_UINT_FIELD(varno);
985 WRITE_INT_FIELD(varattno);
986 WRITE_OID_FIELD(vartype);
987 WRITE_INT_FIELD(vartypmod);
988 WRITE_OID_FIELD(varcollid);
989 WRITE_UINT_FIELD(varlevelsup);
990 WRITE_UINT_FIELD(varnoold);
991 WRITE_INT_FIELD(varoattno);
992 WRITE_LOCATION_FIELD(location);
996 _outConst(StringInfo str, const Const *node)
998 WRITE_NODE_TYPE("CONST");
1000 WRITE_OID_FIELD(consttype);
1001 WRITE_INT_FIELD(consttypmod);
1002 WRITE_OID_FIELD(constcollid);
1003 WRITE_INT_FIELD(constlen);
1004 WRITE_BOOL_FIELD(constbyval);
1005 WRITE_BOOL_FIELD(constisnull);
1006 WRITE_LOCATION_FIELD(location);
1008 appendStringInfoString(str, " :constvalue ");
1009 if (node->constisnull)
1010 appendStringInfoString(str, "<>");
1012 _outDatum(str, node->constvalue, node->constlen, node->constbyval);
1016 _outParam(StringInfo str, const Param *node)
1018 WRITE_NODE_TYPE("PARAM");
1020 WRITE_ENUM_FIELD(paramkind, ParamKind);
1021 WRITE_INT_FIELD(paramid);
1022 WRITE_OID_FIELD(paramtype);
1023 WRITE_INT_FIELD(paramtypmod);
1024 WRITE_OID_FIELD(paramcollid);
1025 WRITE_LOCATION_FIELD(location);
1029 _outAggref(StringInfo str, const Aggref *node)
1031 WRITE_NODE_TYPE("AGGREF");
1033 WRITE_OID_FIELD(aggfnoid);
1034 WRITE_OID_FIELD(aggtype);
1035 WRITE_OID_FIELD(aggoutputtype);
1036 WRITE_OID_FIELD(aggcollid);
1037 WRITE_OID_FIELD(inputcollid);
1038 WRITE_NODE_FIELD(aggdirectargs);
1039 WRITE_NODE_FIELD(args);
1040 WRITE_NODE_FIELD(aggorder);
1041 WRITE_NODE_FIELD(aggdistinct);
1042 WRITE_NODE_FIELD(aggfilter);
1043 WRITE_BOOL_FIELD(aggstar);
1044 WRITE_BOOL_FIELD(aggvariadic);
1045 WRITE_CHAR_FIELD(aggkind);
1046 WRITE_UINT_FIELD(agglevelsup);
1047 WRITE_LOCATION_FIELD(location);
1051 _outGroupingFunc(StringInfo str, const GroupingFunc *node)
1053 WRITE_NODE_TYPE("GROUPINGFUNC");
1055 WRITE_NODE_FIELD(args);
1056 WRITE_NODE_FIELD(refs);
1057 WRITE_NODE_FIELD(cols);
1058 WRITE_UINT_FIELD(agglevelsup);
1059 WRITE_LOCATION_FIELD(location);
1063 _outWindowFunc(StringInfo str, const WindowFunc *node)
1065 WRITE_NODE_TYPE("WINDOWFUNC");
1067 WRITE_OID_FIELD(winfnoid);
1068 WRITE_OID_FIELD(wintype);
1069 WRITE_OID_FIELD(wincollid);
1070 WRITE_OID_FIELD(inputcollid);
1071 WRITE_NODE_FIELD(args);
1072 WRITE_NODE_FIELD(aggfilter);
1073 WRITE_UINT_FIELD(winref);
1074 WRITE_BOOL_FIELD(winstar);
1075 WRITE_BOOL_FIELD(winagg);
1076 WRITE_LOCATION_FIELD(location);
1080 _outArrayRef(StringInfo str, const ArrayRef *node)
1082 WRITE_NODE_TYPE("ARRAYREF");
1084 WRITE_OID_FIELD(refarraytype);
1085 WRITE_OID_FIELD(refelemtype);
1086 WRITE_INT_FIELD(reftypmod);
1087 WRITE_OID_FIELD(refcollid);
1088 WRITE_NODE_FIELD(refupperindexpr);
1089 WRITE_NODE_FIELD(reflowerindexpr);
1090 WRITE_NODE_FIELD(refexpr);
1091 WRITE_NODE_FIELD(refassgnexpr);
1095 _outFuncExpr(StringInfo str, const FuncExpr *node)
1097 WRITE_NODE_TYPE("FUNCEXPR");
1099 WRITE_OID_FIELD(funcid);
1100 WRITE_OID_FIELD(funcresulttype);
1101 WRITE_BOOL_FIELD(funcretset);
1102 WRITE_BOOL_FIELD(funcvariadic);
1103 WRITE_ENUM_FIELD(funcformat, CoercionForm);
1104 WRITE_OID_FIELD(funccollid);
1105 WRITE_OID_FIELD(inputcollid);
1106 WRITE_NODE_FIELD(args);
1107 WRITE_LOCATION_FIELD(location);
1111 _outNamedArgExpr(StringInfo str, const NamedArgExpr *node)
1113 WRITE_NODE_TYPE("NAMEDARGEXPR");
1115 WRITE_NODE_FIELD(arg);
1116 WRITE_STRING_FIELD(name);
1117 WRITE_INT_FIELD(argnumber);
1118 WRITE_LOCATION_FIELD(location);
1122 _outOpExpr(StringInfo str, const OpExpr *node)
1124 WRITE_NODE_TYPE("OPEXPR");
1126 WRITE_OID_FIELD(opno);
1127 WRITE_OID_FIELD(opfuncid);
1128 WRITE_OID_FIELD(opresulttype);
1129 WRITE_BOOL_FIELD(opretset);
1130 WRITE_OID_FIELD(opcollid);
1131 WRITE_OID_FIELD(inputcollid);
1132 WRITE_NODE_FIELD(args);
1133 WRITE_LOCATION_FIELD(location);
1137 _outDistinctExpr(StringInfo str, const DistinctExpr *node)
1139 WRITE_NODE_TYPE("DISTINCTEXPR");
1141 WRITE_OID_FIELD(opno);
1142 WRITE_OID_FIELD(opfuncid);
1143 WRITE_OID_FIELD(opresulttype);
1144 WRITE_BOOL_FIELD(opretset);
1145 WRITE_OID_FIELD(opcollid);
1146 WRITE_OID_FIELD(inputcollid);
1147 WRITE_NODE_FIELD(args);
1148 WRITE_LOCATION_FIELD(location);
1152 _outNullIfExpr(StringInfo str, const NullIfExpr *node)
1154 WRITE_NODE_TYPE("NULLIFEXPR");
1156 WRITE_OID_FIELD(opno);
1157 WRITE_OID_FIELD(opfuncid);
1158 WRITE_OID_FIELD(opresulttype);
1159 WRITE_BOOL_FIELD(opretset);
1160 WRITE_OID_FIELD(opcollid);
1161 WRITE_OID_FIELD(inputcollid);
1162 WRITE_NODE_FIELD(args);
1163 WRITE_LOCATION_FIELD(location);
1167 _outScalarArrayOpExpr(StringInfo str, const ScalarArrayOpExpr *node)
1169 WRITE_NODE_TYPE("SCALARARRAYOPEXPR");
1171 WRITE_OID_FIELD(opno);
1172 WRITE_OID_FIELD(opfuncid);
1173 WRITE_BOOL_FIELD(useOr);
1174 WRITE_OID_FIELD(inputcollid);
1175 WRITE_NODE_FIELD(args);
1176 WRITE_LOCATION_FIELD(location);
1180 _outBoolExpr(StringInfo str, const BoolExpr *node)
1184 WRITE_NODE_TYPE("BOOLEXPR");
1186 /* do-it-yourself enum representation */
1187 switch (node->boolop)
1199 appendStringInfoString(str, " :boolop ");
1200 _outToken(str, opstr);
1202 WRITE_NODE_FIELD(args);
1203 WRITE_LOCATION_FIELD(location);
1207 _outSubLink(StringInfo str, const SubLink *node)
1209 WRITE_NODE_TYPE("SUBLINK");
1211 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1212 WRITE_INT_FIELD(subLinkId);
1213 WRITE_NODE_FIELD(testexpr);
1214 WRITE_NODE_FIELD(operName);
1215 WRITE_NODE_FIELD(subselect);
1216 WRITE_LOCATION_FIELD(location);
1220 _outSubPlan(StringInfo str, const SubPlan *node)
1222 WRITE_NODE_TYPE("SUBPLAN");
1224 WRITE_ENUM_FIELD(subLinkType, SubLinkType);
1225 WRITE_NODE_FIELD(testexpr);
1226 WRITE_NODE_FIELD(paramIds);
1227 WRITE_INT_FIELD(plan_id);
1228 WRITE_STRING_FIELD(plan_name);
1229 WRITE_OID_FIELD(firstColType);
1230 WRITE_INT_FIELD(firstColTypmod);
1231 WRITE_OID_FIELD(firstColCollation);
1232 WRITE_BOOL_FIELD(useHashTable);
1233 WRITE_BOOL_FIELD(unknownEqFalse);
1234 WRITE_NODE_FIELD(setParam);
1235 WRITE_NODE_FIELD(parParam);
1236 WRITE_NODE_FIELD(args);
1237 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1238 WRITE_FLOAT_FIELD(per_call_cost, "%.2f");
1242 _outAlternativeSubPlan(StringInfo str, const AlternativeSubPlan *node)
1244 WRITE_NODE_TYPE("ALTERNATIVESUBPLAN");
1246 WRITE_NODE_FIELD(subplans);
1250 _outFieldSelect(StringInfo str, const FieldSelect *node)
1252 WRITE_NODE_TYPE("FIELDSELECT");
1254 WRITE_NODE_FIELD(arg);
1255 WRITE_INT_FIELD(fieldnum);
1256 WRITE_OID_FIELD(resulttype);
1257 WRITE_INT_FIELD(resulttypmod);
1258 WRITE_OID_FIELD(resultcollid);
1262 _outFieldStore(StringInfo str, const FieldStore *node)
1264 WRITE_NODE_TYPE("FIELDSTORE");
1266 WRITE_NODE_FIELD(arg);
1267 WRITE_NODE_FIELD(newvals);
1268 WRITE_NODE_FIELD(fieldnums);
1269 WRITE_OID_FIELD(resulttype);
1273 _outRelabelType(StringInfo str, const RelabelType *node)
1275 WRITE_NODE_TYPE("RELABELTYPE");
1277 WRITE_NODE_FIELD(arg);
1278 WRITE_OID_FIELD(resulttype);
1279 WRITE_INT_FIELD(resulttypmod);
1280 WRITE_OID_FIELD(resultcollid);
1281 WRITE_ENUM_FIELD(relabelformat, CoercionForm);
1282 WRITE_LOCATION_FIELD(location);
1286 _outCoerceViaIO(StringInfo str, const CoerceViaIO *node)
1288 WRITE_NODE_TYPE("COERCEVIAIO");
1290 WRITE_NODE_FIELD(arg);
1291 WRITE_OID_FIELD(resulttype);
1292 WRITE_OID_FIELD(resultcollid);
1293 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1294 WRITE_LOCATION_FIELD(location);
1298 _outArrayCoerceExpr(StringInfo str, const ArrayCoerceExpr *node)
1300 WRITE_NODE_TYPE("ARRAYCOERCEEXPR");
1302 WRITE_NODE_FIELD(arg);
1303 WRITE_OID_FIELD(elemfuncid);
1304 WRITE_OID_FIELD(resulttype);
1305 WRITE_INT_FIELD(resulttypmod);
1306 WRITE_OID_FIELD(resultcollid);
1307 WRITE_BOOL_FIELD(isExplicit);
1308 WRITE_ENUM_FIELD(coerceformat, CoercionForm);
1309 WRITE_LOCATION_FIELD(location);
1313 _outConvertRowtypeExpr(StringInfo str, const ConvertRowtypeExpr *node)
1315 WRITE_NODE_TYPE("CONVERTROWTYPEEXPR");
1317 WRITE_NODE_FIELD(arg);
1318 WRITE_OID_FIELD(resulttype);
1319 WRITE_ENUM_FIELD(convertformat, CoercionForm);
1320 WRITE_LOCATION_FIELD(location);
1324 _outCollateExpr(StringInfo str, const CollateExpr *node)
1326 WRITE_NODE_TYPE("COLLATE");
1328 WRITE_NODE_FIELD(arg);
1329 WRITE_OID_FIELD(collOid);
1330 WRITE_LOCATION_FIELD(location);
1334 _outCaseExpr(StringInfo str, const CaseExpr *node)
1336 WRITE_NODE_TYPE("CASE");
1338 WRITE_OID_FIELD(casetype);
1339 WRITE_OID_FIELD(casecollid);
1340 WRITE_NODE_FIELD(arg);
1341 WRITE_NODE_FIELD(args);
1342 WRITE_NODE_FIELD(defresult);
1343 WRITE_LOCATION_FIELD(location);
1347 _outCaseWhen(StringInfo str, const CaseWhen *node)
1349 WRITE_NODE_TYPE("WHEN");
1351 WRITE_NODE_FIELD(expr);
1352 WRITE_NODE_FIELD(result);
1353 WRITE_LOCATION_FIELD(location);
1357 _outCaseTestExpr(StringInfo str, const CaseTestExpr *node)
1359 WRITE_NODE_TYPE("CASETESTEXPR");
1361 WRITE_OID_FIELD(typeId);
1362 WRITE_INT_FIELD(typeMod);
1363 WRITE_OID_FIELD(collation);
1367 _outArrayExpr(StringInfo str, const ArrayExpr *node)
1369 WRITE_NODE_TYPE("ARRAY");
1371 WRITE_OID_FIELD(array_typeid);
1372 WRITE_OID_FIELD(array_collid);
1373 WRITE_OID_FIELD(element_typeid);
1374 WRITE_NODE_FIELD(elements);
1375 WRITE_BOOL_FIELD(multidims);
1376 WRITE_LOCATION_FIELD(location);
1380 _outRowExpr(StringInfo str, const RowExpr *node)
1382 WRITE_NODE_TYPE("ROW");
1384 WRITE_NODE_FIELD(args);
1385 WRITE_OID_FIELD(row_typeid);
1386 WRITE_ENUM_FIELD(row_format, CoercionForm);
1387 WRITE_NODE_FIELD(colnames);
1388 WRITE_LOCATION_FIELD(location);
1392 _outRowCompareExpr(StringInfo str, const RowCompareExpr *node)
1394 WRITE_NODE_TYPE("ROWCOMPARE");
1396 WRITE_ENUM_FIELD(rctype, RowCompareType);
1397 WRITE_NODE_FIELD(opnos);
1398 WRITE_NODE_FIELD(opfamilies);
1399 WRITE_NODE_FIELD(inputcollids);
1400 WRITE_NODE_FIELD(largs);
1401 WRITE_NODE_FIELD(rargs);
1405 _outCoalesceExpr(StringInfo str, const CoalesceExpr *node)
1407 WRITE_NODE_TYPE("COALESCE");
1409 WRITE_OID_FIELD(coalescetype);
1410 WRITE_OID_FIELD(coalescecollid);
1411 WRITE_NODE_FIELD(args);
1412 WRITE_LOCATION_FIELD(location);
1416 _outMinMaxExpr(StringInfo str, const MinMaxExpr *node)
1418 WRITE_NODE_TYPE("MINMAX");
1420 WRITE_OID_FIELD(minmaxtype);
1421 WRITE_OID_FIELD(minmaxcollid);
1422 WRITE_OID_FIELD(inputcollid);
1423 WRITE_ENUM_FIELD(op, MinMaxOp);
1424 WRITE_NODE_FIELD(args);
1425 WRITE_LOCATION_FIELD(location);
1429 _outXmlExpr(StringInfo str, const XmlExpr *node)
1431 WRITE_NODE_TYPE("XMLEXPR");
1433 WRITE_ENUM_FIELD(op, XmlExprOp);
1434 WRITE_STRING_FIELD(name);
1435 WRITE_NODE_FIELD(named_args);
1436 WRITE_NODE_FIELD(arg_names);
1437 WRITE_NODE_FIELD(args);
1438 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
1439 WRITE_OID_FIELD(type);
1440 WRITE_INT_FIELD(typmod);
1441 WRITE_LOCATION_FIELD(location);
1445 _outNullTest(StringInfo str, const NullTest *node)
1447 WRITE_NODE_TYPE("NULLTEST");
1449 WRITE_NODE_FIELD(arg);
1450 WRITE_ENUM_FIELD(nulltesttype, NullTestType);
1451 WRITE_BOOL_FIELD(argisrow);
1452 WRITE_LOCATION_FIELD(location);
1456 _outBooleanTest(StringInfo str, const BooleanTest *node)
1458 WRITE_NODE_TYPE("BOOLEANTEST");
1460 WRITE_NODE_FIELD(arg);
1461 WRITE_ENUM_FIELD(booltesttype, BoolTestType);
1462 WRITE_LOCATION_FIELD(location);
1466 _outCoerceToDomain(StringInfo str, const CoerceToDomain *node)
1468 WRITE_NODE_TYPE("COERCETODOMAIN");
1470 WRITE_NODE_FIELD(arg);
1471 WRITE_OID_FIELD(resulttype);
1472 WRITE_INT_FIELD(resulttypmod);
1473 WRITE_OID_FIELD(resultcollid);
1474 WRITE_ENUM_FIELD(coercionformat, CoercionForm);
1475 WRITE_LOCATION_FIELD(location);
1479 _outCoerceToDomainValue(StringInfo str, const CoerceToDomainValue *node)
1481 WRITE_NODE_TYPE("COERCETODOMAINVALUE");
1483 WRITE_OID_FIELD(typeId);
1484 WRITE_INT_FIELD(typeMod);
1485 WRITE_OID_FIELD(collation);
1486 WRITE_LOCATION_FIELD(location);
1490 _outSetToDefault(StringInfo str, const SetToDefault *node)
1492 WRITE_NODE_TYPE("SETTODEFAULT");
1494 WRITE_OID_FIELD(typeId);
1495 WRITE_INT_FIELD(typeMod);
1496 WRITE_OID_FIELD(collation);
1497 WRITE_LOCATION_FIELD(location);
1501 _outCurrentOfExpr(StringInfo str, const CurrentOfExpr *node)
1503 WRITE_NODE_TYPE("CURRENTOFEXPR");
1505 WRITE_UINT_FIELD(cvarno);
1506 WRITE_STRING_FIELD(cursor_name);
1507 WRITE_INT_FIELD(cursor_param);
1511 _outInferenceElem(StringInfo str, const InferenceElem *node)
1513 WRITE_NODE_TYPE("INFERENCEELEM");
1515 WRITE_NODE_FIELD(expr);
1516 WRITE_OID_FIELD(infercollid);
1517 WRITE_OID_FIELD(inferopclass);
1521 _outTargetEntry(StringInfo str, const TargetEntry *node)
1523 WRITE_NODE_TYPE("TARGETENTRY");
1525 WRITE_NODE_FIELD(expr);
1526 WRITE_INT_FIELD(resno);
1527 WRITE_STRING_FIELD(resname);
1528 WRITE_UINT_FIELD(ressortgroupref);
1529 WRITE_OID_FIELD(resorigtbl);
1530 WRITE_INT_FIELD(resorigcol);
1531 WRITE_BOOL_FIELD(resjunk);
1535 _outRangeTblRef(StringInfo str, const RangeTblRef *node)
1537 WRITE_NODE_TYPE("RANGETBLREF");
1539 WRITE_INT_FIELD(rtindex);
1543 _outJoinExpr(StringInfo str, const JoinExpr *node)
1545 WRITE_NODE_TYPE("JOINEXPR");
1547 WRITE_ENUM_FIELD(jointype, JoinType);
1548 WRITE_BOOL_FIELD(isNatural);
1549 WRITE_NODE_FIELD(larg);
1550 WRITE_NODE_FIELD(rarg);
1551 WRITE_NODE_FIELD(usingClause);
1552 WRITE_NODE_FIELD(quals);
1553 WRITE_NODE_FIELD(alias);
1554 WRITE_INT_FIELD(rtindex);
1558 _outFromExpr(StringInfo str, const FromExpr *node)
1560 WRITE_NODE_TYPE("FROMEXPR");
1562 WRITE_NODE_FIELD(fromlist);
1563 WRITE_NODE_FIELD(quals);
1567 _outOnConflictExpr(StringInfo str, const OnConflictExpr *node)
1569 WRITE_NODE_TYPE("ONCONFLICTEXPR");
1571 WRITE_ENUM_FIELD(action, OnConflictAction);
1572 WRITE_NODE_FIELD(arbiterElems);
1573 WRITE_NODE_FIELD(arbiterWhere);
1574 WRITE_OID_FIELD(constraint);
1575 WRITE_NODE_FIELD(onConflictSet);
1576 WRITE_NODE_FIELD(onConflictWhere);
1577 WRITE_INT_FIELD(exclRelIndex);
1578 WRITE_NODE_FIELD(exclRelTlist);
1581 /*****************************************************************************
1583 * Stuff from relation.h.
1585 *****************************************************************************/
1588 * print the basic stuff of all nodes that inherit from Path
1590 * Note we do NOT print the parent, else we'd be in infinite recursion.
1591 * We can print the parent's relids for identification purposes, though.
1592 * We print the pathtarget only if it's not the default one for the rel.
1593 * We also do not print the whole of param_info, since it's printed by
1594 * _outRelOptInfo; it's sufficient and less cluttering to print just the
1595 * required outer relids.
1598 _outPathInfo(StringInfo str, const Path *node)
1600 WRITE_ENUM_FIELD(pathtype, NodeTag);
1601 appendStringInfoString(str, " :parent_relids ");
1602 _outBitmapset(str, node->parent->relids);
1603 if (node->pathtarget != node->parent->reltarget)
1604 WRITE_NODE_FIELD(pathtarget);
1605 appendStringInfoString(str, " :required_outer ");
1606 if (node->param_info)
1607 _outBitmapset(str, node->param_info->ppi_req_outer);
1609 _outBitmapset(str, NULL);
1610 WRITE_BOOL_FIELD(parallel_aware);
1611 WRITE_BOOL_FIELD(parallel_safe);
1612 WRITE_INT_FIELD(parallel_degree);
1613 WRITE_FLOAT_FIELD(rows, "%.0f");
1614 WRITE_FLOAT_FIELD(startup_cost, "%.2f");
1615 WRITE_FLOAT_FIELD(total_cost, "%.2f");
1616 WRITE_NODE_FIELD(pathkeys);
1620 * print the basic stuff of all nodes that inherit from JoinPath
1623 _outJoinPathInfo(StringInfo str, const JoinPath *node)
1625 _outPathInfo(str, (const Path *) node);
1627 WRITE_ENUM_FIELD(jointype, JoinType);
1628 WRITE_NODE_FIELD(outerjoinpath);
1629 WRITE_NODE_FIELD(innerjoinpath);
1630 WRITE_NODE_FIELD(joinrestrictinfo);
1634 _outPath(StringInfo str, const Path *node)
1636 WRITE_NODE_TYPE("PATH");
1638 _outPathInfo(str, (const Path *) node);
1642 _outIndexPath(StringInfo str, const IndexPath *node)
1644 WRITE_NODE_TYPE("INDEXPATH");
1646 _outPathInfo(str, (const Path *) node);
1648 WRITE_NODE_FIELD(indexinfo);
1649 WRITE_NODE_FIELD(indexclauses);
1650 WRITE_NODE_FIELD(indexquals);
1651 WRITE_NODE_FIELD(indexqualcols);
1652 WRITE_NODE_FIELD(indexorderbys);
1653 WRITE_NODE_FIELD(indexorderbycols);
1654 WRITE_ENUM_FIELD(indexscandir, ScanDirection);
1655 WRITE_FLOAT_FIELD(indextotalcost, "%.2f");
1656 WRITE_FLOAT_FIELD(indexselectivity, "%.4f");
1660 _outBitmapHeapPath(StringInfo str, const BitmapHeapPath *node)
1662 WRITE_NODE_TYPE("BITMAPHEAPPATH");
1664 _outPathInfo(str, (const Path *) node);
1666 WRITE_NODE_FIELD(bitmapqual);
1670 _outBitmapAndPath(StringInfo str, const BitmapAndPath *node)
1672 WRITE_NODE_TYPE("BITMAPANDPATH");
1674 _outPathInfo(str, (const Path *) node);
1676 WRITE_NODE_FIELD(bitmapquals);
1677 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1681 _outBitmapOrPath(StringInfo str, const BitmapOrPath *node)
1683 WRITE_NODE_TYPE("BITMAPORPATH");
1685 _outPathInfo(str, (const Path *) node);
1687 WRITE_NODE_FIELD(bitmapquals);
1688 WRITE_FLOAT_FIELD(bitmapselectivity, "%.4f");
1692 _outTidPath(StringInfo str, const TidPath *node)
1694 WRITE_NODE_TYPE("TIDPATH");
1696 _outPathInfo(str, (const Path *) node);
1698 WRITE_NODE_FIELD(tidquals);
1702 _outSubqueryScanPath(StringInfo str, const SubqueryScanPath *node)
1704 WRITE_NODE_TYPE("SUBQUERYSCANPATH");
1706 _outPathInfo(str, (const Path *) node);
1708 WRITE_NODE_FIELD(subpath);
1712 _outForeignPath(StringInfo str, const ForeignPath *node)
1714 WRITE_NODE_TYPE("FOREIGNPATH");
1716 _outPathInfo(str, (const Path *) node);
1718 WRITE_NODE_FIELD(fdw_outerpath);
1719 WRITE_NODE_FIELD(fdw_private);
1723 _outCustomPath(StringInfo str, const CustomPath *node)
1725 WRITE_NODE_TYPE("CUSTOMPATH");
1727 _outPathInfo(str, (const Path *) node);
1729 WRITE_UINT_FIELD(flags);
1730 WRITE_NODE_FIELD(custom_paths);
1731 WRITE_NODE_FIELD(custom_private);
1732 appendStringInfoString(str, " :methods ");
1733 _outToken(str, node->methods->CustomName);
1737 _outAppendPath(StringInfo str, const AppendPath *node)
1739 WRITE_NODE_TYPE("APPENDPATH");
1741 _outPathInfo(str, (const Path *) node);
1743 WRITE_NODE_FIELD(subpaths);
1747 _outMergeAppendPath(StringInfo str, const MergeAppendPath *node)
1749 WRITE_NODE_TYPE("MERGEAPPENDPATH");
1751 _outPathInfo(str, (const Path *) node);
1753 WRITE_NODE_FIELD(subpaths);
1754 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
1758 _outResultPath(StringInfo str, const ResultPath *node)
1760 WRITE_NODE_TYPE("RESULTPATH");
1762 _outPathInfo(str, (const Path *) node);
1764 WRITE_NODE_FIELD(quals);
1768 _outMaterialPath(StringInfo str, const MaterialPath *node)
1770 WRITE_NODE_TYPE("MATERIALPATH");
1772 _outPathInfo(str, (const Path *) node);
1774 WRITE_NODE_FIELD(subpath);
1778 _outUniquePath(StringInfo str, const UniquePath *node)
1780 WRITE_NODE_TYPE("UNIQUEPATH");
1782 _outPathInfo(str, (const Path *) node);
1784 WRITE_NODE_FIELD(subpath);
1785 WRITE_ENUM_FIELD(umethod, UniquePathMethod);
1786 WRITE_NODE_FIELD(in_operators);
1787 WRITE_NODE_FIELD(uniq_exprs);
1791 _outGatherPath(StringInfo str, const GatherPath *node)
1793 WRITE_NODE_TYPE("GATHERPATH");
1795 _outPathInfo(str, (const Path *) node);
1797 WRITE_NODE_FIELD(subpath);
1798 WRITE_BOOL_FIELD(single_copy);
1802 _outProjectionPath(StringInfo str, const ProjectionPath *node)
1804 WRITE_NODE_TYPE("PROJECTIONPATH");
1806 _outPathInfo(str, (const Path *) node);
1808 WRITE_NODE_FIELD(subpath);
1812 _outSortPath(StringInfo str, const SortPath *node)
1814 WRITE_NODE_TYPE("SORTPATH");
1816 _outPathInfo(str, (const Path *) node);
1818 WRITE_NODE_FIELD(subpath);
1822 _outGroupPath(StringInfo str, const GroupPath *node)
1824 WRITE_NODE_TYPE("GROUPPATH");
1826 _outPathInfo(str, (const Path *) node);
1828 WRITE_NODE_FIELD(subpath);
1829 WRITE_NODE_FIELD(groupClause);
1830 WRITE_NODE_FIELD(qual);
1834 _outUpperUniquePath(StringInfo str, const UpperUniquePath *node)
1836 WRITE_NODE_TYPE("UPPERUNIQUEPATH");
1838 _outPathInfo(str, (const Path *) node);
1840 WRITE_NODE_FIELD(subpath);
1841 WRITE_INT_FIELD(numkeys);
1845 _outAggPath(StringInfo str, const AggPath *node)
1847 WRITE_NODE_TYPE("AGGPATH");
1849 _outPathInfo(str, (const Path *) node);
1851 WRITE_NODE_FIELD(subpath);
1852 WRITE_ENUM_FIELD(aggstrategy, AggStrategy);
1853 WRITE_FLOAT_FIELD(numGroups, "%.0f");
1854 WRITE_NODE_FIELD(groupClause);
1855 WRITE_NODE_FIELD(qual);
1859 _outGroupingSetsPath(StringInfo str, const GroupingSetsPath *node)
1861 WRITE_NODE_TYPE("GROUPINGSETSPATH");
1863 _outPathInfo(str, (const Path *) node);
1865 WRITE_NODE_FIELD(subpath);
1866 WRITE_NODE_FIELD(rollup_groupclauses);
1867 WRITE_NODE_FIELD(rollup_lists);
1868 WRITE_NODE_FIELD(qual);
1872 _outMinMaxAggPath(StringInfo str, const MinMaxAggPath *node)
1874 WRITE_NODE_TYPE("MINMAXAGGPATH");
1876 _outPathInfo(str, (const Path *) node);
1878 WRITE_NODE_FIELD(mmaggregates);
1879 WRITE_NODE_FIELD(quals);
1883 _outWindowAggPath(StringInfo str, const WindowAggPath *node)
1885 WRITE_NODE_TYPE("WINDOWAGGPATH");
1887 _outPathInfo(str, (const Path *) node);
1889 WRITE_NODE_FIELD(subpath);
1890 WRITE_NODE_FIELD(winclause);
1891 WRITE_NODE_FIELD(winpathkeys);
1895 _outSetOpPath(StringInfo str, const SetOpPath *node)
1897 WRITE_NODE_TYPE("SETOPPATH");
1899 _outPathInfo(str, (const Path *) node);
1901 WRITE_NODE_FIELD(subpath);
1902 WRITE_ENUM_FIELD(cmd, SetOpCmd);
1903 WRITE_ENUM_FIELD(strategy, SetOpStrategy);
1904 WRITE_NODE_FIELD(distinctList);
1905 WRITE_INT_FIELD(flagColIdx);
1906 WRITE_INT_FIELD(firstFlag);
1907 WRITE_FLOAT_FIELD(numGroups, "%.0f");
1911 _outRecursiveUnionPath(StringInfo str, const RecursiveUnionPath *node)
1913 WRITE_NODE_TYPE("RECURSIVEUNIONPATH");
1915 _outPathInfo(str, (const Path *) node);
1917 WRITE_NODE_FIELD(leftpath);
1918 WRITE_NODE_FIELD(rightpath);
1919 WRITE_NODE_FIELD(distinctList);
1920 WRITE_INT_FIELD(wtParam);
1921 WRITE_FLOAT_FIELD(numGroups, "%.0f");
1925 _outLockRowsPath(StringInfo str, const LockRowsPath *node)
1927 WRITE_NODE_TYPE("LOCKROWSPATH");
1929 _outPathInfo(str, (const Path *) node);
1931 WRITE_NODE_FIELD(subpath);
1932 WRITE_NODE_FIELD(rowMarks);
1933 WRITE_INT_FIELD(epqParam);
1937 _outModifyTablePath(StringInfo str, const ModifyTablePath *node)
1939 WRITE_NODE_TYPE("MODIFYTABLEPATH");
1941 _outPathInfo(str, (const Path *) node);
1943 WRITE_ENUM_FIELD(operation, CmdType);
1944 WRITE_BOOL_FIELD(canSetTag);
1945 WRITE_UINT_FIELD(nominalRelation);
1946 WRITE_NODE_FIELD(resultRelations);
1947 WRITE_NODE_FIELD(subpaths);
1948 WRITE_NODE_FIELD(subroots);
1949 WRITE_NODE_FIELD(withCheckOptionLists);
1950 WRITE_NODE_FIELD(returningLists);
1951 WRITE_NODE_FIELD(rowMarks);
1952 WRITE_NODE_FIELD(onconflict);
1953 WRITE_INT_FIELD(epqParam);
1957 _outLimitPath(StringInfo str, const LimitPath *node)
1959 WRITE_NODE_TYPE("LIMITPATH");
1961 _outPathInfo(str, (const Path *) node);
1963 WRITE_NODE_FIELD(subpath);
1964 WRITE_NODE_FIELD(limitOffset);
1965 WRITE_NODE_FIELD(limitCount);
1969 _outNestPath(StringInfo str, const NestPath *node)
1971 WRITE_NODE_TYPE("NESTPATH");
1973 _outJoinPathInfo(str, (const JoinPath *) node);
1977 _outMergePath(StringInfo str, const MergePath *node)
1979 WRITE_NODE_TYPE("MERGEPATH");
1981 _outJoinPathInfo(str, (const JoinPath *) node);
1983 WRITE_NODE_FIELD(path_mergeclauses);
1984 WRITE_NODE_FIELD(outersortkeys);
1985 WRITE_NODE_FIELD(innersortkeys);
1986 WRITE_BOOL_FIELD(materialize_inner);
1990 _outHashPath(StringInfo str, const HashPath *node)
1992 WRITE_NODE_TYPE("HASHPATH");
1994 _outJoinPathInfo(str, (const JoinPath *) node);
1996 WRITE_NODE_FIELD(path_hashclauses);
1997 WRITE_INT_FIELD(num_batches);
2001 _outPlannerGlobal(StringInfo str, const PlannerGlobal *node)
2003 WRITE_NODE_TYPE("PLANNERGLOBAL");
2005 /* NB: this isn't a complete set of fields */
2006 WRITE_NODE_FIELD(subplans);
2007 WRITE_BITMAPSET_FIELD(rewindPlanIDs);
2008 WRITE_NODE_FIELD(finalrtable);
2009 WRITE_NODE_FIELD(finalrowmarks);
2010 WRITE_NODE_FIELD(resultRelations);
2011 WRITE_NODE_FIELD(relationOids);
2012 WRITE_NODE_FIELD(invalItems);
2013 WRITE_INT_FIELD(nParamExec);
2014 WRITE_UINT_FIELD(lastPHId);
2015 WRITE_UINT_FIELD(lastRowMarkId);
2016 WRITE_BOOL_FIELD(transientPlan);
2017 WRITE_BOOL_FIELD(hasRowSecurity);
2018 WRITE_BOOL_FIELD(parallelModeOK);
2019 WRITE_BOOL_FIELD(parallelModeNeeded);
2020 WRITE_BOOL_FIELD(wholePlanParallelSafe);
2021 WRITE_BOOL_FIELD(hasForeignJoin);
2025 _outPlannerInfo(StringInfo str, const PlannerInfo *node)
2027 WRITE_NODE_TYPE("PLANNERINFO");
2029 /* NB: this isn't a complete set of fields */
2030 WRITE_NODE_FIELD(parse);
2031 WRITE_NODE_FIELD(glob);
2032 WRITE_UINT_FIELD(query_level);
2033 WRITE_NODE_FIELD(plan_params);
2034 WRITE_BITMAPSET_FIELD(outer_params);
2035 WRITE_BITMAPSET_FIELD(all_baserels);
2036 WRITE_BITMAPSET_FIELD(nullable_baserels);
2037 WRITE_NODE_FIELD(join_rel_list);
2038 WRITE_INT_FIELD(join_cur_level);
2039 WRITE_NODE_FIELD(init_plans);
2040 WRITE_NODE_FIELD(cte_plan_ids);
2041 WRITE_NODE_FIELD(multiexpr_params);
2042 WRITE_NODE_FIELD(eq_classes);
2043 WRITE_NODE_FIELD(canon_pathkeys);
2044 WRITE_NODE_FIELD(left_join_clauses);
2045 WRITE_NODE_FIELD(right_join_clauses);
2046 WRITE_NODE_FIELD(full_join_clauses);
2047 WRITE_NODE_FIELD(join_info_list);
2048 WRITE_NODE_FIELD(append_rel_list);
2049 WRITE_NODE_FIELD(rowMarks);
2050 WRITE_NODE_FIELD(placeholder_list);
2051 WRITE_NODE_FIELD(query_pathkeys);
2052 WRITE_NODE_FIELD(group_pathkeys);
2053 WRITE_NODE_FIELD(window_pathkeys);
2054 WRITE_NODE_FIELD(distinct_pathkeys);
2055 WRITE_NODE_FIELD(sort_pathkeys);
2056 WRITE_NODE_FIELD(processed_tlist);
2057 WRITE_NODE_FIELD(minmax_aggs);
2058 WRITE_FLOAT_FIELD(total_table_pages, "%.0f");
2059 WRITE_FLOAT_FIELD(tuple_fraction, "%.4f");
2060 WRITE_FLOAT_FIELD(limit_tuples, "%.0f");
2061 WRITE_BOOL_FIELD(hasInheritedTarget);
2062 WRITE_BOOL_FIELD(hasJoinRTEs);
2063 WRITE_BOOL_FIELD(hasLateralRTEs);
2064 WRITE_BOOL_FIELD(hasDeletedRTEs);
2065 WRITE_BOOL_FIELD(hasHavingQual);
2066 WRITE_BOOL_FIELD(hasPseudoConstantQuals);
2067 WRITE_BOOL_FIELD(hasRecursion);
2068 WRITE_INT_FIELD(wt_param_id);
2069 WRITE_BITMAPSET_FIELD(curOuterRels);
2070 WRITE_NODE_FIELD(curOuterParams);
2074 _outRelOptInfo(StringInfo str, const RelOptInfo *node)
2076 WRITE_NODE_TYPE("RELOPTINFO");
2078 /* NB: this isn't a complete set of fields */
2079 WRITE_ENUM_FIELD(reloptkind, RelOptKind);
2080 WRITE_BITMAPSET_FIELD(relids);
2081 WRITE_FLOAT_FIELD(rows, "%.0f");
2082 WRITE_BOOL_FIELD(consider_startup);
2083 WRITE_BOOL_FIELD(consider_param_startup);
2084 WRITE_BOOL_FIELD(consider_parallel);
2085 WRITE_NODE_FIELD(reltarget);
2086 WRITE_NODE_FIELD(pathlist);
2087 WRITE_NODE_FIELD(ppilist);
2088 WRITE_NODE_FIELD(partial_pathlist);
2089 WRITE_NODE_FIELD(cheapest_startup_path);
2090 WRITE_NODE_FIELD(cheapest_total_path);
2091 WRITE_NODE_FIELD(cheapest_unique_path);
2092 WRITE_NODE_FIELD(cheapest_parameterized_paths);
2093 WRITE_BITMAPSET_FIELD(direct_lateral_relids);
2094 WRITE_BITMAPSET_FIELD(lateral_relids);
2095 WRITE_UINT_FIELD(relid);
2096 WRITE_OID_FIELD(reltablespace);
2097 WRITE_ENUM_FIELD(rtekind, RTEKind);
2098 WRITE_INT_FIELD(min_attr);
2099 WRITE_INT_FIELD(max_attr);
2100 WRITE_NODE_FIELD(lateral_vars);
2101 WRITE_BITMAPSET_FIELD(lateral_referencers);
2102 WRITE_NODE_FIELD(indexlist);
2103 WRITE_UINT_FIELD(pages);
2104 WRITE_FLOAT_FIELD(tuples, "%.0f");
2105 WRITE_FLOAT_FIELD(allvisfrac, "%.6f");
2106 WRITE_NODE_FIELD(subroot);
2107 WRITE_NODE_FIELD(subplan_params);
2108 WRITE_OID_FIELD(serverid);
2109 /* we don't try to print fdwroutine or fdw_private */
2110 WRITE_NODE_FIELD(baserestrictinfo);
2111 WRITE_NODE_FIELD(joininfo);
2112 WRITE_BOOL_FIELD(has_eclass_joins);
2116 _outIndexOptInfo(StringInfo str, const IndexOptInfo *node)
2118 WRITE_NODE_TYPE("INDEXOPTINFO");
2120 /* NB: this isn't a complete set of fields */
2121 WRITE_OID_FIELD(indexoid);
2122 /* Do NOT print rel field, else infinite recursion */
2123 WRITE_UINT_FIELD(pages);
2124 WRITE_FLOAT_FIELD(tuples, "%.0f");
2125 WRITE_INT_FIELD(tree_height);
2126 WRITE_INT_FIELD(ncolumns);
2127 /* array fields aren't really worth the trouble to print */
2128 WRITE_OID_FIELD(relam);
2129 /* indexprs is redundant since we print indextlist */
2130 WRITE_NODE_FIELD(indpred);
2131 WRITE_NODE_FIELD(indextlist);
2132 WRITE_NODE_FIELD(indrestrictinfo);
2133 WRITE_BOOL_FIELD(predOK);
2134 WRITE_BOOL_FIELD(unique);
2135 WRITE_BOOL_FIELD(immediate);
2136 WRITE_BOOL_FIELD(hypothetical);
2137 /* we don't bother with fields copied from the index AM's API struct */
2141 _outForeignKeyOptInfo(StringInfo str, const ForeignKeyOptInfo *node)
2143 WRITE_NODE_TYPE("FOREIGNKEYOPTINFO");
2145 WRITE_OID_FIELD(conrelid);
2146 WRITE_OID_FIELD(confrelid);
2147 WRITE_INT_FIELD(nkeys);
2151 _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
2154 * To simplify reading, we just chase up to the topmost merged EC and
2155 * print that, without bothering to show the merge-ees separately.
2157 while (node->ec_merged)
2158 node = node->ec_merged;
2160 WRITE_NODE_TYPE("EQUIVALENCECLASS");
2162 WRITE_NODE_FIELD(ec_opfamilies);
2163 WRITE_OID_FIELD(ec_collation);
2164 WRITE_NODE_FIELD(ec_members);
2165 WRITE_NODE_FIELD(ec_sources);
2166 WRITE_NODE_FIELD(ec_derives);
2167 WRITE_BITMAPSET_FIELD(ec_relids);
2168 WRITE_BOOL_FIELD(ec_has_const);
2169 WRITE_BOOL_FIELD(ec_has_volatile);
2170 WRITE_BOOL_FIELD(ec_below_outer_join);
2171 WRITE_BOOL_FIELD(ec_broken);
2172 WRITE_UINT_FIELD(ec_sortref);
2176 _outEquivalenceMember(StringInfo str, const EquivalenceMember *node)
2178 WRITE_NODE_TYPE("EQUIVALENCEMEMBER");
2180 WRITE_NODE_FIELD(em_expr);
2181 WRITE_BITMAPSET_FIELD(em_relids);
2182 WRITE_BITMAPSET_FIELD(em_nullable_relids);
2183 WRITE_BOOL_FIELD(em_is_const);
2184 WRITE_BOOL_FIELD(em_is_child);
2185 WRITE_OID_FIELD(em_datatype);
2189 _outPathKey(StringInfo str, const PathKey *node)
2191 WRITE_NODE_TYPE("PATHKEY");
2193 WRITE_NODE_FIELD(pk_eclass);
2194 WRITE_OID_FIELD(pk_opfamily);
2195 WRITE_INT_FIELD(pk_strategy);
2196 WRITE_BOOL_FIELD(pk_nulls_first);
2200 _outPathTarget(StringInfo str, const PathTarget *node)
2202 WRITE_NODE_TYPE("PATHTARGET");
2204 WRITE_NODE_FIELD(exprs);
2205 if (node->sortgrouprefs)
2209 appendStringInfoString(str, " :sortgrouprefs");
2210 for (i = 0; i < list_length(node->exprs); i++)
2211 appendStringInfo(str, " %u", node->sortgrouprefs[i]);
2213 WRITE_FLOAT_FIELD(cost.startup, "%.2f");
2214 WRITE_FLOAT_FIELD(cost.per_tuple, "%.2f");
2215 WRITE_INT_FIELD(width);
2219 _outParamPathInfo(StringInfo str, const ParamPathInfo *node)
2221 WRITE_NODE_TYPE("PARAMPATHINFO");
2223 WRITE_BITMAPSET_FIELD(ppi_req_outer);
2224 WRITE_FLOAT_FIELD(ppi_rows, "%.0f");
2225 WRITE_NODE_FIELD(ppi_clauses);
2229 _outRestrictInfo(StringInfo str, const RestrictInfo *node)
2231 WRITE_NODE_TYPE("RESTRICTINFO");
2233 /* NB: this isn't a complete set of fields */
2234 WRITE_NODE_FIELD(clause);
2235 WRITE_BOOL_FIELD(is_pushed_down);
2236 WRITE_BOOL_FIELD(outerjoin_delayed);
2237 WRITE_BOOL_FIELD(can_join);
2238 WRITE_BOOL_FIELD(pseudoconstant);
2239 WRITE_BITMAPSET_FIELD(clause_relids);
2240 WRITE_BITMAPSET_FIELD(required_relids);
2241 WRITE_BITMAPSET_FIELD(outer_relids);
2242 WRITE_BITMAPSET_FIELD(nullable_relids);
2243 WRITE_BITMAPSET_FIELD(left_relids);
2244 WRITE_BITMAPSET_FIELD(right_relids);
2245 WRITE_NODE_FIELD(orclause);
2246 /* don't write parent_ec, leads to infinite recursion in plan tree dump */
2247 WRITE_FLOAT_FIELD(norm_selec, "%.4f");
2248 WRITE_FLOAT_FIELD(outer_selec, "%.4f");
2249 WRITE_NODE_FIELD(mergeopfamilies);
2250 /* don't write left_ec, leads to infinite recursion in plan tree dump */
2251 /* don't write right_ec, leads to infinite recursion in plan tree dump */
2252 WRITE_NODE_FIELD(left_em);
2253 WRITE_NODE_FIELD(right_em);
2254 WRITE_BOOL_FIELD(outer_is_left);
2255 WRITE_OID_FIELD(hashjoinoperator);
2259 _outPlaceHolderVar(StringInfo str, const PlaceHolderVar *node)
2261 WRITE_NODE_TYPE("PLACEHOLDERVAR");
2263 WRITE_NODE_FIELD(phexpr);
2264 WRITE_BITMAPSET_FIELD(phrels);
2265 WRITE_UINT_FIELD(phid);
2266 WRITE_UINT_FIELD(phlevelsup);
2270 _outSpecialJoinInfo(StringInfo str, const SpecialJoinInfo *node)
2272 WRITE_NODE_TYPE("SPECIALJOININFO");
2274 WRITE_BITMAPSET_FIELD(min_lefthand);
2275 WRITE_BITMAPSET_FIELD(min_righthand);
2276 WRITE_BITMAPSET_FIELD(syn_lefthand);
2277 WRITE_BITMAPSET_FIELD(syn_righthand);
2278 WRITE_ENUM_FIELD(jointype, JoinType);
2279 WRITE_BOOL_FIELD(lhs_strict);
2280 WRITE_BOOL_FIELD(delay_upper_joins);
2281 WRITE_BOOL_FIELD(semi_can_btree);
2282 WRITE_BOOL_FIELD(semi_can_hash);
2283 WRITE_NODE_FIELD(semi_operators);
2284 WRITE_NODE_FIELD(semi_rhs_exprs);
2288 _outAppendRelInfo(StringInfo str, const AppendRelInfo *node)
2290 WRITE_NODE_TYPE("APPENDRELINFO");
2292 WRITE_UINT_FIELD(parent_relid);
2293 WRITE_UINT_FIELD(child_relid);
2294 WRITE_OID_FIELD(parent_reltype);
2295 WRITE_OID_FIELD(child_reltype);
2296 WRITE_NODE_FIELD(translated_vars);
2297 WRITE_OID_FIELD(parent_reloid);
2301 _outPlaceHolderInfo(StringInfo str, const PlaceHolderInfo *node)
2303 WRITE_NODE_TYPE("PLACEHOLDERINFO");
2305 WRITE_UINT_FIELD(phid);
2306 WRITE_NODE_FIELD(ph_var);
2307 WRITE_BITMAPSET_FIELD(ph_eval_at);
2308 WRITE_BITMAPSET_FIELD(ph_lateral);
2309 WRITE_BITMAPSET_FIELD(ph_needed);
2310 WRITE_INT_FIELD(ph_width);
2314 _outMinMaxAggInfo(StringInfo str, const MinMaxAggInfo *node)
2316 WRITE_NODE_TYPE("MINMAXAGGINFO");
2318 WRITE_OID_FIELD(aggfnoid);
2319 WRITE_OID_FIELD(aggsortop);
2320 WRITE_NODE_FIELD(target);
2321 /* We intentionally omit subroot --- too large, not interesting enough */
2322 WRITE_NODE_FIELD(path);
2323 WRITE_FLOAT_FIELD(pathcost, "%.2f");
2324 WRITE_NODE_FIELD(param);
2328 _outPlannerParamItem(StringInfo str, const PlannerParamItem *node)
2330 WRITE_NODE_TYPE("PLANNERPARAMITEM");
2332 WRITE_NODE_FIELD(item);
2333 WRITE_INT_FIELD(paramId);
2336 /*****************************************************************************
2338 * Stuff from extensible.h
2340 *****************************************************************************/
2343 _outExtensibleNode(StringInfo str, const ExtensibleNode *node)
2345 const ExtensibleNodeMethods *methods;
2347 methods = GetExtensibleNodeMethods(node->extnodename, false);
2349 WRITE_NODE_TYPE("EXTENSIBLENODE");
2351 WRITE_STRING_FIELD(extnodename);
2353 /* serialize the private fields */
2354 methods->nodeOut(str, node);
2357 /*****************************************************************************
2359 * Stuff from parsenodes.h.
2361 *****************************************************************************/
2364 * print the basic stuff of all nodes that inherit from CreateStmt
2367 _outCreateStmtInfo(StringInfo str, const CreateStmt *node)
2369 WRITE_NODE_FIELD(relation);
2370 WRITE_NODE_FIELD(tableElts);
2371 WRITE_NODE_FIELD(inhRelations);
2372 WRITE_NODE_FIELD(ofTypename);
2373 WRITE_NODE_FIELD(constraints);
2374 WRITE_NODE_FIELD(options);
2375 WRITE_ENUM_FIELD(oncommit, OnCommitAction);
2376 WRITE_STRING_FIELD(tablespacename);
2377 WRITE_BOOL_FIELD(if_not_exists);
2381 _outCreateStmt(StringInfo str, const CreateStmt *node)
2383 WRITE_NODE_TYPE("CREATESTMT");
2385 _outCreateStmtInfo(str, (const CreateStmt *) node);
2389 _outCreateForeignTableStmt(StringInfo str, const CreateForeignTableStmt *node)
2391 WRITE_NODE_TYPE("CREATEFOREIGNTABLESTMT");
2393 _outCreateStmtInfo(str, (const CreateStmt *) node);
2395 WRITE_STRING_FIELD(servername);
2396 WRITE_NODE_FIELD(options);
2400 _outImportForeignSchemaStmt(StringInfo str, const ImportForeignSchemaStmt *node)
2402 WRITE_NODE_TYPE("IMPORTFOREIGNSCHEMASTMT");
2404 WRITE_STRING_FIELD(server_name);
2405 WRITE_STRING_FIELD(remote_schema);
2406 WRITE_STRING_FIELD(local_schema);
2407 WRITE_ENUM_FIELD(list_type, ImportForeignSchemaType);
2408 WRITE_NODE_FIELD(table_list);
2409 WRITE_NODE_FIELD(options);
2413 _outIndexStmt(StringInfo str, const IndexStmt *node)
2415 WRITE_NODE_TYPE("INDEXSTMT");
2417 WRITE_STRING_FIELD(idxname);
2418 WRITE_NODE_FIELD(relation);
2419 WRITE_STRING_FIELD(accessMethod);
2420 WRITE_STRING_FIELD(tableSpace);
2421 WRITE_NODE_FIELD(indexParams);
2422 WRITE_NODE_FIELD(options);
2423 WRITE_NODE_FIELD(whereClause);
2424 WRITE_NODE_FIELD(excludeOpNames);
2425 WRITE_STRING_FIELD(idxcomment);
2426 WRITE_OID_FIELD(indexOid);
2427 WRITE_OID_FIELD(oldNode);
2428 WRITE_BOOL_FIELD(unique);
2429 WRITE_BOOL_FIELD(primary);
2430 WRITE_BOOL_FIELD(isconstraint);
2431 WRITE_BOOL_FIELD(deferrable);
2432 WRITE_BOOL_FIELD(initdeferred);
2433 WRITE_BOOL_FIELD(transformed);
2434 WRITE_BOOL_FIELD(concurrent);
2435 WRITE_BOOL_FIELD(if_not_exists);
2439 _outNotifyStmt(StringInfo str, const NotifyStmt *node)
2441 WRITE_NODE_TYPE("NOTIFY");
2443 WRITE_STRING_FIELD(conditionname);
2444 WRITE_STRING_FIELD(payload);
2448 _outDeclareCursorStmt(StringInfo str, const DeclareCursorStmt *node)
2450 WRITE_NODE_TYPE("DECLARECURSOR");
2452 WRITE_STRING_FIELD(portalname);
2453 WRITE_INT_FIELD(options);
2454 WRITE_NODE_FIELD(query);
2458 _outSelectStmt(StringInfo str, const SelectStmt *node)
2460 WRITE_NODE_TYPE("SELECT");
2462 WRITE_NODE_FIELD(distinctClause);
2463 WRITE_NODE_FIELD(intoClause);
2464 WRITE_NODE_FIELD(targetList);
2465 WRITE_NODE_FIELD(fromClause);
2466 WRITE_NODE_FIELD(whereClause);
2467 WRITE_NODE_FIELD(groupClause);
2468 WRITE_NODE_FIELD(havingClause);
2469 WRITE_NODE_FIELD(windowClause);
2470 WRITE_NODE_FIELD(valuesLists);
2471 WRITE_NODE_FIELD(sortClause);
2472 WRITE_NODE_FIELD(limitOffset);
2473 WRITE_NODE_FIELD(limitCount);
2474 WRITE_NODE_FIELD(lockingClause);
2475 WRITE_NODE_FIELD(withClause);
2476 WRITE_ENUM_FIELD(op, SetOperation);
2477 WRITE_BOOL_FIELD(all);
2478 WRITE_NODE_FIELD(larg);
2479 WRITE_NODE_FIELD(rarg);
2483 _outFuncCall(StringInfo str, const FuncCall *node)
2485 WRITE_NODE_TYPE("FUNCCALL");
2487 WRITE_NODE_FIELD(funcname);
2488 WRITE_NODE_FIELD(args);
2489 WRITE_NODE_FIELD(agg_order);
2490 WRITE_NODE_FIELD(agg_filter);
2491 WRITE_BOOL_FIELD(agg_within_group);
2492 WRITE_BOOL_FIELD(agg_star);
2493 WRITE_BOOL_FIELD(agg_distinct);
2494 WRITE_BOOL_FIELD(func_variadic);
2495 WRITE_NODE_FIELD(over);
2496 WRITE_LOCATION_FIELD(location);
2500 _outDefElem(StringInfo str, const DefElem *node)
2502 WRITE_NODE_TYPE("DEFELEM");
2504 WRITE_STRING_FIELD(defnamespace);
2505 WRITE_STRING_FIELD(defname);
2506 WRITE_NODE_FIELD(arg);
2507 WRITE_ENUM_FIELD(defaction, DefElemAction);
2511 _outTableLikeClause(StringInfo str, const TableLikeClause *node)
2513 WRITE_NODE_TYPE("TABLELIKECLAUSE");
2515 WRITE_NODE_FIELD(relation);
2516 WRITE_UINT_FIELD(options);
2520 _outLockingClause(StringInfo str, const LockingClause *node)
2522 WRITE_NODE_TYPE("LOCKINGCLAUSE");
2524 WRITE_NODE_FIELD(lockedRels);
2525 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2526 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2530 _outXmlSerialize(StringInfo str, const XmlSerialize *node)
2532 WRITE_NODE_TYPE("XMLSERIALIZE");
2534 WRITE_ENUM_FIELD(xmloption, XmlOptionType);
2535 WRITE_NODE_FIELD(expr);
2536 WRITE_NODE_FIELD(typeName);
2537 WRITE_LOCATION_FIELD(location);
2541 _outColumnDef(StringInfo str, const ColumnDef *node)
2543 WRITE_NODE_TYPE("COLUMNDEF");
2545 WRITE_STRING_FIELD(colname);
2546 WRITE_NODE_FIELD(typeName);
2547 WRITE_INT_FIELD(inhcount);
2548 WRITE_BOOL_FIELD(is_local);
2549 WRITE_BOOL_FIELD(is_not_null);
2550 WRITE_BOOL_FIELD(is_from_type);
2551 WRITE_CHAR_FIELD(storage);
2552 WRITE_NODE_FIELD(raw_default);
2553 WRITE_NODE_FIELD(cooked_default);
2554 WRITE_NODE_FIELD(collClause);
2555 WRITE_OID_FIELD(collOid);
2556 WRITE_NODE_FIELD(constraints);
2557 WRITE_NODE_FIELD(fdwoptions);
2558 WRITE_LOCATION_FIELD(location);
2562 _outTypeName(StringInfo str, const TypeName *node)
2564 WRITE_NODE_TYPE("TYPENAME");
2566 WRITE_NODE_FIELD(names);
2567 WRITE_OID_FIELD(typeOid);
2568 WRITE_BOOL_FIELD(setof);
2569 WRITE_BOOL_FIELD(pct_type);
2570 WRITE_NODE_FIELD(typmods);
2571 WRITE_INT_FIELD(typemod);
2572 WRITE_NODE_FIELD(arrayBounds);
2573 WRITE_LOCATION_FIELD(location);
2577 _outTypeCast(StringInfo str, const TypeCast *node)
2579 WRITE_NODE_TYPE("TYPECAST");
2581 WRITE_NODE_FIELD(arg);
2582 WRITE_NODE_FIELD(typeName);
2583 WRITE_LOCATION_FIELD(location);
2587 _outCollateClause(StringInfo str, const CollateClause *node)
2589 WRITE_NODE_TYPE("COLLATECLAUSE");
2591 WRITE_NODE_FIELD(arg);
2592 WRITE_NODE_FIELD(collname);
2593 WRITE_LOCATION_FIELD(location);
2597 _outIndexElem(StringInfo str, const IndexElem *node)
2599 WRITE_NODE_TYPE("INDEXELEM");
2601 WRITE_STRING_FIELD(name);
2602 WRITE_NODE_FIELD(expr);
2603 WRITE_STRING_FIELD(indexcolname);
2604 WRITE_NODE_FIELD(collation);
2605 WRITE_NODE_FIELD(opclass);
2606 WRITE_ENUM_FIELD(ordering, SortByDir);
2607 WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
2611 _outQuery(StringInfo str, const Query *node)
2613 WRITE_NODE_TYPE("QUERY");
2615 WRITE_ENUM_FIELD(commandType, CmdType);
2616 WRITE_ENUM_FIELD(querySource, QuerySource);
2617 /* we intentionally do not print the queryId field */
2618 WRITE_BOOL_FIELD(canSetTag);
2621 * Hack to work around missing outfuncs routines for a lot of the
2622 * utility-statement node types. (The only one we actually *need* for
2623 * rules support is NotifyStmt.) Someday we ought to support 'em all, but
2624 * for the meantime do this to avoid getting lots of warnings when running
2625 * with debug_print_parse on.
2627 if (node->utilityStmt)
2629 switch (nodeTag(node->utilityStmt))
2634 case T_DeclareCursorStmt:
2635 WRITE_NODE_FIELD(utilityStmt);
2638 appendStringInfoString(str, " :utilityStmt ?");
2643 appendStringInfoString(str, " :utilityStmt <>");
2645 WRITE_INT_FIELD(resultRelation);
2646 WRITE_BOOL_FIELD(hasAggs);
2647 WRITE_BOOL_FIELD(hasWindowFuncs);
2648 WRITE_BOOL_FIELD(hasSubLinks);
2649 WRITE_BOOL_FIELD(hasDistinctOn);
2650 WRITE_BOOL_FIELD(hasRecursive);
2651 WRITE_BOOL_FIELD(hasModifyingCTE);
2652 WRITE_BOOL_FIELD(hasForUpdate);
2653 WRITE_BOOL_FIELD(hasRowSecurity);
2654 WRITE_NODE_FIELD(cteList);
2655 WRITE_NODE_FIELD(rtable);
2656 WRITE_NODE_FIELD(jointree);
2657 WRITE_NODE_FIELD(targetList);
2658 WRITE_NODE_FIELD(onConflict);
2659 WRITE_NODE_FIELD(returningList);
2660 WRITE_NODE_FIELD(groupClause);
2661 WRITE_NODE_FIELD(groupingSets);
2662 WRITE_NODE_FIELD(havingQual);
2663 WRITE_NODE_FIELD(windowClause);
2664 WRITE_NODE_FIELD(distinctClause);
2665 WRITE_NODE_FIELD(sortClause);
2666 WRITE_NODE_FIELD(limitOffset);
2667 WRITE_NODE_FIELD(limitCount);
2668 WRITE_NODE_FIELD(rowMarks);
2669 WRITE_NODE_FIELD(setOperations);
2670 WRITE_NODE_FIELD(constraintDeps);
2674 _outWithCheckOption(StringInfo str, const WithCheckOption *node)
2676 WRITE_NODE_TYPE("WITHCHECKOPTION");
2678 WRITE_ENUM_FIELD(kind, WCOKind);
2679 WRITE_STRING_FIELD(relname);
2680 WRITE_STRING_FIELD(polname);
2681 WRITE_NODE_FIELD(qual);
2682 WRITE_BOOL_FIELD(cascaded);
2686 _outSortGroupClause(StringInfo str, const SortGroupClause *node)
2688 WRITE_NODE_TYPE("SORTGROUPCLAUSE");
2690 WRITE_UINT_FIELD(tleSortGroupRef);
2691 WRITE_OID_FIELD(eqop);
2692 WRITE_OID_FIELD(sortop);
2693 WRITE_BOOL_FIELD(nulls_first);
2694 WRITE_BOOL_FIELD(hashable);
2698 _outGroupingSet(StringInfo str, const GroupingSet *node)
2700 WRITE_NODE_TYPE("GROUPINGSET");
2702 WRITE_ENUM_FIELD(kind, GroupingSetKind);
2703 WRITE_NODE_FIELD(content);
2704 WRITE_LOCATION_FIELD(location);
2708 _outWindowClause(StringInfo str, const WindowClause *node)
2710 WRITE_NODE_TYPE("WINDOWCLAUSE");
2712 WRITE_STRING_FIELD(name);
2713 WRITE_STRING_FIELD(refname);
2714 WRITE_NODE_FIELD(partitionClause);
2715 WRITE_NODE_FIELD(orderClause);
2716 WRITE_INT_FIELD(frameOptions);
2717 WRITE_NODE_FIELD(startOffset);
2718 WRITE_NODE_FIELD(endOffset);
2719 WRITE_UINT_FIELD(winref);
2720 WRITE_BOOL_FIELD(copiedOrder);
2724 _outRowMarkClause(StringInfo str, const RowMarkClause *node)
2726 WRITE_NODE_TYPE("ROWMARKCLAUSE");
2728 WRITE_UINT_FIELD(rti);
2729 WRITE_ENUM_FIELD(strength, LockClauseStrength);
2730 WRITE_ENUM_FIELD(waitPolicy, LockWaitPolicy);
2731 WRITE_BOOL_FIELD(pushedDown);
2735 _outWithClause(StringInfo str, const WithClause *node)
2737 WRITE_NODE_TYPE("WITHCLAUSE");
2739 WRITE_NODE_FIELD(ctes);
2740 WRITE_BOOL_FIELD(recursive);
2741 WRITE_LOCATION_FIELD(location);
2745 _outCommonTableExpr(StringInfo str, const CommonTableExpr *node)
2747 WRITE_NODE_TYPE("COMMONTABLEEXPR");
2749 WRITE_STRING_FIELD(ctename);
2750 WRITE_NODE_FIELD(aliascolnames);
2751 WRITE_NODE_FIELD(ctequery);
2752 WRITE_LOCATION_FIELD(location);
2753 WRITE_BOOL_FIELD(cterecursive);
2754 WRITE_INT_FIELD(cterefcount);
2755 WRITE_NODE_FIELD(ctecolnames);
2756 WRITE_NODE_FIELD(ctecoltypes);
2757 WRITE_NODE_FIELD(ctecoltypmods);
2758 WRITE_NODE_FIELD(ctecolcollations);
2762 _outSetOperationStmt(StringInfo str, const SetOperationStmt *node)
2764 WRITE_NODE_TYPE("SETOPERATIONSTMT");
2766 WRITE_ENUM_FIELD(op, SetOperation);
2767 WRITE_BOOL_FIELD(all);
2768 WRITE_NODE_FIELD(larg);
2769 WRITE_NODE_FIELD(rarg);
2770 WRITE_NODE_FIELD(colTypes);
2771 WRITE_NODE_FIELD(colTypmods);
2772 WRITE_NODE_FIELD(colCollations);
2773 WRITE_NODE_FIELD(groupClauses);
2777 _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
2779 WRITE_NODE_TYPE("RTE");
2781 /* put alias + eref first to make dump more legible */
2782 WRITE_NODE_FIELD(alias);
2783 WRITE_NODE_FIELD(eref);
2784 WRITE_ENUM_FIELD(rtekind, RTEKind);
2786 switch (node->rtekind)
2789 WRITE_OID_FIELD(relid);
2790 WRITE_CHAR_FIELD(relkind);
2791 WRITE_NODE_FIELD(tablesample);
2794 WRITE_NODE_FIELD(subquery);
2795 WRITE_BOOL_FIELD(security_barrier);
2798 WRITE_ENUM_FIELD(jointype, JoinType);
2799 WRITE_NODE_FIELD(joinaliasvars);
2802 WRITE_NODE_FIELD(functions);
2803 WRITE_BOOL_FIELD(funcordinality);
2806 WRITE_NODE_FIELD(values_lists);
2807 WRITE_NODE_FIELD(values_collations);
2810 WRITE_STRING_FIELD(ctename);
2811 WRITE_UINT_FIELD(ctelevelsup);
2812 WRITE_BOOL_FIELD(self_reference);
2813 WRITE_NODE_FIELD(ctecoltypes);
2814 WRITE_NODE_FIELD(ctecoltypmods);
2815 WRITE_NODE_FIELD(ctecolcollations);
2818 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
2822 WRITE_BOOL_FIELD(lateral);
2823 WRITE_BOOL_FIELD(inh);
2824 WRITE_BOOL_FIELD(inFromCl);
2825 WRITE_UINT_FIELD(requiredPerms);
2826 WRITE_OID_FIELD(checkAsUser);
2827 WRITE_BITMAPSET_FIELD(selectedCols);
2828 WRITE_BITMAPSET_FIELD(insertedCols);
2829 WRITE_BITMAPSET_FIELD(updatedCols);
2830 WRITE_NODE_FIELD(securityQuals);
2834 _outRangeTblFunction(StringInfo str, const RangeTblFunction *node)
2836 WRITE_NODE_TYPE("RANGETBLFUNCTION");
2838 WRITE_NODE_FIELD(funcexpr);
2839 WRITE_INT_FIELD(funccolcount);
2840 WRITE_NODE_FIELD(funccolnames);
2841 WRITE_NODE_FIELD(funccoltypes);
2842 WRITE_NODE_FIELD(funccoltypmods);
2843 WRITE_NODE_FIELD(funccolcollations);
2844 WRITE_BITMAPSET_FIELD(funcparams);
2848 _outTableSampleClause(StringInfo str, const TableSampleClause *node)
2850 WRITE_NODE_TYPE("TABLESAMPLECLAUSE");
2852 WRITE_OID_FIELD(tsmhandler);
2853 WRITE_NODE_FIELD(args);
2854 WRITE_NODE_FIELD(repeatable);
2858 _outAExpr(StringInfo str, const A_Expr *node)
2860 WRITE_NODE_TYPE("AEXPR");
2865 appendStringInfoChar(str, ' ');
2866 WRITE_NODE_FIELD(name);
2869 appendStringInfoChar(str, ' ');
2870 WRITE_NODE_FIELD(name);
2871 appendStringInfoString(str, " ANY ");
2874 appendStringInfoChar(str, ' ');
2875 WRITE_NODE_FIELD(name);
2876 appendStringInfoString(str, " ALL ");
2878 case AEXPR_DISTINCT:
2879 appendStringInfoString(str, " DISTINCT ");
2880 WRITE_NODE_FIELD(name);
2883 appendStringInfoString(str, " NULLIF ");
2884 WRITE_NODE_FIELD(name);
2887 appendStringInfoString(str, " OF ");
2888 WRITE_NODE_FIELD(name);
2891 appendStringInfoString(str, " IN ");
2892 WRITE_NODE_FIELD(name);
2895 appendStringInfoString(str, " LIKE ");
2896 WRITE_NODE_FIELD(name);
2899 appendStringInfoString(str, " ILIKE ");
2900 WRITE_NODE_FIELD(name);
2903 appendStringInfoString(str, " SIMILAR ");
2904 WRITE_NODE_FIELD(name);
2907 appendStringInfoString(str, " BETWEEN ");
2908 WRITE_NODE_FIELD(name);
2910 case AEXPR_NOT_BETWEEN:
2911 appendStringInfoString(str, " NOT_BETWEEN ");
2912 WRITE_NODE_FIELD(name);
2914 case AEXPR_BETWEEN_SYM:
2915 appendStringInfoString(str, " BETWEEN_SYM ");
2916 WRITE_NODE_FIELD(name);
2918 case AEXPR_NOT_BETWEEN_SYM:
2919 appendStringInfoString(str, " NOT_BETWEEN_SYM ");
2920 WRITE_NODE_FIELD(name);
2923 appendStringInfoString(str, " PAREN");
2926 appendStringInfoString(str, " ??");
2930 WRITE_NODE_FIELD(lexpr);
2931 WRITE_NODE_FIELD(rexpr);
2932 WRITE_LOCATION_FIELD(location);
2936 _outValue(StringInfo str, const Value *value)
2938 switch (value->type)
2941 appendStringInfo(str, "%ld", value->val.ival);
2946 * We assume the value is a valid numeric literal and so does not
2949 appendStringInfoString(str, value->val.str);
2954 * We use _outToken to provide escaping of the string's content,
2955 * but we don't want it to do anything with an empty string.
2957 appendStringInfoChar(str, '"');
2958 if (value->val.str[0] != '\0')
2959 _outToken(str, value->val.str);
2960 appendStringInfoChar(str, '"');
2963 /* internal representation already has leading 'b' */
2964 appendStringInfoString(str, value->val.str);
2967 /* this is seen only within A_Const, not in transformed trees */
2968 appendStringInfoString(str, "NULL");
2971 elog(ERROR, "unrecognized node type: %d", (int) value->type);
2977 _outColumnRef(StringInfo str, const ColumnRef *node)
2979 WRITE_NODE_TYPE("COLUMNREF");
2981 WRITE_NODE_FIELD(fields);
2982 WRITE_LOCATION_FIELD(location);
2986 _outParamRef(StringInfo str, const ParamRef *node)
2988 WRITE_NODE_TYPE("PARAMREF");
2990 WRITE_INT_FIELD(number);
2991 WRITE_LOCATION_FIELD(location);
2995 _outAConst(StringInfo str, const A_Const *node)
2997 WRITE_NODE_TYPE("A_CONST");
2999 appendStringInfoString(str, " :val ");
3000 _outValue(str, &(node->val));
3001 WRITE_LOCATION_FIELD(location);
3005 _outA_Star(StringInfo str, const A_Star *node)
3007 WRITE_NODE_TYPE("A_STAR");
3011 _outA_Indices(StringInfo str, const A_Indices *node)
3013 WRITE_NODE_TYPE("A_INDICES");
3015 WRITE_BOOL_FIELD(is_slice);
3016 WRITE_NODE_FIELD(lidx);
3017 WRITE_NODE_FIELD(uidx);
3021 _outA_Indirection(StringInfo str, const A_Indirection *node)
3023 WRITE_NODE_TYPE("A_INDIRECTION");
3025 WRITE_NODE_FIELD(arg);
3026 WRITE_NODE_FIELD(indirection);
3030 _outA_ArrayExpr(StringInfo str, const A_ArrayExpr *node)
3032 WRITE_NODE_TYPE("A_ARRAYEXPR");
3034 WRITE_NODE_FIELD(elements);
3035 WRITE_LOCATION_FIELD(location);
3039 _outResTarget(StringInfo str, const ResTarget *node)
3041 WRITE_NODE_TYPE("RESTARGET");
3043 WRITE_STRING_FIELD(name);
3044 WRITE_NODE_FIELD(indirection);
3045 WRITE_NODE_FIELD(val);
3046 WRITE_LOCATION_FIELD(location);
3050 _outMultiAssignRef(StringInfo str, const MultiAssignRef *node)
3052 WRITE_NODE_TYPE("MULTIASSIGNREF");
3054 WRITE_NODE_FIELD(source);
3055 WRITE_INT_FIELD(colno);
3056 WRITE_INT_FIELD(ncolumns);
3060 _outSortBy(StringInfo str, const SortBy *node)
3062 WRITE_NODE_TYPE("SORTBY");
3064 WRITE_NODE_FIELD(node);
3065 WRITE_ENUM_FIELD(sortby_dir, SortByDir);
3066 WRITE_ENUM_FIELD(sortby_nulls, SortByNulls);
3067 WRITE_NODE_FIELD(useOp);
3068 WRITE_LOCATION_FIELD(location);
3072 _outWindowDef(StringInfo str, const WindowDef *node)
3074 WRITE_NODE_TYPE("WINDOWDEF");
3076 WRITE_STRING_FIELD(name);
3077 WRITE_STRING_FIELD(refname);
3078 WRITE_NODE_FIELD(partitionClause);
3079 WRITE_NODE_FIELD(orderClause);
3080 WRITE_INT_FIELD(frameOptions);
3081 WRITE_NODE_FIELD(startOffset);
3082 WRITE_NODE_FIELD(endOffset);
3083 WRITE_LOCATION_FIELD(location);
3087 _outRangeSubselect(StringInfo str, const RangeSubselect *node)
3089 WRITE_NODE_TYPE("RANGESUBSELECT");
3091 WRITE_BOOL_FIELD(lateral);
3092 WRITE_NODE_FIELD(subquery);
3093 WRITE_NODE_FIELD(alias);
3097 _outRangeFunction(StringInfo str, const RangeFunction *node)
3099 WRITE_NODE_TYPE("RANGEFUNCTION");
3101 WRITE_BOOL_FIELD(lateral);
3102 WRITE_BOOL_FIELD(ordinality);
3103 WRITE_BOOL_FIELD(is_rowsfrom);
3104 WRITE_NODE_FIELD(functions);
3105 WRITE_NODE_FIELD(alias);
3106 WRITE_NODE_FIELD(coldeflist);
3110 _outRangeTableSample(StringInfo str, const RangeTableSample *node)
3112 WRITE_NODE_TYPE("RANGETABLESAMPLE");
3114 WRITE_NODE_FIELD(relation);
3115 WRITE_NODE_FIELD(method);
3116 WRITE_NODE_FIELD(args);
3117 WRITE_NODE_FIELD(repeatable);
3118 WRITE_LOCATION_FIELD(location);
3122 _outConstraint(StringInfo str, const Constraint *node)
3124 WRITE_NODE_TYPE("CONSTRAINT");
3126 WRITE_STRING_FIELD(conname);
3127 WRITE_BOOL_FIELD(deferrable);
3128 WRITE_BOOL_FIELD(initdeferred);
3129 WRITE_LOCATION_FIELD(location);
3131 appendStringInfoString(str, " :contype ");
3132 switch (node->contype)
3135 appendStringInfoString(str, "NULL");
3138 case CONSTR_NOTNULL:
3139 appendStringInfoString(str, "NOT_NULL");
3142 case CONSTR_DEFAULT:
3143 appendStringInfoString(str, "DEFAULT");
3144 WRITE_NODE_FIELD(raw_expr);
3145 WRITE_STRING_FIELD(cooked_expr);
3149 appendStringInfoString(str, "CHECK");
3150 WRITE_BOOL_FIELD(is_no_inherit);
3151 WRITE_NODE_FIELD(raw_expr);
3152 WRITE_STRING_FIELD(cooked_expr);
3155 case CONSTR_PRIMARY:
3156 appendStringInfoString(str, "PRIMARY_KEY");
3157 WRITE_NODE_FIELD(keys);
3158 WRITE_NODE_FIELD(options);
3159 WRITE_STRING_FIELD(indexname);
3160 WRITE_STRING_FIELD(indexspace);
3161 /* access_method and where_clause not currently used */
3165 appendStringInfoString(str, "UNIQUE");
3166 WRITE_NODE_FIELD(keys);
3167 WRITE_NODE_FIELD(options);
3168 WRITE_STRING_FIELD(indexname);
3169 WRITE_STRING_FIELD(indexspace);
3170 /* access_method and where_clause not currently used */
3173 case CONSTR_EXCLUSION:
3174 appendStringInfoString(str, "EXCLUSION");
3175 WRITE_NODE_FIELD(exclusions);
3176 WRITE_NODE_FIELD(options);
3177 WRITE_STRING_FIELD(indexname);
3178 WRITE_STRING_FIELD(indexspace);
3179 WRITE_STRING_FIELD(access_method);
3180 WRITE_NODE_FIELD(where_clause);
3183 case CONSTR_FOREIGN:
3184 appendStringInfoString(str, "FOREIGN_KEY");
3185 WRITE_NODE_FIELD(pktable);
3186 WRITE_NODE_FIELD(fk_attrs);
3187 WRITE_NODE_FIELD(pk_attrs);
3188 WRITE_CHAR_FIELD(fk_matchtype);
3189 WRITE_CHAR_FIELD(fk_upd_action);
3190 WRITE_CHAR_FIELD(fk_del_action);
3191 WRITE_NODE_FIELD(old_conpfeqop);
3192 WRITE_OID_FIELD(old_pktable_oid);
3193 WRITE_BOOL_FIELD(skip_validation);
3194 WRITE_BOOL_FIELD(initially_valid);
3197 case CONSTR_ATTR_DEFERRABLE:
3198 appendStringInfoString(str, "ATTR_DEFERRABLE");
3201 case CONSTR_ATTR_NOT_DEFERRABLE:
3202 appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
3205 case CONSTR_ATTR_DEFERRED:
3206 appendStringInfoString(str, "ATTR_DEFERRED");
3209 case CONSTR_ATTR_IMMEDIATE:
3210 appendStringInfoString(str, "ATTR_IMMEDIATE");
3214 appendStringInfo(str, "<unrecognized_constraint %d>",
3215 (int) node->contype);
3223 * converts a Node into ascii string and append it to 'str'
3226 _outNode(StringInfo str, const void *obj)
3229 appendStringInfoString(str, "<>");
3230 else if (IsA(obj, List) ||IsA(obj, IntList) || IsA(obj, OidList))
3232 else if (IsA(obj, Integer) ||
3235 IsA(obj, BitString))
3237 /* nodeRead does not want to see { } around these! */
3238 _outValue(str, obj);
3242 appendStringInfoChar(str, '{');
3243 switch (nodeTag(obj))
3246 _outPlannedStmt(str, obj);
3252 _outResult(str, obj);
3255 _outModifyTable(str, obj);
3258 _outAppend(str, obj);
3261 _outMergeAppend(str, obj);
3263 case T_RecursiveUnion:
3264 _outRecursiveUnion(str, obj);
3267 _outBitmapAnd(str, obj);
3270 _outBitmapOr(str, obj);
3273 _outGather(str, obj);
3279 _outSeqScan(str, obj);
3282 _outSampleScan(str, obj);
3285 _outIndexScan(str, obj);
3287 case T_IndexOnlyScan:
3288 _outIndexOnlyScan(str, obj);
3290 case T_BitmapIndexScan:
3291 _outBitmapIndexScan(str, obj);
3293 case T_BitmapHeapScan:
3294 _outBitmapHeapScan(str, obj);
3297 _outTidScan(str, obj);
3299 case T_SubqueryScan:
3300 _outSubqueryScan(str, obj);
3302 case T_FunctionScan:
3303 _outFunctionScan(str, obj);
3306 _outValuesScan(str, obj);
3309 _outCteScan(str, obj);
3311 case T_WorkTableScan:
3312 _outWorkTableScan(str, obj);
3315 _outForeignScan(str, obj);
3318 _outCustomScan(str, obj);
3324 _outNestLoop(str, obj);
3327 _outMergeJoin(str, obj);
3330 _outHashJoin(str, obj);
3336 _outWindowAgg(str, obj);
3339 _outGroup(str, obj);
3342 _outMaterial(str, obj);
3348 _outUnique(str, obj);
3354 _outSetOp(str, obj);
3357 _outLockRows(str, obj);
3360 _outLimit(str, obj);
3362 case T_NestLoopParam:
3363 _outNestLoopParam(str, obj);
3366 _outPlanRowMark(str, obj);
3368 case T_PlanInvalItem:
3369 _outPlanInvalItem(str, obj);
3372 _outAlias(str, obj);
3375 _outRangeVar(str, obj);
3378 _outIntoClause(str, obj);
3384 _outConst(str, obj);
3387 _outParam(str, obj);
3390 _outAggref(str, obj);
3392 case T_GroupingFunc:
3393 _outGroupingFunc(str, obj);
3396 _outWindowFunc(str, obj);
3399 _outArrayRef(str, obj);
3402 _outFuncExpr(str, obj);
3404 case T_NamedArgExpr:
3405 _outNamedArgExpr(str, obj);
3408 _outOpExpr(str, obj);
3410 case T_DistinctExpr:
3411 _outDistinctExpr(str, obj);
3414 _outNullIfExpr(str, obj);
3416 case T_ScalarArrayOpExpr:
3417 _outScalarArrayOpExpr(str, obj);
3420 _outBoolExpr(str, obj);
3423 _outSubLink(str, obj);
3426 _outSubPlan(str, obj);
3428 case T_AlternativeSubPlan:
3429 _outAlternativeSubPlan(str, obj);
3432 _outFieldSelect(str, obj);
3435 _outFieldStore(str, obj);
3438 _outRelabelType(str, obj);
3441 _outCoerceViaIO(str, obj);
3443 case T_ArrayCoerceExpr:
3444 _outArrayCoerceExpr(str, obj);
3446 case T_ConvertRowtypeExpr:
3447 _outConvertRowtypeExpr(str, obj);
3450 _outCollateExpr(str, obj);
3453 _outCaseExpr(str, obj);
3456 _outCaseWhen(str, obj);
3458 case T_CaseTestExpr:
3459 _outCaseTestExpr(str, obj);
3462 _outArrayExpr(str, obj);
3465 _outRowExpr(str, obj);
3467 case T_RowCompareExpr:
3468 _outRowCompareExpr(str, obj);
3470 case T_CoalesceExpr:
3471 _outCoalesceExpr(str, obj);
3474 _outMinMaxExpr(str, obj);
3477 _outXmlExpr(str, obj);
3480 _outNullTest(str, obj);
3483 _outBooleanTest(str, obj);
3485 case T_CoerceToDomain:
3486 _outCoerceToDomain(str, obj);
3488 case T_CoerceToDomainValue:
3489 _outCoerceToDomainValue(str, obj);
3491 case T_SetToDefault:
3492 _outSetToDefault(str, obj);
3494 case T_CurrentOfExpr:
3495 _outCurrentOfExpr(str, obj);
3497 case T_InferenceElem:
3498 _outInferenceElem(str, obj);
3501 _outTargetEntry(str, obj);
3504 _outRangeTblRef(str, obj);
3507 _outJoinExpr(str, obj);
3510 _outFromExpr(str, obj);
3512 case T_OnConflictExpr:
3513 _outOnConflictExpr(str, obj);
3519 _outIndexPath(str, obj);
3521 case T_BitmapHeapPath:
3522 _outBitmapHeapPath(str, obj);
3524 case T_BitmapAndPath:
3525 _outBitmapAndPath(str, obj);
3527 case T_BitmapOrPath:
3528 _outBitmapOrPath(str, obj);
3531 _outTidPath(str, obj);
3533 case T_SubqueryScanPath:
3534 _outSubqueryScanPath(str, obj);
3537 _outForeignPath(str, obj);
3540 _outCustomPath(str, obj);
3543 _outAppendPath(str, obj);
3545 case T_MergeAppendPath:
3546 _outMergeAppendPath(str, obj);
3549 _outResultPath(str, obj);
3551 case T_MaterialPath:
3552 _outMaterialPath(str, obj);
3555 _outUniquePath(str, obj);
3558 _outGatherPath(str, obj);
3560 case T_ProjectionPath:
3561 _outProjectionPath(str, obj);
3564 _outSortPath(str, obj);
3567 _outGroupPath(str, obj);
3569 case T_UpperUniquePath:
3570 _outUpperUniquePath(str, obj);
3573 _outAggPath(str, obj);
3575 case T_GroupingSetsPath:
3576 _outGroupingSetsPath(str, obj);
3578 case T_MinMaxAggPath:
3579 _outMinMaxAggPath(str, obj);
3581 case T_WindowAggPath:
3582 _outWindowAggPath(str, obj);
3585 _outSetOpPath(str, obj);
3587 case T_RecursiveUnionPath:
3588 _outRecursiveUnionPath(str, obj);
3590 case T_LockRowsPath:
3591 _outLockRowsPath(str, obj);
3593 case T_ModifyTablePath:
3594 _outModifyTablePath(str, obj);
3597 _outLimitPath(str, obj);
3600 _outNestPath(str, obj);
3603 _outMergePath(str, obj);
3606 _outHashPath(str, obj);
3608 case T_PlannerGlobal:
3609 _outPlannerGlobal(str, obj);
3612 _outPlannerInfo(str, obj);
3615 _outRelOptInfo(str, obj);
3617 case T_IndexOptInfo:
3618 _outIndexOptInfo(str, obj);
3620 case T_ForeignKeyOptInfo:
3621 _outForeignKeyOptInfo(str, obj);
3623 case T_EquivalenceClass:
3624 _outEquivalenceClass(str, obj);
3626 case T_EquivalenceMember:
3627 _outEquivalenceMember(str, obj);
3630 _outPathKey(str, obj);
3633 _outPathTarget(str, obj);
3635 case T_ParamPathInfo:
3636 _outParamPathInfo(str, obj);
3638 case T_RestrictInfo:
3639 _outRestrictInfo(str, obj);
3641 case T_PlaceHolderVar:
3642 _outPlaceHolderVar(str, obj);
3644 case T_SpecialJoinInfo:
3645 _outSpecialJoinInfo(str, obj);
3647 case T_AppendRelInfo:
3648 _outAppendRelInfo(str, obj);
3650 case T_PlaceHolderInfo:
3651 _outPlaceHolderInfo(str, obj);
3653 case T_MinMaxAggInfo:
3654 _outMinMaxAggInfo(str, obj);
3656 case T_PlannerParamItem:
3657 _outPlannerParamItem(str, obj);
3660 case T_ExtensibleNode:
3661 _outExtensibleNode(str, obj);
3665 _outCreateStmt(str, obj);
3667 case T_CreateForeignTableStmt:
3668 _outCreateForeignTableStmt(str, obj);
3670 case T_ImportForeignSchemaStmt:
3671 _outImportForeignSchemaStmt(str, obj);
3674 _outIndexStmt(str, obj);
3677 _outNotifyStmt(str, obj);
3679 case T_DeclareCursorStmt:
3680 _outDeclareCursorStmt(str, obj);
3683 _outSelectStmt(str, obj);
3686 _outColumnDef(str, obj);
3689 _outTypeName(str, obj);
3692 _outTypeCast(str, obj);
3694 case T_CollateClause:
3695 _outCollateClause(str, obj);
3698 _outIndexElem(str, obj);
3701 _outQuery(str, obj);
3703 case T_WithCheckOption:
3704 _outWithCheckOption(str, obj);
3706 case T_SortGroupClause:
3707 _outSortGroupClause(str, obj);
3710 _outGroupingSet(str, obj);
3712 case T_WindowClause:
3713 _outWindowClause(str, obj);
3715 case T_RowMarkClause:
3716 _outRowMarkClause(str, obj);
3719 _outWithClause(str, obj);
3721 case T_CommonTableExpr:
3722 _outCommonTableExpr(str, obj);
3724 case T_SetOperationStmt:
3725 _outSetOperationStmt(str, obj);
3727 case T_RangeTblEntry:
3728 _outRangeTblEntry(str, obj);
3730 case T_RangeTblFunction:
3731 _outRangeTblFunction(str, obj);
3733 case T_TableSampleClause:
3734 _outTableSampleClause(str, obj);
3737 _outAExpr(str, obj);
3740 _outColumnRef(str, obj);
3743 _outParamRef(str, obj);
3746 _outAConst(str, obj);
3749 _outA_Star(str, obj);
3752 _outA_Indices(str, obj);
3754 case T_A_Indirection:
3755 _outA_Indirection(str, obj);
3758 _outA_ArrayExpr(str, obj);
3761 _outResTarget(str, obj);
3763 case T_MultiAssignRef:
3764 _outMultiAssignRef(str, obj);
3767 _outSortBy(str, obj);
3770 _outWindowDef(str, obj);
3772 case T_RangeSubselect:
3773 _outRangeSubselect(str, obj);
3775 case T_RangeFunction:
3776 _outRangeFunction(str, obj);
3778 case T_RangeTableSample:
3779 _outRangeTableSample(str, obj);
3782 _outConstraint(str, obj);
3785 _outFuncCall(str, obj);
3788 _outDefElem(str, obj);
3790 case T_TableLikeClause:
3791 _outTableLikeClause(str, obj);
3793 case T_LockingClause:
3794 _outLockingClause(str, obj);
3796 case T_XmlSerialize:
3797 _outXmlSerialize(str, obj);
3803 * This should be an ERROR, but it's too useful to be able to
3804 * dump structures that _outNode only understands part of.
3806 elog(WARNING, "could not dump unrecognized node type: %d",
3807 (int) nodeTag(obj));
3810 appendStringInfoChar(str, '}');
3816 * returns the ascii representation of the Node as a palloc'd string
3819 nodeToString(const void *obj)
3823 /* see stringinfo.h for an explanation of this maneuver */
3824 initStringInfo(&str);
3825 _outNode(&str, obj);