Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mysql-test/r/feature_shorten_log_table_mdl_scope.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
create user 'u0'@'%';
grant all privileges on *.* to 'u0'@'%';
begin;
select * from mysql.slow_log;
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id
truncate table mysql.slow_log;
commit;
drop user 'u0'@'%';
28 changes: 28 additions & 0 deletions mysql-test/t/feature_shorten_log_table_mdl_scope.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--source include/count_sessions.inc

connection default;

create user 'u0'@'%';
grant all privileges on *.* to 'u0'@'%';

connect(con_u0, localhost, u0,,);
connect(con_root,localhost, root,,);

connection con_root;
begin;
select * from mysql.slow_log;


connection con_u0;
truncate table mysql.slow_log;


connection con_root;
commit;


connection default;
drop user 'u0'@'%';

disconnect con_u0;
disconnect con_root;
9 changes: 8 additions & 1 deletion sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5816,8 +5816,15 @@ TABLE_LIST *SELECT_LEX::add_table_to_list(

// Pure table aliases do not need to be locked:
if (!(table_options & TL_OPTION_ALIAS)) {
enum_mdl_duration mdl_duration;
/* Shorten SLOW_LOG/GENERAL_LOG table MDL to STATEMENT */
if (query_logger.check_if_log_table(ptr, false) == QUERY_LOG_NONE)
mdl_duration = MDL_TRANSACTION;
else
mdl_duration = MDL_STATEMENT;

MDL_REQUEST_INIT(&ptr->mdl_request, MDL_key::TABLE, ptr->db,
ptr->table_name, mdl_type, MDL_TRANSACTION);
ptr->table_name, mdl_type, mdl_duration);
}
if (table_name->is_derived_table()) {
ptr->derived_key_list.empty();
Expand Down