#include "dict0boot.h"#include "dict0crea.h"#include "btr0btr.h"#include "dict0load.h"#include "trx0trx.h"#include "srv0srv.h"#include "ibuf0ibuf.h"#include "buf0flu.h"#include "log0recv.h"#include "os0file.h"Include dependency graph for dict0boot.c:

Go to the source code of this file.
Functions | |
| dict_hdr_t * | dict_hdr_get (mtr_t *mtr) |
| dulint | dict_hdr_get_new_id (ulint type) |
| void | dict_hdr_flush_row_id (void) |
| static ibool | dict_hdr_create (mtr_t *mtr) |
| void | dict_boot (void) |
| static void | dict_insert_initial_data (void) |
| void | dict_create (void) |
| void dict_boot | ( | void | ) |
Definition at line 210 of file dict0boot.c.
References DATA_BINARY, DATA_INT, DICT_CLUSTERED, DICT_COLUMNS_ID, DICT_FIELDS_ID, DICT_HDR_COLUMNS, DICT_HDR_FIELDS, dict_hdr_get(), DICT_HDR_INDEXES, DICT_HDR_ROW_ID, DICT_HDR_ROW_ID_WRITE_MARGIN, DICT_HDR_SPACE, DICT_HDR_TABLE_IDS, DICT_HDR_TABLES, dict_index_add_to_cache(), DICT_INDEXES_ID, dict_init(), dict_load_sys_table(), dict_mem_index_add_field(), dict_mem_index_create(), dict_mem_table_add_col(), dict_mem_table_create(), dict_sys, dict_table_add_to_cache(), DICT_TABLE_IDS_ID, DICT_TABLES_ID, DICT_UNIQUE, ibuf_init_at_db_start(), dict_table_struct::id, index(), MLOG_4BYTES, mtr_commit(), mtr_read_dulint(), mtr_read_ulint(), mtr_start(), dict_sys_struct::mutex, mutex_enter, mutex_exit(), dict_sys_struct::row_id, dict_sys_struct::sys_columns, dict_sys_struct::sys_fields, dict_sys_struct::sys_indexes, dict_sys_struct::sys_tables, ut_a, ut_dulint_add(), and ut_dulint_align_up().
Referenced by dict_create(), and innobase_start_or_create_for_mysql().
00212 { 00213 dict_table_t* table; 00214 dict_index_t* index; 00215 dict_hdr_t* dict_hdr; 00216 mtr_t mtr; 00217 ibool success; 00218 00219 mtr_start(&mtr); 00220 00221 /* Create the hash tables etc. */ 00222 dict_init(); 00223 00224 mutex_enter(&(dict_sys->mutex)); 00225 00226 /* Get the dictionary header */ 00227 dict_hdr = dict_hdr_get(&mtr); 00228 00229 /* Because we only write new row ids to disk-based data structure 00230 (dictionary header) when it is divisible by 00231 DICT_HDR_ROW_ID_WRITE_MARGIN, in recovery we will not recover 00232 the latest value of the row id counter. Therefore we advance 00233 the counter at the database startup to avoid overlapping values. 00234 Note that when a user after database startup first time asks for 00235 a new row id, then because the counter is now divisible by 00236 ..._MARGIN, it will immediately be updated to the disk-based 00237 header. */ 00238 00239 dict_sys->row_id = ut_dulint_add( 00240 ut_dulint_align_up( 00241 mtr_read_dulint(dict_hdr + DICT_HDR_ROW_ID, &mtr), 00242 DICT_HDR_ROW_ID_WRITE_MARGIN), 00243 DICT_HDR_ROW_ID_WRITE_MARGIN); 00244 00245 /* Insert into the dictionary cache the descriptions of the basic 00246 system tables */ 00247 /*-------------------------*/ 00248 table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0); 00249 00250 dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0); 00251 dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0); 00252 dict_mem_table_add_col(table, "N_COLS", DATA_INT, 0, 4, 0); 00253 dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4, 0); 00254 dict_mem_table_add_col(table, "MIX_ID", DATA_BINARY, 0, 0, 0); 00255 dict_mem_table_add_col(table, "MIX_LEN", DATA_INT, 0, 4, 0); 00256 dict_mem_table_add_col(table, "CLUSTER_NAME", DATA_BINARY, 0, 0, 0); 00257 dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4, 0); 00258 00259 table->id = DICT_TABLES_ID; 00260 00261 dict_table_add_to_cache(table); 00262 dict_sys->sys_tables = table; 00263 00264 index = dict_mem_index_create("SYS_TABLES", "CLUST_IND", 00265 DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 1); 00266 00267 dict_mem_index_add_field(index, "NAME", 0); 00268 00269 index->id = DICT_TABLES_ID; 00270 00271 success = dict_index_add_to_cache(table, index, mtr_read_ulint( 00272 dict_hdr + DICT_HDR_TABLES, MLOG_4BYTES, &mtr)); 00273 ut_a(success); 00274 /*-------------------------*/ 00275 index = dict_mem_index_create("SYS_TABLES", "ID_IND", 00276 DICT_HDR_SPACE, DICT_UNIQUE, 1); 00277 dict_mem_index_add_field(index, "ID", 0); 00278 00279 index->id = DICT_TABLE_IDS_ID; 00280 success = dict_index_add_to_cache(table, index, mtr_read_ulint( 00281 dict_hdr + DICT_HDR_TABLE_IDS, MLOG_4BYTES, &mtr)); 00282 ut_a(success); 00283 /*-------------------------*/ 00284 table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0); 00285 00286 dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY,0,0,0); 00287 dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0); 00288 dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0); 00289 dict_mem_table_add_col(table, "MTYPE", DATA_INT, 0, 4, 0); 00290 dict_mem_table_add_col(table, "PRTYPE", DATA_INT, 0, 4, 0); 00291 dict_mem_table_add_col(table, "LEN", DATA_INT, 0, 4, 0); 00292 dict_mem_table_add_col(table, "PREC", DATA_INT, 0, 4, 0); 00293 00294 table->id = DICT_COLUMNS_ID; 00295 00296 dict_table_add_to_cache(table); 00297 dict_sys->sys_columns = table; 00298 00299 index = dict_mem_index_create("SYS_COLUMNS", "CLUST_IND", 00300 DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); 00301 00302 dict_mem_index_add_field(index, "TABLE_ID", 0); 00303 dict_mem_index_add_field(index, "POS", 0); 00304 00305 index->id = DICT_COLUMNS_ID; 00306 success = dict_index_add_to_cache(table, index, mtr_read_ulint( 00307 dict_hdr + DICT_HDR_COLUMNS, MLOG_4BYTES, &mtr)); 00308 ut_a(success); 00309 /*-------------------------*/ 00310 table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0); 00311 00312 dict_mem_table_add_col(table, "TABLE_ID", DATA_BINARY, 0,0,0); 00313 dict_mem_table_add_col(table, "ID", DATA_BINARY, 0, 0, 0); 00314 dict_mem_table_add_col(table, "NAME", DATA_BINARY, 0, 0, 0); 00315 dict_mem_table_add_col(table, "N_FIELDS", DATA_INT, 0, 4, 0); 00316 dict_mem_table_add_col(table, "TYPE", DATA_INT, 0, 4, 0); 00317 dict_mem_table_add_col(table, "SPACE", DATA_INT, 0, 4, 0); 00318 dict_mem_table_add_col(table, "PAGE_NO", DATA_INT, 0, 4, 0); 00319 00320 /* The '+ 2' below comes from the 2 system fields */ 00321 #if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2 00322 #error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2" 00323 #endif 00324 #if DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2 00325 #error "DICT_SYS_INDEXES_SPACE_NO_FIELD != 5 + 2" 00326 #endif 00327 #if DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2 00328 #error "DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2" 00329 #endif 00330 00331 table->id = DICT_INDEXES_ID; 00332 dict_table_add_to_cache(table); 00333 dict_sys->sys_indexes = table; 00334 00335 index = dict_mem_index_create("SYS_INDEXES", "CLUST_IND", 00336 DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); 00337 00338 dict_mem_index_add_field(index, "TABLE_ID", 0); 00339 dict_mem_index_add_field(index, "ID", 0); 00340 00341 index->id = DICT_INDEXES_ID; 00342 success = dict_index_add_to_cache(table, index, mtr_read_ulint( 00343 dict_hdr + DICT_HDR_INDEXES, MLOG_4BYTES, &mtr)); 00344 ut_a(success); 00345 /*-------------------------*/ 00346 table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0); 00347 00348 dict_mem_table_add_col(table, "INDEX_ID", DATA_BINARY, 0,0,0); 00349 dict_mem_table_add_col(table, "POS", DATA_INT, 0, 4, 0); 00350 dict_mem_table_add_col(table, "COL_NAME", DATA_BINARY, 0,0,0); 00351 00352 table->id = DICT_FIELDS_ID; 00353 dict_table_add_to_cache(table); 00354 dict_sys->sys_fields = table; 00355 00356 index = dict_mem_index_create("SYS_FIELDS", "CLUST_IND", 00357 DICT_HDR_SPACE, DICT_UNIQUE | DICT_CLUSTERED, 2); 00358 00359 dict_mem_index_add_field(index, "INDEX_ID", 0); 00360 dict_mem_index_add_field(index, "POS", 0); 00361 00362 index->id = DICT_FIELDS_ID; 00363 success = dict_index_add_to_cache(table, index, mtr_read_ulint( 00364 dict_hdr + DICT_HDR_FIELDS, MLOG_4BYTES, &mtr)); 00365 ut_a(success); 00366 00367 mtr_commit(&mtr); 00368 /*-------------------------*/ 00369 00370 /* Initialize the insert buffer table and index for each tablespace */ 00371 00372 ibuf_init_at_db_start(); 00373 00374 /* Load definitions of other indexes on system tables */ 00375 00376 dict_load_sys_table(dict_sys->sys_tables); 00377 dict_load_sys_table(dict_sys->sys_columns); 00378 dict_load_sys_table(dict_sys->sys_indexes); 00379 dict_load_sys_table(dict_sys->sys_fields); 00380 00381 mutex_exit(&(dict_sys->mutex)); 00382 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dict_create | ( | void | ) |
Definition at line 399 of file dict0boot.c.
References dict_boot(), dict_hdr_create(), dict_insert_initial_data(), mtr_commit(), and mtr_start().
Referenced by innobase_start_or_create_for_mysql().
00401 { 00402 mtr_t mtr; 00403 00404 mtr_start(&mtr); 00405 00406 dict_hdr_create(&mtr); 00407 00408 mtr_commit(&mtr); 00409 00410 dict_boot(); 00411 00412 dict_insert_initial_data(); 00413 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static ibool dict_hdr_create | ( | mtr_t * | mtr | ) | [static] |
Definition at line 110 of file dict0boot.c.
References btr_create(), buf_frame_get_page_no(), DICT_CLUSTERED, DICT_COLUMNS_ID, DICT_FIELDS_ID, DICT_HDR, DICT_HDR_COLUMNS, DICT_HDR_FIELDS, DICT_HDR_FIRST_ID, DICT_HDR_FSEG_HEADER, dict_hdr_get(), DICT_HDR_INDEX_ID, DICT_HDR_INDEXES, DICT_HDR_MIX_ID, DICT_HDR_PAGE_NO, DICT_HDR_ROW_ID, DICT_HDR_SPACE, DICT_HDR_TABLE_ID, DICT_HDR_TABLE_IDS, DICT_HDR_TABLES, DICT_INDEXES_ID, DICT_TABLE_IDS_ID, DICT_TABLES_ID, DICT_UNIQUE, FALSE, FIL_NULL, fseg_create(), MLOG_4BYTES, mlog_write_dulint(), mlog_write_ulint(), page, page_t, TRUE, ut_a, ut_ad, and ut_dulint_create().
Referenced by dict_create().
00112 : TRUE if succeed */ 00113 mtr_t* mtr) /* in: mtr */ 00114 { 00115 dict_hdr_t* dict_header; 00116 ulint hdr_page_no; 00117 ulint root_page_no; 00118 page_t* page; 00119 00120 ut_ad(mtr); 00121 00122 /* Create the dictionary header file block in a new, allocated file 00123 segment in the system tablespace */ 00124 page = fseg_create(DICT_HDR_SPACE, 0, 00125 DICT_HDR + DICT_HDR_FSEG_HEADER, mtr); 00126 00127 hdr_page_no = buf_frame_get_page_no(page); 00128 00129 ut_a(DICT_HDR_PAGE_NO == hdr_page_no); 00130 00131 dict_header = dict_hdr_get(mtr); 00132 00133 /* Start counting row, table, index, and tree ids from 00134 DICT_HDR_FIRST_ID */ 00135 mlog_write_dulint(dict_header + DICT_HDR_ROW_ID, 00136 ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); 00137 00138 mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID, 00139 ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); 00140 00141 mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID, 00142 ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); 00143 00144 mlog_write_dulint(dict_header + DICT_HDR_MIX_ID, 00145 ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr); 00146 00147 /* Create the B-tree roots for the clustered indexes of the basic 00148 system tables */ 00149 00150 /*--------------------------*/ 00151 root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, 00152 DICT_HDR_SPACE, DICT_TABLES_ID, FALSE, mtr); 00153 if (root_page_no == FIL_NULL) { 00154 00155 return(FALSE); 00156 } 00157 00158 mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no, 00159 MLOG_4BYTES, mtr); 00160 /*--------------------------*/ 00161 root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, 00162 DICT_TABLE_IDS_ID, FALSE, mtr); 00163 if (root_page_no == FIL_NULL) { 00164 00165 return(FALSE); 00166 } 00167 00168 mlog_write_ulint(dict_header + DICT_HDR_TABLE_IDS, root_page_no, 00169 MLOG_4BYTES, mtr); 00170 /*--------------------------*/ 00171 root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, 00172 DICT_HDR_SPACE, DICT_COLUMNS_ID, FALSE, mtr); 00173 if (root_page_no == FIL_NULL) { 00174 00175 return(FALSE); 00176 } 00177 00178 mlog_write_ulint(dict_header + DICT_HDR_COLUMNS, root_page_no, 00179 MLOG_4BYTES, mtr); 00180 /*--------------------------*/ 00181 root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, 00182 DICT_HDR_SPACE, DICT_INDEXES_ID, FALSE, mtr); 00183 if (root_page_no == FIL_NULL) { 00184 00185 return(FALSE); 00186 } 00187 00188 mlog_write_ulint(dict_header + DICT_HDR_INDEXES, root_page_no, 00189 MLOG_4BYTES, mtr); 00190 /*--------------------------*/ 00191 root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE, 00192 DICT_HDR_SPACE, DICT_FIELDS_ID, FALSE, mtr); 00193 if (root_page_no == FIL_NULL) { 00194 00195 return(FALSE); 00196 } 00197 00198 mlog_write_ulint(dict_header + DICT_HDR_FIELDS, root_page_no, 00199 MLOG_4BYTES, mtr); 00200 /*--------------------------*/ 00201 00202 return(TRUE); 00203 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void dict_hdr_flush_row_id | ( | void | ) |
Definition at line 83 of file dict0boot.c.
References dict_hdr_get(), DICT_HDR_ROW_ID, dict_sys, id, mlog_write_dulint(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, dict_sys_struct::row_id, and ut_ad.
00085 { 00086 dict_hdr_t* dict_hdr; 00087 dulint id; 00088 mtr_t mtr; 00089 00090 #ifdef UNIV_SYNC_DEBUG 00091 ut_ad(mutex_own(&(dict_sys->mutex))); 00092 #endif /* UNIV_SYNC_DEBUG */ 00093 00094 id = dict_sys->row_id; 00095 00096 mtr_start(&mtr); 00097 00098 dict_hdr = dict_hdr_get(&mtr); 00099 00100 mlog_write_dulint(dict_hdr + DICT_HDR_ROW_ID, id, &mtr); 00101 00102 mtr_commit(&mtr); 00103 }
Here is the call graph for this function:

| dict_hdr_t* dict_hdr_get | ( | mtr_t * | mtr | ) |
Definition at line 30 of file dict0boot.c.
References buf_page_get, DICT_HDR, DICT_HDR_PAGE_NO, DICT_HDR_SPACE, RW_X_LATCH, SYNC_DICT_HEADER, and ut_ad.
Referenced by dict_boot(), dict_hdr_create(), dict_hdr_flush_row_id(), and dict_hdr_get_new_id().
00032 : pointer to the dictionary header, 00033 page x-latched */ 00034 mtr_t* mtr) /* in: mtr */ 00035 { 00036 dict_hdr_t* header; 00037 00038 ut_ad(mtr); 00039 00040 header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO, 00041 RW_X_LATCH, mtr); 00042 #ifdef UNIV_SYNC_DEBUG 00043 buf_page_dbg_add_level(header, SYNC_DICT_HEADER); 00044 #endif /* UNIV_SYNC_DEBUG */ 00045 return(header); 00046 }
Here is the caller graph for this function:

Definition at line 52 of file dict0boot.c.
References dict_hdr_get(), DICT_HDR_INDEX_ID, DICT_HDR_MIX_ID, DICT_HDR_TABLE_ID, id, mlog_write_dulint(), mtr_commit(), mtr_read_dulint(), mtr_start(), ut_ad, and ut_dulint_add().
Referenced by dict_build_index_def_step(), dict_build_table_def_step(), row_discard_tablespace_for_mysql(), and row_truncate_table_for_mysql().
00054 : the new id */ 00055 ulint type) /* in: DICT_HDR_ROW_ID, ... */ 00056 { 00057 dict_hdr_t* dict_hdr; 00058 dulint id; 00059 mtr_t mtr; 00060 00061 ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID) 00062 || (type == DICT_HDR_MIX_ID)); 00063 00064 mtr_start(&mtr); 00065 00066 dict_hdr = dict_hdr_get(&mtr); 00067 00068 id = mtr_read_dulint(dict_hdr + type, &mtr); 00069 id = ut_dulint_add(id, 1); 00070 00071 mlog_write_dulint(dict_hdr + type, id, &mtr); 00072 00073 mtr_commit(&mtr); 00074 00075 return(id); 00076 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void dict_insert_initial_data | ( | void | ) | [static] |
Definition at line 389 of file dict0boot.c.
Referenced by dict_create().
Here is the caller graph for this function:

1.4.7

