#include "univ.i"#include "dict0types.h"#include "ut0byte.h"Include dependency graph for dict0load.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| void | dict_check_tablespaces_and_store_max_id (ibool in_crash_recovery) |
| char * | dict_get_first_table_name_in_db (const char *name) |
| dict_table_t * | dict_load_table (const char *name) |
| dict_table_t * | dict_load_table_on_id (dulint table_id) |
| void | dict_load_sys_table (dict_table_t *table) |
| ulint | dict_load_foreigns (const char *table_name, ibool check_charsets) |
| void | dict_print (void) |
| void dict_check_tablespaces_and_store_max_id | ( | ibool | in_crash_recovery | ) |
Definition at line 218 of file dict0load.c.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_open_at_index_side(), btr_pcur_restore_position(), btr_pcur_store_position(), BTR_SEARCH_LEAF, dict_sys, dict_table_get_low(), dict_table_is_comp(), FALSE, fil_open_single_table_tablespace(), fil_set_max_space_id_if_bigger(), fil_space_for_table_exists_in_mem(), dict_table_struct::indexes, mach_read_from_4(), mem_free, mem_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, mutex_enter, mutex_exit(), name, rec_get_deleted_flag(), rec_get_nth_field_old(), TRUE, ut_a, and UT_LIST_GET_FIRST.
Referenced by innobase_start_or_create_for_mysql().
00220 : are we doing a crash recovery */ 00221 { 00222 dict_table_t* sys_tables; 00223 dict_index_t* sys_index; 00224 btr_pcur_t pcur; 00225 rec_t* rec; 00226 byte* field; 00227 ulint len; 00228 ulint space_id; 00229 ulint max_space_id = 0; 00230 mtr_t mtr; 00231 00232 mutex_enter(&(dict_sys->mutex)); 00233 00234 mtr_start(&mtr); 00235 00236 sys_tables = dict_table_get_low("SYS_TABLES"); 00237 sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); 00238 ut_a(!dict_table_is_comp(sys_tables)); 00239 00240 btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur, 00241 TRUE, &mtr); 00242 loop: 00243 btr_pcur_move_to_next_user_rec(&pcur, &mtr); 00244 00245 rec = btr_pcur_get_rec(&pcur); 00246 00247 if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { 00248 /* end of index */ 00249 00250 btr_pcur_close(&pcur); 00251 mtr_commit(&mtr); 00252 00253 /* We must make the tablespace cache aware of the biggest 00254 known space id */ 00255 00256 /* printf("Biggest space id in data dictionary %lu\n", 00257 max_space_id); */ 00258 fil_set_max_space_id_if_bigger(max_space_id); 00259 00260 mutex_exit(&(dict_sys->mutex)); 00261 00262 return; 00263 } 00264 00265 field = rec_get_nth_field_old(rec, 0, &len); 00266 00267 if (!rec_get_deleted_flag(rec, 0)) { 00268 00269 /* We found one */ 00270 00271 char* name = mem_strdupl((char*) field, len); 00272 00273 field = rec_get_nth_field_old(rec, 9, &len); 00274 ut_a(len == 4); 00275 00276 space_id = mach_read_from_4(field); 00277 00278 btr_pcur_store_position(&pcur, &mtr); 00279 00280 mtr_commit(&mtr); 00281 00282 if (space_id != 0 && in_crash_recovery) { 00283 /* Check that the tablespace (the .ibd file) really 00284 exists; print a warning to the .err log if not */ 00285 00286 fil_space_for_table_exists_in_mem(space_id, name, 00287 FALSE, TRUE, TRUE); 00288 } 00289 00290 if (space_id != 0 && !in_crash_recovery) { 00291 /* It is a normal database startup: create the space 00292 object and check that the .ibd file exists. */ 00293 00294 fil_open_single_table_tablespace(FALSE, space_id, 00295 name); 00296 } 00297 00298 mem_free(name); 00299 00300 if (space_id > max_space_id) { 00301 max_space_id = space_id; 00302 } 00303 00304 mtr_start(&mtr); 00305 00306 btr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr); 00307 } 00308 00309 goto loop; 00310 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* dict_get_first_table_name_in_db | ( | const char * | name | ) |
Definition at line 33 of file dict0load.c.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_open_on_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_index_copy_types(), dict_sys, dict_table_get_low(), dict_table_is_comp(), dtuple_create(), dtuple_get_nth_field(), dict_table_struct::indexes, mem_heap_create, mem_heap_free, mem_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, NULL, PAGE_CUR_GE, rec_get_deleted_flag(), rec_get_nth_field_old(), strlen(), ut_a, ut_ad, UT_LIST_GET_FIRST, ut_memcmp(), and ut_strlen().
Referenced by row_drop_database_for_mysql().
00035 : table name, NULL if 00036 does not exist; the caller must 00037 free the memory in the string! */ 00038 const char* name) /* in: database name which ends in '/' */ 00039 { 00040 dict_table_t* sys_tables; 00041 btr_pcur_t pcur; 00042 dict_index_t* sys_index; 00043 dtuple_t* tuple; 00044 mem_heap_t* heap; 00045 dfield_t* dfield; 00046 rec_t* rec; 00047 byte* field; 00048 ulint len; 00049 mtr_t mtr; 00050 00051 #ifdef UNIV_SYNC_DEBUG 00052 ut_ad(mutex_own(&(dict_sys->mutex))); 00053 #endif /* UNIV_SYNC_DEBUG */ 00054 00055 heap = mem_heap_create(1000); 00056 00057 mtr_start(&mtr); 00058 00059 sys_tables = dict_table_get_low("SYS_TABLES"); 00060 sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); 00061 ut_a(!dict_table_is_comp(sys_tables)); 00062 00063 tuple = dtuple_create(heap, 1); 00064 dfield = dtuple_get_nth_field(tuple, 0); 00065 00066 dfield_set_data(dfield, name, ut_strlen(name)); 00067 dict_index_copy_types(tuple, sys_index, 1); 00068 00069 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, 00070 BTR_SEARCH_LEAF, &pcur, &mtr); 00071 loop: 00072 rec = btr_pcur_get_rec(&pcur); 00073 00074 if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { 00075 /* Not found */ 00076 00077 btr_pcur_close(&pcur); 00078 mtr_commit(&mtr); 00079 mem_heap_free(heap); 00080 00081 return(NULL); 00082 } 00083 00084 field = rec_get_nth_field_old(rec, 0, &len); 00085 00086 if (len < strlen(name) 00087 || ut_memcmp(name, field, strlen(name)) != 0) { 00088 /* Not found */ 00089 00090 btr_pcur_close(&pcur); 00091 mtr_commit(&mtr); 00092 mem_heap_free(heap); 00093 00094 return(NULL); 00095 } 00096 00097 if (!rec_get_deleted_flag(rec, 0)) { 00098 00099 /* We found one */ 00100 00101 char* table_name = mem_strdupl((char*) field, len); 00102 00103 btr_pcur_close(&pcur); 00104 mtr_commit(&mtr); 00105 mem_heap_free(heap); 00106 00107 return(table_name); 00108 } 00109 00110 btr_pcur_move_to_next_user_rec(&pcur, &mtr); 00111 00112 goto loop; 00113 }
Here is the call graph for this function:

Here is the caller graph for this function:

| ulint dict_load_foreigns | ( | const char * | table_name, | |
| ibool | check_charsets | |||
| ) |
Definition at line 1212 of file dict0load.c.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_open_on_user_rec(), btr_pcur_restore_position(), btr_pcur_store_position(), BTR_SEARCH_LEAF, cmp_data_data(), DB_ERROR, DB_SUCCESS, dfield_get_data(), dfield_get_len(), dfield_get_type(), dfield_set_data(), dict_index_copy_types(), dict_load_foreign(), dict_sys, dict_table_get_first_index(), dict_table_get_low(), dict_table_get_next_index(), dict_table_is_comp(), dtuple_create(), dtuple_get_nth_field(), err, id, mem_heap_create, mem_heap_free, mem_heap_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, NULL, PAGE_CUR_GE, rec_get_deleted_flag(), rec_get_nth_field_old(), ut_a, ut_ad, ut_memcmp(), and ut_strlen().
Referenced by dict_load_table(), row_rename_table_for_mysql(), and row_table_add_foreign_constraints().
01214 : DB_SUCCESS or error code */ 01215 const char* table_name, /* in: table name */ 01216 ibool check_charsets) /* in: TRUE=check charset 01217 compatibility */ 01218 { 01219 btr_pcur_t pcur; 01220 mem_heap_t* heap; 01221 dtuple_t* tuple; 01222 dfield_t* dfield; 01223 dict_index_t* sec_index; 01224 dict_table_t* sys_foreign; 01225 rec_t* rec; 01226 byte* field; 01227 ulint len; 01228 char* id ; 01229 ulint err; 01230 mtr_t mtr; 01231 01232 #ifdef UNIV_SYNC_DEBUG 01233 ut_ad(mutex_own(&(dict_sys->mutex))); 01234 #endif /* UNIV_SYNC_DEBUG */ 01235 01236 sys_foreign = dict_table_get_low("SYS_FOREIGN"); 01237 01238 if (sys_foreign == NULL) { 01239 /* No foreign keys defined yet in this database */ 01240 01241 fprintf(stderr, 01242 "InnoDB: Error: no foreign key system tables in the database\n"); 01243 01244 return(DB_ERROR); 01245 } 01246 01247 ut_a(!dict_table_is_comp(sys_foreign)); 01248 mtr_start(&mtr); 01249 01250 /* Get the secondary index based on FOR_NAME from table 01251 SYS_FOREIGN */ 01252 01253 sec_index = dict_table_get_next_index( 01254 dict_table_get_first_index(sys_foreign)); 01255 start_load: 01256 heap = mem_heap_create(256); 01257 01258 tuple = dtuple_create(heap, 1); 01259 dfield = dtuple_get_nth_field(tuple, 0); 01260 01261 dfield_set_data(dfield, table_name, ut_strlen(table_name)); 01262 dict_index_copy_types(tuple, sec_index, 1); 01263 01264 btr_pcur_open_on_user_rec(sec_index, tuple, PAGE_CUR_GE, 01265 BTR_SEARCH_LEAF, &pcur, &mtr); 01266 loop: 01267 rec = btr_pcur_get_rec(&pcur); 01268 01269 if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { 01270 /* End of index */ 01271 01272 goto load_next_index; 01273 } 01274 01275 /* Now we have the record in the secondary index containing a table 01276 name and a foreign constraint ID */ 01277 01278 rec = btr_pcur_get_rec(&pcur); 01279 field = rec_get_nth_field_old(rec, 0, &len); 01280 01281 /* Check if the table name in the record is the one searched for; the 01282 following call does the comparison in the latin1_swedish_ci 01283 charset-collation, in a case-insensitive way. */ 01284 01285 if (0 != cmp_data_data(dfield_get_type(dfield), 01286 dfield_get_data(dfield), dfield_get_len(dfield), 01287 field, len)) { 01288 01289 goto load_next_index; 01290 } 01291 01292 /* Since table names in SYS_FOREIGN are stored in a case-insensitive 01293 order, we have to check that the table name matches also in a binary 01294 string comparison. On Unix, MySQL allows table names that only differ 01295 in character case. */ 01296 01297 if (0 != ut_memcmp(field, table_name, len)) { 01298 01299 goto next_rec; 01300 } 01301 01302 if (rec_get_deleted_flag(rec, 0)) { 01303 01304 goto next_rec; 01305 } 01306 01307 /* Now we get a foreign key constraint id */ 01308 field = rec_get_nth_field_old(rec, 1, &len); 01309 id = mem_heap_strdupl(heap, (char*) field, len); 01310 01311 btr_pcur_store_position(&pcur, &mtr); 01312 01313 mtr_commit(&mtr); 01314 01315 /* Load the foreign constraint definition to the dictionary cache */ 01316 01317 err = dict_load_foreign(id, check_charsets); 01318 01319 if (err != DB_SUCCESS) { 01320 btr_pcur_close(&pcur); 01321 mem_heap_free(heap); 01322 01323 return(err); 01324 } 01325 01326 mtr_start(&mtr); 01327 01328 btr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr); 01329 next_rec: 01330 btr_pcur_move_to_next_user_rec(&pcur, &mtr); 01331 01332 goto loop; 01333 01334 load_next_index: 01335 btr_pcur_close(&pcur); 01336 mtr_commit(&mtr); 01337 mem_heap_free(heap); 01338 01339 sec_index = dict_table_get_next_index(sec_index); 01340 01341 if (sec_index != NULL) { 01342 01343 mtr_start(&mtr); 01344 01345 goto start_load; 01346 } 01347 01348 return(DB_SUCCESS); 01349 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dict_load_sys_table | ( | dict_table_t * | table | ) |
Definition at line 988 of file dict0load.c.
References dict_load_indexes(), dict_sys, mem_heap_create, mem_heap_free, dict_sys_struct::mutex, and ut_ad.
Referenced by dict_boot().
00990 : system table */ 00991 { 00992 mem_heap_t* heap; 00993 00994 #ifdef UNIV_SYNC_DEBUG 00995 ut_ad(mutex_own(&(dict_sys->mutex))); 00996 #endif /* UNIV_SYNC_DEBUG */ 00997 00998 heap = mem_heap_create(1000); 00999 01000 dict_load_indexes(table, heap); 01001 01002 mem_heap_free(heap); 01003 }
Here is the call graph for this function:

Here is the caller graph for this function:

| dict_table_t* dict_load_table | ( | const char * | name | ) |
Definition at line 719 of file dict0load.c.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_open_on_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_field_get_col(), dict_index_copy_types(), dict_index_get_nth_field(), dict_load_columns(), dict_load_foreigns(), dict_load_indexes(), dict_mem_table_create(), dict_sys, dict_table_add_to_cache(), dict_table_get_low(), dict_table_is_comp(), DICT_TABLE_ORDINARY, DICT_TF_COMPACT, dtuple_create(), dtuple_get_nth_field(), err, FALSE, fil_open_single_table_tablespace(), fil_space_for_table_exists_in_mem(), flags, dict_table_struct::ibd_file_missing, dict_table_struct::id, dict_table_struct::indexes, mach_read_from_4(), mach_read_from_8(), mem_heap_create, mem_heap_free, mtr_commit(), mtr_start(), dict_sys_struct::mutex, dict_table_struct::name, NULL, PAGE_CUR_GE, rec_get_deleted_flag(), rec_get_nth_field_old(), TRUE, ut_a, ut_ad, UT_LIST_GET_FIRST, ut_memcmp(), ut_print_timestamp(), ut_strcmp(), and ut_strlen().
Referenced by dict_load_table_on_id(), and row_drop_table_for_mysql().
00721 : table, NULL if does not exist; 00722 if the table is stored in an .ibd file, 00723 but the file does not exist, 00724 then we set the ibd_file_missing flag TRUE 00725 in the table object we return */ 00726 const char* name) /* in: table name in the 00727 databasename/tablename format */ 00728 { 00729 ibool ibd_file_missing = FALSE; 00730 dict_table_t* table; 00731 dict_table_t* sys_tables; 00732 btr_pcur_t pcur; 00733 dict_index_t* sys_index; 00734 dtuple_t* tuple; 00735 mem_heap_t* heap; 00736 dfield_t* dfield; 00737 rec_t* rec; 00738 byte* field; 00739 ulint len; 00740 ulint space; 00741 ulint n_cols; 00742 ulint flags; 00743 ulint err; 00744 mtr_t mtr; 00745 00746 #ifdef UNIV_SYNC_DEBUG 00747 ut_ad(mutex_own(&(dict_sys->mutex))); 00748 #endif /* UNIV_SYNC_DEBUG */ 00749 00750 heap = mem_heap_create(1000); 00751 00752 mtr_start(&mtr); 00753 00754 sys_tables = dict_table_get_low("SYS_TABLES"); 00755 sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); 00756 ut_a(!dict_table_is_comp(sys_tables)); 00757 00758 tuple = dtuple_create(heap, 1); 00759 dfield = dtuple_get_nth_field(tuple, 0); 00760 00761 dfield_set_data(dfield, name, ut_strlen(name)); 00762 dict_index_copy_types(tuple, sys_index, 1); 00763 00764 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, 00765 BTR_SEARCH_LEAF, &pcur, &mtr); 00766 rec = btr_pcur_get_rec(&pcur); 00767 00768 if (!btr_pcur_is_on_user_rec(&pcur, &mtr) 00769 || rec_get_deleted_flag(rec, 0)) { 00770 /* Not found */ 00771 err_exit: 00772 btr_pcur_close(&pcur); 00773 mtr_commit(&mtr); 00774 mem_heap_free(heap); 00775 00776 return(NULL); 00777 } 00778 00779 field = rec_get_nth_field_old(rec, 0, &len); 00780 00781 /* Check if the table name in record is the searched one */ 00782 if (len != ut_strlen(name) || ut_memcmp(name, field, len) != 0) { 00783 00784 goto err_exit; 00785 } 00786 00787 ut_a(0 == ut_strcmp("SPACE", 00788 dict_field_get_col( 00789 dict_index_get_nth_field(sys_index, 9))->name)); 00790 00791 field = rec_get_nth_field_old(rec, 9, &len); 00792 space = mach_read_from_4(field); 00793 00794 /* Check if the tablespace exists and has the right name */ 00795 if (space != 0) { 00796 if (fil_space_for_table_exists_in_mem(space, name, FALSE, 00797 FALSE, FALSE)) { 00798 /* Ok; (if we did a crash recovery then the tablespace 00799 can already be in the memory cache) */ 00800 } else { 00801 /* In >= 4.1.9, InnoDB scans the data dictionary also 00802 at a normal mysqld startup. It is an error if the 00803 space object does not exist in memory. */ 00804 00805 ut_print_timestamp(stderr); 00806 fprintf(stderr, 00807 " InnoDB: error: space object of table %s,\n" 00808 "InnoDB: space id %lu did not exist in memory. Retrying an open.\n", 00809 name, (ulong)space); 00810 /* Try to open the tablespace */ 00811 if (!fil_open_single_table_tablespace(TRUE, 00812 space, name)) { 00813 /* We failed to find a sensible tablespace 00814 file */ 00815 00816 ibd_file_missing = TRUE; 00817 } 00818 } 00819 } 00820 00821 ut_a(0 == ut_strcmp("N_COLS", 00822 dict_field_get_col( 00823 dict_index_get_nth_field(sys_index, 4))->name)); 00824 00825 field = rec_get_nth_field_old(rec, 4, &len); 00826 n_cols = mach_read_from_4(field); 00827 00828 flags = 0; 00829 00830 /* The high-order bit of N_COLS is the "compact format" flag. */ 00831 if (n_cols & 0x80000000UL) { 00832 flags |= DICT_TF_COMPACT; 00833 } 00834 00835 table = dict_mem_table_create(name, space, n_cols & ~0x80000000UL, 00836 flags); 00837 00838 table->ibd_file_missing = ibd_file_missing; 00839 00840 ut_a(0 == ut_strcmp("ID", 00841 dict_field_get_col( 00842 dict_index_get_nth_field(sys_index, 3))->name)); 00843 00844 field = rec_get_nth_field_old(rec, 3, &len); 00845 table->id = mach_read_from_8(field); 00846 00847 field = rec_get_nth_field_old(rec, 5, &len); 00848 if (UNIV_UNLIKELY(mach_read_from_4(field) != DICT_TABLE_ORDINARY)) { 00849 ut_print_timestamp(stderr); 00850 fprintf(stderr, 00851 " InnoDB: table %s: unknown table type %lu\n", 00852 name, (ulong) mach_read_from_4(field)); 00853 goto err_exit; 00854 } 00855 00856 btr_pcur_close(&pcur); 00857 mtr_commit(&mtr); 00858 00859 dict_load_columns(table, heap); 00860 00861 dict_table_add_to_cache(table); 00862 00863 dict_load_indexes(table, heap); 00864 00865 err = dict_load_foreigns(table->name, TRUE); 00866 /* 00867 if (err != DB_SUCCESS) { 00868 00869 mutex_enter(&dict_foreign_err_mutex); 00870 00871 ut_print_timestamp(stderr); 00872 00873 fprintf(stderr, 00874 " InnoDB: Error: could not make a foreign key definition to match\n" 00875 "InnoDB: the foreign key table or the referenced table!\n" 00876 "InnoDB: The data dictionary of InnoDB is corrupt. You may need to drop\n" 00877 "InnoDB: and recreate the foreign key table or the referenced table.\n" 00878 "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" 00879 "InnoDB: Latest foreign key error printout:\n%s\n", dict_foreign_err_buf); 00880 00881 mutex_exit(&dict_foreign_err_mutex); 00882 } 00883 */ 00884 mem_heap_free(heap); 00885 00886 return(table); 00887 }
Here is the call graph for this function:

Here is the caller graph for this function:

| dict_table_t* dict_load_table_on_id | ( | dulint | table_id | ) |
Definition at line 893 of file dict0load.c.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_open_on_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_index_copy_types(), dict_load_table(), dict_sys, dict_table_get_first_index(), dict_table_get_next_index(), dict_table_is_comp(), dtuple_create(), dtuple_get_nth_field(), mach_read_from_8(), mach_write_to_8(), mem_heap_create, mem_heap_free, mem_heap_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, NULL, PAGE_CUR_GE, rec_get_deleted_flag(), rec_get_nth_field_old(), dict_sys_struct::sys_tables, ut_a, ut_ad, and ut_dulint_cmp().
00895 : table; NULL if table does not exist */ 00896 dulint table_id) /* in: table id */ 00897 { 00898 byte id_buf[8]; 00899 btr_pcur_t pcur; 00900 mem_heap_t* heap; 00901 dtuple_t* tuple; 00902 dfield_t* dfield; 00903 dict_index_t* sys_table_ids; 00904 dict_table_t* sys_tables; 00905 rec_t* rec; 00906 byte* field; 00907 ulint len; 00908 dict_table_t* table; 00909 mtr_t mtr; 00910 00911 #ifdef UNIV_SYNC_DEBUG 00912 ut_ad(mutex_own(&(dict_sys->mutex))); 00913 #endif /* UNIV_SYNC_DEBUG */ 00914 00915 /* NOTE that the operation of this function is protected by 00916 the dictionary mutex, and therefore no deadlocks can occur 00917 with other dictionary operations. */ 00918 00919 mtr_start(&mtr); 00920 /*---------------------------------------------------*/ 00921 /* Get the secondary index based on ID for table SYS_TABLES */ 00922 sys_tables = dict_sys->sys_tables; 00923 sys_table_ids = dict_table_get_next_index( 00924 dict_table_get_first_index(sys_tables)); 00925 ut_a(!dict_table_is_comp(sys_tables)); 00926 heap = mem_heap_create(256); 00927 00928 tuple = dtuple_create(heap, 1); 00929 dfield = dtuple_get_nth_field(tuple, 0); 00930 00931 /* Write the table id in byte format to id_buf */ 00932 mach_write_to_8(id_buf, table_id); 00933 00934 dfield_set_data(dfield, id_buf, 8); 00935 dict_index_copy_types(tuple, sys_table_ids, 1); 00936 00937 btr_pcur_open_on_user_rec(sys_table_ids, tuple, PAGE_CUR_GE, 00938 BTR_SEARCH_LEAF, &pcur, &mtr); 00939 rec = btr_pcur_get_rec(&pcur); 00940 00941 if (!btr_pcur_is_on_user_rec(&pcur, &mtr) 00942 || rec_get_deleted_flag(rec, 0)) { 00943 /* Not found */ 00944 00945 btr_pcur_close(&pcur); 00946 mtr_commit(&mtr); 00947 mem_heap_free(heap); 00948 00949 return(NULL); 00950 } 00951 00952 /*---------------------------------------------------*/ 00953 /* Now we have the record in the secondary index containing the 00954 table ID and NAME */ 00955 00956 rec = btr_pcur_get_rec(&pcur); 00957 field = rec_get_nth_field_old(rec, 0, &len); 00958 ut_ad(len == 8); 00959 00960 /* Check if the table id in record is the one searched for */ 00961 if (ut_dulint_cmp(table_id, mach_read_from_8(field)) != 0) { 00962 00963 btr_pcur_close(&pcur); 00964 mtr_commit(&mtr); 00965 mem_heap_free(heap); 00966 00967 return(NULL); 00968 } 00969 00970 /* Now we get the table name from the record */ 00971 field = rec_get_nth_field_old(rec, 1, &len); 00972 /* Load the table definition to memory */ 00973 table = dict_load_table(mem_heap_strdupl(heap, (char*) field, len)); 00974 00975 btr_pcur_close(&pcur); 00976 mtr_commit(&mtr); 00977 mem_heap_free(heap); 00978 00979 return(table); 00980 }
Here is the call graph for this function:

| void dict_print | ( | void | ) |
Definition at line 120 of file dict0load.c.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_open_at_index_side(), btr_pcur_restore_position(), btr_pcur_store_position(), BTR_SEARCH_LEAF, dict_sys, dict_table_get_first_index(), dict_table_get_low(), dict_table_print_low(), dict_update_statistics_low(), dict_table_struct::indexes, kernel_mutex, mem_free, mem_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, mutex_enter, mutex_exit(), NULL, rec_get_deleted_flag(), rec_get_nth_field_old(), srv_fatal_semaphore_wait_threshold, TRUE, UT_LIST_GET_FIRST, and ut_print_namel().
Referenced by srv_lock_timeout_and_monitor_thread().
00122 { 00123 dict_table_t* sys_tables; 00124 dict_index_t* sys_index; 00125 dict_table_t* table; 00126 btr_pcur_t pcur; 00127 rec_t* rec; 00128 byte* field; 00129 ulint len; 00130 mtr_t mtr; 00131 00132 /* Enlarge the fatal semaphore wait timeout during the InnoDB table 00133 monitor printout */ 00134 00135 mutex_enter(&kernel_mutex); 00136 srv_fatal_semaphore_wait_threshold += 7200; /* 2 hours */ 00137 mutex_exit(&kernel_mutex); 00138 00139 mutex_enter(&(dict_sys->mutex)); 00140 00141 mtr_start(&mtr); 00142 00143 sys_tables = dict_table_get_low("SYS_TABLES"); 00144 sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); 00145 00146 btr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur, 00147 TRUE, &mtr); 00148 loop: 00149 btr_pcur_move_to_next_user_rec(&pcur, &mtr); 00150 00151 rec = btr_pcur_get_rec(&pcur); 00152 00153 if (!btr_pcur_is_on_user_rec(&pcur, &mtr)) { 00154 /* end of index */ 00155 00156 btr_pcur_close(&pcur); 00157 mtr_commit(&mtr); 00158 00159 mutex_exit(&(dict_sys->mutex)); 00160 00161 /* Restore the fatal semaphore wait timeout */ 00162 00163 mutex_enter(&kernel_mutex); 00164 srv_fatal_semaphore_wait_threshold -= 7200; /* 2 hours */ 00165 mutex_exit(&kernel_mutex); 00166 00167 return; 00168 } 00169 00170 field = rec_get_nth_field_old(rec, 0, &len); 00171 00172 if (!rec_get_deleted_flag(rec, 0)) { 00173 00174 /* We found one */ 00175 00176 char* table_name = mem_strdupl((char*) field, len); 00177 00178 btr_pcur_store_position(&pcur, &mtr); 00179 00180 mtr_commit(&mtr); 00181 00182 table = dict_table_get_low(table_name); 00183 mem_free(table_name); 00184 00185 if (table == NULL) { 00186 fputs("InnoDB: Failed to load table ", stderr); 00187 ut_print_namel(stderr, NULL, TRUE, (char*) field, len); 00188 putc('\n', stderr); 00189 } else { 00190 /* The table definition was corrupt if there 00191 is no index */ 00192 00193 if (dict_table_get_first_index(table)) { 00194 dict_update_statistics_low(table, TRUE); 00195 } 00196 00197 dict_table_print_low(table); 00198 } 00199 00200 mtr_start(&mtr); 00201 00202 btr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr); 00203 } 00204 00205 goto loop; 00206 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

