Commit 90451a59 authored by Marko Mäkelä's avatar Marko Mäkelä

Follow-up to 792c9f9a

dict_index_add_to_cache(): Make the 'index' a reference to a pointer,
so that the caller will avoid the expensive call to
dict_index_get_if_in_cache_low().
parent 8688ef22
...@@ -1473,15 +1473,11 @@ dict_create_index_step( ...@@ -1473,15 +1473,11 @@ dict_create_index_step(
} }
if (node->state == INDEX_ADD_TO_CACHE) { if (node->state == INDEX_ADD_TO_CACHE) {
index_id_t index_id = node->index->id;
err = dict_index_add_to_cache( err = dict_index_add_to_cache(
node->table, node->index, FIL_NULL, node->table, node->index, FIL_NULL,
trx_is_strict(trx), node->add_v); trx_is_strict(trx), node->add_v);
node->index = dict_index_get_if_in_cache_low(index_id); ut_ad((node->index == NULL) == (err != DB_SUCCESS));
ut_a((node->index == NULL) == (err != DB_SUCCESS));
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
......
...@@ -2348,18 +2348,17 @@ added column. ...@@ -2348,18 +2348,17 @@ added column.
@param[in,out] index index; NOTE! The index memory @param[in,out] index index; NOTE! The index memory
object is freed in this function! object is freed in this function!
@param[in] page_no root page number of the index @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 if records could be too big to fit in
an B-tree page an B-tree page
@param[in] add_v new virtual column that being added along with @param[in] add_v virtual columns being added along with ADD INDEX
an add index call
@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */ @return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
dberr_t dberr_t
dict_index_add_to_cache( dict_index_add_to_cache(
dict_table_t* table, dict_table_t* table,
dict_index_t* index, dict_index_t*& index,
ulint page_no, ulint page_no,
ibool strict, bool strict,
const dict_add_v_col_t* add_v) const dict_add_v_col_t* add_v)
{ {
dict_index_t* new_index; dict_index_t* new_index;
...@@ -2379,7 +2378,8 @@ dict_index_add_to_cache( ...@@ -2379,7 +2378,8 @@ dict_index_add_to_cache(
if (!dict_index_find_cols(table, index, add_v)) { if (!dict_index_find_cols(table, index, add_v)) {
dict_mem_index_free(index); dict_mem_index_free(index);
return(DB_CORRUPTION); index = NULL;
return DB_CORRUPTION;
} }
/* Build the cache internal representation of the index, /* Build the cache internal representation of the index,
...@@ -2409,7 +2409,8 @@ dict_index_add_to_cache( ...@@ -2409,7 +2409,8 @@ dict_index_add_to_cache(
if (strict) { if (strict) {
dict_mem_index_free(new_index); dict_mem_index_free(new_index);
dict_mem_index_free(index); dict_mem_index_free(index);
return(DB_TOO_BIG_RECORD); index = NULL;
return DB_TOO_BIG_RECORD;
} else if (current_thd != NULL) { } else if (current_thd != NULL) {
/* Avoid the warning to be printed /* Avoid the warning to be printed
during recovery. */ during recovery. */
...@@ -2487,8 +2488,8 @@ dict_index_add_to_cache( ...@@ -2487,8 +2488,8 @@ dict_index_add_to_cache(
SYNC_INDEX_TREE); SYNC_INDEX_TREE);
dict_mem_index_free(index); dict_mem_index_free(index);
index = new_index;
return(DB_SUCCESS); return DB_SUCCESS;
} }
/**********************************************************************//** /**********************************************************************//**
......
...@@ -1095,23 +1095,22 @@ dict_index_remove_from_v_col_list( ...@@ -1095,23 +1095,22 @@ dict_index_remove_from_v_col_list(
/** Adds an index to the dictionary cache, with possible indexing newly /** Adds an index to the dictionary cache, with possible indexing newly
added column. added column.
@param[in] table table on which the index is @param[in,out] table table on which the index is
@param[in] index index; NOTE! The index memory @param[in,out] index index; NOTE! The index memory
object is freed in this function! object is freed in this function!
@param[in] page_no root page number of the index @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 if records could be too big to fit in
an B-tree page an B-tree page
@param[in] add_v new virtual column that being added along with @param[in] add_v virtual columns being added along with ADD INDEX
an add index call
@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */ @return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
dberr_t dberr_t
dict_index_add_to_cache( dict_index_add_to_cache(
dict_table_t* table, dict_table_t* table,
dict_index_t* index, dict_index_t*& index,
ulint page_no, ulint page_no,
ibool strict, bool strict = false,
const dict_add_v_col_t* add_v=NULL) const dict_add_v_col_t* add_v = NULL)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/********************************************************************//** /********************************************************************//**
Gets the number of fields in the internal representation of an index, Gets the number of fields in the internal representation of an index,
......
...@@ -2450,20 +2450,14 @@ row_create_index_for_mysql( ...@@ -2450,20 +2450,14 @@ row_create_index_for_mysql(
} else { } else {
dict_build_index_def(table, index, trx); 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( err = dict_index_add_to_cache(
table, index, FIL_NULL, trx_is_strict(trx)); table, index, FIL_NULL, trx_is_strict(trx));
ut_ad((index == NULL) == (err != DB_SUCCESS));
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
goto error_handling; 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; index->table = table;
err = dict_create_index_tree_in_mem(index, trx); err = dict_create_index_tree_in_mem(index, trx);
......
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