InnoDB Plugin  1.0
dict0boot.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #ifndef dict0boot_h
27 #define dict0boot_h
28 
29 #include "univ.i"
30 
31 #include "mtr0mtr.h"
32 #include "mtr0log.h"
33 #include "ut0byte.h"
34 #include "buf0buf.h"
35 #include "fsp0fsp.h"
36 #include "dict0dict.h"
37 
38 typedef byte dict_hdr_t;
39 
40 /**********************************************************************/
43 UNIV_INTERN
44 dict_hdr_t*
46 /*=========*/
47  mtr_t* mtr);
48 /**********************************************************************/
50 UNIV_INTERN
51 void
53 /*================*/
54  table_id_t* table_id,
56  index_id_t* index_id,
58  ulint* space_id);
60 /**********************************************************************/
63 UNIV_INTERN
64 void
66 /*=======================*/
67 /**********************************************************************/
70 UNIV_INLINE
73 /*=========================*/
74 /**********************************************************************/
77 UNIV_INLINE
80 /*=================*/
81  const byte* field);
82 /**********************************************************************/
84 UNIV_INLINE
85 void
87 /*==================*/
88  byte* field,
89  row_id_t row_id);
90 /*****************************************************************/
94 UNIV_INTERN
95 dberr_t
96 dict_boot(void)
97 /*===========*/
98  __attribute__((warn_unused_result));
99 
100 /*****************************************************************/
103 UNIV_INTERN
104 dberr_t
105 dict_create(void)
106 /*=============*/
107  __attribute__((warn_unused_result));
108 
109 /*********************************************************************/
112 UNIV_INLINE
113 bool
115 /*==============*/
116  table_id_t id)
117  __attribute__((warn_unused_result));
118 
119 /* Space id and page no where the dictionary header resides */
120 #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */
121 #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO
122 
123 /* The ids for the basic system tables and their indexes */
124 #define DICT_TABLES_ID 1
125 #define DICT_COLUMNS_ID 2
126 #define DICT_INDEXES_ID 3
127 #define DICT_FIELDS_ID 4
128 /* The following is a secondary index on SYS_TABLES */
129 #define DICT_TABLE_IDS_ID 5
130 
131 #define DICT_HDR_FIRST_ID 10 /* the ids for tables etc. start
132  from this number, except for basic
133  system tables and their above defined
134  indexes; ibuf tables and indexes are
135  assigned as the id the number
136  DICT_IBUF_ID_MIN plus the space id */
137 
138 /* The offset of the dictionary header on the page */
139 #define DICT_HDR FSEG_PAGE_DATA
140 
141 /*-------------------------------------------------------------*/
142 /* Dictionary header offsets */
143 #define DICT_HDR_ROW_ID 0 /* The latest assigned row id */
144 #define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */
145 #define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */
146 #define DICT_HDR_MAX_SPACE_ID 24 /* The latest assigned space id,or 0*/
147 #define DICT_HDR_MIX_ID_LOW 28 /* Obsolete,always DICT_HDR_FIRST_ID*/
148 #define DICT_HDR_TABLES 32 /* Root of SYS_TABLES clust index */
149 #define DICT_HDR_TABLE_IDS 36 /* Root of SYS_TABLE_IDS sec index */
150 #define DICT_HDR_COLUMNS 40 /* Root of SYS_COLUMNS clust index */
151 #define DICT_HDR_INDEXES 44 /* Root of SYS_INDEXES clust index */
152 #define DICT_HDR_FIELDS 48 /* Root of SYS_FIELDS clust index */
153 
154 #define DICT_HDR_FSEG_HEADER 56 /* Segment header for the tablespace
155  segment into which the dictionary
156  header is created */
157 /*-------------------------------------------------------------*/
158 
159 /* The columns in SYS_TABLES */
160 enum dict_col_sys_tables_enum {
161  DICT_COL__SYS_TABLES__NAME = 0,
162  DICT_COL__SYS_TABLES__ID = 1,
163  DICT_COL__SYS_TABLES__N_COLS = 2,
164  DICT_COL__SYS_TABLES__TYPE = 3,
165  DICT_COL__SYS_TABLES__MIX_ID = 4,
166  DICT_COL__SYS_TABLES__MIX_LEN = 5,
167  DICT_COL__SYS_TABLES__CLUSTER_ID = 6,
168  DICT_COL__SYS_TABLES__SPACE = 7,
169  DICT_NUM_COLS__SYS_TABLES = 8
170 };
171 /* The field numbers in the SYS_TABLES clustered index */
172 enum dict_fld_sys_tables_enum {
173  DICT_FLD__SYS_TABLES__NAME = 0,
174  DICT_FLD__SYS_TABLES__DB_TRX_ID = 1,
175  DICT_FLD__SYS_TABLES__DB_ROLL_PTR = 2,
176  DICT_FLD__SYS_TABLES__ID = 3,
177  DICT_FLD__SYS_TABLES__N_COLS = 4,
178  DICT_FLD__SYS_TABLES__TYPE = 5,
179  DICT_FLD__SYS_TABLES__MIX_ID = 6,
180  DICT_FLD__SYS_TABLES__MIX_LEN = 7,
181  DICT_FLD__SYS_TABLES__CLUSTER_ID = 8,
182  DICT_FLD__SYS_TABLES__SPACE = 9,
183  DICT_NUM_FIELDS__SYS_TABLES = 10
184 };
185 /* The field numbers in the SYS_TABLE_IDS index */
186 enum dict_fld_sys_table_ids_enum {
187  DICT_FLD__SYS_TABLE_IDS__ID = 0,
188  DICT_FLD__SYS_TABLE_IDS__NAME = 1,
189  DICT_NUM_FIELDS__SYS_TABLE_IDS = 2
190 };
191 /* The columns in SYS_COLUMNS */
192 enum dict_col_sys_columns_enum {
193  DICT_COL__SYS_COLUMNS__TABLE_ID = 0,
194  DICT_COL__SYS_COLUMNS__POS = 1,
195  DICT_COL__SYS_COLUMNS__NAME = 2,
196  DICT_COL__SYS_COLUMNS__MTYPE = 3,
197  DICT_COL__SYS_COLUMNS__PRTYPE = 4,
198  DICT_COL__SYS_COLUMNS__LEN = 5,
199  DICT_COL__SYS_COLUMNS__PREC = 6,
200  DICT_NUM_COLS__SYS_COLUMNS = 7
201 };
202 /* The field numbers in the SYS_COLUMNS clustered index */
203 enum dict_fld_sys_columns_enum {
204  DICT_FLD__SYS_COLUMNS__TABLE_ID = 0,
205  DICT_FLD__SYS_COLUMNS__POS = 1,
206  DICT_FLD__SYS_COLUMNS__DB_TRX_ID = 2,
207  DICT_FLD__SYS_COLUMNS__DB_ROLL_PTR = 3,
208  DICT_FLD__SYS_COLUMNS__NAME = 4,
209  DICT_FLD__SYS_COLUMNS__MTYPE = 5,
210  DICT_FLD__SYS_COLUMNS__PRTYPE = 6,
211  DICT_FLD__SYS_COLUMNS__LEN = 7,
212  DICT_FLD__SYS_COLUMNS__PREC = 8,
213  DICT_NUM_FIELDS__SYS_COLUMNS = 9
214 };
215 /* The columns in SYS_INDEXES */
216 enum dict_col_sys_indexes_enum {
217  DICT_COL__SYS_INDEXES__TABLE_ID = 0,
218  DICT_COL__SYS_INDEXES__ID = 1,
219  DICT_COL__SYS_INDEXES__NAME = 2,
220  DICT_COL__SYS_INDEXES__N_FIELDS = 3,
221  DICT_COL__SYS_INDEXES__TYPE = 4,
222  DICT_COL__SYS_INDEXES__SPACE = 5,
223  DICT_COL__SYS_INDEXES__PAGE_NO = 6,
224  DICT_NUM_COLS__SYS_INDEXES = 7
225 };
226 /* The field numbers in the SYS_INDEXES clustered index */
227 enum dict_fld_sys_indexes_enum {
228  DICT_FLD__SYS_INDEXES__TABLE_ID = 0,
229  DICT_FLD__SYS_INDEXES__ID = 1,
230  DICT_FLD__SYS_INDEXES__DB_TRX_ID = 2,
231  DICT_FLD__SYS_INDEXES__DB_ROLL_PTR = 3,
232  DICT_FLD__SYS_INDEXES__NAME = 4,
233  DICT_FLD__SYS_INDEXES__N_FIELDS = 5,
234  DICT_FLD__SYS_INDEXES__TYPE = 6,
235  DICT_FLD__SYS_INDEXES__SPACE = 7,
236  DICT_FLD__SYS_INDEXES__PAGE_NO = 8,
237  DICT_NUM_FIELDS__SYS_INDEXES = 9
238 };
239 /* The columns in SYS_FIELDS */
240 enum dict_col_sys_fields_enum {
241  DICT_COL__SYS_FIELDS__INDEX_ID = 0,
242  DICT_COL__SYS_FIELDS__POS = 1,
243  DICT_COL__SYS_FIELDS__COL_NAME = 2,
244  DICT_NUM_COLS__SYS_FIELDS = 3
245 };
246 /* The field numbers in the SYS_FIELDS clustered index */
247 enum dict_fld_sys_fields_enum {
248  DICT_FLD__SYS_FIELDS__INDEX_ID = 0,
249  DICT_FLD__SYS_FIELDS__POS = 1,
250  DICT_FLD__SYS_FIELDS__DB_TRX_ID = 2,
251  DICT_FLD__SYS_FIELDS__DB_ROLL_PTR = 3,
252  DICT_FLD__SYS_FIELDS__COL_NAME = 4,
253  DICT_NUM_FIELDS__SYS_FIELDS = 5
254 };
255 /* The columns in SYS_FOREIGN */
256 enum dict_col_sys_foreign_enum {
257  DICT_COL__SYS_FOREIGN__ID = 0,
258  DICT_COL__SYS_FOREIGN__FOR_NAME = 1,
259  DICT_COL__SYS_FOREIGN__REF_NAME = 2,
260  DICT_COL__SYS_FOREIGN__N_COLS = 3,
261  DICT_NUM_COLS__SYS_FOREIGN = 4
262 };
263 /* The field numbers in the SYS_FOREIGN clustered index */
264 enum dict_fld_sys_foreign_enum {
265  DICT_FLD__SYS_FOREIGN__ID = 0,
266  DICT_FLD__SYS_FOREIGN__DB_TRX_ID = 1,
267  DICT_FLD__SYS_FOREIGN__DB_ROLL_PTR = 2,
268  DICT_FLD__SYS_FOREIGN__FOR_NAME = 3,
269  DICT_FLD__SYS_FOREIGN__REF_NAME = 4,
270  DICT_FLD__SYS_FOREIGN__N_COLS = 5,
271  DICT_NUM_FIELDS__SYS_FOREIGN = 6
272 };
273 /* The field numbers in the SYS_FOREIGN_FOR_NAME secondary index */
274 enum dict_fld_sys_foreign_for_name_enum {
275  DICT_FLD__SYS_FOREIGN_FOR_NAME__NAME = 0,
276  DICT_FLD__SYS_FOREIGN_FOR_NAME__ID = 1,
277  DICT_NUM_FIELDS__SYS_FOREIGN_FOR_NAME = 2
278 };
279 /* The columns in SYS_FOREIGN_COLS */
280 enum dict_col_sys_foreign_cols_enum {
281  DICT_COL__SYS_FOREIGN_COLS__ID = 0,
282  DICT_COL__SYS_FOREIGN_COLS__POS = 1,
283  DICT_COL__SYS_FOREIGN_COLS__FOR_COL_NAME = 2,
284  DICT_COL__SYS_FOREIGN_COLS__REF_COL_NAME = 3,
285  DICT_NUM_COLS__SYS_FOREIGN_COLS = 4
286 };
287 /* The field numbers in the SYS_FOREIGN_COLS clustered index */
288 enum dict_fld_sys_foreign_cols_enum {
289  DICT_FLD__SYS_FOREIGN_COLS__ID = 0,
290  DICT_FLD__SYS_FOREIGN_COLS__POS = 1,
291  DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_ID = 2,
292  DICT_FLD__SYS_FOREIGN_COLS__DB_ROLL_PTR = 3,
293  DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME = 4,
294  DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME = 5,
295  DICT_NUM_FIELDS__SYS_FOREIGN_COLS = 6
296 };
297 /* The columns in SYS_TABLESPACES */
298 enum dict_col_sys_tablespaces_enum {
299  DICT_COL__SYS_TABLESPACES__SPACE = 0,
300  DICT_COL__SYS_TABLESPACES__NAME = 1,
301  DICT_COL__SYS_TABLESPACES__FLAGS = 2,
302  DICT_NUM_COLS__SYS_TABLESPACES = 3
303 };
304 /* The field numbers in the SYS_TABLESPACES clustered index */
305 enum dict_fld_sys_tablespaces_enum {
306  DICT_FLD__SYS_TABLESPACES__SPACE = 0,
307  DICT_FLD__SYS_TABLESPACES__DB_TRX_ID = 1,
308  DICT_FLD__SYS_TABLESPACES__DB_ROLL_PTR = 2,
309  DICT_FLD__SYS_TABLESPACES__NAME = 3,
310  DICT_FLD__SYS_TABLESPACES__FLAGS = 4,
311  DICT_NUM_FIELDS__SYS_TABLESPACES = 5
312 };
313 /* The columns in SYS_DATAFILES */
314 enum dict_col_sys_datafiles_enum {
315  DICT_COL__SYS_DATAFILES__SPACE = 0,
316  DICT_COL__SYS_DATAFILES__PATH = 1,
317  DICT_NUM_COLS__SYS_DATAFILES = 2
318 };
319 /* The field numbers in the SYS_DATAFILES clustered index */
320 enum dict_fld_sys_datafiles_enum {
321  DICT_FLD__SYS_DATAFILES__SPACE = 0,
322  DICT_FLD__SYS_DATAFILES__DB_TRX_ID = 1,
323  DICT_FLD__SYS_DATAFILES__DB_ROLL_PTR = 2,
324  DICT_FLD__SYS_DATAFILES__PATH = 3,
325  DICT_NUM_FIELDS__SYS_DATAFILES = 4
326 };
327 
328 /* A number of the columns above occur in multiple tables. These are the
329 length of thos fields. */
330 #define DICT_FLD_LEN_SPACE 4
331 #define DICT_FLD_LEN_FLAGS 4
332 
333 /* When a row id which is zero modulo this number (which must be a power of
334 two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is
335 updated */
336 #define DICT_HDR_ROW_ID_WRITE_MARGIN 256
337 
338 #ifndef UNIV_NONINL
339 #include "dict0boot.ic"
340 #endif
341 
342 #endif