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);
590 return do_add(
nullptr, value);
622 return do_add(
nullptr, value);
630 return do_add(
nullptr, value);
638 return do_add(
nullptr, value);
658 return add(
"select#", select_number);
679 const bool old_empty =
empty;
744 size_t val_length,
bool escape);
1070#define OPT_TRACE_TRANSFORM(trace, object_level0, object_level1, \
1071 select_number, from, to) \
1072 Opt_trace_object object_level0(trace); \
1073 Opt_trace_object object_level1(trace, "transformation"); \
1074 object_level1.add_select_number(select_number); \
1075 object_level1.add_alnum("from", from).add_alnum("to", to);
Used to store optimizer cost estimates.
Definition: handler.h:3657
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:850
Definition: sql_list.h:433
A JSON array (ordered set of values).
Definition: opt_trace.h:828
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:837
Opt_trace_array(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an array.
Definition: opt_trace.h:847
A per-session context which is always available at any point of execution, because in practice it's a...
Definition: opt_trace_context.h:89
void disable_I_S_for_this_and_children()
Temporarily disables I_S for this trace and its children.
Definition: opt_trace_context.h:256
feature_value
Features' numeric values for @@optimizer_trace_features variable.
Definition: opt_trace_context.h:200
@ MISC
Anything unclassified, including the top object (thus, by "inheritance from parent",...
Definition: opt_trace_context.h:215
bool is_started() const
Returns whether there is a current trace.
Definition: opt_trace_context.h:143
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:265
Instantiate an instance of this class for specific cases where optimizer trace, in a certain section ...
Definition: opt_trace.h:860
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:902
Opt_trace_disable_I_S(Opt_trace_context *ctx_arg, bool disable_arg)
Definition: opt_trace.h:893
Opt_trace_disable_I_S & operator=(const Opt_trace_disable_I_S &)
Opt_trace_context * ctx
Context.
Definition: opt_trace.h:908
Iterator over the list of remembered traces.
Definition: opt_trace.h:406
Opt_trace_iterator(Opt_trace_context *ctx)
Definition: opt_trace.cc:1147
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:1156
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:1152
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:798
Opt_trace_object(Opt_trace_context *ctx, Opt_trace_context::feature_value feature=Opt_trace_context::MISC)
Constructs an object.
Definition: opt_trace.h:817
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:807
Definition: opt_trace.h:920
bool error
whether trace start() had an error
Definition: opt_trace.h:954
~Opt_trace_start()
Definition: opt_trace2server.cc:238
Opt_trace_context *const ctx
Definition: opt_trace.h:953
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:107
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:641
Opt_trace_struct & add_select_number(uint select_number)
Helper to put the number of query_block in an object.
Definition: opt_trace.h:657
Opt_trace_struct & do_add_utf8_table(const Table_ref *tab)
Definition: opt_trace.cc:367
char previous_key[25]
Fixed-length prefix of previous key in this structure, if this structure is an object.
Definition: opt_trace.h:789
Opt_trace_struct & add(ulonglong value)
Definition: opt_trace.h:628
const char * saved_key
Key if the structure is the value of a key/value pair, NULL otherwise.
Definition: opt_trace.h:782
~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:263
Opt_trace_struct & add(Item *item)
Definition: opt_trace.h:578
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:612
void do_destruct()
Really does destruction.
Definition: opt_trace.cc:281
Opt_trace_struct & add(int value)
Definition: opt_trace.h:596
bool started
Whether the structure does tracing or is dummy.
Definition: opt_trace.h:757
Opt_trace_struct & add(const char *key, longlong value)
Definition: opt_trace.h:616
Opt_trace_stmt * stmt
Trace owning the structure.
Definition: opt_trace.h:780
bool requires_key
Whether the structure requires/forbids keys for values inside it.
Definition: opt_trace.h:771
Opt_trace_struct & add(longlong value)
Definition: opt_trace.h:620
bool set_not_empty()
Informs this structure that we are adding data (scalars, structures) to it.
Definition: opt_trace.h:678
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:289
Opt_trace_struct & add(double value)
Definition: opt_trace.h:636
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:600
Opt_trace_struct & add(const char *key, double value)
Definition: opt_trace.h:632
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:378
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:608
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:778
Opt_trace_struct & add(bool value)
Definition: opt_trace.h:588
Opt_trace_struct & add(const char *key, Item *item)
Add a value (of Item type) to the structure.
Definition: opt_trace.h:574
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:604
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:666
Opt_trace_struct & do_add_null(const char *key)
Definition: opt_trace.cc:340
Opt_trace_struct & add(const char *key, const char *value)
Not implemented, use add_alnum() instead.
bool empty
Definition: opt_trace.h:779
Opt_trace_struct & add(const char *key, bool value)
Definition: opt_trace.h:584
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:624
Opt_trace_struct & add_utf8_table(const Table_ref *tab)
Helper to put the database/table name in an object.
Definition: opt_trace.h:649
Opt_trace_struct & add(const char *key, int value)
Definition: opt_trace.h:592
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1155
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:1171
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
A base class for everything that can be set with SET command.
Definition: set_var.h:942
sp_head represents one instance of a stored program.
Definition: sp_head.h:379
sp_printable defines an interface which should be implemented if a class wants report some internal i...
Definition: sp_instr.h:66
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
Header for compiler-dependent features.
constexpr bool likely(bool expr)
Definition: my_compiler.h:54
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:55
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:44
static std::string escape(const std::string &str)
Escapes (only) apostrophes.
Definition: st_units_of_measure.cc:36
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:382
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
unsigned int uint
Definition: uca9-dump.cc:74