MySQL 8.0.39
Source Code Documentation
anonymous_namespace{opt_trace2server.cc} Namespace Reference

Functions

bool list_has_optimizer_trace_table (const Table_ref *tbl)
 Whether a list of tables contains information_schema.OPTIMIZER_TRACE. More...
 
bool sql_command_can_be_traced (enum enum_sql_command sql_command)
 Whether a SQL command qualifies for optimizer tracing. More...
 
bool sets_var_optimizer_trace (enum enum_sql_command sql_command, List< set_var_base > *set_vars)
 
void opt_trace_disable_if_no_tables_access (THD *thd, Table_ref *tbl)
 If tracing is on, checks additional privileges on a list of tables/views, to make sure that the user has the right to do SHOW CREATE TABLE/VIEW and "SELECT *". More...
 

Variables

const char I_S_table_name [] = "OPTIMIZER_TRACE"
 

Function Documentation

◆ list_has_optimizer_trace_table()

bool anonymous_namespace{opt_trace2server.cc}::list_has_optimizer_trace_table ( const Table_ref tbl)

Whether a list of tables contains information_schema.OPTIMIZER_TRACE.

Parameters
tbllist of tables
Note
this does not catch that a stored routine or view accesses the OPTIMIZER_TRACE table. So using a stored routine or view to read OPTIMIZER_TRACE will overwrite OPTIMIZER_TRACE as it runs and provide uninteresting info.

◆ opt_trace_disable_if_no_tables_access()

void anonymous_namespace opt_trace2server anonymous_namespace{opt_trace2server.cc}::cc::opt_trace_disable_if_no_tables_access ( THD thd,
Table_ref tbl 
)

If tracing is on, checks additional privileges on a list of tables/views, to make sure that the user has the right to do SHOW CREATE TABLE/VIEW and "SELECT *".

For that:

  • this functions checks table-level SELECT
  • which is sufficient for SHOW CREATE TABLE and "SELECT *", if a base table
  • if a view, if the view has not been identified as such then opt_trace_disable_if_no_view_access() will be later called and check SHOW VIEW; other we check SHOW VIEW here; SHOW VIEW + SELECT is sufficient for SHOW CREATE VIEW. If a privilege is missing, notifies the trace system.
Parameters
thdthread context
tbllist of tables to check

◆ sets_var_optimizer_trace()

bool anonymous_namespace{opt_trace2server.cc}::sets_var_optimizer_trace ( enum enum_sql_command  sql_command,
List< set_var_base > *  set_vars 
)
Returns
whether this command is "SET ... @@@@OPTIMIZER_TRACE=..."

◆ sql_command_can_be_traced()

bool anonymous_namespace{opt_trace2server.cc}::sql_command_can_be_traced ( enum enum_sql_command  sql_command)
inline

Whether a SQL command qualifies for optimizer tracing.

Parameters
sql_commandthe command

Variable Documentation

◆ I_S_table_name

const char anonymous_namespace{opt_trace2server.cc}::I_S_table_name[] = "OPTIMIZER_TRACE"