~ubuntu-branches/ubuntu/utopic/mariadb-5.5/utopic-security

« back to all changes in this revision

Viewing changes to storage/innobase/dict/dict0load.c

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2014-08-27 21:12:36 UTC
  • mfrom: (2.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140827211236-se41hwfe4xy0hpef
* d/control: Removed Provides: libmysqlclient-dev (Closes: #759309)
* d/control: Removed Provides: libmysqld-dev with same motivation
* Re-introduced tha HPPA build patch as the upstream fix wasn't complete
* Fixed all kFreeBSD build and test suite issues
* Added Italian translation (Closes: #759813)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1759
1759
        const char*     err_msg;
1760
1760
        mtr_t           mtr;
1761
1761
 
 
1762
        DBUG_ENTER("dict_load_table");
 
1763
 
1762
1764
        ut_ad(mutex_own(&(dict_sys->mutex)));
1763
1765
 
1764
1766
        heap = mem_heap_create(32000);
1792
1794
                mtr_commit(&mtr);
1793
1795
                mem_heap_free(heap);
1794
1796
 
1795
 
                return(NULL);
 
1797
                DBUG_RETURN(NULL);
1796
1798
        }
1797
1799
 
1798
1800
        field = rec_get_nth_field_old(rec, 0, &len);
1954
1956
#endif /* 0 */
1955
1957
func_exit:
1956
1958
        mem_heap_free(heap);
1957
 
 
1958
 
        return(table);
 
1959
        ut_ad(table == NULL || dict_table_check_foreign_keys(table));
 
1960
        DBUG_RETURN(table);
1959
1961
}
1960
1962
 
1961
1963
/***********************************************************************//**
2122
2124
                ut_a(!rec_get_deleted_flag(rec, 0));
2123
2125
 
2124
2126
                field = rec_get_nth_field_old(rec, 0, &len);
 
2127
 
 
2128
                if (len != id_len || ut_memcmp(id, field, len) != 0) {
 
2129
                        char * tmp,*tmp2;
 
2130
 
 
2131
                        tmp = mem_heap_alloc(foreign->heap, id_len+4);
 
2132
                        ut_memcpy(tmp, id, id_len);
 
2133
                        tmp[id_len]='\0';
 
2134
                        tmp2 = mem_heap_alloc(foreign->heap, len+4);
 
2135
                        ut_memcpy(tmp2, id, len);
 
2136
                        tmp2[len]='\0';
 
2137
                        fprintf(stderr, "InnoDB: Error: len = %lu != id_len %lu\n",
 
2138
                                len, id_len);
 
2139
                        fprintf(stderr, "InnoDB: Error: id %s != field %s\n",
 
2140
                                tmp, tmp2);
 
2141
 
 
2142
                }
 
2143
 
2125
2144
                ut_a(len == id_len);
2126
2145
                ut_a(ut_memcmp(id, field, len) == 0);
2127
2146
 
2180
2199
        dict_table_t*   for_table;
2181
2200
        dict_table_t*   ref_table;
2182
2201
 
 
2202
        DBUG_ENTER("dict_load_foreign");
 
2203
 
2183
2204
        ut_ad(mutex_own(&(dict_sys->mutex)));
2184
2205
 
2185
2206
        heap2 = mem_heap_create(1000);
2212
2233
                mtr_commit(&mtr);
2213
2234
                mem_heap_free(heap2);
2214
2235
 
2215
 
                return(DB_ERROR);
 
2236
                DBUG_RETURN(DB_ERROR);
2216
2237
        }
2217
2238
 
2218
2239
        field = rec_get_nth_field_old(rec, 0, &len);
2228
2249
                mtr_commit(&mtr);
2229
2250
                mem_heap_free(heap2);
2230
2251
 
2231
 
                return(DB_ERROR);
 
2252
                DBUG_RETURN(DB_ERROR);
2232
2253
        }
2233
2254
 
2234
2255
        /* Read the table names and the number of columns associated
2325
2346
        a new foreign key constraint but loading one from the data
2326
2347
        dictionary. */
2327
2348
 
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));
2329
2350
}
2330
2351
 
