27 #if defined(BUILD_DRIZZLE)
30 # include "mysql_version.h"
35 #include "dict0load.ic"
51 static const char* SYSTEM_TABLE_NAME[] = {
72 dict_index_get_nth_field(
75 return(strcmp(name, dict_table_get_col_name(table, tmp)) == 0);
84 dict_get_first_table_name_in_db(
110 dfield = dtuple_get_nth_field(tuple, 0);
113 dict_index_copy_types(tuple, sys_index, 1);
115 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
118 rec = btr_pcur_get_rec(&pcur);
130 field = rec_get_nth_field_old(rec, 0, &len);
132 if (len < strlen(name)
133 ||
ut_memcmp(name, field, strlen(name)) != 0) {
147 char* table_name =
mem_strdupl((
char*) field, len);
178 mutex_enter(&kernel_mutex);
179 srv_fatal_semaphore_wait_threshold += 7200;
180 mutex_exit(&kernel_mutex);
183 mutex_enter(&(dict_sys->
mutex));
187 rec = dict_startscan_system(&pcur, &mtr, SYS_TABLES);
192 err_msg = dict_process_sys_tables_rec(
200 dict_table_print_low(table);
203 fprintf(stderr,
" InnoDB: %s\n", err_msg);
209 rec = dict_getnext_system(&pcur, &mtr);
213 mutex_exit(&(dict_sys->
mutex));
217 mutex_enter(&kernel_mutex);
218 srv_fatal_semaphore_wait_threshold -= 7200;
219 mutex_exit(&kernel_mutex);
228 dict_getnext_system_low(
239 rec = btr_pcur_get_rec(pcur);
250 btr_pcur_store_position(pcur, mtr);
260 dict_startscan_system(
265 dict_system_id_t system_id)
271 ut_a(system_id < SYS_NUM_SYSTEM_TABLES);
280 rec = dict_getnext_system_low(pcur, mtr);
302 rec = dict_getnext_system_low(pcur, mtr);
313 dict_process_sys_tables_rec(
318 dict_table_info_t status)
325 const char* err_msg = NULL;
328 field = (
const char*) rec_get_nth_field_old(rec, 0, &len);
341 err_msg =
"Table not found in cache";
344 err_msg = dict_load_table_low(table_name, rec, table);
352 && dict_table_get_first_index(*table)) {
356 dict_update_statistics(*table,
371 dict_process_sys_indexes_rec(
376 table_id_t* table_id)
384 err_msg = dict_load_index_low(buf, NULL,
385 heap, rec, FALSE, &index);
397 dict_process_sys_columns_rec(
402 table_id_t* table_id,
403 const char** col_name)
408 err_msg = dict_load_column_low(NULL, heap, column,
409 table_id, col_name, rec);
419 dict_process_sys_fields_rec(
426 index_id_t* index_id,
435 last_index_id =
static_cast<unsigned char *
>(
mem_heap_alloc(heap, 8));
438 err_msg = dict_load_field_low(buf, NULL, sys_field,
439 pos, last_index_id, heap, rec);
454 dict_process_sys_foreign_rec(
463 ulint n_fields_and_type;
466 return(
"delete-marked record in SYS_FOREIGN");
470 return(
"wrong number of columns in SYS_FOREIGN record");
473 field = rec_get_nth_field_old(rec, 0, &len);
474 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
476 return(
"incorrect column length in SYS_FOREIGN");
486 if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
490 if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
497 field = rec_get_nth_field_old(rec, 3, &len);
498 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
502 heap, (
const char*) field, len);
504 field = rec_get_nth_field_old(rec, 4, &len);
505 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
509 heap, (
const char*) field, len);
511 field = rec_get_nth_field_old(rec, 5, &len);
512 if (UNIV_UNLIKELY(len != 4)) {
517 foreign->
type = (
unsigned int) (n_fields_and_type >> 24);
518 foreign->
n_fields = (
unsigned int) (n_fields_and_type & 0x3FFUL);
529 dict_process_sys_foreign_col_rec(
534 const char** for_col_name,
535 const char** ref_col_name,
543 return(
"delete-marked record in SYS_FOREIGN_COLS");
547 return(
"wrong number of columns in SYS_FOREIGN_COLS record");
550 field = rec_get_nth_field_old(rec, 0, &len);
551 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
553 return(
"incorrect column length in SYS_FOREIGN_COLS");
557 field = rec_get_nth_field_old(rec, 1, &len);
558 if (UNIV_UNLIKELY(len != 4)) {
564 if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
568 if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
572 field = rec_get_nth_field_old(rec, 4, &len);
573 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
578 field = rec_get_nth_field_old(rec, 5, &len);
579 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
591 UNIV_INTERN
void dict_print_with_callback(dict_print_callback func,
void *func_arg)
604 mutex_enter(&kernel_mutex);
605 srv_fatal_semaphore_wait_threshold += 7200;
606 mutex_exit(&kernel_mutex);
608 mutex_enter(&(dict_sys->
mutex));
620 rec = btr_pcur_get_rec(&pcur);
628 mutex_exit(&(dict_sys->
mutex));
632 mutex_enter(&kernel_mutex);
633 srv_fatal_semaphore_wait_threshold -= 7200;
634 mutex_exit(&kernel_mutex);
639 field = rec_get_nth_field_old(rec, 0, &len);
645 char* table_name =
mem_strdupl((
char*) field, len);
647 btr_pcur_store_position(&pcur, &mtr);
651 func(func_arg, table_name);
668 dict_sys_tables_get_flags(
677 field = rec_get_nth_field_old(rec, 5, &len);
686 field = rec_get_nth_field_old(rec, 4, &len);
689 if (UNIV_UNLIKELY(!(n_cols & 0x80000000UL))) {
691 return(ULINT_UNDEFINED);
700 return(ULINT_UNDEFINED);
703 #if DICT_TF_FORMAT_MAX > DICT_TF_FORMAT_ZIP
704 # error "missing case labels for DICT_TF_FORMAT_ZIP .. DICT_TF_FORMAT_MAX"
710 if (UNIV_UNLIKELY((flags & DICT_TF_ZSSIZE_MASK)
713 return(ULINT_UNDEFINED);
716 if (UNIV_UNLIKELY(flags & (SIZE_MAX <<
DICT_TF_BITS))) {
718 return(ULINT_UNDEFINED);
734 dict_check_tablespaces_and_store_max_id(
736 ibool in_crash_recovery)
745 mutex_enter(&(dict_sys->
mutex));
754 + DICT_HDR_MAX_SPACE_ID,
756 fil_set_max_space_id_if_bigger(max_space_id);
763 rec = btr_pcur_get_rec(&pcur);
776 fil_set_max_space_id_if_bigger(max_space_id);
778 mutex_exit(&(dict_sys->
mutex));
792 field = rec_get_nth_field_old(rec, 0, &len);
795 flags = dict_sys_tables_get_flags(rec);
796 if (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) {
798 field = rec_get_nth_field_old(rec, 5, &len);
802 fputs(
" InnoDB: Error: table ", stderr);
805 "InnoDB: in InnoDB data dictionary"
806 " has unknown type %lx.\n",
812 field = rec_get_nth_field_old(rec, 9, &len);
817 btr_pcur_store_position(&pcur, &mtr);
823 }
else if (in_crash_recovery) {
829 field = rec_get_nth_field_old(rec, 4, &len);
833 field = rec_get_nth_field_old(rec, 7, &len);
847 fil_space_for_table_exists_in_mem(
848 space_id, name, is_temp, TRUE, !is_temp);
853 fil_open_single_table_tablespace(FALSE, space_id,
859 if (space_id > max_space_id) {
860 max_space_id = space_id;
877 dict_load_column_low(
887 table_id_t* table_id,
888 const char** col_name,
899 ut_ad(table || column);
902 return(
"delete-marked record in SYS_COLUMNS");
906 return(
"wrong number of columns in SYS_COLUMNS record");
909 field = rec_get_nth_field_old(rec, 0, &len);
910 if (UNIV_UNLIKELY(len != 8)) {
912 return(
"incorrect column length in SYS_COLUMNS");
918 return(
"SYS_COLUMNS.TABLE_ID mismatch");
921 field = rec_get_nth_field_old(rec, 1, &len);
922 if (UNIV_UNLIKELY(len != 4)) {
929 if (UNIV_UNLIKELY(table && table->
n_def != pos)) {
930 return(
"SYS_COLUMNS.POS mismatch");
934 if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
938 if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
942 field = rec_get_nth_field_old(rec, 4, &len);
943 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
953 field = rec_get_nth_field_old(rec, 5, &len);
954 if (UNIV_UNLIKELY(len != 4)) {
960 field = rec_get_nth_field_old(rec, 6, &len);
961 if (UNIV_UNLIKELY(len != 4)) {
967 && dtype_is_string_type(mtype)) {
970 if (dtype_is_binary_string_type(mtype, prtype)) {
974 prtype = dtype_form_prtype(
976 DATA_MYSQL_BINARY_CHARSET_COLL);
981 prtype = dtype_form_prtype(
983 data_mysql_default_charset_coll);
987 field = rec_get_nth_field_old(rec, 7, &len);
988 if (UNIV_UNLIKELY(len != 4)) {
992 field = rec_get_nth_field_old(rec, 8, &len);
993 if (UNIV_UNLIKELY(len != 4)) {
998 dict_mem_table_add_col(table, heap, name, mtype,
1001 dict_mem_fill_column_struct(column, pos, mtype,
1036 ut_a(name_of_col_is(sys_columns, sys_index, 4,
"NAME"));
1037 ut_a(name_of_col_is(sys_columns, sys_index, 8,
"PREC"));
1040 dfield = dtuple_get_nth_field(tuple, 0);
1046 dict_index_copy_types(tuple, sys_index, 1);
1048 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
1050 for (i = 0; i + DATA_N_SYS_COLS < (ulint) table->
n_cols; i++) {
1051 const char* err_msg;
1053 rec = btr_pcur_get_rec(&pcur);
1057 err_msg = dict_load_column_low(table, heap, NULL, NULL,
1061 fprintf(stderr,
"InnoDB: %s\n", err_msg);
1073 static const char* dict_load_field_del =
"delete-marked record in SYS_FIELDS";
1081 dict_load_field_low(
1093 byte* last_index_id,
1100 ulint pos_and_prefix_len;
1106 ut_a((!index) || (!sys_field));
1109 return(dict_load_field_del);
1113 return(
"wrong number of columns in SYS_FIELDS record");
1116 field = rec_get_nth_field_old(rec, 0, &len);
1117 if (UNIV_UNLIKELY(len != 8)) {
1119 return(
"incorrect column length in SYS_FIELDS");
1123 ut_a(last_index_id);
1124 memcpy(index_id, (
const char*)field, 8);
1125 first_field = memcmp(index_id, last_index_id, 8);
1127 first_field = (index->
n_def == 0);
1128 if (memcmp(field, index_id, 8)) {
1129 return(
"SYS_FIELDS.INDEX_ID mismatch");
1133 field = rec_get_nth_field_old(rec, 1, &len);
1134 if (UNIV_UNLIKELY(len != 4)) {
1139 if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
1143 if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
1157 if (index && UNIV_UNLIKELY
1158 ((pos_and_prefix_len & 0xFFFFUL) != index->
n_def
1159 && (pos_and_prefix_len >> 16 & 0xFFFF) != index->
n_def)) {
1160 return(
"SYS_FIELDS.POS mismatch");
1163 if (first_field || pos_and_prefix_len > 0xFFFFUL) {
1164 prefix_len = pos_and_prefix_len & 0xFFFFUL;
1165 position = (pos_and_prefix_len & 0xFFFF0000UL) >> 16;
1168 position = pos_and_prefix_len & 0xFFFFUL;
1171 field = rec_get_nth_field_old(rec, 4, &len);
1172 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
1177 dict_mem_index_add_field(
1185 heap, (
const char*) field, len);
1221 ut_a(name_of_col_is(sys_fields, sys_index, 4,
"COL_NAME"));
1224 dfield = dtuple_get_nth_field(tuple, 0);
1230 dict_index_copy_types(tuple, sys_index, 1);
1232 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
1234 for (i = 0; i < index->
n_fields; i++) {
1235 const char* err_msg;
1237 rec = btr_pcur_get_rec(&pcur);
1241 err_msg = dict_load_field_low(buf, index, NULL, NULL, NULL,
1244 if (err_msg == dict_load_field_del) {
1250 }
else if (err_msg) {
1251 fprintf(stderr,
"InnoDB: %s\n", err_msg);
1252 error = DB_CORRUPTION;
1267 static const char* dict_load_index_del =
"delete-marked record in SYS_INDEXES";
1269 static const char* dict_load_index_id_err =
"SYS_INDEXES.TABLE_ID mismatch";
1279 dict_load_index_low(
1284 const char* table_name,
1308 return(dict_load_index_del);
1312 return(
"wrong number of columns in SYS_INDEXES record");
1315 field = rec_get_nth_field_old(rec, 0, &len);
1316 if (UNIV_UNLIKELY(len != 8)) {
1318 return(
"incorrect column length in SYS_INDEXES");
1323 memcpy(table_id, (
const char*)field, 8);
1324 }
else if (memcmp(field, table_id, 8)) {
1327 return(dict_load_index_id_err);
1330 field = rec_get_nth_field_old(rec, 1, &len);
1331 if (UNIV_UNLIKELY(len != 8)) {
1338 if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
1342 if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
1346 field = rec_get_nth_field_old(rec, 4, &name_len);
1347 if (UNIV_UNLIKELY(name_len == UNIV_SQL_NULL)) {
1354 field = rec_get_nth_field_old(rec, 5, &len);
1355 if (UNIV_UNLIKELY(len != 4)) {
1360 field = rec_get_nth_field_old(rec, 6, &len);
1361 if (UNIV_UNLIKELY(len != 4)) {
1366 field = rec_get_nth_field_old(rec, 7, &len);
1367 if (UNIV_UNLIKELY(len != 4)) {
1372 field = rec_get_nth_field_old(rec, 8, &len);
1373 if (UNIV_UNLIKELY(len != 4)) {
1378 *index = dict_mem_index_create(table_name, name_buf,
1379 space, type, n_fields);
1384 space, type, n_fields);
1389 ut_ad((*index)->page);
1405 dict_err_ignore_t ignore_err)
1417 ulint error = DB_SUCCESS;
1426 ut_a(name_of_col_is(sys_indexes, sys_index, 4,
"NAME"));
1427 ut_a(name_of_col_is(sys_indexes, sys_index, 8,
"PAGE_NO"));
1430 dfield = dtuple_get_nth_field(tuple, 0);
1436 dict_index_copy_types(tuple, sys_index, 1);
1438 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
1442 const char* err_msg;
1449 rec = btr_pcur_get_rec(&pcur);
1451 err_msg = dict_load_index_low(buf, table->
name, heap, rec,
1453 ut_ad((index == NULL) == (err_msg != NULL));
1455 if (err_msg == dict_load_index_id_err) {
1459 }
else if (err_msg == dict_load_index_del) {
1462 }
else if (err_msg) {
1463 fprintf(stderr,
"InnoDB: %s\n", err_msg);
1464 error = DB_CORRUPTION;
1475 "InnoDB: Error: unknown type %lu"
1476 " of index %s of table %s\n",
1479 error = DB_UNSUPPORTED;
1480 dict_mem_index_free(index);
1485 "InnoDB: Error: trying to load index %s"
1487 "InnoDB: but the index tree has been freed!\n",
1498 "InnoDB: Index is corrupt but forcing"
1499 " load into data dictionary\n");
1502 dict_mem_index_free(index);
1503 error = DB_CORRUPTION;
1507 && NULL == dict_table_get_first_index(table)) {
1509 fputs(
"InnoDB: Error: trying to load index ",
1512 fputs(
" for table ", stderr);
1514 fputs(
"\nInnoDB: but the first index"
1515 " is not clustered!\n", stderr);
1518 }
else if (table->
id < DICT_HDR_FIRST_ID
1521 && !strcmp(
"ID_IND", index->
name)))) {
1525 dict_mem_index_free(index);
1527 dict_load_fields(index, heap);
1528 error = dict_index_add_to_cache(table, index,
1529 index->
page, FALSE);
1535 if (UNIV_UNLIKELY(error != DB_SUCCESS)) {
1558 dict_load_table_low(
1571 return(
"delete-marked record in SYS_TABLES");
1575 return(
"wrong number of columns in SYS_TABLES record");
1579 if (UNIV_UNLIKELY(len < 1 || len == UNIV_SQL_NULL)) {
1581 return(
"incorrect column length in SYS_TABLES");
1584 if (UNIV_UNLIKELY(len != DATA_TRX_ID_LEN && len != UNIV_SQL_NULL)) {
1588 if (UNIV_UNLIKELY(len != DATA_ROLL_PTR_LEN && len != UNIV_SQL_NULL)) {
1593 if (UNIV_UNLIKELY(len != 8)) {
1597 field = rec_get_nth_field_old(rec, 4, &len);
1598 if (UNIV_UNLIKELY(len != 4)) {
1605 if (UNIV_UNLIKELY(len != 4)) {
1610 if (UNIV_UNLIKELY(len != 8)) {
1615 if (UNIV_UNLIKELY(len != 4)) {
1620 if (UNIV_UNLIKELY(len != UNIV_SQL_NULL)) {
1624 field = rec_get_nth_field_old(rec, 9, &len);
1626 if (UNIV_UNLIKELY(len != 4)) {
1634 flags = dict_sys_tables_get_flags(rec);
1636 if (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) {
1637 field = rec_get_nth_field_old(rec, 5, &len);
1642 fputs(
" InnoDB: Error: table ", stderr);
1644 fprintf(stderr,
"\n"
1645 "InnoDB: in InnoDB data dictionary"
1646 " has unknown type %lx.\n",
1648 return(
"incorrect flags in SYS_TABLES");
1656 if (n_cols & 0x80000000UL) {
1661 field = rec_get_nth_field_old(rec, 7, &len);
1663 if (UNIV_UNLIKELY(len != 4)) {
1672 fputs(
" InnoDB: Warning: table ", stderr);
1674 fprintf(stderr,
"\n"
1675 "InnoDB: in InnoDB data dictionary"
1676 " has unknown flags %lx.\n",
1686 *table = dict_mem_table_create(name, space, n_cols & ~0x80000000UL,
1689 field = rec_get_nth_field_old(rec, 3, &len);
1694 (*table)->ibd_file_missing = FALSE;
1715 dict_err_ignore_t ignore_err)
1730 const char* err_msg;
1742 ut_a(name_of_col_is(sys_tables, sys_index, 3,
"ID"));
1743 ut_a(name_of_col_is(sys_tables, sys_index, 4,
"N_COLS"));
1744 ut_a(name_of_col_is(sys_tables, sys_index, 5,
"TYPE"));
1745 ut_a(name_of_col_is(sys_tables, sys_index, 7,
"MIX_LEN"));
1746 ut_a(name_of_col_is(sys_tables, sys_index, 9,
"SPACE"));
1749 dfield = dtuple_get_nth_field(tuple, 0);
1752 dict_index_copy_types(tuple, sys_index, 1);
1754 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
1756 rec = btr_pcur_get_rec(&pcur);
1769 field = rec_get_nth_field_old(rec, 0, &len);
1777 err_msg = dict_load_table_low(name, rec, &table);
1782 fprintf(stderr,
" InnoDB: %s\n", err_msg);
1786 if (table->
space == 0) {
1788 }
else if (!fil_space_for_table_exists_in_mem(
1800 " InnoDB: error: space object of table ");
1802 fprintf(stderr,
",\n"
1803 "InnoDB: space id %lu did not exist in memory."
1804 " Retrying an open.\n",
1805 (ulong) table->
space);
1807 if (!fil_open_single_table_tablespace(
1822 dict_load_columns(table, heap);
1825 dict_table_add_to_cache(table, heap);
1827 dict_table_add_system_columns(table, heap);
1832 err = dict_load_indexes(table, heap, ignore_err);
1843 }
else if (err == DB_SUCCESS) {
1844 err = dict_load_foreigns(table->
name, TRUE, TRUE);
1846 if (err != DB_SUCCESS) {
1847 dict_table_remove_from_cache(table);
1852 }
else if (!srv_force_recovery) {
1853 dict_table_remove_from_cache(table);
1857 if (err != DB_SUCCESS && table != NULL) {
1859 mutex_enter(&dict_foreign_err_mutex);
1864 " InnoDB: Error: could not make a foreign key"
1865 " definition to match\n"
1866 "InnoDB: the foreign key table"
1867 " or the referenced table!\n"
1868 "InnoDB: The data dictionary of InnoDB is corrupt."
1869 " You may need to drop\n"
1870 "InnoDB: and recreate the foreign key table"
1871 " or the referenced table.\n"
1872 "InnoDB: Submit a detailed bug report"
1873 " to http://bugs.mysql.com\n"
1874 "InnoDB: Latest foreign key error printout:\n%s\n",
1875 dict_foreign_err_buf);
1877 mutex_exit(&dict_foreign_err_mutex);
1890 dict_load_table_on_id(
1892 table_id_t table_id)
1921 sys_table_ids = dict_table_get_next_index(
1922 dict_table_get_first_index(sys_tables));
1927 dfield = dtuple_get_nth_field(tuple, 0);
1933 dict_index_copy_types(tuple, sys_table_ids, 1);
1935 btr_pcur_open_on_user_rec(sys_table_ids, tuple, PAGE_CUR_GE,
1937 rec = btr_pcur_get_rec(&pcur);
1949 rec = btr_pcur_get_rec(&pcur);
1956 rec = btr_pcur_get_rec(&pcur);
1957 field = rec_get_nth_field_old(rec, 0, &len);
1966 field = rec_get_nth_field_old(rec, 1, &len);
1984 dict_load_sys_table(
2003 dict_load_foreign_cols(
2034 dfield = dtuple_get_nth_field(tuple, 0);
2037 dict_index_copy_types(tuple, sys_index, 1);
2039 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
2041 for (i = 0; i < foreign->
n_fields; i++) {
2043 rec = btr_pcur_get_rec(&pcur);
2048 field = rec_get_nth_field_old(rec, 0, &len);
2052 field = rec_get_nth_field_old(rec, 1, &len);
2056 field = rec_get_nth_field_old(rec, 4, &len);
2058 foreign->
heap, (
char*) field, len);
2060 field = rec_get_nth_field_old(rec, 5, &len);
2062 foreign->
heap, (
char*) field, len);
2080 ibool check_charsets,
2082 ibool check_recursive)
2097 ulint n_fields_and_type;
2113 dfield = dtuple_get_nth_field(tuple, 0);
2116 dict_index_copy_types(tuple, sys_index, 1);
2118 btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE,
2120 rec = btr_pcur_get_rec(&pcur);
2127 "InnoDB: Error A: cannot load foreign constraint %s\n",
2137 field = rec_get_nth_field_old(rec, 0, &len);
2143 "InnoDB: Error B: cannot load foreign constraint %s\n",
2158 foreign = dict_mem_foreign_create();
2161 rec_get_nth_field_old(rec, 5, &len));
2167 foreign->
type = (
unsigned int) (n_fields_and_type >> 24);
2168 foreign->
n_fields = (
unsigned int) (n_fields_and_type & 0x3FFUL);
2172 field = rec_get_nth_field_old(rec, 3, &len);
2175 foreign->
heap, (
char*) field, len);
2176 dict_mem_foreign_table_name_lookup_set(foreign, TRUE);
2178 field = rec_get_nth_field_old(rec, 4, &len);
2180 foreign->
heap, (
char*) field, len);
2181 dict_mem_referenced_table_name_lookup_set(foreign, TRUE);
2186 dict_load_foreign_cols(
id, foreign);
2224 if (for_table && ref_table && check_recursive) {
2245 return(dict_foreign_add_to_cache(foreign, check_charsets));
2259 const char* table_name,
2260 ibool check_recursive,
2262 ibool check_charsets)
2282 if (sys_foreign == NULL) {
2286 "InnoDB: Error: no foreign key system tables"
2287 " in the database\n");
2298 sec_index = dict_table_get_next_index(
2299 dict_table_get_first_index(sys_foreign));
2304 dfield = dtuple_get_nth_field(tuple, 0);
2307 dict_index_copy_types(tuple, sec_index, 1);
2309 btr_pcur_open_on_user_rec(sec_index, tuple, PAGE_CUR_GE,
2312 rec = btr_pcur_get_rec(&pcur);
2317 goto load_next_index;
2323 rec = btr_pcur_get_rec(&pcur);
2324 field = rec_get_nth_field_old(rec, 0, &len);
2331 dfield_get_type(dfield)->prtype,
2332 static_cast<const unsigned char *>(dfield_get_data(dfield)),
2336 goto load_next_index;
2346 if ((srv_lower_case_table_names != 2)
2347 && (0 !=
ut_memcmp(field, table_name, len))) {
2357 field = rec_get_nth_field_old(rec, 1, &len);
2360 btr_pcur_store_position(&pcur, &mtr);
2366 err = dict_load_foreign(
id, check_charsets, check_recursive);
2368 if (err != DB_SUCCESS) {
2388 sec_index = dict_table_get_next_index(sec_index);
2390 if (sec_index != NULL) {
2397 check_recursive = FALSE;