PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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);
58 
59 /* Hook for plugins to get control in explain_get_index_name() */
60 typedef const char *(*explain_get_index_name_hook_type) (Oid indexId);
62 
63 
64 extern void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
65  ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest);
66 
67 extern ExplainState *NewExplainState(void);
68 
70 
71 extern void ExplainOneUtility(Node *utilityStmt, IntoClause *into,
72  ExplainState *es, const char *queryString,
73  ParamListInfo params, QueryEnvironment *queryEnv);
74 
75 extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into,
76  ExplainState *es, const char *queryString,
77  ParamListInfo params, QueryEnvironment *queryEnv,
78  const instr_time *planduration);
79 
80 extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc);
81 extern void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc);
82 
83 extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc);
84 
85 extern void ExplainBeginOutput(ExplainState *es);
86 extern void ExplainEndOutput(ExplainState *es);
87 extern void ExplainSeparatePlans(ExplainState *es);
88 
89 extern void ExplainPropertyList(const char *qlabel, List *data,
90  ExplainState *es);
91 extern void ExplainPropertyListNested(const char *qlabel, List *data,
92  ExplainState *es);
93 extern void ExplainPropertyText(const char *qlabel, const char *value,
94  ExplainState *es);
95 extern void ExplainPropertyInteger(const char *qlabel, int value,
96  ExplainState *es);
97 extern void ExplainPropertyLong(const char *qlabel, long value,
98  ExplainState *es);
99 extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits,
100  ExplainState *es);
101 extern void ExplainPropertyBool(const char *qlabel, bool value,
102  ExplainState *es);
103 
104 extern void ExplainOpenGroup(const char *objtype, const char *labelname,
105  bool labeled, ExplainState *es);
106 extern void ExplainCloseGroup(const char *objtype, const char *labelname,
107  bool labeled, ExplainState *es);
108 
109 #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:3340
Bitmapset * printed_subplans
Definition: explain.h:47
struct timeval instr_time
Definition: instr_time.h:147
void ExplainPropertyLong(const char *qlabel, long value, ExplainState *es)
Definition: explain.c:3236
Definition: nodes.h:509
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
TupleDesc ExplainResultDesc(ExplainStmt *stmt)
Definition: explain.c:298
void ExplainPropertyBool(const char *qlabel, bool value, ExplainState *es)
Definition: explain.c:3262
PlannedStmt * pstmt
Definition: explain.h:43
void ExplainPropertyListNested(const char *qlabel, List *data, ExplainState *es)
Definition: explain.c:3114
List * rtable_names
Definition: explain.h:45
#define PGDLLIMPORT
Definition: c.h:1052
struct ExplainState ExplainState
void ExplainEndOutput(ExplainState *es)
Definition: explain.c:3453
static struct @121 value
List * grouping_stack
Definition: explain.h:41
int indent
Definition: explain.h:40
PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook
Definition: explain.c:44
void ExplainPropertyList(const char *qlabel, List *data, ExplainState *es)
Definition: explain.c:3044
bool timing
Definition: explain.h:36
void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:650
void ExplainBeginOutput(ExplainState *es)
Definition: explain.c:3422
const char *(* explain_get_index_name_hook_type)(Oid indexId)
Definition: explain.h:60
bool verbose
Definition: explain.h:32
void ExplainOpenGroup(const char *objtype, const char *labelname, bool labeled, ExplainState *es)
Definition: explain.c:3277
void ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest)
Definition: explain.c:141
void ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params, QueryEnvironment *queryEnv)
Definition: explain.c:386
void ExplainPropertyInteger(const char *qlabel, int value, ExplainState *es)
Definition: explain.c:3224
ExplainFormat format
Definition: explain.h:38
void ExplainSeparatePlans(ExplainState *es)
Definition: explain.c:3482
void ExplainPropertyFloat(const char *qlabel, double value, int ndigits, ExplainState *es)
Definition: explain.c:3249
void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:697
ExplainState * NewExplainState(void)
Definition: explain.c:281
bool buffers
Definition: explain.h:35
void ExplainPropertyText(const char *qlabel, const char *value, ExplainState *es)
Definition: explain.c:3215
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
List * rtable
Definition: explain.h:44
void(* ExplainOneQuery_hook_type)(Query *query, int cursorOptions, IntoClause *into, ExplainState *es, const char *queryString, ParamListInfo params)
Definition: explain.h:51
void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc)
Definition: explain.c:613