~jobinau/drizzle/bug_654164

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-11-26 22:50:54 UTC
  • mfrom: (1953.1.6 build)
  • Revision ID: mordred@inaugust.com-20101126225054-sg90svw8579t5p3i
Stewart - InnoDB 1.1.1
Monty - Fixed some autoconf tests which were returning false positives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 1996, 2010, Innobase Oy. All Rights Reserved.
4
4
 
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
1431
1431
        upd_node_t*     node,   /*!< in: row update node */
1432
1432
        que_thr_t*      thr)    /*!< in: query thread */
1433
1433
{
1434
 
        ibool           check_ref;
1435
 
        ibool           found;
1436
 
        dict_index_t*   index;
1437
 
        dtuple_t*       entry;
1438
 
        btr_pcur_t      pcur;
1439
 
        btr_cur_t*      btr_cur;
1440
 
        mem_heap_t*     heap;
1441
 
        rec_t*          rec;
1442
 
        ulint           err     = DB_SUCCESS;
1443
 
        mtr_t           mtr;
1444
 
        trx_t*          trx     = thr_get_trx(thr);
 
1434
        mtr_t                   mtr;
 
1435
        const rec_t*            rec;
 
1436
        btr_pcur_t              pcur;
 
1437
        mem_heap_t*             heap;
 
1438
        dtuple_t*               entry;
 
1439
        dict_index_t*           index;
 
1440
        btr_cur_t*              btr_cur;
 
1441
        ibool                   referenced;
 
1442
        ulint                   err     = DB_SUCCESS;
 
1443
        trx_t*                  trx     = thr_get_trx(thr);
 
1444
        ulint                   mode    = BTR_MODIFY_LEAF;
 
1445
        enum row_search_result  search_result;
1445
1446
 
1446
1447
        index = node->index;
1447
1448
 
1448
 
        check_ref = row_upd_index_is_referenced(index, trx);
 
1449
        referenced = row_upd_index_is_referenced(index, trx);
1449
1450
 
1450
1451
        heap = mem_heap_create(1024);
1451
1452
 
1456
1457
        log_free_check();
1457
1458
        mtr_start(&mtr);
1458
1459
 
1459
 
        found = row_search_index_entry(index, entry, BTR_MODIFY_LEAF, &pcur,
1460
 
                                       &mtr);
 
1460
        /* Set the query thread, so that ibuf_insert_low() will be
 
1461
        able to invoke thd_get_trx(). */
 
1462
        btr_pcur_get_btr_cur(&pcur)->thr = thr;
 
1463
 
 
1464
        /* We can only try to use the insert/delete buffer to buffer
 
1465
        delete-mark operations if the index we're modifying has no foreign
 
1466
        key constraints referring to it. */
 
1467
        if (!referenced) {
 
1468
                mode |= BTR_DELETE_MARK;
 
1469
        }
 
1470
 
 
1471
        search_result = row_search_index_entry(index, entry, mode,
 
1472
                                               &pcur, &mtr);
 
1473
 
1461
1474
        btr_cur = btr_pcur_get_btr_cur(&pcur);
1462
1475
 
1463
1476
        rec = btr_cur_get_rec(btr_cur);
1464
1477
 
1465
 
        if (UNIV_UNLIKELY(!found)) {
 
1478
        switch (search_result) {
 
1479
        case ROW_NOT_DELETED_REF:       /* should only occur for BTR_DELETE */
 
1480
                ut_error;
 
1481
                break;
 
1482
        case ROW_BUFFERED:
 
1483
                /* Entry was delete marked already. */
 
1484
                break;
 
1485
 
 
1486
        case ROW_NOT_FOUND:
1466
1487
                fputs("InnoDB: error in sec index entry update in\n"
1467
1488
                      "InnoDB: ", stderr);
1468
1489
                dict_index_name_print(stderr, trx, index);
1479
1500
                fputs("\n"
1480
1501
                      "InnoDB: Submit a detailed bug report"
1481
1502
                      " to http://bugs.mysql.com\n", stderr);
1482
 
        } else {
 
1503
                break;
 
1504
        case ROW_FOUND:
1483
1505
                /* Delete mark the old index record; it can already be
1484
1506
                delete marked if we return after a lock wait in
1485
1507
                row_ins_index_entry below */
1486
1508
 
1487
 
                if (!rec_get_deleted_flag(rec,
1488
 
                                          dict_table_is_comp(index->table))) {
1489
 
                        err = btr_cur_del_mark_set_sec_rec(0, btr_cur, TRUE,
1490
 
                                                           thr, &mtr);
1491
 
                        if (err == DB_SUCCESS && check_ref) {
1492
 
 
1493
 
                                ulint*  offsets = rec_get_offsets(
1494
 
                                        rec, index, NULL,
1495
 
                                        ULINT_UNDEFINED, &heap);
 
1509
                if (!rec_get_deleted_flag(
 
1510
                        rec, dict_table_is_comp(index->table))) {
 
1511
 
 
1512
                        err = btr_cur_del_mark_set_sec_rec(
 
1513
                                0, btr_cur, TRUE, thr, &mtr);
 
1514
 
 
1515
                        if (err == DB_SUCCESS && referenced) {
 
1516
 
 
1517
                                ulint*  offsets;
 
1518
 
 
1519
                                offsets = rec_get_offsets(
 
1520
                                        rec, index, NULL, ULINT_UNDEFINED,
 
1521
                                        &heap);
 
1522
 
1496
1523
                                /* NOTE that the following call loses
1497
1524
                                the position of pcur ! */
1498
1525
                                err = row_upd_check_references_constraints(
1500
1527
                                        index, offsets, thr, &mtr);
1501
1528
                        }
1502
1529
                }
 
1530
                break;
1503
1531
        }
1504
1532
 
1505
1533
        btr_pcur_close(&pcur);
1563
1591
        upd_node_t*     node,   /*!< in: row update node */
1564
1592
        dict_index_t*   index,  /*!< in: clustered index of the record */
1565
1593
        que_thr_t*      thr,    /*!< in: query thread */
1566
 
        ibool           check_ref,/*!< in: TRUE if index may be referenced in
 
1594
        ibool           referenced,/*!< in: TRUE if index may be referenced in
1567
1595
                                a foreign key constraint */
1568
1596
        mtr_t*          mtr)    /*!< in: mtr; gets committed here */
1569
1597
{
1609
1637
                btr_cur_mark_extern_inherited_fields(
1610
1638
                        btr_cur_get_page_zip(btr_cur),
1611
1639
                        rec, index, offsets, node->update, mtr);
1612
 
                if (check_ref) {
 
1640
                if (referenced) {
1613
1641
                        /* NOTE that the following call loses
1614
1642
                        the position of pcur ! */
 
1643
 
1615
1644
                        err = row_upd_check_references_constraints(
1616
1645
                                node, pcur, table, index, offsets, thr, mtr);
 
1646
 
1617
1647
                        if (err != DB_SUCCESS) {
 
1648
 
1618
1649
                                mtr_commit(mtr);
 
1650
 
1619
1651
                                if (UNIV_LIKELY_NULL(heap)) {
1620
1652
                                        mem_heap_free(heap);
1621
1653
                                }
 
1654
 
1622
1655
                                return(err);
1623
1656
                        }
1624
1657
                }
1773
1806
        ulint*          offsets,/*!< in/out: rec_get_offsets() for the
1774
1807
                                record under the cursor */
1775
1808
        que_thr_t*      thr,    /*!< in: query thread */
1776
 
        ibool           check_ref,/*!< in: TRUE if index may be referenced in
 
1809
        ibool           referenced,
 
1810
                                /*!< in: TRUE if index may be referenced in
1777
1811
                                a foreign key constraint */
1778
1812
        mtr_t*          mtr)    /*!< in: mtr; gets committed here */
1779
1813
{
1798
1832
 
1799
1833
        err = btr_cur_del_mark_set_clust_rec(BTR_NO_LOCKING_FLAG,
1800
1834
                                             btr_cur, TRUE, thr, mtr);
1801
 
        if (err == DB_SUCCESS && check_ref) {
 
1835
        if (err == DB_SUCCESS && referenced) {
1802
1836
                /* NOTE that the following call loses the position of pcur ! */
1803
1837
 
1804
 
                err = row_upd_check_references_constraints(node,
1805
 
                                                           pcur, index->table,
1806
 
                                                           index, offsets,
1807
 
                                                           thr, mtr);
 
1838
                err = row_upd_check_references_constraints(
 
1839
                        node, pcur, index->table, index, offsets, thr, mtr);
1808
1840
        }
1809
1841
 
1810
1842
        mtr_commit(mtr);
1826
1858
        dict_index_t*   index;
1827
1859
        btr_pcur_t*     pcur;
1828
1860
        ibool           success;
1829
 
        ibool           check_ref;
1830
1861
        ulint           err;
1831
1862
        mtr_t*          mtr;
1832
1863
        mtr_t           mtr_buf;
1834
1865
        mem_heap_t*     heap            = NULL;
1835
1866
        ulint           offsets_[REC_OFFS_NORMAL_SIZE];
1836
1867
        ulint*          offsets;
 
1868
        ibool           referenced;
1837
1869
        rec_offs_init(offsets_);
1838
1870
 
1839
1871
        index = dict_table_get_first_index(node->table);
1840
1872
 
1841
 
        check_ref = row_upd_index_is_referenced(index, thr_get_trx(thr));
 
1873
        referenced = row_upd_index_is_referenced(index, thr_get_trx(thr));
1842
1874
 
1843
1875
        pcur = node->pcur;
1844
1876
 
1908
1940
        /* NOTE: the following function calls will also commit mtr */
1909
1941
 
1910
1942
        if (node->is_delete) {
1911
 
                err = row_upd_del_mark_clust_rec(node, index, offsets,
1912
 
                                                 thr, check_ref, mtr);
 
1943
                err = row_upd_del_mark_clust_rec(
 
1944
                        node, index, offsets, thr, referenced, mtr);
 
1945
 
1913
1946
                if (err == DB_SUCCESS) {
1914
1947
                        node->state = UPD_NODE_UPDATE_ALL_SEC;
1915
1948
                        node->index = dict_table_get_next_index(index);
1957
1990
                choosing records to update. MySQL solves now the problem
1958
1991
                externally! */
1959
1992
 
1960
 
                err = row_upd_clust_rec_by_insert(node, index, thr, check_ref,
1961
 
                                                  mtr);
 
1993
                err = row_upd_clust_rec_by_insert(
 
1994
                        node, index, thr, referenced, mtr);
 
1995
 
1962
1996
                if (err != DB_SUCCESS) {
1963
1997
 
1964
1998
                        return(err);