Commit 7bb535bb authored by osku's avatar osku

Make dict_index_find_cols() always succeed.

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