~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/dict/dict0boot.c

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
/**************************************************************************
27
27
Gets a pointer to the dictionary header and x-latches its page. */
28
 
 
 
28
UNIV_INTERN
29
29
dict_hdr_t*
30
30
dict_hdr_get(
31
31
/*=========*/
33
33
                        page x-latched */
34
34
        mtr_t*  mtr)    /* in: mtr */
35
35
{
 
36
        buf_block_t*    block;
36
37
        dict_hdr_t*     header;
37
38
 
38
 
        ut_ad(mtr);
39
 
 
40
 
        header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO,
41
 
                                         RW_X_LATCH, mtr);
 
39
        block = buf_page_get(DICT_HDR_SPACE, 0, DICT_HDR_PAGE_NO,
 
40
                             RW_X_LATCH, mtr);
 
41
        header = DICT_HDR + buf_block_get_frame(block);
42
42
#ifdef UNIV_SYNC_DEBUG
43
 
        buf_page_dbg_add_level(header, SYNC_DICT_HEADER);
 
43
        buf_block_dbg_add_level(block, SYNC_DICT_HEADER);
44
44
#endif /* UNIV_SYNC_DEBUG */
45
45
        return(header);
46
46
}
47
47
 
48
48
/**************************************************************************
49
49
Returns a new table, index, or tree id. */
50
 
 
 
50
UNIV_INTERN
51
51
dulint
52
52
dict_hdr_get_new_id(
53
53
/*================*/
77
77
/**************************************************************************
78
78
Writes the current value of the row id counter to the dictionary header file
79
79
page. */
80
 
 
 
80
UNIV_INTERN
81
81
void
82
82
dict_hdr_flush_row_id(void)
83
83
/*=======================*/
109
109
                        /* out: TRUE if succeed */
110
110
        mtr_t*  mtr)    /* in: mtr */
111
111
{
 
112
        buf_block_t*    block;
112
113
        dict_hdr_t*     dict_header;
113
 
        ulint           hdr_page_no;
114
114
        ulint           root_page_no;
115
 
        page_t*         page;
116
115
 
117
116
        ut_ad(mtr);
118
117
 
119
118
        /* Create the dictionary header file block in a new, allocated file
120
119
        segment in the system tablespace */
121
 
        page = fseg_create(DICT_HDR_SPACE, 0,
122
 
                           DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
123
 
 
124
 
        hdr_page_no = buf_frame_get_page_no(page);
125
 
 
126
 
        ut_a(DICT_HDR_PAGE_NO == hdr_page_no);
 
120
        block = fseg_create(DICT_HDR_SPACE, 0,
 
121
                            DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
 
122
 
 
123
        ut_a(DICT_HDR_PAGE_NO == buf_block_get_page_no(block));
127
124
 
128
125
        dict_header = dict_hdr_get(mtr);
129
126
 
147
144
 
148
145
        /*--------------------------*/
149
146
        root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
150
 
                                  DICT_HDR_SPACE, DICT_TABLES_ID, FALSE, mtr);
 
147
                                  DICT_HDR_SPACE, 0, DICT_TABLES_ID,
 
148
                                  srv_sys->dummy_ind1, mtr);
151
149
        if (root_page_no == FIL_NULL) {
152
150
 
153
151
                return(FALSE);
156
154
        mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no,
157
155
                         MLOG_4BYTES, mtr);
158
156
        /*--------------------------*/
159
 
        root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE,
160
 
                                  DICT_TABLE_IDS_ID, FALSE, mtr);
 
157
        root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, 0,
 
158
                                  DICT_TABLE_IDS_ID,
 
159
                                  srv_sys->dummy_ind1, mtr);
161
160
        if (root_page_no == FIL_NULL) {
162
161
 
163
162
                return(FALSE);
167
166
                         MLOG_4BYTES, mtr);
168
167
        /*--------------------------*/
169
168
        root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
170
 
                                  DICT_HDR_SPACE, DICT_COLUMNS_ID, FALSE, mtr);
 
169
                                  DICT_HDR_SPACE, 0, DICT_COLUMNS_ID,
 
170
                                  srv_sys->dummy_ind1, mtr);
171
171
        if (root_page_no == FIL_NULL) {
172
172
 
173
173
                return(FALSE);
177
177
                         MLOG_4BYTES, mtr);
178
178
        /*--------------------------*/
179
179
        root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
180
 
                                  DICT_HDR_SPACE, DICT_INDEXES_ID, FALSE, mtr);
 
180
                                  DICT_HDR_SPACE, 0, DICT_INDEXES_ID,
 
181
                                  srv_sys->dummy_ind1, mtr);
181
182
        if (root_page_no == FIL_NULL) {
182
183
 
183
184
                return(FALSE);
187
188
                         MLOG_4BYTES, mtr);
188
189
        /*--------------------------*/
189
190
        root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
190
 
                                  DICT_HDR_SPACE, DICT_FIELDS_ID, FALSE, mtr);
 
191
                                  DICT_HDR_SPACE, 0, DICT_FIELDS_ID,
 
192
                                  srv_sys->dummy_ind1, mtr);
