32 #include "dict0dict.ic"
33 #include "dict0priv.ic"
41 #ifndef UNIV_HOTBACKUP
101 #ifdef UNIV_PFS_RWLOCK
102 UNIV_INTERN mysql_pfs_key_t dict_operation_lock_key;
103 UNIV_INTERN mysql_pfs_key_t index_tree_rw_lock_key;
104 UNIV_INTERN mysql_pfs_key_t index_online_log_key;
105 UNIV_INTERN mysql_pfs_key_t dict_table_stats_latch_key;
108 #ifdef UNIV_PFS_MUTEX
109 UNIV_INTERN mysql_pfs_key_t zip_pad_mutex_key;
110 UNIV_INTERN mysql_pfs_key_t dict_sys_mutex_key;
111 UNIV_INTERN mysql_pfs_key_t dict_foreign_err_mutex_key;
114 #define DICT_HEAP_SIZE 100
116 #define DICT_POOL_PER_TABLE_HASH 512
118 #define DICT_POOL_PER_VARYING 4
122 static char dict_ibfk[] = "_ibfk_";
134 #define DICT_TABLE_STATS_LATCHES_SIZE 64
143 dict_index_find_cols(
153 dict_index_build_internal_clust(
164 dict_index_build_internal_non_clust(
174 dict_index_build_internal_fts(
190 dict_index_print_low(
197 dict_field_print_low(
205 dict_index_remove_from_cache_low(
215 dict_table_remove_from_cache_low(
225 dict_lru_validate(
void);
240 dict_non_lru_find_table(
247 UNIV_INTERN FILE* dict_foreign_err_file = NULL;
249 UNIV_INTERN
ib_mutex_t dict_foreign_err_mutex;
274 for (; *name1 == *name2; name1++, name2++) {
293 const char* s = strchr(name,
'/');
310 s = strchr(name,
'/');
336 #define GET_TABLE_STATS_LATCH(table) \
337 (&dict_table_stats_latches[ut_fold_ull((ib_uint64_t) table) \
338 % DICT_TABLE_STATS_LATCHES_SIZE])
352 ut_ad(table != NULL);
353 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
355 switch (latch_mode) {
379 ut_ad(table != NULL);
380 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
382 switch (latch_mode) {
401 dict_table_try_drop_aborted(
411 trx->
op_info =
"try to drop any indexes after an aborted index creation";
412 row_mysql_lock_data_dictionary(trx);
441 dict_table_try_drop_aborted_and_mutex_exit(
452 && dict_table_get_first_index(table)) {
456 table_id_t table_id = table->
id;
460 dict_table_try_drop_aborted(table, table_id, 1);
492 if (strchr(table->
name,
'/') != NULL
499 MONITOR_DEC(MONITOR_TABLE_REFERENCE);
501 ut_ad(dict_lru_validate());
505 ut_ad(dict_lru_find_table(table));
507 ut_ad(dict_non_lru_find_table(table));
512 table_id_t table_id = table->
id;
515 drop_aborted = try_drop
518 && dict_table_get_first_index(table);
523 dict_table_try_drop_aborted(NULL, table_id, 0);
544 ut_ad(col_nr < table->n_def);
545 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
549 for (i = 0; i < col_nr; i++) {
557 #ifndef UNIV_HOTBACKUP
596 ut_a(ib_vector_size(indexes) == 0);
598 for (index = dict_table_get_first_index(table);
600 index = dict_table_get_next_index(index)) {
602 if (index->
type == DICT_FTS) {
603 ib_vector_push(indexes, &index);
607 return(ib_vector_size(indexes));
675 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
677 col = dict_table_get_nth_col(index->
table, n);
686 for (pos = 0; pos < n_fields; pos++) {
687 field = dict_index_get_nth_field(index, pos);
689 if (col == field->
col
696 return(ULINT_UNDEFINED);
699 #ifndef UNIV_HOTBACKUP
716 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
723 col = dict_table_get_nth_col(index->
table, n);
727 for (pos = 0; pos < n_fields; pos++) {
728 field = dict_index_get_nth_field(index, pos);
730 if (col == field->
col) {
760 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
762 field2 = dict_index_get_nth_field(index2, n);
766 for (pos = 0; pos < n_fields; pos++) {
767 field = dict_index_get_nth_field(index, pos);
769 if (field->
col == field2->
col
778 return(ULINT_UNDEFINED);
818 dict_table_try_drop_aborted_and_mutex_exit(
858 col = dict_table_get_nth_col(table, n);
860 index = dict_table_get_first_index(table);
864 for (pos = 0; pos < n_fields; pos++) {
865 field = dict_index_get_nth_field(index, pos);
867 if (col == field->
col) {
887 mutex_create(dict_sys_mutex_key, &
dict_sys->
mutex, SYNC_DICT);
900 ut_a(dict_foreign_err_file);
902 mutex_create(dict_foreign_err_mutex_key,
903 &dict_foreign_err_mutex, SYNC_NO_ORDER_CHECK);
908 &dict_table_stats_latches[i], SYNC_INDEX_TREE);
921 ut_ad(dict_lru_validate());
922 ut_ad(dict_lru_find_table(table));
930 ut_ad(dict_lru_validate());
986 fprintf(stderr,
" InnoDB: table ");
988 fprintf(stderr,
"is corrupted. Please drop the table "
1003 ut_ad(dict_lru_validate());
1006 dict_table_try_drop_aborted_and_mutex_exit(table, try_drop);
1024 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
1034 DATA_ROW_ID | DATA_NOT_NULL,
1036 #if DATA_ROW_ID != 0
1037 #error "DATA_ROW_ID != 0"
1040 DATA_TRX_ID | DATA_NOT_NULL,
1042 #if DATA_TRX_ID != 1
1043 #error "DATA_TRX_ID != 1"
1046 DATA_ROLL_PTR | DATA_NOT_NULL,
1048 #if DATA_ROLL_PTR != 2
1049 #error "DATA_ROLL_PTR != 2"
1054 #if DATA_N_SYS_COLS != 3
1055 #error "DATA_N_SYS_COLS != 3"
1059 #ifndef UNIV_HOTBACKUP
1067 ibool can_be_evicted,
1075 ut_ad(dict_lru_validate());
1078 #define BIG_ROW_SIZE 1024
1086 fold = ut_fold_string(table->
name);
1090 for (i = 0; i < table->
n_def; i++) {
1092 dict_table_get_nth_col(table, i));
1098 if (row_len >= BIG_ROW_SIZE || col_len >= BIG_ROW_SIZE) {
1099 row_len = BIG_ROW_SIZE;
1105 table->
big_rows = row_len >= BIG_ROW_SIZE;
1113 ut_a(table2 == NULL);
1120 ut_ad(table2 == NULL);
1129 table2->
id == table->
id);
1130 ut_a(table2 == NULL);
1137 ut_ad(table2 == NULL);
1157 ut_ad(dict_lru_validate());
1160 + strlen(table->
name) + 1;
1168 dict_table_can_be_evicted(
1173 #ifdef UNIV_SYNC_DEBUG
1193 for (index = dict_table_get_first_index(table);
1195 index = dict_table_get_next_index(index)) {
1239 ulint n_evicted = 0;
1241 ut_a(pct_check > 0);
1242 ut_a(pct_check <= 100);
1244 #ifdef UNIV_SYNC_DEBUG
1247 ut_ad(dict_lru_validate());
1251 if (len < max_tables) {
1255 check_up_to = len - ((len * pct_check) / 100);
1258 ut_a(i == 0 || check_up_to <= i);
1266 && (len - n_evicted) > max_tables;
1273 if (dict_table_can_be_evicted(table)) {
1275 dict_table_remove_from_cache_low(table, TRUE);
1295 ut_ad(dict_lru_find_table(table));
1315 ut_ad(dict_non_lru_find_table(table));
1331 dict_table_find_index_on_id(
1338 for (index = dict_table_get_first_index(table);
1340 index = dict_table_get_next_index(index)) {
1342 if (
id == index->
id) {
1374 dict_index_t* index = dict_table_find_index_on_id(table,
id);
1376 if (index != NULL) {
1385 dict_index_t* index = dict_table_find_index_on_id(table,
id);
1387 if (index != NULL) {
1403 const char* new_name,
1404 ibool rename_also_foreigns)
1411 char old_name[MAX_FULL_NAME_LEN + 1];
1416 if (strlen(table->
name) + 1 <=
sizeof(old_name)) {
1417 memcpy(old_name, table->
name, strlen(table->
name) + 1);
1420 fprintf(stderr,
"InnoDB: too long table name: '%s', "
1421 "max length is %d\n", table->
name,
1426 fold = ut_fold_string(new_name);
1433 DBUG_EXECUTE_IF(
"dict_table_rename_in_cache_failure",
1434 if (table2 == NULL) {
1439 "Cannot rename table '%s' to '%s' since the "
1440 "dictionary cache already contains '%s'.",
1441 old_name, new_name, new_name);
1449 os_file_type_t
type;
1471 && !os_file_delete_if_exists(innodb_file_temp_key,
1475 "Delete of %s failed.", filepath);
1480 }
else if (table->
space != TRX_SYS_SPACE) {
1481 char* new_path = NULL;
1485 fputs(
" InnoDB: Error: trying to rename a"
1486 " TEMPORARY TABLE ", stderr);
1488 fputs(
" (", stderr);
1491 fputs(
" )\n", stderr);
1500 old_path, new_name);
1505 new_name, new_path);
1507 if (err != DB_SUCCESS) {
1514 old_name, table->
space, new_name, new_path);
1531 ut_fold_string(old_name), table);
1533 if (strlen(new_name) > strlen(table->
name)) {
1537 ut_a(strlen(new_name) <= MAX_FULL_NAME_LEN);
1539 table->
name =
static_cast<char*
>(
1542 memcpy(table->
name, new_name, strlen(new_name) + 1);
1552 for (index = dict_table_get_first_index(table);
1554 index = dict_table_get_next_index(index)) {
1559 if (!rename_also_foreigns) {
1571 while (foreign != NULL) {
1580 while (foreign != NULL) {
1600 while (foreign != NULL) {
1613 if (strchr(foreign->
id,
'/')) {
1629 ibool on_tmp = FALSE;
1634 strncpy(old_name_cs_filename, old_name,
1636 if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) {
1638 innobase_convert_to_system_charset(
1639 strchr(old_name_cs_filename,
'/') + 1,
1640 strchr(old_name,
'/') + 1,
1648 innobase_convert_to_filename_charset(
1649 strchr(old_name_cs_filename,
1651 strchr(old_name,
'/') + 1,
1656 strncpy(old_name_cs_filename, old_name,
1663 if (strstr(fkid, TEMP_TABLE_PATH_PREFIX) == NULL) {
1664 innobase_convert_to_filename_charset(
1665 strchr(fkid,
'/') + 1,
1666 strchr(foreign->
id,
'/') + 1,
1675 + ((
sizeof dict_ibfk) - 1)
1676 && !memcmp(fkid, old_name_cs_filename,
1678 && !memcmp(fkid +
ut_strlen(old_name_cs_filename),
1679 dict_ibfk, (
sizeof dict_ibfk) - 1)) {
1686 if (strlen(table->
name) > strlen(old_name)) {
1687 foreign->
id =
static_cast<char*
>(
1691 + strlen(old_id) + 1));
1695 strncpy(table_name, table->
name,
1697 innobase_convert_to_system_charset(
1698 strchr(table_name,
'/') + 1,
1699 strchr(table->
name,
'/') + 1,
1707 strncpy(table_name, table->
name,
1713 strcpy(foreign->
id, table_name);
1718 sprintf(strchr(foreign->
id,
'/') + 1,
1720 strchr(table_name,
'/') +1,
1721 strstr(old_id,
"_ibfk_") );
1732 foreign->
id =
static_cast<char*
>(
1735 db_len + strlen(old_id) + 1));
1743 strcpy(foreign->
id + db_len,
1791 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
1808 dict_table_remove_from_cache_low(
1819 ut_ad(dict_lru_validate());
1823 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
1826 fputs(
"Removing table ", stderr);
1828 fputs(
" from dictionary cache\n", stderr);
1856 dict_index_remove_from_cache_low(table, index, lru_evict);
1862 ut_fold_string(table->
name), table);
1869 ut_ad(dict_lru_find_table(table));
1872 ut_ad(dict_non_lru_find_table(table));
1876 ut_ad(dict_lru_validate());
1884 #ifdef UNIV_SYNC_DEBUG
1919 dict_table_remove_from_cache_low(table, FALSE);
1934 #if DATA_N_SYS_COLS != 3
1935 #error "DATA_N_SYS_COLS != 3"
1938 static const char* reserved_names[] = {
1939 "DB_ROW_ID",
"DB_TRX_ID",
"DB_ROLL_PTR"
1944 for (i = 0; i < UT_ARR_SIZE(reserved_names); i++) {
1965 dict_index_too_big_for_undo(
1975 = dict_table_get_first_index(table);
1989 if (new_index->
type & DICT_FTS) {
1995 clust_index = new_index;
2000 for (i = 0; i < clust_index->
n_uniq; i++) {
2018 for (i = 0; i < clust_index->
n_def; i++) {
2031 max_size = fixed_size;
2043 for (j = 0; j < new_index->
n_uniq; j++) {
2045 new_index, j) == col) {
2047 = dict_index_get_nth_field(
2068 ulint max_field_len;
2075 max_size =
ut_min(max_size, max_field_len);
2082 max_size =
ut_min(max_prefix, max_size);
2088 undo_page_len += 5 + max_size;
2091 return(undo_page_len >= UNIV_PAGE_SIZE);
2101 dict_index_too_big_for_tree(
2118 if (new_index->
type & DICT_FTS) {
2123 "ib_force_create_table",
2129 if (zip_size && zip_size < UNIV_PAGE_SIZE) {
2144 page_ptr_max = page_rec_max / 2;
2154 page_ptr_max = page_rec_max;
2157 ? REC_N_NEW_EXTRA_BYTES
2158 : REC_N_OLD_EXTRA_BYTES;
2171 rec_max_size += 2 * new_index->
n_fields;
2175 for (i = 0; i < new_index->
n_fields; i++) {
2177 = dict_index_get_nth_field(new_index, i);
2180 ulint field_max_size;
2181 ulint field_ext_max_size;
2196 if (field_max_size) {
2202 field_ext_max_size = 0;
2203 goto add_field_size;
2207 field_ext_max_size = field_max_size < 256 ? 1 : 2;
2223 field_ext_max_size = 1;
2230 rec_max_size += field_ext_max_size;
2233 rec_max_size += field_max_size;
2236 if (UNIV_UNLIKELY(rec_max_size >= page_rec_max)) {
2248 && rec_max_size + REC_NODE_PTR_SIZE >= page_ptr_max) {
2279 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
2286 if (!dict_index_find_cols(table, index)) {
2295 if (index->
type == DICT_FTS) {
2296 new_index = dict_index_build_internal_fts(table, index);
2298 new_index = dict_index_build_internal_clust(table, index);
2300 new_index = dict_index_build_internal_non_clust(table, index);
2309 if (strict && dict_index_too_big_for_tree(table, new_index)) {
2316 if (dict_index_is_univ(index)) {
2319 n_ord = new_index->
n_uniq;
2346 #if UNIV_FORMAT_B != UNIV_FORMAT_MAX
2347 # error "UNIV_FORMAT_B != UNIV_FORMAT_MAX"
2351 for (i = 0; i < n_ord; i++) {
2353 = dict_index_get_nth_field(new_index, i);
2374 if (dict_index_too_big_for_undo(table, new_index)) {
2389 for (i = 0; i < n_ord; i++) {
2391 = dict_index_get_nth_field(new_index, i);
2400 if (!dict_index_is_univ(new_index)) {
2414 new_index->stat_n_non_null_key_vals =
2418 *
sizeof(*new_index->stat_n_non_null_key_vals)));
2431 new_index->
page = page_no;
2434 ? SYNC_IBUF_INDEX_TREE : SYNC_INDEX_TREE);
2447 dict_index_remove_from_cache_low(
2458 ut_ad(table && index);
2459 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
2460 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
2488 if (ref_count == 0) {
2496 if (retries % 500 == 0) {
2498 fprintf(stderr,
"InnoDB: Error: Waited for"
2499 " %lu secs for hash index"
2500 " ref_count (%lu) to drop"
2512 if (retries >= 60000) {
2517 rw_lock_free(&index->
lock);
2540 dict_index_remove_from_cache_low(table, index, FALSE);
2549 dict_index_find_cols(
2556 ut_ad(table && index);
2557 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
2560 for (i = 0; i < index->
n_fields; i++) {
2562 dict_field_t* field = dict_index_get_nth_field(index, i);
2564 for (j = 0; j < table->
n_cols; j++) {
2567 field->
col = dict_table_get_nth_col(table, j);
2575 fputs(
"InnoDB: Error: no matching column for ", stderr);
2577 fputs(
" in ", stderr);
2579 fputs(
"!\n", stderr);
2603 const char* col_name;
2609 field = dict_index_get_nth_field(index, index->
n_def - 1);
2615 if (prefix_len && field->
fixed_len > prefix_len) {
2616 field->
fixed_len = (
unsigned int) prefix_len;
2626 #if DICT_MAX_FIXED_COL_LEN != 768
2630 # error "DICT_MAX_FIXED_COL_LEN != 768"
2633 if (!(col->
prtype & DATA_NOT_NULL)) {
2638 #ifndef UNIV_HOTBACKUP
2656 for (i = start; i < end; i++) {
2658 field = dict_index_get_nth_field(index2, i);
2677 if (dict_index_is_univ(index)) {
2683 for (i = 0; i < n_fields; i++) {
2687 ifield = dict_index_get_nth_field(index, i);
2688 dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
2708 dfield_t* dfield = dtuple_get_nth_field(tuple, i);
2709 dtype_t* dtype = dfield_get_type(dfield);
2722 dict_table_wait_for_bg_threads_to_exit(
2728 fts_t* fts = table->fts;
2730 #ifdef UNIV_SYNC_DEBUG
2749 dict_index_build_internal_clust(
2761 ut_ad(table && index);
2764 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
2777 new_index->
id = index->
id;
2780 dict_index_copy(new_index, index, table, 0, index->
n_fields);
2782 if (dict_index_is_univ(index)) {
2785 new_index->
n_uniq = REC_MAX_N_FIELDS;
2802 trx_id_pos = new_index->
n_def;
2804 #if DATA_ROW_ID != 0
2805 # error "DATA_ROW_ID != 0"
2807 #if DATA_TRX_ID != 1
2808 # error "DATA_TRX_ID != 1"
2810 #if DATA_ROLL_PTR != 2
2811 # error "DATA_ROLL_PTR != 2"
2816 dict_table_get_sys_col(
2817 table, DATA_ROW_ID),
2823 dict_table_get_sys_col(table, DATA_TRX_ID),
2827 dict_table_get_sys_col(table,
2831 for (i = 0; i < trx_id_pos; i++) {
2837 if (fixed_size == 0) {
2843 if (dict_index_get_nth_field(new_index, i)->prefix_len
2869 indexed =
static_cast<ibool*
>(
2873 for (i = 0; i < new_index->
n_def; i++) {
2875 field = dict_index_get_nth_field(new_index, i);
2882 indexed[field->
col->
ind] = TRUE;
2888 for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->
n_cols; i++) {
2890 dict_col_t* col = dict_table_get_nth_col(table, i);
2893 if (!indexed[col->
ind]) {
2903 new_index->
cached = TRUE;
2914 dict_index_build_internal_non_clust(
2926 ut_ad(table && index);
2929 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
2936 ut_ad(!dict_index_is_univ(clust_index));
2948 new_index->
id = index->
id;
2951 dict_index_copy(new_index, index, table, 0, index->
n_fields);
2954 indexed =
static_cast<ibool*
>(
2958 for (i = 0; i < new_index->
n_def; i++) {
2960 field = dict_index_get_nth_field(new_index, i);
2967 indexed[field->
col->
ind] = TRUE;
2974 for (i = 0; i < clust_index->
n_uniq; i++) {
2976 field = dict_index_get_nth_field(clust_index, i);
2978 if (!indexed[field->
col->
ind]) {
2997 new_index->
cached = TRUE;
3007 dict_index_build_internal_fts(
3014 ut_ad(table && index);
3016 #ifdef UNIV_SYNC_DEBUG
3019 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
3031 new_index->
id = index->
id;
3034 dict_index_copy(new_index, index, table, 0, index->
n_fields);
3037 new_index->
cached = TRUE;
3039 if (table->fts->
cache == NULL) {
3078 ut_ad(index != NULL);
3079 ut_ad(table != NULL);
3109 ut_ad(index != NULL);
3110 ut_ad(table != NULL);
3213 const char** col_names,
3216 const char** columns,
3222 bool check_charsets,
3235 index = dict_table_get_first_index(table);
3237 while (index != NULL) {
3238 if (types_idx != index
3239 && !(index->
type & DICT_FTS)
3242 table, col_names, columns, n_cols,
3244 check_charsets, check_null)) {
3248 index = dict_table_get_next_index(index);
3258 dict_foreign_error_report_low(
3265 fprintf(file,
" Error in foreign key constraint of table %s:\n",
3273 dict_foreign_error_report(
3279 mutex_enter(&dict_foreign_err_mutex);
3282 fputs(
" Constraint:\n", file);
3286 fputs(
"The index in the foreign key in table is ", file);
3289 "See " REFMAN
"innodb-foreign-key-constraints.html\n"
3290 "for correct foreign key definition.\n",
3293 mutex_exit(&dict_foreign_err_mutex);
3308 const char** col_names,
3311 bool check_charsets,
3321 ibool added_to_referenced_list= FALSE;
3322 FILE* ef = dict_foreign_err_file;
3331 ut_a(for_table || ref_table);
3334 for_in_cache = dict_foreign_find(for_table, foreign->
id);
3337 if (!for_in_cache && ref_table) {
3338 for_in_cache = dict_foreign_find(ref_table, foreign->
id);
3345 for_in_cache = foreign;
3353 check_charsets,
false);
3357 dict_foreign_error_report(
3359 "there is no index in referenced table"
3360 " which would contain\n"
3361 "the columns as the first columns,"
3362 " or the data types in the\n"
3363 "referenced table do not match"
3364 " the ones in table.");
3366 if (for_in_cache == foreign) {
3378 added_to_referenced_list = TRUE;
3383 for_table, col_names,
3393 dict_foreign_error_report(
3395 "there is no index in the table"
3396 " which would contain\n"
3397 "the columns as the first columns,"
3398 " or the data types in the\n"
3399 "table do not match"
3400 " the ones in the referenced table\n"
3401 "or one of the ON ... SET NULL columns"
3402 " is declared NOT NULL.");
3404 if (for_in_cache == foreign) {
3405 if (added_to_referenced_list) {
3436 ut_ad(dict_lru_validate());
3454 bool escape =
false;
3456 for (; *ptr; ptr++) {
3457 if (*ptr == quote) {
3472 }
else if (*ptr ==
'\\') {
3475 }
else if (*ptr ==
'`' || *ptr ==
'"' || *ptr ==
'\'') {
3481 for (i = 0;
string[
i]; i++) {
3482 if (toupper((
int)(
unsigned char)(ptr[i]))
3483 != toupper((
int)(
unsigned char)
3511 const char* old_ptr = ptr;
3512 const char* old_ptr2;
3516 while (my_isspace(cs, *ptr)) {
3522 ptr = dict_scan_to(ptr,
string);
3524 if (*ptr ==
'\0' || old_ptr2 != ptr) {
3550 ibool accept_also_dot)
3563 while (my_isspace(cs, *ptr)) {
3572 if (*ptr ==
'`' || *ptr ==
'"') {
3584 if (*ptr == quote) {
3586 if (*ptr != quote) {
3594 while (!my_isspace(cs, *ptr) && *ptr !=
'(' && *ptr !=
')'
3595 && (accept_also_dot || *ptr !=
'.')
3596 && *ptr !=
',' && *ptr !=
'\0') {
3604 if (UNIV_UNLIKELY(!heap)) {
3613 str = d =
static_cast<char*
>(
3617 if ((*d++ = *s++) == quote) {
3624 ut_ad(s + 1 == ptr);
3676 ptr = dict_scan_id(cs, ptr, heap, name, FALSE, TRUE);
3678 if (*name == NULL) {
3683 if (table == NULL) {
3696 *column = dict_table_get_nth_col(table, i);
3697 strcpy((
char*) *name, col_name);
3718 const char* database_name,
3719 ulint database_name_len,
3721 ulint table_name_len,
3726 const char* db_name;
3728 if (!database_name) {
3734 db_name = database_name;
3738 ref =
static_cast<char*
>(
3741 memcpy(ref, db_name, database_name_len);
3742 ref[database_name_len] =
'/';
3743 memcpy(ref + database_name_len + 1, table_name, table_name_len + 1);
3751 memcpy(ref, db_name, database_name_len);
3752 ref[database_name_len] =
'/';
3753 memcpy(ref + database_name_len + 1, table_name, table_name_len + 1);
3773 dict_scan_table_name(
3781 const char** ref_name)
3784 const char* database_name = NULL;
3785 ulint database_name_len = 0;
3787 const char* scan_name;
3792 ptr = dict_scan_id(cs, ptr, heap, &scan_name, TRUE, FALSE);
3794 if (scan_name == NULL) {
3804 database_name = scan_name;
3805 database_name_len = strlen(database_name);
3807 ptr = dict_scan_id(cs, ptr, heap, &table_name, TRUE, FALSE);
3809 if (table_name == NULL) {
3823 for (s = scan_name; *s; s++) {
3825 database_name = scan_name;
3826 database_name_len = s - scan_name;
3832 table_name = scan_name;
3836 name, database_name, database_name_len,
3837 table_name, strlen(table_name), table, heap);
3859 ptr = dict_scan_id(cs, ptr, NULL, &start, FALSE, TRUE);
3878 dict_strip_comments(
3880 const char* sql_string,
3885 const char* eptr = sql_string + sql_length;
3889 bool escape =
false;
3891 DBUG_ENTER(
"dict_strip_comments");
3893 DBUG_PRINT(
"dict_strip_comments", (
"%s", sql_string));
3895 str =
static_cast<char*
>(mem_alloc(sql_length + 1));
3902 if (sptr >= eptr || *sptr ==
'\0') {
3906 ut_a(ptr <= str + sql_length);
3908 DBUG_PRINT(
"dict_strip_comments", (
"%s", str));
3912 if (*sptr == quote) {
3928 }
else if (*sptr ==
'\\') {
3931 }
else if (*sptr ==
'"' || *sptr ==
'`' || *sptr ==
'\'') {
3934 }
else if (*sptr ==
'#'
3935 || (sptr[0] ==
'-' && sptr[1] ==
'-'
3936 && sptr[2] ==
' ')) {
3938 if (++sptr >= eptr) {
3952 }
else if (!quote && *sptr ==
'/' && *(sptr + 1) ==
'*') {
3963 if (sptr[1] ==
'/') {
3993 ulint biggest_id = 0;
4003 if (
ut_strlen(foreign->
id) > ((
sizeof dict_ibfk) - 1) + len
4006 dict_ibfk, (
sizeof dict_ibfk) - 1)
4007 && foreign->
id[len + ((
sizeof dict_ibfk) - 1)] !=
'0') {
4010 id = strtoul(foreign->
id + len
4011 + ((
sizeof dict_ibfk) - 1),
4013 if (*endp ==
'\0') {
4014 ut_a(
id != biggest_id);
4016 if (
id > biggest_id) {
4032 dict_foreign_report_syntax_err(
4035 const char* start_of_latest_foreign,
4042 FILE* ef = dict_foreign_err_file;
4044 mutex_enter(&dict_foreign_err_mutex);
4045 dict_foreign_error_report_low(ef, name);
4046 fprintf(ef,
"%s:\nSyntax error close to:\n%s\n",
4047 start_of_latest_foreign, ptr);
4048 mutex_exit(&dict_foreign_err_mutex);
4060 dict_create_foreign_constraints_low(
4065 const char* sql_string,
4082 ulint highest_id_so_far = 0;
4085 const char* ptr = sql_string;
4086 const char* start_of_latest_foreign = sql_string;
4087 FILE* ef = dict_foreign_err_file;
4107 if (table == NULL) {
4108 mutex_enter(&dict_foreign_err_mutex);
4109 dict_foreign_error_report_low(ef, name);
4111 "Cannot find the table in the internal"
4112 " data dictionary of InnoDB.\n"
4113 "Create table statement:\n%s\n", sql_string);
4114 mutex_exit(&dict_foreign_err_mutex);
4122 ptr = dict_accept(cs, ptr,
"ALTER", &success);
4129 ptr = dict_accept(cs, ptr,
"TABLE", &success);
4138 ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
4139 &success, heap, &referenced_table_name);
4142 "InnoDB: Error: could not find"
4143 " the table being ALTERED in:\n%s\n",
4158 if (table_to_alter == NULL) {
4159 highest_id_so_far = 0;
4169 ptr1 = dict_scan_to(ptr,
"CONSTRAINT");
4170 ptr2 = dict_scan_to(ptr,
"FOREIGN");
4172 constraint_name = NULL;
4180 ptr = dict_accept(cs, ptr,
"CONSTRAINT", &success);
4184 if (!my_isspace(cs, *ptr) && *ptr !=
'"' && *ptr !=
'`') {
4188 while (my_isspace(cs, *ptr)) {
4194 ptr = dict_scan_id(cs, ptr, heap,
4195 &constraint_name, FALSE, FALSE);
4219 highest_id_so_far, table, trx);
4223 start_of_latest_foreign = ptr;
4225 ptr = dict_accept(cs, ptr,
"FOREIGN", &success);
4231 if (!my_isspace(cs, *ptr)) {
4235 ptr = dict_accept(cs, ptr,
"KEY", &success);
4241 ptr = dict_accept(cs, ptr,
"(", &success);
4246 ptr = dict_skip_word(cs, ptr, &success);
4249 dict_foreign_report_syntax_err(
4250 name, start_of_latest_foreign, ptr);
4255 ptr = dict_accept(cs, ptr,
"(", &success);
4269 ut_a(i < (
sizeof column_names) /
sizeof *column_names);
4270 ptr = dict_scan_col(cs, ptr, &success, table, columns + i,
4271 heap, column_names + i);
4273 mutex_enter(&dict_foreign_err_mutex);
4274 dict_foreign_error_report_low(ef, name);
4275 fprintf(ef,
"%s:\nCannot resolve column name close to:\n%s\n",
4276 start_of_latest_foreign, ptr);
4277 mutex_exit(&dict_foreign_err_mutex);
4284 ptr = dict_accept(cs, ptr,
",", &success);
4290 ptr = dict_accept(cs, ptr,
")", &success);
4293 dict_foreign_report_syntax_err(
4294 name, start_of_latest_foreign, ptr);
4305 table, NULL, column_names, i, NULL, TRUE, FALSE);
4308 mutex_enter(&dict_foreign_err_mutex);
4309 dict_foreign_error_report_low(ef, name);
4310 fputs(
"There is no index in table ", ef);
4312 fprintf(ef,
" where the columns appear\n"
4313 "as the first columns. Constraint:\n%s\n"
4314 "See " REFMAN
"innodb-foreign-key-constraints.html\n"
4315 "for correct foreign key definition.\n",
4316 start_of_latest_foreign);
4317 mutex_exit(&dict_foreign_err_mutex);
4321 ptr = dict_accept(cs, ptr,
"REFERENCES", &success);
4323 if (!success || !my_isspace(cs, *ptr)) {
4324 dict_foreign_report_syntax_err(
4325 name, start_of_latest_foreign, ptr);
4333 if (constraint_name) {
4344 foreign->
heap, db_len + strlen(constraint_name) + 2));
4347 foreign->
id[db_len] =
'/';
4348 strcpy(foreign->
id + db_len + 1, constraint_name);
4357 foreign->
n_fields = (
unsigned int) i;
4362 for (i = 0; i < foreign->
n_fields; i++) {
4369 ptr = dict_scan_table_name(cs, ptr, &referenced_table, name,
4370 &success, heap, &referenced_table_name);
4378 mutex_enter(&dict_foreign_err_mutex);
4379 dict_foreign_error_report_low(ef, name);
4380 fprintf(ef,
"%s:\nCannot resolve table name close to:\n"
4382 start_of_latest_foreign, ptr);
4383 mutex_exit(&dict_foreign_err_mutex);
4388 ptr = dict_accept(cs, ptr,
"(", &success);
4392 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
4401 ptr = dict_scan_col(cs, ptr, &success, referenced_table, columns + i,
4402 heap, column_names + i);
4408 mutex_enter(&dict_foreign_err_mutex);
4409 dict_foreign_error_report_low(ef, name);
4410 fprintf(ef,
"%s:\nCannot resolve column name close to:\n"
4412 start_of_latest_foreign, ptr);
4413 mutex_exit(&dict_foreign_err_mutex);
4418 ptr = dict_accept(cs, ptr,
",", &success);
4424 ptr = dict_accept(cs, ptr,
")", &success);
4426 if (!success || foreign->
n_fields != i) {
4429 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
4440 ptr = dict_accept(cs, ptr,
"ON", &success);
4444 goto try_find_index;
4447 ptr = dict_accept(cs, ptr,
"DELETE", &success);
4450 ptr = dict_accept(cs, ptr,
"UPDATE", &success);
4455 dict_foreign_report_syntax_err(
4456 name, start_of_latest_foreign, ptr);
4460 is_on_delete = FALSE;
4463 is_on_delete = TRUE;
4467 ptr = dict_accept(cs, ptr,
"RESTRICT", &success);
4470 goto scan_on_conditions;
4473 ptr = dict_accept(cs, ptr,
"CASCADE", &success);
4482 goto scan_on_conditions;
4485 ptr = dict_accept(cs, ptr,
"NO", &success);
4488 ptr = dict_accept(cs, ptr,
"ACTION", &success);
4492 dict_foreign_report_syntax_err(
4493 name, start_of_latest_foreign, ptr);
4504 goto scan_on_conditions;
4507 ptr = dict_accept(cs, ptr,
"SET", &success);
4511 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
4516 ptr = dict_accept(cs, ptr,
"NULL", &success);
4520 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
4525 for (j = 0; j < foreign->
n_fields; j++) {
4534 mutex_enter(&dict_foreign_err_mutex);
4535 dict_foreign_error_report_low(ef, name);
4537 "You have defined a SET NULL condition"
4538 " though some of the\n"
4539 "columns are defined as NOT NULL.\n",
4540 start_of_latest_foreign);
4541 mutex_exit(&dict_foreign_err_mutex);
4553 goto scan_on_conditions;
4556 if (n_on_deletes > 1 || n_on_updates > 1) {
4561 mutex_enter(&dict_foreign_err_mutex);
4562 dict_foreign_error_report_low(ef, name);
4564 "You have twice an ON DELETE clause"
4565 " or twice an ON UPDATE clause.\n",
4566 start_of_latest_foreign);
4567 mutex_exit(&dict_foreign_err_mutex);
4576 if (referenced_table) {
4583 mutex_enter(&dict_foreign_err_mutex);
4584 dict_foreign_error_report_low(ef, name);
4586 "Cannot find an index in the"
4587 " referenced table where the\n"
4588 "referenced columns appear as the"
4589 " first columns, or column types\n"
4590 "in the table and the referenced table"
4591 " do not match for constraint.\n"
4592 "Note that the internal storage type of"
4593 " ENUM and SET changed in\n"
4594 "tables created with >= InnoDB-4.1.12,"
4595 " and such columns in old tables\n"
4596 "cannot be referenced by such columns"
4599 "innodb-foreign-key-constraints.html\n"
4600 "for correct foreign key definition.\n",
4601 start_of_latest_foreign);
4602 mutex_exit(&dict_foreign_err_mutex);
4615 foreign->
heap, referenced_table_name);
4621 for (i = 0; i < foreign->
n_fields; i++) {
4630 if (referenced_table) {
4647 const char* keyword)
4652 dict_accept(cs, str, keyword, &success);
4668 const char* sql_string,
4691 str = dict_strip_comments(sql_string, sql_length);
4694 err = dict_create_foreign_constraints_low(
4718 const char*** constraints_to_drop)
4736 *constraints_to_drop =
static_cast<const char**
>(
4741 str = dict_strip_comments(ptr, len);
4747 ptr = dict_scan_to(ptr,
"DROP");
4755 ptr = dict_accept(cs, ptr,
"DROP", &success);
4757 if (!my_isspace(cs, *ptr)) {
4762 ptr = dict_accept(cs, ptr,
"FOREIGN", &success);
4764 if (!success || !my_isspace(cs, *ptr)) {
4769 ptr = dict_accept(cs, ptr,
"KEY", &success);
4776 ptr = dict_scan_id(cs, ptr, heap, &
id, FALSE, TRUE);
4784 (*constraints_to_drop)[*
n] =
id;
4791 while (foreign != NULL) {
4793 || (strchr(foreign->
id,
'/')
4805 if (foreign == NULL) {
4808 FILE* ef = dict_foreign_err_file;
4810 mutex_enter(&dict_foreign_err_mutex);
4813 fputs(
" Error in dropping of a foreign key "
4814 "constraint of table ", ef);
4816 fputs(
",\nin SQL command\n", ef);
4818 fputs(
"\nCannot find a constraint with the "
4822 mutex_exit(&dict_foreign_err_mutex);
4834 FILE* ef = dict_foreign_err_file;
4836 mutex_enter(&dict_foreign_err_mutex);
4839 fputs(
" Syntax error in dropping of a"
4840 " foreign key constraint of table ", ef);
4843 "close to:\n%s\n in SQL command\n%s\n", ptr, str);
4844 mutex_exit(&dict_foreign_err_mutex);
4862 index_id_t index_id)
4869 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
4875 dict_index_get_if_in_cache(
4877 index_id_t index_id)
4902 dict_index_check_search_tuple(
4936 if (dict_index_is_univ(index)) {
4969 field = dtuple_get_nth_field(tuple, n_unique);
4972 dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4);
4976 | REC_STATUS_NODE_PTR);
5001 UNIV_PREFETCH_R(rec);
5003 if (dict_index_is_univ(index)) {
5056 sum = REC_N_NEW_EXTRA_BYTES;
5064 sum += size < 128 ? 1 : 2;
5066 if (!(col->
prtype & DATA_NOT_NULL)) {
5088 sum += REC_N_OLD_EXTRA_BYTES;
5097 dict_foreign_print_low(
5105 fprintf(stderr,
" FOREIGN KEY CONSTRAINT %s: %s (",
5108 for (i = 0; i < foreign->
n_fields; i++) {
5112 fprintf(stderr,
" )\n"
5116 for (i = 0; i < foreign->
n_fields; i++) {
5120 fputs(
" )\n", stderr);
5144 "--------------------------------------\n"
5145 "TABLE: name %s, id %llu, flags %lx, columns %lu,"
5146 " indexes %lu, appr.rows " UINT64PF
"\n"
5150 (ulong) table->
flags,
5155 for (i = 0; i < (ulint) table->
n_cols; i++) {
5156 dict_col_print_low(table, dict_table_get_nth_col(table, i));
5157 fputs(
"; ", stderr);
5164 while (index != NULL) {
5165 dict_index_print_low(index);
5175 while (foreign != NULL) {
5176 dict_foreign_print_low(foreign);
5182 while (foreign != NULL) {
5183 dict_foreign_print_low(foreign);
5212 dict_index_print_low(
5231 " INDEX: name %s, id %llu, fields %lu/%lu,"
5232 " uniq %lu, type %lu\n"
5233 " root page %lu, appr.key vals %lu,"
5234 " leaf pages %lu, size pages %lu\n"
5241 (ulong) index->
type,
5242 (ulong) index->
page,
5247 for (i = 0; i < index->
n_fields; i++) {
5248 dict_field_print_low(dict_index_get_nth_field(index, i));
5253 #ifdef UNIV_BTR_PRINT
5254 btr_print_size(index);
5256 btr_print_index(index, 7);
5264 dict_field_print_low(
5270 fprintf(stderr,
" %s", field->
name);
5273 fprintf(stderr,
"(%lu)", (ulong) field->
prefix_len);
5289 const char* stripped_id;
5292 if (strchr(foreign->
id,
'/')) {
5294 stripped_id = foreign->
id + 1
5297 stripped_id = foreign->
id;
5309 fputs(
" CONSTRAINT ", file);
5311 fputs(
" FOREIGN KEY (", file);
5315 if (++i < foreign->n_fields) {
5322 fputs(
") REFERENCES ", file);
5341 if (++i < foreign->n_fields) {
5351 fputs(
" ON DELETE CASCADE", file);
5355 fputs(
" ON DELETE SET NULL", file);
5359 fputs(
" ON DELETE NO ACTION", file);
5363 fputs(
" ON UPDATE CASCADE", file);
5367 fputs(
" ON UPDATE SET NULL", file);
5371 fputs(
" ON UPDATE NO ACTION", file);
5381 ibool create_table_format,
5395 if (foreign == NULL) {
5401 while (foreign != NULL) {
5402 if (create_table_format) {
5404 file, trx, foreign, TRUE);
5409 for (i = 0; i < foreign->
n_fields; i++) {
5418 fputs(
") REFER ", file);
5423 for (i = 0; i < foreign->
n_fields; i++) {
5435 fputs(
" ON DELETE CASCADE", file);
5439 fputs(
" ON DELETE SET NULL", file);
5443 fputs(
" ON DELETE NO ACTION", file);
5447 fputs(
" ON UPDATE CASCADE", file);
5451 fputs(
" ON UPDATE SET NULL", file);
5455 fputs(
" ON UPDATE NO ACTION", file);
5475 fputs(
"index ", file);
5477 fputs(
" of table ", file);
5486 dict_find_table_by_space(
5494 ut_ad(space_id > 0);
5503 while (table && count < num_item) {
5504 if (table->
space == space_id) {
5527 table = dict_find_table_by_space(space_id);
5563 row_mysql_lock_data_dictionary(trx);
5571 #ifdef UNIV_SYNC_DEBUG
5572 ut_ad(sync_thread_levels_empty_except_dict());
5589 +
sizeof(
upd_t) + 12));
5598 dfield = dtuple_get_nth_field(tuple, 0);
5603 dfield = dtuple_get_nth_field(tuple, 1);
5612 &cursor, 0, __FILE__, __LINE__, &mtr);
5618 byte* field = rec_get_nth_field_old(
5619 btr_cur_get_rec(&cursor),
5620 DICT_FLD__SYS_INDEXES__TYPE, &len);
5628 status =
"Unable to flag";
5633 table_name =
static_cast<char*
>(
mem_heap_alloc(heap, FN_REFLEN + 1));
5635 table_name, FN_REFLEN,
5639 ib_logf(IB_LOG_LEVEL_ERROR,
"%s corruption of %s in table %s in %s",
5640 status, index->
name, table_name, ctx);
5671 corrupt_table = table ? table : index->
table;
5674 if (corrupt_table) {
5695 DATA_ENGLISH | DATA_NOT_NULL, 8);
5698 DICT_HDR_SPACE, 0, 1);
5700 dict_table_get_nth_col(table, 0), 0);
5708 DATA_ENGLISH | DATA_NOT_NULL, 8);
5710 DICT_HDR_SPACE, 0, 1);
5712 dict_table_get_nth_col(table, 0), 0);
5719 #ifndef UNIV_HOTBACKUP
5757 index = dict_table_get_first_index(table);
5759 while (index != NULL) {
5765 index = dict_table_get_next_index(index);
5780 const char** col_names,
5857 index = dict_table_get_first_index(table);
5859 while (index != NULL) {
5861 if (!min_index || index->
id < min_index->
id) {
5867 index = dict_table_get_next_index(index);
5879 dict_table_check_for_dup_indexes(
5883 enum check_name check)
5904 case CHECK_ALL_COMPLETE:
5906 case CHECK_ABORTED_OK:
5917 case CHECK_PARTIAL_OK:
5951 char buf[MAX_FULL_NAME_LEN];
5959 if (table == NULL) {
5963 "Table %s not found.",
5965 TRUE, buf,
sizeof(buf)));
5967 return(DB_TABLE_NOT_FOUND);
5974 "Tablespace for table %s is missing.",
5976 TRUE, buf,
sizeof(buf)));
5978 return(DB_TABLE_NOT_FOUND);
5981 if ((ulint) table->
n_def - DATA_N_SYS_COLS != req_schema->n_cols) {
5986 "%s has %d columns but should have %lu.",
5988 TRUE, buf,
sizeof(buf)),
5989 table->
n_def - DATA_N_SYS_COLS,
5990 req_schema->n_cols);
6000 for (i = 0; i < req_schema->n_cols; i++) {
6004 char actual_type[64];
6016 for (j = 0; j < table->
n_def; j++) {
6022 req_schema->columns[i].name) == 0) {
6030 if (j == table->
n_def) {
6033 "required column %s "
6034 "not found in table %s.",
6035 req_schema->columns[i].name,
6037 req_schema->table_name,
6038 TRUE, buf,
sizeof(buf)));
6048 req_schema->columns[i].prtype_mask,
6049 req_schema->columns[i].len,
6050 req_type,
sizeof(req_type));
6055 actual_type,
sizeof(actual_type));
6058 if (req_schema->columns[i].len != table->
cols[j].
len) {
6061 "Column %s in table %s is %s "
6062 "but should be %s (length mismatch).",
6063 req_schema->columns[i].name,
6065 TRUE, buf,
sizeof(buf)),
6066 actual_type, req_type);
6072 if (req_schema->columns[i].mtype != table->
cols[j].
mtype) {
6075 "Column %s in table %s is %s "
6076 "but should be %s (type mismatch).",
6077 req_schema->columns[i].name,
6079 TRUE, buf,
sizeof(buf)),
6080 actual_type, req_type);
6086 if (req_schema->columns[i].prtype_mask != 0
6088 & req_schema->columns[i].prtype_mask)
6089 != req_schema->columns[i].prtype_mask) {
6092 "Column %s in table %s is %s "
6093 "but should be %s (flags mismatch).",
6094 req_schema->columns[i].name,
6096 TRUE, buf,
sizeof(buf)),
6097 actual_type, req_type);
6106 "Table %s has %lu foreign key(s) pointing to other "
6107 "tables, but it must have %lu.",
6109 TRUE, buf,
sizeof(buf)),
6111 req_schema->n_foreign);
6118 "There are %lu foreign key(s) pointing to %s, "
6119 "but there must be %lu.",
6122 TRUE, buf,
sizeof(buf)),
6123 req_schema->n_referenced);
6140 const char* db_and_table,
6143 size_t db_utf8_size,
6145 size_t table_utf8_size)
6147 char db[MAX_DATABASE_NAME_LEN + 1];
6153 ut_a(db_len <=
sizeof(db));
6155 memcpy(db, db_and_table, db_len);
6159 &my_charset_filename, db,
6160 system_charset_info, db_utf8, db_utf8_size,
6165 const char* table_p;
6168 for (table_p = table, buf_p = buf; table_p[0] !=
'\0'; table_p++) {
6169 if (table_p[0] !=
'#') {
6170 buf_p[0] = table_p[0];
6180 ut_a((
size_t) (buf_p - buf) <
sizeof(buf));
6186 &my_charset_filename, buf,
6187 system_charset_info, table_utf8, table_utf8_size,
6219 ut_a(prev_table->magic_n == DICT_TABLE_MAGIC_N);
6244 mutex_free(&dict_foreign_err_mutex);
6251 rw_lock_free(&dict_table_stats_latches[i]);
6261 dict_lru_validate(
void)
6290 dict_lru_find_table(
6296 ut_ad(find_table != NULL);
6305 if (table == find_table) {
6318 dict_non_lru_find_table(
6324 ut_ad(find_table != NULL);
6333 if (table == find_table) {
6351 const char** col_names,
6354 const char** columns,
6361 bool check_charsets,
6374 for (ulint i = 0; i < n_cols; i++) {
6376 const char* col_name;
6379 field = dict_index_get_nth_field(index, i);
6389 && (field->
col->
prtype & DATA_NOT_NULL)) {
6393 col_name = col_names
6418 dict_index_zip_pad_update(
6421 ulint zip_threshold)
6432 if(zip_threshold == 0) {
6444 fail_pct = (info->
failure * 100) / total;
6448 if (fail_pct > zip_threshold) {
6458 #ifdef HAVE_ATOMIC_BUILTINS
6485 #ifdef HAVE_ATOMIC_BUILTINS
6514 if (!zip_threshold) {
6521 dict_index_zip_pad_update(&index->
zip_pad, zip_threshold);
6537 if (!zip_threshold) {
6544 dict_index_zip_pad_update(&index->
zip_pad, zip_threshold);
6567 return(UNIV_PAGE_SIZE);
6574 #ifdef HAVE_ATOMIC_BUILTINS
6575 pad = os_atomic_increment_ulint(&index->
zip_pad.
pad, 0);
6582 ut_ad(pad < UNIV_PAGE_SIZE);
6583 sz = UNIV_PAGE_SIZE - pad;
6587 min_sz = (UNIV_PAGE_SIZE * (100 -
zip_pad_max)) / 100;
6589 return(
ut_max(sz, min_sz));
6601 switch (dict_tf_get_rec_format(table_flag)) {
6603 return(
"ROW_TYPE_REDUNDANT");
6605 return(
"ROW_TYPE_COMPACT");
6607 return(
"ROW_TYPE_COMPRESSED");
6609 return(
"ROW_TYPE_DYNAMIC");