2331
2352
/***********************************************************************//**
2360
2381
        ulint           err;
2361
2382
        mtr_t           mtr;
2362
2383
 
 
2384
        DBUG_ENTER("dict_load_foreigns");
 
2385
 
2363
2386
        ut_ad(mutex_own(&(dict_sys->mutex)));
2364
2387
 
2365
2388
        sys_foreign = dict_table_get_low("SYS_FOREIGN", DICT_ERR_IGNORE_NONE);
2371
2394
                        "InnoDB: Error: no foreign key system tables"
2372
2395
                        " in the database\n");
2373
2396
 
2374
 
                return(DB_ERROR);
 
2397
                DBUG_RETURN(DB_ERROR);
2375
2398
        }
2376
2399
 
2377
2400
        ut_a(!dict_table_is_comp(sys_foreign));
2451
2474
        if (err != DB_SUCCESS) {
2452
2475
                btr_pcur_close(&pcur);
2453
2476
 
2454
 
                return(err);
 
2477
                DBUG_RETURN(err);
2455
2478
        }
2456
2479
 
2457
2480
        mtr_start(&mtr);
2480
2503
                goto start_load;
2481
2504
        }
2482
2505
 
2483
 
        return(DB_SUCCESS);
 
2506
        DBUG_RETURN(DB_SUCCESS);
 
2507
}
 
2508
 
 
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. */
 
2515
ibool
 
2516
dict_table_check_foreign_keys(
 
2517
/*==========================*/
 
2518
        const dict_table_t* table)      /* in: table object to check */
 
2519
{
 
2520
        dict_foreign_t*         foreign;
 
2521
        const ib_rbt_node_t*    node;
 
2522
 
 
2523
        ut_ad(mutex_own(&(dict_sys->mutex)));
 
2524
 
 
2525
        if (table->foreign_rbt == NULL) {
 
2526
 
 
2527
                if (UT_LIST_GET_LEN(table->foreign_list) > 0) {
 
2528
                        return(FALSE);
 
2529
                }
 
2530
 
 
2531
        } else {
 
2532
 
 
2533
                if (UT_LIST_GET_LEN(table->foreign_list)
 
2534
                    != rbt_size(table->foreign_rbt)) {
 
2535
                        return(FALSE);
 
2536
                }
 
2537
 
 
2538
                foreign = UT_LIST_GET_FIRST(table->foreign_list);
 
2539
 
 
2540
                while (foreign != NULL) {
 
2541
 
 
2542
                        node = rbt_lookup(table->foreign_rbt, foreign->id);
 
2543
                        if (node == NULL) {
 
2544
                                return(FALSE);
 
2545
                        }
 
2546
                        foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
 
2547
                }
 
2548
        }
 
2549
 
 
2550
        if (table->referenced_rbt == NULL ) {
 
2551
 
 
2552
                if (UT_LIST_GET_LEN(table->referenced_list) > 0) {
 
2553
                        return(FALSE);
 
2554
                }
 
2555
 
 
2556
        } else {
 
2557
 
 
2558
                if (UT_LIST_GET_LEN(table->referenced_list)
 
2559
                    != rbt_size(table->referenced_rbt)) {
 
2560
                        return(FALSE);
 
2561
                }
 
2562
 
 
2563
                foreign = UT_LIST_GET_FIRST(table->referenced_list);
 
2564
 
 
2565
                while (foreign != NULL) {
 
2566
 
 
2567
                        node = rbt_lookup(table->referenced_rbt, foreign->id);
 
2568
                        if (node == NULL) {
 
2569
                                return(FALSE);
 
2570
                        }
 
2571
                        foreign = UT_LIST_GET_NEXT(referenced_list, foreign);
 
2572
                }
 
2573
        }
 
2574
 
 
2575
        return(TRUE);
2484
2576
}