~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: lbieber
  • Date: 2010-10-06 16:34:16 UTC
  • mfrom: (1816.1.3 build)
  • Revision ID: lbieber@orisndriz08-20101006163416-ea0sl59qgpglk21y
Merge Monty - Change the requirement from either libinnodb to libhaildb. Also, tied it to version 2.2
Merge Andrew - fix bug 650935: remove --compress from all clients
Merge Andrew - fix bug 653471: Add -A to drizzle client
Merge Travis - 621861 = To change C structs to C++ classes in Drizzle

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1996, 2010, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
4
4
 
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
62
62
}
63
63
 
64
64
/**********************************************************************//**
65
 
Returns a new table, index, or space id. */
 
65
Returns a new table, index, or tree id.
 
66
@return the new id */
66
67
UNIV_INTERN
67
 
void
 
68
dulint
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, ... */
76
72
{
77
73
        dict_hdr_t*     dict_hdr;
78
 
        ib_id_t         id;
 
74
        dulint          id;
79
75
        mtr_t           mtr;
80
76
 
 
77
        ut_ad((type == DICT_HDR_TABLE_ID) || (type == DICT_HDR_INDEX_ID));
 
78
 
81
79
        mtr_start(&mtr);
82
80
 
83
81
        dict_hdr = dict_hdr_get(&mtr);
84
82
 
85
 
        if (table_id) {
86
 
                id = mach_read_from_8(dict_hdr + DICT_HDR_TABLE_ID);
87
 
                id++;
88
 
                mlog_write_ull(dict_hdr + DICT_HDR_TABLE_ID, id, &mtr);
89
 
                *table_id = id;
90
 
        }
91
 
 
92
 
        if (index_id) {
93
 
                id = mach_read_from_8(dict_hdr + DICT_HDR_INDEX_ID);
94
 
                id++;
95
 
                mlog_write_ull(dict_hdr + DICT_HDR_INDEX_ID, id, &mtr);
96
 
                *index_id = id;
97
 
        }
98
 
 
99
 
        if (space_id) {
100
 
                *space_id = mtr_read_ulint(dict_hdr + DICT_HDR_MAX_SPACE_ID,
101
 
                                           MLOG_4BYTES, &mtr);
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);
105
 
                }
106
 
        }
 
83
        id = mtr_read_dulint(dict_hdr + type, &mtr);
 
84
        id = ut_dulint_add(id, 1);
 
85
 
 
86
        mlog_write_dulint(dict_hdr + type, id, &mtr);
107
87
 
108
88
        mtr_commit(&mtr);
 
89
 
 
90
        return(id);
109
91
}
110
92
 
111
93
/**********************************************************************//**
117
99
/*=======================*/
118
100
{
119
101
        dict_hdr_t*     dict_hdr;
120
 
        row_id_t        id;
 
102
        dulint          id;
121
103
        mtr_t           mtr;
122
104
 
123
105
        ut_ad(mutex_own(&(dict_sys->mutex)));
128
110
 
129
111
        dict_hdr = dict_hdr_get(&mtr);
130
112
 
131
 
        mlog_write_ull(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
 
113
        mlog_write_dulint(dict_hdr + DICT_HDR_ROW_ID, id, &mtr);
132
114
 
133
115
        mtr_commit(&mtr);
134
116
}
160
142
 
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);
165
 
 
166
 
        mlog_write_ull(dict_header + DICT_HDR_TABLE_ID,
167
 
                       DICT_HDR_FIRST_ID, mtr);
168
 
 
169
 
        mlog_write_ull(dict_header + DICT_HDR_INDEX_ID,
170
 
                       DICT_HDR_FIRST_ID, mtr);
171
 
 
172
 
        mlog_write_ulint(dict_header + DICT_HDR_MAX_SPACE_ID,
173
 
                         0, MLOG_4BYTES, mtr);
174
 
 
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);
 
147
 
 
148
        mlog_write_dulint(dict_header + DICT_HDR_TABLE_ID,
 
149
                          ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
 
150
 
 
151
        mlog_write_dulint(dict_header + DICT_HDR_INDEX_ID,
 
152
                          ut_dulint_create(0, DICT_HDR_FIRST_ID), mtr);
 
153
 
 
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);
178
157
 
179
158
        /* Create the B-tree roots for the clustered indexes of the basic
180
159
        system tables */
276
255
        ..._MARGIN, it will immediately be updated to the disk-based
277
256
        header. */
278
257
 
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,
 
260
                                                   &mtr),
 
261
                                   DICT_HDR_ROW_ID_WRITE_MARGIN),
 
262
                DICT_HDR_ROW_ID_WRITE_MARGIN);
282
263
 
283
264
        /* Insert into the dictionary cache the descriptions of the basic
284
265
        system tables */
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);
379
357
 
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"
383
361
#endif
387
365
#if DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2
388
366
#error "DICT_SYS_INDEXES_TYPE_FIELD != 4 + 2"
389
367
#endif
390
 
#if DICT_SYS_INDEXES_NAME_FIELD != 2 + 2
391
 
#error "DICT_SYS_INDEXES_NAME_FIELD != 2 + 2"
392
 
#endif
393
368
 
394
369
        table->id = DICT_INDEXES_ID;
395
370
        dict_table_add_to_cache(table, heap);