Commit 15ec36a6 authored by Yuchen Pei's avatar Yuchen Pei

check for import tablespace option

parent 54fcb541
...@@ -2232,7 +2232,6 @@ struct Table_scope_and_contents_source_pod_st // For trivial members ...@@ -2232,7 +2232,6 @@ struct Table_scope_and_contents_source_pod_st // For trivial members
MDL_ticket *mdl_ticket; MDL_ticket *mdl_ticket;
bool table_was_deleted; bool table_was_deleted;
sequence_definition *seq_create_info; sequence_definition *seq_create_info;
bool importing_tablespace; // Whether we are attempting to import tablespace
void init() void init()
{ {
......
...@@ -7210,6 +7210,7 @@ alter_commands: ...@@ -7210,6 +7210,7 @@ alter_commands:
Lex->m_sql_cmd= new (thd->mem_root) Lex->m_sql_cmd= new (thd->mem_root)
Sql_cmd_discard_import_tablespace( Sql_cmd_discard_import_tablespace(
Sql_cmd_discard_import_tablespace::IMPORT_TABLESPACE); Sql_cmd_discard_import_tablespace::IMPORT_TABLESPACE);
Lex->create_info.add(DDL_options_st::OPT_IMPORT_TABLESPACE);
if (unlikely(Lex->m_sql_cmd == NULL)) if (unlikely(Lex->m_sql_cmd == NULL))
MYSQL_YYABORT; MYSQL_YYABORT;
} }
......
...@@ -537,7 +537,8 @@ struct DDL_options_st ...@@ -537,7 +537,8 @@ struct DDL_options_st
OPT_OR_REPLACE_SLAVE_GENERATED= 32,// REPLACE was added on slave, it was OPT_OR_REPLACE_SLAVE_GENERATED= 32,// REPLACE was added on slave, it was
// not in the original query on master. // not in the original query on master.
OPT_IF_EXISTS= 64, OPT_IF_EXISTS= 64,
OPT_CREATE_SELECT= 128 // CREATE ... SELECT OPT_CREATE_SELECT= 128, // CREATE ... SELECT
OPT_IMPORT_TABLESPACE= 256 // ALTER ... IMPORT TABLESPACE
}; };
private: private:
...@@ -566,6 +567,7 @@ struct DDL_options_st ...@@ -566,6 +567,7 @@ struct DDL_options_st
bool like() const { return m_options & OPT_LIKE; } bool like() const { return m_options & OPT_LIKE; }
bool if_exists() const { return m_options & OPT_IF_EXISTS; } bool if_exists() const { return m_options & OPT_IF_EXISTS; }
bool is_create_select() const { return m_options & OPT_CREATE_SELECT; } bool is_create_select() const { return m_options & OPT_CREATE_SELECT; }
bool import_tablespace() const { return m_options & OPT_IMPORT_TABLESPACE; }
void add(const DDL_options_st::Options other) void add(const DDL_options_st::Options other)
{ {
......
...@@ -5844,13 +5844,13 @@ ha_innobase::open(const char* name, int, uint) ...@@ -5844,13 +5844,13 @@ ha_innobase::open(const char* name, int, uint)
DEBUG_SYNC(thd, "ib_open_after_dict_open"); DEBUG_SYNC(thd, "ib_open_after_dict_open");
// TODO: thd_sql_command() is a weak check. We should also check it /* If the table does not exist and we are trying to import, create a
// is an importing. "bare" table similar to the effects of CREATE TABLE followed by ALTER
if (!ib_table && thd_sql_command(thd) == SQLCOM_ALTER_TABLE) TABLE ... DISCARD TABLESPACE. */
if (!ib_table && thd_ddl_options(thd)->import_tablespace())
{ {
HA_CREATE_INFO create_info; HA_CREATE_INFO create_info;
create_info.init(); create_info.init();
create_info.importing_tablespace = true;
trx_t *trx= innobase_trx_allocate(thd); trx_t *trx= innobase_trx_allocate(thd);
trx_start_for_ddl(trx); trx_start_for_ddl(trx);
lock_sys_tables(trx); lock_sys_tables(trx);
...@@ -5861,7 +5861,7 @@ ha_innobase::open(const char* name, int, uint) ...@@ -5861,7 +5861,7 @@ ha_innobase::open(const char* name, int, uint)
trx->free(); trx->free();
ib_table = open_dict_table(name, norm_name, is_part, ib_table = open_dict_table(name, norm_name, is_part,
DICT_ERR_IGNORE_TABLESPACE); DICT_ERR_IGNORE_TABLESPACE);
DEBUG_SYNC(thd, "ib_open_after_import_tablespace"); DEBUG_SYNC(thd, "ib_open_after_create_and_open_for_import");
} }
if (NULL == ib_table) { if (NULL == ib_table) {
...@@ -10591,7 +10591,7 @@ create_table_info_t::create_table_def() ...@@ -10591,7 +10591,7 @@ create_table_info_t::create_table_def()
/* Set file_unreadable to avoid is_readable() assertion /* Set file_unreadable to avoid is_readable() assertion
errors. Semantically we assume the tablespace is not available errors. Semantically we assume the tablespace is not available
until we are able to import it.*/ until we are able to import it.*/
if (m_create_info->importing_tablespace) if (thd_ddl_options(m_thd)->import_tablespace())
table->file_unreadable = true; table->file_unreadable = true;
if (DICT_TF_HAS_DATA_DIR(m_flags)) { if (DICT_TF_HAS_DATA_DIR(m_flags)) {
...@@ -11607,8 +11607,10 @@ bool create_table_info_t::innobase_table_flags() ...@@ -11607,8 +11607,10 @@ bool create_table_info_t::innobase_table_flags()
} }
} }
// If we are trying to import a tablespace, mark tablespace as discarded /* If we are trying to import a tablespace, mark tablespace as
if (m_create_info->importing_tablespace) discarded. Without this dict_create_index_space() will attempt to
create a tablespace. */
if (thd_ddl_options(m_thd)->import_tablespace())
m_flags2 |= DICT_TF2_DISCARDED; m_flags2 |= DICT_TF2_DISCARDED;
row_type = m_create_info->row_type; row_type = m_create_info->row_type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment