Commit 7bb535bb authored by osku's avatar osku

Make dict_index_find_cols() always succeed.

parent 16951e43
......@@ -214,7 +214,6 @@ dict_boot(void)
dict_index_t* index;
dict_hdr_t* dict_hdr;
mtr_t mtr;
ibool success;
mtr_start(&mtr);
......@@ -269,21 +268,20 @@ dict_boot(void)
index->id = DICT_TABLES_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint
(dict_hdr + DICT_HDR_TABLES,
dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr + DICT_HDR_TABLES,
MLOG_4BYTES, &mtr));
ut_a(success);
/*-------------------------*/
index = dict_mem_index_create("SYS_TABLES", "ID_IND",
DICT_HDR_SPACE, DICT_UNIQUE, 1);
dict_mem_index_add_field(index, "ID", 0);
index->id = DICT_TABLE_IDS_ID;
success = dict_index_add_to_cache(table, index,
mtr_read_ulint
(dict_hdr + DICT_HDR_TABLE_IDS,
dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr + DICT_HDR_TABLE_IDS,
MLOG_4BYTES, &mtr));
ut_a(success);
/*-------------------------*/
table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
......@@ -308,10 +306,10 @@ dict_boot(void)
dict_mem_index_add_field(index, "POS", 0);
index->id = DICT_COLUMNS_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint
(dict_hdr + DICT_HDR_COLUMNS,
dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr + DICT_HDR_COLUMNS,
MLOG_4BYTES, &mtr));
ut_a(success);
/*-------------------------*/
table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
......@@ -346,10 +344,10 @@ dict_boot(void)
dict_mem_index_add_field(index, "ID", 0);
index->id = DICT_INDEXES_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint
(dict_hdr + DICT_HDR_INDEXES,
dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr + DICT_HDR_INDEXES,
MLOG_4BYTES, &mtr));
ut_a(success);
/*-------------------------*/
table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
......@@ -369,10 +367,9 @@ dict_boot(void)
dict_mem_index_add_field(index, "POS", 0);
index->id = DICT_FIELDS_ID;
success = dict_index_add_to_cache(table, index, mtr_read_ulint
(dict_hdr + DICT_HDR_FIELDS,
dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr + DICT_HDR_FIELDS,
MLOG_4BYTES, &mtr));
ut_a(success);
mtr_commit(&mtr);
/*-------------------------*/
......
......@@ -1004,7 +1004,6 @@ dict_create_index_step(
que_thr_t* thr) /* in: query thread */
{
ind_node_t* node;
ibool success;
ulint err = DB_ERROR;
trx_t* trx;
......@@ -1088,11 +1087,9 @@ dict_create_index_step(
if (node->state == INDEX_ADD_TO_CACHE) {
success = dict_index_add_to_cache(node->table, node->index,
dict_index_add_to_cache(node->table, node->index,
node->page_no);
ut_a(success);
err = DB_SUCCESS;
}
......
......@@ -146,13 +146,12 @@ dict_index_copy(
ulint start, /* in: first position to copy */
ulint end); /* in: last position to copy */
/***********************************************************************
Tries to find column names for the index and
sets the col field of the index. */
Tries to find column names for the index and sets the col field of the
index. */
static
ibool
void
dict_index_find_cols(
/*=================*/
/* out: TRUE if success */
dict_table_t* table, /* in: table */
dict_index_t* index); /* in: index */
/***********************************************************************
......@@ -1308,10 +1307,9 @@ dict_col_name_is_reserved(
/**************************************************************************
Adds an index to the dictionary cache. */
ibool
void
dict_index_add_to_cache(
/*====================*/
/* out: TRUE if success */
dict_table_t* table, /* in: table on which the index is */
dict_index_t* index, /* in, own: index; NOTE! The index memory
object is freed in this function! */
......@@ -1321,7 +1319,6 @@ dict_index_add_to_cache(
dict_tree_t* tree;
dict_field_t* field;
ulint n_ord;
ibool success;
ulint i;
ut_ad(index);
......@@ -1349,13 +1346,7 @@ dict_index_add_to_cache(
ut_a(!(index->type & DICT_CLUSTERED)
|| UT_LIST_GET_LEN(table->indexes) == 0);
success = dict_index_find_cols(table, index);
if (!success) {
dict_mem_index_free(index);
return(FALSE);
}
dict_index_find_cols(table, index);
/* Build the cache internal representation of the index,
containing also the added system fields */
......@@ -1421,8 +1412,6 @@ dict_index_add_to_cache(
dict_sys->size += mem_heap_get_size(new_index->heap);
dict_mem_index_free(index);
return(TRUE);
}
/**************************************************************************
......@@ -1459,13 +1448,12 @@ dict_index_remove_from_cache(
}
/***********************************************************************
Tries to find column names for the index and
sets the col field of the index. */
Tries to find column names for the index and sets the col field of the
index. */
static
ibool
void
dict_index_find_cols(
/*=================*/
/* out: TRUE if success */
dict_table_t* table, /* in: table */
dict_index_t* index) /* in: index */
{
......@@ -1483,17 +1471,20 @@ dict_index_find_cols(
for (j = 0; j < table->n_cols; j++) {
dict_col_t* col = dict_table_get_nth_col(table, j);
if (!strcmp(col->name, field->name)) {
field->col = col;
goto found;
}
}
return(FALSE);
found: ;
}
/* It is an error not to find a matching column. */
ut_error;
return(TRUE);
found:
;
}
}
/***********************************************************************
......
......@@ -550,12 +550,11 @@ dict_index_find_on_id_low(
/* out: index or NULL if not found from cache */
dulint id); /* in: index id */
/**************************************************************************
Adds an index to dictionary cache. */
Adds an index to the dictionary cache. */
ibool
void
dict_index_add_to_cache(
/*====================*/
/* out: TRUE if success */
dict_table_t* table, /* in: table on which the index is */
dict_index_t* index, /* in, own: index; NOTE! The index memory
object is freed in this function! */
......
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