Commit 264f83f0 authored by unknown's avatar unknown

InnoDB: Allow concurrent TRUNCATE and INSERT on a table. (Bug #8144)


innobase/include/rem0rec.ic:
  Improve formatting of comments
innobase/include/trx0trx.h:
  dict_operation: document the effect of setting the flag
innobase/row/row0mysql.c:
  Do not set the dict_operation flag. (Bug #8144)
  Allow MySQL to have open handles to the table being truncated.
sql/ha_innodb.cc:
  store_lock(): Do not weaken TL_WRITE locks taken by TRUNCATE TABLE.
parent 9aad0ae3
......@@ -526,7 +526,7 @@ bits of a record. (Only compact records have status bits.) */
UNIV_INLINE
ulint
rec_get_info_and_status_bits(
/*==============*/
/*=========================*/
/* out: info bits */
rec_t* rec, /* in: physical record */
ibool comp) /* in: TRUE=compact page format */
......@@ -550,7 +550,7 @@ bits of a record. (Only compact records have status bits.) */
UNIV_INLINE
void
rec_set_info_and_status_bits(
/*==============*/
/*=========================*/
rec_t* rec, /* in: physical record */
ibool comp, /* in: TRUE=compact page format */
ulint bits) /* in: info bits */
......
......@@ -383,7 +383,9 @@ struct trx_struct{
dulint commit_lsn; /* lsn at the time of the commit */
ibool dict_operation; /* TRUE if the trx is used to create
a table, create an index, or drop a
table */
table. This is a hint that the table
may need to be dropped in crash
recovery. */
dulint table_id; /* table id if the preceding field is
TRUE */
/*------------------------------*/
......
......@@ -2561,17 +2561,6 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */
goto funct_exit;
}
if (table->n_mysql_handles_opened > 1) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: MySQL is trying to truncate table ", stderr);
ut_print_name(stderr, trx, table->name);
fputs("\n"
"InnoDB: though there are still open handles to it.\n", stderr);
err = DB_ERROR;
goto funct_exit;
}
/* TODO: could we replace the counter n_foreign_key_checks_running
with lock checks on the table? Acquire here an exclusive lock on the
table, and rewrite lock0lock.c and the lock wait in srv0srv.c so that
......@@ -2594,7 +2583,6 @@ fputs(" InnoDB: Warning: MySQL is trying to truncate table ", stderr);
lock_reset_all_on_table(table);
trx->dict_operation = TRUE;
trx->table_id = table->id;
/* scan SYS_INDEXES for all indexes of the table */
......
......@@ -5787,11 +5787,12 @@ ha_innobase::store_lock(
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) {
/* If we are not doing a LOCK TABLE or DISCARD/IMPORT
TABLESPACE, then allow multiple writers */
TABLESPACE or TRUNCATE TABLE, then allow multiple writers */
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
lock_type <= TL_WRITE) && !thd->in_lock_tables
&& !thd->tablespace_op) {
&& !thd->tablespace_op
&& thd->lex->sql_command != SQLCOM_TRUNCATE) {
lock_type = TL_WRITE_ALLOW_WRITE;
}
......
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