Browse Source

MDEV-12266: Remove dict_index_t::space

We can rely on the dict_table_t::space. All indexes of a table object
are always in the same tablespace. (For fulltext indexes, the data is
located in auxiliary tables, and these will continue to have their own
table objects, separate from the main table.)
pull/687/head
Marko Mäkelä 8 years ago
parent
commit
604fea1ad6
  1. 44
      storage/innobase/btr/btr0btr.cc
  2. 5
      storage/innobase/btr/btr0bulk.cc
  3. 38
      storage/innobase/btr/btr0cur.cc
  4. 7
      storage/innobase/btr/btr0scrub.cc
  5. 13
      storage/innobase/btr/btr0sea.cc
  6. 9
      storage/innobase/dict/dict0boot.cc
  7. 16
      storage/innobase/dict/dict0crea.cc
  8. 9
      storage/innobase/dict/dict0dict.cc
  9. 12
      storage/innobase/dict/dict0load.cc
  10. 5
      storage/innobase/dict/dict0mem.cc
  11. 9
      storage/innobase/fts/fts0fts.cc
  12. 6
      storage/innobase/handler/ha_innodb.cc
  13. 30
      storage/innobase/handler/i_s.cc
  14. 5
      storage/innobase/ibuf/ibuf0ibuf.cc
  15. 4
      storage/innobase/include/btr0bulk.h
  16. 8
      storage/innobase/include/btr0sea.ic
  17. 9
      storage/innobase/include/dict0dict.h
  18. 17
      storage/innobase/include/dict0dict.ic
  19. 10
      storage/innobase/include/dict0mem.h
  20. 4
      storage/innobase/include/dict0mem.ic
  21. 2
      storage/innobase/include/row0row.h
  22. 4
      storage/innobase/lock/lock0lock.cc
  23. 3
      storage/innobase/mtr/mtr0log.cc
  24. 8
      storage/innobase/page/page0cur.cc
  25. 4
      storage/innobase/page/page0page.cc
  26. 3
      storage/innobase/page/page0zip.cc
  27. 2
      storage/innobase/pars/pars0pars.cc
  28. 2
      storage/innobase/row/row0ftsort.cc
  29. 7
      storage/innobase/row/row0import.cc
  30. 4
      storage/innobase/row/row0ins.cc
  31. 6
      storage/innobase/row/row0merge.cc
  32. 1
      storage/innobase/row/row0mysql.cc
  33. 2
      storage/innobase/row/row0quiesce.cc
  34. 2
      storage/innobase/row/row0upd.cc

44
storage/innobase/btr/btr0btr.cc

