mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / innodb / t / innodb_bug21704.test
blobc649b61034cea9e62aff1db432107d2ca375a484
1 -- source include/have_innodb.inc
3 --echo #
4 --echo # Bug#21704: Renaming column does not update FK definition.
5 --echo #
7 --echo
8 --echo # Test that it's not possible to rename columns participating in a
9 --echo # foreign key (either in the referencing or referenced table).
10 --echo
12 --disable_warnings
13 DROP TABLE IF EXISTS t1;
14 DROP TABLE IF EXISTS t2;
15 DROP TABLE IF EXISTS t3;
16 --enable_warnings
18 CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB;
20 CREATE TABLE t2 (a INT PRIMARY KEY, b INT,
21                  CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a))
22 ROW_FORMAT=COMPACT ENGINE=INNODB;
24 CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT,
25   CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a))
26 ROW_FORMAT=COMPACT ENGINE=INNODB;
28 INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
29 INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
30 INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3);
32 --echo
33 --echo # Test renaming the column in the referenced table.
34 --echo
36 # mysqltest first does replace_regex, then replace_result
37 --replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
38 # Embedded server doesn't chdir to data directory
39 --replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
40 --error ER_ERROR_ON_RENAME
41 ALTER TABLE t1 CHANGE a c INT;
43 --echo # Ensure that online column rename works.
45 --enable_info
46 ALTER TABLE t1 CHANGE b c INT;
47 --disable_info
49 --echo
50 --echo # Test renaming the column in the referencing table
51 --echo
53 # mysqltest first does replace_regex, then replace_result
54 --replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
55 # Embedded server doesn't chdir to data directory
56 --replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
57 --error ER_ERROR_ON_RENAME
58 ALTER TABLE t2 CHANGE a c INT;
60 --echo # Ensure that online column rename works.
62 --enable_info
63 ALTER TABLE t2 CHANGE b c INT;
64 --disable_info
66 --echo
67 --echo # Test with self-referential constraints
68 --echo
70 # mysqltest first does replace_regex, then replace_result
71 --replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
72 # Embedded server doesn't chdir to data directory
73 --replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
74 --error ER_ERROR_ON_RENAME
75 ALTER TABLE t3 CHANGE a d INT;
77 # mysqltest first does replace_regex, then replace_result
78 --replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
79 # Embedded server doesn't chdir to data directory
80 --replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
81 --error ER_ERROR_ON_RENAME
82 ALTER TABLE t3 CHANGE b d INT;
84 --echo # Ensure that online column rename works.
86 --enable_info
87 ALTER TABLE t3 CHANGE c d INT;
88 --disable_info
90 --echo
91 --echo # Cleanup.
92 --echo
94 DROP TABLE t3;
95 DROP TABLE t2;
96 DROP TABLE t1;