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-2018, 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  ExplainFormat format; /* output format */
39  /* state for output formatting --- not reset for each new plan tree */
40  int indent; /* current indentation level */
41  List *grouping_stack; /* format-specific grouping state */
42  /* state related to the current plan tree (filled by ExplainPrintPlan) */
43  PlannedStmt *pstmt; /* top of plan */
44  List *rtable; /* range table */
45  List *rtable_names; /* alias names for RTEs */
46  List *deparse_cxt; /* context list for deparsing expressions */
47  Bitmapset *printed_subplans; /* ids of SubPlans we've printed */
48 } ExplainState;
49 
50 /* Hook for plugins to get control in ExplainOneQuery() */
51 typedef void (*ExplainOneQuery_hook_type) (Query *query,
52  int cursorOptions,
53  IntoClause *into,
54  ExplainState *es,
55  const char *queryString,
56  ParamListInfo params,
57  QueryEnvironment *queryEnv);
59 
60 /* Hook for plugins to get control in explain_get_index_name() */
61 typedef const char *(*explain_get_index_name_hook_type) (Oid indexId);
63 
64 
65 extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
66  ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest);
67 
68 extern ExplainState *NewExplainState(void);
69 
71 
72 extern void ExplainOneUtility(Node *utilityStmt, IntoClause *into,
73  ExplainState *es, const char *queryString,
74  ParamListInfo params, QueryEnvironment *queryEnv);
75 
76 extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into,
77  ExplainState *es, const char *queryString,
78  ParamListInfo params, QueryEnvironment *queryEnv,
79  const instr_time *planduration);
80 
81 extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc);
82 extern void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc);
83 
84 extern void ExplainPrintJIT(ExplainState *es, QueryDesc *queryDesc);
85 
86 extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc);
87 
88 extern void ExplainBeginOutput(ExplainState *es);
89 extern void ExplainEndOutput(ExplainState *es);
90 extern void ExplainSeparatePlans(ExplainState *es);
91 
92 extern void ExplainPropertyList(const char *qlabel, List *data,
93  ExplainState *es);
94 extern void ExplainPropertyListNested(const char *qlabel, List *data,
95  ExplainState *es);
96 extern void ExplainPropertyText(const char *qlabel, const char *value,
97  ExplainState *es);
98 extern void ExplainPropertyInteger(const char *qlabel, const char *unit,
99  int64 value, ExplainState *es);
100 extern void ExplainPropertyFloat(const char *qlabel, const char *unit,
101  double value, int ndigits, ExplainState *es);
102 extern void ExplainPropertyBool(const char *qlabel, bool value,
103  ExplainState *es);
104 
105 extern void ExplainOpenGroup(const char *objtype, const char *labelname,
106  bool labeled, ExplainState *es);
107 extern void ExplainCloseGroup(const char *objtype, const char *labelname,
108  bool labeled, ExplainState *es);
109 
110 #endif /* EXPLAIN_H */
PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook
Definition: explain.c:48
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:3517
Bitmapset * printed_subplans
Definition: explain.h:47
struct timeval instr_time
Definition: instr_time.h:147
Definition: nodes.h:517
List * deparse_cxt
Definition: explain.h:46
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:3411
TupleDesc ExplainResultDesc(ExplainStmt *stmt)
Definition: explain.c:300
void ExplainPropertyBool(const char *qlabel, bool value, ExplainState *es)
Definition: explain.c:3439
PlannedStmt * pstmt
Definition: explain.h:43
void ExplainPropertyListNested(const char *qlabel, List *data, ExplainState *es)
Definition: explain.c:3296
List * rtable_names
Definition: explain.h:45
#define PGDLLIMPORT
Definition: c.h:1105
struct ExplainState ExplainState
void ExplainEndOutput(ExplainState *es)
Definition: explain.c:3630
List * grouping_stack
Definition: explain.h:41
int indent
Definition: explain.h:40
PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook
Definition: explain.c:45
void ExplainPropertyList(const char *qlabel, List *data, ExplainState *es)
Definition: explain.c:3226
bool timing
Definition: explain.h:36
void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:650
void ExplainBeginOutput(ExplainState *es)
Definition: explain.c:3599
bool verbose
Definition: explain.h:32
static struct @131 value
void ExplainOpenGroup(const char *objtype, const char *labelname, bool labeled, ExplainState *es)
Definition: explain.c:3454
void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest)
Definition: explain.c:143
void ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
Definition: explain.c:388
ExplainFormat format
Definition: explain.h:38
void ExplainSeparatePlans(ExplainState *es)
Definition: explain.c:3659
const char *(* explain_get_index_name_hook_type)(Oid indexId)
Definition: explain.h:61
void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:748
void ExplainPrintJIT(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:696
void(* ExplainOneQuery_hook_type)(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
Definition: explain.h:51
ExplainState * NewExplainState(void)
Definition: explain.c:283
bool buffers
Definition: explain.h:35
void ExplainPropertyText(const char *qlabel, const char *value, ExplainState *es)
Definition: explain.c:3402
void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv, const instr_time *planduration)
Definition: explain.c:463
Definition: pg_list.h:45
StringInfo str
Definition: explain.h:30
void ExplainPropertyFloat(const char *qlabel, const char *unit, double value, int ndigits, ExplainState *es)
Definition: explain.c:3425
List * rtable
Definition: explain.h:44
void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:613