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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 8));
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
91
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
89
ptr = mem_heap_alloc(heap, 4);
92
90
mach_write_to_4(ptr, table->n_def
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
99
if (table->flags & (~DICT_TF_COMPACT & ~(~0 << DICT_TF_BITS))) {
96
ptr = mem_heap_alloc(heap, 4);
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
ptr = static_cast<unsigned char *>(mem_heap_zalloc(heap, 8));
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 = static_cast<unsigned char *>(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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
129
ptr = mem_heap_alloc(heap, 4);
133
130
mach_write_to_4(ptr, table->space);
135
132
dfield_set_data(dfield, ptr, 4);
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 8));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
211
ptr = mem_heap_alloc(heap, 4);
217
212
mach_write_to_4(ptr, 0/* unused */);
219
214
dfield_set_data(dfield, ptr, 4);
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,
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 8));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 8));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
374
ptr = mem_heap_alloc(heap, 4);
400
375
mach_write_to_4(ptr, index->type);
402
377
dfield_set_data(dfield, ptr, 4);
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
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 8));
448
ptr = mem_heap_alloc(heap, 8);
476
449
mach_write_to_8(ptr, index->id);
478
451
dfield_set_data(dfield, ptr, 8);
479
452
/* 1: POS + PREFIX LENGTH ----------------------------*/
481
dfield = dtuple_get_nth_field(entry, 1/*POS*/);
454
dfield = dtuple_get_nth_field(entry, 1);
483
ptr = static_cast<unsigned char *>(mem_heap_alloc(heap, 4));
456
ptr = mem_heap_alloc(heap, 4);
485
458
if (index_contains_column_prefix_field) {
486
459
/* If there are column prefix fields in the index, then