Loading innobase/dict/dict0boot.c +19 −15 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ dict_boot(void) dict_index_t* index; dict_hdr_t* dict_hdr; mtr_t mtr; ibool success; mtr_start(&mtr); Loading Loading @@ -275,20 +276,20 @@ dict_boot(void) dict_mem_index_add_field(index, "NAME", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_TABLES, MLOG_4BYTES, &mtr); index->id = DICT_TABLES_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_TABLE_IDS, MLOG_4BYTES, &mtr); index->id = DICT_TABLE_IDS_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, FALSE); Loading @@ -311,10 +312,10 @@ dict_boot(void) dict_mem_index_add_field(index, "TABLE_ID", 0, 0); dict_mem_index_add_field(index, "POS", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_COLUMNS, MLOG_4BYTES, &mtr); index->id = DICT_COLUMNS_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, FALSE); Loading @@ -332,6 +333,9 @@ dict_boot(void) #endif #if DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2 #error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2" #endif #if DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2 #error "DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2" #endif table->id = DICT_INDEXES_ID; Loading @@ -344,10 +348,10 @@ dict_boot(void) dict_mem_index_add_field(index, "TABLE_ID", 0, 0); dict_mem_index_add_field(index, "ID", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_INDEXES, MLOG_4BYTES, &mtr); index->id = DICT_INDEXES_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, FALSE); Loading @@ -365,10 +369,10 @@ dict_boot(void) dict_mem_index_add_field(index, "INDEX_ID", 0, 0); dict_mem_index_add_field(index, "POS", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_FIELDS, MLOG_4BYTES, &mtr); index->id = DICT_FIELDS_ID; ut_a(dict_index_add_to_cache(table, index)); success = dict_index_add_to_cache(table, index, mtr_read_ulint( dict_hdr + DICT_HDR_FIELDS, MLOG_4BYTES, &mtr)); ut_a(success); mtr_commit(&mtr); /*-------------------------*/ Loading innobase/dict/dict0crea.c +102 −7 Original line number Diff line number Diff line Loading @@ -544,9 +544,7 @@ dict_build_index_def_step( table in the same tablespace */ index->space = table->space; index->page_no = FIL_NULL; node->page_no = FIL_NULL; row = dict_create_sys_indexes_tuple(index, node->heap); node->ind_row = row; Loading Loading @@ -624,18 +622,18 @@ dict_create_index_tree_step( btr_pcur_move_to_next_user_rec(&pcur, &mtr); index->page_no = btr_create(index->type, index->space, index->id, node->page_no = btr_create(index->type, index->space, index->id, table->comp, &mtr); /* printf("Created a new index tree in space %lu root page %lu\n", index->space, index->page_no); */ page_rec_write_index_page_no(btr_pcur_get_rec(&pcur), DICT_SYS_INDEXES_PAGE_NO_FIELD, index->page_no, &mtr); node->page_no, &mtr); btr_pcur_close(&pcur); mtr_commit(&mtr); if (index->page_no == FIL_NULL) { if (node->page_no == FIL_NULL) { return(DB_OUT_OF_FILE_SPACE); } Loading Loading @@ -706,6 +704,101 @@ dict_drop_index_tree( DICT_SYS_INDEXES_PAGE_NO_FIELD, FIL_NULL, mtr); } /*********************************************************************** Truncates the index tree associated with a row in SYS_INDEXES table. */ void dict_truncate_index_tree( /*=====================*/ dict_table_t* table, /* in: the table the index belongs to */ rec_t* rec, /* in: record in the clustered index of SYS_INDEXES table */ mtr_t* mtr) /* in: mtr having the latch on the record page */ { ulint root_page_no; ulint space; ulint type; dulint index_id; byte* ptr; ulint len; ibool comp; dict_index_t* index; #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ ut_a(!dict_sys->sys_indexes->comp); ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len); ut_ad(len == 4); root_page_no = mtr_read_ulint(ptr, MLOG_4BYTES, mtr); if (root_page_no == FIL_NULL) { /* The tree has been freed. */ return; } ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); ut_ad(len == 4); space = mtr_read_ulint(ptr, MLOG_4BYTES, mtr); if (!fil_tablespace_exists_in_mem(space)) { /* It is a single table tablespace and the .ibd file is missing: do nothing */ return; } ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_TYPE_FIELD, &len); ut_ad(len == 4); type = mach_read_from_4(ptr); ptr = rec_get_nth_field_old(rec, 1, &len); ut_ad(len == 8); index_id = mach_read_from_8(ptr); /* We free all the pages but the root page first; this operation may span several mini-transactions */ btr_free_but_not_root(space, root_page_no); /* Then we free the root page in the same mini-transaction where we create the b-tree and write its new root page number to the appropriate field in the SYS_INDEXES record: this mini-transaction marks the B-tree totally truncated */ comp = page_is_comp(btr_page_get( space, root_page_no, RW_X_LATCH, mtr)); btr_free_root(space, root_page_no, mtr); /* Find the index corresponding to this SYS_INDEXES record. */ for (index = UT_LIST_GET_FIRST(table->indexes); index; index = UT_LIST_GET_NEXT(indexes, index)) { if (!ut_dulint_cmp(index->id, index_id)) { break; } } root_page_no = btr_create(type, space, index_id, comp, mtr); if (index) { index->tree->page = root_page_no; } page_rec_write_index_page_no(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, root_page_no, mtr); } /************************************************************************* Creates a table create graph. */ Loading Loading @@ -762,6 +855,7 @@ ind_create_graph_create( node->index = index; node->state = INDEX_BUILD_INDEX_DEF; node->page_no = FIL_NULL; node->heap = mem_heap_create(256); node->ind_def = ins_node_create(INS_DIRECT, Loading Loading @@ -981,7 +1075,8 @@ dict_create_index_step( if (node->state == INDEX_ADD_TO_CACHE) { success = dict_index_add_to_cache(node->table, node->index); success = dict_index_add_to_cache(node->table, node->index, node->page_no); ut_a(success); Loading innobase/dict/dict0dict.c +6 −7 Original line number Diff line number Diff line Loading @@ -1374,8 +1374,9 @@ 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 dict_index_t* index, /* in, own: index; NOTE! The index memory object is freed in this function! */ ulint page_no)/* in: root page number of the index */ { dict_index_t* new_index; dict_tree_t* tree; Loading Loading @@ -1461,10 +1462,9 @@ dict_index_add_to_cache( tree = dict_index_get_tree( UT_LIST_GET_FIRST(cluster->indexes)); new_index->tree = tree; new_index->page_no = tree->page; } else { /* Create an index tree memory object for the index */ tree = dict_tree_create(new_index); tree = dict_tree_create(new_index, page_no); ut_ad(tree); new_index->tree = tree; Loading Loading @@ -1749,7 +1749,6 @@ dict_index_build_internal_clust( new_index->n_user_defined_cols = index->n_fields; new_index->id = index->id; new_index->page_no = index->page_no; if (table->type != DICT_TABLE_ORDINARY) { /* The index is mixed: copy common key prefix fields */ Loading Loading @@ -1928,7 +1927,6 @@ dict_index_build_internal_non_clust( new_index->n_user_defined_cols = index->n_fields; new_index->id = index->id; new_index->page_no = index->page_no; /* Copy fields from index to new_index */ dict_index_copy(new_index, index, 0, index->n_fields); Loading Loading @@ -3565,9 +3563,10 @@ dict_tree_t* dict_tree_create( /*=============*/ /* out, own: created tree */ dict_index_t* index) /* in: the index for which to create: in the dict_index_t* index, /* in: the index for which to create: in the case of a mixed tree, this should be the index of the cluster object */ ulint page_no)/* in: root page number of the index */ { dict_tree_t* tree; Loading @@ -3577,7 +3576,7 @@ dict_tree_create( tree->type = index->type; tree->space = index->space; tree->page = index->page_no; tree->page = page_no; tree->id = index->id; Loading innobase/dict/dict0load.c +1 −3 Original line number Diff line number Diff line Loading @@ -681,12 +681,10 @@ dict_load_indexes( } else { index = dict_mem_index_create(table->name, name_buf, space, type, n_fields); index->page_no = page_no; index->id = id; dict_load_fields(table, index, heap); dict_index_add_to_cache(table, index); dict_index_add_to_cache(table, index, page_no); } btr_pcur_move_to_next_user_rec(&pcur, &mtr); Loading innobase/ibuf/ibuf0ibuf.c +1 −3 Original line number Diff line number Diff line Loading @@ -548,11 +548,9 @@ ibuf_data_init_for_space( dict_mem_index_add_field(index, "PAGE_NO", 0, 0); dict_mem_index_add_field(index, "TYPES", 0, 0); index->page_no = FSP_IBUF_TREE_ROOT_PAGE_NO; index->id = ut_dulint_add(DICT_IBUF_ID_MIN, space); dict_index_add_to_cache(table, index); dict_index_add_to_cache(table, index, FSP_IBUF_TREE_ROOT_PAGE_NO); data->index = dict_table_get_first_index(table); Loading Loading
innobase/dict/dict0boot.c +19 −15 Original line number Diff line number Diff line Loading @@ -223,6 +223,7 @@ dict_boot(void) dict_index_t* index; dict_hdr_t* dict_hdr; mtr_t mtr; ibool success; mtr_start(&mtr); Loading Loading @@ -275,20 +276,20 @@ dict_boot(void) dict_mem_index_add_field(index, "NAME", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_TABLES, MLOG_4BYTES, &mtr); index->id = DICT_TABLES_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_TABLE_IDS, MLOG_4BYTES, &mtr); index->id = DICT_TABLE_IDS_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, FALSE); Loading @@ -311,10 +312,10 @@ dict_boot(void) dict_mem_index_add_field(index, "TABLE_ID", 0, 0); dict_mem_index_add_field(index, "POS", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_COLUMNS, MLOG_4BYTES, &mtr); index->id = DICT_COLUMNS_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, FALSE); Loading @@ -332,6 +333,9 @@ dict_boot(void) #endif #if DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2 #error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2" #endif #if DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2 #error "DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2" #endif table->id = DICT_INDEXES_ID; Loading @@ -344,10 +348,10 @@ dict_boot(void) dict_mem_index_add_field(index, "TABLE_ID", 0, 0); dict_mem_index_add_field(index, "ID", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_INDEXES, MLOG_4BYTES, &mtr); index->id = DICT_INDEXES_ID; ut_a(dict_index_add_to_cache(table, index)); success = 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, FALSE); Loading @@ -365,10 +369,10 @@ dict_boot(void) dict_mem_index_add_field(index, "INDEX_ID", 0, 0); dict_mem_index_add_field(index, "POS", 0, 0); index->page_no = mtr_read_ulint(dict_hdr + DICT_HDR_FIELDS, MLOG_4BYTES, &mtr); index->id = DICT_FIELDS_ID; ut_a(dict_index_add_to_cache(table, index)); success = dict_index_add_to_cache(table, index, mtr_read_ulint( dict_hdr + DICT_HDR_FIELDS, MLOG_4BYTES, &mtr)); ut_a(success); mtr_commit(&mtr); /*-------------------------*/ Loading
innobase/dict/dict0crea.c +102 −7 Original line number Diff line number Diff line Loading @@ -544,9 +544,7 @@ dict_build_index_def_step( table in the same tablespace */ index->space = table->space; index->page_no = FIL_NULL; node->page_no = FIL_NULL; row = dict_create_sys_indexes_tuple(index, node->heap); node->ind_row = row; Loading Loading @@ -624,18 +622,18 @@ dict_create_index_tree_step( btr_pcur_move_to_next_user_rec(&pcur, &mtr); index->page_no = btr_create(index->type, index->space, index->id, node->page_no = btr_create(index->type, index->space, index->id, table->comp, &mtr); /* printf("Created a new index tree in space %lu root page %lu\n", index->space, index->page_no); */ page_rec_write_index_page_no(btr_pcur_get_rec(&pcur), DICT_SYS_INDEXES_PAGE_NO_FIELD, index->page_no, &mtr); node->page_no, &mtr); btr_pcur_close(&pcur); mtr_commit(&mtr); if (index->page_no == FIL_NULL) { if (node->page_no == FIL_NULL) { return(DB_OUT_OF_FILE_SPACE); } Loading Loading @@ -706,6 +704,101 @@ dict_drop_index_tree( DICT_SYS_INDEXES_PAGE_NO_FIELD, FIL_NULL, mtr); } /*********************************************************************** Truncates the index tree associated with a row in SYS_INDEXES table. */ void dict_truncate_index_tree( /*=====================*/ dict_table_t* table, /* in: the table the index belongs to */ rec_t* rec, /* in: record in the clustered index of SYS_INDEXES table */ mtr_t* mtr) /* in: mtr having the latch on the record page */ { ulint root_page_no; ulint space; ulint type; dulint index_id; byte* ptr; ulint len; ibool comp; dict_index_t* index; #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ ut_a(!dict_sys->sys_indexes->comp); ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len); ut_ad(len == 4); root_page_no = mtr_read_ulint(ptr, MLOG_4BYTES, mtr); if (root_page_no == FIL_NULL) { /* The tree has been freed. */ return; } ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); ut_ad(len == 4); space = mtr_read_ulint(ptr, MLOG_4BYTES, mtr); if (!fil_tablespace_exists_in_mem(space)) { /* It is a single table tablespace and the .ibd file is missing: do nothing */ return; } ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_TYPE_FIELD, &len); ut_ad(len == 4); type = mach_read_from_4(ptr); ptr = rec_get_nth_field_old(rec, 1, &len); ut_ad(len == 8); index_id = mach_read_from_8(ptr); /* We free all the pages but the root page first; this operation may span several mini-transactions */ btr_free_but_not_root(space, root_page_no); /* Then we free the root page in the same mini-transaction where we create the b-tree and write its new root page number to the appropriate field in the SYS_INDEXES record: this mini-transaction marks the B-tree totally truncated */ comp = page_is_comp(btr_page_get( space, root_page_no, RW_X_LATCH, mtr)); btr_free_root(space, root_page_no, mtr); /* Find the index corresponding to this SYS_INDEXES record. */ for (index = UT_LIST_GET_FIRST(table->indexes); index; index = UT_LIST_GET_NEXT(indexes, index)) { if (!ut_dulint_cmp(index->id, index_id)) { break; } } root_page_no = btr_create(type, space, index_id, comp, mtr); if (index) { index->tree->page = root_page_no; } page_rec_write_index_page_no(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, root_page_no, mtr); } /************************************************************************* Creates a table create graph. */ Loading Loading @@ -762,6 +855,7 @@ ind_create_graph_create( node->index = index; node->state = INDEX_BUILD_INDEX_DEF; node->page_no = FIL_NULL; node->heap = mem_heap_create(256); node->ind_def = ins_node_create(INS_DIRECT, Loading Loading @@ -981,7 +1075,8 @@ dict_create_index_step( if (node->state == INDEX_ADD_TO_CACHE) { success = dict_index_add_to_cache(node->table, node->index); success = dict_index_add_to_cache(node->table, node->index, node->page_no); ut_a(success); Loading
innobase/dict/dict0dict.c +6 −7 Original line number Diff line number Diff line Loading @@ -1374,8 +1374,9 @@ 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 dict_index_t* index, /* in, own: index; NOTE! The index memory object is freed in this function! */ ulint page_no)/* in: root page number of the index */ { dict_index_t* new_index; dict_tree_t* tree; Loading Loading @@ -1461,10 +1462,9 @@ dict_index_add_to_cache( tree = dict_index_get_tree( UT_LIST_GET_FIRST(cluster->indexes)); new_index->tree = tree; new_index->page_no = tree->page; } else { /* Create an index tree memory object for the index */ tree = dict_tree_create(new_index); tree = dict_tree_create(new_index, page_no); ut_ad(tree); new_index->tree = tree; Loading Loading @@ -1749,7 +1749,6 @@ dict_index_build_internal_clust( new_index->n_user_defined_cols = index->n_fields; new_index->id = index->id; new_index->page_no = index->page_no; if (table->type != DICT_TABLE_ORDINARY) { /* The index is mixed: copy common key prefix fields */ Loading Loading @@ -1928,7 +1927,6 @@ dict_index_build_internal_non_clust( new_index->n_user_defined_cols = index->n_fields; new_index->id = index->id; new_index->page_no = index->page_no; /* Copy fields from index to new_index */ dict_index_copy(new_index, index, 0, index->n_fields); Loading Loading @@ -3565,9 +3563,10 @@ dict_tree_t* dict_tree_create( /*=============*/ /* out, own: created tree */ dict_index_t* index) /* in: the index for which to create: in the dict_index_t* index, /* in: the index for which to create: in the case of a mixed tree, this should be the index of the cluster object */ ulint page_no)/* in: root page number of the index */ { dict_tree_t* tree; Loading @@ -3577,7 +3576,7 @@ dict_tree_create( tree->type = index->type; tree->space = index->space; tree->page = index->page_no; tree->page = page_no; tree->id = index->id; Loading
innobase/dict/dict0load.c +1 −3 Original line number Diff line number Diff line Loading @@ -681,12 +681,10 @@ dict_load_indexes( } else { index = dict_mem_index_create(table->name, name_buf, space, type, n_fields); index->page_no = page_no; index->id = id; dict_load_fields(table, index, heap); dict_index_add_to_cache(table, index); dict_index_add_to_cache(table, index, page_no); } btr_pcur_move_to_next_user_rec(&pcur, &mtr); Loading
innobase/ibuf/ibuf0ibuf.c +1 −3 Original line number Diff line number Diff line Loading @@ -548,11 +548,9 @@ ibuf_data_init_for_space( dict_mem_index_add_field(index, "PAGE_NO", 0, 0); dict_mem_index_add_field(index, "TYPES", 0, 0); index->page_no = FSP_IBUF_TREE_ROOT_PAGE_NO; index->id = ut_dulint_add(DICT_IBUF_ID_MIN, space); dict_index_add_to_cache(table, index); dict_index_add_to_cache(table, index, FSP_IBUF_TREE_ROOT_PAGE_NO); data->index = dict_table_get_first_index(table); Loading