~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge initial InnoDB+ import.

This was applied by generating a patch between MySQL 5.1.50 InnoDB plugin and
the just-merged innodb+ from mysql-trunk revision-id: vasil.dimov@oracle.com-20100422110752-1zowoqxel5xx3z2e

Then, some manual merge resolving and it worked. This should make it much
easier to merge the rest of InnoDB 1.1 and 1.2 from the mysql tree using
my bzr-reapply script.

This takes us to InnoDB 1.1.1(ish).

Show diffs side-by-side

added added

removed removed

Lines of Context:
505
505
        case DB_CANNOT_ADD_CONSTRAINT:
506
506
        case DB_TOO_MANY_CONCURRENT_TRXS:
507
507
        case DB_OUT_OF_FILE_SPACE:
508
 
        case DB_INTERRUPTED:
509
508
                if (savept) {
510
509
                        /* Roll back the latest, possibly incomplete
511
510
                        insertion or update */
608
607
 
609
608
        prebuilt->select_lock_type = LOCK_NONE;
610
609
        prebuilt->stored_select_lock_type = 99999999;
611
 
        UNIV_MEM_INVALID(&prebuilt->stored_select_lock_type,
612
 
                         sizeof prebuilt->stored_select_lock_type);
613
610
 
614
611
        prebuilt->search_tuple = dtuple_create(
615
612
                heap, 2 * dict_table_get_n_cols(table));
1413
1410
}
1414
1411
 
1415
1412
/*********************************************************************//**
1416
 
This can only be used when srv_locks_unsafe_for_binlog is TRUE or this
1417
 
session is using a READ COMMITTED or READ UNCOMMITTED isolation level.
1418
 
Before calling this function row_search_for_mysql() must have
1419
 
initialized prebuilt->new_rec_locks to store the information which new
1420
 
record locks really were set. This function removes a newly set
1421
 
clustered index record lock under prebuilt->pcur or
1422
 
prebuilt->clust_pcur.  Thus, this implements a 'mini-rollback' that
1423
 
releases the latest clustered index record lock we set.
1424
 
@return error code or DB_SUCCESS */
 
1413
This can only be used when srv_locks_unsafe_for_binlog is TRUE or
 
1414
this session is using a READ COMMITTED isolation level. Before
 
1415
calling this function we must use trx_reset_new_rec_lock_info() and
 
1416
trx_register_new_rec_lock() to store the information which new record locks
 
1417
really were set. This function removes a newly set lock under prebuilt->pcur,
 
1418
and also under prebuilt->clust_pcur. Currently, this is only used and tested
 
1419
in the case of an UPDATE or a DELETE statement, where the row lock is of the
 
1420
LOCK_X type.
 
1421
Thus, this implements a 'mini-rollback' that releases the latest record
 
1422
locks we set.
 
1423
@return error code or DB_SUCCESS */
1425
1424
UNIV_INTERN
1426
1425
int
1427
1426
row_unlock_for_mysql(
1428
1427
/*=================*/
1429
 
        row_prebuilt_t* prebuilt,       /*!< in/out: prebuilt struct in MySQL
 
1428
        row_prebuilt_t* prebuilt,       /*!< in: prebuilt struct in MySQL
1430
1429
                                        handle */
1431
 
        ibool           has_latches_on_recs)/*!< in: TRUE if called so
1432
 
                                        that we have the latches on
1433
 
                                        the records under pcur and
1434
 
                                        clust_pcur, and we do not need
1435
 
                                        to reposition the cursors. */
 
1430
        ibool           has_latches_on_recs)/*!< TRUE if called so that we have
 
1431
                                        the latches on the records under pcur
 
1432
                                        and clust_pcur, and we do not need to
 
1433
                                        reposition the cursors. */
