blob: e5df16b1e3b6b20dcb8a7834fc93cf1f1d608a21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#ifndef OPT_TRACE_CONTEXT_INCLUDED
#define OPT_TRACE_CONTEXT_INCLUDED
#include "sql_array.h"
class Opt_trace_stmt;
class Opt_trace_context
{
public:
Opt_trace_context();
~Opt_trace_context();
void start(THD *thd, TABLE_LIST *tbl,
enum enum_sql_command sql_command,
const char *query,
size_t query_length,
const CHARSET_INFO *query_charset,
ulong max_mem_size_arg);
void end();
void set_query(const char *query, size_t length, const CHARSET_INFO *charset);
void delete_traces();
void set_allowed_mem_size(size_t mem_size);
size_t remaining_mem_size();
private:
Opt_trace_stmt* top_trace()
{
return *(traces.front());
}
public:
/*
This returns the top trace from the list of traces. This function
is used when we want to see the contents of the INFORMATION_SCHEMA.OPTIMIZER_TRACE
table.
*/
Opt_trace_stmt* get_top_trace()
{
if (!traces.elements())
return NULL;
return top_trace();
}
/*
This returns the current trace, to which we are still writing and has not been finished
*/
Json_writer* get_current_json();
bool empty()
{
return static_cast<uint>(traces.elements()) == 0;
}
bool is_started()
{
return current_trace && is_enabled();
}
bool disable_tracing_if_required();
bool enable_tracing_if_required();
bool is_enabled();
void missing_privilege();
static const char *flag_names[];
enum
{
FLAG_DEFAULT = 0,
FLAG_ENABLED = 1 << 0
};
private:
/*
List of traces (currently it stores only 1 trace)
*/
Dynamic_array<Opt_trace_stmt*> traces;
Opt_trace_stmt *current_trace;
size_t max_mem_size;
};
#endif /* OPT_TRACE_CONTEXT_INCLUDED */
|