1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * explain.h |
4 | * prototypes for explain.c |
5 | * |
6 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
7 | * Portions Copyright (c) 1994-5, Regents of the University of California |
8 | * |
9 | * src/include/commands/explain.h |
10 | * |
11 | *------------------------------------------------------------------------- |
12 | */ |
13 | #ifndef EXPLAIN_H |
14 | #define EXPLAIN_H |
15 | |
16 | #include "executor/executor.h" |
17 | #include "lib/stringinfo.h" |
18 | #include "parser/parse_node.h" |
19 | |
20 | typedef enum ExplainFormat |
21 | { |
22 | EXPLAIN_FORMAT_TEXT, |
23 | EXPLAIN_FORMAT_XML, |
24 | EXPLAIN_FORMAT_JSON, |
25 | EXPLAIN_FORMAT_YAML |
26 | } ExplainFormat; |
27 | |
28 | typedef struct ExplainState |
29 | { |
30 | StringInfo str; /* output buffer */ |
31 | /* options */ |
32 | bool verbose; /* be verbose */ |
33 | bool analyze; /* print actual times */ |
34 | bool costs; /* print estimated costs */ |
35 | bool buffers; /* print buffer usage */ |
36 | bool timing; /* print detailed node timing */ |
37 | bool summary; /* print total planning and execution timing */ |
38 | bool settings; /* print modified settings */ |
39 | ExplainFormat format; /* output format */ |
40 | /* state for output formatting --- not reset for each new plan tree */ |
41 | int indent; /* current indentation level */ |
42 | List *grouping_stack; /* format-specific grouping state */ |
43 | /* state related to the current plan tree (filled by ExplainPrintPlan) */ |
44 | PlannedStmt *pstmt; /* top of plan */ |
45 | List *rtable; /* range table */ |
46 | List *rtable_names; /* alias names for RTEs */ |
47 | List *deparse_cxt; /* context list for deparsing expressions */ |
48 | Bitmapset *printed_subplans; /* ids of SubPlans we've printed */ |
49 | } ExplainState; |
50 | |
51 | /* Hook for plugins to get control in ExplainOneQuery() */ |
52 | typedef void (*ExplainOneQuery_hook_type) (Query *query, |
53 | int cursorOptions, |
54 | IntoClause *into, |
55 | ExplainState *es, |
56 | const char *queryString, |
57 | ParamListInfo params, |
58 | QueryEnvironment *queryEnv); |
59 | extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook; |
60 | |
61 | /* Hook for plugins to get control in explain_get_index_name() */ |
62 | typedef const char *(*explain_get_index_name_hook_type) (Oid indexId); |
63 | extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook; |
64 | |
65 | |
66 | extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, |
67 | ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest); |
68 | |
69 | extern ExplainState *NewExplainState(void); |
70 | |
71 | extern TupleDesc ExplainResultDesc(ExplainStmt *stmt); |
72 | |
73 | extern void ExplainOneUtility(Node *utilityStmt, IntoClause *into, |
74 | ExplainState *es, const char *queryString, |
75 | ParamListInfo params, QueryEnvironment *queryEnv); |
76 | |
77 | extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, |
78 | ExplainState *es, const char *queryString, |
79 | ParamListInfo params, QueryEnvironment *queryEnv, |
80 | const instr_time *planduration); |
81 | |
82 | extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc); |
83 | extern void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc); |
84 | |
85 | extern void ExplainPrintJITSummary(ExplainState *es, QueryDesc *queryDesc); |
86 | extern void ExplainPrintJIT(ExplainState *es, int jit_flags, |
87 | struct JitInstrumentation *jit_instr, int worker_i); |
88 | |
89 | extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc); |
90 | |
91 | extern void ExplainBeginOutput(ExplainState *es); |
92 | extern void ExplainEndOutput(ExplainState *es); |
93 | extern void ExplainSeparatePlans(ExplainState *es); |
94 | |
95 | extern void ExplainPropertyList(const char *qlabel, List *data, |
96 | ExplainState *es); |
97 | extern void ExplainPropertyListNested(const char *qlabel, List *data, |
98 | ExplainState *es); |
99 | extern void ExplainPropertyText(const char *qlabel, const char *value, |
100 | ExplainState *es); |
101 | extern void ExplainPropertyInteger(const char *qlabel, const char *unit, |
102 | int64 value, ExplainState *es); |
103 | extern void ExplainPropertyFloat(const char *qlabel, const char *unit, |
104 | double value, int ndigits, ExplainState *es); |
105 | extern void ExplainPropertyBool(const char *qlabel, bool value, |
106 | ExplainState *es); |
107 | |
108 | extern void ExplainOpenGroup(const char *objtype, const char *labelname, |
109 | bool labeled, ExplainState *es); |
110 | extern void ExplainCloseGroup(const char *objtype, const char *labelname, |
111 | bool labeled, ExplainState *es); |
112 | |
113 | #endif /* EXPLAIN_H */ |
114 | |