Skip to content
Permalink
Browse files
MDEV-12266: Remove dict_index_t::table_name
Replace index->table_name with index->table->name.
  • Loading branch information
dr-m committed Mar 29, 2018
1 parent 604fea1 commit 428e028
Show file tree
Hide file tree
Showing 28 changed files with 304 additions and 501 deletions.
@@ -283,7 +283,6 @@ dict_boot(void)
dict_hdr_t* dict_hdr;
mem_heap_t* heap;
mtr_t mtr;
dberr_t error;

/* Be sure these constants do not ever change. To avoid bloat,
only check the *NUM_FIELDS* in each table */
@@ -356,34 +355,27 @@ dict_boot(void)
dict_sys->sys_tables = table;
mem_heap_empty(heap);

index = dict_mem_index_create("SYS_TABLES", "CLUST_IND",
index = dict_mem_index_create(table, "CLUST_IND",
DICT_UNIQUE | DICT_CLUSTERED, 1);

dict_mem_index_add_field(index, "NAME", 0);

index->id = DICT_TABLES_ID;

error = dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr
+ DICT_HDR_TABLES,
MLOG_4BYTES, &mtr),
FALSE);
ut_a(error == DB_SUCCESS);
index = dict_index_add_to_cache(
index, mach_read_from_4(dict_hdr + DICT_HDR_TABLES));
ut_a(index);
ut_ad(!table->is_instant());
table->indexes.start->n_core_null_bytes = UT_BITS_IN_BYTES(
table->indexes.start->n_nullable);

/*-------------------------*/
index = dict_mem_index_create("SYS_TABLES", "ID_IND", DICT_UNIQUE, 1);
index = dict_mem_index_create(table, "ID_IND", DICT_UNIQUE, 1);
dict_mem_index_add_field(index, "ID", 0);

index->id = DICT_TABLE_IDS_ID;
error = dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr
+ DICT_HDR_TABLE_IDS,
MLOG_4BYTES, &mtr),
FALSE);
ut_a(error == DB_SUCCESS);
index = dict_index_add_to_cache(
index, mach_read_from_4(dict_hdr + DICT_HDR_TABLE_IDS));
ut_a(index);

/*-------------------------*/
table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE,
@@ -404,19 +396,16 @@ dict_boot(void)
dict_sys->sys_columns = table;
mem_heap_empty(heap);

index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND",
index = dict_mem_index_create(table, "CLUST_IND",
DICT_UNIQUE | DICT_CLUSTERED, 2);

dict_mem_index_add_field(index, "TABLE_ID", 0);
dict_mem_index_add_field(index, "POS", 0);

index->id = DICT_COLUMNS_ID;
error = dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr
+ DICT_HDR_COLUMNS,
MLOG_4BYTES, &mtr),
FALSE);
ut_a(error == DB_SUCCESS);
index = dict_index_add_to_cache(
index, mach_read_from_4(dict_hdr + DICT_HDR_COLUMNS));
ut_a(index);
ut_ad(!table->is_instant());
table->indexes.start->n_core_null_bytes = UT_BITS_IN_BYTES(
table->indexes.start->n_nullable);
@@ -450,19 +439,16 @@ dict_boot(void)
dict_sys->sys_indexes = table;
mem_heap_empty(heap);

index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND",
index = dict_mem_index_create(table, "CLUST_IND",
DICT_UNIQUE | DICT_CLUSTERED, 2);

dict_mem_index_add_field(index, "TABLE_ID", 0);
dict_mem_index_add_field(index, "ID", 0);

index->id = DICT_INDEXES_ID;
error = dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr
+ DICT_HDR_INDEXES,
MLOG_4BYTES, &mtr),
FALSE);
ut_a(error == DB_SUCCESS);
index = dict_index_add_to_cache(
index, mach_read_from_4(dict_hdr + DICT_HDR_INDEXES));
ut_a(index);
ut_ad(!table->is_instant());
table->indexes.start->n_core_null_bytes = UT_BITS_IN_BYTES(
table->indexes.start->n_nullable);
@@ -481,19 +467,16 @@ dict_boot(void)
dict_sys->sys_fields = table;
mem_heap_free(heap);

index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND",
index = dict_mem_index_create(table, "CLUST_IND",
DICT_UNIQUE | DICT_CLUSTERED, 2);

