~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/row/row0mysql.c

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
618
618
                      "InnoDB: " REFMAN "forcing-recovery.html"
619
619
                      " for help.\n", stderr);
620
620
                break;
 
621
        case DB_FOREIGN_EXCEED_MAX_CASCADE:
 
622
                fprintf(stderr, "InnoDB: Cannot delete/update rows with"
 
623
                        " cascading foreign key constraints that exceed max"
 
624
                        " depth of %lu\n"
 
625
                        "Please drop excessive foreign constraints"
 
626
                        " and try again\n", (ulong) DICT_FK_MAX_RECURSIVE_LOAD);
 
627
                break;
621
628
        default:
622
629
                fprintf(stderr, "InnoDB: unknown error code %lu\n",
623
630
                        (ulong) err);
1424
1431
run_again:
1425
1432
        thr->run_node = node;
1426
1433
        thr->prev_node = node;
 
1434
        thr->fk_cascade_depth = 0;
1427
1435
 
1428
1436
        row_upd_step(thr);
1429
1437
 
 
1438
        /* The recursive call for cascading update/delete happens
 
1439
        in above row_upd_step(), reset the counter once we come
 
1440
        out of the recursive call, so it does not accumulate for
 
1441
        different row deletes */
 
1442
        thr->fk_cascade_depth = 0;
 
1443
 
1430
1444
        err = trx->error_state;
1431
1445
 
 
1446
        /* Reset fk_cascade_depth back to 0 */
 
1447
        thr->fk_cascade_depth = 0;
 
1448
 
1432
1449
        if (err != DB_SUCCESS) {
1433
1450
                que_thr_stop_for_mysql(thr);
1434
1451
 
1465
1482
                srv_n_rows_updated++;
1466
1483
        }
1467
1484
 
1468
 
        row_update_statistics_if_needed(prebuilt->table);
 
1485
        /* We update table statistics only if it is a DELETE or UPDATE
 
1486
        that changes indexed columns, UPDATEs that change only non-indexed
 
1487
        columns would not affect statistics. */
 
1488
        if (node->is_delete || !(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
 
1489
                row_update_statistics_if_needed(prebuilt->table);
 
1490
        }
1469
1491
 
1470
1492
        trx->op_info = "";
1471
1493
 
1619
1641
        trx_t*  trx;
1620
1642
 
1621
1643
        trx = thr_get_trx(thr);
 
1644
 
 
1645
        /* Increment fk_cascade_depth to record the recursive call depth on
 
1646
        a single update/delete that affects multiple tables chained
 
1647
        together with foreign key relations. */
 
1648
        thr->fk_cascade_depth++;
 
1649
 
 
1650
        if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) {
 
1651
                return (DB_FOREIGN_EXCEED_MAX_CASCADE);
 
1652
        }
1622
1653
run_again:
1623
1654
        thr->run_node = node;
1624
1655
        thr->prev_node = node;
1625
1656
 
1626
1657
        row_upd_step(thr);
1627
1658
 
 
1659
        /* The recursive call for cascading update/delete happens
 
1660
        in above row_upd_step(), reset the counter once we come
 
1661
        out of the recursive call, so it does not accumulate for
 
1662
        different row deletes */
 
1663
        thr->fk_cascade_depth = 0;
 
1664
 
1628
1665
        err = trx->error_state;
1629
1666
 
1630
1667
        /* Note that the cascade node is a subnode of another InnoDB
2087
2124
                                              name, reject_fks);
2088
2125
        if (err == DB_SUCCESS) {
2089
2126
                /* Check that also referencing constraints are ok */
2090
 
                err = dict_load_foreigns(name, TRUE);
 
2127
                err = dict_load_foreigns(name, FALSE, TRUE);
2091
2128
        }
2092
2129
 
2093
2130
        if (err != DB_SUCCESS) {
2780
2817
 
2781
2818
        trx->table_id = table->id;
2782
2819
 
 
2820
        /* Lock all index trees for this table, as we will
 
2821
        truncate the table/index and possibly change their metadata.
 
2822
        All DML/DDL are blocked by table level lock, with
 
2823
        a few exceptions such as queries into information schema
 
2824
        about the table, MySQL could try to access index stats
 
2825
        for this kind of query, we need to use index locks to
 
2826
        sync up */
 
2827
        dict_table_x_lock_indexes(table);
 
2828
 
2783
2829
        if (table->space && !table->dir_path_of_temp_table) {
2784
2830
                /* Discard and create the single-table tablespace. */
2785
2831
                ulint   space   = table->space;
2796
2842
                            || fil_create_new_single_table_tablespace(
2797
2843
                                    space, table->name, FALSE, flags,
2798
2844
                                    FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) {
 
2845
                                dict_table_x_unlock_indexes(table);
2799
2846
                                ut_print_timestamp(stderr);
2800
2847
                                fprintf(stderr,
2801
2848
                                        "  InnoDB: TRUNCATE TABLE %s failed to"
2899
2946
 
2900
2947
        mem_heap_free(heap);
2901
2948
 
 
2949
        /* Done with index truncation, release index tree locks,
 
2950
        subsequent work relates to table level metadata change */
 
2951
        dict_table_x_unlock_indexes(table);
 
2952
 
2902
2953
        dict_hdr_get_new_id(&new_id, NULL, NULL);
2903
2954
 
2904
2955
        info = pars_info_create();
3950
4001
                an ALTER, not in a RENAME. */
3951
4002
 
3952
4003
                err = dict_load_foreigns(
3953
 
                        new_name, !old_is_tmp || trx->check_foreigns);
 
4004
                        new_name, FALSE, !old_is_tmp || trx->check_foreigns);
3954
4005
 
3955
4006
                if (err != DB_SUCCESS) {
3956
4007
                        ut_print_timestamp(stderr);