blob: 64a6ff761eadb46f2de06cb35a60e1f30ac2d287 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
--source include/have_innodb.inc
# This is the test for bug #47621, column rename operation should
# not result in column definition inconsistency between MySQL and
# InnoDB
CREATE TABLE bug47621 (salesperson INT) ENGINE=InnoDB;
# Change the column name
ALTER TABLE bug47621 CHANGE salesperson sales_acct_id INT;
# If there is inconsistency of column name definition
# in MySQL or InnoDB, following create index would fail
create index orgs on bug47621(sales_acct_id);
# Change the column name back with the index defined on it.
ALTER TABLE bug47621 CHANGE sales_acct_id salesperson INT;
drop table bug47621;
CREATE TABLE bug47621_sale (
salesperson INT,
PRIMARY KEY(salesperson)) engine = innodb;
CREATE TABLE bug47621_shirt(
id SMALLINT,
owner INT,
FOREIGN KEY(owner)
references bug47621_sale(salesperson) ON DELETE RESTRICT)
engine = innodb;
insert into bug47621_sale values(9);
insert into bug47621_shirt values(1, 9);
# Any rename operation on columns involved in a reference constraint will
# fail, as it will be rejected by InnoDB row_rename_table_for_mysql().
# In above example, any rename on column "salesperson" for table
# "bug47621_sale", or on column "owner" for table "bug47621_shirt will
# be blocked. We do not put such rename in the test since InnoDB error
# message will be printed in the error log, and result in test failure.
#
# ALTER TABLE bug47621_sale CHANGE salesperson sales_acct_id INT;
# Any rename on columns not involved in the foreign key constraint
# could still proceed
ALTER TABLE bug47621_shirt CHANGE id new_id INT;
# Referencing table dropped, the rename operation on related columns
# could proceed
drop table bug47621_shirt;
ALTER TABLE bug47621_sale CHANGE salesperson sales_acct_id INT;
ALTER TABLE bug47621_sale ADD INDEX idx (sales_acct_id);
drop table bug47621_sale;
|