191
193
        if (root_page_no == FIL_NULL) {
192
194
 
193
195
                return(FALSE);
203
205
/*********************************************************************
204
206
Initializes the data dictionary memory structures when the database is
205
207
started. This function is also called when the data dictionary is created. */
206
 
 
 
208
UNIV_INTERN
207
209
void
208
210
dict_boot(void)
209
211
/*===========*/
213
215
        dict_hdr_t*     dict_hdr;
214
216
        mem_heap_t*     heap;
215
217
        mtr_t           mtr;
 
218
        ulint           error;
216
219
 
217
220
        mtr_start(&mtr);
218
221
 
249
252
 
250
253
        dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
251
254
        dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
 
255
        /* ROW_FORMAT = (N_COLS >> 31) ? COMPACT : REDUNDANT */
252
256
        dict_mem_table_add_col(table, heap, "N_COLS", DATA_INT, 0, 4);
 
257
        /* TYPE is either DICT_TABLE_ORDINARY, or (TYPE & DICT_TF_COMPACT)
 
258
        and (TYPE & DICT_TF_FORMAT_MASK) are nonzero and TYPE = table->flags */
253
259
        dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4);
254
260
        dict_mem_table_add_col(table, heap, "MIX_ID", DATA_BINARY, 0, 0);
255
261
        dict_mem_table_add_col(table, heap, "MIX_LEN", DATA_INT, 0, 4);
270
276
 
271
277
        index->id = DICT_TABLES_ID;
272
278
 
273
 
        dict_index_add_to_cache(table, index,
274
 
                                mtr_read_ulint(dict_hdr + DICT_HDR_TABLES,
275
 
                                               MLOG_4BYTES, &mtr));
 
279
        error = dict_index_add_to_cache(table, index,
 
280
                                        mtr_read_ulint(dict_hdr
 
281
                                                       + DICT_HDR_TABLES,
 
282
                                                       MLOG_4BYTES, &mtr));
 
283
        ut_a(error == DB_SUCCESS);
276
284
 
277
285
        /*-------------------------*/
278
286
        index = dict_mem_index_create("SYS_TABLES", "ID_IND",
280
288
        dict_mem_index_add_field(index, "ID", 0);
281
289
 
282
290
        index->id = DICT_TABLE_IDS_ID;
283
 
        dict_index_add_to_cache(table, index,
284
 
                                mtr_read_ulint(dict_hdr + DICT_HDR_TABLE_IDS,
285
 
                                               MLOG_4BYTES, &mtr));
 
291
        error = dict_index_add_to_cache(table, index,
 
292
                                        mtr_read_ulint(dict_hdr
 
293
                                                       + DICT_HDR_TABLE_IDS,
 
294
                                                       MLOG_4BYTES, &mtr));
 
295
        ut_a(error == DB_SUCCESS);
286
296
 
287
297
        /*-------------------------*/
288
298
        table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
309
319
        dict_mem_index_add_field(index, "POS", 0);
310
320
 
311
321
        index->id = DICT_COLUMNS_ID;
312
 
        dict_index_add_to_cache(table, index,
313
 
                                mtr_read_ulint(dict_hdr + DICT_HDR_COLUMNS,
314
 
                                               MLOG_4BYTES, &mtr));
 
322
        error = dict_index_add_to_cache(table, index,
 
323
                                        mtr_read_ulint(dict_hdr
 
324
                                                       + DICT_HDR_COLUMNS,
 
325
                                                       MLOG_4BYTES, &mtr));
 
326
        ut_a(error == DB_SUCCESS);
315
327
 
316
328
        /*-------------------------*/
317
329
        table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
348
360
        dict_mem_index_add_field(index, "ID", 0);
349
361
 
350
362
        index->id = DICT_INDEXES_ID;
351
 
        dict_index_add_to_cache(table, index,
352
 
                                mtr_read_ulint(dict_hdr + DICT_HDR_INDEXES,
353
 
                                               MLOG_4BYTES, &mtr));
 
363
        error = dict_index_add_to_cache(table, index,
 
364
                                        mtr_read_ulint(dict_hdr
 
365
                                                       + DICT_HDR_INDEXES,
 
366
                                                       MLOG_4BYTES, &mtr));
 
367
        ut_a(error == DB_SUCCESS);
354
368
 
355
369
        /*-------------------------*/
356
370
        table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
372
386
        dict_mem_index_add_field(index, "POS", 0);
373
387
 
374
388
        index->id = DICT_FIELDS_ID;
375
 
        dict_index_add_to_cache(table, index,
376
 
                                mtr_read_ulint(dict_hdr + DICT_HDR_FIELDS,
377
 
                                               MLOG_4BYTES, &mtr));
 
389
        error = dict_index_add_to_cache(table, index,
 
390
                                        mtr_read_ulint(dict_hdr
 
391
                                                       + DICT_HDR_FIELDS,
 
392
                                                       MLOG_4BYTES, &mtr));
 
393
        ut_a(error == DB_SUCCESS);
378
394
 
379
395
        mtr_commit(&mtr);
380
396
        /*-------------------------*/
406
422
 
407
423
/*********************************************************************
408
424
Creates and initializes the data dictionary at the database creation. */
409
 
 
 
425
UNIV_INTERN
410
426
void
411
427
dict_create(void)
412
428
/*=============*/