Bug #16997 Table rename that changes database does not rename indexes
Submitted: 1 Feb 2006 9:10 Modified: 2 Jun 2006 4:32
Reporter: Martin Skold Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:4.1/5.0/5.1 OS:
Assigned to: Martin Skold CPU Architecture:Any

[1 Feb 2006 9:10] Martin Skold
Description:
If one renames one table so that it moves
from one database to another, indexes are
not moved along. In ndb (and in mysql)
table names are paths with database as
level above table name. In ndb indexes
are special tables stored along the table.
To optimize table rename (at alter table),
indexes are not renamed when table name
changes (they use table-id in there name,
which does not change at rename).
If database changes, they must be renamed.

How to repeat:
create table t2 (a int primary key);
create database mysqltest;
use mysqltest;
alter table test.t2 rename t2;
-- indexes are now still in test and any use of them will fail

Suggested fix:
Quick fix, in ha_ndbcluster::rename_table, detect
database change and rename each index.
Long term fix: make DICT handle database change.
[5 May 2006 15:20] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/6016
[24 May 2006 9:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/6817
[31 May 2006 8:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/7080
[1 Jun 2006 5:06] Tomas Ulin
pushed to 5.1.12
[2 Jun 2006 4:32] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented bugfix in 4.1.21/5.0.23/5.1.12 changelogs; closed.