~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
400
400
                                        row is used, as row may contain
401
401
                                        pointers to this record! */
402
402
{
403
 
        mysql_row_templ_t*      templ;
 
403
        const mysql_row_templ_t*templ;
404
404
        dfield_t*               dfield;
405
405
        ulint                   i;
406
406
 
552
552
                      " after the startup or when\n"
553
553
                      "InnoDB: you dump the tables, look at\n"
554
554
                      "InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
555
 
                      "forcing-recovery.html"
 
555
                      "forcing-innodb-recovery.html"
556
556
                      " for help.\n", stderr);
557
557
 
 
558
        } else if (err == DB_FOREIGN_EXCEED_MAX_CASCADE) {
 
559
                fprintf(stderr, "InnoDB: Cannot delete/update rows with"
 
560
                        " cascading foreign key constraints that exceed max"
 
561
                        " depth of %lu\n"
 
562
                        "Please drop excessive foreign constraints"
 
563
                        " and try again\n", (ulong) DICT_FK_MAX_RECURSIVE_LOAD);
558
564
        } else {
559
565
                fprintf(stderr, "InnoDB: unknown error code %lu\n",
560
566
                        (ulong) err);
1406
1412
run_again:
1407
1413
        thr->run_node = node;
1408
1414
        thr->prev_node = node;
 
1415
        thr->fk_cascade_depth = 0;
1409
1416
 
1410
1417
        row_upd_step(thr);
1411
1418
 
1412
1419
        err = trx->error_state;
1413
1420
 
 
1421
        /* Reset fk_cascade_depth back to 0 */
 
1422
        thr->fk_cascade_depth = 0;
 
1423
 
1414
1424
        if (err != DB_SUCCESS) {
1415
1425
                que_thr_stop_for_mysql(thr);
1416
1426
 
1447
1457
                srv_n_rows_updated++;
1448
1458
        }
1449
1459
 
1450
 
        row_update_statistics_if_needed(prebuilt->table);
 
1460
        /* We update table statistics only if it is a DELETE or UPDATE
 
1461
        that changes indexed columns, UPDATEs that change only non-indexed
 
1462
        columns would not affect statistics. */
 
1463
        if (node->is_delete || !(node->cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
 
1464
                row_update_statistics_if_needed(prebuilt->table);
 
1465
        }
1451
1466
 
1452
1467
        trx->op_info = "";
1453
1468
 
1597
1612
        trx_t*  trx;
1598
1613
 
1599
1614
        trx = thr_get_trx(thr);
 
1615
 
 
1616
        /* Increment fk_cascade_depth to record the recursive call depth on
 
1617
        a single update/delete that affects multiple tables chained
 
1618
        together with foreign key relations. */
 
1619
        thr->fk_cascade_depth++;
 
1620
 
 
1621
        if (thr->fk_cascade_depth > FK_MAX_CASCADE_DEL) {
 
1622
                return (DB_FOREIGN_EXCEED_MAX_CASCADE);
 
1623
        }
1600
1624
run_again:
1601
1625
        thr->run_node = node;
1602
1626
        thr->prev_node = node;
1603
1627
 
1604
1628
        row_upd_step(thr);
1605
1629
 
 
1630
        /* The recursive call for cascading update/delete happens
 
1631
        in above row_upd_step(), reset the counter once we come
 
1632
        out of the recursive call, so it does not accumulate for
 
1633
        different row deletes */
 
1634
        thr->fk_cascade_depth = 0;
 
1635
 
1606
1636
        err = trx->error_state;
1607
1637
 
1608
1638
        /* Note that the cascade node is a subnode of another InnoDB
1951
1981
                table already exists */
1952
1982
 
1953
1983
                trx->error_state = DB_SUCCESS;
 
1984
                dict_mem_table_free(table);
1954
1985
        }
1955
1986
 
1956
1987
        que_graph_free((que_t*) que_node_get_parent(thr));
2129
2160
 
2130
2161
        if (err == DB_SUCCESS) {
2131
2162
                /* Check that also referencing constraints are ok */
2132
 
                err = dict_load_foreigns(name, TRUE);
 
2163
                err = dict_load_foreigns(name, FALSE, TRUE);
2133
2164
        }
2134
2165
 
2135
2166
        if (err != DB_SUCCESS) {
2814
2845
 
2815
2846
        trx->table_id = table->id;
2816
2847
 
 
2848
        /* Lock all index trees for this table, as we will
 
2849
        truncate the table/index and possibly change their metadata.
 
2850
        All DML/DDL are blocked by table level lock, with
 
2851
        a few exceptions such as queries into information schema
 
2852
        about the table, MySQL could try to access index stats
 
2853
        for this kind of query, we need to use index locks to
 
2854
        sync up */
 
2855
        dict_table_x_lock_indexes(table);
 
2856
 
2817
2857
        /* scan SYS_INDEXES for all indexes of the table */
2818
2858
        heap = mem_heap_create(800);
2819
2859
 
2886
2926
 
2887
2927
        mem_heap_free(heap);
2888
2928
 
 
2929
        /* Done with index truncation, release index tree locks,
 
2930
        subsequent work relates to table level metadata change */
 
2931
        dict_table_x_unlock_indexes(table);
 
2932
 
2889
2933
        new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
2890
2934
 
2891
2935
        info = pars_info_create();
3878
3922
                an ALTER, not in a RENAME. */
3879
3923
 
3880
3924
                err = dict_load_foreigns(
3881
 
                        new_name, old_is_tmp ? trx->check_foreigns : TRUE);
 
3925
                        new_name, FALSE,
 
3926
                        old_is_tmp ? trx->check_foreigns : TRUE);
3882
3927
 
3883
3928
                if (err != DB_SUCCESS) {
3884
3929
                        ut_print_timestamp(stderr);