MySQL 8.0.39
Source Code Documentation
|
The trace of one statement. More...
Public Member Functions | |
Opt_trace_stmt (Opt_trace_context *ctx_arg) | |
Constructor, starts a trace for information_schema and dbug. More... | |
void | end () |
Ends a trace; destruction may not be possible immediately as we may have to keep the trace in case the user later reads it from I_S. More... | |
bool | has_ended () const |
void | set_allowed_mem_size (size_t size) |
Sets the quantity of allowed memory for this trace. More... | |
void | set_query (const char *query, size_t length, const CHARSET_INFO *charset) |
bool | open_struct (const char *key, Opt_trace_struct *ots, bool wants_disable_I_S, char opening_bracket) |
When creating an Opt_trace_struct: adds a key and the opening bracket to the trace buffer, updates current_struct. More... | |
void | close_struct (const char *saved_key, bool has_disabled_I_S, char closing_bracket) |
When closing an Opt_trace_struct: More... | |
void | separator () |
Put optional comma, newline and indentation. More... | |
void | next_line () |
Put newline and indentation. More... | |
void | add (const char *key, const char *val, size_t val_length, bool quotes, bool escape) |
Adds a key/value pair to the trace buffer. More... | |
void | fill_info (Opt_trace_info *info) const |
Fills user-level information. More... | |
size_t | alloced_length () const |
void | assert_current_struct (const Opt_trace_struct *s) const |
void | missing_privilege () |
bool | support_I_S () const |
void | disable_I_S () |
Temporarily disables I_S output for this statement. More... | |
void | restore_I_S () |
Restores I_S support to what it was before the previous call to disable_I_S(). More... | |
const char * | make_unknown_key () |
Generate a dummy unique key, and return pointer to it. More... | |
Private Attributes | |
bool | ended |
Whether end() has been called on this instance. More... | |
int | I_S_disabled |
0 <=> this trace should be in information_schema. More... | |
bool | missing_priv |
whether user lacks privilege to see this trace More... | |
Opt_trace_context * | ctx |
context More... | |
Opt_trace_struct * | current_struct |
current open structure More... | |
Prealloced_array< Opt_trace_struct *, 16 > | stack_of_current_structs |
Same logic as Opt_trace_context::stack_of_current_stmts. More... | |
Buffer | trace_buffer |
Where the trace is accumulated. More... | |
Buffer | query_buffer |
Where the original query is put. More... | |
uint | unknown_key_count |
Counter which serves to have unique autogenerated keys, needed if we autogenerate more than one key in a single object. More... | |
char | unknown_key [24] |
Space for last autogenerated key. More... | |
The trace of one statement.
For example, executing a stored procedure containing 3 sub-statements will produce 4 traces (one for the CALL statement, one for each sub-statement), so 4 Opt_trace_stmt linked together into Opt_trace_context's lists.
Opt_trace_stmt::Opt_trace_stmt | ( | Opt_trace_context * | ctx_arg | ) |
Constructor, starts a trace for information_schema and dbug.
ctx_arg | context |
void Opt_trace_stmt::add | ( | const char * | key, |
const char * | val, | ||
size_t | val_length, | ||
bool | quotes, | ||
bool | escape | ||
) |
Adds a key/value pair to the trace buffer.
key | key or NULL |
val | representation of value as string |
val_length | length of value |
quotes | should value be delimited with '"' (false when the value is the representation of a number, boolean or null) |
escape | does value need escaping (has special characters) |
|
inline |
|
inline |
void Opt_trace_stmt::close_struct | ( | const char * | saved_key, |
bool | has_disabled_I_S, | ||
char | closing_bracket | ||
) |
When closing an Opt_trace_struct:
saved_key | key or NULL |
has_disabled_I_S | whether structure had disabled I_S output |
closing_bracket | closing bracket to use |
|
inline |
Temporarily disables I_S output for this statement.
void Opt_trace_stmt::end | ( | void | ) |
Ends a trace; destruction may not be possible immediately as we may have to keep the trace in case the user later reads it from I_S.
void Opt_trace_stmt::fill_info | ( | Opt_trace_info * | info | ) | const |
Fills user-level information.
|
inline |
end()
has been called on this instance. const char * Opt_trace_stmt::make_unknown_key | ( | ) |
Generate a dummy unique key, and return pointer to it.
The pointed data has the lifetime of Opt_trace_stmt, and is overwritten by the next call to this function.
void Opt_trace_stmt::missing_privilege | ( | ) |
void Opt_trace_stmt::next_line | ( | ) |
Put newline and indentation.
bool Opt_trace_stmt::open_struct | ( | const char * | key, |
Opt_trace_struct * | ots, | ||
bool | wants_disable_I_S, | ||
char | opening_bracket | ||
) |
When creating an Opt_trace_struct: adds a key and the opening bracket to the trace buffer, updates current_struct.
key | key or NULL |
ots | structure being created |
wants_disable_I_S | whether structure wants to disable I_S output |
opening_bracket | opening bracket to use |
false | ok |
true | error, Opt_trace_struct must set itself to dummy; trace may have been written to, will likely be invalid JSON. |
|
inline |
Restores I_S support to what it was before the previous call to disable_I_S().
void Opt_trace_stmt::separator | ( | ) |
Put optional comma, newline and indentation.
void Opt_trace_stmt::set_allowed_mem_size | ( | size_t | size | ) |
Sets the quantity of allowed memory for this trace.
void Opt_trace_stmt::set_query | ( | const char * | query, |
size_t | length, | ||
const CHARSET_INFO * | charset | ||
) |
|
inline |
|
private |
context
|
private |
current open structure
|
private |
Whether end()
has been called on this instance.
|
private |
0 <=> this trace should be in information_schema.
In the life of an Opt_trace_stmt, support for I_S may be temporarily disabled. Once disabled, it must stay disabled until re-enabled at the same stack frame. This: Opt_trace_object1 // disables I_S Opt_trace_object2 // re-enables I_S is impossible (the top object wins). So it is sufficient, to keep track of the current state, to have a counter incremented each time we get a request to disable I_S.
|
private |
whether user lacks privilege to see this trace
|
private |
Where the original query is put.
|
private |
Same logic as Opt_trace_context::stack_of_current_stmts.
|
private |
Where the trace is accumulated.
|
private |
Space for last autogenerated key.
|
private |
Counter which serves to have unique autogenerated keys, needed if we autogenerate more than one key in a single object.