30 #include "dict0mem.ic"
38 #ifndef UNIV_HOTBACKUP
41 # include "mysql_com.h"
44 #ifdef UNIV_BLOB_DEBUG
48 #define DICT_HEAP_SIZE 100
53 UNIV_INTERN mysql_pfs_key_t autoinc_mutex_key;
75 ut_a(!(flags2 & ~DICT_TF2_BIT_MASK));
84 table->
flags = (
unsigned int) flags;
85 table->
flags2 = (
unsigned int) flags2;
86 table->
name =
static_cast<char*
>(
ut_malloc(strlen(name) + 1));
87 memcpy(table->
name, name, strlen(name) + 1);
88 table->
space = (
unsigned int) space;
89 table->
n_cols = (
unsigned int) (n_cols + DATA_N_SYS_COLS);
93 (n_cols + DATA_N_SYS_COLS)
96 ut_d(table->magic_n = DICT_TABLE_MAGIC_N);
98 #ifndef UNIV_HOTBACKUP
102 mutex_create(autoinc_mutex_key,
135 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
147 #ifndef UNIV_HOTBACKUP
161 const char* col_names,
172 ut_ad(!cols == !col_names);
176 const char* s = col_names;
179 for (i = 0; i < cols; i++) {
183 old_len = s - col_names;
188 new_len = strlen(name) + 1;
189 total_len = old_len + new_len;
194 memcpy(res, col_names, old_len);
197 memcpy(res + old_len, name, new_len);
219 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
220 ut_ad(!heap == !name);
225 if (UNIV_UNLIKELY(table->
n_def == table->
n_cols)) {
228 if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->
col_names)) {
230 char* s =
static_cast<char*
>(
240 col = dict_table_get_nth_col(table, i);
247 static __attribute__((nonnull))
249 dict_mem_table_col_rename_low(
256 size_t from_len = strlen(s), to_len = strlen(to);
258 ut_ad(i < table->n_def);
259 ut_ad(from_len <= NAME_LEN);
260 ut_ad(to_len <= NAME_LEN);
262 if (from_len == to_len) {
265 strcpy(const_cast<char*>(s), to);
270 ulint prefix_len = s - table->col_names;
272 for (; i < table->n_def; i++) {
276 ulint full_len = s - table->col_names;
279 if (to_len > from_len) {
280 col_names =
static_cast<char*
>(
283 full_len + to_len - from_len));
285 memcpy(col_names, table->col_names, prefix_len);
287 col_names =
const_cast<char*
>(table->col_names);
290 memcpy(col_names + prefix_len, to, to_len);
291 memmove(col_names + prefix_len + to_len,
292 table->col_names + (prefix_len + from_len),
293 full_len - (prefix_len + from_len));
301 for (ulint i = 0; i < n_fields; i++) {
303 = dict_index_get_nth_field(
306 = field->
name - table->col_names;
307 if (name_ofs <= prefix_len) {
308 field->
name = col_names + name_ofs;
310 ut_a(name_ofs < full_len);
311 field->
name = col_names
312 + name_ofs + to_len - from_len;
317 table->col_names = col_names;
324 for (
unsigned f = 0; f < foreign->n_fields; f++) {
329 foreign->foreign_col_names[f]
330 = dict_index_get_nth_field(
331 foreign->foreign_index, f)->name;
336 table->referenced_list);
339 for (
unsigned f = 0; f < foreign->n_fields; f++) {
345 const char* col_name = dict_index_get_nth_field(
346 foreign->referenced_index, f)->name;
348 if (strcmp(foreign->referenced_col_names[f],
350 char** rc =
const_cast<char**
>(
351 foreign->referenced_col_names + f);
352 size_t col_name_len_1 = strlen(col_name) + 1;
354 if (col_name_len_1 <= strlen(*rc) + 1) {
355 memcpy(*rc, col_name, col_name_len_1);
357 *rc =
static_cast<char*
>(
381 ut_ad(nth_col < table->n_def);
383 for (
unsigned i = 0; i < nth_col; i++) {
384 size_t len = strlen(s);
391 ut_ad(!strcmp(from, s));
393 dict_mem_table_col_rename_low(table, nth_col, to, s);
410 #ifndef UNIV_HOTBACKUP
415 column->
ind = (
unsigned int) col_pos;
418 column->
mtype = (
unsigned int) mtype;
419 column->
prtype = (
unsigned int) prtype;
420 column->
len = (
unsigned int) col_len;
421 #ifndef UNIV_HOTBACKUP
435 const char* index_name,
446 ut_ad(table_name && index_name);
454 space, type, n_fields);
456 os_fast_mutex_init(zip_pad_mutex_key, &index->
zip_pad.
mutex);
461 #ifndef UNIV_HOTBACKUP
563 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
567 field = dict_index_get_nth_field(index, index->
n_def - 1);
570 field->
prefix_len = (
unsigned int) prefix_len;
582 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
583 #ifdef UNIV_BLOB_DEBUG
585 mutex_free(&index->blobs_mutex);
600 dict_mem_create_temporary_tablename(
606 const char* dbend = strchr(dbtab,
'/');
608 size_t dblen = dbend - dbtab + 1;
609 size_t size = tmp_file_prefix_length + 4 + 9 + 9 + dblen;
612 memcpy(name, dbtab, dblen);