24#ifndef OPT_TRACE_INCLUDED
25#define OPT_TRACE_INCLUDED
526 return do_add(
key, value, strlen(value),
false);
537 return do_add(
nullptr, value, strlen(value),
false);
550 return do_add(
key, value, val_length,
true);
556 return do_add(
nullptr, value, val_length,
true);
562 return do_add(
key, value, strlen(value),
true);
568 return do_add(
nullptr, value, strlen(value),
true);
586 return do_add(
nullptr, item);
594 return do_add(
nullptr, value);
626 return do_add(
nullptr, value);
634 return do_add(
nullptr, value);
642 return do_add(
nullptr, value);
662 return add(
"select#", select_number);
683 const bool old_empty =
empty;
748 size_t val_length,
bool escape);
1074#define OPT_TRACE_TRANSFORM(trace, object_level0, object_level1, \
1075 select_number, from, to) \
1076 const Opt_trace_object object_level0(trace); \
1077 Opt_trace_object object_level1(trace, "transformation"); \
1078 object_level1.add_select_number(select_number); \
1079 object_level1.add_alnum("from", from).add_alnum("to", to);
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Used to store optimizer cost estimates.
Definition: handler.h:3865
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
Definition: sql_list.h:467
A JSON array (ordered set of values).
Definition: opt_trace.h:832
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:841
Opt_trace_array(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an array.
Definition: opt_trace.h:851
A per-session context which is always available at any point of execution, because in practice it's a...
Definition: opt_trace_context.h:93
void disable_I_S_for_this_and_children()
Temporarily disables I_S for this trace and its children.
Definition: opt_trace_context.h:260
feature_value
Features' numeric values for @@optimizer_trace_features variable.
Definition: opt_trace_context.h:204
@ MISC
Anything unclassified, including the top object (thus, by "inheritance from parent",...
Definition: opt_trace_context.h:219
bool is_started() const
Returns whether there is a current trace.
Definition: opt_trace_context.h:147
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:269
Instantiate an instance of this class for specific cases where optimizer trace, in a certain section ...
Definition: opt_trace.h:864
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:906
Opt_trace_disable_I_S(Opt_trace_context *ctx_arg, bool disable_arg)
Definition: opt_trace.h:897
Opt_trace_disable_I_S & operator=(const Opt_trace_disable_I_S &)
Opt_trace_context * ctx
Context.
Definition: opt_trace.h:912
Iterator over the list of remembered traces.
Definition: opt_trace.h:407
Opt_trace_iterator(Opt_trace_context *ctx)
Definition: opt_trace.cc:1151
bool at_end() const
Definition: opt_trace.h:428
void get_value(Opt_trace_info *info) const
Provides information about the trace on which the iterator is positioned.
Definition: opt_trace.cc:1160
const Opt_trace_stmt * cursor
trace which the iterator is positioned on
Definition: opt_trace.h:433
Opt_trace_context * ctx
Pointer to context, from which traces are retrieved.
Definition: opt_trace.h:432
void next()
Advances iterator to next trace.
Definition: opt_trace.cc:1156
long row_count
how many traces retrieved so far
Definition: opt_trace.h:434
A JSON object (unordered set of key/value pairs).
Definition: opt_trace.h:802
Opt_trace_object(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an object.
Definition: opt_trace.h:821
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:811
Definition: opt_trace.h:924
bool error
whether trace start() had an error
Definition: opt_trace.h:958
~Opt_trace_start()
Definition: opt_trace2server.cc:239
Opt_trace_context *const ctx
Definition: opt_trace.h:957
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:134
The trace of one statement.
Definition: opt_trace.cc:111
Object and array are both "structured data" and have lots in common, so the Opt_trace_struct is a bas...
Definition: opt_trace.h:446
Opt_trace_struct & add_null(const char *key)
Adds a JSON null object (==Python's "None")
Definition: opt_trace.h:645
Opt_trace_struct & add(const Item *item)
Definition: opt_trace.h:584
Opt_trace_struct & add_select_number(uint select_number)
Helper to put the number of query_block in an object.
Definition: opt_trace.h:661
Opt_trace_struct & do_add_utf8_table(const Table_ref *tab)
Definition: opt_trace.cc:371
char previous_key[25]
Fixed-length prefix of previous key in this structure, if this structure is an object.
Definition: opt_trace.h:793
Opt_trace_struct & add(ulonglong value)
Definition: opt_trace.h:632
const char * saved_key
Key if the structure is the value of a key/value pair, NULL otherwise.
Definition: opt_trace.h:786
~Opt_trace_struct()
Definition: opt_trace.h:479
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:267
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:489
Opt_trace_struct & add(ulong value)
Definition: opt_trace.h:616
void do_destruct()
Really does destruction.
Definition: opt_trace.cc:285
Opt_trace_struct & add(int value)
Definition: opt_trace.h:600
bool started
Whether the structure does tracing or is dummy.
Definition: opt_trace.h:761
Opt_trace_struct & add(const char *key, longlong value)
Definition: opt_trace.h:620
Opt_trace_struct & add(const char *key, const Item *item)
Add a value (of Item type) to the structure.
Definition: opt_trace.h:580
Opt_trace_stmt * stmt
Trace owning the structure.
Definition: opt_trace.h:784
bool requires_key
Whether the structure requires/forbids keys for values inside it.
Definition: opt_trace.h:775
Opt_trace_struct & add(longlong value)
Definition: opt_trace.h:624
bool set_not_empty()
Informs this structure that we are adding data (scalars, structures) to it.
Definition: opt_trace.h:682
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:293
Opt_trace_struct & add(double value)
Definition: opt_trace.h:640
Opt_trace_struct & add_alnum(const char *key, const char *value)
Adds a value (of string type) to the structure.
Definition: opt_trace.h:524
Opt_trace_struct & add(const char *key, uint value)
Definition: opt_trace.h:604
Opt_trace_struct & add(const char *key, double value)
Definition: opt_trace.h:636
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:382
Opt_trace_struct & add_utf8(const char *value)
Variant of add_utf8() where 'value' is 0-terminated.
Definition: opt_trace.h:566
Opt_trace_struct & add(const char *key, ulong value)
Definition: opt_trace.h:612
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:547
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:461
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:782
Opt_trace_struct & add(bool value)
Definition: opt_trace.h:592
Opt_trace_struct & add_utf8(const char *key, const char *value)
Variant of add_utf8() where 'value' is 0-terminated.
Definition: opt_trace.h:560
Opt_trace_struct & add(uint value)
Definition: opt_trace.h:608
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:554
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:670
Opt_trace_struct & do_add_null(const char *key)
Definition: opt_trace.cc:344
Opt_trace_struct & add(const char *key, const char *value)
Not implemented, use add_alnum() instead.
bool empty
Definition: opt_trace.h:783
Opt_trace_struct & add(const char *key, bool value)
Definition: opt_trace.h:588
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:535
Opt_trace_struct & add(const char *key, ulonglong value)
Definition: opt_trace.h:628
Opt_trace_struct & add_utf8_table(const Table_ref *tab)
Helper to put the database/table name in an object.
Definition: opt_trace.h:653
Opt_trace_struct & add(const char *key, int value)
Definition: opt_trace.h:596
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1163
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:1179
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
A base class for everything that can be set with SET command.
Definition: set_var.h:950
sp_head represents one instance of a stored program.
Definition: sp_head.h:383
sp_printable defines an interface which should be implemented if a class wants report some internal i...
Definition: sp_instr.h:67
Header for compiler-dependent features.
constexpr bool likely(bool expr)
Definition: my_compiler.h:57
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:58
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
long long int longlong
Definition: my_inttypes.h:55
enum_sql_command
Definition: my_sqlcommand.h:46
static char * query
Definition: myisam_ftdump.cc:47
static std::string escape(const std::string &str)
Escapes (only) apostrophes.
Definition: st_units_of_measure.cc:39
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:344
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:365
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:244
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:480
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:275
This contains the declaration of class Opt_trace_context, which is needed to declare THD.
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Definition: m_ctype.h:423
User-visible information about a trace.
Definition: opt_trace.h:377
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:398
size_t trace_length
length of trace string / String containing original query. 0-termination: like trace_ptr.
Definition: opt_trace.h:389
const CHARSET_INFO * query_charset
charset of query string
Definition: opt_trace.h:393
const char * query_ptr
Definition: opt_trace.h:391
const char * trace_ptr
String containing trace.
Definition: opt_trace.h:388
bool missing_priv
whether user lacks privilege to see this trace
Definition: opt_trace.h:399
size_t query_length
length of query string
Definition: opt_trace.h:392