1 # This is the test for bug #47621, column rename operation should
2 # not result in column definition inconsistency between MySQL and
5 -- source include/have_innodb_plugin.inc
7 CREATE TABLE bug47621 (salesperson INT) ENGINE=InnoDB;
9 # Change the column name
10 ALTER TABLE bug47621 CHANGE salesperson sales_acct_id INT;
12 # If there is inconsistency of column name definition
13 # in MySQL or InnoDB, following create index would fail
14 create index orgs on bug47621(sales_acct_id);
16 # Change the column name back with the index defined on it.
17 ALTER TABLE bug47621 CHANGE sales_acct_id salesperson INT;
21 CREATE TABLE bug47621_sale (
23 PRIMARY KEY(salesperson)) engine = innodb;
25 CREATE TABLE bug47621_shirt(
29 references bug47621_sale(salesperson) ON DELETE RESTRICT)
32 insert into bug47621_sale values(9);
34 insert into bug47621_shirt values(1, 9);
36 # Any rename operation on columns involved in a reference constraint will
37 # fail, as it will be rejected by InnoDB row_rename_table_for_mysql().
38 # In above example, any rename on column "salesperson" for table
39 # "bug47621_sale", or on column "owner" for table "bug47621_shirt will
40 # be blocked. We do not put such rename in the test since InnoDB error
41 # message will be printed in the error log, and result in test failure.
43 # ALTER TABLE bug47621_sale CHANGE salesperson sales_acct_id INT;
45 # Any rename on columns not involved in the foreign key constraint
47 ALTER TABLE bug47621_shirt CHANGE id new_id INT;
49 # Referencing table dropped, the rename operation on related columns
51 drop table bug47621_shirt;
53 ALTER TABLE bug47621_sale CHANGE salesperson sales_acct_id INT;
55 ALTER TABLE bug47621_sale ADD INDEX idx (sales_acct_id);
57 drop table bug47621_sale;