00001 /****************************************************** 00002 Data dictionary creation and booting 00003 00004 (c) 1996 Innobase Oy 00005 00006 Created 4/18/1996 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef dict0boot_h 00010 #define dict0boot_h 00011 00012 #include "univ.i" 00013 00014 #include "mtr0mtr.h" 00015 #include "mtr0log.h" 00016 #include "ut0byte.h" 00017 #include "buf0buf.h" 00018 #include "fsp0fsp.h" 00019 #include "dict0dict.h" 00020 00021 typedef byte dict_hdr_t; 00022 00023 /************************************************************************** 00024 Gets a pointer to the dictionary header and x-latches its page. */ 00025 00026 dict_hdr_t* 00027 dict_hdr_get( 00028 /*=========*/ 00029 /* out: pointer to the dictionary header, 00030 page x-latched */ 00031 mtr_t* mtr); /* in: mtr */ 00032 /************************************************************************** 00033 Returns a new row, table, index, or tree id. */ 00034 00035 dulint 00036 dict_hdr_get_new_id( 00037 /*================*/ 00038 /* out: the new id */ 00039 ulint type); /* in: DICT_HDR_ROW_ID, ... */ 00040 /************************************************************************** 00041 Returns a new row id. */ 00042 UNIV_INLINE 00043 dulint 00044 dict_sys_get_new_row_id(void); 00045 /*=========================*/ 00046 /* out: the new id */ 00047 /************************************************************************** 00048 Reads a row id from a record or other 6-byte stored form. */ 00049 UNIV_INLINE 00050 dulint 00051 dict_sys_read_row_id( 00052 /*=================*/ 00053 /* out: row id */ 00054 byte* field); /* in: record field */ 00055 /************************************************************************** 00056 Writes a row id to a record or other 6-byte stored form. */ 00057 UNIV_INLINE 00058 void 00059 dict_sys_write_row_id( 00060 /*==================*/ 00061 byte* field, /* in: record field */ 00062 dulint row_id);/* in: row id */ 00063 /********************************************************************* 00064 Initializes the data dictionary memory structures when the database is 00065 started. This function is also called when the data dictionary is created. */ 00066 00067 void 00068 dict_boot(void); 00069 /*===========*/ 00070 /********************************************************************* 00071 Creates and initializes the data dictionary at the database creation. */ 00072 00073 void 00074 dict_create(void); 00075 /*=============*/ 00076 00077 00078 /* Space id and page no where the dictionary header resides */ 00079 #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */ 00080 #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO 00081 00082 /* The ids for the basic system tables and their indexes */ 00083 #define DICT_TABLES_ID ut_dulint_create(0, 1) 00084 #define DICT_COLUMNS_ID ut_dulint_create(0, 2) 00085 #define DICT_INDEXES_ID ut_dulint_create(0, 3) 00086 #define DICT_FIELDS_ID ut_dulint_create(0, 4) 00087 /* The following is a secondary index on SYS_TABLES */ 00088 #define DICT_TABLE_IDS_ID ut_dulint_create(0, 5) 00089 00090 #define DICT_HDR_FIRST_ID 10 /* the ids for tables etc. start 00091 from this number, except for basic 00092 system tables and their above defined 00093 indexes; ibuf tables and indexes are 00094 assigned as the id the number 00095 DICT_IBUF_ID_MIN plus the space id */ 00096 #define DICT_IBUF_ID_MIN ut_dulint_create(0xFFFFFFFFUL, 0) 00097 00098 /* The offset of the dictionary header on the page */ 00099 #define DICT_HDR FSEG_PAGE_DATA 00100 00101 /*-------------------------------------------------------------*/ 00102 /* Dictionary header offsets */ 00103 #define DICT_HDR_ROW_ID 0 /* The latest assigned row id */ 00104 #define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */ 00105 #define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */ 00106 #define DICT_HDR_MIX_ID 24 /* The latest assigned mix id */ 00107 #define DICT_HDR_TABLES 32 /* Root of the table index tree */ 00108 #define DICT_HDR_TABLE_IDS 36 /* Root of the table index tree */ 00109 #define DICT_HDR_COLUMNS 40 /* Root of the column index tree */ 00110 #define DICT_HDR_INDEXES 44 /* Root of the index index tree */ 00111 #define DICT_HDR_FIELDS 48 /* Root of the index field index tree */ 00112 00113 #define DICT_HDR_FSEG_HEADER 56 /* Segment header for the tablespace 00114 segment into which the dictionary 00115 header is created */ 00116 /*-------------------------------------------------------------*/ 00117 00118 /* The field number of the page number field in the sys_indexes table 00119 clustered index */ 00120 #define DICT_SYS_INDEXES_PAGE_NO_FIELD 8 00121 #define DICT_SYS_INDEXES_SPACE_NO_FIELD 7 00122 #define DICT_SYS_INDEXES_TYPE_FIELD 6 00123 00124 /* When a row id which is zero modulo this number (which must be a power of 00125 two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is 00126 updated */ 00127 #define DICT_HDR_ROW_ID_WRITE_MARGIN 256 00128 00129 #ifndef UNIV_NONINL 00130 #include "dict0boot.ic" 00131 #endif 00132 00133 #endif
1.4.7

