diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2019-02-13 11:22:16 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2019-02-13 11:52:36 +0530 |
commit | be8709eb7bdf2a68a1c04fd8ab368113f5f39b63 (patch) | |
tree | 35585804a654ec75089a92e90d546f73e7f60b68 /sql/sql_view.cc | |
parent | 6b979416e0e4eac0a036ca5f2b81b748a3d2e680 (diff) | |
download | mariadb-git-be8709eb7bdf2a68a1c04fd8ab368113f5f39b63.tar.gz |
MDEV-6111 Optimizer Trace
This task involves the implementation for the optimizer trace.
This feature produces a trace for any SELECT/UPDATE/DELETE/,
which contains information about decisions taken by the optimizer during
the optimization phase (choice of table access method, various costs,
transformations, etc). This feature would help to tell why some decisions were
taken by the optimizer and why some were rejected.
Trace is session-local, controlled by the @@optimizer_trace variable.
To enable optimizer trace we need to write:
set @@optimizer_trace variable= 'enabled=on';
To display the trace one can run:
SELECT trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
This task also involves:
MDEV-18489: Limit the memory used by the optimizer trace
introduces a switch optimizer_trace_max_mem_size which limits
the memory used by the optimizer trace. This was implemented by
Sergei Petrunia.
Diffstat (limited to 'sql/sql_view.cc')
-rw-r--r-- | sql/sql_view.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sql/sql_view.cc b/sql/sql_view.cc index e475a3d3719..31032c5cd5e 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -36,6 +36,7 @@ #include "datadict.h" // dd_frm_is_view() #include "sql_derived.h" #include "sql_cte.h" // check_dependencies_in_with_clauses() +#include "opt_trace.h" #define MD5_BUFF_LENGTH 33 @@ -1420,6 +1421,15 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table, goto err; /* + Check rights to run commands which show underlying tables. + In the optimizer trace we would not like to show trace for + cases when the current user does not have rights for the + underlying tables. + */ + if (!table->prelocking_placeholder) + opt_trace_disable_if_no_view_access(thd, table, view_tables); + + /* Check rights to run commands (ANALYZE SELECT, EXPLAIN SELECT & SHOW CREATE) which show underlying tables. Skip this step if we are opening view for prelocking only. |