#include "univ.i"#include "mtr0mtr.h"#include "mtr0log.h"#include "ut0byte.h"#include "buf0buf.h"#include "fsp0fsp.h"#include "dict0dict.h"Include dependency graph for dict0boot.h:

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

Go to the source code of this file.
Defines | |
| #define | DICT_HDR_SPACE 0 |
| #define | DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO |
| #define | DICT_TABLES_ID ut_dulint_create(0, 1) |
| #define | DICT_COLUMNS_ID ut_dulint_create(0, 2) |
| #define | DICT_INDEXES_ID ut_dulint_create(0, 3) |
| #define | DICT_FIELDS_ID ut_dulint_create(0, 4) |
| #define | DICT_TABLE_IDS_ID ut_dulint_create(0, 5) |
| #define | DICT_HDR_FIRST_ID 10 |
| #define | DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFFUL, 0) |
| #define | DICT_HDR FSEG_PAGE_DATA |
| #define | DICT_HDR_ROW_ID 0 |
| #define | DICT_HDR_TABLE_ID 8 |
| #define | DICT_HDR_INDEX_ID 16 |
| #define | DICT_HDR_MIX_ID 24 |
| #define | DICT_HDR_TABLES 32 |
| #define | DICT_HDR_TABLE_IDS 36 |
| #define | DICT_HDR_COLUMNS 40 |
| #define | DICT_HDR_INDEXES 44 |
| #define | DICT_HDR_FIELDS 48 |
| #define | DICT_HDR_FSEG_HEADER 56 |
| #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_HDR_ROW_ID_WRITE_MARGIN 256 |
Typedefs | |
| typedef byte | dict_hdr_t |
Functions | |
| dict_hdr_t * | dict_hdr_get (mtr_t *mtr) |
| dulint | dict_hdr_get_new_id (ulint type) |
| UNIV_INLINE dulint | dict_sys_get_new_row_id (void) |
| UNIV_INLINE dulint | dict_sys_read_row_id (byte *field) |
| UNIV_INLINE void | dict_sys_write_row_id (byte *field, dulint row_id) |
| void | dict_boot (void) |
| void | dict_create (void) |
| #define DICT_COLUMNS_ID ut_dulint_create(0, 2) |
| #define DICT_FIELDS_ID ut_dulint_create(0, 4) |
Definition at line 86 of file dict0boot.h.
Referenced by dict_boot(), dict_hdr_create(), and dict_table_get_on_id().
| #define DICT_HDR FSEG_PAGE_DATA |
| #define DICT_HDR_COLUMNS 40 |
| #define DICT_HDR_FIELDS 48 |
| #define DICT_HDR_FIRST_ID 10 |
Definition at line 90 of file dict0boot.h.
Referenced by dict_hdr_create(), and dict_load_indexes().
| #define DICT_HDR_FSEG_HEADER 56 |
| #define DICT_HDR_INDEX_ID 16 |
Definition at line 105 of file dict0boot.h.
Referenced by dict_build_index_def_step(), dict_hdr_create(), and dict_hdr_get_new_id().
| #define DICT_HDR_INDEXES 44 |
| #define DICT_HDR_MIX_ID 24 |
Definition at line 106 of file dict0boot.h.
Referenced by dict_hdr_create(), and dict_hdr_get_new_id().
| #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO |
| #define DICT_HDR_ROW_ID 0 |
Definition at line 103 of file dict0boot.h.
Referenced by dict_boot(), dict_hdr_create(), and dict_hdr_flush_row_id().
| #define DICT_HDR_ROW_ID_WRITE_MARGIN 256 |
| #define DICT_HDR_SPACE 0 |
Definition at line 79 of file dict0boot.h.
Referenced by dict_boot(), dict_hdr_create(), dict_hdr_get(), ibuf_dummy_index_create(), mlog_parse_index(), and srv_init().
| #define DICT_HDR_TABLE_ID 8 |
Definition at line 104 of file dict0boot.h.
Referenced by dict_build_table_def_step(), dict_hdr_create(), dict_hdr_get_new_id(), row_discard_tablespace_for_mysql(), and row_truncate_table_for_mysql().
| #define DICT_HDR_TABLE_IDS 36 |
| #define DICT_HDR_TABLES 32 |
| #define DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFFUL, 0) |
Definition at line 96 of file dict0boot.h.
Referenced by fsp_header_init(), and ibuf_data_init_for_space().
| #define DICT_INDEXES_ID ut_dulint_create(0, 3) |
Definition at line 85 of file dict0boot.h.
Referenced by dict_boot(), dict_hdr_create(), row_undo_ins_remove_clust_rec(), and row_upd_clust_step().
| #define DICT_SYS_INDEXES_PAGE_NO_FIELD 8 |
Definition at line 120 of file dict0boot.h.
Referenced by dict_create_index_tree_step(), dict_drop_index_tree(), dict_truncate_index_tree(), and row_truncate_table_for_mysql().
| #define DICT_SYS_INDEXES_SPACE_NO_FIELD 7 |
Definition at line 121 of file dict0boot.h.
Referenced by dict_drop_index_tree(), and dict_truncate_index_tree().
| #define DICT_SYS_INDEXES_TYPE_FIELD 6 |
| #define DICT_TABLE_IDS_ID ut_dulint_create(0, 5) |
| #define DICT_TABLES_ID ut_dulint_create(0, 1) |
| typedef byte dict_hdr_t |
Definition at line 21 of file dict0boot.h.
| 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:

| 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:

| UNIV_INLINE dulint dict_sys_get_new_row_id | ( | void | ) |
1.4.7