dict_mem_index_add_field(index, "INDEX_ID", 0);
dict_mem_index_add_field(index, "POS", 0);

index->id = DICT_FIELDS_ID;
error = dict_index_add_to_cache(table, index,
mtr_read_ulint(dict_hdr
+ DICT_HDR_FIELDS,
MLOG_4BYTES, &mtr),
FALSE);
ut_a(error == DB_SUCCESS);
index = dict_index_add_to_cache(
index, mach_read_from_4(dict_hdr + DICT_HDR_FIELDS));
ut_a(index);
ut_ad(!table->is_instant());
table->indexes.start->n_core_null_bytes = UT_BITS_IN_BYTES(
table->indexes.start->n_nullable);
@@ -462,7 +462,6 @@ dict_create_sys_indexes_tuple(
tuple is allocated */
{
dict_table_t* sys_indexes;
dict_table_t* table;
dtuple_t* entry;
dfield_t* dfield;
byte* ptr;
@@ -473,8 +472,6 @@ dict_create_sys_indexes_tuple(

sys_indexes = dict_sys->sys_indexes;

table = dict_table_get_low(index->table_name);

entry = dtuple_create(
heap, DICT_NUM_COLS__SYS_INDEXES + DATA_N_SYS_COLS);

@@ -485,7 +482,7 @@ dict_create_sys_indexes_tuple(
entry, DICT_COL__SYS_INDEXES__TABLE_ID);

ptr = static_cast<byte*>(mem_heap_alloc(heap, 8));
mach_write_to_8(ptr, table->id);
mach_write_to_8(ptr, index->table->id);

dfield_set_data(dfield, ptr, 8);

@@ -539,7 +536,7 @@ dict_create_sys_indexes_tuple(
entry, DICT_COL__SYS_INDEXES__SPACE);

ptr = static_cast<byte*>(mem_heap_alloc(heap, 4));
mach_write_to_4(ptr, table->space);
mach_write_to_4(ptr, index->table->space);

dfield_set_data(dfield, ptr, 4);

@@ -707,7 +704,8 @@ dict_build_index_def_step(

index = node->index;

table = dict_table_get_low(index->table_name);
table = index->table = node->table = dict_table_open_on_name(
node->table_name, TRUE, FALSE, DICT_ERR_IGNORE_NONE);

if (table == NULL) {
return(DB_TABLE_NOT_FOUND);
@@ -718,8 +716,6 @@ dict_build_index_def_step(
trx->table_id = table->id;
}

node->table = table;

ut_ad((UT_LIST_GET_LEN(table->indexes) > 0)
|| dict_index_is_clust(index));

@@ -738,6 +734,7 @@ dict_build_index_def_step(
index->trx_id = trx->id;
ut_ad(table->def_trx_id <= trx->id);
table->def_trx_id = trx->id;
dict_table_close(table, true, false);

return(DB_SUCCESS);
}
@@ -1201,13 +1198,15 @@ tab_create_graph_create(

/** Creates an index create graph.
@param[in] index index to create, built as a memory data structure
@param[in] table table name
@param[in,out] heap heap where created
@param[in] add_v new virtual columns added in the same clause with
add index
@return own: index create node */
ind_node_t*
ind_create_graph_create(
dict_index_t* index,
const char* table,
mem_heap_t* heap,
const dict_add_v_col_t* add_v)
{
@@ -1220,6 +1219,8 @@ ind_create_graph_create(

node->index = index;

node->table_name = table;

node->add_v = add_v;

node->state = INDEX_BUILD_INDEX_DEF;
@@ -1438,18 +1439,14 @@ dict_create_index_step(
}

if (node->state == INDEX_ADD_TO_CACHE) {
ut_ad(node->index->table == node->table);
node->index = dict_index_add_to_cache(
node->index, FIL_NULL, trx_is_strict(trx),
&err, node->add_v);

index_id_t index_id = node->index->id;

err = dict_index_add_to_cache_w_vcol(
node->table, node->index, node->add_v, FIL_NULL,
trx_is_strict(trx));

node->index = dict_index_get_if_in_cache_low(index_id);
ut_a((node->index == NULL) == (err != DB_SUCCESS));

if (err != DB_SUCCESS) {
ut_ad((node->index == NULL) == (err != DB_SUCCESS));

if (!node->index) {
goto function_exit;
}

0 comments on commit 428e028

Please sign in to comment.