11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
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., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
17
*****************************************************************************/
52
52
dict_create_sys_tables_tuple(
53
53
/*=========================*/
54
const dict_table_t* table, /*!< in: table */
55
mem_heap_t* heap) /*!< in: memory heap from
56
which the memory for the built
54
dict_table_t* table, /*!< in: table */
55
mem_heap_t* heap) /*!< in: memory heap from which the memory for
56
the built tuple is allocated */
59
58
dict_table_t* sys_tables;
67
65
sys_tables = dict_sys->sys_tables;
71
69
dict_table_copy_types(entry, sys_tables);
73
71
/* 0: NAME -----------------------------*/
74
dfield = dtuple_get_nth_field(entry, 0/*NAME*/);
72
dfield = dtuple_get_nth_field(entry, 0);
76
74
dfield_set_data(dfield, table->name, ut_strlen(table->name));
77
75
/* 3: ID -------------------------------*/
78
dfield = dtuple_get_nth_field(entry, 1/*ID*/);
76
dfield = dtuple_get_nth_field(entry, 1);
80
78
ptr = mem_heap_alloc(heap, 8);
81
79
mach_write_to_8(ptr, table->id);
83
81
dfield_set_data(dfield, ptr, 8);
84
82
/* 4: N_COLS ---------------------------*/
85
dfield = dtuple_get_nth_field(entry, 2/*N_COLS*/);
83
dfield = dtuple_get_nth_field(entry, 2);
87
85
#if DICT_TF_COMPACT != 1
93
91
| ((table->flags & DICT_TF_COMPACT) << 31));
94
92
dfield_set_data(dfield, ptr, 4);
95
93
/* 5: TYPE -----------------------------*/
96
dfield = dtuple_get_nth_field(entry, 3/*TYPE*/);
94
dfield = dtuple_get_nth_field(entry, 3);
98
96
ptr = mem_heap_alloc(heap, 4);
99
if (table->flags & (~DICT_TF_COMPACT & ~(~0 << DICT_TF_BITS))) {
97
if (table->flags & ~DICT_TF_COMPACT) {
100
98
ut_a(table->flags & DICT_TF_COMPACT);
101
99
ut_a(dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP);
102
100
ut_a((table->flags & DICT_TF_ZSSIZE_MASK)
103
101
<= (DICT_TF_ZSSIZE_MAX << DICT_TF_ZSSIZE_SHIFT));
104
ut_a(!(table->flags & (~0 << DICT_TF2_BITS)));
105
mach_write_to_4(ptr, table->flags & ~(~0 << DICT_TF_BITS));
102
ut_a(!(table->flags & (~0 << DICT_TF_BITS)));
103
mach_write_to_4(ptr, table->flags);
107
105
mach_write_to_4(ptr, DICT_TABLE_ORDINARY);
110
108
dfield_set_data(dfield, ptr, 4);
111
109
/* 6: MIX_ID (obsolete) ---------------------------*/
112
dfield = dtuple_get_nth_field(entry, 4/*MIX_ID*/);
110
dfield = dtuple_get_nth_field(entry, 4);
114
112
ptr = mem_heap_zalloc(heap, 8);
116
114
dfield_set_data(dfield, ptr, 8);
117
/* 7: MIX_LEN (additional flags) --------------------------*/
119
dfield = dtuple_get_nth_field(entry, 5/*MIX_LEN*/);
121
ptr = mem_heap_alloc(heap, 4);
122
mach_write_to_4(ptr, table->flags >> DICT_TF2_SHIFT);
115
/* 7: MIX_LEN (obsolete) --------------------------*/
117
dfield = dtuple_get_nth_field(entry, 5);
119
ptr = mem_heap_zalloc(heap, 4);
124
121
dfield_set_data(dfield, ptr, 4);
125
122
/* 8: CLUSTER_NAME ---------------------*/
126
dfield = dtuple_get_nth_field(entry, 6/*CLUSTER_NAME*/);
123
dfield = dtuple_get_nth_field(entry, 6);
127
124
dfield_set_null(dfield); /* not supported */
129
126
/* 9: SPACE ----------------------------*/
130
dfield = dtuple_get_nth_field(entry, 7/*SPACE*/);
127
dfield = dtuple_get_nth_field(entry, 7);
132
129
ptr = mem_heap_alloc(heap, 4);
133
130
mach_write_to_4(ptr, table->space);
147
144
dict_create_sys_columns_tuple(
148
145
/*==========================*/
149
const dict_table_t* table, /*!< in: table */
150
ulint i, /*!< in: column number */
151
mem_heap_t* heap) /*!< in: memory heap from
152
which the memory for the built
153
tuple is allocated */
146
dict_table_t* table, /*!< in: table */
147
ulint i, /*!< in: column number */
148
mem_heap_t* heap) /*!< in: memory heap from which the memory for
149
the built tuple is allocated */
155
151
dict_table_t* sys_columns;
157
153
const dict_col_t* column;
158
154
dfield_t* dfield;
160
const char* col_name;
156
const char* col_name;
158
ut_ad(table && heap);
165
160
column = dict_table_get_nth_col(table, i);
171
166
dict_table_copy_types(entry, sys_columns);
173
168
/* 0: TABLE_ID -----------------------*/
174
dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
169
dfield = dtuple_get_nth_field(entry, 0);
176
171
ptr = mem_heap_alloc(heap, 8);
177
172
mach_write_to_8(ptr, table->id);
179
174
dfield_set_data(dfield, ptr, 8);
180
175
/* 1: POS ----------------------------*/
181
dfield = dtuple_get_nth_field(entry, 1/*POS*/);
176
dfield = dtuple_get_nth_field(entry, 1);
183
178
ptr = mem_heap_alloc(heap, 4);
184
179
mach_write_to_4(ptr, i);
186
181
dfield_set_data(dfield, ptr, 4);
187
182
/* 4: NAME ---------------------------*/
188
dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
183
dfield = dtuple_get_nth_field(entry, 2);
190
185
col_name = dict_table_get_col_name(table, i);
191
186
dfield_set_data(dfield, col_name, ut_strlen(col_name));
192
187
/* 5: MTYPE --------------------------*/
193
dfield = dtuple_get_nth_field(entry, 3/*MTYPE*/);
188
dfield = dtuple_get_nth_field(entry, 3);
195
190
ptr = mem_heap_alloc(heap, 4);
196
191
mach_write_to_4(ptr, column->mtype);
198
193
dfield_set_data(dfield, ptr, 4);
199
194
/* 6: PRTYPE -------------------------*/
200
dfield = dtuple_get_nth_field(entry, 4/*PRTYPE*/);
195
dfield = dtuple_get_nth_field(entry, 4);
202
197
ptr = mem_heap_alloc(heap, 4);
203
198
mach_write_to_4(ptr, column->prtype);
205
200
dfield_set_data(dfield, ptr, 4);
206
201
/* 7: LEN ----------------------------*/
207
dfield = dtuple_get_nth_field(entry, 5/*LEN*/);
202
dfield = dtuple_get_nth_field(entry, 5);
209
204
ptr = mem_heap_alloc(heap, 4);
210
205
mach_write_to_4(ptr, column->len);
212
207
dfield_set_data(dfield, ptr, 4);
213
208
/* 8: PREC ---------------------------*/
214
dfield = dtuple_get_nth_field(entry, 6/*PREC*/);
209
dfield = dtuple_get_nth_field(entry, 6);
216
211
ptr = mem_heap_alloc(heap, 4);
217
212
mach_write_to_4(ptr, 0/* unused */);
235
230
dict_table_t* table;
239
233
const char* path_or_name;
243
ibool file_per_table;
245
237
ut_ad(mutex_own(&(dict_sys->mutex)));
247
239
table = node->table;
249
/* Cache the global variable "srv_file_per_table" to
250
a local variable before using it. Please note
251
"srv_file_per_table" is not under dict_sys mutex
252
protection, and could be changed while executing
253
this function. So better to cache the current value
254
to a local variable, and all future reference to
255
"srv_file_per_table" should use this local variable. */
256
file_per_table = srv_file_per_table;
258
dict_hdr_get_new_id(&table->id, NULL, NULL);
241
table->id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
260
243
thr_get_trx(thr)->table_id = table->id;
262
if (file_per_table) {
263
/* Get a new space id if srv_file_per_table is set */
264
dict_hdr_get_new_id(NULL, NULL, &space);
266
if (UNIV_UNLIKELY(space == ULINT_UNDEFINED)) {
245
if (srv_file_per_table) {
270
246
/* We create a new single-table tablespace for the table.
271
247
We initially let it be 4 pages:
272
248
- page 0 is the fsp header and an extent descriptor page,
290
268
ut_ad(!dict_table_zip_size(table)
291
269
|| dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP);
293
flags = table->flags & ~(~0 << DICT_TF_BITS);
294
271
error = fil_create_new_single_table_tablespace(
295
space, path_or_name, is_path,
296
flags == DICT_TF_COMPACT ? 0 : flags,
272
&space, path_or_name, is_path,
273
table->flags == DICT_TF_COMPACT ? 0 : table->flags,
297
274
FIL_IBD_FILE_INITIAL_SIZE);
298
275
table->space = (unsigned int) space;
346
323
dict_create_sys_indexes_tuple(
347
324
/*==========================*/
348
const dict_index_t* index, /*!< in: index */
349
mem_heap_t* heap) /*!< in: memory heap from
350
which the memory for the built
351
tuple is allocated */
325
dict_index_t* index, /*!< in: index */
326
mem_heap_t* heap) /*!< in: memory heap from which the memory for
327
the built tuple is allocated */
353
329
dict_table_t* sys_indexes;
354
330
dict_table_t* table;
369
344
dict_table_copy_types(entry, sys_indexes);
371
346
/* 0: TABLE_ID -----------------------*/
372
dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
347
dfield = dtuple_get_nth_field(entry, 0);
374
349
ptr = mem_heap_alloc(heap, 8);
375
350
mach_write_to_8(ptr, table->id);
377
352
dfield_set_data(dfield, ptr, 8);
378
353
/* 1: ID ----------------------------*/
379
dfield = dtuple_get_nth_field(entry, 1/*ID*/);
354
dfield = dtuple_get_nth_field(entry, 1);
381
356
ptr = mem_heap_alloc(heap, 8);
382
357
mach_write_to_8(ptr, index->id);
384
359
dfield_set_data(dfield, ptr, 8);
385
360
/* 4: NAME --------------------------*/
386
dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
361
dfield = dtuple_get_nth_field(entry, 2);
388
363
dfield_set_data(dfield, index->name, ut_strlen(index->name));
389
364
/* 5: N_FIELDS ----------------------*/
390
dfield = dtuple_get_nth_field(entry, 3/*N_FIELDS*/);
365
dfield = dtuple_get_nth_field(entry, 3);
392
367
ptr = mem_heap_alloc(heap, 4);
393
368
mach_write_to_4(ptr, index->n_fields);
395
370
dfield_set_data(dfield, ptr, 4);
396
371
/* 6: TYPE --------------------------*/
397
dfield = dtuple_get_nth_field(entry, 4/*TYPE*/);
372
dfield = dtuple_get_nth_field(entry, 4);
399
374
ptr = mem_heap_alloc(heap, 4);
400
375
mach_write_to_4(ptr, index->type);
438
413
dict_create_sys_fields_tuple(
439
414
/*=========================*/
440
const dict_index_t* index, /*!< in: index */
441
ulint i, /*!< in: field number */
442
mem_heap_t* heap) /*!< in: memory heap from
443
which the memory for the built
444
tuple is allocated */
415
dict_index_t* index, /*!< in: index */
416
ulint i, /*!< in: field number */
417
mem_heap_t* heap) /*!< in: memory heap from which the memory for
418
the built tuple is allocated */
446
420
dict_table_t* sys_fields;
470
443
dict_table_copy_types(entry, sys_fields);
472
445
/* 0: INDEX_ID -----------------------*/
473
dfield = dtuple_get_nth_field(entry, 0/*INDEX_ID*/);
446
dfield = dtuple_get_nth_field(entry, 0);
475
448
ptr = mem_heap_alloc(heap, 8);
476
449
mach_write_to_8(ptr, index->id);
653
627
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
655
zip_size = dict_table_zip_size(index->table);
657
node->page_no = btr_create(index->type, index->space, zip_size,
629
node->page_no = btr_create(index->type, index->space,
630
dict_table_zip_size(index->table),
658
631
index->id, index, &mtr);
659
632
/* printf("Created a new index tree in space %lu root page %lu\n",
660
633
index->space, index->page_no); */
852
825
for (index = UT_LIST_GET_FIRST(table->indexes);
854
827
index = UT_LIST_GET_NEXT(indexes, index)) {
855
if (index->id == index_id) {
828
if (!ut_dulint_cmp(index->id, index_id)) {
856
829
root_page_no = btr_create(type, space, zip_size,
857
830
index_id, index, mtr);
858
831
index->page = (unsigned int) root_page_no;
1117
1091
if (node->state == INDEX_ADD_TO_CACHE) {
1119
index_id_t index_id = node->index->id;
1093
dulint index_id = node->index->id;
1121
err = dict_index_add_to_cache(
1122
node->table, node->index, FIL_NULL,
1124
|| dict_table_get_format(node->table)
1125
>= DICT_TF_FORMAT_ZIP);
1095
err = dict_index_add_to_cache(node->table, node->index,
1127
1098
node->index = dict_index_get_if_in_cache_low(index_id);
1128
1099
ut_a(!node->index == (err != DB_SUCCESS));