24#ifndef OPT_TRACE_INCLUDED
25#define OPT_TRACE_INCLUDED
521 return do_add(
key, value, strlen(value),
false);
532 return do_add(
nullptr, value, strlen(value),
false);
545 return do_add(
key, value, val_length,
true);
551 return do_add(
nullptr, value, val_length,
true);
557 return do_add(
key, value, strlen(value),
true);
563 return do_add(
nullptr, value, strlen(value),
true);
581 return do_add(
nullptr, item);
591 return do_add(
nullptr, value);
623 return do_add(
nullptr, value);
631 return do_add(
nullptr, value);
639 return do_add(
nullptr, value);
659 return add(
"select#", select_number);
680 const bool old_empty =
empty;
745 size_t val_length,
bool escape);
1071#define OPT_TRACE_TRANSFORM(trace, object_level0, object_level1, \
1072 select_number, from, to) \
1073 Opt_trace_object object_level0(trace); \
1074 Opt_trace_object object_level1(trace, "transformation"); \
1075 object_level1.add_select_number(select_number); \
1076 object_level1.add_alnum("from", from).add_alnum("to", to);
Used to store optimizer cost estimates.
Definition: handler.h:3706
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
Definition: sql_list.h:434
A JSON array (ordered set of values).
Definition: opt_trace.h:829
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:838
Opt_trace_array(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an array.
Definition: opt_trace.h:848
A per-session context which is always available at any point of execution, because in practice it's a...
Definition: opt_trace_context.h:90
void disable_I_S_for_this_and_children()
Temporarily disables I_S for this trace and its children.
Definition: opt_trace_context.h:257
feature_value
Features' numeric values for @@optimizer_trace_features variable.
Definition: opt_trace_context.h:201
@ MISC
Anything unclassified, including the top object (thus, by "inheritance from parent",...
Definition: opt_trace_context.h:216
bool is_started() const
Returns whether there is a current trace.
Definition: opt_trace_context.h:144
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:266
Instantiate an instance of this class for specific cases where optimizer trace, in a certain section ...
Definition: opt_trace.h:861
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:903
Opt_trace_disable_I_S(Opt_trace_context *ctx_arg, bool disable_arg)
Definition: opt_trace.h:894
Opt_trace_disable_I_S & operator=(const Opt_trace_disable_I_S &)
Opt_trace_context * ctx
Context.
Definition: opt_trace.h:909
Iterator over the list of remembered traces.
Definition: opt_trace.h:407
Opt_trace_iterator(Opt_trace_context *ctx)
Definition: opt_trace.cc:1148
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:1157
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:1153
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:799
Opt_trace_object(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an object.
Definition: opt_trace.h:818
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:808
Definition: opt_trace.h:921
bool error
whether trace start() had an error
Definition: opt_trace.h:955
~Opt_trace_start()
Definition: opt_trace2server.cc:239
Opt_trace_context *const ctx
Definition: opt_trace.h:954
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:108
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:642
Opt_trace_struct & add_select_number(uint select_number)
Helper to put the number of query_block in an object.
Definition: opt_trace.h:658
Opt_trace_struct & do_add_utf8_table(const Table_ref *tab)
Definition: opt_trace.cc:368
char previous_key[25]
Fixed-length prefix of previous key in this structure, if this structure is an object.
Definition: opt_trace.h:790
Opt_trace_struct & add(ulonglong value)
Definition: opt_trace.h:629
const char * saved_key
Key if the structure is the value of a key/value pair, NULL otherwise.
Definition: opt_trace.h:783
~Opt_trace_struct()
Definition: opt_trace.h:474
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:264
Opt_trace_struct & add(Item *item)
Definition: opt_trace.h:579
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:484
Opt_trace_struct & add(ulong value)
Definition: opt_trace.h:613
void do_destruct()
Really does destruction.
Definition: opt_trace.cc:282
Opt_trace_struct & add(int value)
Definition: opt_trace.h:597
bool started
Whether the structure does tracing or is dummy.
Definition: opt_trace.h:758
Opt_trace_struct & add(const char *key, longlong value)
Definition: opt_trace.h:617
Opt_trace_stmt * stmt
Trace owning the structure.
Definition: opt_trace.h:781
bool requires_key
Whether the structure requires/forbids keys for values inside it.
Definition: opt_trace.h:772
Opt_trace_struct & add(longlong value)
Definition: opt_trace.h:621
bool set_not_empty()
Informs this structure that we are adding data (scalars, structures) to it.
Definition: opt_trace.h:679
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:290
Opt_trace_struct & add(double value)
Definition: opt_trace.h:637
Opt_trace_struct & add_alnum(const char *key, const char *value)
Adds a value (of string type) to the structure.
Definition: opt_trace.h:519
Opt_trace_struct & add(const char *key, uint value)
Definition: opt_trace.h:601
Opt_trace_struct & add(const char *key, double value)
Definition: opt_trace.h:633
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:379
Opt_trace_struct & add_utf8(const char *value)
Variant of add_utf8() where 'value' is 0-terminated.
Definition: opt_trace.h:561
Opt_trace_struct & add(const char *key, ulong value)
Definition: opt_trace.h:609
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:542
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:779
Opt_trace_struct & add(bool value)
Definition: opt_trace.h:589
Opt_trace_struct & add(const char *key, Item *item)
Add a value (of Item type) to the structure.
Definition: opt_trace.h:575
Opt_trace_struct & add_utf8(const char *key, const char *value)
Variant of add_utf8() where 'value' is 0-terminated.
Definition: opt_trace.h:555
Opt_trace_struct & add(uint value)
Definition: opt_trace.h:605
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:549
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:667
Opt_trace_struct & do_add_null(const char *key)
Definition: opt_trace.cc:341
Opt_trace_struct & add(const char *key, const char *value)
Not implemented, use add_alnum() instead.
bool empty
Definition: opt_trace.h:780
Opt_trace_struct & add(const char *key, bool value)
Definition: opt_trace.h:585
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:530
Opt_trace_struct & add(const char *key, ulonglong value)
Definition: opt_trace.h:625
Opt_trace_struct & add_utf8_table(const Table_ref *tab)
Helper to put the database/table name in an object.
Definition: opt_trace.h:650
Opt_trace_struct & add(const char *key, int value)
Definition: opt_trace.h:593
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1156
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:1172
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
A base class for everything that can be set with SET command.
Definition: set_var.h:943
sp_head represents one instance of a stored program.
Definition: sp_head.h:380
sp_printable defines an interface which should be implemented if a class wants report some internal i...
Definition: sp_instr.h:67
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
Header for compiler-dependent features.
constexpr bool likely(bool expr)
Definition: my_compiler.h:55
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:56
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:45
static std::string escape(const std::string &str)
Escapes (only) apostrophes.
Definition: st_units_of_measure.cc:37
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:385
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
unsigned int uint
Definition: uca9-dump.cc:75