Commit a3c60017 authored by heikki's avatar heikki

Fix bug #21784 of a crash in DROP TABLE with concurrent queries on the table

parent 799b0638
...@@ -6789,19 +6789,17 @@ ha_innobase::store_lock( ...@@ -6789,19 +6789,17 @@ ha_innobase::store_lock(
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx; trx_t* trx;
/* Call update_thd() to update prebuilt->trx to point to the trx /* Note that trx in this function is NOT necessarily prebuilt->trx
object of thd! Failure to do this caused a serious memory because we call update_thd() later, in ::external_lock()! Failure to
corruption bug in 5.1.11. */ understand this caused a serious memory corruption bug in 5.1.11. */
update_thd(thd); trx = check_trx_exists(thd);
trx = prebuilt->trx;
/* NOTE: MySQL can call this function with lock 'type' TL_IGNORE! /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE!
Be careful to ignore TL_IGNORE if we are going to do something with Be careful to ignore TL_IGNORE if we are going to do something with
only 'real' locks! */ only 'real' locks! */
/* If no MySQL tables is use we need to set isolation level /* If no MySQL table is in use, we need to set the isolation level
of the transaction. */ of the transaction. */
if (lock_type != TL_IGNORE if (lock_type != TL_IGNORE
...@@ -6811,7 +6809,13 @@ ha_innobase::store_lock( ...@@ -6811,7 +6809,13 @@ ha_innobase::store_lock(
thd->variables.tx_isolation); thd->variables.tx_isolation);
} }
if ((lock_type == TL_READ && thd->in_lock_tables) || if (thd->lex->sql_command == SQLCOM_DROP_TABLE) {
/* MySQL calls this function in DROP TABLE though this table
handle may belong to another thd that is running a query. Let
us in that case skip any changes to the prebuilt struct. */
} else if ((lock_type == TL_READ && thd->in_lock_tables) ||
(lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) || (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) ||
lock_type == TL_READ_WITH_SHARED_LOCKS || lock_type == TL_READ_WITH_SHARED_LOCKS ||
lock_type == TL_READ_NO_INSERT || lock_type == TL_READ_NO_INSERT ||
...@@ -7071,8 +7075,11 @@ ha_innobase::innobase_read_and_init_auto_inc( ...@@ -7071,8 +7075,11 @@ ha_innobase::innobase_read_and_init_auto_inc(
in table.h says that 'next_number_field' is set when it is in table.h says that 'next_number_field' is set when it is
'active'. */ 'active'. */
my_bitmap_map *old_map;
old_map= dbug_tmp_use_all_columns(table, table->read_set);
auto_inc = (longlong) table->found_next_number_field-> auto_inc = (longlong) table->found_next_number_field->
val_int_offset(table->s->rec_buff_length) + 1; val_int_offset(table->s->rec_buff_length) + 1;
dbug_tmp_restore_column_map(table->read_set, old_map);
} }
dict_table_autoinc_initialize(prebuilt->table, auto_inc); dict_table_autoinc_initialize(prebuilt->table, auto_inc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment