2122
2124
ut_a(!rec_get_deleted_flag(rec, 0));
2124
2126
field = rec_get_nth_field_old(rec, 0, &len);
2128
if (len != id_len || ut_memcmp(id, field, len) != 0) {
2131
tmp = mem_heap_alloc(foreign->heap, id_len+4);
2132
ut_memcpy(tmp, id, id_len);
2134
tmp2 = mem_heap_alloc(foreign->heap, len+4);
2135
ut_memcpy(tmp2, id, len);
2137
fprintf(stderr, "InnoDB: Error: len = %lu != id_len %lu\n",
2139
fprintf(stderr, "InnoDB: Error: id %s != field %s\n",
2125
2144
ut_a(len == id_len);
2126
2145
ut_a(ut_memcmp(id, field, len) == 0);
2325
2346
a new foreign key constraint but loading one from the data
2328
return(dict_foreign_add_to_cache(foreign, check_charsets, ignore_err));
2349
DBUG_RETURN(dict_foreign_add_to_cache(foreign, check_charsets, ignore_err));
2331
2352
/***********************************************************************//**
2480
2503
goto start_load;
2506
DBUG_RETURN(DB_SUCCESS);
2509
/********************************************************************//**
2510
Check if dict_table_t::foreign_rbt and dict_table::foreign_list
2511
contain the same set of foreign key objects; and check if
2512
dict_table_t::referenced_rbt and dict_table::referenced_list contain
2513
the same set of foreign key objects.
2514
@return TRUE if correct, FALSE otherwise. */
2516
dict_table_check_foreign_keys(
2517
/*==========================*/
2518
const dict_table_t* table) /* in: table object to check */
2520
dict_foreign_t* foreign;
2521
const ib_rbt_node_t* node;
2523
ut_ad(mutex_own(&(dict_sys->mutex)));
2525
if (table->foreign_rbt == NULL) {
2527
if (UT_LIST_GET_LEN(table->foreign_list) > 0) {
2533
if (UT_LIST_GET_LEN(table->foreign_list)
2534
!= rbt_size(table->foreign_rbt)) {
2538
foreign = UT_LIST_GET_FIRST(table->foreign_list);
2540
while (foreign != NULL) {
2542
node = rbt_lookup(table->foreign_rbt, foreign->id);
2546
foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
2550
if (table->referenced_rbt == NULL ) {
2552
if (UT_LIST_GET_LEN(table->referenced_list) > 0) {
2558
if (UT_LIST_GET_LEN(table->referenced_list)
2559
!= rbt_size(table->referenced_rbt)) {
2563
foreign = UT_LIST_GET_FIRST(table->referenced_list);
2565
while (foreign != NULL) {
2567
node = rbt_lookup(table->referenced_rbt, foreign->id);
2571
foreign = UT_LIST_GET_NEXT(referenced_list, foreign);