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
MDL_ticket *mdl_ticket;
bool table_was_deleted;
sequence_definition *seq_create_info;
bool importing_tablespace; // Whether we are attempting to import tablespace
void init()
{
......
......@@ -7210,6 +7210,7 @@ alter_commands:
Lex->m_sql_cmd= new (thd->mem_root)
Sql_cmd_discard_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))
MYSQL_YYABORT;
}
......
......@@ -537,7 +537,8 @@ struct DDL_options_st
OPT_OR_REPLACE_SLAVE_GENERATED= 32,// REPLACE was added on slave, it was
// not in the original query on master.
OPT_IF_EXISTS= 64,
OPT_CREATE_SELECT= 128 // CREATE ... SELECT
OPT_CREATE_SELECT= 128, // CREATE ... SELECT
OPT_IMPORT_TABLESPACE= 256 // ALTER ... IMPORT TABLESPACE
};
private:
......@@ -566,6 +567,7 @@ struct DDL_options_st
bool like() const { return m_options & OPT_LIKE; }
bool if_exists() const { return m_options & OPT_IF_EXISTS; }
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)
{
......
......@@ -5844,13 +5844,13 @@ ha_innobase::open(const char* name, int, uint)
DEBUG_SYNC(thd, "ib_open_after_dict_open");
// TODO: thd_sql_command() is a weak check. We should also check it
// is an importing.
if (!ib_table && thd_sql_command(thd) == SQLCOM_ALTER_TABLE)
/* If the table does not exist and we are trying to import, create a
"bare" table similar to the effects of CREATE TABLE followed by ALTER
TABLE ... DISCARD TABLESPACE. */
if (!ib_table && thd_ddl_options(thd)->import_tablespace())
{
HA_CREATE_INFO create_info;
create_info.init();
create_info.importing_tablespace = true;
trx_t *trx= innobase_trx_allocate(thd);
trx_start_for_ddl(trx);
lock_sys_tables(trx);
......@@ -5861,7 +5861,7 @@ ha_innobase::open(const char* name, int, uint)
trx->free();
ib_table = open_dict_table(name, norm_name, is_part,
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) {
......@@ -10591,7 +10591,7 @@ create_table_info_t::create_table_def()
/* Set file_unreadable to avoid is_readable() assertion
errors. Semantically we assume the tablespace is not available
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;
if (DICT_TF_HAS_DATA_DIR(m_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 (m_create_info->importing_tablespace)
/* If we are trying to import a tablespace, mark tablespace as
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;
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