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;
208 for (; *name1 == *name2; name1++, name2++) {
227 const char* s = strchr(name,
'/');
233 s= strchr(name,
'/');
250 catalog = strchr(name,
'/');
252 s= strchr(catalog+1,
'/');
281 #define GET_TABLE_STATS_LATCH(table) \
282 (&dict_table_stats_latches[ut_fold_ull(table->id) \
283 % DICT_TABLE_STATS_LATCHES_SIZE])
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));
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));
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
477 index = dict_table_get_first_index(table);
480 if (
id == index->
id) {
486 index = dict_table_get_next_index(index);
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
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) {
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);
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
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)
755 if (inc_mysql_count && table) {
784 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
794 DATA_ROW_ID | DATA_NOT_NULL,
797 #error "DATA_ROW_ID != 0"
800 DATA_TRX_ID | DATA_NOT_NULL,
803 #error "DATA_TRX_ID != 1"
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
835 #define BIG_ROW_SIZE 1024
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;
929 index = dict_table_get_first_index(table);
932 if (
id == index->
id) {
938 index = dict_table_get_next_index(index);
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);
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);
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) {
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);
1143 db_len + strlen(old_id) + 1));
1151 strcpy(foreign->
id + db_len,
1163 while (foreign != NULL) {
1196 ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
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) {
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) {
1581 ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
1587 if (!dict_index_find_cols(table, 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)) {
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)));
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);
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);
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++) {
1828 field->
col = dict_table_get_nth_col(table, j);
1836 fputs(
"InnoDB: Error: no matching column for ", stderr);
1838 fputs(
" in ", stderr);
1840 fputs(
"!\n", stderr);
1864 const char* col_name;
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);
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));
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);
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"
2051 dict_table_get_sys_col(
2052 table, DATA_ROW_ID),
2058 dict_table_get_sys_col(table, DATA_TRX_ID),
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]) {
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);
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]) {
2219 new_index->
cached = TRUE;
2252 ut_ad(index != NULL);
2253 ut_ad(table != NULL);
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);
2434 && (field->
col->
prtype & DATA_NOT_NULL)) {
2457 index = dict_table_get_next_index(index);
2473 ut_a(foreign != NULL);
2479 return(dict_foreign_find_index(
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);
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);
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);
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) {
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;
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);
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);
3531 if (constraint_name) {
3542 foreign->
heap, db_len + strlen(constraint_name) + 2));
3545 foreign->
id[db_len] =
'/';
3546 strcpy(foreign->
id + db_len + 1, constraint_name);
3555 foreign->
n_fields = (
unsigned int) i;
3557 i *
sizeof(
void*)));
3558 for (i = 0; i < foreign->
n_fields; i++) {
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);
3815 i *
sizeof(
void*)));
3816 for (i = 0; i < foreign->
n_fields; i++) {
3825 if (referenced_table) {
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,
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,
'/')
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);
4029 index_id_t index_id)
4036 #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
4042 dict_index_get_if_in_cache(
4044 index_id_t index_id)
4069 dict_index_check_search_tuple(
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);
4168 UNIV_PREFETCH_R(rec);
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;
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) {
4316 sum_of_index_sizes += size;
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);
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);
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);
4480 while (foreign != NULL) {
4481 dict_foreign_print_low(foreign);
4487 while (foreign != NULL) {
4488 dict_foreign_print_low(foreign);
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);
4592 const char* stripped_id;
4595 if (strchr(foreign->
id,
'/')) {
4597 stripped_id = foreign->
id + 1
4600 stripped_id = foreign->
id;
4612 fputs(
" CONSTRAINT ", file);
4614 fputs(
" FOREIGN KEY (", file);
4618 if (++i < foreign->n_fields) {
4625 fputs(
") REFERENCES ", file);
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);
4684 ibool create_table_format,
4698 if (foreign == NULL) {
4704 while (foreign != NULL) {
4705 if (create_table_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);
4778 fputs(
"index ", file);
4780 fputs(
" of table ", file);
4797 DATA_ENGLISH | DATA_NOT_NULL, 8);
4800 DICT_HDR_SPACE, 0, 1);
4802 dict_table_get_nth_col(table, 0), 0);
4808 DATA_ENGLISH | DATA_NOT_NULL, 8);
4810 DICT_HDR_SPACE, 0, 1);
4812 dict_table_get_nth_col(table, 0), 0);
4839 #ifndef UNIV_HOTBACKUP
4852 index = dict_table_get_first_index(table);
4854 while (index != NULL) {
4860 index = dict_table_get_next_index(index);
4893 ut_a(new_index || !trx->check_foreigns);
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);
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]);
#define FIL_PAGE_DATA_END
#define UT_LIST_GET_LEN(BASE)
#define TRX_UNDO_PAGE_HDR
UNIV_INTERN void btr_estimate_number_of_different_key_vals(dict_index_t *index)
UNIV_INLINE ulint ut_fold_ull(ib_uint64_t d) __attribute__((const ))
FILE * os_file_create_tmpfile(void)
UNIV_INTERN void dict_mem_index_add_field(dict_index_t *index, const char *name, ulint prefix_len)
#define rw_lock_create(K, L, level)
UNIV_INTERN dict_index_t * dict_table_get_index_on_name_and_min_id(dict_table_t *table, const char *name)
UNIV_INTERN void dict_table_add_to_cache(dict_table_t *table, mem_heap_t *heap)
UNIV_INTERN void dict_print_info_on_foreign_keys(ibool create_table_format, FILE *file, trx_t *trx, dict_table_t *table)
#define UT_LIST_GET_NEXT(NAME, N)
UNIV_INTERN void innobase_convert_from_table_id(const void *, char *to, const char *from, ulint len)
UNIV_INTERN void * ut_realloc(void *ptr, ulint size)
UNIV_INTERN rec_t * rec_copy_prefix_to_buf(const rec_t *rec, const dict_index_t *index, ulint n_fields, byte **buf, ulint *buf_size)
UNIV_INTERN void rec_copy_prefix_to_dtuple(dtuple_t *tuple, const rec_t *rec, const dict_index_t *index, ulint n_fields, mem_heap_t *heap)
UNIV_INTERN ulint dict_create_add_foreigns_to_dictionary(ulint start_id, dict_table_t *table, trx_t *trx)
UNIV_INTERN dtuple_t * dict_index_build_data_tuple(dict_index_t *index, rec_t *rec, ulint n_fields, mem_heap_t *heap)
ulint stat_modified_counter
UNIV_INTERN const char * dict_table_get_col_name(const dict_table_t *table, ulint col_nr)
UNIV_INTERN dtuple_t * dict_index_build_node_ptr(const dict_index_t *index, const rec_t *rec, ulint page_no, mem_heap_t *heap, ulint level)
UNIV_INLINE ulint dict_col_get_max_size(const dict_col_t *col)
UNIV_INTERN ulint dict_index_get_nth_field_pos(const dict_index_t *index, const dict_index_t *index2, ulint n)
char * foreign_table_name_lookup
UNIV_INLINE void mach_write_to_4(byte *b, ulint n)
UNIV_INLINE ulint dict_index_get_n_fields(const dict_index_t *index)
UNIV_INTERN ulint dict_index_calc_min_rec_len(const dict_index_t *index)
char * foreign_table_name
UNIV_INTERN void dict_print_info_on_foreign_key_in_create_format(FILE *file, trx_t *trx, dict_foreign_t *foreign, ibool add_newline)
UNIV_INTERN void dict_table_replace_index_in_foreign_list(dict_table_t *table, dict_index_t *index, const trx_t *trx)
UNIV_INLINE dict_table_t * dict_table_get_on_id_low(table_id_t table_id)
#define DICT_FOREIGN_ON_DELETE_NO_ACTION
UNIV_INTERN dict_foreign_t * dict_table_get_referenced_constraint(dict_table_t *table, dict_index_t *index)
UNIV_INLINE dtuple_t * dtuple_create(mem_heap_t *heap, ulint n_fields)
UNIV_INTERN void dict_table_change_id_in_cache(dict_table_t *table, table_id_t new_id)
UNIV_INLINE ulint rec_get_n_fields_old(const rec_t *rec)
UNIV_INTERN void dict_mutex_exit_for_mysql(void)
UNIV_INLINE ulint mem_heap_get_size(mem_heap_t *heap)
UNIV_INTERN void ut_print_filename(FILE *f, const char *name)
char * referenced_table_name_lookup
UNIV_INLINE void * ut_memcpy(void *dest, const void *sour, ulint n)
#define DICT_FOREIGN_ON_UPDATE_NO_ACTION
UNIV_INTERN ibool dict_tables_have_same_db(const char *name1, const char *name2)
UNIV_INLINE ibool dict_table_is_comp(const dict_table_t *table)
UNIV_INTERN void dict_table_print_low(dict_table_t *table)
UNIV_INLINE ulint dict_col_get_clust_pos(const dict_col_t *col, const dict_index_t *clust_index)
UNIV_INTERN void dict_index_add_col(dict_index_t *index, const dict_table_t *table, dict_col_t *col, ulint prefix_len)
UNIV_INTERN dict_index_t * dict_mem_index_create(const char *table_name, const char *index_name, ulint space, ulint type, ulint n_fields)
UNIV_INTERN void dict_mem_table_free(dict_table_t *table)
#define DICT_TF_FORMAT_51
UNIV_INTERN hash_table_t * hash_create(ulint n)
#define DICT_FOREIGN_ON_UPDATE_CASCADE
UNIV_INTERN ulint dict_index_get_nth_col_pos(const dict_index_t *index, ulint n)
#define DICT_FOREIGN_ON_DELETE_SET_NULL
#define DICT_TF_FORMAT_ZIP
#define mem_heap_free(heap)
UNIV_INLINE ulint dict_col_get_fixed_size(const dict_col_t *col, ulint comp)
UNIV_INTERN ibool fil_rename_tablespace(const char *old_name, ulint id, const char *new_name)
UNIV_INTERN void dict_update_statistics(dict_table_t *table, ibool only_calc_if_missing_stats)
UNIV_INLINE void dict_col_copy_type(const dict_col_t *col, dtype_t *type)
UNIV_INLINE dict_table_t * dict_table_get_low(const char *table_name)
UNIV_INLINE const dict_col_t * dict_index_get_nth_col(const dict_index_t *index, ulint pos)
UNIV_INTERN void dict_index_copy_types(dtuple_t *tuple, const dict_index_t *index, ulint n_fields)
char * referenced_table_name
#define HASH_INSERT(TYPE, NAME, TABLE, FOLD, DATA)
unsigned n_user_defined_cols
unsigned stat_initialized
UNIV_INLINE ulint dtuple_get_n_fields(const dtuple_t *tuple)
UNIV_INTERN dict_table_t * dict_table_get_on_id(table_id_t table_id, trx_t *trx)
UNIV_INTERN ulint dict_get_db_name_len(const char *name)
dict_index_t * foreign_index
UNIV_INTERN void dict_table_copy_types(dtuple_t *tuple, const dict_table_t *table)
#define DICT_MAX_INDEX_COL_LEN
DICT_MAX_INDEX_COL_LEN is measured in bytes and is the maximum indexed column length (or indexed pref...
UNIV_INTERN char * mem_heap_strdup(mem_heap_t *heap, const char *str)
UNIV_INTERN ibool dict_index_contains_col_or_prefix(const dict_index_t *index, ulint n)
UNIV_INTERN dict_index_t * dict_table_get_index_on_name(dict_table_t *table, const char *name)
UNIV_INTERN void dict_table_autoinc_update_if_greater(dict_table_t *table, ib_uint64_t value)
#define HASH_GET_NEXT(NAME, DATA)
UNIV_INTERN void dict_close(void)
UNIV_INTERN void hash_table_free(hash_table_t *table)
UNIV_INLINE ulint dict_index_get_n_unique_in_tree(const dict_index_t *index)
UNIV_INTERN btr_search_t * btr_search_info_create(mem_heap_t *heap)
UNIV_INTERN dict_index_t * dict_index_find_on_id_low(index_id_t id)
#define DICT_FOREIGN_ON_DELETE_CASCADE
const char * dict_remove_db_name(const char *name)
UNIV_INTERN void dict_table_print_by_name(const char *name)
hash_table_t * table_id_hash
#define UT_LIST_REMOVE(NAME, BASE, N)
UNIV_INLINE void dfield_set_data(dfield_t *field, const void *data, ulint len)
UNIV_INLINE ulint dict_table_zip_size(const dict_table_t *table)
const char ** referenced_col_names
UNIV_INLINE ulint dict_table_get_format(const dict_table_t *table)
UNIV_INTERN ibool dict_table_rename_in_cache(dict_table_t *table, const char *new_name, ibool rename_also_foreigns)
#define HASH_GET_FIRST(TABLE, HASH_VAL)
ib_int64_t * stat_n_diff_key_vals
UNIV_INTERN void os_thread_sleep(ulint tm)
UNIV_INTERN dict_table_t * dict_mem_table_create(const char *name, ulint space, ulint n_cols, ulint flags)
UNIV_INTERN dict_index_t * dict_index_get_if_in_cache_low(index_id_t index_id)
UNIV_INLINE char * mem_heap_strdupl(mem_heap_t *heap, const char *str, ulint len)
UNIV_INLINE ulint dict_col_get_no(const dict_col_t *col)
UNIV_INLINE ulint dict_index_is_clust(const dict_index_t *index) __attribute__((pure))
UNIV_INLINE ulint dtuple_get_n_fields_cmp(const dtuple_t *tuple)
UNIV_INTERN ibool dtuple_check_typed(const dtuple_t *tuple)
UNIV_INTERN void dict_mutex_enter_for_mysql(void)
ulint dict_operation_lock_mode
ulint stat_sum_of_other_index_sizes
UNIV_INTERN void dict_table_add_system_columns(dict_table_t *table, mem_heap_t *heap)
UNIV_INLINE ulint dict_index_get_n_ordering_defined_by_user(const dict_index_t *index)
UNIV_INTERN void dict_table_autoinc_initialize(dict_table_t *table, ib_uint64_t value)
UNIV_INLINE void dtuple_set_info_bits(dtuple_t *tuple, ulint info_bits)
dict_index_t * dict_ind_compact
UNIV_INTERN void ut_print_name(FILE *f, struct trx_struct *trx, ibool table_id, const char *name)
UNIV_INLINE const dict_col_t * dict_field_get_col(const dict_field_t *field)
ulint stat_clustered_index_size
btr_search_t * search_info
UNIV_INLINE void * mem_heap_alloc(mem_heap_t *heap, ulint n)
#define mem_heap_create(N)
UNIV_INLINE void * mem_heap_zalloc(mem_heap_t *heap, ulint n)
UNIV_INTERN void dict_mem_table_add_col(dict_table_t *table, mem_heap_t *heap, const char *name, ulint mtype, ulint prtype, ulint len)
UNIV_INTERN void dict_ind_init(void)
UNIV_INLINE ulint dtuple_get_info_bits(const dtuple_t *tuple)
UNIV_INLINE dict_table_t * dict_table_check_if_in_cache_low(const char *table_name)
ulint n_mysql_handles_opened
#define UT_LIST_ADD_LAST(NAME, BASE, N)
UNIV_INTERN ib_uint64_t dict_table_autoinc_read(const dict_table_t *table)
#define UT_LIST_GET_FIRST(BASE)
UNIV_INTERN ulint dict_index_add_to_cache(dict_table_t *table, dict_index_t *index, ulint page_no, ibool strict)
UNIV_INTERN void dict_mem_foreign_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
UNIV_INTERN dict_index_t * dict_table_get_index_by_max_id(dict_table_t *table, const char *name, const char **columns, ulint n_cols)
#define rw_lock_s_lock(M)
UNIV_INTERN dict_foreign_t * dict_table_get_foreign_constraint(dict_table_t *table, dict_index_t *index)
UNIV_INTERN void dict_mem_index_free(dict_index_t *index)
#define DICT_FOREIGN_ON_UPDATE_SET_NULL
dict_table_t * referenced_table
#define HASH_SEARCH(NAME, TABLE, FOLD, TYPE, DATA, ASSERTION, TEST)
UNIV_INTERN void dict_table_stats_lock(const dict_table_t *table, ulint latch_mode)
unsigned ibd_file_missing
#define TRX_UNDO_PAGE_HDR_SIZE
UNIV_INLINE void dtuple_set_n_fields_cmp(dtuple_t *tuple, ulint n_fields_cmp)
UNIV_INLINE ulint dict_table_get_n_cols(const dict_table_t *table)
UNIV_INTERN void dict_table_stats_unlock(const dict_table_t *table, ulint latch_mode)
#define UT_LIST_INIT(BASE)
UNIV_INTERN void dict_table_print(dict_table_t *table)
UNIV_INLINE ulint ut_fold_string(const char *str) __attribute__((pure))
UNIV_INTERN int innobase_strcasecmp(const char *a, const char *b)
#define BTR_EXTERN_FIELD_REF_SIZE
UNIV_INLINE char * mem_strdup(const char *str)
UNIV_INLINE ulint dict_index_get_n_unique(const dict_index_t *index)
UNIV_INTERN void innobase_casedn_str(char *a)
UNIV_INTERN void dict_table_decrement_handle_count(dict_table_t *table, ibool dict_locked)
UNIV_INTERN ulint dict_foreign_parse_drop_constraints(mem_heap_t *heap, trx_t *trx, dict_table_t *table, ulint *n, const char ***constraints_to_drop)
UNIV_INLINE void dfield_set_null(dfield_t *field)
#define UT_LIST_ADD_FIRST(NAME, BASE, N)
static const std::string srv_mysql50_table_name_prefix("#mysql50#")
UNIV_INTERN dict_foreign_t * dict_mem_foreign_create(void)
UNIV_INTERN void ut_print_timestamp(FILE *file)
UNIV_INLINE void dtype_set(dtype_t *type, ulint mtype, ulint prtype, ulint len)
UNIV_INTERN void dict_table_autoinc_lock(dict_table_t *table)
UNIV_INTERN ulint btr_get_size(dict_index_t *index, ulint flag)
UNIV_INTERN ulint page_zip_empty_size(ulint n_fields, ulint zip_size) __attribute__((const ))
UNIV_INLINE ulint dict_index_is_unique(const dict_index_t *index) __attribute__((pure))
UNIV_INTERN ibool cmp_cols_are_equal(const dict_col_t *col1, const dict_col_t *col2, ibool check_charsets)
drizzled::Session * mysql_thd
UNIV_INLINE void dtuple_set_types_binary(dtuple_t *tuple, ulint n)
UNIV_INTERN ulint dict_table_get_nth_col_pos(const dict_table_t *table, ulint n)
hash_table_t * table_hash
UNIV_INTERN ulint dict_create_foreign_constraints(trx_t *trx, const char *sql_string, size_t sql_length, const char *name, ibool reject_fks)
const char * dir_path_of_temp_table
UNIV_INTERN void dtype_print(const dtype_t *type)
UNIV_INTERN ibool dict_table_is_referenced_by_foreign_key(const dict_table_t *table)
#define HASH_DELETE(TYPE, NAME, TABLE, FOLD, DATA)
UNIV_INTERN dict_index_t * dict_index_get_on_id_low(dict_table_t *table, index_id_t index_id)
UNIV_INTERN dict_table_t * dict_table_get(const char *table_name, ibool inc_mysql_count)
UNIV_INTERN void dict_table_autoinc_unlock(dict_table_t *table)
UNIV_INLINE ulint page_get_free_space_of_empty(ulint comp) __attribute__((const ))
#define HASH_SEARCH_ALL(NAME, TABLE, TYPE, DATA, ASSERTION, TEST)
UNIV_INTERN void dict_casedn_str(char *a)
dict_table_t * foreign_table
UNIV_INTERN rec_t * dict_index_copy_rec_order_prefix(const dict_index_t *index, const rec_t *rec, ulint *n_fields, byte **buf, ulint *buf_size)
UNIV_INTERN dict_index_t * dict_foreign_find_equiv_index(dict_foreign_t *foreign)
UNIV_INTERN void dict_mem_referenced_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
UNIV_INTERN ibool dict_col_name_is_reserved(const char *name)
UNIV_INTERN void innobase_convert_from_id(const void *, char *to, const char *from, ulint len)
UNIV_INTERN void dict_index_name_print(FILE *file, trx_t *trx, const dict_index_t *index)
UNIV_INLINE int ut_memcmp(const void *str1, const void *str2, ulint n)
UNIV_INTERN void dict_init(void)
const char ** foreign_col_names
#define TEMP_INDEX_PREFIX
#define UT_BITS_IN_BYTES(b)
UNIV_INTERN ulint btr_search_info_get_ref_count(btr_search_t *info)
rw_lock_t dict_operation_lock
the data dictionary rw-latch protecting dict_sys
UNIV_INLINE ulint dict_index_is_ibuf(const dict_index_t *index) __attribute__((pure))
#define UT_LIST_GET_LAST(BASE)
UNIV_INTERN ulint dict_foreign_add_to_cache(dict_foreign_t *foreign, ibool check_charsets)
UNIV_INLINE int ut_strcmp(const char *str1, const char *str2)
UNIV_INLINE ulint buf_pool_get_curr_size(void)
dict_index_t * dict_ind_redundant
UNIV_INLINE ulint hash_get_n_cells(hash_table_t *table)
dict_index_t * referenced_index
UNIV_INLINE ulint ut_strlen(const char *str)
UNIV_INTERN void dict_index_remove_from_cache(dict_table_t *table, dict_index_t *index)
UNIV_INTERN void dict_table_remove_from_cache(dict_table_t *table)
UNIV_INTERN ibool dict_table_col_in_clustered_key(const dict_table_t *table, ulint n)