1436
1434
{
1437
1435
        btr_pcur_t*     pcur            = prebuilt->pcur;
1438
1436
        btr_pcur_t*     clust_pcur      = prebuilt->clust_pcur;
1443
1441
 
1444
1442
        if (UNIV_UNLIKELY
1445
1443
            (!srv_locks_unsafe_for_binlog
1446
 
             && trx->isolation_level > TRX_ISO_READ_COMMITTED)) {
 
1444
             && trx->isolation_level != TRX_ISO_READ_COMMITTED)) {
1447
1445
 
1448
1446
                fprintf(stderr,
1449
1447
                        "InnoDB: Error: calling row_unlock_for_mysql though\n"
1630
1628
}
1631
1629
 
1632
1630
/*********************************************************************//**
 
1631
Calculates the key number used inside MySQL for an Innobase index. We have
 
1632
to take into account if we generated a default clustered index for the table
 
1633
@return the key number used inside MySQL */
 
1634
UNIV_INTERN
 
1635
ulint
 
1636
row_get_mysql_key_number_for_index(
 
1637
/*===============================*/
 
1638
        const dict_index_t*     index)  /*!< in: index */
 
1639
{
 
1640
        const dict_index_t*     ind;
 
1641
        ulint                   i;
 
1642
 
 
1643
        ut_a(index);
 
1644
 
 
1645
        i = 0;
 
1646
        ind = dict_table_get_first_index(index->table);
 
1647
 
 
1648
        while (index != ind) {
 
1649
                ind = dict_table_get_next_index(ind);
 
1650
                i++;
 
1651
        }
 
1652
 
 
1653
        if (row_table_got_default_clust_index(index->table)) {
 
1654
                ut_a(i > 0);
 
1655
                i--;
 
1656
        }
 
1657
 
 
1658
        return(i);
 
1659
}
 
1660
 
 
1661
/*********************************************************************//**
1633
1662
Locks the data dictionary in shared mode from modifications, for performing
1634
1663
foreign key check, rollback, or other operation invisible to MySQL. */
1635
1664
UNIV_INTERN
2001
2030
                                FOREIGN KEY (a, b) REFERENCES table2(c, d),
2002
2031
                                        table2 can be written also with the
2003
2032
                                        database name before it: test.table2 */
2004
 
        size_t          sql_length,     /*!< in: length of sql_string */
2005
2033
        const char*     name,           /*!< in: table full name in the
2006
2034
                                        normalized form
2007
2035
                                        database_name/table_name */
2023
2051
 
2024
2052
        trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
2025
2053
 
2026
 
        err = dict_create_foreign_constraints(trx, sql_string, sql_length,
2027
 
                                              name, reject_fks);
 
2054
        err = dict_create_foreign_constraints(trx, sql_string, name,
 
2055
                                              reject_fks);
2028
2056
        if (err == DB_SUCCESS) {
2029
2057
                /* Check that also referencing constraints are ok */
2030
2058
                err = dict_load_foreigns(name, TRUE);
2368
2396
                goto funct_exit;
2369
2397
        }
2370
2398
 
2371
 
        dict_hdr_get_new_id(&new_id, NULL, NULL);
 
2399
        new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
2372
2400
 
2373
2401
        /* Remove all locks except the table-level S and X locks. */
2374
2402
        lock_remove_all_on_table(table, FALSE);
2730
2758
 
2731
2759
                        dict_index_t*   index;
2732
2760
 
2733
 
                        dict_hdr_get_new_id(NULL, NULL, &space);
 
2761
                        space = 0;
2734
2762
 
2735
 
                        if (space == ULINT_UNDEFINED
2736
 
                            || fil_create_new_single_table_tablespace(
2737
 
                                    space, table->name, FALSE, flags,
 
2763
                        if (fil_create_new_single_table_tablespace(
 
2764
                                    &space, table->name, FALSE, flags,
2738
2765
                                    FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) {
2739
2766
                                ut_print_timestamp(stderr);
2740
2767
                                fprintf(stderr,
2839
2866
 
2840
2867
        mem_heap_free(heap);
2841
2868
 
2842
 
        dict_hdr_get_new_id(&new_id, NULL, NULL);
 
2869
        new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
2843
2870
 
2844
2871
        info = pars_info_create();
2845
2872