23#ifndef OPT_TRACE_INCLUDED
24#define OPT_TRACE_INCLUDED
520 return do_add(
key, value, strlen(value),
false);
531 return do_add(
nullptr, value, strlen(value),
false);
544 return do_add(
key, value, val_length,
true);
550 return do_add(
nullptr, value, val_length,
true);
556 return do_add(
key, value, strlen(value),
true);
562 return do_add(
nullptr, value, strlen(value),
true);
580 return do_add(
nullptr, item);
588 return do_add(
nullptr, value);
620 return do_add(
nullptr, value);
628 return do_add(
nullptr, value);
636 return do_add(
nullptr, value);
656 return add(
"select#", select_number);
677 const bool old_empty =
empty;
742 size_t val_length,
bool escape);
1068#define OPT_TRACE_TRANSFORM(trace, object_level0, object_level1, \
1069 select_number, from, to) \
1070 const Opt_trace_object object_level0(trace); \
1071 Opt_trace_object object_level1(trace, "transformation"); \
1072 object_level1.add_select_number(select_number); \
1073 object_level1.add_alnum("from", from).add_alnum("to", to);
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:250
Used to store optimizer cost estimates.
Definition: handler.h:3793
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:932
Definition: sql_list.h:433
A JSON array (ordered set of values).
Definition: opt_trace.h:826
Opt_trace_array(Opt_trace_context *ctx, const char *key, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an array.
Definition: opt_trace.h:835
Opt_trace_array(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an array.
Definition: opt_trace.h:845
A per-session context which is always available at any point of execution, because in practice it's a...
Definition: opt_trace_context.h:91
void disable_I_S_for_this_and_children()
Temporarily disables I_S for this trace and its children.
Definition: opt_trace_context.h:258
feature_value
Features' numeric values for @@optimizer_trace_features variable.
Definition: opt_trace_context.h:202
@ MISC
Anything unclassified, including the top object (thus, by "inheritance from parent",...
Definition: opt_trace_context.h:217
bool is_started() const
Returns whether there is a current trace.
Definition: opt_trace_context.h:145
void restore_I_S()
Restores I_S support to what it was before the previous call to disable_I_S_for_this_and_children().
Definition: opt_trace_context.h:267
Instantiate an instance of this class for specific cases where optimizer trace, in a certain section ...
Definition: opt_trace.h:858
Opt_trace_disable_I_S(const Opt_trace_disable_I_S &)
~Opt_trace_disable_I_S()
Destructor. Restores trace's "enabled" property to its previous value.
Definition: opt_trace.h:900
Opt_trace_disable_I_S(Opt_trace_context *ctx_arg, bool disable_arg)
Definition: opt_trace.h:891
Opt_trace_disable_I_S & operator=(const Opt_trace_disable_I_S &)
Opt_trace_context * ctx
Context.
Definition: opt_trace.h:906
Iterator over the list of remembered traces.
Definition: opt_trace.h:406
Opt_trace_iterator(Opt_trace_context *ctx)
Definition: opt_trace.cc:1150
bool at_end() const
Definition: opt_trace.h:427
void get_value(Opt_trace_info *info) const
Provides information about the trace on which the iterator is positioned.
Definition: opt_trace.cc:1159
const Opt_trace_stmt * cursor
trace which the iterator is positioned on
Definition: opt_trace.h:432
Opt_trace_context * ctx
Pointer to context, from which traces are retrieved.
Definition: opt_trace.h:431
void next()
Advances iterator to next trace.
Definition: opt_trace.cc:1155
long row_count
how many traces retrieved so far
Definition: opt_trace.h:433
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:796
Opt_trace_object(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an object.
Definition: opt_trace.h:815
Opt_trace_object(Opt_trace_context *ctx, const char *key, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an object.
Definition: opt_trace.h:805
Definition: opt_trace.h:918
bool error
whether trace start() had an error
Definition: opt_trace.h:952
~Opt_trace_start()
Definition: opt_trace2server.cc:238
Opt_trace_context *const ctx
Definition: opt_trace.h:951
Opt_trace_start(THD *thd_arg, Table_ref *tbl, enum enum_sql_command sql_command, List< set_var_base > *set_vars, const char *query, size_t query_length, sp_printable *instr, const CHARSET_INFO *query_charset)
Instantiate this class to start tracing a THD's actions (generally at a statement's start),...
Definition: opt_trace2server.cc:133
The trace of one statement.
Definition: opt_trace.cc:110
Object and array are both "structured data" and have lots in common, so the Opt_trace_struct is a bas...
Definition: opt_trace.h:445
Opt_trace_struct & add_null(const char *key)
Adds a JSON null object (==Python's "None")
Definition: opt_trace.h:639
Opt_trace_struct & add(const Item *item)
Definition: opt_trace.h:578
Opt_trace_struct & add_select_number(uint select_number)
Helper to put the number of query_block in an object.
Definition: opt_trace.h:655
Opt_trace_struct & do_add_utf8_table(const Table_ref *tab)
Definition: opt_trace.cc:370
char previous_key[25]
Fixed-length prefix of previous key in this structure, if this structure is an object.
Definition: opt_trace.h:787
Opt_trace_struct & add(ulonglong value)
Definition: opt_trace.h:626
const char * saved_key
Key if the structure is the value of a key/value pair, NULL otherwise.
Definition: opt_trace.h:780
~Opt_trace_struct()
Definition: opt_trace.h:473
void do_construct(Opt_trace_context *ctx, bool requires_key, const char *key, Opt_trace_context::feature_value feature)
Full initialization.
Definition: opt_trace.cc:266
void end()
The exception to RAII: this function is an explicit way of ending a structure before it goes out of s...
Definition: opt_trace.h:483
Opt_trace_struct & add(ulong value)
Definition: opt_trace.h:610
void do_destruct()
Really does destruction.
Definition: opt_trace.cc:284
Opt_trace_struct & add(int value)
Definition: opt_trace.h:594
bool started
Whether the structure does tracing or is dummy.
Definition: opt_trace.h:755
Opt_trace_struct & add(const char *key, longlong value)
Definition: opt_trace.h:614
Opt_trace_struct & add(const char *key, const Item *item)
Add a value (of Item type) to the structure.
Definition: opt_trace.h:574
Opt_trace_stmt * stmt
Trace owning the structure.
Definition: opt_trace.h:778
bool requires_key
Whether the structure requires/forbids keys for values inside it.
Definition: opt_trace.h:769
Opt_trace_struct & add(longlong value)
Definition: opt_trace.h:618
bool set_not_empty()
Informs this structure that we are adding data (scalars, structures) to it.
Definition: opt_trace.h:676
Opt_trace_struct & do_add(const char *key, const char *value, size_t val_length, bool escape)
Really adds to the object.
Definition: opt_trace.cc:292
Opt_trace_struct & add(double value)
Definition: opt_trace.h:634
Opt_trace_struct & add_alnum(const char *key, const char *value)
Adds a value (of string type) to the structure.
Definition: opt_trace.h:518
Opt_trace_struct & add(const char *key, uint value)
Definition: opt_trace.h:598
Opt_trace_struct & add(const char *key, double value)
Definition: opt_trace.h:630
Opt_trace_struct & operator=(const Opt_trace_struct &)
not defined
const char * check_key(const char *key)
Validates the key about to be added.
Definition: opt_trace.cc:381
Opt_trace_struct & add_utf8(const char *value)
Variant of add_utf8() where 'value' is 0-terminated.
Definition: opt_trace.h:560
Opt_trace_struct & add(const char *key, ulong value)
Definition: opt_trace.h:606
Opt_trace_struct & add_utf8(const char *key, const char *value, size_t val_length)
Like add_alnum() but supports any UTF8 characters in 'value'.
Definition: opt_trace.h:541
Opt_trace_struct(Opt_trace_context *ctx_arg, bool requires_key_arg, const char *key, Opt_trace_context::feature_value feature)
Definition: opt_trace.h:460
bool has_disabled_I_S
Whether this structure caused tracing to be disabled in this statement because belonging to a not-tra...
Definition: opt_trace.h:776
Opt_trace_struct & add(bool value)
Definition: opt_trace.h:586
Opt_trace_struct & add_utf8(const char *key, const char *value)
Variant of add_utf8() where 'value' is 0-terminated.
Definition: opt_trace.h:554
Opt_trace_struct & add(uint value)
Definition: opt_trace.h:602
Opt_trace_struct & add_utf8(const char *value, size_t val_length)
Variant of add_utf8() for adding to an array (no key)
Definition: opt_trace.h:548
Opt_trace_struct(const Opt_trace_struct &)
not defined
Opt_trace_struct & add(const char *key, const Cost_estimate &cost)
Add a value to the structure.
Definition: opt_trace.h:664
Opt_trace_struct & do_add_null(const char *key)
Definition: opt_trace.cc:343
Opt_trace_struct & add(const char *key, const char *value)
Not implemented, use add_alnum() instead.
bool empty
Definition: opt_trace.h:777
Opt_trace_struct & add(const char *key, bool value)
Definition: opt_trace.h:582
Opt_trace_struct & add(const char *key)
Opt_trace_struct & add_alnum(const char *value)
Adds a value (of string type) to the structure.
Definition: opt_trace.h:529
Opt_trace_struct & add(const char *key, ulonglong value)
Definition: opt_trace.h:622
Opt_trace_struct & add_utf8_table(const Table_ref *tab)
Helper to put the database/table name in an object.
Definition: opt_trace.h:647
Opt_trace_struct & add(const char *key, int value)
Definition: opt_trace.h:590
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1161
Query_block * query_block() const override
The query_block which holds the ORDER BY and LIMIT information for this set operation.
Definition: sql_lex.h:1177
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
A base class for everything that can be set with SET command.
Definition: set_var.h:949
sp_head represents one instance of a stored program.
Definition: sp_head.h:382
sp_printable defines an interface which should be implemented if a class wants report some internal i...
Definition: sp_instr.h:66
Header for compiler-dependent features.
constexpr bool likely(bool expr)
Definition: my_compiler.h:56
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:57
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
long long int longlong
Definition: my_inttypes.h:54
enum_sql_command
Definition: my_sqlcommand.h:45
static char * query
Definition: myisam_ftdump.cc:46
static std::string escape(const std::string &str)
Escapes (only) apostrophes.
Definition: st_units_of_measure.cc:38
void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp)
If tracing is on, checks additional privileges on a stored routine, to make sure that the user has th...
Definition: opt_trace2server.cc:343
void opt_trace_disable_if_no_view_access(THD *thd, Table_ref *view, Table_ref *underlying_tables)
If tracing is on, checks additional privileges for a view, to make sure that the user has the right t...
Definition: opt_trace2server.cc:364
void opt_trace_print_expanded_query(const THD *thd, Query_block *query_block, Opt_trace_object *trace_object)
Prints SELECT query to optimizer trace.
Definition: opt_trace2server.cc:243
int fill_optimizer_trace_info(THD *thd, Table_ref *tables, Item *)
Fills information_schema.OPTIMIZER_TRACE with rows (one per trace)
Definition: opt_trace2server.cc:479
void opt_trace_disable_if_no_security_context_access(THD *thd)
If the security context is not that of the connected user, inform the trace system that a privilege i...
Definition: opt_trace2server.cc:274
This contains the declaration of class Opt_trace_context, which is needed to declare THD.
required string key
Definition: replication_asynchronous_connection_failover.proto:59
Definition: m_ctype.h:422
User-visible information about a trace.
Definition: opt_trace.h:376
size_t missing_bytes
How many bytes this trace is missing (for traces which were truncated because of @@optimizer-trace-ma...
Definition: opt_trace.h:397
size_t trace_length
length of trace string / String containing original query. 0-termination: like trace_ptr.
Definition: opt_trace.h:388
const CHARSET_INFO * query_charset
charset of query string
Definition: opt_trace.h:392
const char * query_ptr
Definition: opt_trace.h:390
const char * trace_ptr
String containing trace.
Definition: opt_trace.h:387
bool missing_priv
whether user lacks privilege to see this trace
Definition: opt_trace.h:398
size_t query_length
length of query string
Definition: opt_trace.h:391