~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

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
 
UNIV_INTERN
 
28
 
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;
37
36
        dict_hdr_t*     header;
38
37
 
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);
 
38
        ut_ad(mtr);
 
39
 
 
40
        header = DICT_HDR + buf_page_get(DICT_HDR_SPACE, DICT_HDR_PAGE_NO,
 
41
                                         RW_X_LATCH, mtr);
42
42
#ifdef UNIV_SYNC_DEBUG
43
 
        buf_block_dbg_add_level(block, SYNC_DICT_HEADER);
 
43
        buf_page_dbg_add_level(header, 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
 
UNIV_INTERN
 
50
 
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
 
UNIV_INTERN
 
80
 
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;
113
112
        dict_hdr_t*     dict_header;
 
113
        ulint           hdr_page_no;
114
114
        ulint           root_page_no;
 
115
        page_t*         page;
115
116
 
116
117
        ut_ad(mtr);
117
118
 
118
119
        /* Create the dictionary header file block in a new, allocated file
119
120
        segment in the system tablespace */
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));
 
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);
124
127
 
125
128
        dict_header = dict_hdr_get(mtr);
126
129
 
144
147
 
145
148
        /*--------------------------*/
146
149
        root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
147
 
                                  DICT_HDR_SPACE, 0, DICT_TABLES_ID,
148
 
                                  srv_sys->dummy_ind1, mtr);
 
150
                                  DICT_HDR_SPACE, DICT_TABLES_ID, FALSE, mtr);
149
151
        if (root_page_no == FIL_NULL) {
150
152
 
151
153
                return(FALSE);
154
156
        mlog_write_ulint(dict_header + DICT_HDR_TABLES, root_page_no,
155
157
                         MLOG_4BYTES, mtr);
156
158
        /*--------------------------*/
157
 
        root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE, 0,
158
 
                                  DICT_TABLE_IDS_ID,
159
 
                                  srv_sys->dummy_ind1, mtr);
 
159
        root_page_no = btr_create(DICT_UNIQUE, DICT_HDR_SPACE,
 
160
                                  DICT_TABLE_IDS_ID, FALSE, mtr);
160
161
        if (root_page_no == FIL_NULL) {
161
162
 
162
163
                return(FALSE);
166
167
                         MLOG_4BYTES, mtr);
167
168
        /*--------------------------*/
168
169
        root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
169
 
                                  DICT_HDR_SPACE, 0, DICT_COLUMNS_ID,
170
 
                                  srv_sys->dummy_ind1, mtr);
 
170
                                  DICT_HDR_SPACE, DICT_COLUMNS_ID, FALSE, 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, 0, DICT_INDEXES_ID,
181
 
                                  srv_sys->dummy_ind1, mtr);
 
180
                                  DICT_HDR_SPACE, DICT_INDEXES_ID, FALSE, mtr);
182
181
        if (root_page_no == FIL_NULL) {
183
182
 
184
183
                return(FALSE);
188
187
                         MLOG_4BYTES, mtr);
189
188
        /*--------------------------*/
190
189
        root_page_no = btr_create(DICT_CLUSTERED | DICT_UNIQUE,
191
 
                                  DICT_HDR_SPACE, 0, DICT_FIELDS_ID,
192
 
                                  srv_sys->dummy_ind1, mtr);
 
190
                                  DICT_HDR_SPACE, DICT_FIELDS_ID, FALSE, mtr);
193
191
        if (root_page_no == FIL_NULL) {
194
192
 
195
193
                return(FALSE);
205
203
/*********************************************************************
206
204
Initializes the data dictionary memory structures when the database is
207
205
started. This function is also called when the data dictionary is created. */
208
 
UNIV_INTERN
 
206
 
209
207
void
210
208
dict_boot(void)
211
209
/*===========*/
215
213
        dict_hdr_t*     dict_hdr;
216
214
        mem_heap_t*     heap;
217
215
        mtr_t           mtr;
218
 
        ulint           error;
219
216
 
220
217
        mtr_start(&mtr);
221
218
 
252
249
 
253
250
        dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
254
251
        dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
255
 
        /* ROW_FORMAT = (N_COLS >> 31) ? COMPACT : REDUNDANT */
256
252
        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 */
259
253
        dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4);
260
254
        dict_mem_table_add_col(table, heap, "MIX_ID", DATA_BINARY, 0, 0);
261
255
        dict_mem_table_add_col(table, heap, "MIX_LEN", DATA_INT, 0, 4);
276
270
 
277
271
        index->id = DICT_TABLES_ID;
278
272
 
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);
 
273
        dict_index_add_to_cache(table, index,
 
274
                                mtr_read_ulint(dict_hdr + DICT_HDR_TABLES,
 
275
                                               MLOG_4BYTES, &mtr));
284
276
 
285
277
        /*-------------------------*/
286
278
        index = dict_mem_index_create("SYS_TABLES", "ID_IND",
288
280
        dict_mem_index_add_field(index, "ID", 0);
289
281
 
290
282
        index->id = DICT_TABLE_IDS_ID;
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);
 
283
        dict_index_add_to_cache(table, index,
 
284
                                mtr_read_ulint(dict_hdr + DICT_HDR_TABLE_IDS,
 
285
                                               MLOG_4BYTES, &mtr));
296
286
 
297
287
        /*-------------------------*/
298
288
        table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0);
319
309
        dict_mem_index_add_field(index, "POS", 0);
320
310
 
321
311
        index->id = DICT_COLUMNS_ID;
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);
 
312
        dict_index_add_to_cache(table, index,
 
313
                                mtr_read_ulint(dict_hdr + DICT_HDR_COLUMNS,
 
314
                                               MLOG_4BYTES, &mtr));
327
315
 
328
316
        /*-------------------------*/
329
317
        table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0);
360
348
        dict_mem_index_add_field(index, "ID", 0);
361
349
 
362
350
        index->id = DICT_INDEXES_ID;
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);
 
351
        dict_index_add_to_cache(table, index,
 
352
                                mtr_read_ulint(dict_hdr + DICT_HDR_INDEXES,
 
353
                                               MLOG_4BYTES, &mtr));
368
354
 
369
355
        /*-------------------------*/
370
356
        table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0);
386
372
        dict_mem_index_add_field(index, "POS", 0);
387
373
 
388
374
        index->id = DICT_FIELDS_ID;
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);
 
375
        dict_index_add_to_cache(table, index,
 
376
                                mtr_read_ulint(dict_hdr + DICT_HDR_FIELDS,
 
377
                                               MLOG_4BYTES, &mtr));
394
378
 
395
379
        mtr_commit(&mtr);
396
380
        /*-------------------------*/
422
406
 
423
407
/*********************************************************************
424
408
Creates and initializes the data dictionary at the database creation. */
425
 
UNIV_INTERN
 
409
 
426
410
void
427
411
dict_create(void)
428
412
/*=============*/