1
1
/*****************************************************************************
3
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
64
64
/**********************************************************************//**
65
Returns a new table, index, or space id. */
65
Returns a new table, index, or tree id.
68
69
dict_hdr_get_new_id(
69
70
/*================*/
70
table_id_t* table_id, /*!< out: table id
71
(not assigned if NULL) */
72
index_id_t* index_id, /*!< out: index id
73
(not assigned if NULL) */
74
ulint* space_id) /*!< out: space id
75
(not assigned if NULL) */
71
ulint type) /*!< in: DICT_HDR_ROW_ID, ... */
77
73
dict_hdr_t* dict_hdr;
77
ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID));
83
81
dict_hdr = dict_hdr_get(&mtr);
86
id = mach_read_from_8(dict_hdr + DICT_HDR_TABLE_ID);
88
mlog_write_ull(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr);
93
id = mach_read_from_8(dict_hdr + DICT_HDR_INDEX_ID);
95
mlog_write_ull(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr);
100
*space_id = mtr_read_ulint(dict_hdr + DICT_HDR_MAX_SPACE_ID,
102
if (fil_assign_new_space_id(space_id)) {
103
mlog_write_ulint(dict_hdr + DICT_HDR_MAX_SPACE_ID,
104
*space_id, MLOG_4BYTES, &mtr);
83
id = mtr_read_dulint(dict_hdr + type, &mtr);
84
id = ut_dulint_add(id, 1);
86
mlog_write_dulint(dict_hdr + type, id, &mtr);
111
93
/**********************************************************************//**
129
111
dict_hdr = dict_hdr_get(&mtr);
131
mlog_write_ull(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
113
mlog_write_dulint(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
133
115
mtr_commit(&mtr);
161
143
/* Start counting row, table, index, and tree ids from
162
144
DICT_HDR_FIRST_ID */
163
mlog_write_ull(dict_header + DICT_HDR_ROW_ID,
164
DICT_HDR_FIRST_ID, mtr);
166
mlog_write_ull(dict_header + DICT_HDR_TABLE_ID,
167
DICT_HDR_FIRST_ID, mtr);
169
mlog_write_ull(dict_header + DICT_HDR_INDEX_ID,
170
DICT_HDR_FIRST_ID, mtr);
172
mlog_write_ulint(dict_header + DICT_HDR_MAX_SPACE_ID,
173
0, MLOG_4BYTES, mtr);
175
/* Obsolete, but we must initialize it anyway. */
176
mlog_write_ulint(dict_header + DICT_HDR_MIX_ID_LOW,
177
DICT_HDR_FIRST_ID, MLOG_4BYTES, mtr);
145
mlog_write_dulint(dict_header + DICT_HDR_ROW_ID,
146
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
148
mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID,
149
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
151
mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID,
152
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
154
/* Obsolete, but we must initialize it to 0 anyway. */
155
mlog_write_dulint(dict_header + DICT_HDR_MIX_ID,
156
ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
179
158
/* Create the B-tree roots for the clustered indexes of the basic
276
255
..._MARGIN, it will immediately be updated to the disk-based
279
dict_sys->row_id = DICT_HDR_ROW_ID_WRITE_MARGIN
280
+ ut_uint64_align_up(mach_read_from_8(dict_hdr + DICT_HDR_ROW_ID),
281
DICT_HDR_ROW_ID_WRITE_MARGIN);
258
dict_sys->row_id = ut_dulint_add(
259
ut_dulint_align_up(mtr_read_dulint(dict_hdr + DICT_HDR_ROW_ID,
261
DICT_HDR_ROW_ID_WRITE_MARGIN),
262
DICT_HDR_ROW_ID_WRITE_MARGIN);
283
264
/* Insert into the dictionary cache the descriptions of the basic
293
274
and (TYPE & DICT_TF_FORMAT_MASK) are nonzero and TYPE = table->flags */
294
275
dict_mem_table_add_col(table, heap, "TYPE", DATA_INT, 0, 4);
295
276
dict_mem_table_add_col(table, heap, "MIX_ID", DATA_BINARY, 0, 0);
296
/* MIX_LEN may contain additional table flags when
297
ROW_FORMAT!=REDUNDANT. Currently, these flags include
298
DICT_TF2_TEMPORARY. */
299
277
dict_mem_table_add_col(table, heap, "MIX_LEN", DATA_INT, 0, 4);
300
278
dict_mem_table_add_col(table, heap, "CLUSTER_NAME", DATA_BINARY, 0, 0);
301
279
dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4);
377
355
dict_mem_table_add_col(table, heap, "SPACE", DATA_INT, 0, 4);
378
356
dict_mem_table_add_col(table, heap, "PAGE_NO", DATA_INT, 0, 4);
380
/* The '+ 2' below comes from the fields DB_TRX_ID, DB_ROLL_PTR */
358
/* The '+ 2' below comes from the 2 system fields */
381
359
#if DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2
382
360
#error "DICT_SYS_INDEXES_PAGE_NO_FIELD != 6 + 2"
387
365
#if DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2
388
366
#error "DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2"
390
#if DICT_SYS_INDEXES_NAME_FIELD != 2 + 2
391
#error "DICT_SYS_INDEXES_NAME_FIELD != 2 + 2"
394
369
table->id = DICT_INDEXES_ID;
395
370
dict_table_add_to_cache(table, heap);