@ -1471,16 +1471,16 @@ btr_free(
ib_uint64_t
btr_read_autoinc(dict_index_t* index)
{
ut_ad(dict_index_is_clust(index));
ut_ad(index->is_primary());
ut_ad(index->table->persistent_autoinc);
ut_ad(!dict_table_is_temporary(index->table));
ut_ad(!index->table->is_temporary());
if (fil_space_t* space = fil_space_acquire(index->space)) {
if (fil_space_t* space = fil_space_acquire(index->table->space)) {
mtr_t mtr;
mtr.start();
ib_uint64_t autoinc;
if (buf_block_t* block = buf_page_get(
page_id_t(index->space, index->page),
page_id_t(space->id, index->page),
page_size_t(space->flags),
RW_S_LATCH, &mtr)) {
autoinc = page_get_autoinc(block->frame);
@ -1510,11 +1510,11 @@ btr_read_autoinc_with_fallback(const dict_table_t* table, unsigned col_no)
dict_index_t* index = dict_table_get_first_index(table);
if (index == NULL) {
} else if (fil_space_t* space = fil_space_acquire(index->space)) {
} else if (fil_space_t* space = fil_space_acquire(table->space)) {
mtr_t mtr;
mtr.start();
buf_block_t* block = buf_page_get(
page_id_t(index->space, index->page),
page_id_t(space->id, index->page),
page_size_t(space->flags),
RW_S_LATCH, &mtr);
@ -1537,7 +1537,7 @@ btr_read_autoinc_with_fallback(const dict_table_t* table, unsigned col_no)
index = dict_table_get_next_index(index);
}
if (index != NULL && index->space == space->id) {
if (index) {
autoinc = row_search_max_autoinc(index);
}
}
@ -1557,16 +1557,16 @@ btr_read_autoinc_with_fallback(const dict_table_t* table, unsigned col_no)
void
btr_write_autoinc(dict_index_t* index, ib_uint64_t autoinc, bool reset)
{
ut_ad(dict_index_is_clust(index));
ut_ad(index->is_primary());
ut_ad(index->table->persistent_autoinc);
ut_ad(!dict_table_is_temporary(index->table));
ut_ad(!index->table->is_temporary());
if (fil_space_t* space = fil_space_acquire(index->space)) {
if (fil_space_t* space = fil_space_acquire(index->table->space)) {
mtr_t mtr;
mtr.start();
mtr.set_named_space(space);
page_set_autoinc(buf_page_get(
page_id_t(index->space, index->page),
page_id_t(space->id, index->page),
page_size_t(space->flags),
RW_SX_LATCH, &mtr),
index, autoinc, &mtr, reset);
@ -4984,7 +4984,7 @@ btr_validate_level(
}
#endif
fil_space_t* space = fil_space_get(index->space);
fil_space_t* space = fil_space_get(index->table->space);
const page_size_t table_page_size(
dict_table_page_size(index->table));
const page_size_t space_page_size(space->flags);
@ -5011,8 +5011,8 @@ btr_validate_level(
ret = false;
}
ut_a(index->space == block->page.id.space());
ut_a(index->space == page_get_space_id(page));
ut_a(index->table->space == block->page.id.space());
ut_a(block->page.id.space() == page_get_space_id(page));
#ifdef UNIV_ZIP_DEBUG
page_zip = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page, index));
@ -5041,7 +5041,7 @@ btr_validate_level(
while (left_page_no != FIL_NULL) {
page_id_t left_page_id(
index->space, left_page_no);
index->table->space, left_page_no);
/* To obey latch order of tree blocks,
we should release the right_block once to
obtain lock of the uncle block. */
@ -5078,7 +5078,7 @@ loop:
ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */
ut_a(block->page.id.space() == index->space);
ut_a(block->page.id.space() == index->table->space);
if (fseg_page_is_free(space, block->page.id.page_no())) {
@ -5121,7 +5121,7 @@ loop:
savepoint = mtr_set_savepoint(&mtr);
right_block = btr_block_get(
page_id_t(index->space, right_page_no),
page_id_t(index->table->space, right_page_no),
table_page_size,
RW_SX_LATCH, index, &mtr);
@ -5298,13 +5298,13 @@ loop:
&mtr, savepoint, right_block);
btr_block_get(
page_id_t(index->space,
page_id_t(index->table->space,
parent_right_page_no),
table_page_size,
RW_SX_LATCH, index, &mtr);
right_block = btr_block_get(
page_id_t(index->space,
page_id_t(index->table->space,
right_page_no),
table_page_size,
RW_SX_LATCH, index, &mtr);
@ -5382,14 +5382,14 @@ node_ptr_fails:
if (parent_right_page_no != FIL_NULL) {
btr_block_get(
page_id_t(
index->space,
index->table->space,
parent_right_page_no),
table_page_size,
RW_SX_LATCH, index, &mtr);
}
} else if (parent_page_no != FIL_NULL) {
btr_block_get(
page_id_t(index->space,
page_id_t(index->table->space,
parent_page_no),
table_page_size,
RW_SX_LATCH, index, &mtr);
@ -5397,7 +5397,7 @@ node_ptr_fails:
}
block = btr_block_get(
page_id_t(index->space, right_page_no),
page_id_t(index->table->space, right_page_no),
table_page_size,
RW_SX_LATCH, index, &mtr);

5
storage/innobase/btr/btr0bulk.cc

@ -67,7 +67,8 @@ PageBulk::init()
ulint n_reserved;
bool success;
success = fsp_reserve_free_extents(&n_reserved, m_index->space,
success = fsp_reserve_free_extents(&n_reserved,
m_index->table->space,
1, FSP_NORMAL, &alloc_mtr);
if (!success) {
mtr_commit(&alloc_mtr);
@ -80,7 +81,7 @@ PageBulk::init()
&alloc_mtr, mtr);
if (n_reserved > 0) {
fil_space_release_free_extents(m_index->space,
fil_space_release_free_extents(m_index->table->space,
n_reserved);
}

38
storage/innobase/btr/btr0cur.cc

@ -2990,7 +2990,7 @@ btr_cur_ins_lock_and_undo(
ut_ad(!dict_index_is_online_ddl(index)
|| dict_index_is_clust(index)
|| (flags & BTR_CREATE_FLAG));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
/* Check if there is predicate or GAP lock preventing the insertion */
if (!(flags & BTR_NO_LOCKING_FLAG)) {
@ -3445,7 +3445,8 @@ btr_cur_pessimistic_insert(
ulint n_extents = cursor->tree_height / 16 + 3;
success = fsp_reserve_free_extents(&n_reserved, index->space,
success = fsp_reserve_free_extents(&n_reserved,
index->table->space,
n_extents, FSP_NORMAL, mtr);
if (!success) {
return(DB_OUT_OF_FILE_SPACE);
@ -3471,8 +3472,8 @@ btr_cur_pessimistic_insert(
if (big_rec_vec == NULL) {
if (n_reserved > 0) {
fil_space_release_free_extents(index->space,
n_reserved);
fil_space_release_free_extents(
index->table->space, n_reserved);
}
return(DB_TOO_BIG_RECORD);
}
@ -3547,7 +3548,8 @@ btr_cur_pessimistic_insert(
}
if (n_reserved > 0) {
fil_space_release_free_extents(index->space, n_reserved);
fil_space_release_free_extents(index->table->space,
n_reserved);
}
*big_rec = big_rec_vec;
@ -3585,7 +3587,7 @@ btr_cur_upd_lock_and_undo(
index = cursor->index;
ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
if (!dict_index_is_clust(index)) {
ut_ad(dict_index_is_online_ddl(index)
@ -4585,7 +4587,7 @@ btr_cur_pessimistic_update(
#endif /* UNIV_ZIP_DEBUG */
if (n_reserved > 0) {
fil_space_release_free_extents(
index->space, n_reserved);
index->table->space, n_reserved);
}
err = DB_TOO_BIG_RECORD;
@ -4614,7 +4616,7 @@ btr_cur_pessimistic_update(
ulint n_extents = cursor->tree_height / 16 + 3;
if (!fsp_reserve_free_extents(
&n_reserved, index->space, n_extents,
&n_reserved, index->table->space, n_extents,
flags & BTR_NO_UNDO_LOG_FLAG
? FSP_CLEANING : FSP_NORMAL,
mtr)) {
@ -4858,7 +4860,8 @@ return_after_reservations:
#endif /* UNIV_ZIP_DEBUG */
if (n_reserved > 0) {
fil_space_release_free_extents(index->space, n_reserved);
fil_space_release_free_extents(index->table->space,
n_reserved);
}
*big_rec = big_rec_vec;
@ -4884,7 +4887,7 @@ btr_cur_del_mark_set_clust_rec_log(
byte* log_ptr;
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
log_ptr = mlog_open_and_write_index(mtr, rec, index,
page_rec_is_comp(rec)
@ -5038,7 +5041,7 @@ btr_cur_del_mark_set_clust_rec(
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(buf_block_get_frame(block) == page_align(rec));
ut_ad(page_rec_is_leaf(rec));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
if (rec_get_deleted_flag(rec, rec_offs_comp(offsets))) {
/* We may already have delete-marked this record
@ -5319,7 +5322,7 @@ btr_cur_optimistic_delete_func(
MTR_MEMO_PAGE_X_FIX));
ut_ad(mtr_is_block_fix(mtr, btr_cur_get_block(cursor),
MTR_MEMO_PAGE_X_FIX, cursor->index->table));
ut_ad(mtr->is_named_space(cursor->index->space));
ut_ad(mtr->is_named_space(cursor->index->table->space));
/* This is intended only for leaf page deletions */
@ -5510,7 +5513,7 @@ btr_cur_pessimistic_delete(
MTR_MEMO_X_LOCK
| MTR_MEMO_SX_LOCK));
ut_ad(mtr_is_block_fix(mtr, block, MTR_MEMO_PAGE_X_FIX, index->table));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
if (!has_reserved_extents) {
/* First reserve enough free space for the file segments
@ -5520,7 +5523,7 @@ btr_cur_pessimistic_delete(
ulint n_extents = cursor->tree_height / 32 + 1;
success = fsp_reserve_free_extents(&n_reserved,
index->space,
index->table->space,
n_extents,
FSP_CLEANING, mtr);
if (!success) {
@ -5718,7 +5721,8 @@ return_after_reservations:
}
if (n_reserved > 0) {
fil_space_release_free_extents(index->space, n_reserved);
fil_space_release_free_extents(index->table->space,
n_reserved);
}
return(ret);
@ -5833,7 +5837,7 @@ btr_estimate_n_rows_in_range_on_level(
page_id_t page_id(
dict_index_get_space(index), slot1->page_no);
const fil_space_t* space = fil_space_get(index->space);
const fil_space_t* space = fil_space_get(index->table->space);
ut_ad(space);
const page_size_t page_size(space->flags);
@ -7685,7 +7689,7 @@ btr_free_externally_stored_field(
ut_ad(!(mach_read_from_4(field_ref + BTR_EXTERN_LEN)
& ~((BTR_EXTERN_OWNER_FLAG
| BTR_EXTERN_INHERITED_FLAG) << 24)));
ut_ad(space_id == index->space);
ut_ad(space_id == index->table->space);
const page_size_t ext_page_size(dict_table_page_size(index->table));
const page_size_t& rec_page_size(rec == NULL

7
storage/innobase/btr/btr0scrub.cc

@ -423,7 +423,7 @@ btr_pessimistic_scrub(
* so that splitting won't fail due to this */
ulint n_extents = 3;
ulint n_reserved = 0;
if (!fsp_reserve_free_extents(&n_reserved, index->space,
if (!fsp_reserve_free_extents(&n_reserved, index->table->space,
n_extents, FSP_NORMAL, mtr)) {
log_scrub_failure(index, scrub_data, block,
DB_OUT_OF_FILE_SPACE);
@ -523,7 +523,8 @@ btr_pessimistic_scrub(
}
if (n_reserved > 0) {
fil_space_release_free_extents(index->space, n_reserved);
fil_space_release_free_extents(index->table->space,
n_reserved);
}
scrub_data->scrub_stat.page_splits++;
@ -798,7 +799,7 @@ btr_scrub_page(
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;
}
if (scrub_data->current_index->space != scrub_data->space) {
if (scrub_data->current_index->table->space != scrub_data->space) {
/* this is truncate table */
mtr_commit(mtr);
return BTR_SCRUB_SKIP_PAGE_AND_CLOSE_TABLE;

13
storage/innobase/btr/btr0sea.cc

@ -666,7 +666,7 @@ btr_search_update_hash_ref(
return;
}
ut_ad(block->page.id.space() == index->space);
ut_ad(block->page.id.space() == index->table->space);
ut_ad(index == cursor->index);
ut_ad(!dict_index_is_ibuf(index));
@ -1151,7 +1151,7 @@ retry:
#endif
ut_ad(btr_search_enabled);
ut_ad(block->page.id.space() == index->space);
ut_ad(block->page.id.space() == index->table->space);
ut_a(index_id == index->id);
ut_a(!dict_index_is_ibuf(index));
#ifdef UNIV_DEBUG
@ -1370,7 +1370,7 @@ btr_search_build_page_hash_index(
rec_offs_init(offsets_);
ut_ad(ahi_latch == btr_get_search_latch(index));
ut_ad(index);
ut_ad(block->page.id.space() == index->space);
ut_ad(block->page.id.space() == index->table->space);
ut_a(!dict_index_is_ibuf(index));
ut_ad(page_is_leaf(block->frame));
@ -1688,7 +1688,7 @@ btr_search_update_hash_on_delete(btr_cur_t* cursor)
return;
}
ut_ad(block->page.id.space() == index->space);
ut_ad(block->page.id.space() == index->table->space);
ut_a(index == cursor->index);
ut_a(block->curr_n_fields > 0 || block->curr_n_bytes > 0);
ut_a(!dict_index_is_ibuf(index));
@ -1845,7 +1845,7 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch)
return;
}
ut_ad(block->page.id.space() == index->space);
ut_ad(block->page.id.space() == index->table->space);
btr_search_check_free_space_in_heap(index);
table = btr_get_search_table(index);
@ -2066,7 +2066,8 @@ btr_search_hash_table_validate(ulint hash_table_id)
}
ut_a(!dict_index_is_ibuf(block->index));
ut_ad(block->page.id.space() == block->index->space);
ut_ad(block->page.id.space()
== block->index->table->space);
page_index_id = btr_page_get_index_id(block->frame);

9
storage/innobase/dict/dict0boot.cc

@ -357,7 +357,6 @@ dict_boot(void)
mem_heap_empty(heap);
index = dict_mem_index_create("SYS_TABLES", "CLUST_IND",
DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 1);
dict_mem_index_add_field(index, "NAME", 0);
@ -375,8 +374,7 @@ dict_boot(void)
table->indexes.start->n_nullable);
/*-------------------------*/
index = dict_mem_index_create("SYS_TABLES", "ID_IND",
DICT_HDR_SPACE, DICT_UNIQUE, 1);
index = dict_mem_index_create("SYS_TABLES", "ID_IND", DICT_UNIQUE, 1);
dict_mem_index_add_field(index, "ID", 0);
index->id = DICT_TABLE_IDS_ID;
@ -407,7 +405,6 @@ dict_boot(void)
mem_heap_empty(heap);
index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND",
DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 2);
dict_mem_index_add_field(index, "TABLE_ID", 0);
@ -433,6 +430,8 @@ dict_boot(void)
dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "N_FIELDS", DATA_INT, 0, 4);
dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4);
/* SYS_INDEXES.SPACE is redundant and not being read;
SYS_TABLES.SPACE is being used instead. */
dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4);
dict_mem_table_add_col(table, heap, "PAGE_NO", DATA_INT, 0, 4);
dict_mem_table_add_col(table, heap, "MERGE_THRESHOLD", DATA_INT, 0, 4);
@ -452,7 +451,6 @@ dict_boot(void)
mem_heap_empty(heap);
index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND",
DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 2);
dict_mem_index_add_field(index, "TABLE_ID", 0);
@ -484,7 +482,6 @@ dict_boot(void)
mem_heap_free(heap);
index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND",
DICT_HDR_SPACE,
DICT_UNIQUE | DICT_CLUSTERED, 2);
dict_mem_index_add_field(index, "INDEX_ID", 0);

16
storage/innobase/dict/dict0crea.cc

@ -539,7 +539,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, index->space);
mach_write_to_4(ptr, table->space);
dfield_set_data(dfield, ptr, 4);
@ -728,7 +728,6 @@ dict_build_index_def_step(
/* Inherit the space id from the table; we store all indexes of a
table in the same tablespace */
index->space = table->space;
node->page_no = FIL_NULL;
row = dict_create_sys_indexes_tuple(index, node->heap);
node->ind_row = row;
@ -765,11 +764,6 @@ dict_build_index_def(
dict_hdr_get_new_id(NULL, &index->id, NULL, table, false);
/* Inherit the space id from the table; we store all indexes of a
table in the same tablespace */
index->space = table->space;
/* Note that the index was created by this transaction. */
index->trx_id = trx->id;
}
@ -841,7 +835,7 @@ dict_create_index_tree_step(
index->set_modified(mtr);
node->page_no = btr_create(
index->type, index->space,
index->type, index->table->space,
dict_table_page_size(index->table),
index->id, index, NULL, &mtr);
@ -896,7 +890,7 @@ dict_create_index_tree_in_mem(
ut_ad(!dict_table_is_discarded(index->table));
page_no = btr_create(
index->type, index->space,
index->type, index->table->space,
dict_table_page_size(index->table),
index->id, index, NULL, &mtr);
@ -995,7 +989,7 @@ dict_drop_index_tree_in_mem(
ut_ad(dict_table_is_temporary(index->table));
ulint root_page_no = page_no;
ulint space = index->space;
ulint space = index->table->space;
bool found;
const page_size_t page_size(fil_space_get_page_size(space,
&found));
@ -1107,7 +1101,7 @@ dict_truncate_index_tree_in_mem(
{
mtr_t mtr;
bool truncate;
ulint space = index->space;
ulint space = index->table->space;
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(dict_table_is_temporary(index->table));

9
storage/innobase/dict/dict0dict.cc

@ -3017,8 +3017,7 @@ dict_index_build_internal_clust(
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
/* Create a new index object with certainly enough fields */
new_index = dict_mem_index_create(table->name.m_name,
index->name, table->space,
new_index = dict_mem_index_create(table->name.m_name, index->name,
index->type,
index->n_fields + table->n_cols);
@ -3185,7 +3184,7 @@ dict_index_build_internal_non_clust(
/* Create a new index */
new_index = dict_mem_index_create(
table->name.m_name, index->name, index->space, index->type,
table->name.m_name, index->name, index->type,
index->n_fields + 1 + clust_index->n_uniq);
/* Copy other relevant data from the old index
@ -3275,7 +3274,7 @@ dict_index_build_internal_fts(
/* Create a new index */
new_index = dict_mem_index_create(
table->name.m_name, index->name, index->space, index->type,
table->name.m_name, index->name, index->type,
index->n_fields);
/* Copy other relevant data from the old index struct to the new
@ -6265,7 +6264,7 @@ dict_ind_init()
DATA_ENGLISH | DATA_NOT_NULL, 8);
dict_ind_redundant = dict_mem_index_create("SYS_DUMMY1", "SYS_DUMMY1",
DICT_HDR_SPACE, 0, 1);
0, 1);
dict_index_add_col(dict_ind_redundant, table,
dict_table_get_nth_col(table, 0), 0);
dict_ind_redundant->table = table;

12
storage/innobase/dict/dict0load.cc

@ -2255,7 +2255,6 @@ dict_load_index_low(
index_id_t id;
ulint n_fields;
ulint type;
ulint space;
unsigned merge_threshold;
if (allocate) {
@ -2353,13 +2352,6 @@ err_len:
return("unknown SYS_INDEXES.TYPE bits");
}
field = rec_get_nth_field_old(
rec, DICT_FLD__SYS_INDEXES__SPACE, &len);
if (len != 4) {
goto err_len;
}
space = mach_read_from_4(field);
field = rec_get_nth_field_old(
rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
if (len != 4) {
@ -2368,12 +2360,12 @@ err_len:
if (allocate) {
*index = dict_mem_index_create(table_name, name_buf,
space, type, n_fields);
type, n_fields);
} else {
ut_a(*index);
dict_mem_fill_index_struct(*index, NULL, NULL, name_buf,
space, type, n_fields);
type, n_fields);
}
(*index)->id = id;

5
storage/innobase/dict/dict0mem.cc

@ -723,9 +723,6 @@ dict_mem_index_create(
/*==================*/
const char* table_name, /*!< in: table name */
const char* index_name, /*!< in: index name */
ulint space, /*!< in: space where the index tree is
placed, ignored if the index is of
the clustered type */
ulint type, /*!< in: DICT_UNIQUE,
DICT_CLUSTERED, ... ORed */
ulint n_fields) /*!< in: number of fields */
@ -741,7 +738,7 @@ dict_mem_index_create(
mem_heap_zalloc(heap, sizeof(*index)));
dict_mem_fill_index_struct(index, heap, table_name, index_name,
space, type, n_fields);
type, n_fields);
dict_index_zip_pad_mutex_create_lazy(index);

9
storage/innobase/fts/fts0fts.cc

@ -1820,7 +1820,7 @@ fts_create_one_common_table(
dict_index_t* index = dict_mem_index_create(
fts_table_name, "FTS_COMMON_TABLE_IND",
new_table->space, DICT_UNIQUE|DICT_CLUSTERED, 1);
DICT_UNIQUE|DICT_CLUSTERED, 1);
if (!is_config) {
dict_mem_index_add_field(index, "doc_id", 0);
@ -1945,9 +1945,8 @@ fts_create_common_tables(
goto func_exit;
}
index = dict_mem_index_create(
name, FTS_DOC_ID_INDEX_NAME, table->space,
DICT_UNIQUE, 1);
index = dict_mem_index_create(name, FTS_DOC_ID_INDEX_NAME,
DICT_UNIQUE, 1);
dict_mem_index_add_field(index, FTS_DOC_ID_COL_NAME, 0);
op = trx_get_dict_operation(trx);
@ -2038,7 +2037,7 @@ fts_create_one_index_table(
if (error == DB_SUCCESS) {
dict_index_t* index = dict_mem_index_create(
table_name, "FTS_INDEX_TABLE_IND", new_table->space,
table_name, "FTS_INDEX_TABLE_IND",
DICT_UNIQUE|DICT_CLUSTERED, 2);
dict_mem_index_add_field(index, "word", 0);
dict_mem_index_add_field(index, "first_doc_id", 0);

6
storage/innobase/handler/ha_innodb.cc

@ -11282,7 +11282,7 @@ create_index(
if (ind_type != 0)
{
index = dict_mem_index_create(table_name, key->name.str, 0,
index = dict_mem_index_create(table_name, key->name.str,
ind_type,
key->user_defined_key_parts);
@ -11324,7 +11324,7 @@ create_index(
/* We pass 0 as the space id, and determine at a lower level the space
id where to store the table */
index = dict_mem_index_create(table_name, key->name.str, 0,
index = dict_mem_index_create(table_name, key->name.str,
ind_type, key->user_defined_key_parts);
for (ulint i = 0; i < key->user_defined_key_parts; i++) {
@ -11425,7 +11425,7 @@ create_clustered_index_when_no_primary(
id where to store the table */
index = dict_mem_index_create(table_name,
innobase_index_reserve_name,
0, DICT_CLUSTERED, 0);
DICT_CLUSTERED, 0);
error = row_create_index_for_mysql(index, trx, NULL);

30
storage/innobase/handler/i_s.cc

@ -6611,6 +6611,7 @@ i_s_dict_fill_sys_indexes(
/*======================*/
THD* thd, /*!< in: thread */
table_id_t table_id, /*!< in: table id */
ulint space_id, /*!< in: tablespace id */
dict_index_t* index, /*!< in: populated dict_index_t
struct with index info */
TABLE* table_to_fill) /*!< in/out: fill this table */
@ -6627,20 +6628,25 @@ i_s_dict_fill_sys_indexes(
OK(fields[SYS_INDEX_TABLE_ID]->store(longlong(table_id), true));
OK(fields[SYS_INDEX_TYPE]->store(index->type));
OK(fields[SYS_INDEX_TYPE]->store(index->type, true));
OK(fields[SYS_INDEX_NUM_FIELDS]->store(index->n_fields));
/* FIL_NULL is ULINT32_UNDEFINED */
if (index->page == FIL_NULL) {
OK(fields[SYS_INDEX_PAGE_NO]->store(-1));
fields[SYS_INDEX_PAGE_NO]->set_null();
} else {
OK(fields[SYS_INDEX_PAGE_NO]->store(index->page));
OK(fields[SYS_INDEX_PAGE_NO]->store(index->page, true));
}
OK(fields[SYS_INDEX_SPACE]->store(index->space));
if (space_id == ULINT_UNDEFINED) {
fields[SYS_INDEX_SPACE]->set_null();
} else {
OK(fields[SYS_INDEX_SPACE]->store(space_id, true));
}
OK(fields[SYS_INDEX_MERGE_THRESHOLD]->store(index->merge_threshold));
OK(fields[SYS_INDEX_MERGE_THRESHOLD]->store(index->merge_threshold,
true));
OK(schema_table_store_record(thd, table_to_fill));
@ -6682,19 +6688,27 @@ i_s_sys_indexes_fill_table(
while (rec) {
const char* err_msg;
table_id_t table_id;
ulint space_id;
dict_index_t index_rec;
/* Populate a dict_index_t structure with information from
a SYS_INDEXES row */
err_msg = dict_process_sys_indexes_rec(heap, rec, &index_rec,
&table_id);
const byte* field = rec_get_nth_field_old(
rec, DICT_FLD__SYS_INDEXES__SPACE, &space_id);
space_id = space_id == 4 ? mach_read_from_4(field)
: ULINT_UNDEFINED;
mtr_commit(&mtr);
mutex_exit(&dict_sys->mutex);
if (!err_msg) {
i_s_dict_fill_sys_indexes(thd, table_id, &index_rec,
tables->table);
if (int err = i_s_dict_fill_sys_indexes(
thd, table_id, space_id, &index_rec,
tables->table)) {
mem_heap_free(heap);
DBUG_RETURN(err);
}
} else {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_CANT_FIND_SYSTEM_REC, "%s",

5
storage/innobase/ibuf/ibuf0ibuf.cc

@ -561,7 +561,7 @@ ibuf_init_at_db_start(void)
ibuf->index = dict_mem_index_create(
"innodb_change_buffer", "CLUST_IND",
IBUF_SPACE_ID, DICT_CLUSTERED | DICT_IBUF, 1);
DICT_CLUSTERED | DICT_IBUF, 1);
ibuf->index->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID;
ibuf->index->table = dict_mem_table_create(
"innodb_change_buffer", IBUF_SPACE_ID, 1, 0, 0, 0);
@ -1498,8 +1498,7 @@ ibuf_dummy_index_create(
DICT_HDR_SPACE, n, 0,
comp ? DICT_TF_COMPACT : 0, 0);
index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY",
DICT_HDR_SPACE, 0, n);
index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY", 0, n);
index->table = table;

4
storage/innobase/include/btr0bulk.h

@ -285,7 +285,7 @@ public:
{
ut_ad(m_flush_observer != NULL);
#ifdef UNIV_DEBUG
fil_space_inc_redo_skipped_count(m_index->space);
fil_space_inc_redo_skipped_count(m_index->table->space);
#endif /* UNIV_DEBUG */
}
@ -296,7 +296,7 @@ public:
UT_DELETE(m_page_bulks);
#ifdef UNIV_DEBUG
fil_space_dec_redo_skipped_count(m_index->space);
fil_space_dec_redo_skipped_count(m_index->table->space);
#endif /* UNIV_DEBUG */
}

8
storage/innobase/include/btr0sea.ic

@ -169,8 +169,8 @@ btr_get_search_latch(const dict_index_t* index)
{
ut_ad(index != NULL);
ulint ifold = ut_fold_ulint_pair(static_cast<ulint>(index->id),
static_cast<ulint>(index->space));
ulint ifold = ut_fold_ulint_pair(ulint(index->id),
index->table->space);
return(btr_search_latches[ifold % btr_ahi_parts]);
}
@ -185,8 +185,8 @@ btr_get_search_table(const dict_index_t* index)
{
ut_ad(index != NULL);
ulint ifold = ut_fold_ulint_pair(static_cast<ulint>(index->id),
static_cast<ulint>(index->space));
ulint ifold = ut_fold_ulint_pair(ulint(index->id),
index->table->space);
return(btr_search_sys->hash_tables[ifold % btr_ahi_parts]);
}

9
storage/innobase/include/dict0dict.h

@ -1443,15 +1443,6 @@ dict_index_get_space(
const dict_index_t* index) /*!< in: index */
MY_ATTRIBUTE((nonnull, warn_unused_result));
/*********************************************************************//**
Sets the space id of the root of the index tree. */
UNIV_INLINE
void
dict_index_set_space(
/*=================*/
dict_index_t* index, /*!< in/out: index */
ulint space) /*!< in: space id */
MY_ATTRIBUTE((nonnull));
/*********************************************************************//**
Gets the page number of the root of the index tree.
@return page number */
UNIV_INLINE

17
storage/innobase/include/dict0dict.ic

@ -1173,22 +1173,7 @@ dict_index_get_space(
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
return(index->space);
}
/*********************************************************************//**
Sets the space id of the root of the index tree. */
UNIV_INLINE
void
dict_index_set_space(
/*=================*/
dict_index_t* index, /*!< in/out: index */
ulint space) /*!< in: space id */
{
ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
index->space = unsigned(space);
return(index->table->space);
}
/*********************************************************************//**

10
storage/innobase/include/dict0mem.h

@ -399,9 +399,6 @@ dict_mem_fill_index_struct(
mem_heap_t* heap, /*!< in: memory heap */
const char* table_name, /*!< in: table name */
const char* index_name, /*!< in: index name */
ulint space, /*!< in: space where the index tree is
placed, ignored if the index is of
the clustered type */
ulint type, /*!< in: DICT_UNIQUE,
DICT_CLUSTERED, ... ORed */
ulint n_fields); /*!< in: number of fields */
@ -413,9 +410,6 @@ dict_mem_index_create(
/*==================*/
const char* table_name, /*!< in: table name */
const char* index_name, /*!< in: index name */
ulint space, /*!< in: space where the index tree is
placed, ignored if the index is of
the clustered type */
ulint type, /*!< in: DICT_UNIQUE,
DICT_CLUSTERED, ... ORed */
ulint n_fields); /*!< in: number of fields */
@ -885,8 +879,6 @@ struct dict_index_t{
id_name_t name; /*!< index name */
const char* table_name;/*!< table name */
dict_table_t* table; /*!< back pointer to table */
unsigned space:32;
/*!< space where the index tree is placed */
unsigned page:32;/*!< index tree root page number */
unsigned merge_threshold:6;
/*!< In the pessimistic delete, if the page
@ -1950,7 +1942,7 @@ public:
inline void dict_index_t::set_modified(mtr_t& mtr) const
{
mtr.set_named_space(space);
mtr.set_named_space(table->space);
}
inline bool dict_index_t::is_readable() const

4
storage/innobase/include/dict0mem.ic

@ -39,9 +39,6 @@ dict_mem_fill_index_struct(
mem_heap_t* heap, /*!< in: memory heap */
const char* table_name, /*!< in: table name */
const char* index_name, /*!< in: index name */
ulint space, /*!< in: space where the index tree is
placed, ignored if the index is of
the clustered type */
ulint type, /*!< in: DICT_UNIQUE,
DICT_CLUSTERED, ... ORed */
ulint n_fields) /*!< in: number of fields */
@ -61,7 +58,6 @@ dict_mem_fill_index_struct(
/* Assign a ulint to a 4-bit-mapped field.
Only the low-order 4 bits are assigned. */
index->type = unsigned(type);
index->space = (unsigned int) space;
index->page = FIL_NULL;
index->merge_threshold = DICT_INDEX_MERGE_THRESHOLD_DEFAULT;
index->table_name = table_name;

2
storage/innobase/include/row0row.h

@ -398,7 +398,7 @@ row_mtr_start(mtr_t* mtr, dict_index_t* index, bool pessimistic)
{
mtr->start();
switch (index->space) {
switch (index->table->space) {
case IBUF_SPACE_ID:
if (pessimistic
&& !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) {

4
storage/innobase/lock/lock0lock.cc

@ -5338,7 +5338,7 @@ lock_rec_insert_check_and_lock(
ut_ad(!dict_index_is_online_ddl(index)
|| dict_index_is_clust(index)
|| (flags & BTR_CREATE_FLAG));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
ut_ad(page_rec_is_leaf(rec));
if (flags & BTR_NO_LOCKING_FLAG) {
@ -5709,7 +5709,7 @@ lock_sec_rec_modify_check_and_lock(
ut_ad(!dict_index_is_clust(index));
ut_ad(!dict_index_is_online_ddl(index) || (flags & BTR_CREATE_FLAG));
ut_ad(block->frame == page_align(rec));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
ut_ad(page_rec_is_leaf(rec));
ut_ad(!rec_is_default_row(rec, index));

3
storage/innobase/mtr/mtr0log.cc

@ -590,8 +590,7 @@ mlog_parse_index(
}
table = dict_mem_table_create("LOG_DUMMY", DICT_HDR_SPACE, n, 0,
comp ? DICT_TF_COMPACT : 0, 0);
ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY",
DICT_HDR_SPACE, 0, n);
ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY", 0, n);
ind->table = table;
ind->n_uniq = (unsigned int) n_uniq;
if (n_uniq != n) {

8
storage/innobase/page/page0cur.cc

@ -850,7 +850,7 @@ page_cur_insert_rec_write_log(
}
ut_a(rec_size < UNIV_PAGE_SIZE);
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
ut_ad(page_align(insert_rec) == page_align(cursor_rec));
ut_ad(!page_rec_is_comp(insert_rec)
== !dict_table_is_comp(index->table));
@ -1937,7 +1937,7 @@ page_copy_rec_list_to_created_page_write_log(
byte* log_ptr;
ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
log_ptr = mlog_open_and_write_index(mtr, page, index,
page_is_comp(page)
@ -2213,7 +2213,7 @@ page_cur_delete_rec_write_log(
byte* log_ptr;
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
log_ptr = mlog_open_and_write_index(mtr, rec, index,
page_rec_is_comp(rec)
@ -2323,7 +2323,7 @@ page_cur_delete_rec(
ut_ad(mach_read_from_8(page + PAGE_HEADER + PAGE_INDEX_ID) == index->id
|| index->is_dummy
|| (mtr ? mtr->is_inside_ibuf() : dict_index_is_ibuf(index)));
ut_ad(mtr == NULL || mtr->is_named_space(index->space));
ut_ad(!mtr || mtr->is_named_space(index->table->space));
/* The record must not be the supremum or infimum record. */
ut_ad(page_rec_is_user_rec(current_rec));

4
storage/innobase/page/page0page.cc

@ -238,9 +238,9 @@ page_set_autoinc(
{
ut_ad(mtr_memo_contains_flagged(
mtr, block, MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX));
ut_ad(dict_index_is_clust(index));
ut_ad(index->is_primary());
ut_ad(index->page == block->page.id.page_no());
ut_ad(index->space == block->page.id.space());
ut_ad(index->table->space == block->page.id.space());
byte* field = PAGE_HEADER + PAGE_ROOT_AUTO_INC
+ buf_block_get_frame(block);

3
storage/innobase/page/page0zip.cc

@ -1709,8 +1709,7 @@ page_zip_fields_decode(
table = dict_mem_table_create("ZIP_DUMMY", DICT_HDR_SPACE, n, 0,
DICT_TF_COMPACT, 0);
index = dict_mem_index_create("ZIP_DUMMY", "ZIP_DUMMY",
DICT_HDR_SPACE, 0, n);
index = dict_mem_index_create("ZIP_DUMMY", "ZIP_DUMMY", 0, n);
index->table = table;
index->n_uniq = unsigned(n);
/* avoid ut_ad(index->cached) in dict_index_get_n_unique_in_tree */

2
storage/innobase/pars/pars0pars.cc

@ -1974,7 +1974,7 @@ pars_create_index(
ind_type = ind_type | DICT_CLUSTERED;
}
index = dict_mem_index_create(table_sym->name, index_sym->name, 0,
index = dict_mem_index_create(table_sym->name, index_sym->name,
ind_type, n_fields);
column = column_list;

2
storage/innobase/row/row0ftsort.cc

@ -87,7 +87,7 @@ row_merge_create_fts_sort_index(
// FIXME: This name shouldn't be hard coded here.
new_index = dict_mem_index_create(
index->table->name.m_name, "tmp_fts_idx", 0, DICT_FTS, 3);
index->table->name.m_name, "tmp_fts_idx", DICT_FTS, 3);
new_index->id = index->id;
new_index->table = (dict_table_t*) table;

7
storage/innobase/row/row0import.cc

@ -1318,8 +1318,6 @@ row_import::set_root_by_name() UNIV_NOTHROW
/* We've already checked that it exists. */
ut_a(index != 0);
/* Set the root page number and space id. */
index->space = m_table->space;
index->page = cfg_index->m_page_no;
}
}
@ -1379,7 +1377,6 @@ row_import::set_root_by_heuristic() UNIV_NOTHROW
cfg_index[i].m_srv_index = index;
index->space = m_table->space;
index->page = cfg_index[i].m_page_no;
++i;
@ -2054,7 +2051,6 @@ row_import_discard_changes(
index = UT_LIST_GET_NEXT(indexes, index)) {
index->page = FIL_NULL;
index->space = FIL_NULL;
}
table->file_unreadable = true;
@ -2156,7 +2152,6 @@ row_import_adjust_root_pages_of_secondary_indexes(
ut_a(!dict_index_is_clust(index));
if (!(index->type & DICT_CORRUPT)
&& index->space != FIL_NULL
&& index->page != FIL_NULL) {
/* Update the Btree segment headers for index node and
@ -3129,7 +3124,7 @@ row_import_update_index_root(
mach_write_to_4(
reinterpret_cast<byte*>(&space),
reset ? FIL_NULL : index->space);
reset ? FIL_NULL : index->table->space);
mach_write_to_8(
reinterpret_cast<byte*>(&index_id),

4
storage/innobase/row/row0ins.cc

@ -2797,7 +2797,7 @@ row_ins_sec_mtr_start_and_check_if_aborted(
ulint search_mode)
{
ut_ad(!dict_index_is_clust(index));
ut_ad(mtr->is_named_space(index->space));
ut_ad(mtr->is_named_space(index->table->space));
const mtr_log_t log_mode = mtr->get_log_mode();
@ -3309,7 +3309,7 @@ row_ins_sec_index_entry(
if (err == DB_FAIL) {
mem_heap_empty(heap);
if (index->space == IBUF_SPACE_ID
if (index->table->space == IBUF_SPACE_ID
&& !(index->type & (DICT_UNIQUE | DICT_SPATIAL))) {
ibuf_free_excess_pages();
}

6
storage/innobase/row/row0merge.cc

@ -4469,7 +4469,7 @@ row_merge_create_index(
a lower level the space id where to store the table. */
index = dict_mem_index_create(table->name.m_name, index_def->name,
0, index_def->ind_type, n_fields);
index_def->ind_type, n_fields);
index->table = table;
index->set_committed(index_def->rebuild);
@ -4556,12 +4556,12 @@ row_merge_write_redo(
mtr_t mtr;
byte* log_ptr;
ut_ad(!dict_table_is_temporary(index->table));
ut_ad(!index->table->is_temporary());
mtr.start();
log_ptr = mlog_open(&mtr, 11 + 8);
log_ptr = mlog_write_initial_log_record_low(
MLOG_INDEX_LOAD,
index->space, index->page, log_ptr, &mtr);
index->table->space, index->page, log_ptr, &mtr);
mach_write_to_8(log_ptr, index->id);
mlog_close(&mtr, log_ptr + 8);
mtr.commit();

1
storage/innobase/row/row0mysql.cc

@ -3219,7 +3219,6 @@ row_discard_tablespace(
index = UT_LIST_GET_NEXT(indexes, index)) {
index->page = FIL_NULL;
index->space = FIL_NULL;
}
/* If the tablespace did not already exist or we couldn't

2
storage/innobase/row/row0quiesce.cc

@ -145,7 +145,7 @@ row_quiesce_write_indexes(
mach_write_to_8(ptr, index->id);
ptr += sizeof(index_id_t);
mach_write_to_4(ptr, index->space);
mach_write_to_4(ptr, table->space);
ptr += sizeof(ib_uint32_t);
mach_write_to_4(ptr, index->page);

2
storage/innobase/row/row0upd.cc

@ -2313,7 +2313,7 @@ row_upd_sec_index_entry(
mtr.start();
switch (index->space) {
switch (index->table->space) {
case SRV_TMP_SPACE_ID:
mtr.set_log_mode(MTR_LOG_NO_REDO);
flags = BTR_NO_LOCKING_FLAG;

Loading…
Cancel
Save