summaryrefslogtreecommitdiff
path: root/sql/sql_reload.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-02-02 10:06:29 +0100
committerSergei Golubchik <sergii@pisem.net>2014-02-02 10:06:29 +0100
commitfa11d613cfbaee23d48cabfb65435d83adee7818 (patch)
treebd90c2e71a319c8366d355c79d33a985130330b6 /sql/sql_reload.cc
parentd929342b0f8d5a85aac4e76486b0ff2aff7ca54f (diff)
downloadmariadb-git-fa11d613cfbaee23d48cabfb65435d83adee7818.tar.gz
MySQL WL#5522 - InnoDB transportable tablespaces.
Cleanups: * remove unused HA_EXTRA_EXPORT (can be added later if needed, e.g. for Aria) * clarify the meaning of HA_CAN_EXPORT * make all engines that support EXPORT to announce it * reduce code duplication
Diffstat (limited to 'sql/sql_reload.cc')
-rw-r--r--sql/sql_reload.cc145
1 files changed, 43 insertions, 102 deletions
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index c7038b6522d..bb3d5bb899a 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -407,7 +407,8 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
/**
- Implementation of FLUSH TABLES <table_list> WITH READ LOCK.
+ Implementation of FLUSH TABLES <table_list> WITH READ LOCK
+ and FLUSH TABLES <table_list> FOR EXPORT
In brief: take exclusive locks, expel tables from the table
cache, reopen the tables, enter the 'LOCKED TABLES' mode,
@@ -496,27 +497,30 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
goto error;
}
- /*
- Acquire SNW locks on tables to be flushed. Don't acquire global
- IX and database-scope IX locks on the tables as this will make
- this statement incompatible with FLUSH TABLES WITH READ LOCK.
- */
- if (lock_table_names(thd, all_tables, NULL,
- thd->variables.lock_wait_timeout,
- MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK))
- goto error;
+ if (thd->lex->type & REFRESH_READ_LOCK)
+ {
+ /*
+ Acquire SNW locks on tables to be flushed. Don't acquire global
+ IX and database-scope IX locks on the tables as this will make
+ this statement incompatible with FLUSH TABLES WITH READ LOCK.
+ */
+ if (lock_table_names(thd, all_tables, NULL,
+ thd->variables.lock_wait_timeout,
+ MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK))
+ goto error;
- DEBUG_SYNC(thd,"flush_tables_with_read_lock_after_acquire_locks");
+ DEBUG_SYNC(thd,"flush_tables_with_read_lock_after_acquire_locks");
- for (table_list= all_tables; table_list;
- table_list= table_list->next_global)
- {
- /* Request removal of table from cache. */
- tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
- table_list->db,
- table_list->table_name, FALSE);
- /* Reset ticket to satisfy asserts in open_tables(). */
- table_list->mdl_request.ticket= NULL;
+ for (table_list= all_tables; table_list;
+ table_list= table_list->next_global)
+ {
+ /* Request removal of table from cache. */
+ tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
+ table_list->db,
+ table_list->table_name, FALSE);
+ /* Reset ticket to satisfy asserts in open_tables(). */
+ table_list->mdl_request.ticket= NULL;
+ }
}
/*
@@ -531,11 +535,27 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
*/
if (open_and_lock_tables(thd, all_tables, FALSE,
MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK,
- &lock_tables_prelocking_strategy) ||
- thd->locked_tables_list.init_locked_tables(thd))
- {
+ &lock_tables_prelocking_strategy))
goto error;
+
+ if (thd->lex->type & REFRESH_FOR_EXPORT)
+ {
+ // Check if all storage engines support FOR EXPORT.
+ for (TABLE_LIST *table_list= all_tables; table_list;
+ table_list= table_list->next_global)
+ {
+ if (!(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT))
+ {
+ my_error(ER_ILLEGAL_HA, MYF(0),table_list->table->file->table_type(),
+ table_list->db, table_list->table_name);
+ return true;
+ }
+ }
}
+
+ if (thd->locked_tables_list.init_locked_tables(thd))
+ goto error;
+
thd->variables.option_bits|= OPTION_TABLE_LOCK;
/*
@@ -553,85 +573,6 @@ error:
/**
- Prepare tables for export (transportable tablespaces) by
- a) waiting until write transactions/DDL operations using these
- tables have completed.
- b) block new write operations/DDL operations on these tables.
-
- Once this is done, notify the storage engines using handler::extra().
-
- Finally, enter LOCK TABLES mode, so that locks are held
- until UNLOCK TABLES is executed.
-
- @param thd Thread handler
- @param all_tables TABLE_LIST for tables to be exported
-
- @retval false Ok
- @retval true Error
-*/
-
-bool flush_tables_for_export(THD *thd, TABLE_LIST *all_tables)
-{
- Lock_tables_prelocking_strategy lock_tables_prelocking_strategy;
-
- /*
- This is called from SQLCOM_FLUSH, the transaction has
- been committed implicitly.
- */
-
- if (thd->locked_tables_mode)
- {
- my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0));
- return true;
- }
-
- /*
- Acquire SNW locks on tables to be exported. Don't acquire
- global IX as this will make this statement incompatible
- with FLUSH TABLES WITH READ LOCK.
- */
- if (open_and_lock_tables(thd, all_tables, false,
- MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK,
- &lock_tables_prelocking_strategy))
- {
- return true;
- }
-
- // Check if all storage engines support FOR EXPORT.
- for (TABLE_LIST *table_list= all_tables; table_list;
- table_list= table_list->next_global)
- {
- if (!(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT))
- {
- my_error(ER_ILLEGAL_HA, MYF(0),table_list->table->file->table_type(),
- table_list->db, table_list->table_name);
- return true;
- }
- }
-
- // Notify the storage engines that the tables should be made ready for export.
- for (TABLE_LIST *table_list= all_tables; table_list;
- table_list= table_list->next_global)
- {
- handler *handler_file= table_list->table->file;
- int error= handler_file->extra(HA_EXTRA_EXPORT);
- if (error)
- {
- handler_file->print_error(error, MYF(0));
- return true;
- }
- }
-
- // Enter LOCKED TABLES mode.
- if (thd->locked_tables_list.init_locked_tables(thd))
- return true;
- thd->variables.option_bits|= OPTION_TABLE_LOCK;
-
- return false;
-}
-
-
-/**
Disable checkpoints for all handlers
This is released in unlock_global_read_lock()
*/