Commit 1f0f7d59 authored by Marko Mäkelä's avatar Marko Mäkelä

Remove dict_build_tablespace_for_table()

create_table_info_t::create_table_def(): Assign the innodb_temporary
tablespace directly.

dict_build_tablespace_for_table(): Merge to the only remaining caller,
dict_build_table_def_step().
parent 60ef478c
...@@ -353,47 +353,10 @@ dict_build_table_def_step( ...@@ -353,47 +353,10 @@ dict_build_table_def_step(
que_thr_t* thr, /*!< in: query thread */ que_thr_t* thr, /*!< in: query thread */
tab_node_t* node) /*!< in: table create node */ tab_node_t* node) /*!< in: table create node */
{ {
dict_table_t* table;
dtuple_t* row;
dberr_t err = DB_SUCCESS;
table = node->table;
trx_t* trx = thr_get_trx(thr);
dict_table_assign_new_id(table, trx);
err = dict_build_tablespace_for_table(table, node);
if (err != DB_SUCCESS) {
return(err);
}
row = dict_create_sys_tables_tuple(table, node->heap);
ins_node_set_new_row(node->tab_def, row);
return(err);
}
/** Builds a tablespace to contain a table, using file-per-table=1.
@param[in,out] table Table to build in its own tablespace.
@param[in] node Table create node
@return DB_SUCCESS or error code */
dberr_t
dict_build_tablespace_for_table(
dict_table_t* table,
tab_node_t* node)
{
dberr_t err = DB_SUCCESS;
mtr_t mtr;
ulint space = 0;
bool needs_file_per_table;
char* filepath;
ut_ad(mutex_own(&dict_sys->mutex)); ut_ad(mutex_own(&dict_sys->mutex));
dict_table_t* table = node->table;
needs_file_per_table ut_ad(!table->is_temporary());
= DICT_TF2_FLAG_IS_SET(table, DICT_TF2_USE_FILE_PER_TABLE); dict_table_assign_new_id(table, thr_get_trx(thr));
/* Always set this bit for all new created tables */ /* Always set this bit for all new created tables */
DICT_TF2_FLAG_SET(table, DICT_TF2_FTS_AUX_HEX_NAME); DICT_TF2_FLAG_SET(table, DICT_TF2_FTS_AUX_HEX_NAME);
...@@ -401,42 +364,35 @@ dict_build_tablespace_for_table( ...@@ -401,42 +364,35 @@ dict_build_tablespace_for_table(
DICT_TF2_FLAG_UNSET(table, DICT_TF2_FLAG_UNSET(table,
DICT_TF2_FTS_AUX_HEX_NAME);); DICT_TF2_FTS_AUX_HEX_NAME););
if (needs_file_per_table) { if (DICT_TF2_FLAG_IS_SET(table, DICT_TF2_USE_FILE_PER_TABLE)) {
ut_ad(!dict_table_is_temporary(table));
/* This table will need a new tablespace. */ /* This table will need a new tablespace. */
ut_ad(DICT_TF_GET_ZIP_SSIZE(table->flags) == 0 ut_ad(DICT_TF_GET_ZIP_SSIZE(table->flags) == 0
|| dict_table_has_atomic_blobs(table)); || dict_table_has_atomic_blobs(table));
/* Get a new tablespace ID */ /* Get a new tablespace ID */
dict_hdr_get_new_id(NULL, NULL, &space, table, false); ulint space_id;
dict_hdr_get_new_id(NULL, NULL, &space_id, table, false);
DBUG_EXECUTE_IF( DBUG_EXECUTE_IF(
"ib_create_table_fail_out_of_space_ids", "ib_create_table_fail_out_of_space_ids",
space = ULINT_UNDEFINED; space_id = ULINT_UNDEFINED;
); );
if (space == ULINT_UNDEFINED) { if (space_id == ULINT_UNDEFINED) {
return(DB_ERROR); return(DB_ERROR);
} }
table->space = static_cast<unsigned int>(space); table->space = unsigned(space_id);
/* Determine the tablespace flags. */ /* Determine the tablespace flags. */
bool has_data_dir = DICT_TF_HAS_DATA_DIR(table->flags); bool has_data_dir = DICT_TF_HAS_DATA_DIR(table->flags);
ulint fsp_flags = dict_tf_to_fsp_flags(table->flags); ulint fsp_flags = dict_tf_to_fsp_flags(table->flags);
ut_ad(!has_data_dir || table->data_dir_path);
if (has_data_dir) { char* filepath = has_data_dir
ut_ad(table->data_dir_path); ? fil_make_filepath(table->data_dir_path,
filepath = fil_make_filepath( table->name.m_name, IBD, true)
table->data_dir_path, : fil_make_filepath(NULL,
table->name.m_name, IBD, true); table->name.m_name, IBD, false);
} else {
/* Make the tablespace file in the default dir
using the table name */
filepath = fil_make_filepath(
NULL, table->name.m_name, IBD, false);
}
/* We create a new single-table tablespace for the table. /* We create a new single-table tablespace for the table.
We initially let it be 4 pages: We initially let it be 4 pages:
...@@ -446,39 +402,33 @@ dict_build_tablespace_for_table( ...@@ -446,39 +402,33 @@ dict_build_tablespace_for_table(
- page 3 will contain the root of the clustered index of - page 3 will contain the root of the clustered index of
the table we create here. */ the table we create here. */
err = fil_ibd_create( dberr_t err = fil_ibd_create(
space, table->name.m_name, filepath, fsp_flags, space_id, table->name.m_name, filepath, fsp_flags,
FIL_IBD_FILE_INITIAL_SIZE, FIL_IBD_FILE_INITIAL_SIZE,
node ? node->mode : FIL_ENCRYPTION_DEFAULT, node->mode, node->key_id);
node ? node->key_id : FIL_DEFAULT_ENCRYPTION_KEY);
ut_free(filepath); ut_free(filepath);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
return(err); return(err);
} }
mtr_start(&mtr); mtr_t mtr;
mtr.start();
mtr.set_named_space(table->space); mtr.set_named_space(table->space);
fsp_header_init(table->space, FIL_IBD_FILE_INITIAL_SIZE, &mtr); fsp_header_init(table->space, FIL_IBD_FILE_INITIAL_SIZE, &mtr);
mtr.commit();
mtr_commit(&mtr);
} else { } else {
ut_ad(dict_tf_get_rec_format(table->flags) ut_ad(dict_tf_get_rec_format(table->flags)
!= REC_FORMAT_COMPRESSED); != REC_FORMAT_COMPRESSED);
if (dict_table_is_temporary(table)) { ut_ad(table->space == TRX_SYS_SPACE);
table->space = SRV_TMP_SPACE_ID;
} else {
ut_ad(table->space == srv_sys_space.space_id());
}
DBUG_EXECUTE_IF("ib_ddl_crash_during_tablespace_alloc", DBUG_EXECUTE_IF("ib_ddl_crash_during_tablespace_alloc",
DBUG_SUICIDE();); DBUG_SUICIDE(););
} }
return(DB_SUCCESS); ins_node_set_new_row(node->tab_def,
dict_create_sys_tables_tuple(table, node->heap));
return DB_SUCCESS;
} }
/** Builds a SYS_VIRTUAL row definition to insert. /** Builds a SYS_VIRTUAL row definition to insert.
......
...@@ -11197,23 +11197,14 @@ create_table_info_t::create_table_def() ...@@ -11197,23 +11197,14 @@ create_table_info_t::create_table_def()
ut_ad(trx_state_eq(m_trx, TRX_STATE_NOT_STARTED)); ut_ad(trx_state_eq(m_trx, TRX_STATE_NOT_STARTED));
/* If temp table, then we avoid creation of entries in SYSTEM TABLES. if (table->is_temporary()) {
Given that temp table lifetime is limited to connection/server lifetime /* Get a new table ID. FIXME: Make this a private
on re-start we don't need to restore temp-table and so no entry is sequence, not shared with persistent tables! */
needed in SYSTEM tables. */
if (dict_table_is_temporary(table)) {
/* Get a new table ID */
dict_table_assign_new_id(table, m_trx); dict_table_assign_new_id(table, m_trx);
ut_ad(dict_tf_get_rec_format(table->flags)
/* Create temp tablespace if configured. */ != REC_FORMAT_COMPRESSED);
err = dict_build_tablespace_for_table(table, NULL); table->space = SRV_TMP_SPACE_ID;
table->add_to_cache();
if (err == DB_SUCCESS) {
table->add_to_cache();
DBUG_EXECUTE_IF("ib_ddl_crash_during_create2",
DBUG_SUICIDE(););
}
} else { } else {
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
err = row_create_table_for_mysql( err = row_create_table_for_mysql(
......
...@@ -68,15 +68,6 @@ dict_create_table_step( ...@@ -68,15 +68,6 @@ dict_create_table_step(
/*===================*/ /*===================*/
que_thr_t* thr); /*!< in: query thread */ que_thr_t* thr); /*!< in: query thread */
/** Builds a tablespace to contain a table, using file-per-table=1.
@param[in,out] table Table to build in its own tablespace.
@param[in] node Table create node
@return DB_SUCCESS or error code */
dberr_t
dict_build_tablespace_for_table(
dict_table_t* table,
tab_node_t* node);
/** Assign a new table ID and put it into the table cache and the transaction. /** Assign a new table ID and put it into the table cache and the transaction.
@param[in,out] table Table that needs an ID @param[in,out] table Table that needs an ID
@param[in,out] trx Transaction */ @param[in,out] trx Transaction */
......
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