PostgreSQL Source Code  git master
explain.h
Go to the documentation of this file.
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 {
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);
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);
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 
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_num);
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 */
PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook
Definition: explain.c:47
bool summary
Definition: explain.h:37
ExplainFormat
Definition: explain.h:20
void ExplainCloseGroup(const char *objtype, const char *labelname, bool labeled, ExplainState *es)
Definition: explain.c:3707
Bitmapset * printed_subplans
Definition: explain.h:48
struct timeval instr_time
Definition: instr_time.h:150
static struct @145 value
Definition: nodes.h:525
List * deparse_cxt
Definition: explain.h:47
unsigned int Oid
Definition: postgres_ext.h:31
bool costs
Definition: explain.h:34
bool analyze
Definition: explain.h:33
void ExplainPropertyInteger(const char *qlabel, const char *unit, int64 value, ExplainState *es)
Definition: explain.c:3601
TupleDesc ExplainResultDesc(ExplainStmt *stmt)
Definition: explain.c:302
void ExplainPropertyBool(const char *qlabel, bool value, ExplainState *es)
Definition: explain.c:3629
PlannedStmt * pstmt
Definition: explain.h:44
void ExplainPropertyListNested(const char *qlabel, List *data, ExplainState *es)
Definition: explain.c:3486
List * rtable_names
Definition: explain.h:46
#define PGDLLIMPORT
Definition: c.h:1272
struct ExplainState ExplainState
void ExplainPrintJIT(ExplainState *es, int jit_flags, struct JitInstrumentation *jit_instr, int worker_num)
Definition: explain.c:799
void ExplainEndOutput(ExplainState *es)
Definition: explain.c:3820
List * grouping_stack
Definition: explain.h:42
int indent
Definition: explain.h:41
PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook
Definition: explain.c:44
void ExplainPropertyList(const char *qlabel, List *data, ExplainState *es)
Definition: explain.c:3416
bool timing
Definition: explain.h:36
void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:724
void ExplainBeginOutput(ExplainState *es)
Definition: explain.c:3789
bool verbose
Definition: explain.h:32
void ExplainOpenGroup(const char *objtype, const char *labelname, bool labeled, ExplainState *es)
Definition: explain.c:3644
void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest)
Definition: explain.c:142
void ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
Definition: explain.c:390
ExplainFormat format
Definition: explain.h:39
void ExplainSeparatePlans(ExplainState *es)
Definition: explain.c:3849
const char *(* explain_get_index_name_hook_type)(Oid indexId)
Definition: explain.h:62
void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:899
void(* ExplainOneQuery_hook_type)(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
Definition: explain.h:52
ExplainState * NewExplainState(void)
Definition: explain.c:285
void ExplainPrintJITSummary(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:770
bool buffers
Definition: explain.h:35
void ExplainPropertyText(const char *qlabel, const char *value, ExplainState *es)
Definition: explain.c:3592
void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv, const instr_time *planduration)
Definition: explain.c:465
Definition: pg_list.h:50
StringInfo str
Definition: explain.h:30
bool settings
Definition: explain.h:38
void ExplainPropertyFloat(const char *qlabel, const char *unit, double value, int ndigits, ExplainState *es)
Definition: explain.c:3615
List * rtable
Definition: explain.h:45
void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:681