summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/my_base.h5
-rw-r--r--mysql-test/r/flush-innodb.result4
-rw-r--r--mysql-test/t/flush-innodb.test2
-rw-r--r--sql/handler.h4
-rw-r--r--sql/sql_parse.cc15
-rw-r--r--sql/sql_reload.cc145
-rw-r--r--sql/sql_reload.h1
-rw-r--r--sql/sql_yacc.yy39
-rw-r--r--storage/archive/ha_archive.h2
-rw-r--r--storage/csv/ha_tina.h2
-rw-r--r--storage/myisam/ha_myisam.cc2
-rw-r--r--storage/myisammrg/ha_myisammrg.h2
12 files changed, 72 insertions, 151 deletions
diff --git a/include/my_base.h b/include/my_base.h
index 2880b52e6e2..fcad2fc1a80 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -200,11 +200,6 @@ enum ha_extra_function {
HA_EXTRA_ATTACH_CHILDREN,
HA_EXTRA_IS_ATTACHED_CHILDREN,
HA_EXTRA_DETACH_CHILDREN,
- /*
- Prepare table for export
- (e.g. quiesce the table and write table metadata).
- */
- HA_EXTRA_EXPORT,
HA_EXTRA_DETACH_CHILD,
/* Inform handler we will force a close as part of flush */
HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
diff --git a/mysql-test/r/flush-innodb.result b/mysql-test/r/flush-innodb.result
index cba2d4a56e6..6a97d33225e 100644
--- a/mysql-test/r/flush-innodb.result
+++ b/mysql-test/r/flush-innodb.result
@@ -155,9 +155,9 @@ UNLOCK TABLES;
DROP TABLE t1;
# Test 6: Unsupported storage engines.
#
-CREATE TABLE t1(a INT) engine= MyISAM;
+CREATE TABLE t1(a INT) engine= MEMORY;
FLUSH TABLE t1 FOR EXPORT;
-ERROR HY000: Storage engine MyISAM of the table `test`.`t1` doesn't have this option
+ERROR HY000: Storage engine MEMORY of the table `test`.`t1` doesn't have this option
DROP TABLE t1;
# Connection con1
# Connection defalt
diff --git a/mysql-test/t/flush-innodb.test b/mysql-test/t/flush-innodb.test
index 4494ee94376..7a877b977ce 100644
--- a/mysql-test/t/flush-innodb.test
+++ b/mysql-test/t/flush-innodb.test
@@ -267,7 +267,7 @@ DROP TABLE t1;
--echo # Test 6: Unsupported storage engines.
--echo #
-CREATE TABLE t1(a INT) engine= MyISAM;
+CREATE TABLE t1(a INT) engine= MEMORY;
--error ER_ILLEGAL_HA
FLUSH TABLE t1 FOR EXPORT;
DROP TABLE t1;
diff --git a/sql/handler.h b/sql/handler.h
index c0746b37fbc..0202fedb1eb 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -249,7 +249,9 @@ enum enum_alter_inplace_result {
/*
Storage engine supports table export using the
- FLUSH TABLE <table_list> FOR EXPORT statement.
+ FLUSH TABLE <table_list> FOR EXPORT statement
+ (meaning, after this statement one can copy table files out of the
+ datadir and later "import" (somehow) in another MariaDB instance)
*/
#define HA_CAN_EXPORT (1LL << 45)
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index ec4e873f8ec..221ed09c215 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4221,25 +4221,16 @@ end_with_restore_list:
if (check_global_access(thd,RELOAD_ACL))
goto error;
- if (first_table && lex->type & REFRESH_READ_LOCK)
+ if (first_table && lex->type & (REFRESH_READ_LOCK|REFRESH_FOR_EXPORT))
{
/* Check table-level privileges. */
if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables,
FALSE, UINT_MAX, FALSE))
goto error;
+
if (flush_tables_with_read_lock(thd, all_tables))
goto error;
- my_ok(thd);
- break;
- }
- else if (first_table && lex->type & REFRESH_FOR_EXPORT)
- {
- /* Check table-level privileges. */
- if (check_table_access(thd, LOCK_TABLES_ACL | SELECT_ACL, all_tables,
- FALSE, UINT_MAX, FALSE))
- goto error;
- if (flush_tables_for_export(thd, all_tables))
- goto error;
+
my_ok(thd);
break;
}
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()
*/
diff --git a/sql/sql_reload.h b/sql/sql_reload.h
index 554fe8ade4d..33ca022dc14 100644
--- a/sql/sql_reload.h
+++ b/sql/sql_reload.h
@@ -22,6 +22,5 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options,
TABLE_LIST *tables, int *write_to_binlog);
bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables);
-bool flush_tables_for_export(THD *thd, TABLE_LIST *all_tables);
#endif
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index e7045abf7d7..f8724943676 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1829,7 +1829,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
object_privilege object_privilege_list user_list user_and_role_list
rename_list
clear_privileges flush_options flush_option
- opt_flush_lock flush_options_list
+ opt_flush_lock flush_lock flush_options_list
equal optional_braces
opt_mi_check_type opt_to mi_check_types
table_to_table_list table_to_table opt_table_list opt_as
@@ -12779,24 +12779,27 @@ flush_options:
YYPS->m_lock_type= TL_READ_NO_INSERT;
YYPS->m_mdl_type= MDL_SHARED_HIGH_PRIO;
}
- opt_table_list {}
- opt_flush_lock {}
+ opt_table_list opt_flush_lock
| flush_options_list
;
opt_flush_lock:
/* empty */ {}
- | WITH READ_SYM LOCK_SYM optional_flush_tables_arguments
+ | flush_lock
+ {
+ TABLE_LIST *tables= Lex->query_tables;
+ for (; tables; tables= tables->next_global)
{
- TABLE_LIST *tables= Lex->query_tables;
- Lex->type|= REFRESH_READ_LOCK | $4;
- for (; tables; tables= tables->next_global)
- {
- tables->mdl_request.set_type(MDL_SHARED_NO_WRITE);
- tables->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */
- tables->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */
- }
+ tables->mdl_request.set_type(MDL_SHARED_NO_WRITE);
+ tables->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */
+ tables->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */
}
+ }
+ ;
+
+flush_lock:
+ WITH READ_SYM LOCK_SYM optional_flush_tables_arguments
+ { Lex->type|= REFRESH_READ_LOCK | $4; }
| FOR_SYM
{
if (Lex->query_tables == NULL) // Table list can't be empty
@@ -12804,18 +12807,8 @@ opt_flush_lock:
my_parse_error(ER(ER_NO_TABLES_USED));
MYSQL_YYABORT;
}
- }
- EXPORT_SYM
- {
- TABLE_LIST *tables= Lex->query_tables;
Lex->type|= REFRESH_FOR_EXPORT;
- for (; tables; tables= tables->next_global)
- {
- tables->mdl_request.set_type(MDL_SHARED_NO_WRITE);
- tables->required_type= FRMTYPE_TABLE; /* Don't try to flush views. */
- tables->open_type= OT_BASE_ONLY; /* Ignore temporary tables. */
- }
- }
+ } EXPORT_SYM
;
flush_options_list:
diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h
index 47ee89198e6..56ff566db8c 100644
--- a/storage/archive/ha_archive.h
+++ b/storage/archive/ha_archive.h
@@ -107,7 +107,7 @@ public:
{
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD |
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
- HA_STATS_RECORDS_IS_EXACT |
+ HA_STATS_RECORDS_IS_EXACT | HA_CAN_EXPORT |
HA_HAS_RECORDS | HA_CAN_REPAIR |
HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY);
}
diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h
index ebf62fbed65..000b46b2bb2 100644
--- a/storage/csv/ha_tina.h
+++ b/storage/csv/ha_tina.h
@@ -106,7 +106,7 @@ public:
ulonglong table_flags() const
{
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT |
- HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
+ HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE | HA_CAN_EXPORT |
HA_CAN_REPAIR);
}
ulong index_flags(uint idx, uint part, bool all_parts) const
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 6bedc5c07aa..4fb51e610bb 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -667,7 +667,7 @@ ha_myisam::ha_myisam(handlerton *hton, TABLE_SHARE *table_arg)
:handler(hton, table_arg), file(0),
int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
- HA_CAN_VIRTUAL_COLUMNS |
+ HA_CAN_VIRTUAL_COLUMNS | HA_CAN_EXPORT |
HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
HA_FILE_BASED | HA_CAN_GEOMETRY | HA_NO_TRANSACTIONS |
HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD | HA_CAN_RTREEKEYS |
diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h
index 6b4301616d9..e5a74baa1ae 100644
--- a/storage/myisammrg/ha_myisammrg.h
+++ b/storage/myisammrg/ha_myisammrg.h
@@ -89,7 +89,7 @@ public:
HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED |
HA_ANY_INDEX_MAY_BE_UNIQUE | HA_CAN_BIT_FIELD |
- HA_HAS_RECORDS |
+ HA_HAS_RECORDS | HA_CAN_EXPORT |
HA_NO_COPY_ON_ALTER |
HA_DUPLICATE_POS);
}