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
if (table->flags & ~DICT_TF_COMPACT) {
99
if (table->flags & (~DICT_TF_COMPACT & ~(~0 << DICT_TF_BITS))) {
98
100
ut_a(table->flags & DICT_TF_COMPACT);
99
101
ut_a(dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP);
100
102
ut_a((table->flags & DICT_TF_ZSSIZE_MASK)
101
103
<= (DICT_TF_ZSSIZE_MAX << DICT_TF_ZSSIZE_SHIFT));
102
ut_a(!(table->flags & (~0 << DICT_TF_BITS)));
103
mach_write_to_4(ptr, table->flags);
104
ut_a(!(table->flags & (~0 << DICT_TF2_BITS)));
105
mach_write_to_4(ptr, table->flags & ~(~0 << DICT_TF_BITS));
105
107
mach_write_to_4(ptr, DICT_TABLE_ORDINARY);
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
/* 7: MIX_LEN (obsolete) --------------------------*/
117
dfield = dtuple_get_nth_field(entry, 5);
119
ptr = mem_heap_zalloc(heap, 4);
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);
121
124
dfield_set_data(dfield, ptr, 4);
122
125
/* 8: CLUSTER_NAME ---------------------*/
123
dfield = dtuple_get_nth_field(entry, 6);
126
dfield = dtuple_get_nth_field(entry, 6/*CLUSTER_NAME*/);
124
127
dfield_set_null(dfield); /* not supported */
126
129
/* 9: SPACE ----------------------------*/
127
dfield = dtuple_get_nth_field(entry, 7);
130
dfield = dtuple_get_nth_field(entry, 7/*SPACE*/);
129
132
ptr = mem_heap_alloc(heap, 4);
130
133
mach_write_to_4(ptr, table->space);
144
147
dict_create_sys_columns_tuple(
145
148
/*==========================*/
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 */
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 */
151
155
dict_table_t* sys_columns;
153
157
const dict_col_t* column;
154
158
dfield_t* dfield;
156
const char* col_name;
160
const char* col_name;
158
ut_ad(table && heap);
160
165
column = dict_table_get_nth_col(table, i);
166
171
dict_table_copy_types(entry, sys_columns);
168
173
/* 0: TABLE_ID -----------------------*/
169
dfield = dtuple_get_nth_field(entry, 0);
174
dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
171
176
ptr = mem_heap_alloc(heap, 8);
172
177
mach_write_to_8(ptr, table->id);
174
179
dfield_set_data(dfield, ptr, 8);
175
180
/* 1: POS ----------------------------*/
176
dfield = dtuple_get_nth_field(entry, 1);
181
dfield = dtuple_get_nth_field(entry, 1/*POS*/);
178
183
ptr = mem_heap_alloc(heap, 4);
179
184
mach_write_to_4(ptr, i);
181
186
dfield_set_data(dfield, ptr, 4);
182
187
/* 4: NAME ---------------------------*/
183
dfield = dtuple_get_nth_field(entry, 2);
188
dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
185
190
col_name = dict_table_get_col_name(table, i);
186
191
dfield_set_data(dfield, col_name, ut_strlen(col_name));
187
192
/* 5: MTYPE --------------------------*/
188
dfield = dtuple_get_nth_field(entry, 3);
193
dfield = dtuple_get_nth_field(entry, 3/*MTYPE*/);
190
195
ptr = mem_heap_alloc(heap, 4);
191
196
mach_write_to_4(ptr, column->mtype);
193
198
dfield_set_data(dfield, ptr, 4);
194
199
/* 6: PRTYPE -------------------------*/
195
dfield = dtuple_get_nth_field(entry, 4);
200
dfield = dtuple_get_nth_field(entry, 4/*PRTYPE*/);
197
202
ptr = mem_heap_alloc(heap, 4);
198
203
mach_write_to_4(ptr, column->prtype);
200
205
dfield_set_data(dfield, ptr, 4);
201
206
/* 7: LEN ----------------------------*/
202
dfield = dtuple_get_nth_field(entry, 5);
207
dfield = dtuple_get_nth_field(entry, 5/*LEN*/);
204
209
ptr = mem_heap_alloc(heap, 4);
205
210
mach_write_to_4(ptr, column->len);
207
212
dfield_set_data(dfield, ptr, 4);
208
213
/* 8: PREC ---------------------------*/
209
dfield = dtuple_get_nth_field(entry, 6);
214
dfield = dtuple_get_nth_field(entry, 6/*PREC*/);
211
216
ptr = mem_heap_alloc(heap, 4);
212
217
mach_write_to_4(ptr, 0/* unused */);
230
235
dict_table_t* table;
233
239
const char* path_or_name;
243
ibool file_per_table;
237
245
ut_ad(mutex_own(&(dict_sys->mutex)));
239
247
table = node->table;
241
table->id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
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);
243
260
thr_get_trx(thr)->table_id = table->id;
245
if (srv_file_per_table) {
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)) {
246
270
/* We create a new single-table tablespace for the table.
247
271
We initially let it be 4 pages:
248
272
- page 0 is the fsp header and an extent descriptor page,
268
290
ut_ad(!dict_table_zip_size(table)
269
291
|| dict_table_get_format(table) >= DICT_TF_FORMAT_ZIP);
293
flags = table->flags & ~(~0 << DICT_TF_BITS);
271
294
error = fil_create_new_single_table_tablespace(
272
&space, path_or_name, is_path,
273
table->flags == DICT_TF_COMPACT ? 0 : table->flags,
295
space, path_or_name, is_path,
296
flags == DICT_TF_COMPACT ? 0 : flags,
274
297
FIL_IBD_FILE_INITIAL_SIZE);
275
298
table->space = (unsigned int) space;
323
346
dict_create_sys_indexes_tuple(
324
347
/*==========================*/
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 */
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 */
329
353
dict_table_t* sys_indexes;
330
354
dict_table_t* table;
344
369
dict_table_copy_types(entry, sys_indexes);
346
371
/* 0: TABLE_ID -----------------------*/
347
dfield = dtuple_get_nth_field(entry, 0);
372
dfield = dtuple_get_nth_field(entry, 0/*TABLE_ID*/);
349
374
ptr = mem_heap_alloc(heap, 8);
350
375
mach_write_to_8(ptr, table->id);
352
377
dfield_set_data(dfield, ptr, 8);
353
378
/* 1: ID ----------------------------*/
354
dfield = dtuple_get_nth_field(entry, 1);
379
dfield = dtuple_get_nth_field(entry, 1/*ID*/);
356
381
ptr = mem_heap_alloc(heap, 8);
357
382
mach_write_to_8(ptr, index->id);
359
384
dfield_set_data(dfield, ptr, 8);
360
385
/* 4: NAME --------------------------*/
361
dfield = dtuple_get_nth_field(entry, 2);
386
dfield = dtuple_get_nth_field(entry, 2/*NAME*/);
363
388
dfield_set_data(dfield, index->name, ut_strlen(index->name));
364
389
/* 5: N_FIELDS ----------------------*/
365
dfield = dtuple_get_nth_field(entry, 3);
390
dfield = dtuple_get_nth_field(entry, 3/*N_FIELDS*/);
367
392
ptr = mem_heap_alloc(heap, 4);
368
393
mach_write_to_4(ptr, index->n_fields);
370
395
dfield_set_data(dfield, ptr, 4);
371
396
/* 6: TYPE --------------------------*/
372
dfield = dtuple_get_nth_field(entry, 4);
397
dfield = dtuple_get_nth_field(entry, 4/*TYPE*/);
374
399
ptr = mem_heap_alloc(heap, 4);
375
400
mach_write_to_4(ptr, index->type);
413
438
dict_create_sys_fields_tuple(
414
439
/*=========================*/
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 */
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 */
420
446
dict_table_t* sys_fields;
443
470
dict_table_copy_types(entry, sys_fields);
445
472
/* 0: INDEX_ID -----------------------*/
446
dfield = dtuple_get_nth_field(entry, 0);
473
dfield = dtuple_get_nth_field(entry, 0/*INDEX_ID*/);
448
475
ptr = mem_heap_alloc(heap, 8);
449
476
mach_write_to_8(ptr, index->id);
627
653
btr_pcur_move_to_next_user_rec(&pcur, &mtr);
629
node->page_no = btr_create(index->type, index->space,
630
dict_table_zip_size(index->table),
655
zip_size = dict_table_zip_size(index->table);
657
node->page_no = btr_create(index->type, index->space, zip_size,
631
658
index->id, index, &mtr);
632
659
/* printf("Created a new index tree in space %lu root page %lu\n",
633
660
index->space, index->page_no); */
801
828
appropriate field in the SYS_INDEXES record: this mini-transaction
802
829
marks the B-tree totally truncated */
804
btr_page_get(space, zip_size, root_page_no, RW_X_LATCH, mtr);
831
btr_block_get(space, zip_size, root_page_no, RW_X_LATCH, NULL, mtr);
806
833
btr_free_root(space, zip_size, root_page_no, mtr);
1093
1120
dulint index_id = node->index->id;
1095
err = dict_index_add_to_cache(node->table, node->index,
1122
err = dict_index_add_to_cache(
1123
node->table, node->index, FIL_NULL,
1125
|| dict_table_get_format(node->table)
1126
>= DICT_TF_FORMAT_ZIP);
1098
1128
node->index = dict_index_get_if_in_cache_low(index_id);
1099
1129
ut_a(!node->index == (err != DB_SUCCESS));