~james-page/ubuntu/precise/mysql-5.5/misc-fixes

« 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-06-11 07:34:33 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120611073433-l9za2ni4ipp848y3
Tags: 5.5.24-0ubuntu0.12.04.1
* SECURITY UPDATE: Update to 5.5.24 to fix security issues (LP: #1011371)
  - http://dev.mysql.com/doc/refman/5.5/en/news-5-5-24.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All Rights Reserved.
 
3
Copyright (c) 2000, 2012, Oracle and/or its affiliates. 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
11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
12
 
13
13
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
 
Place, Suite 330, Boston, MA 02111-1307 USA
 
14
this program; if not, write to the Free Software Foundation, Inc.,
 
15
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16
16
 
17
17
*****************************************************************************/
18
18
 
51
51
#include "btr0sea.h"
52
52
#include "fil0fil.h"
53
53
#include "ibuf0ibuf.h"
 
54
#include "m_string.h"
 
55
#include "my_sys.h"
 
56
 
54
57
 
55
58
/** Provide optional 4.x backwards compatibility for 5.0 and above */
56
59
UNIV_INTERN ibool       row_rollback_on_timeout = FALSE;
1443
1446
                return(DB_ERROR);
1444
1447
        }
1445
1448
 
 
1449
        DEBUG_SYNC_C("innodb_row_update_for_mysql_begin");
 
1450
 
1446
1451
        trx->op_info = "updating or deleting";
1447
1452
 
1448
1453
        row_mysql_delay_if_needed();
1783
1788
{
1784
1789
        ut_a(trx->dict_operation_lock_mode == 0);
1785
1790
 
1786
 
        rw_lock_s_lock_func(&dict_operation_lock, 0, file, line);
 
1791
        rw_lock_s_lock_inline(&dict_operation_lock, 0, file, line);
1787
1792
 
1788
1793
        trx->dict_operation_lock_mode = RW_S_LATCH;
1789
1794
}
1820
1825
        /* Serialize data dictionary operations with dictionary mutex:
1821
1826
        no deadlocks or lock waits can occur then in these operations */
1822
1827
 
1823
 
        rw_lock_x_lock_func(&dict_operation_lock, 0, file, line);
 
1828
        rw_lock_x_lock_inline(&dict_operation_lock, 0, file, line);
1824
1829
        trx->dict_operation_lock_mode = RW_X_LATCH;
1825
1830
 
1826
1831
        mutex_enter(&(dict_sys->mutex));
1994
1999
        case DB_TOO_MANY_CONCURRENT_TRXS:
1995
2000
                /* We already have .ibd file here. it should be deleted. */
1996
2001
 
1997
 
                if (table->space && !fil_delete_tablespace(table->space)) {
 
2002
                if (table->space && !fil_delete_tablespace(table->space,
 
2003
                                                           FALSE)) {
1998
2004
                        ut_print_timestamp(stderr);
1999
2005
                        fprintf(stderr,
2000
2006
                                "  InnoDB: Error: not able to"
3075
3081
{
3076
3082
        dict_foreign_t* foreign;
3077
3083
        dict_table_t*   table;
 
3084
        dict_index_t*   index;
3078
3085
        ulint           space_id;
3079
3086
        ulint           err;
3080
3087
        const char*     table_name;
3282
3289
        trx_set_dict_operation(trx, TRX_DICT_OP_TABLE);
3283
3290
        trx->table_id = table->id;
3284
3291
 
 
3292
        /* Mark all indexes unavailable in the data dictionary cache
 
3293
        before starting to drop the table. */
 
3294
 
 
3295
        for (index = dict_table_get_first_index(table);
 
3296
             index != NULL;
 
3297
             index = dict_table_get_next_index(index)) {
 
3298
                rw_lock_x_lock(dict_index_get_lock(index));
 
3299
                ut_ad(!index->to_be_dropped);
 
3300
                index->to_be_dropped = TRUE;
 
3301
                rw_lock_x_unlock(dict_index_get_lock(index));
 
3302
        }
 
3303
 
3285
3304
        /* We use the private SQL parser of Innobase to generate the
3286
3305
        query graphs needed in deleting the dictionary data from system
3287
3306
        tables in Innobase. Deleting a row from SYS_INDEXES table also
3420
3439
                                        "InnoDB: of table ");
3421
3440
                                ut_print_name(stderr, trx, TRUE, name);
3422
3441
                                fprintf(stderr, ".\n");
3423
 
                        } else if (!fil_delete_tablespace(space_id)) {
 
3442
                        } else if (!fil_delete_tablespace(space_id, FALSE)) {
3424
3443
                                fprintf(stderr,
3425
3444
                                        "InnoDB: We removed now the InnoDB"
3426
3445
                                        " internal data dictionary entry\n"
3447
3466
                the undo log. We can directly exit here
3448
3467
                and return the DB_TOO_MANY_CONCURRENT_TRXS
3449
3468
                error. */
 
3469
 
 
3470
                /* Mark all indexes available in the data dictionary
 
3471
                cache again. */
 
3472
 
 
3473
                for (index = dict_table_get_first_index(table);
 
3474
                     index != NULL;
 
3475
                     index = dict_table_get_next_index(index)) {
 
3476
                        rw_lock_x_lock(dict_index_get_lock(index));
 
3477
                        index->to_be_dropped = FALSE;
 
3478
                        rw_lock_x_unlock(dict_index_get_lock(index));
 
3479
                }
3450
3480
                break;
3451
3481
 
3452
3482
        case DB_OUT_OF_FILE_SPACE:
3803
3833
        ulint           n_constraints_to_drop   = 0;
3804
3834
        ibool           old_is_tmp, new_is_tmp;
3805
3835
        pars_info_t*    info                    = NULL;
 
3836
        int             retry;
3806
3837
 
3807
3838
        ut_a(old_name != NULL);
3808
3839
        ut_a(new_name != NULL);
3885
3916
                }
3886
3917
        }
3887
3918
 
 
3919
        /* Is a foreign key check running on this table? */
 
3920
        for (retry = 0; retry < 100
 
3921
             && table->n_foreign_key_checks_running > 0; ++retry) {
 
3922
                row_mysql_unlock_data_dictionary(trx);
 
3923
                os_thread_yield();
 
3924
                row_mysql_lock_data_dictionary(trx);
 
3925
        }
 
3926
 
 
3927
        if (table->n_foreign_key_checks_running > 0) {
 
3928
                ut_print_timestamp(stderr);
 
3929
                fputs(" InnoDB: Error: in ALTER TABLE ", stderr);
 
3930
                ut_print_name(stderr, trx, TRUE, old_name);
 
3931
                fprintf(stderr, "\n"
 
3932
                        "InnoDB: a FOREIGN KEY check is running.\n"
 
3933
                        "InnoDB: Cannot rename table.\n");
 
3934
                err = DB_TABLE_IN_FK_CHECK;
 
3935
                goto funct_exit;
 
3936
        }
 
3937
 
3888
3938
        /* We use the private SQL parser of Innobase to generate the query
3889
3939
        graphs needed in updating the dictionary data from system tables. */
3890
3940