diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2015-11-18 21:31:45 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2015-11-18 21:31:45 +0300 |
commit | f91798dd1c9e178061ba58c88a42b9cb3701385d (patch) | |
tree | 68d64690d16cbc5dd27abc4f5d9bfa5a0fee8ad1 /sql/sql_rename.cc | |
parent | c2ec897745f37c1479dc9be3a2a3b476e4ed694f (diff) | |
download | mariadb-git-f91798dd1c9e178061ba58c88a42b9cb3701385d.tar.gz |
MDEV-7370: Server deadlocks on renaming a table for which persistent statistics exists
RENAME TABLE code tries to update EITS statistics. It hung, because
it used an index on (db_name,table_name) to find the table, and attempted
to update these values at the same time. The fix is do what SQL UPDATE
statement does when updating index that it's used for scanning:
- First, buffer the rowids of rows to be updated,
- then make the second pass to actually update the rows
Also fixed the call to rename_table_in_stat_tables() in sql_rename.cc
to pass the correct new database (before, it passed old db_name so cross-
database renames were not handled correctly).
Variant #2, with review feedback addressed.
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r-- | sql/sql_rename.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 6496e1895fb..e0fd7005cd5 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -274,8 +274,9 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, LEX_STRING table_name= { ren_table->table_name, ren_table->table_name_length }; LEX_STRING new_table= { (char *) new_alias, strlen(new_alias) }; + LEX_STRING new_db_name= { (char*)new_db, strlen(new_db)}; (void) rename_table_in_stat_tables(thd, &db_name, &table_name, - &db_name, &new_table); + &new_db_name, &new_table); if ((rc= Table_triggers_list::change_table_name(thd, ren_table->db, old_alias, ren_table->table_name, |