summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rw-r--r--sql/lock.cc4
-rw-r--r--sql/log.cc48
-rw-r--r--sql/sql_base.cc6
4 files changed, 21 insertions, 38 deletions
diff --git a/.bzrignore b/.bzrignore
index fdcbc3b262b..0ffc430a578 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -2996,3 +2996,4 @@ win/vs8cache.txt
zlib/*.ds?
zlib/*.vcproj
support-files/mysqld_multi.server
+tests/bug25714
diff --git a/sql/lock.cc b/sql/lock.cc
index 8e13c42d6d4..20fb7d73c1c 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -290,6 +290,10 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
}
else if (!thd->some_tables_deleted || (flags & MYSQL_LOCK_IGNORE_FLUSH))
{
+ /*
+ Thread was killed or lock aborted. Let upper level close all
+ used tables and retry or give error.
+ */
thd->locked=0;
break;
}
diff --git a/sql/log.cc b/sql/log.cc
index c5c84cfb11f..c7e122462e6 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -323,20 +323,11 @@ bool Log_to_csv_event_handler::
Field_timestamp *field0;
ulonglong save_thd_options;
bool save_query_start_used;
- time_t save_start_time;
- time_t save_time_after_lock;
- time_t save_user_time;
- bool save_time_zone_used;
+ save_query_start_used= thd->query_start_used; // Because of field->set_time()
save_thd_options= thd->options;
thd->options&= ~OPTION_BIN_LOG;
- save_query_start_used= thd->query_start_used;
- save_start_time= thd->start_time;
- save_time_after_lock= thd->time_after_lock;
- save_user_time= thd->user_time;
- save_time_zone_used= thd->time_zone_used;
-
bzero(& table_list, sizeof(TABLE_LIST));
table_list.alias= table_list.table_name= GENERAL_LOG_NAME.str;
table_list.table_name_length= GENERAL_LOG_NAME.length;
@@ -346,12 +337,13 @@ bool Log_to_csv_event_handler::
table_list.db= MYSQL_SCHEMA_NAME.str;
table_list.db_length= MYSQL_SCHEMA_NAME.length;
- table= open_performance_schema_table(thd, & table_list,
- & open_tables_backup);
+ if (!(table= open_performance_schema_table(thd, & table_list,
+ & open_tables_backup)))
+ goto err;
+
need_close= TRUE;
- if (!table ||
- table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
+ if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
table->file->ha_rnd_init(0))
goto err;
@@ -434,12 +426,7 @@ err:
close_performance_schema_table(thd, & open_tables_backup);
thd->options= save_thd_options;
-
thd->query_start_used= save_query_start_used;
- thd->start_time= save_start_time;
- thd->time_after_lock= save_time_after_lock;
- thd->user_time= save_user_time;
- thd->time_zone_used= save_time_zone_used;
return result;
}
@@ -485,11 +472,6 @@ bool Log_to_csv_event_handler::
bool need_close= FALSE;
bool need_rnd_end= FALSE;
Open_tables_state open_tables_backup;
- bool save_query_start_used;
- time_t save_start_time;
- time_t save_time_after_lock;
- time_t save_user_time;
- bool save_time_zone_used;
CHARSET_INFO *client_cs= thd->variables.character_set_client;
DBUG_ENTER("Log_to_csv_event_handler::log_slow");
@@ -502,18 +484,13 @@ bool Log_to_csv_event_handler::
table_list.db= MYSQL_SCHEMA_NAME.str;
table_list.db_length= MYSQL_SCHEMA_NAME.length;
- save_query_start_used= thd->query_start_used;
- save_start_time= thd->start_time;
- save_time_after_lock= thd->time_after_lock;
- save_user_time= thd->user_time;
- save_time_zone_used= thd->time_zone_used;
+ if (!(table= open_performance_schema_table(thd, & table_list,
+ & open_tables_backup)))
+ goto err;
- table= open_performance_schema_table(thd, & table_list,
- & open_tables_backup);
need_close= TRUE;
- if (!table ||
- table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
+ if (table->file->extra(HA_EXTRA_MARK_AS_LOG_TABLE) ||
table->file->ha_rnd_init(0))
goto err;
@@ -635,11 +612,6 @@ err:
if (need_close)
close_performance_schema_table(thd, & open_tables_backup);
- thd->query_start_used= save_query_start_used;
- thd->start_time= save_start_time;
- thd->time_after_lock= save_time_after_lock;
- thd->user_time= save_user_time;
- thd->time_zone_used= save_time_zone_used;
DBUG_RETURN(result);
}
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index cf3ef111780..28ce23ccd1a 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7198,6 +7198,12 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
else if (in_use != thd)
{
DBUG_PRINT("info", ("Table was in use by other thread"));
+ /*
+ Mark that table is going to be deleted from cache. This will
+ force threads that are in mysql_lock_tables() (but not yet
+ in thr_multi_lock()) to abort it's locks, close all tables and retry
+ */
+ in_use->some_tables_deleted= 1;
if (table->is_name_opened())
{
DBUG_PRINT("info", ("Found another active instance of the table"));