Skip to content

Commit

Permalink
MDEV-18713 Assertion `strcmp(share->unique_file_name,filename) || sha…
Browse files Browse the repository at this point in the history
…re->last_version' failed in test_if_reopen upon REPLACE into table with key on blob

close table->update_handler in close_thread_tables().
it's not enough to do it in sql_update.cc only, because
sql_insert.cc can also do updates (REPLACE) and even
sql_delete.cc can (DELETE ... FOR PORTION OF)
  • Loading branch information
vuvova committed Feb 28, 2019
1 parent 20c89f9 commit 3f53515
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions mysql-test/main/long_unique_bugs.result
Expand Up @@ -20,3 +20,9 @@ t1 CREATE TABLE `t1` (
UNIQUE KEY `b` (`b`) USING HASH
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (pk int, b blob, primary key(pk), unique(b)) engine=myisam;
insert into t1 values (1,'foo');
replace into t1 (pk) values (1);
alter table t1 force;
replace into t1 (pk) values (1);
drop table t1;
10 changes: 10 additions & 0 deletions mysql-test/main/long_unique_bugs.test
Expand Up @@ -26,3 +26,13 @@ alter table t1 add unique (b);
alter table t1 force;
show create table t1;
drop table t1;

#
# MDEV-18713 Assertion `strcmp(share->unique_file_name,filename) || share->last_version' failed in test_if_reopen upon REPLACE into table with key on blob
#
create table t1 (pk int, b blob, primary key(pk), unique(b)) engine=myisam;
insert into t1 values (1,'foo');
replace into t1 (pk) values (1);
alter table t1 force;
replace into t1 (pk) values (1);
drop table t1;
6 changes: 5 additions & 1 deletion sql/sql_base.cc
Expand Up @@ -850,12 +850,16 @@ void close_thread_tables(THD *thd)
DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt ||
(thd->state_flags & Open_tables_state::BACKUPS_AVAIL));

/* Detach MERGE children after every statement. Even under LOCK TABLES. */
for (table= thd->open_tables; table; table= table->next)
{
if (table->update_handler)
table->delete_update_handler();

/* Table might be in use by some outer statement. */
DBUG_PRINT("tcache", ("table: '%s' query_id: %lu",
table->s->table_name.str, (ulong) table->query_id));

/* Detach MERGE children after every statement. Even under LOCK TABLES. */
if (thd->locked_tables_mode <= LTM_LOCK_TABLES ||
table->query_id == thd->query_id)
{
Expand Down
4 changes: 0 additions & 4 deletions sql/sql_update.cc
Expand Up @@ -1137,8 +1137,6 @@ int mysql_update(THD *thd,
break;
}
}
if (table->update_handler)
table->delete_update_handler();
ANALYZE_STOP_TRACKING(&explain->command_tracker);
table->auto_increment_field_not_null= FALSE;
dup_key_found= 0;
Expand Down Expand Up @@ -2371,8 +2369,6 @@ multi_update::~multi_update()
for (table= update_tables ; table; table= table->next_local)
{
table->table->no_keyread= 0;
if (table->table->update_handler)
table->table->delete_update_handler();
if (ignore)
table->table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
}
Expand Down

0 comments on commit 3f53515

Please sign in to comment.