29 #include "dict0dict.ic"
37 #ifndef UNIV_HOTBACKUP
60 #include <drizzled/session.h>
76 #ifdef UNIV_PFS_RWLOCK
77 UNIV_INTERN mysql_pfs_key_t dict_operation_lock_key;
78 UNIV_INTERN mysql_pfs_key_t index_tree_rw_lock_key;
79 UNIV_INTERN mysql_pfs_key_t dict_table_stats_latch_key;
83 UNIV_INTERN mysql_pfs_key_t dict_sys_mutex_key;
84 UNIV_INTERN mysql_pfs_key_t dict_foreign_err_mutex_key;
87 #define DICT_HEAP_SIZE 100
89 #define DICT_POOL_PER_TABLE_HASH 512
91 #define DICT_POOL_PER_VARYING 4
95 static char dict_ibfk[] = "_ibfk_";
107 #define DICT_TABLE_STATS_LATCHES_SIZE 64
108 static rw_lock_t dict_table_stats_latches[DICT_TABLE_STATS_LATCHES_SIZE];
116 dict_index_find_cols(
126 dict_index_build_internal_clust(
137 dict_index_build_internal_non_clust(
146 dict_foreign_remove_from_cache(
161 dict_index_print_low(
168 dict_field_print_low(
181 UNIV_INTERN FILE* dict_foreign_err_file = NULL;
183 UNIV_INTERN
mutex_t dict_foreign_err_mutex;
201 dict_tables_have_same_db(
208 for (; *name1 == *name2; name1++, name2++) {
227 const char* s = strchr(name,
'/');
233 s= strchr(name,
'/');
243 dict_get_db_name_len(
250 catalog = strchr(name,
'/');
252 s= strchr(catalog+1,
'/');
264 dict_mutex_enter_for_mysql(
void)
274 dict_mutex_exit_for_mysql(
void)
281 #define GET_TABLE_STATS_LATCH(table) \
282 (&dict_table_stats_latches[ut_fold_ull(table->id) \
283 % DICT_TABLE_STATS_LATCHES_SIZE])
291 dict_table_stats_lock(
297 ut_ad(table != NULL);
298 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
300 switch (latch_mode) {
305 rw_lock_x_lock(GET_TABLE_STATS_LATCH(table));
318 dict_table_stats_unlock(
324 ut_ad(table != NULL);
325 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
327 switch (latch_mode) {
329 rw_lock_s_unlock(GET_TABLE_STATS_LATCH(table));
332 rw_lock_x_unlock(GET_TABLE_STATS_LATCH(table));
345 dict_table_decrement_handle_count(
351 mutex_enter(&dict_sys->
mutex);
360 mutex_exit(&dict_sys->
mutex);
371 dict_table_get_col_name(
380 ut_ad(col_nr < table->n_def);
381 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
385 for (i = 0; i < col_nr; i++) {
393 #ifndef UNIV_HOTBACKUP
398 dict_table_autoinc_lock(
409 dict_table_autoinc_initialize(
425 dict_table_autoinc_read(
439 dict_table_autoinc_update_if_greater(
457 dict_table_autoinc_unlock(
470 dict_index_get_on_id_low(
477 index = dict_table_get_first_index(table);
480 if (
id == index->
id) {
486 index = dict_table_get_next_index(index);
499 dict_index_get_nth_col_pos(
510 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
512 col = dict_table_get_nth_col(index->
table, n);
521 for (pos = 0; pos < n_fields; pos++) {
522 field = dict_index_get_nth_field(index, pos);
530 return(ULINT_UNDEFINED);
533 #ifndef UNIV_HOTBACKUP
539 dict_index_contains_col_or_prefix(
550 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
557 col = dict_table_get_nth_col(index->
table, n);
561 for (pos = 0; pos < n_fields; pos++) {
562 field = dict_index_get_nth_field(index, pos);
564 if (col == field->
col) {
582 dict_index_get_nth_field_pos(
594 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
596 field2 = dict_index_get_nth_field(index2, n);
600 for (pos = 0; pos < n_fields; pos++) {
601 field = dict_index_get_nth_field(index, pos);
603 if (field->
col == field2->
col
612 return(ULINT_UNDEFINED);
620 dict_table_get_on_id(
637 mutex_enter(&(dict_sys->
mutex));
641 mutex_exit(&(dict_sys->
mutex));
651 dict_table_get_nth_col_pos(
656 return(dict_index_get_nth_col_pos(dict_table_get_first_index(table),
666 dict_table_col_in_clustered_key(
679 col = dict_table_get_nth_col(table, n);
681 index = dict_table_get_first_index(table);
685 for (pos = 0; pos < n_fields; pos++) {
686 field = dict_index_get_nth_field(index, pos);
688 if (col == field->
col) {
708 mutex_create(dict_sys_mutex_key, &dict_sys->
mutex, SYNC_DICT);
711 / (DICT_POOL_PER_TABLE_HASH
714 / (DICT_POOL_PER_TABLE_HASH
721 &dict_operation_lock, SYNC_DICT_OPERATION);
724 ut_a(dict_foreign_err_file);
726 mutex_create(dict_foreign_err_mutex_key,
727 &dict_foreign_err_mutex, SYNC_ANY_LATCH);
729 for (i = 0; i < DICT_TABLE_STATS_LATCHES_SIZE; i++) {
731 &dict_table_stats_latches[i], SYNC_INDEX_TREE);
745 const char* table_name,
746 ibool inc_mysql_count)
751 mutex_enter(&(dict_sys->
mutex));
755 if (inc_mysql_count && table) {
759 mutex_exit(&(dict_sys->
mutex));
765 dict_update_statistics(table, TRUE
777 dict_table_add_system_columns(
784 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
793 dict_mem_table_add_col(table, heap,
"DB_ROW_ID", DATA_SYS,
794 DATA_ROW_ID | DATA_NOT_NULL,
797 #error "DATA_ROW_ID != 0"
799 dict_mem_table_add_col(table, heap,
"DB_TRX_ID", DATA_SYS,
800 DATA_TRX_ID | DATA_NOT_NULL,
803 #error "DATA_TRX_ID != 1"
805 dict_mem_table_add_col(table, heap,
"DB_ROLL_PTR", DATA_SYS,
806 DATA_ROLL_PTR | DATA_NOT_NULL,
808 #if DATA_ROLL_PTR != 2
809 #error "DATA_ROLL_PTR != 2"
814 #if DATA_N_SYS_COLS != 3
815 #error "DATA_N_SYS_COLS != 3"
819 #ifndef UNIV_HOTBACKUP
824 dict_table_add_to_cache(
835 #define BIG_ROW_SIZE 1024
839 dict_table_add_system_columns(table, heap);
847 for (i = 0; i < table->
n_def; i++) {
849 dict_table_get_nth_col(table, i));
855 if (row_len >= BIG_ROW_SIZE || col_len >= BIG_ROW_SIZE) {
856 row_len = BIG_ROW_SIZE;
862 table->
big_rows = row_len >= BIG_ROW_SIZE;
870 ut_a(table2 == NULL);
877 ut_ad(table2 == NULL);
886 table2->
id == table->
id);
887 ut_a(table2 == NULL);
894 ut_ad(table2 == NULL);
909 + strlen(table->
name) + 1;
919 dict_index_find_on_id_low(
929 index = dict_table_get_first_index(table);
932 if (
id == index->
id) {
938 index = dict_table_get_next_index(index);
952 dict_table_rename_in_cache(
955 const char* new_name,
956 ibool rename_also_foreigns)
963 char old_name[MAX_FULL_NAME_LEN + 1];
969 if (strlen(table->
name) + 1 <=
sizeof(old_name)) {
970 memcpy(old_name, table->
name, strlen(table->
name) + 1);
973 fprintf(stderr,
"InnoDB: too long table name: '%s', "
974 "max length is %d\n", table->
name,
987 if (UNIV_LIKELY_NULL(table2)) {
989 fputs(
" InnoDB: Error: dictionary cache"
990 " already contains a table ", stderr);
993 "InnoDB: cannot rename table ", stderr);
1003 if (table->
space != 0) {
1006 fputs(
" InnoDB: Error: trying to rename a"
1007 " TEMPORARY TABLE ", stderr);
1009 fputs(
" (", stderr);
1012 fputs(
" )\n", stderr);
1014 }
else if (!fil_rename_tablespace(old_name, table->
space,
1024 if (strlen(new_name) > strlen(table->
name)) {
1028 ut_a(strlen(new_name) <= MAX_TABLE_NAME_LEN);
1031 memcpy(table->
name, new_name, strlen(new_name) + 1);
1037 dict_sys->
size += strlen(new_name) - strlen(old_name);
1041 index = dict_table_get_first_index(table);
1043 while (index != NULL) {
1046 index = dict_table_get_next_index(index);
1049 if (!rename_also_foreigns) {
1061 while (foreign != NULL) {
1062 dict_foreign_remove_from_cache(foreign);
1070 while (foreign != NULL) {
1090 while (foreign != NULL) {
1098 dict_mem_foreign_table_name_lookup_set(foreign, TRUE);
1101 dict_mem_foreign_table_name_lookup_set(foreign, FALSE);
1104 if (strchr(foreign->
id,
'/')) {
1113 + ((
sizeof dict_ibfk) - 1)
1114 && !memcmp(foreign->
id, old_name,
1117 dict_ibfk, (
sizeof dict_ibfk) - 1)) {
1121 if (strlen(table->
name) > strlen(old_name)) {
1125 + strlen(old_id) + 1));
1130 strcpy(foreign->
id, table->
name);
1136 db_len = dict_get_db_name_len(table->
name) + 1;
1138 if (dict_get_db_name_len(table->
name)
1139 > dict_get_db_name_len(foreign->
id)) {
1143 db_len + strlen(old_id) + 1));
1151 strcpy(foreign->
id + db_len,
1152 dict_remove_db_name(old_id));
1163 while (foreign != NULL) {
1171 dict_mem_referenced_table_name_lookup_set(foreign, TRUE);
1175 dict_mem_referenced_table_name_lookup_set(foreign, FALSE);
1189 dict_table_change_id_in_cache(
1196 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
1213 dict_table_remove_from_cache(
1223 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
1226 fputs(
"Removing table ", stderr);
1228 fputs(
" from dictionary cache\n", stderr);
1234 while (foreign != NULL) {
1235 dict_foreign_remove_from_cache(foreign);
1243 while (foreign != NULL) {
1253 while (index != NULL) {
1254 dict_index_remove_from_cache(table, index);
1271 dict_sys->
size -= size;
1273 dict_mem_table_free(table);
1282 dict_col_name_is_reserved(
1288 #if DATA_N_SYS_COLS != 3
1289 #error "DATA_N_SYS_COLS != 3"
1292 static const char* reserved_names[] = {
1293 "DB_ROW_ID",
"DB_TRX_ID",
"DB_ROLL_PTR"
1298 for (i = 0; i < UT_ARR_SIZE(reserved_names); i++) {
1314 dict_index_too_big_for_undo(
1324 = dict_table_get_first_index(table);
1336 if (UNIV_UNLIKELY(!clust_index)) {
1338 clust_index = new_index;
1343 for (i = 0; i < clust_index->
n_uniq; i++) {
1361 for (i = 0; i < clust_index->
n_def; i++) {
1372 max_size = fixed_size;
1380 for (j = 0; j < new_index->
n_uniq; j++) {
1382 new_index, j) == col) {
1397 if (max_size > REC_MAX_INDEX_COL_LEN) {
1398 max_size = REC_MAX_INDEX_COL_LEN;
1404 undo_page_len += 5 + max_size;
1407 return(undo_page_len >= UNIV_PAGE_SIZE);
1416 dict_index_too_big_for_tree(
1434 if (zip_size && zip_size < UNIV_PAGE_SIZE) {
1446 page_ptr_max = page_rec_max / 2;
1456 page_ptr_max = page_rec_max;
1459 ? REC_N_NEW_EXTRA_BYTES
1460 : REC_N_OLD_EXTRA_BYTES;
1473 rec_max_size += 2 * new_index->
n_fields;
1477 for (i = 0; i < new_index->
n_fields; i++) {
1479 = dict_index_get_nth_field(new_index, i);
1482 ulint field_max_size;
1483 ulint field_ext_max_size;
1498 if (field_max_size) {
1504 field_ext_max_size = 0;
1505 goto add_field_size;
1509 field_ext_max_size = field_max_size < 256 ? 1 : 2;
1525 field_ext_max_size = 1;
1532 rec_max_size += field_ext_max_size;
1535 rec_max_size += field_max_size;
1538 if (UNIV_UNLIKELY(rec_max_size >= page_rec_max)) {
1550 && rec_max_size + REC_NODE_PTR_SIZE >= page_ptr_max) {
1564 dict_index_add_to_cache(
1581 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
1587 if (!dict_index_find_cols(table, index)) {
1589 dict_mem_index_free(index);
1590 return(DB_CORRUPTION);
1597 new_index = dict_index_build_internal_clust(table, index);
1599 new_index = dict_index_build_internal_non_clust(table, index);
1607 if (strict && dict_index_too_big_for_tree(table, new_index)) {
1609 dict_mem_index_free(new_index);
1610 dict_mem_index_free(index);
1611 return(DB_TOO_BIG_RECORD);
1617 n_ord = new_index->
n_uniq;
1638 #if DICT_TF_FORMAT_ZIP != DICT_TF_FORMAT_MAX
1639 # error "DICT_TF_FORMAT_ZIP != DICT_TF_FORMAT_MAX"
1643 for (i = 0; i < n_ord; i++) {
1645 = dict_index_get_nth_field(new_index, i);
1665 if (dict_index_too_big_for_undo(table, new_index)) {
1679 for (i = 0; i < n_ord; i++) {
1681 dict_index_get_nth_field(new_index, i)->col->ord_part = 1;
1687 new_index->
table = table;
1695 new_index->
page = page_no;
1704 *
sizeof(ib_int64_t)));
1706 new_index->stat_n_non_null_key_vals =
static_cast<ib_int64_t *
>(
mem_heap_zalloc(
1709 *
sizeof(*new_index->stat_n_non_null_key_vals)));
1722 dict_mem_index_free(index);
1731 dict_index_remove_from_cache(
1740 ut_ad(table && index);
1741 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
1742 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
1760 ulint ref_count = btr_search_info_get_ref_count(info);
1761 if (ref_count == 0) {
1769 if (retries % 500 == 0) {
1771 fprintf(stderr,
"InnoDB: Error: Waited for"
1772 " %lu secs for hash index"
1773 " ref_count (%lu) to drop"
1785 if (retries >= 60000) {
1790 rw_lock_free(&index->
lock);
1799 dict_sys->
size -= size;
1801 dict_mem_index_free(index);
1810 dict_index_find_cols(
1817 ut_ad(table && index);
1818 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
1821 for (i = 0; i < index->
n_fields; i++) {
1823 dict_field_t* field = dict_index_get_nth_field(index, i);
1825 for (j = 0; j < table->
n_cols; j++) {
1826 if (!strcmp(dict_table_get_col_name(table, j),
1828 field->
col = dict_table_get_nth_col(table, j);
1836 fputs(
"InnoDB: Error: no matching column for ", stderr);
1838 fputs(
" in ", stderr);
1839 dict_index_name_print(stderr, NULL, index);
1840 fputs(
"!\n", stderr);
1864 const char* col_name;
1868 dict_mem_index_add_field(index, col_name, prefix_len);
1870 field = dict_index_get_nth_field(index, index->
n_def - 1);
1876 if (prefix_len && field->
fixed_len > prefix_len) {
1877 field->
fixed_len = (
unsigned int) prefix_len;
1887 #if DICT_MAX_INDEX_COL_LEN != 1024
1891 # error "DICT_MAX_INDEX_COL_LEN != 1024"
1894 if (!(col->
prtype & DATA_NOT_NULL)) {
1899 #ifndef UNIV_HOTBACKUP
1917 for (i = start; i < end; i++) {
1919 field = dict_index_get_nth_field(index2, i);
1920 dict_index_add_col(index1, table, field->
col,
1929 dict_index_copy_types(
1944 for (i = 0; i < n_fields; i++) {
1948 ifield = dict_index_get_nth_field(index, i);
1949 dfield_type = dfield_get_type(dtuple_get_nth_field(tuple, i));
1960 dict_table_copy_types(
1969 dfield_t* dfield = dtuple_get_nth_field(tuple, i);
1970 dtype_t* dtype = dfield_get_type(dfield);
1983 dict_index_build_internal_clust(
1996 ut_ad(table && index);
1999 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
2002 new_index = dict_mem_index_create(table->
name,
2012 new_index->
id = index->
id;
2015 dict_index_copy(new_index, index, table, 0, index->
n_fields);
2020 new_index->
n_uniq = REC_MAX_N_FIELDS;
2037 trx_id_pos = new_index->
n_def;
2039 #if DATA_ROW_ID != 0
2040 # error "DATA_ROW_ID != 0"
2042 #if DATA_TRX_ID != 1
2043 # error "DATA_TRX_ID != 1"
2045 #if DATA_ROLL_PTR != 2
2046 # error "DATA_ROLL_PTR != 2"
2050 dict_index_add_col(new_index, table,
2051 dict_table_get_sys_col(
2052 table, DATA_ROW_ID),
2057 dict_index_add_col(new_index, table,
2058 dict_table_get_sys_col(table, DATA_TRX_ID),
2061 dict_index_add_col(new_index, table,
2062 dict_table_get_sys_col(table,
2066 for (i = 0; i < trx_id_pos; i++) {
2072 if (fixed_size == 0) {
2078 if (dict_index_get_nth_field(new_index, i)->prefix_len
2092 indexed =
static_cast<unsigned long *
>(indexed_ptr);
2095 for (i = 0; i < new_index->
n_def; i++) {
2097 field = dict_index_get_nth_field(new_index, i);
2104 indexed[field->
col->
ind] = TRUE;
2110 for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->
n_cols; i++) {
2112 dict_col_t* col = dict_table_get_nth_col(table, i);
2115 if (!indexed[col->
ind]) {
2116 dict_index_add_col(new_index, table, col, 0);
2125 new_index->
cached = TRUE;
2136 dict_index_build_internal_non_clust(
2148 ut_ad(table && index);
2151 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
2161 new_index = dict_mem_index_create(
2170 new_index->
id = index->
id;
2173 dict_index_copy(new_index, index, table, 0, index->
n_fields);
2177 indexed =
static_cast<unsigned long *
>(indexed_ptr);
2180 for (i = 0; i < new_index->
n_def; i++) {
2182 field = dict_index_get_nth_field(new_index, i);
2189 indexed[field->
col->
ind] = TRUE;
2196 for (i = 0; i < clust_index->
n_uniq; i++) {
2198 field = dict_index_get_nth_field(clust_index, i);
2200 if (!indexed[field->
col->
ind]) {
2201 dict_index_add_col(new_index, table, field->
col,
2219 new_index->
cached = TRUE;
2231 dict_table_is_referenced_by_foreign_key(
2245 dict_table_get_referenced_constraint(
2252 ut_ad(index != NULL);
2253 ut_ad(table != NULL);
2276 dict_table_get_foreign_constraint(
2283 ut_ad(index != NULL);
2284 ut_ad(table != NULL);
2315 dict_foreign_remove_from_cache(
2334 dict_foreign_free(foreign);
2384 dict_foreign_find_index(
2387 const char** columns,
2391 ibool check_charsets,
2400 index = dict_table_get_first_index(table);
2402 while (index != NULL) {
2412 for (i = 0; i < n_cols; i++) {
2414 const char* col_name;
2416 field = dict_index_get_nth_field(index, i);
2418 col_name = dict_table_get_col_name(
2434 && (field->
col->
prtype & DATA_NOT_NULL)) {
2457 index = dict_table_get_next_index(index);
2469 dict_foreign_find_equiv_index(
2473 ut_a(foreign != NULL);
2479 return(dict_foreign_find_index(
2492 dict_table_get_index_by_max_id(
2496 const char** columns,
2503 index = dict_table_get_first_index(table);
2505 while (index != NULL) {
2512 for (i = 0; i < n_cols; i++) {
2514 const char* col_name;
2516 field = dict_index_get_nth_field(index, i);
2518 col_name = dict_table_get_col_name(
2522 columns[i], col_name)) {
2532 if (!found || index->
id > found->
id) {
2539 index = dict_table_get_next_index(index);
2549 dict_foreign_error_report_low(
2556 fprintf(file,
" Error in foreign key constraint of table %s:\n",
2564 dict_foreign_error_report(
2570 mutex_enter(&dict_foreign_err_mutex);
2573 fputs(
" Constraint:\n", file);
2574 dict_print_info_on_foreign_key_in_create_format(file, NULL, fk, TRUE);
2577 fputs(
"The index in the foreign key in table is ", file);
2580 "See " REFMAN
"innodb-foreign-key-constraints.html\n"
2581 "for correct foreign key definition.\n",
2584 mutex_exit(&dict_foreign_err_mutex);
2595 dict_foreign_add_to_cache(
2598 ibool check_charsets)
2605 ibool added_to_referenced_list= FALSE;
2606 FILE* ef = dict_foreign_err_file;
2615 ut_a(for_table || ref_table);
2618 for_in_cache = dict_foreign_find(for_table, foreign->
id);
2621 if (!for_in_cache && ref_table) {
2622 for_in_cache = dict_foreign_find(ref_table, foreign->
id);
2629 for_in_cache = foreign;
2633 index = dict_foreign_find_index(
2637 check_charsets, FALSE);
2639 if (index == NULL) {
2640 dict_foreign_error_report(
2642 "there is no index in referenced table"
2643 " which would contain\n"
2644 "the columns as the first columns,"
2645 " or the data types in the\n"
2646 "referenced table do not match"
2647 " the ones in table.");
2649 if (for_in_cache == foreign) {
2653 return(DB_CANNOT_ADD_CONSTRAINT);
2661 added_to_referenced_list = TRUE;
2665 index = dict_foreign_find_index(
2674 if (index == NULL) {
2675 dict_foreign_error_report(
2677 "there is no index in the table"
2678 " which would contain\n"
2679 "the columns as the first columns,"
2680 " or the data types in the\n"
2681 "table do not match"
2682 " the ones in the referenced table\n"
2683 "or one of the ON ... SET NULL columns"
2684 " is declared NOT NULL.");
2686 if (for_in_cache == foreign) {
2687 if (added_to_referenced_list) {
2697 return(DB_CANNOT_ADD_CONSTRAINT);
2724 for (; *ptr; ptr++) {
2725 if (*ptr == quote) {
2731 }
else if (*ptr ==
'`' || *ptr ==
'"' || *ptr ==
'\'') {
2737 for (i = 0;
string[i]; i++) {
2738 if (toupper((
int)(
unsigned char)(ptr[i]))
2739 != toupper((
int)(
unsigned char)
2767 const char* old_ptr = ptr;
2768 const char* old_ptr2;
2772 while (innobase_isspace(cs, *ptr)) {
2778 ptr = dict_scan_to(ptr,
string);
2780 if (*ptr ==
'\0' || old_ptr2 != ptr) {
2806 ibool accept_also_dot)
2819 while (innobase_isspace(cs, *ptr)) {
2828 if (*ptr ==
'`' || *ptr ==
'"') {
2840 if (*ptr == quote) {
2842 if (*ptr != quote) {
2850 while (!innobase_isspace(cs, *ptr) && *ptr !=
'(' && *ptr !=
')'
2851 && (accept_also_dot || *ptr !=
'.')
2852 && *ptr !=
',' && *ptr !=
'\0') {
2860 if (UNIV_UNLIKELY(!heap)) {
2870 if ((*d++ = *s++) == quote) {
2877 ut_ad(s + 1 == ptr);
2929 ptr = dict_scan_id(cs, ptr, heap, name, FALSE, TRUE);
2931 if (*name == NULL) {
2936 if (table == NULL) {
2942 const char* col_name = dict_table_get_col_name(
2949 *column = dict_table_get_nth_col(table, i);
2950 strcpy((
char*) *name, col_name);
2965 dict_scan_table_name(
2973 const char** ref_name)
2976 const char* database_name = NULL;
2977 ulint database_name_len = 0;
2978 const char* table_name = NULL;
2979 ulint table_name_len;
2980 const char* scan_name;
2986 ptr = dict_scan_id(cs, ptr, heap, &scan_name, TRUE, FALSE);
2988 if (scan_name == NULL) {
2998 database_name = scan_name;
2999 database_name_len = strlen(database_name);
3001 ptr = dict_scan_id(cs, ptr, heap, &table_name, TRUE, FALSE);
3003 if (table_name == NULL) {
3017 for (s = scan_name; *s; s++) {
3019 database_name = scan_name;
3020 database_name_len = s - scan_name;
3026 table_name = scan_name;
3029 if (database_name == NULL) {
3032 database_name = name;
3033 database_name_len = dict_get_db_name_len(name);
3036 table_name_len = strlen(table_name);
3039 ref =
static_cast<char *
>(
mem_heap_alloc(heap, database_name_len + table_name_len + 2));
3040 memcpy(ref, database_name, database_name_len);
3041 ref[database_name_len] =
'/';
3042 memcpy(ref + database_name_len + 1, table_name, table_name_len + 1);
3047 if (srv_lower_case_table_names == 2) {
3050 memcpy(ref, database_name, database_name_len);
3051 ref[database_name_len] =
'/';
3052 memcpy(ref + database_name_len + 1, table_name, table_name_len + 1);
3054 if (srv_lower_case_table_names == 1) {
3081 ptr = dict_scan_id(cs, ptr, NULL, &start, FALSE, TRUE);
3100 dict_strip_comments(
3102 const char* sql_string,
3107 const char* eptr = sql_string + sql_length;
3112 str =
static_cast<char *
>(mem_alloc(sql_length + 1));
3119 if (sptr >= eptr || *sptr ==
'\0') {
3123 ut_a(ptr <= str + sql_length);
3128 if (*sptr == quote) {
3135 }
else if (*sptr ==
'"' || *sptr ==
'`' || *sptr ==
'\'') {
3138 }
else if (*sptr ==
'#'
3139 || (sptr[0] ==
'-' && sptr[1] ==
'-'
3140 && sptr[2] ==
' ')) {
3142 if (++sptr >= eptr) {
3156 }
else if (!quote && *sptr ==
'/' && *(sptr + 1) ==
'*') {
3167 if (sptr[1] ==
'/') {
3191 dict_table_get_highest_foreign_id(
3197 ulint biggest_id = 0;
3207 if (
ut_strlen(foreign->
id) > ((
sizeof dict_ibfk) - 1) + len
3210 dict_ibfk, (
sizeof dict_ibfk) - 1)
3211 && foreign->
id[len + ((
sizeof dict_ibfk) - 1)] !=
'0') {
3214 id = strtoul(foreign->
id + len
3215 + ((
sizeof dict_ibfk) - 1),
3217 if (*endp ==
'\0') {
3218 ut_a(
id != biggest_id);
3220 if (
id > biggest_id) {
3236 dict_foreign_report_syntax_err(
3239 const char* start_of_latest_foreign,
3244 FILE* ef = dict_foreign_err_file;
3246 mutex_enter(&dict_foreign_err_mutex);
3247 dict_foreign_error_report_low(ef, name);
3248 fprintf(ef,
"%s:\nSyntax error close to:\n%s\n",
3249 start_of_latest_foreign, ptr);
3250 mutex_exit(&dict_foreign_err_mutex);
3262 dict_create_foreign_constraints_low(
3267 const char* sql_string,
3284 ulint highest_id_so_far = 0;
3287 const char* ptr = sql_string;
3288 const char* start_of_latest_foreign = sql_string;
3289 FILE* ef = dict_foreign_err_file;
3290 const char* constraint_name;
3301 const char* column_names[500];
3302 const char* referenced_table_name;
3308 if (table == NULL) {
3309 mutex_enter(&dict_foreign_err_mutex);
3310 dict_foreign_error_report_low(ef, name);
3312 "Cannot find the table in the internal"
3313 " data dictionary of InnoDB.\n"
3314 "Create table statement:\n%s\n", sql_string);
3315 mutex_exit(&dict_foreign_err_mutex);
3323 ptr = dict_accept(cs, ptr,
"ALTER", &success);
3330 ptr = dict_accept(cs, ptr,
"TABLE", &success);
3339 ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
3340 &success, heap, &referenced_table_name);
3343 "InnoDB: Error: could not find"
3344 " the table being ALTERED in:\n%s\n",
3359 if (table_to_alter == NULL) {
3360 highest_id_so_far = 0;
3362 highest_id_so_far = dict_table_get_highest_foreign_id(
3370 ptr1 = dict_scan_to(ptr,
"CONSTRAINT");
3371 ptr2 = dict_scan_to(ptr,
"FOREIGN");
3373 constraint_name = NULL;
3381 ptr = dict_accept(cs, ptr,
"CONSTRAINT", &success);
3385 if (!innobase_isspace(cs, *ptr) && *ptr !=
'"' && *ptr !=
'`') {
3389 while (innobase_isspace(cs, *ptr)) {
3395 ptr = dict_scan_id(cs, ptr, heap,
3396 &constraint_name, FALSE, FALSE);
3412 return(DB_CANNOT_ADD_CONSTRAINT);
3419 error = dict_create_add_foreigns_to_dictionary(
3420 highest_id_so_far, table, trx);
3424 start_of_latest_foreign = ptr;
3426 ptr = dict_accept(cs, ptr,
"FOREIGN", &success);
3432 if (!innobase_isspace(cs, *ptr)) {
3436 ptr = dict_accept(cs, ptr,
"KEY", &success);
3442 ptr = dict_accept(cs, ptr,
"(", &success);
3447 ptr = dict_skip_word(cs, ptr, &success);
3450 dict_foreign_report_syntax_err(
3451 name, start_of_latest_foreign, ptr);
3453 return(DB_CANNOT_ADD_CONSTRAINT);
3456 ptr = dict_accept(cs, ptr,
"(", &success);
3470 ut_a(i < (
sizeof column_names) /
sizeof *column_names);
3471 ptr = dict_scan_col(cs, ptr, &success, table, columns + i,
3472 heap, column_names + i);
3474 mutex_enter(&dict_foreign_err_mutex);
3475 dict_foreign_error_report_low(ef, name);
3476 fprintf(ef,
"%s:\nCannot resolve column name close to:\n%s\n",
3477 start_of_latest_foreign, ptr);
3478 mutex_exit(&dict_foreign_err_mutex);
3480 return(DB_CANNOT_ADD_CONSTRAINT);
3485 ptr = dict_accept(cs, ptr,
",", &success);
3491 ptr = dict_accept(cs, ptr,
")", &success);
3494 dict_foreign_report_syntax_err(
3495 name, start_of_latest_foreign, ptr);
3496 return(DB_CANNOT_ADD_CONSTRAINT);
3502 index = dict_foreign_find_index(table, column_names, i,
3506 mutex_enter(&dict_foreign_err_mutex);
3507 dict_foreign_error_report_low(ef, name);
3508 fputs(
"There is no index in table ", ef);
3510 fprintf(ef,
" where the columns appear\n"
3511 "as the first columns. Constraint:\n%s\n"
3512 "See " REFMAN
"innodb-foreign-key-constraints.html\n"
3513 "for correct foreign key definition.\n",
3514 start_of_latest_foreign);
3515 mutex_exit(&dict_foreign_err_mutex);
3517 return(DB_CHILD_NO_INDEX);
3519 ptr = dict_accept(cs, ptr,
"REFERENCES", &success);
3521 if (!success || !innobase_isspace(cs, *ptr)) {
3522 dict_foreign_report_syntax_err(
3523 name, start_of_latest_foreign, ptr);
3524 return(DB_CANNOT_ADD_CONSTRAINT);
3529 foreign = dict_mem_foreign_create();
3531 if (constraint_name) {
3539 db_len = dict_get_db_name_len(table->
name);
3542 foreign->
heap, db_len + strlen(constraint_name) + 2));
3545 foreign->
id[db_len] =
'/';
3546 strcpy(foreign->
id + db_len + 1, constraint_name);
3552 dict_mem_foreign_table_name_lookup_set(foreign, TRUE);
3555 foreign->
n_fields = (
unsigned int) i;
3557 i *
sizeof(
void*)));
3558 for (i = 0; i < foreign->
n_fields; i++) {
3561 dict_table_get_col_name(table,
3565 ptr = dict_scan_table_name(cs, ptr, &referenced_table, name,
3566 &success, heap, &referenced_table_name);
3571 if (!success || (!referenced_table && trx->check_foreigns)) {
3572 dict_foreign_free(foreign);
3574 mutex_enter(&dict_foreign_err_mutex);
3575 dict_foreign_error_report_low(ef, name);
3576 fprintf(ef,
"%s:\nCannot resolve table name close to:\n"
3578 start_of_latest_foreign, ptr);
3579 mutex_exit(&dict_foreign_err_mutex);
3581 return(DB_CANNOT_ADD_CONSTRAINT);
3584 ptr = dict_accept(cs, ptr,
"(", &success);
3587 dict_foreign_free(foreign);
3588 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
3590 return(DB_CANNOT_ADD_CONSTRAINT);
3597 ptr = dict_scan_col(cs, ptr, &success, referenced_table, columns + i,
3598 heap, column_names + i);
3602 dict_foreign_free(foreign);
3604 mutex_enter(&dict_foreign_err_mutex);
3605 dict_foreign_error_report_low(ef, name);
3606 fprintf(ef,
"%s:\nCannot resolve column name close to:\n"
3608 start_of_latest_foreign, ptr);
3609 mutex_exit(&dict_foreign_err_mutex);
3611 return(DB_CANNOT_ADD_CONSTRAINT);
3614 ptr = dict_accept(cs, ptr,
",", &success);
3620 ptr = dict_accept(cs, ptr,
")", &success);
3622 if (!success || foreign->
n_fields != i) {
3623 dict_foreign_free(foreign);
3625 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
3627 return(DB_CANNOT_ADD_CONSTRAINT);
3636 ptr = dict_accept(cs, ptr,
"ON", &success);
3640 goto try_find_index;
3643 ptr = dict_accept(cs, ptr,
"DELETE", &success);
3646 ptr = dict_accept(cs, ptr,
"UPDATE", &success);
3649 dict_foreign_free(foreign);
3651 dict_foreign_report_syntax_err(
3652 name, start_of_latest_foreign, ptr);
3653 return(DB_CANNOT_ADD_CONSTRAINT);
3656 is_on_delete = FALSE;
3659 is_on_delete = TRUE;
3663 ptr = dict_accept(cs, ptr,
"RESTRICT", &success);
3666 goto scan_on_conditions;
3669 ptr = dict_accept(cs, ptr,
"CASCADE", &success);
3678 goto scan_on_conditions;
3681 ptr = dict_accept(cs, ptr,
"NO", &success);
3684 ptr = dict_accept(cs, ptr,
"ACTION", &success);
3687 dict_foreign_free(foreign);
3688 dict_foreign_report_syntax_err(
3689 name, start_of_latest_foreign, ptr);
3691 return(DB_CANNOT_ADD_CONSTRAINT);
3700 goto scan_on_conditions;
3703 ptr = dict_accept(cs, ptr,
"SET", &success);
3706 dict_foreign_free(foreign);
3707 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
3709 return(DB_CANNOT_ADD_CONSTRAINT);
3712 ptr = dict_accept(cs, ptr,
"NULL", &success);
3715 dict_foreign_free(foreign);
3716 dict_foreign_report_syntax_err(name, start_of_latest_foreign,
3718 return(DB_CANNOT_ADD_CONSTRAINT);
3721 for (j = 0; j < foreign->
n_fields; j++) {
3728 dict_foreign_free(foreign);
3730 mutex_enter(&dict_foreign_err_mutex);
3731 dict_foreign_error_report_low(ef, name);
3733 "You have defined a SET NULL condition"
3734 " though some of the\n"
3735 "columns are defined as NOT NULL.\n",
3736 start_of_latest_foreign);
3737 mutex_exit(&dict_foreign_err_mutex);
3739 return(DB_CANNOT_ADD_CONSTRAINT);
3749 goto scan_on_conditions;
3752 if (n_on_deletes > 1 || n_on_updates > 1) {
3755 dict_foreign_free(foreign);
3757 mutex_enter(&dict_foreign_err_mutex);
3758 dict_foreign_error_report_low(ef, name);
3760 "You have twice an ON DELETE clause"
3761 " or twice an ON UPDATE clause.\n",
3762 start_of_latest_foreign);
3763 mutex_exit(&dict_foreign_err_mutex);
3765 return(DB_CANNOT_ADD_CONSTRAINT);
3772 if (referenced_table) {
3773 index = dict_foreign_find_index(referenced_table,
3778 dict_foreign_free(foreign);
3779 mutex_enter(&dict_foreign_err_mutex);
3780 dict_foreign_error_report_low(ef, name);
3782 "Cannot find an index in the"
3783 " referenced table where the\n"
3784 "referenced columns appear as the"
3785 " first columns, or column types\n"
3786 "in the table and the referenced table"
3787 " do not match for constraint.\n"
3788 "Note that the internal storage type of"
3789 " ENUM and SET changed in\n"
3790 "tables created with >= InnoDB-4.1.12,"
3791 " and such columns in old tables\n"
3792 "cannot be referenced by such columns"
3795 "innodb-foreign-key-constraints.html\n"
3796 "for correct foreign key definition.\n",
3797 start_of_latest_foreign);
3798 mutex_exit(&dict_foreign_err_mutex);
3800 return(DB_PARENT_NO_INDEX);
3803 ut_a(trx->check_foreigns == FALSE);
3811 foreign->
heap, referenced_table_name);
3812 dict_mem_referenced_table_name_lookup_set(foreign, TRUE);
3815 i *
sizeof(
void*)));
3816 for (i = 0; i < foreign->
n_fields; i++) {
3825 if (referenced_table) {
3843 dict_create_foreign_constraints(
3846 const char* sql_string,
3869 str = dict_strip_comments(sql_string, sql_length);
3872 err = dict_create_foreign_constraints_low(
3873 trx, heap, trx->session()->charset(), str, name,
3888 dict_foreign_parse_drop_constraints(
3896 const char*** constraints_to_drop)
3905 FILE* ef = dict_foreign_err_file;
3911 cs = trx->session()->charset();
3915 *constraints_to_drop =
static_cast<const char **
>(
mem_heap_alloc(heap, 1000 *
sizeof(
char*)));
3917 ptr= trx->session()->getQueryStringCopy(len);
3919 str = dict_strip_comments(ptr, len);
3925 ptr = dict_scan_to(ptr,
"DROP");
3933 ptr = dict_accept(cs, ptr,
"DROP", &success);
3935 if (!innobase_isspace(cs, *ptr)) {
3940 ptr = dict_accept(cs, ptr,
"FOREIGN", &success);
3942 if (!success || !innobase_isspace(cs, *ptr)) {
3947 ptr = dict_accept(cs, ptr,
"KEY", &success);
3954 ptr = dict_scan_id(cs, ptr, heap, &
id, FALSE, TRUE);
3962 (*constraints_to_drop)[*n] = id;
3969 while (foreign != NULL) {
3970 if (0 == strcmp(foreign->
id,
id)
3971 || (strchr(foreign->
id,
'/')
3973 dict_remove_db_name(foreign->
id)))) {
3981 if (foreign == NULL) {
3982 mutex_enter(&dict_foreign_err_mutex);
3985 fputs(
" Error in dropping of a foreign key constraint"
3989 "in SQL command\n", ef);
3991 fputs(
"\nCannot find a constraint with the given id ", ef);
3994 mutex_exit(&dict_foreign_err_mutex);
3998 return(DB_CANNOT_DROP_CONSTRAINT);
4004 mutex_enter(&dict_foreign_err_mutex);
4007 fputs(
" Syntax error in dropping of a"
4008 " foreign key constraint of table ", ef);
4011 "close to:\n%s\n in SQL command\n%s\n", ptr, str);
4012 mutex_exit(&dict_foreign_err_mutex);
4016 return(DB_CANNOT_DROP_CONSTRAINT);
4027 dict_index_get_if_in_cache_low(
4029 index_id_t index_id)
4033 return(dict_index_find_on_id_low(index_id));
4036 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
4042 dict_index_get_if_in_cache(
4044 index_id_t index_id)
4048 if (dict_sys == NULL) {
4052 mutex_enter(&(dict_sys->
mutex));
4054 index = dict_index_get_if_in_cache_low(index_id);
4056 mutex_exit(&(dict_sys->
mutex));
4069 dict_index_check_search_tuple(
4086 dict_index_build_node_ptr(
4130 dict_index_copy_types(tuple, index, n_unique);
4136 field = dtuple_get_nth_field(tuple, n_unique);
4139 dtype_set(dfield_get_type(field), DATA_SYS_CHILD, DATA_NOT_NULL, 4);
4143 | REC_STATUS_NODE_PTR);
4156 dict_index_copy_rec_order_prefix(
4168 UNIV_PREFETCH_R(rec);
4186 dict_index_build_data_tuple(
4200 dict_index_copy_types(tuple, index, n_fields);
4213 dict_index_calc_min_rec_len(
4223 sum = REC_N_NEW_EXTRA_BYTES;
4231 sum += size < 128 ? 1 : 2;
4233 if (!(col->
prtype & DATA_NOT_NULL)) {
4255 sum += REC_N_OLD_EXTRA_BYTES;
4265 dict_update_statistics(
4268 ibool only_calc_if_missing_stats)
4274 ulint sum_of_index_sizes = 0;
4279 " InnoDB: cannot calculate statistics for table %s\n"
4280 "InnoDB: because the .ibd file is missing. For help,"
4281 " please refer to\n"
4282 "InnoDB: " REFMAN
"innodb-troubleshooting.html\n",
4291 index = dict_table_get_first_index(table);
4293 if (index == NULL) {
4299 dict_table_stats_lock(table, RW_X_LATCH);
4302 dict_table_stats_unlock(table, RW_X_LATCH);
4312 size = btr_get_size(index, BTR_TOTAL_SIZE);
4316 sum_of_index_sizes += size;
4318 size = btr_get_size(index, BTR_N_LEAF_PAGES);
4327 btr_estimate_number_of_different_key_vals(index);
4337 sum_of_index_sizes++;
4344 memset(index->stat_n_non_null_key_vals, 0,
4346 *
sizeof(*index->stat_n_non_null_key_vals));
4349 index = dict_table_get_next_index(index);
4352 index = dict_table_get_first_index(table);
4366 dict_table_stats_unlock(table, RW_X_LATCH);
4373 dict_foreign_print_low(
4381 fprintf(stderr,
" FOREIGN KEY CONSTRAINT %s: %s (",
4384 for (i = 0; i < foreign->
n_fields; i++) {
4388 fprintf(stderr,
" )\n"
4392 for (i = 0; i < foreign->
n_fields; i++) {
4396 fputs(
" )\n", stderr);
4407 mutex_enter(&(dict_sys->
mutex));
4408 dict_table_print_low(table);
4409 mutex_exit(&(dict_sys->
mutex));
4416 dict_table_print_by_name(
4422 mutex_enter(&(dict_sys->
mutex));
4428 dict_table_print_low(table);
4429 mutex_exit(&(dict_sys->
mutex));
4436 dict_table_print_low(
4446 dict_update_statistics(table, FALSE );
4448 dict_table_stats_lock(table, RW_S_LATCH);
4451 "--------------------------------------\n"
4452 "TABLE: name %s, id %llu, flags %lx, columns %lu,"
4453 " indexes %lu, appr.rows %lu\n"
4457 (ulong) table->
flags,
4462 for (i = 0; i < (ulint) table->
n_cols; i++) {
4463 dict_col_print_low(table, dict_table_get_nth_col(table, i));
4464 fputs(
"; ", stderr);
4471 while (index != NULL) {
4472 dict_index_print_low(index);
4476 dict_table_stats_unlock(table, RW_S_LATCH);
4480 while (foreign != NULL) {
4481 dict_foreign_print_low(foreign);
4487 while (foreign != NULL) {
4488 dict_foreign_print_low(foreign);
4507 fprintf(stderr,
"%s: ", dict_table_get_col_name(table,
4517 dict_index_print_low(
4534 " INDEX: name %s, id %llu, fields %lu/%lu,"
4535 " uniq %lu, type %lu\n"
4536 " root page %lu, appr.key vals %lu,"
4537 " leaf pages %lu, size pages %lu\n"
4544 (ulong) index->
type,
4545 (ulong) index->
page,
4550 for (i = 0; i < index->
n_fields; i++) {
4551 dict_field_print_low(dict_index_get_nth_field(index, i));
4556 #ifdef UNIV_BTR_PRINT
4557 btr_print_size(index);
4559 btr_print_index(index, 7);
4567 dict_field_print_low(
4573 fprintf(stderr,
" %s", field->
name);
4576 fprintf(stderr,
"(%lu)", (ulong) field->
prefix_len);
4585 dict_print_info_on_foreign_key_in_create_format(
4592 const char* stripped_id;
4595 if (strchr(foreign->
id,
'/')) {
4597 stripped_id = foreign->
id + 1
4598 + dict_get_db_name_len(foreign->
id);
4600 stripped_id = foreign->
id;
4612 fputs(
" CONSTRAINT ", file);
4614 fputs(
" FOREIGN KEY (", file);
4618 if (++i < foreign->n_fields) {
4625 fputs(
") REFERENCES ", file);
4631 dict_remove_db_name(
4644 if (++i < foreign->n_fields) {
4654 fputs(
" ON DELETE CASCADE", file);
4658 fputs(
" ON DELETE SET NULL", file);
4662 fputs(
" ON DELETE NO ACTION", file);
4666 fputs(
" ON UPDATE CASCADE", file);
4670 fputs(
" ON UPDATE SET NULL", file);
4674 fputs(
" ON UPDATE NO ACTION", file);
4682 dict_print_info_on_foreign_keys(
4684 ibool create_table_format,
4694 mutex_enter(&(dict_sys->
mutex));
4698 if (foreign == NULL) {
4699 mutex_exit(&(dict_sys->
mutex));
4704 while (foreign != NULL) {
4705 if (create_table_format) {
4706 dict_print_info_on_foreign_key_in_create_format(
4707 file, trx, foreign, TRUE);
4712 for (i = 0; i < foreign->
n_fields; i++) {
4721 fputs(
") REFER ", file);
4726 for (i = 0; i < foreign->
n_fields; i++) {
4738 fputs(
" ON DELETE CASCADE", file);
4742 fputs(
" ON DELETE SET NULL", file);
4746 fputs(
" ON DELETE NO ACTION", file);
4750 fputs(
" ON UPDATE CASCADE", file);
4754 fputs(
" ON UPDATE SET NULL", file);
4758 fputs(
" ON UPDATE NO ACTION", file);
4765 mutex_exit(&(dict_sys->
mutex));
4772 dict_index_name_print(
4778 fputs(
"index ", file);
4780 fputs(
" of table ", file);
4795 table = dict_mem_table_create(
"SYS_DUMMY1", DICT_HDR_SPACE, 1, 0);
4796 dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
4797 DATA_ENGLISH | DATA_NOT_NULL, 8);
4799 dict_ind_redundant = dict_mem_index_create(
"SYS_DUMMY1",
"SYS_DUMMY1",
4800 DICT_HDR_SPACE, 0, 1);
4801 dict_index_add_col(dict_ind_redundant, table,
4802 dict_table_get_nth_col(table, 0), 0);
4803 dict_ind_redundant->
table = table;
4805 table = dict_mem_table_create(
"SYS_DUMMY2",
4807 dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
4808 DATA_ENGLISH | DATA_NOT_NULL, 8);
4809 dict_ind_compact = dict_mem_index_create(
"SYS_DUMMY2",
"SYS_DUMMY2",
4810 DICT_HDR_SPACE, 0, 1);
4811 dict_index_add_col(dict_ind_compact, table,
4812 dict_table_get_nth_col(table, 0), 0);
4813 dict_ind_compact->
table = table;
4816 dict_ind_redundant->
cached = dict_ind_compact->
cached = TRUE;
4828 table = dict_ind_compact->
table;
4829 dict_mem_index_free(dict_ind_compact);
4830 dict_ind_compact = NULL;
4831 dict_mem_table_free(table);
4833 table = dict_ind_redundant->
table;
4834 dict_mem_index_free(dict_ind_redundant);
4835 dict_ind_redundant = NULL;
4836 dict_mem_table_free(table);
4839 #ifndef UNIV_HOTBACKUP
4845 dict_table_get_index_on_name(
4852 index = dict_table_get_first_index(table);
4854 while (index != NULL) {
4860 index = dict_table_get_next_index(index);
4872 dict_table_replace_index_in_foreign_list(
4886 = dict_foreign_find_equiv_index(foreign);
4893 ut_a(new_index || !trx->check_foreigns);
4906 dict_table_get_index_on_name_and_min_id(
4915 index = dict_table_get_first_index(table);
4917 while (index != NULL) {
4919 if (!min_index || index->
id < min_index->
id) {
4925 index = dict_table_get_next_index(index);
4937 dict_table_check_for_dup_indexes(
4997 ut_a(prev_table->magic_n == DICT_TABLE_MAGIC_N);
5000 mutex_enter(&dict_sys->
mutex);
5002 dict_table_remove_from_cache(prev_table);
5004 mutex_exit(&dict_sys->
mutex);
5016 mutex_free(&dict_sys->
mutex);
5018 rw_lock_free(&dict_operation_lock);
5019 memset(&dict_operation_lock, 0x0,
sizeof(dict_operation_lock));
5021 mutex_free(&dict_foreign_err_mutex);
5026 for (i = 0; i < DICT_TABLE_STATS_LATCHES_SIZE; i++) {
5027 rw_lock_free(&dict_table_stats_latches[i]);