summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/innobase/dict/dict0crea.cc6
-rw-r--r--storage/innobase/dict/dict0dict.cc19
-rw-r--r--storage/innobase/include/dict0dict.h15
-rw-r--r--storage/innobase/row/row0mysql.cc8
4 files changed, 19 insertions, 29 deletions
diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc
index d277b593a9c..00268f54677 100644
--- a/storage/innobase/dict/dict0crea.cc
+++ b/storage/innobase/dict/dict0crea.cc
@@ -1473,15 +1473,11 @@ dict_create_index_step(
}
if (node->state == INDEX_ADD_TO_CACHE) {
-
- index_id_t index_id = node->index->id;
-
err = dict_index_add_to_cache(
node->table, node->index, FIL_NULL,
trx_is_strict(trx), node->add_v);
- node->index = dict_index_get_if_in_cache_low(index_id);
- ut_a((node->index == NULL) == (err != DB_SUCCESS));
+ ut_ad((node->index == NULL) == (err != DB_SUCCESS));
if (err != DB_SUCCESS) {
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index f9dc00f9dcd..eded73bad10 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -2348,18 +2348,17 @@ added column.
@param[in,out] index index; NOTE! The index memory
object is freed in this function!
@param[in] page_no root page number of the index
-@param[in] strict TRUE=refuse to create the index
+@param[in] strict true=refuse to create the index
if records could be too big to fit in
an B-tree page
-@param[in] add_v new virtual column that being added along with
- an add index call
+@param[in] add_v virtual columns being added along with ADD INDEX
@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
dberr_t
dict_index_add_to_cache(
dict_table_t* table,
- dict_index_t* index,
+ dict_index_t*& index,
ulint page_no,
- ibool strict,
+ bool strict,
const dict_add_v_col_t* add_v)
{
dict_index_t* new_index;
@@ -2379,7 +2378,8 @@ dict_index_add_to_cache(
if (!dict_index_find_cols(table, index, add_v)) {
dict_mem_index_free(index);
- return(DB_CORRUPTION);
+ index = NULL;
+ return DB_CORRUPTION;
}
/* Build the cache internal representation of the index,
@@ -2409,7 +2409,8 @@ dict_index_add_to_cache(
if (strict) {
dict_mem_index_free(new_index);
dict_mem_index_free(index);
- return(DB_TOO_BIG_RECORD);
+ index = NULL;
+ return DB_TOO_BIG_RECORD;
} else if (current_thd != NULL) {
/* Avoid the warning to be printed
during recovery. */
@@ -2487,8 +2488,8 @@ dict_index_add_to_cache(
SYNC_INDEX_TREE);
dict_mem_index_free(index);
-
- return(DB_SUCCESS);
+ index = new_index;
+ return DB_SUCCESS;
}
/**********************************************************************//**
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 52ce261a521..bf4e4b9e289 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -1095,23 +1095,22 @@ dict_index_remove_from_v_col_list(
/** Adds an index to the dictionary cache, with possible indexing newly
added column.
-@param[in] table table on which the index is
-@param[in] index index; NOTE! The index memory
+@param[in,out] table table on which the index is
+@param[in,out] index index; NOTE! The index memory
object is freed in this function!
@param[in] page_no root page number of the index
-@param[in] strict TRUE=refuse to create the index
+@param[in] strict true=refuse to create the index
if records could be too big to fit in
an B-tree page
-@param[in] add_v new virtual column that being added along with
- an add index call
+@param[in] add_v virtual columns being added along with ADD INDEX
@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
dberr_t
dict_index_add_to_cache(
dict_table_t* table,
- dict_index_t* index,
+ dict_index_t*& index,
ulint page_no,
- ibool strict,
- const dict_add_v_col_t* add_v=NULL)
+ bool strict = false,
+ const dict_add_v_col_t* add_v = NULL)
MY_ATTRIBUTE((warn_unused_result));
/********************************************************************//**
Gets the number of fields in the internal representation of an index,
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index fe2a012c323..a5795ff90e8 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -2450,20 +2450,14 @@ row_create_index_for_mysql(
} else {
dict_build_index_def(table, index, trx);
- index_id_t index_id = index->id;
-
- /* add index to dictionary cache and also free index object. */
err = dict_index_add_to_cache(
table, index, FIL_NULL, trx_is_strict(trx));
+ ut_ad((index == NULL) == (err != DB_SUCCESS));
if (err != DB_SUCCESS) {
goto error_handling;
}
- /* as above function has freed index object re-load it
- now from dictionary cache using index_id */
- index = dict_index_get_if_in_cache_low(index_id);
- ut_a(index != NULL);
index->table = table;
err = dict_create_index_tree_in_mem(index, trx);