From: kevin.lewis Date: January 18 2012 3:41pm Subject: bzr push into mysql-trunk branch (kevin.lewis:3746 to 3747) List-Archive: http://lists.mysql.com/commits/142472 Message-Id: <20120118154114.B99321D368D5@dhcp-adc-twvpn-2-vpnpool-10-154-48-42.vpn.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3747 kevin.lewis@stripped 2012-01-18 The primary change is to use macro constants for system table field and column numbers more consistently. The code uses hard coded numbers for both column numbers and cluster index field numbers. Contants are used very inconsistently. This patch uses the convention DICT_COL__{table_name}__{column_name) for the columns of the table and of DICT_FLD__{table_name}__{column_name) for the field numbers in the indexes. Instead of using precompiled macros, these constants are declared as enum values which the debugger can interpret. The preprocessor macros that tested the consistency of these constants are converted to debug runtime asserts. Some included files are deleted from ha_innodb.cc since they no longer need to be included directly. All other changes are just code cleanup. Patch approved by Marko in http://bur03.no.oracle.com/rb/r/877. modified: storage/innobase/dict/dict0boot.cc storage/innobase/dict/dict0crea.cc storage/innobase/dict/dict0dict.cc storage/innobase/dict/dict0load.cc storage/innobase/dict/dict0mem.cc storage/innobase/fil/fil0fil.cc storage/innobase/handler/ha_innodb.cc storage/innobase/handler/i_s.cc storage/innobase/include/dict0boot.h storage/innobase/include/dict0mem.h storage/innobase/include/dict0types.h storage/innobase/include/fil0fil.h storage/innobase/pars/pars0pars.cc storage/innobase/row/row0merge.cc storage/innobase/row/row0mysql.cc storage/innobase/srv/srv0start.cc 3746 Tor Didriksen 2012-01-18 Bug#13580775 ASSERTION FAILED: RECORD_LENGTH == M_RECORD_LENGTH filesort tries to re-use the sort buffer between invocations in order to save malloc/free overhead. The fix for Bug 11748783 - 37359: FILESORT CAN BE MORE EFFICIENT. added an assert that buffer properties (num_records, record_length) are consistent between invocations. Indeed, they are not necessarily consistent. Fix: re-allocate the sort buffer if properties change. @ mysql-test/r/partition.result New test case. @ mysql-test/t/partition.test New test case. @ sql/filesort.cc If we already have allocated a sort buffer, then verify that the same properties (keys, rec_length) that we need for this invocation. @ sql/filesort_utils.h Add sort_buffer_properties @ sql/table.h Add sort_buffer_properties @ unittest/gunit/filesort_buffer-t.cc Test new member funciton. modified: mysql-test/r/partition.result mysql-test/t/partition.test sql/filesort.cc sql/filesort_utils.h sql/table.h unittest/gunit/filesort_buffer-t.cc === modified file 'storage/innobase/dict/dict0boot.cc' --- a/storage/innobase/dict/dict0boot.cc revid:tor.didriksen@stripped +++ b/storage/innobase/dict/dict0boot.cc revid:kevin.lewis@stripped @@ -254,6 +254,28 @@ dict_boot(void) mtr_t mtr; ulint error; + /* Be sure these constants do not ever change. To avoid bloat, + only check the *NUM_FIELDS* in each table */ + + ut_ad(DICT_NUM_COLS__SYS_TABLES == 8); + ut_ad(DICT_NUM_FIELDS__SYS_TABLES == 10); + ut_ad(DICT_NUM_FIELDS__SYS_TABLE_IDS == 2); + ut_ad(DICT_NUM_COLS__SYS_COLUMNS == 7); + ut_ad(DICT_NUM_FIELDS__SYS_COLUMNS == 9); + ut_ad(DICT_NUM_COLS__SYS_INDEXES == 7); + ut_ad(DICT_NUM_FIELDS__SYS_INDEXES == 9); + ut_ad(DICT_NUM_COLS__SYS_FIELDS == 3); + ut_ad(DICT_NUM_FIELDS__SYS_FIELDS == 5); + ut_ad(DICT_NUM_COLS__SYS_FOREIGN == 4); + ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN == 6); + ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN_FOR_NAME == 2); + ut_ad(DICT_NUM_COLS__SYS_FOREIGN_COLS == 4); + ut_ad(DICT_NUM_FIELDS__SYS_FOREIGN_COLS == 6); + ut_ad(DICT_NUM_COLS__SYS_TABLESPACES == 3); + ut_ad(DICT_NUM_FIELDS__SYS_TABLESPACES == 5); + ut_ad(DICT_NUM_COLS__SYS_DATAFILES == 2); + ut_ad(DICT_NUM_FIELDS__SYS_DATAFILES == 4); + mtr_start(&mtr); /* Create the hash tables etc. */ @@ -379,20 +401,6 @@ dict_boot(void) 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); - /* The '+ 2' below comes from the fields DB_TRX_ID, DB_ROLL_PTR */ -#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2 -#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2" -#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 -#if DICT_SYS_INDEXES_NAME_FIELD != 2 + 2 -#error "DICT_SYS_INDEXES_NAME_FIELD != 2 + 2" -#endif - table->id = DICT_INDEXES_ID; dict_table_add_to_cache(table, FALSE, heap); === modified file 'storage/innobase/dict/dict0crea.cc' --- a/storage/innobase/dict/dict0crea.cc revid:tor.didriksen@stripped +++ b/storage/innobase/dict/dict0crea.cc revid:kevin.lewis@stripped @@ -73,12 +73,16 @@ dict_create_sys_tables_tuple( dict_table_copy_types(entry, sys_tables); /* 0: NAME -----------------------------*/ - dfield = dtuple_get_nth_field(entry, 0/*NAME*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__NAME); dfield_set_data(dfield, table->name, ut_strlen(table->name)); + /* 1: DB_TRX_ID added later */ + /* 2: DB_ROLL_PTR added later */ /* 3: ID -------------------------------*/ - dfield = dtuple_get_nth_field(entry, 1/*ID*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__ID); ptr = static_cast(mem_heap_alloc(heap, 8)); mach_write_to_8(ptr, table->id); @@ -86,7 +90,8 @@ dict_create_sys_tables_tuple( dfield_set_data(dfield, ptr, 8); /* 4: N_COLS ---------------------------*/ - dfield = dtuple_get_nth_field(entry, 2/*N_COLS*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__N_COLS); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, table->n_def @@ -94,7 +99,8 @@ dict_create_sys_tables_tuple( dfield_set_data(dfield, ptr, 4); /* 5: TYPE (table flags) -----------------------------*/ - dfield = dtuple_get_nth_field(entry, 3/*TYPE*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__TYPE); ptr = static_cast(mem_heap_alloc(heap, 4)); @@ -107,14 +113,16 @@ dict_create_sys_tables_tuple( dfield_set_data(dfield, ptr, 4); /* 6: MIX_ID (obsolete) ---------------------------*/ - dfield = dtuple_get_nth_field(entry, 4/*MIX_ID*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__MIX_ID); ptr = static_cast(mem_heap_zalloc(heap, 8)); dfield_set_data(dfield, ptr, 8); /* 7: MIX_LEN (additional flags) --------------------------*/ - dfield = dtuple_get_nth_field(entry, 5/*MIX_LEN*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__MIX_LEN); ptr = static_cast(mem_heap_alloc(heap, 4)); /* Be sure all non-used bits are zero. */ @@ -124,11 +132,13 @@ dict_create_sys_tables_tuple( dfield_set_data(dfield, ptr, 4); /* 8: CLUSTER_NAME ---------------------*/ - dfield = dtuple_get_nth_field(entry, 6/*CLUSTER_NAME*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__CLUSTER_ID); dfield_set_null(dfield); /* not supported */ /* 9: SPACE ----------------------------*/ - dfield = dtuple_get_nth_field(entry, 7/*SPACE*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_TABLES__SPACE); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, table->space); @@ -172,47 +182,55 @@ dict_create_sys_columns_tuple( dict_table_copy_types(entry, sys_columns); /* 0: TABLE_ID -----------------------*/ - dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__TABLE_ID); ptr = static_cast(mem_heap_alloc(heap, 8)); mach_write_to_8(ptr, table->id); dfield_set_data(dfield, ptr, 8); + /* 1: POS ----------------------------*/ - dfield = dtuple_get_nth_field(entry, 1/*POS*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__POS); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, i); dfield_set_data(dfield, ptr, 4); + + /* 2: DB_TRX_ID added later */ + /* 3: DB_ROLL_PTR added later */ /* 4: NAME ---------------------------*/ - dfield = dtuple_get_nth_field(entry, 2/*NAME*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__NAME); col_name = dict_table_get_col_name(table, i); dfield_set_data(dfield, col_name, ut_strlen(col_name)); + /* 5: MTYPE --------------------------*/ - dfield = dtuple_get_nth_field(entry, 3/*MTYPE*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__MTYPE); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, column->mtype); dfield_set_data(dfield, ptr, 4); + /* 6: PRTYPE -------------------------*/ - dfield = dtuple_get_nth_field(entry, 4/*PRTYPE*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__PRTYPE); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, column->prtype); dfield_set_data(dfield, ptr, 4); + /* 7: LEN ----------------------------*/ - dfield = dtuple_get_nth_field(entry, 5/*LEN*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__LEN); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, column->len); dfield_set_data(dfield, ptr, 4); + /* 8: PREC ---------------------------*/ - dfield = dtuple_get_nth_field(entry, 6/*PREC*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_COLUMNS__PREC); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, 0/* unused */); @@ -370,7 +388,8 @@ dict_create_sys_indexes_tuple( dict_table_copy_types(entry, sys_indexes); /* 0: TABLE_ID -----------------------*/ - dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_INDEXES__TABLE_ID); ptr = static_cast(mem_heap_alloc(heap, 8)); mach_write_to_8(ptr, table->id); @@ -378,20 +397,25 @@ dict_create_sys_indexes_tuple( dfield_set_data(dfield, ptr, 8); /* 1: ID ----------------------------*/ - dfield = dtuple_get_nth_field(entry, 1/*ID*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_INDEXES__ID); ptr = static_cast(mem_heap_alloc(heap, 8)); mach_write_to_8(ptr, index->id); dfield_set_data(dfield, ptr, 8); + /* 2: DB_TRX_ID added later */ + /* 3: DB_ROLL_PTR added later */ /* 4: NAME --------------------------*/ - dfield = dtuple_get_nth_field(entry, 2/*NAME*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_INDEXES__NAME); dfield_set_data(dfield, index->name, ut_strlen(index->name)); /* 5: N_FIELDS ----------------------*/ - dfield = dtuple_get_nth_field(entry, 3/*N_FIELDS*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_INDEXES__N_FIELDS); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, index->n_fields); @@ -399,7 +423,8 @@ dict_create_sys_indexes_tuple( dfield_set_data(dfield, ptr, 4); /* 6: TYPE --------------------------*/ - dfield = dtuple_get_nth_field(entry, 4/*TYPE*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_INDEXES__TYPE); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, index->type); @@ -408,11 +433,8 @@ dict_create_sys_indexes_tuple( /* 7: SPACE --------------------------*/ -#if DICT_SYS_INDEXES_SPACE_NO_FIELD != 7 -#error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 7" -#endif - - dfield = dtuple_get_nth_field(entry, 5/*SPACE*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_INDEXES__SPACE); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, index->space); @@ -421,11 +443,8 @@ dict_create_sys_indexes_tuple( /* 8: PAGE_NO --------------------------*/ -#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 8 -#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 8" -#endif - - dfield = dtuple_get_nth_field(entry, 6/*PAGE_NO*/); + dfield = dtuple_get_nth_field( + entry, DICT_COL__SYS_INDEXES__PAGE_NO); ptr = static_cast(mem_heap_alloc(heap, 4)); mach_write_to_4(ptr, FIL_NULL); @@ -446,7 +465,7 @@ dtuple_t* dict_create_sys_fields_tuple( /*=========================*/ const dict_index_t* index, /*!< in: index */ - ulint i, /*!< in: field number */ + ulint fld_no, /*!< in: field number */ mem_heap_t* heap) /*!< in: memory heap from which the memory for the built tuple is allocated */ @@ -469,7 +488,7 @@ dict_create_sys_fields_tuple( } } - field = dict_index_get_nth_field(index, i); + field = dict_index_get_nth_field(index, fld_no); sys_fields = dict_sys->sys_fields; @@ -478,15 +497,16 @@ dict_create_sys_fields_tuple( dict_table_copy_types(entry, sys_fields); /* 0: INDEX_ID -----------------------*/ - dfield = dtuple_get_nth_field(entry, 0/*INDEX_ID*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_FIELDS__INDEX_ID); ptr = static_cast(mem_heap_alloc(heap, 8)); mach_write_to_8(ptr, index->id); dfield_set_data(dfield, ptr, 8); - /* 1: POS + PREFIX LENGTH ----------------------------*/ - dfield = dtuple_get_nth_field(entry, 1/*POS*/); + /* 1: POS; FIELD NUMBER & PREFIX LENGTH -----------------------*/ + + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_FIELDS__POS); ptr = static_cast(mem_heap_alloc(heap, 4)); @@ -495,18 +515,21 @@ dict_create_sys_fields_tuple( we store the number of the field to the 2 HIGH bytes and the prefix length to the 2 low bytes, */ - mach_write_to_4(ptr, (i << 16) + field->prefix_len); + mach_write_to_4(ptr, (fld_no << 16) + field->prefix_len); } else { /* Else we store the number of the field to the 2 LOW bytes. This is to keep the storage format compatible with InnoDB versions < 4.0.14. */ - mach_write_to_4(ptr, i); + mach_write_to_4(ptr, fld_no); } dfield_set_data(dfield, ptr, 4); + + /* 2: DB_TRX_ID added later */ + /* 3: DB_ROLL_PTR added later */ /* 4: COL_NAME -------------------------*/ - dfield = dtuple_get_nth_field(entry, 2/*COL_NAME*/); + dfield = dtuple_get_nth_field(entry, DICT_COL__SYS_FIELDS__COL_NAME); dfield_set_data(dfield, field->name, ut_strlen(field->name)); @@ -670,10 +693,10 @@ dict_create_index_tree_step( node->page_no = btr_create(index->type, index->space, zip_size, index->id, index, &mtr); /* printf("Created a new index tree in space %lu root page %lu\n", - index->space, index->page_no); */ + index->space, node->page_no); */ page_rec_write_field(btr_pcur_get_rec(&pcur), - DICT_SYS_INDEXES_PAGE_NO_FIELD, + DICT_FLD__SYS_INDEXES__PAGE_NO, node->page_no, &mtr); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -704,7 +727,8 @@ dict_drop_index_tree( ut_ad(mutex_own(&(dict_sys->mutex))); ut_a(!dict_table_is_comp(dict_sys->sys_indexes)); - ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len); + ptr = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len); ut_ad(len == 4); @@ -716,8 +740,8 @@ dict_drop_index_tree( return; } - ptr = rec_get_nth_field_old(rec, - DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); + ptr = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__SPACE, &len); ut_ad(len == 4); @@ -744,7 +768,7 @@ dict_drop_index_tree( root_page_no); */ btr_free_root(space, zip_size, root_page_no, mtr); - page_rec_write_field(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, + page_rec_write_field(rec, DICT_FLD__SYS_INDEXES__PAGE_NO, FIL_NULL, mtr); } @@ -780,7 +804,8 @@ dict_truncate_index_tree( ut_ad(mutex_own(&(dict_sys->mutex))); ut_a(!dict_table_is_comp(dict_sys->sys_indexes)); rec = btr_pcur_get_rec(pcur); - ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len); + ptr = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len); ut_ad(len == 4); @@ -795,8 +820,8 @@ dict_truncate_index_tree( drop = FALSE; } - ptr = rec_get_nth_field_old(rec, - DICT_SYS_INDEXES_SPACE_NO_FIELD, &len); + ptr = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__SPACE, &len); ut_ad(len == 4); @@ -816,12 +841,12 @@ dict_truncate_index_tree( return(FIL_NULL); } - ptr = rec_get_nth_field_old(rec, - DICT_SYS_INDEXES_TYPE_FIELD, &len); + ptr = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__TYPE, &len); ut_ad(len == 4); type = mach_read_from_4(ptr); - ptr = rec_get_nth_field_old(rec, 1, &len); + ptr = rec_get_nth_field_old(rec, DICT_FLD__SYS_INDEXES__ID, &len); ut_ad(len == 8); index_id = mach_read_from_8(ptr); @@ -848,7 +873,7 @@ create: in SYS_INDEXES, so that the database will not get into an inconsistent state in case it crashes between the mtr_commit() below and the following mtr_commit() call. */ - page_rec_write_field(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, + page_rec_write_field(rec, DICT_FLD__SYS_INDEXES__PAGE_NO, FIL_NULL, mtr); /* We will need to commit the mini-transaction in order to avoid === modified file 'storage/innobase/dict/dict0dict.cc' --- a/storage/innobase/dict/dict0dict.cc revid:tor.didriksen@stripped +++ b/storage/innobase/dict/dict0dict.cc revid:kevin.lewis@stripped @@ -5435,7 +5435,7 @@ dict_set_corrupted( ulint len; byte* field = rec_get_nth_field_old( btr_cur_get_rec(&cursor), - DICT_SYS_INDEXES_TYPE_FIELD, &len); + DICT_FLD__SYS_INDEXES__TYPE, &len); if (len != 4) { goto fail; } === modified file 'storage/innobase/dict/dict0load.cc' --- a/storage/innobase/dict/dict0load.cc revid:tor.didriksen@stripped +++ b/storage/innobase/dict/dict0load.cc revid:kevin.lewis@stripped @@ -60,6 +60,7 @@ static const char* SYSTEM_TABLE_NAME[] = metadata even if it is marked as "corrupted". */ UNIV_INTERN my_bool srv_load_corrupted = FALSE; +#ifdef UNIV_DEBUG /****************************************************************//** Compare the name of an index column. @return TRUE if the i'th column of index is 'name'. */ @@ -78,6 +79,7 @@ name_of_col_is( return(strcmp(name, dict_table_get_col_name(table, tmp)) == 0); } +#endif /* UNIV_DEBUG */ /********************************************************************//** Finds the first table name in the given database. @@ -108,7 +110,7 @@ dict_get_first_table_name_in_db( sys_tables = dict_table_get_low("SYS_TABLES"); sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); - ut_a(!dict_table_is_comp(sys_tables)); + ut_ad(!dict_table_is_comp(sys_tables)); tuple = dtuple_create(heap, 1); dfield = dtuple_get_nth_field(tuple, 0); @@ -131,7 +133,8 @@ loop: return(NULL); } - field = rec_get_nth_field_old(rec, 0, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__NAME, &len); if (len < strlen(name) || ut_memcmp(name, field, strlen(name)) != 0) { @@ -329,7 +332,8 @@ dict_process_sys_tables_rec_and_mtr_comm const char* err_msg = NULL; char* table_name; - field = (const char*) rec_get_nth_field_old(rec, 0, &len); + field = (const char*) rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__NAME, &len); ut_a(!rec_get_deleted_flag(rec, 0)); @@ -476,11 +480,12 @@ dict_process_sys_foreign_rec( return("delete-marked record in SYS_FOREIGN"); } - if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 6)) { + if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_FOREIGN) { return("wrong number of columns in SYS_FOREIGN record"); } - field = rec_get_nth_field_old(rec, 0/*ID*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN__ID, &len); if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { err_len: return("incorrect column length in SYS_FOREIGN"); @@ -492,34 +497,39 @@ err_len: is not assigned. */ foreign->id = mem_heap_strdupl(heap, (const char*) field, len); - rec_get_nth_field_offs_old(rec, 1/*DB_TRX_ID*/, &len); - if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_FOREIGN__DB_TRX_ID, &len); + if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) { goto err_len; } - rec_get_nth_field_offs_old(rec, 2/*DB_ROLL_PTR*/, &len); - if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_FOREIGN__DB_ROLL_PTR, &len); + if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) { goto err_len; } /* The _lookup versions of the referenced and foreign table names are not assigned since they are not used in this dict_foreign_t */ - field = rec_get_nth_field_old(rec, 3/*FOR_NAME*/, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN__FOR_NAME, &len); + if (len < 1 || len == UNIV_SQL_NULL) { goto err_len; } foreign->foreign_table_name = mem_heap_strdupl( heap, (const char*) field, len); - field = rec_get_nth_field_old(rec, 4/*REF_NAME*/, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN__REF_NAME, &len); + if (len < 1 || len == UNIV_SQL_NULL) { goto err_len; } foreign->referenced_table_name = mem_heap_strdupl( heap, (const char*) field, len); - field = rec_get_nth_field_old(rec, 5/*N_COLS*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN__N_COLS, &len); + if (len != 4) { goto err_len; } n_fields_and_type = mach_read_from_4(field); @@ -549,44 +559,50 @@ dict_process_sys_foreign_col_rec( ulint len; const byte* field; - if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) { + if (rec_get_deleted_flag(rec, 0)) { return("delete-marked record in SYS_FOREIGN_COLS"); } - if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 6)) { + if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_FOREIGN_COLS) { return("wrong number of columns in SYS_FOREIGN_COLS record"); } - field = rec_get_nth_field_old(rec, 0/*ID*/, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__ID, &len); + if (len < 1 || len == UNIV_SQL_NULL) { err_len: return("incorrect column length in SYS_FOREIGN_COLS"); } *name = mem_heap_strdupl(heap, (char*) field, len); - field = rec_get_nth_field_old(rec, 1/*POS*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__POS, &len); + if (len != 4) { goto err_len; } *pos = mach_read_from_4(field); - rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len); - if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_ID, &len); + if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) { goto err_len; } - rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len); - if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__DB_ROLL_PTR, &len); + if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) { goto err_len; } - field = rec_get_nth_field_old(rec, 4/*FOR_COL_NAME*/, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME, &len); + if (len < 1 || len == UNIV_SQL_NULL) { goto err_len; } *for_col_name = mem_heap_strdupl(heap, (char*) field, len); - field = rec_get_nth_field_old(rec, 5/*REF_COL_NAME*/, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME, &len); + if (len < 1 || len == UNIV_SQL_NULL) { goto err_len; } *ref_col_name = mem_heap_strdupl(heap, (char*) field, len); @@ -609,7 +625,8 @@ dict_sys_tables_get_flags( ulint n_cols; /* read the 4 byte flags from the TYPE field */ - field = rec_get_nth_field_old(rec, 5/*TYPE*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__TYPE, &len); ut_a(len == 4); type = mach_read_from_4(field); @@ -621,7 +638,8 @@ dict_sys_tables_get_flags( Read the 4 byte N_COLS field and look at the high order bit. It should be set for COMPACT and later. It should not be set for REDUNDANT. */ - field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__N_COLS, &len); ut_a(len == 4); n_cols = mach_read_from_4(field); @@ -658,7 +676,7 @@ dict_check_tablespaces_and_store_max_id( sys_tables = dict_table_get_low("SYS_TABLES"); sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); - ut_a(!dict_table_is_comp(sys_tables)); + ut_ad(!dict_table_is_comp(sys_tables)); max_space_id = mtr_read_ulint(dict_hdr_get(&mtr) + DICT_HDR_MAX_SPACE_ID, @@ -699,13 +717,15 @@ loop: ulint flags; char* name; - field = rec_get_nth_field_old(rec, 0/*NAME*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__NAME, &len); name = mem_strdupl((char*) field, len); flags = dict_sys_tables_get_flags(rec); if (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) { /* Read again the 4 bytes from rec. */ - field = rec_get_nth_field_old(rec, 5/*TYPE*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__TYPE, &len); ut_ad(len == 4); /* this was checked earlier */ flags = mach_read_from_4(field); @@ -720,7 +740,8 @@ loop: goto loop; } - field = rec_get_nth_field_old(rec, 9/*SPACE*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__SPACE, &len); ut_a(len == 4); space_id = mach_read_from_4(field); @@ -737,7 +758,8 @@ loop: Do not print warnings for temporary tables. */ ibool is_temp; - field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__N_COLS, &len); if (mach_read_from_4(field) & DICT_N_COLS_COMPACT) { /* ROW_FORMAT=COMPACT: read the is_temp flag from SYS_TABLES.MIX_LEN. */ @@ -811,49 +833,54 @@ dict_load_column_low( ut_ad(table || column); - if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) { + if (rec_get_deleted_flag(rec, 0)) { return("delete-marked record in SYS_COLUMNS"); } - if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 9)) { + if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_COLUMNS) { return("wrong number of columns in SYS_COLUMNS record"); } - field = rec_get_nth_field_old(rec, 0/*TABLE_ID*/, &len); - if (UNIV_UNLIKELY(len != 8)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_COLUMNS__TABLE_ID, &len); + if (len != 8) { err_len: return("incorrect column length in SYS_COLUMNS"); } if (table_id) { *table_id = mach_read_from_8(field); - } else if (UNIV_UNLIKELY(table->id != mach_read_from_8(field))) { + } else if (table->id != mach_read_from_8(field)) { return("SYS_COLUMNS.TABLE_ID mismatch"); } - field = rec_get_nth_field_old(rec, 1/*POS*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_COLUMNS__POS, &len); + if (len != 4) { goto err_len; } pos = mach_read_from_4(field); - if (UNIV_UNLIKELY(table && table->n_def != pos)) { + if (table && table->n_def != pos) { return("SYS_COLUMNS.POS mismatch"); } - rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len); - if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_COLUMNS__DB_TRX_ID, &len); + if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) { goto err_len; } - rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len); - if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_COLUMNS__DB_ROLL_PTR, &len); + if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) { goto err_len; } - field = rec_get_nth_field_old(rec, 4/*NAME*/, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_COLUMNS__NAME, &len); + if (len < 1 || len == UNIV_SQL_NULL) { goto err_len; } @@ -863,15 +890,17 @@ err_len: *col_name = name; } - field = rec_get_nth_field_old(rec, 5/*MTYPE*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_COLUMNS__MTYPE, &len); + if (len != 4) { goto err_len; } mtype = mach_read_from_4(field); - field = rec_get_nth_field_old(rec, 6/*PRTYPE*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_COLUMNS__PRTYPE, &len); + if (len != 4) { goto err_len; } prtype = mach_read_from_4(field); @@ -897,13 +926,15 @@ err_len: } } - field = rec_get_nth_field_old(rec, 7/*LEN*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_COLUMNS__LEN, &len); + if (len != 4) { goto err_len; } col_len = mach_read_from_4(field); - field = rec_get_nth_field_old(rec, 8/*PREC*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_COLUMNS__PREC, &len); + if (len != 4) { goto err_len; } @@ -944,10 +975,12 @@ dict_load_columns( sys_columns = dict_table_get_low("SYS_COLUMNS"); sys_index = UT_LIST_GET_FIRST(sys_columns->indexes); - ut_a(!dict_table_is_comp(sys_columns)); + ut_ad(!dict_table_is_comp(sys_columns)); - ut_a(name_of_col_is(sys_columns, sys_index, 4, "NAME")); - ut_a(name_of_col_is(sys_columns, sys_index, 8, "PREC")); + ut_ad(name_of_col_is(sys_columns, sys_index, + DICT_FLD__SYS_COLUMNS__NAME, "NAME")); + ut_ad(name_of_col_is(sys_columns, sys_index, + DICT_FLD__SYS_COLUMNS__PREC, "PREC")); tuple = dtuple_create(heap, 1); dfield = dtuple_get_nth_field(tuple, 0); @@ -1034,7 +1067,7 @@ dict_load_field_low( dict_index_t* index, /*!< in/out: index, could be NULL if we just populate a dict_field_t struct with information from - a SYS_FIELDSS record */ + a SYS_FIELDS record */ dict_field_t* sys_field, /*!< out: dict_field_t to be filled */ ulint* pos, /*!< out: Field position */ @@ -1053,16 +1086,17 @@ dict_load_field_low( /* Either index or sys_field is supplied, not both */ ut_a((!index) || (!sys_field)); - if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) { + if (rec_get_deleted_flag(rec, 0)) { return(dict_load_field_del); } - if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 5)) { + if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_FIELDS) { return("wrong number of columns in SYS_FIELDS record"); } - field = rec_get_nth_field_old(rec, 0/*INDEX_ID*/, &len); - if (UNIV_UNLIKELY(len != 8)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FIELDS__INDEX_ID, &len); + if (len != 8) { err_len: return("incorrect column length in SYS_FIELDS"); } @@ -1078,20 +1112,6 @@ err_len: } } - field = rec_get_nth_field_old(rec, 1/*POS*/, &len); - if (UNIV_UNLIKELY(len != 4)) { - goto err_len; - } - - rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len); - if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) { - goto err_len; - } - rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len); - if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) { - goto err_len; - } - /* The next field stores the field position in the index and a possible column prefix length if the index field does not contain the whole column. The storage format is like this: if @@ -1100,6 +1120,12 @@ err_len: bytes the prefix length for the field. Otherwise the field number (index->n_def) is contained in the 2 LOW bytes. */ + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FIELDS__POS, &len); + if (len != 4) { + goto err_len; + } + pos_and_prefix_len = mach_read_from_4(field); if (index && UNIV_UNLIKELY @@ -1116,8 +1142,20 @@ err_len: position = pos_and_prefix_len & 0xFFFFUL; } - field = rec_get_nth_field_old(rec, 4, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_FIELDS__DB_TRX_ID, &len); + if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) { + goto err_len; + } + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_FIELDS__DB_ROLL_PTR, &len); + if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) { + goto err_len; + } + + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FIELDS__COL_NAME, &len); + if (len < 1 || len == UNIV_SQL_NULL) { goto err_len; } @@ -1165,8 +1203,9 @@ dict_load_fields( sys_fields = dict_table_get_low("SYS_FIELDS"); sys_index = UT_LIST_GET_FIRST(sys_fields->indexes); - ut_a(!dict_table_is_comp(sys_fields)); - ut_a(name_of_col_is(sys_fields, sys_index, 4, "COL_NAME")); + ut_ad(!dict_table_is_comp(sys_fields)); + ut_ad(name_of_col_is(sys_fields, sys_index, + DICT_FLD__SYS_FIELDS__COL_NAME, "COL_NAME")); tuple = dtuple_create(heap, 1); dfield = dtuple_get_nth_field(tuple, 0); @@ -1252,16 +1291,17 @@ dict_load_index_low( *index = NULL; } - if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) { + if (rec_get_deleted_flag(rec, 0)) { return(dict_load_index_del); } - if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 9)) { + if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_INDEXES) { return("wrong number of columns in SYS_INDEXES record"); } - field = rec_get_nth_field_old(rec, 0/*TABLE_ID*/, &len); - if (UNIV_UNLIKELY(len != 8)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__TABLE_ID, &len); + if (len != 8) { err_len: return("incorrect column length in SYS_INDEXES"); } @@ -1275,53 +1315,61 @@ err_len: return(dict_load_index_id_err); } - field = rec_get_nth_field_old(rec, 1/*ID*/, &len); - if (UNIV_UNLIKELY(len != 8)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__ID, &len); + if (len != 8) { goto err_len; } id = mach_read_from_8(field); - rec_get_nth_field_offs_old(rec, 2/*DB_TRX_ID*/, &len); - if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_INDEXES__DB_TRX_ID, &len); + if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) { goto err_len; } - rec_get_nth_field_offs_old(rec, 3/*DB_ROLL_PTR*/, &len); - if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_INDEXES__DB_ROLL_PTR, &len); + if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) { goto err_len; } - field = rec_get_nth_field_old(rec, 4/*NAME*/, &name_len); - if (UNIV_UNLIKELY(name_len == UNIV_SQL_NULL)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__NAME, &name_len); + if (name_len == UNIV_SQL_NULL) { goto err_len; } name_buf = mem_heap_strdupl(heap, (const char*) field, name_len); - field = rec_get_nth_field_old(rec, 5/*N_FIELDS*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__N_FIELDS, &len); + if (len != 4) { goto err_len; } n_fields = mach_read_from_4(field); - field = rec_get_nth_field_old(rec, 6/*TYPE*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__TYPE, &len); + if (len != 4) { goto err_len; } type = mach_read_from_4(field); - if (UNIV_UNLIKELY(type & (~0 << DICT_IT_BITS))) { + if (type & (~0 << DICT_IT_BITS)) { return("unknown SYS_INDEXES.TYPE bits"); } - field = rec_get_nth_field_old(rec, 7/*SPACE*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + 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, 8/*PAGE_NO*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len); + if (len != 4) { goto err_len; } @@ -1373,9 +1421,11 @@ dict_load_indexes( sys_indexes = dict_table_get_low("SYS_INDEXES"); sys_index = UT_LIST_GET_FIRST(sys_indexes->indexes); - ut_a(!dict_table_is_comp(sys_indexes)); - ut_a(name_of_col_is(sys_indexes, sys_index, 4, "NAME")); - ut_a(name_of_col_is(sys_indexes, sys_index, 8, "PAGE_NO")); + ut_ad(!dict_table_is_comp(sys_indexes)); + ut_ad(name_of_col_is(sys_indexes, sys_index, + DICT_FLD__SYS_INDEXES__NAME, "NAME")); + ut_ad(name_of_col_is(sys_indexes, sys_index, + DICT_FLD__SYS_INDEXES__PAGE_NO, "PAGE_NO")); tuple = dtuple_create(heap, 1); dfield = dtuple_get_nth_field(tuple, 0); @@ -1570,52 +1620,58 @@ dict_load_table_low( ulint flags = 0; ulint flags2; - if (UNIV_UNLIKELY(rec_get_deleted_flag(rec, 0))) { + if (rec_get_deleted_flag(rec, 0)) { return("delete-marked record in SYS_TABLES"); } - if (UNIV_UNLIKELY(rec_get_n_fields_old(rec) != 10)) { + if (rec_get_n_fields_old(rec) != DICT_NUM_FIELDS__SYS_TABLES) { return("wrong number of columns in SYS_TABLES record"); } - rec_get_nth_field_offs_old(rec, 0/*NAME*/, &len); - if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_TABLES__NAME, &len); + if (len < 1 || len == UNIV_SQL_NULL) { err_len: return("incorrect column length in SYS_TABLES"); } - rec_get_nth_field_offs_old(rec, 1/*DB_TRX_ID*/, &len); - if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_TABLES__DB_TRX_ID, &len); + if (len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL) { goto err_len; } - rec_get_nth_field_offs_old(rec, 2/*DB_ROLL_PTR*/, &len); - if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_TABLES__DB_ROLL_PTR, &len); + if (len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL) { goto err_len; } - rec_get_nth_field_offs_old(rec, 3/*ID*/, &len); - if (UNIV_UNLIKELY(len != 8)) { + rec_get_nth_field_offs_old(rec, DICT_FLD__SYS_TABLES__ID, &len); + if (len != 8) { goto err_len; } - field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__N_COLS, &len); + if (len != 4) { goto err_len; } n_cols = mach_read_from_4(field); - rec_get_nth_field_offs_old(rec, 5/*TYPE*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + rec_get_nth_field_offs_old(rec, DICT_FLD__SYS_TABLES__TYPE, &len); + if (len != 4) { goto err_len; } - rec_get_nth_field_offs_old(rec, 6/*MIX_ID*/, &len); - if (UNIV_UNLIKELY(len != 8)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_TABLES__MIX_ID, &len); + if (len != 8) { goto err_len; } - field = rec_get_nth_field_old(rec, 7/*MIX_LEN*/, &len); - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__MIX_LEN, &len); + if (len != 4) { goto err_len; } @@ -1625,14 +1681,15 @@ err_len: /* DICT_TF2_FTS will be set when indexes is being loaded */ flags2 &= ~DICT_TF2_FTS; - rec_get_nth_field_offs_old(rec, 8/*CLUSTER_ID*/, &len); - if (UNIV_UNLIKELY(len != UNIV_SQL_NULL)) { + rec_get_nth_field_offs_old( + rec, DICT_FLD__SYS_TABLES__CLUSTER_ID, &len); + if (len != UNIV_SQL_NULL) { goto err_len; } - field = rec_get_nth_field_old(rec, 9/*SPACE*/, &len); - - if (UNIV_UNLIKELY(len != 4)) { + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__SPACE, &len); + if (len != 4) { goto err_len; } @@ -1642,7 +1699,8 @@ err_len: flags = dict_sys_tables_get_flags(rec); if (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) { - field = rec_get_nth_field_old(rec, 5/*TYPE*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__TYPE, &len); ut_ad(len == 4); /* this was checked earlier */ flags = mach_read_from_4(field); @@ -1683,7 +1741,7 @@ err_len: *table = dict_mem_table_create( name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2); - field = rec_get_nth_field_old(rec, 3/*ID*/, &len); + field = rec_get_nth_field_old(rec, DICT_FLD__SYS_TABLES__ID, &len); ut_ad(len == 8); /* this was checked earlier */ (*table)->id = mach_read_from_8(field); @@ -1735,12 +1793,17 @@ dict_load_table( sys_tables = dict_table_get_low("SYS_TABLES"); sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); - ut_a(!dict_table_is_comp(sys_tables)); - ut_a(name_of_col_is(sys_tables, sys_index, 3, "ID")); - ut_a(name_of_col_is(sys_tables, sys_index, 4, "N_COLS")); - ut_a(name_of_col_is(sys_tables, sys_index, 5, "TYPE")); - ut_a(name_of_col_is(sys_tables, sys_index, 7, "MIX_LEN")); - ut_a(name_of_col_is(sys_tables, sys_index, 9, "SPACE")); + ut_ad(!dict_table_is_comp(sys_tables)); + ut_ad(name_of_col_is(sys_tables, sys_index, + DICT_FLD__SYS_TABLES__ID, "ID")); + ut_ad(name_of_col_is(sys_tables, sys_index, + DICT_FLD__SYS_TABLES__N_COLS, "N_COLS")); + ut_ad(name_of_col_is(sys_tables, sys_index, + DICT_FLD__SYS_TABLES__TYPE, "TYPE")); + ut_ad(name_of_col_is(sys_tables, sys_index, + DICT_FLD__SYS_TABLES__MIX_LEN, "MIX_LEN")); + ut_ad(name_of_col_is(sys_tables, sys_index, + DICT_FLD__SYS_TABLES__SPACE, "SPACE")); tuple = dtuple_create(heap, 1); dfield = dtuple_get_nth_field(tuple, 0); @@ -1763,7 +1826,8 @@ err_exit: return(NULL); } - field = rec_get_nth_field_old(rec, 0, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__NAME, &len); /* Check if the table name in record is the searched one */ if (len != ut_strlen(name) || ut_memcmp(name, field, len) != 0) { @@ -1957,7 +2021,7 @@ dict_load_table_on_id( sys_tables = dict_sys->sys_tables; sys_table_ids = dict_table_get_next_index( dict_table_get_first_index(sys_tables)); - ut_a(!dict_table_is_comp(sys_tables)); + ut_ad(!dict_table_is_comp(sys_tables)); heap = mem_heap_create(256); tuple = dtuple_create(heap, 1); @@ -1980,7 +2044,8 @@ check_rec: /* Now we have the record in the secondary index containing the table ID and NAME */ - field = rec_get_nth_field_old(rec, 0, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLE_IDS__ID, &len); ut_ad(len == 8); /* Check if the table id in record is the one searched for */ @@ -1997,7 +2062,8 @@ check_rec: } } else { /* Now we get the table name from the record */ - field = rec_get_nth_field_old(rec, 1, &len); + field = rec_get_nth_field_old(rec, + DICT_FLD__SYS_TABLE_IDS__NAME, &len); /* Load the table definition to memory */ table = dict_load_table( mem_heap_strdupl( @@ -2072,7 +2138,7 @@ dict_load_foreign_cols( sys_foreign_cols = dict_table_get_low("SYS_FOREIGN_COLS"); sys_index = UT_LIST_GET_FIRST(sys_foreign_cols->indexes); - ut_a(!dict_table_is_comp(sys_foreign_cols)); + ut_ad(!dict_table_is_comp(sys_foreign_cols)); tuple = dtuple_create(foreign->heap, 1); dfield = dtuple_get_nth_field(tuple, 0); @@ -2089,19 +2155,23 @@ dict_load_foreign_cols( ut_a(btr_pcur_is_on_user_rec(&pcur)); ut_a(!rec_get_deleted_flag(rec, 0)); - field = rec_get_nth_field_old(rec, 0, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__ID, &len); ut_a(len == id_len); ut_a(ut_memcmp(id, field, len) == 0); - field = rec_get_nth_field_old(rec, 1, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__POS, &len); ut_a(len == 4); ut_a(i == mach_read_from_4(field)); - field = rec_get_nth_field_old(rec, 4, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME, &len); foreign->foreign_col_names[i] = mem_heap_strdupl( foreign->heap, (char*) field, len); - field = rec_get_nth_field_old(rec, 5, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME, &len); foreign->referenced_col_names[i] = mem_heap_strdupl( foreign->heap, (char*) field, len); @@ -2153,7 +2223,7 @@ dict_load_foreign( sys_foreign = dict_table_get_low("SYS_FOREIGN"); sys_index = UT_LIST_GET_FIRST(sys_foreign->indexes); - ut_a(!dict_table_is_comp(sys_foreign)); + ut_ad(!dict_table_is_comp(sys_foreign)); tuple = dtuple_create(heap2, 1); dfield = dtuple_get_nth_field(tuple, 0); @@ -2180,7 +2250,7 @@ dict_load_foreign( return(DB_ERROR); } - field = rec_get_nth_field_old(rec, 0, &len); + field = rec_get_nth_field_old(rec, DICT_FLD__SYS_FOREIGN__ID, &len); /* Check if the id in record is the searched one */ if (len != id_len || ut_memcmp(id, field, len) != 0) { @@ -2204,7 +2274,8 @@ dict_load_foreign( foreign = dict_mem_foreign_create(); n_fields_and_type = mach_read_from_4( - rec_get_nth_field_old(rec, 5, &len)); + rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN__N_COLS, &len)); ut_a(len == 4); @@ -2215,13 +2286,15 @@ dict_load_foreign( foreign->id = mem_heap_strdupl(foreign->heap, id, id_len); - field = rec_get_nth_field_old(rec, 3, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN__FOR_NAME, &len); foreign->foreign_table_name = mem_heap_strdupl( foreign->heap, (char*) field, len); dict_mem_foreign_table_name_lookup_set(foreign, TRUE); - field = rec_get_nth_field_old(rec, 4, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN__REF_NAME, &len); foreign->referenced_table_name = mem_heap_strdupl( foreign->heap, (char*) field, len); dict_mem_referenced_table_name_lookup_set(foreign, TRUE); @@ -2334,7 +2407,7 @@ dict_load_foreigns( return(DB_ERROR); } - ut_a(!dict_table_is_comp(sys_foreign)); + ut_ad(!dict_table_is_comp(sys_foreign)); mtr_start(&mtr); /* Get the secondary index based on FOR_NAME from table @@ -2365,7 +2438,8 @@ loop: name and a foreign constraint ID */ rec = btr_pcur_get_rec(&pcur); - field = rec_get_nth_field_old(rec, 0, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__NAME, &len); /* Check if the table name in the record is the one searched for; the following call does the comparison in the latin1_swedish_ci @@ -2399,7 +2473,8 @@ loop: } /* Now we get a foreign key constraint id */ - field = rec_get_nth_field_old(rec, 1, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__ID, &len); btr_pcur_store_position(&pcur, &mtr); === modified file 'storage/innobase/dict/dict0mem.cc' --- a/storage/innobase/dict/dict0mem.cc revid:tor.didriksen@stripped +++ b/storage/innobase/dict/dict0mem.cc revid:kevin.lewis@stripped @@ -113,12 +113,12 @@ dict_mem_table_create( if (dict_table_has_fts_index(table) || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID) || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_ADD_DOC_ID)) { - table->fts = fts_create(table); + table->fts = fts_create(table); table->fts->cache = fts_cache_create(table); fts_optimize_add_table(table); - } else { - table->fts = NULL; - } + } else { + table->fts = NULL; + } #endif /* !UNIV_HOTBACKUP */ return(table); === modified file 'storage/innobase/fil/fil0fil.cc' --- a/storage/innobase/fil/fil0fil.cc revid:tor.didriksen@stripped +++ b/storage/innobase/fil/fil0fil.cc revid:kevin.lewis@stripped @@ -1178,9 +1178,8 @@ fil_space_truncate_start( #endif /* UNIV_LOG_ARCHIVE */ /*******************************************************************//** -Creates a tablespace memory object and puts it to the tablespace memory -cache. If there is an error, prints an error message to the .err log. -This function is not called for the system tablespace. +Creates a space memory object and puts it to the 'fil system' hash table. +If there is an error, prints an error message to the .err log. @return TRUE if success */ UNIV_INTERN ibool @@ -3695,7 +3694,7 @@ next_datadir_item: /*******************************************************************//** Returns TRUE if a single-table tablespace does not exist in the memory cache, or is being deleted there. -@return TRUE if does not exist or is being\ deleted */ +@return TRUE if does not exist or is being deleted */ UNIV_INTERN ibool fil_tablespace_deleted_or_being_deleted_in_mem( === modified file 'storage/innobase/handler/ha_innodb.cc' --- a/storage/innobase/handler/ha_innodb.cc revid:tor.didriksen@stripped +++ b/storage/innobase/handler/ha_innodb.cc revid:kevin.lewis@stripped @@ -35,12 +35,8 @@ this program; if not, write to the Free // EXPLAIN_FILENAME_MAX_EXTRA_LENGTH #include // PROCESS_ACL -#include #include -#include #include -#include -#include /** @file ha_innodb.cc */ === modified file 'storage/innobase/handler/i_s.cc' --- a/storage/innobase/handler/i_s.cc revid:tor.didriksen@stripped +++ b/storage/innobase/handler/i_s.cc revid:kevin.lewis@stripped @@ -6189,7 +6189,7 @@ innodb_sys_indexes_init( { ST_SCHEMA_TABLE* schema; - DBUG_ENTER("innodb_sys_index_init"); + DBUG_ENTER("innodb_sys_indexes_init"); schema = (ST_SCHEMA_TABLE*) p; === modified file 'storage/innobase/include/dict0boot.h' --- a/storage/innobase/include/dict0boot.h revid:tor.didriksen@stripped +++ b/storage/innobase/include/dict0boot.h revid:kevin.lewis@stripped @@ -120,30 +120,159 @@ dict_create(void); /*-------------------------------------------------------------*/ /* Dictionary header offsets */ #define DICT_HDR_ROW_ID 0 /* The latest assigned row id */ -#define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */ -#define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */ -#define DICT_HDR_MAX_SPACE_ID 24 /* The latest assigned space id, or 0*/ -#define DICT_HDR_MIX_ID_LOW 28 /* Obsolete,always DICT_HDR_FIRST_ID */ -#define DICT_HDR_TABLES 32 /* Root of the table index tree */ -#define DICT_HDR_TABLE_IDS 36 /* Root of the table index tree */ -#define DICT_HDR_COLUMNS 40 /* Root of the column index tree */ -#define DICT_HDR_INDEXES 44 /* Root of the index index tree */ -#define DICT_HDR_FIELDS 48 /* Root of the index field - index tree */ +#define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */ +#define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */ +#define DICT_HDR_MAX_SPACE_ID 24 /* The latest assigned space id,or 0*/ +#define DICT_HDR_MIX_ID_LOW 28 /* Obsolete,always DICT_HDR_FIRST_ID*/ +#define DICT_HDR_TABLES 32 /* Root of SYS_TABLES clust index */ +#define DICT_HDR_TABLE_IDS 36 /* Root of SYS_TABLE_IDS sec index */ +#define DICT_HDR_COLUMNS 40 /* Root of SYS_COLUMNS clust index */ +#define DICT_HDR_INDEXES 44 /* Root of SYS_INDEXES clust index */ +#define DICT_HDR_FIELDS 48 /* Root of SYS_FIELDS clust index */ #define DICT_HDR_FSEG_HEADER 56 /* Segment header for the tablespace segment into which the dictionary header is created */ /*-------------------------------------------------------------*/ +/* The columns in SYS_TABLES */ +enum dict_col_sys_tables_enum { + DICT_COL__SYS_TABLES__NAME = 0, + DICT_COL__SYS_TABLES__ID = 1, + DICT_COL__SYS_TABLES__N_COLS = 2, + DICT_COL__SYS_TABLES__TYPE = 3, + DICT_COL__SYS_TABLES__MIX_ID = 4, + DICT_COL__SYS_TABLES__MIX_LEN = 5, + DICT_COL__SYS_TABLES__CLUSTER_ID = 6, + DICT_COL__SYS_TABLES__SPACE = 7, + DICT_NUM_COLS__SYS_TABLES = 8 +}; /* The field numbers in the SYS_TABLES clustered index */ -#define DICT_SYS_TABLES_TYPE_FIELD 5 - +enum dict_fld_sys_tables_enum { + DICT_FLD__SYS_TABLES__NAME = 0, + DICT_FLD__SYS_TABLES__DB_TRX_ID = 1, + DICT_FLD__SYS_TABLES__DB_ROLL_PTR = 2, + DICT_FLD__SYS_TABLES__ID = 3, + DICT_FLD__SYS_TABLES__N_COLS = 4, + DICT_FLD__SYS_TABLES__TYPE = 5, + DICT_FLD__SYS_TABLES__MIX_ID = 6, + DICT_FLD__SYS_TABLES__MIX_LEN = 7, + DICT_FLD__SYS_TABLES__CLUSTER_ID = 8, + DICT_FLD__SYS_TABLES__SPACE = 9, + DICT_NUM_FIELDS__SYS_TABLES = 10 +}; +/* The field numbers in the SYS_TABLE_IDS index */ +enum dict_fld_sys_table_ids_enum { + DICT_FLD__SYS_TABLE_IDS__ID = 0, + DICT_FLD__SYS_TABLE_IDS__NAME = 1, + DICT_NUM_FIELDS__SYS_TABLE_IDS = 2 +}; +/* The columns in SYS_COLUMNS */ +enum dict_col_sys_columns_enum { + DICT_COL__SYS_COLUMNS__TABLE_ID = 0, + DICT_COL__SYS_COLUMNS__POS = 1, + DICT_COL__SYS_COLUMNS__NAME = 2, + DICT_COL__SYS_COLUMNS__MTYPE = 3, + DICT_COL__SYS_COLUMNS__PRTYPE = 4, + DICT_COL__SYS_COLUMNS__LEN = 5, + DICT_COL__SYS_COLUMNS__PREC = 6, + DICT_NUM_COLS__SYS_COLUMNS = 7 +}; +/* The field numbers in the SYS_TABLES clustered index */ +enum dict_fld_sys_columns_enum { + DICT_FLD__SYS_COLUMNS__TABLE_ID = 0, + DICT_FLD__SYS_COLUMNS__POS = 1, + DICT_FLD__SYS_COLUMNS__DB_TRX_ID = 2, + DICT_FLD__SYS_COLUMNS__DB_ROLL_PTR = 3, + DICT_FLD__SYS_COLUMNS__NAME = 4, + DICT_FLD__SYS_COLUMNS__MTYPE = 5, + DICT_FLD__SYS_COLUMNS__PRTYPE = 6, + DICT_FLD__SYS_COLUMNS__LEN = 7, + DICT_FLD__SYS_COLUMNS__PREC = 8, + DICT_NUM_FIELDS__SYS_COLUMNS = 9 +}; +/* The columns in SYS_INDEXES */ +enum dict_col_sys_indexes_enum { + DICT_COL__SYS_INDEXES__TABLE_ID = 0, + DICT_COL__SYS_INDEXES__ID = 1, + DICT_COL__SYS_INDEXES__NAME = 2, + DICT_COL__SYS_INDEXES__N_FIELDS = 3, + DICT_COL__SYS_INDEXES__TYPE = 4, + DICT_COL__SYS_INDEXES__SPACE = 5, + DICT_COL__SYS_INDEXES__PAGE_NO = 6, + DICT_NUM_COLS__SYS_INDEXES = 7 +}; +/* The field numbers in the SYS_INDEXES clustered index */ +enum dict_fld_sys_indexes_enum { + DICT_FLD__SYS_INDEXES__TABLE_ID = 0, + DICT_FLD__SYS_INDEXES__ID = 1, + DICT_FLD__SYS_INDEXES__DB_TRX_ID = 2, + DICT_FLD__SYS_INDEXES__DB_ROLL_PTR = 3, + DICT_FLD__SYS_INDEXES__NAME = 4, + DICT_FLD__SYS_INDEXES__N_FIELDS = 5, + DICT_FLD__SYS_INDEXES__TYPE = 6, + DICT_FLD__SYS_INDEXES__SPACE = 7, + DICT_FLD__SYS_INDEXES__PAGE_NO = 8, + DICT_NUM_FIELDS__SYS_INDEXES = 9 +}; +/* The columns in SYS_FIELDS */ +enum dict_col_sys_fields_enum { + DICT_COL__SYS_FIELDS__INDEX_ID = 0, + DICT_COL__SYS_FIELDS__POS = 1, + DICT_COL__SYS_FIELDS__COL_NAME = 2, + DICT_NUM_COLS__SYS_FIELDS = 3 +}; /* The field numbers in the SYS_INDEXES clustered index */ -#define DICT_SYS_INDEXES_PAGE_NO_FIELD 8 -#define DICT_SYS_INDEXES_SPACE_NO_FIELD 7 -#define DICT_SYS_INDEXES_TYPE_FIELD 6 -#define DICT_SYS_INDEXES_NAME_FIELD 4 +enum dict_fld_sys_fields_enum { + DICT_FLD__SYS_FIELDS__INDEX_ID = 0, + DICT_FLD__SYS_FIELDS__POS = 1, + DICT_FLD__SYS_FIELDS__DB_TRX_ID = 2, + DICT_FLD__SYS_FIELDS__DB_ROLL_PTR = 3, + DICT_FLD__SYS_FIELDS__COL_NAME = 4, + DICT_NUM_FIELDS__SYS_FIELDS = 5 +}; +/* The columns in SYS_FOREIGN */ +enum dict_col_sys_foreign_enum { + DICT_COL__SYS_FOREIGN__ID = 0, + DICT_COL__SYS_FOREIGN__FOR_NAME = 1, + DICT_COL__SYS_FOREIGN__REF_NAME = 2, + DICT_COL__SYS_FOREIGN__N_COLS = 3, + DICT_NUM_COLS__SYS_FOREIGN = 4 +}; +/* The field numbers in the SYS_FOREIGN clustered index */ +enum dict_fld_sys_foreign_enum { + DICT_FLD__SYS_FOREIGN__ID = 0, + DICT_FLD__SYS_FOREIGN__DB_TRX_ID = 1, + DICT_FLD__SYS_FOREIGN__DB_ROLL_PTR = 2, + DICT_FLD__SYS_FOREIGN__FOR_NAME = 3, + DICT_FLD__SYS_FOREIGN__REF_NAME = 4, + DICT_FLD__SYS_FOREIGN__N_COLS = 5, + DICT_NUM_FIELDS__SYS_FOREIGN = 6 +}; +/* The field numbers in the SYS_FOREIGN_FOR_NAME secondary index */ +enum dict_fld_sys_foreign_for_name_enum { + DICT_FLD__SYS_FOREIGN_FOR_NAME__NAME = 0, + DICT_FLD__SYS_FOREIGN_FOR_NAME__ID = 1, + DICT_NUM_FIELDS__SYS_FOREIGN_FOR_NAME = 2 +}; +/* The columns in SYS_FOREIGN_COLS */ +enum dict_col_sys_foreign_cols_enum { + DICT_COL__SYS_FOREIGN_COLS__ID = 0, + DICT_COL__SYS_FOREIGN_COLS__POS = 1, + DICT_COL__SYS_FOREIGN_COLS__FOR_COL_NAME = 2, + DICT_COL__SYS_FOREIGN_COLS__REF_COL_NAME = 3, + DICT_NUM_COLS__SYS_FOREIGN_COLS = 4 +}; +/* The field numbers in the SYS_FOREIGN_COLS clustered index */ +enum dict_fld_sys_foreign_cols_enum { + DICT_FLD__SYS_FOREIGN_COLS__ID = 0, + DICT_FLD__SYS_FOREIGN_COLS__POS = 1, + DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_ID = 2, + DICT_FLD__SYS_FOREIGN_COLS__DB_ROLL_PTR = 3, + DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME = 4, + DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME = 5, + DICT_NUM_FIELDS__SYS_FOREIGN_COLS = 6 +}; /* When a row id which is zero modulo this number (which must be a power of two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is === modified file 'storage/innobase/include/dict0mem.h' --- a/storage/innobase/include/dict0mem.h revid:tor.didriksen@stripped +++ b/storage/innobase/include/dict0mem.h revid:kevin.lewis@stripped @@ -119,8 +119,6 @@ to cache the BLOB prefixes. */ #define DICT_TF_BITS (DICT_TF_WIDTH_COMPACT \ + DICT_TF_WIDTH_ZIP_SSIZE \ + DICT_TF_WIDTH_ATOMIC_BLOBS) -/** Width of all the currently unknown/unused table flags */ -#define DICT_TF_WIDTH_UNUSED ((UNIV_WORD_SIZE * 8) - DICT_TF_BITS) /** A mask of all the known/used bits in table flags */ #define DICT_TF_BIT_MASK (~(~0 << DICT_TF_BITS)) @@ -581,7 +579,6 @@ a foreign key constraint is enforced, th #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32 /*!< ON UPDATE NO ACTION */ /* @} */ - /** Data structure for a database table. Most fields will be initialized to 0, NULL or FALSE in dict_mem_table_create(). */ struct dict_table_struct{ @@ -714,7 +711,7 @@ struct dict_table_struct{ lock we keep a pointer to the transaction here in the autoinc_trx variable. This is to avoid acquiring the lock_sys_t::mutex and - scanning the vector in trx_t. + scanning the vector in trx_t. When an AUTOINC lock has to wait, the corresponding lock instance is created on @@ -762,8 +759,8 @@ struct dict_table_struct{ MySQL does NOT itself check the number of open handles at drop */ UT_LIST_BASE_NODE_T(lock_t) - locks; /*!< list of locks on the table; protected - by lock_sys->mutex */ + locks; /*!< list of locks on the table; protected + by lock_sys->mutex */ #endif /* !UNIV_HOTBACKUP */ #ifdef UNIV_DEBUG === modified file 'storage/innobase/include/dict0types.h' --- a/storage/innobase/include/dict0types.h revid:tor.didriksen@stripped +++ b/storage/innobase/include/dict0types.h revid:kevin.lewis@stripped @@ -42,7 +42,7 @@ typedef struct tab_node_struct tab_node /* The ibuf table and indexes's ID are assigned as the number DICT_IBUF_ID_MIN plus the space id */ -#define DICT_IBUF_ID_MIN 0xFFFFFFFF00000000ULL +#define DICT_IBUF_ID_MIN 0xFFFFFFFF00000000ULL typedef ib_id_t table_id_t; typedef ib_id_t index_id_t; @@ -53,11 +53,11 @@ be responsible to deal with corrupted ta Note: please define the IGNORE_ERR_* as bits, so their value can be or-ed together */ enum dict_err_ignore { - DICT_ERR_IGNORE_NONE = 0, /*!< no error to ignore */ - DICT_ERR_IGNORE_INDEX_ROOT = 1, /*!< ignore error if index root + DICT_ERR_IGNORE_NONE = 0, /*!< no error to ignore */ + DICT_ERR_IGNORE_INDEX_ROOT = 1, /*!< ignore error if index root page is FIL_NULL or incorrect value */ DICT_ERR_IGNORE_CORRUPT = 2, /*!< skip corrupted indexes */ - DICT_ERR_IGNORE_ALL = 0xFFFF /*!< ignore all errors */ + DICT_ERR_IGNORE_ALL = 0xFFFF /*!< ignore all errors */ }; typedef enum dict_err_ignore dict_err_ignore_t; === modified file 'storage/innobase/include/fil0fil.h' --- a/storage/innobase/include/fil0fil.h revid:tor.didriksen@stripped +++ b/storage/innobase/include/fil0fil.h revid:kevin.lewis@stripped @@ -225,8 +225,8 @@ fil_space_truncate_start( some initial files in the space */ #endif /* UNIV_LOG_ARCHIVE */ /*******************************************************************//** -Creates a space memory object and puts it to the 'fil system' hash table. If -there is an error, prints an error message to the .err log. +Creates a space memory object and puts it to the 'fil system' hash table. +If there is an error, prints an error message to the .err log. @return TRUE if success */ UNIV_INTERN ibool @@ -526,7 +526,7 @@ fil_load_single_table_tablespaces(void); /*******************************************************************//** Returns TRUE if a single-table tablespace does not exist in the memory cache, or is being deleted there. -@return TRUE if does not exist or is being\ deleted */ +@return TRUE if does not exist or is being deleted */ UNIV_INTERN ibool fil_tablespace_deleted_or_being_deleted_in_mem( === modified file 'storage/innobase/pars/pars0pars.cc' --- a/storage/innobase/pars/pars0pars.cc revid:tor.didriksen@stripped +++ b/storage/innobase/pars/pars0pars.cc revid:kevin.lewis@stripped @@ -1957,12 +1957,12 @@ pars_create_table( dfield_get_data(dfield))); - switch (size) { + switch (size) { case 0: break; - case 1: case 2: case 4: case 8: case 16: - flags |= DICT_TF_COMPACT; + case 1: case 2: case 4: case 8: case 16: + flags |= DICT_TF_COMPACT; /* FTS-FIXME: needs the zip changes */ /* flags |= size << DICT_TF_COMPRESSED_SHIFT; */ break; === modified file 'storage/innobase/row/row0merge.cc' --- a/storage/innobase/row/row0merge.cc revid:tor.didriksen@stripped +++ b/storage/innobase/row/row0merge.cc revid:kevin.lewis@stripped @@ -2334,8 +2334,8 @@ row_merge_drop_temp_indexes(void) } rec = btr_pcur_get_rec(&pcur); - field = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_NAME_FIELD, - &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__NAME, &len); if (len == UNIV_SQL_NULL || len == 0 || (char) *field != TEMP_INDEX_PREFIX) { continue; @@ -2343,7 +2343,8 @@ row_merge_drop_temp_indexes(void) /* This is a temporary index. */ - field = rec_get_nth_field_old(rec, 0/*TABLE_ID*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__TABLE_ID, &len); if (len != 8) { /* Corrupted TABLE_ID */ continue; === modified file 'storage/innobase/row/row0mysql.cc' --- a/storage/innobase/row/row0mysql.cc revid:tor.didriksen@stripped +++ b/storage/innobase/row/row0mysql.cc revid:kevin.lewis@stripped @@ -2148,7 +2148,7 @@ err_exit: ut_a(mem_validate()); fputs("Memory validated\n", stderr); #endif /* UNIV_MEM_DEBUG */ - } + } heap = mem_heap_create(512); @@ -3190,7 +3190,8 @@ row_truncate_table_for_mysql( rec = btr_pcur_get_rec(&pcur); - field = rec_get_nth_field_old(rec, 0, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_INDEXES__TABLE_ID, &len); ut_ad(len == 8); if (memcmp(buf, field, len) != 0) { @@ -3212,7 +3213,7 @@ row_truncate_table_for_mysql( if (root_page_no != FIL_NULL) { page_rec_write_field( - rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, + rec, DICT_FLD__SYS_INDEXES__PAGE_NO, root_page_no, &mtr); /* We will need to commit and restart the mini-transaction in order to avoid deadlocks. @@ -3393,7 +3394,7 @@ row_drop_table_for_mysql( ulint namelen; ibool locked_dictionary = FALSE; ibool fts_bg_thread_exited = FALSE; - pars_info_t* info = NULL; + pars_info_t* info = NULL; ut_a(name != NULL); @@ -3927,7 +3928,8 @@ row_mysql_drop_temp_tables(void) /* The high order bit of N_COLS is set unless ROW_FORMAT=REDUNDANT. */ rec = btr_pcur_get_rec(&pcur); - field = rec_get_nth_field_old(rec, 4/*N_COLS*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__N_COLS, &len); if (len != 4 || !(mach_read_from_4(field) & DICT_N_COLS_COMPACT)) { continue; @@ -3937,14 +3939,16 @@ row_mysql_drop_temp_tables(void) in ROW_FORMAT=REDUNDANT could write garbage to SYS_TABLES.MIX_LEN, where we now store the is_temp flag. Above, we assumed is_temp=0 if ROW_FORMAT=REDUNDANT. */ - field = rec_get_nth_field_old(rec, 7/*MIX_LEN*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__MIX_LEN, &len); if (len != 4 || !(mach_read_from_4(field) & DICT_TF2_TEMPORARY)) { continue; } /* This is a temporary table. */ - field = rec_get_nth_field_old(rec, 0/*NAME*/, &len); + field = rec_get_nth_field_old( + rec, DICT_FLD__SYS_TABLES__NAME, &len); if (len == UNIV_SQL_NULL || len == 0) { /* Corrupted SYS_TABLES.NAME */ continue; === modified file 'storage/innobase/srv/srv0start.cc' --- a/storage/innobase/srv/srv0start.cc revid:tor.didriksen@stripped +++ b/storage/innobase/srv/srv0start.cc revid:kevin.lewis@stripped @@ -2194,8 +2194,8 @@ innobase_start_or_create_for_mysql(void) srv_is_being_started = FALSE; + /* Create the SYS_FOREIGN and SYS_FOREIGN_COLS system tables */ err = dict_create_or_check_foreign_constraint_tables(); - if (err != DB_SUCCESS) { return((int)DB_ERROR); } No bundle (reason: useless for push emails).