52
52
dict_create_sys_tables_tuple(
53
53
/*=========================*/
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 */
54
const dict_table_t* table, /*!< in: table */
55
mem_heap_t* heap) /*!< in: memory heap from
56
which the memory for the built
58
59
dict_table_t* sys_tables;
65
67
sys_tables = dict_sys->sys_tables;
69
71
dict_table_copy_types(entry, sys_tables);
71
73
/* 0: NAME -----------------------------*/
72
dfield = dtuple_get_nth_field(entry, 0);
74
dfield = dtuple_get_nth_field(entry, 0/*NAME*/);
74
76
dfield_set_data(dfield, table->name, ut_strlen(table->name));
75
77
/* 3: ID -------------------------------*/
76
dfield = dtuple_get_nth_field(entry, 1);
78
dfield = dtuple_get_nth_field(entry, 1/*ID*/);
78
80
ptr = mem_heap_alloc(heap, 8);
79
81
mach_write_to_8(ptr, table->id);
81
83
dfield_set_data(dfield, ptr, 8);
82
84
/* 4: N_COLS ---------------------------*/
83
dfield = dtuple_get_nth_field(entry, 2);
85
dfield = dtuple_get_nth_field(entry, 2/*N_COLS*/);
85
87
#if DICT_TF_COMPACT != 1
91
93
| ((table->flags & DICT_TF_COMPACT) << 31));
92
94
dfield_set_data(dfield, ptr, 4);
93
95
/* 5: TYPE -----------------------------*/
94
dfield = dtuple_get_nth_field(entry, 3);
96
dfield = dtuple_get_nth_field(entry, 3/*TYPE*/);
96
98
ptr = mem_heap_alloc(heap, 4);
97
99
if (table->flags & (~DICT_TF_COMPACT & ~(~0 << DICT_TF_BITS))) {
108
110
dfield_set_data(dfield, ptr, 4);
109
111
/* 6: MIX_ID (obsolete) ---------------------------*/
110
dfield = dtuple_get_nth_field(entry, 4);
112
dfield = dtuple_get_nth_field(entry, 4/*MIX_ID*/);
112
114
ptr = mem_heap_zalloc(heap, 8);
114
116
dfield_set_data(dfield, ptr, 8);
115
117
/* 7: MIX_LEN (additional flags) --------------------------*/
117
dfield = dtuple_get_nth_field(entry, 5);
119
dfield = dtuple_get_nth_field(entry, 5/*MIX_LEN*/);
119
121
ptr = mem_heap_alloc(heap, 4);
120
122
mach_write_to_4(ptr, table->flags >> DICT_TF2_SHIFT);
122
124
dfield_set_data(dfield, ptr, 4);
123
125
/* 8: CLUSTER_NAME ---------------------*/
124
dfield = dtuple_get_nth_field(entry, 6);
126
dfield = dtuple_get_nth_field(entry, 6/*CLUSTER_NAME*/);
125
127
dfield_set_null(dfield); /* not supported */
127
129
/* 9: SPACE ----------------------------*/
128
dfield = dtuple_get_nth_field(entry, 7);
130
dfield = dtuple_get_nth_field(entry, 7/*SPACE*/);
130
132
ptr = mem_heap_alloc(heap, 4);
131
133
mach_write_to_4(ptr, table->space);
145
147
dict_create_sys_columns_tuple(
146
148
/*==========================*/
147
dict_table_t* table, /*!< in: table */
148
ulint i, /*!< in: column number */
149
mem_heap_t* heap) /*!< in: memory heap from which the memory for
150
the built tuple is allocated */
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 */
152
155
dict_table_t* sys_columns;
154
157
const dict_col_t* column;
155
158
dfield_t* dfield;
157
const char* col_name;
160
const char* col_name;
159
ut_ad(table && heap);
161
165
column = dict_table_get_nth_col(table, i);
167
171
dict_table_copy_types(entry, sys_columns);
169
173
/* 0: TABLE_ID -----------------------*/
170
dfield = dtuple_get_nth_field(entry, 0);
174
dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
172
176
ptr = mem_heap_alloc(heap, 8);
173
177
mach_write_to_8(ptr, table->id);
175
179
dfield_set_data(dfield, ptr, 8);
176
180
/* 1: POS ----------------------------*/
177
dfield = dtuple_get_nth_field(entry, 1);
181
dfield = dtuple_get_nth_field(entry, 1/*POS*/);
179
183
ptr = mem_heap_alloc(heap, 4);
180
184
mach_write_to_4(ptr, i);
182
186
dfield_set_data(dfield, ptr, 4);
183
187
/* 4: NAME ---------------------------*/
184
dfield = dtuple_get_nth_field(entry, 2);
188
dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
186
190
col_name = dict_table_get_col_name(table, i);
187
191
dfield_set_data(dfield, col_name, ut_strlen(col_name));
188
192
/* 5: MTYPE --------------------------*/
189
dfield = dtuple_get_nth_field(entry, 3);
193
dfield = dtuple_get_nth_field(entry, 3/*MTYPE*/);
191
195
ptr = mem_heap_alloc(heap, 4);
192
196
mach_write_to_4(ptr, column->mtype);
194
198
dfield_set_data(dfield, ptr, 4);
195
199
/* 6: PRTYPE -------------------------*/
196
dfield = dtuple_get_nth_field(entry, 4);
200
dfield = dtuple_get_nth_field(entry, 4/*PRTYPE*/);
198
202
ptr = mem_heap_alloc(heap, 4);
199
203
mach_write_to_4(ptr, column->prtype);
201
205
dfield_set_data(dfield, ptr, 4);
202
206
/* 7: LEN ----------------------------*/
203
dfield = dtuple_get_nth_field(entry, 5);
207
dfield = dtuple_get_nth_field(entry, 5/*LEN*/);
205
209
ptr = mem_heap_alloc(heap, 4);
206
210
mach_write_to_4(ptr, column->len);
208
212
dfield_set_data(dfield, ptr, 4);
209
213
/* 8: PREC ---------------------------*/
210
dfield = dtuple_get_nth_field(entry, 6);
214
dfield = dtuple_get_nth_field(entry, 6/*PREC*/);
212
216
ptr = mem_heap_alloc(heap, 4);
213
217
mach_write_to_4(ptr, 0/* unused */);
235
239
const char* path_or_name;
239
244
ut_ad(mutex_own(&(dict_sys->mutex)));
241
246
table = node->table;
243
table->id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
248
dict_hdr_get_new_id(&table->id, NULL,
249
srv_file_per_table ? &space : NULL);
245
251
thr_get_trx(thr)->table_id = table->id;
247
253
if (srv_file_per_table) {
254
if (UNIV_UNLIKELY(space == ULINT_UNDEFINED)) {
248
258
/* We create a new single-table tablespace for the table.
249
259
We initially let it be 4 pages:
250
260
- page 0 is the fsp header and an extent descriptor page,
273
281
flags = table->flags & ~(~0 << DICT_TF_BITS);
274
282
error = fil_create_new_single_table_tablespace(
275
&space, path_or_name, is_path,
283
space, path_or_name, is_path,
276
284
flags == DICT_TF_COMPACT ? 0 : flags,
277
285
FIL_IBD_FILE_INITIAL_SIZE);
278
286
table->space = (unsigned int) space;
326
334
dict_create_sys_indexes_tuple(
327
335
/*==========================*/
328
dict_index_t* index, /*!< in: index */
329
mem_heap_t* heap) /*!< in: memory heap from which the memory for
330
the built tuple is allocated */
336
const dict_index_t* index, /*!< in: index */
337
mem_heap_t* heap) /*!< in: memory heap from
338
which the memory for the built
339
tuple is allocated */
332
341
dict_table_t* sys_indexes;
333
342
dict_table_t* table;
347
357
dict_table_copy_types(entry, sys_indexes);
349
359
/* 0: TABLE_ID -----------------------*/
350
dfield = dtuple_get_nth_field(entry, 0);
360
dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
352
362
ptr = mem_heap_alloc(heap, 8);
353
363
mach_write_to_8(ptr, table->id);
355
365
dfield_set_data(dfield, ptr, 8);
356
366
/* 1: ID ----------------------------*/
357
dfield = dtuple_get_nth_field(entry, 1);
367
dfield = dtuple_get_nth_field(entry, 1/*ID*/);
359
369
ptr = mem_heap_alloc(heap, 8);
360
370
mach_write_to_8(ptr, index->id);
362
372
dfield_set_data(dfield, ptr, 8);
363
373
/* 4: NAME --------------------------*/
364
dfield = dtuple_get_nth_field(entry, 2);
374
dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
366
376
dfield_set_data(dfield, index->name, ut_strlen(index->name));
367
377
/* 5: N_FIELDS ----------------------*/
368
dfield = dtuple_get_nth_field(entry, 3);
378
dfield = dtuple_get_nth_field(entry, 3/*N_FIELDS*/);
370
380
ptr = mem_heap_alloc(heap, 4);
371
381
mach_write_to_4(ptr, index->n_fields);
373
383
dfield_set_data(dfield, ptr, 4);
374
384
/* 6: TYPE --------------------------*/
375
dfield = dtuple_get_nth_field(entry, 4);
385
dfield = dtuple_get_nth_field(entry, 4/*TYPE*/);
377
387
ptr = mem_heap_alloc(heap, 4);
378
388
mach_write_to_4(ptr, index->type);
416
426
dict_create_sys_fields_tuple(
417
427
/*=========================*/
418
dict_index_t* index, /*!< in: index */
419
ulint i, /*!< in: field number */
420
mem_heap_t* heap) /*!< in: memory heap from which the memory for
421
the built tuple is allocated */
428
const dict_index_t* index, /*!< in: index */
429
ulint i, /*!< in: field number */
430
mem_heap_t* heap) /*!< in: memory heap from
431
which the memory for the built
432
tuple is allocated */
423
434
dict_table_t* sys_fields;
446
458
dict_table_copy_types(entry, sys_fields);
448
460
/* 0: INDEX_ID -----------------------*/
449
dfield = dtuple_get_nth_field(entry, 0);
461
dfield = dtuple_get_nth_field(entry, 0/*INDEX_ID*/);
451
463
ptr = mem_heap_alloc(heap, 8);
452
464
mach_write_to_8(ptr, index->id);
630
643
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
632
node->page_no = btr_create(index->type, index->space,
633
dict_table_zip_size(index->table),
645
zip_size = dict_table_zip_size(index->table);
647
node->page_no = btr_create(index->type, index->space, zip_size,
634
648
index->id, index, &mtr);
635
649
/* printf("Created a new index tree in space %lu root page %lu\n",
636
650
index->space, index->page_no); */
1096
1110
dulint index_id = node->index->id;
1098
err = dict_index_add_to_cache(node->table, node->index,
1112
err = dict_index_add_to_cache(
1113
node->table, node->index, FIL_NULL,
1115
|| dict_table_get_format(node->table)
1116
>= DICT_TF_FORMAT_ZIP);
1101
1118
node->index = dict_index_get_if_in_cache_low(index_id);
1102
1119
ut_a(!node->index == (err != DB_SUCCESS));