mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 14:33:32 +03:00 
			
		
		
		
	1. BUG#21704 - Renaming column does not update FK definition 2. Changes in mysql-test/include/mtr_warnings.sql so that the testcase for BUG#21704 doesn't fail because of the warnings generated. Detailed revision comments: r5488 | vasil | 2009-07-09 19:16:44 +0300 (Thu, 09 Jul 2009) | 13 lines branches/5.1: Fix Bug#21704 Renaming column does not update FK definition by checking whether a column that participates in a FK definition is being renamed and denying the ALTER in this case. The patch was originally developed by Davi Arnaut <Davi.Arnaut@Sun.COM>: http://lists.mysql.com/commits/77714 and was later adjusted to conform to InnoDB coding style by me (Vasil), I also added some more comments and moved the bug specific mysql-test to a separate file to make it more manageable and flexible.
		
			
				
	
	
		
			97 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			97 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
-- source include/have_innodb.inc
 | 
						|
 | 
						|
--echo #
 | 
						|
--echo # Bug#21704: Renaming column does not update FK definition.
 | 
						|
--echo #
 | 
						|
 | 
						|
--echo
 | 
						|
--echo # Test that it's not possible to rename columns participating in a
 | 
						|
--echo # foreign key (either in the referencing or referenced table).
 | 
						|
--echo
 | 
						|
 | 
						|
--disable_warnings
 | 
						|
DROP TABLE IF EXISTS t1;
 | 
						|
DROP TABLE IF EXISTS t2;
 | 
						|
DROP TABLE IF EXISTS t3;
 | 
						|
--enable_warnings
 | 
						|
 | 
						|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB;
 | 
						|
 | 
						|
CREATE TABLE t2 (a INT PRIMARY KEY, b INT,
 | 
						|
                 CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a))
 | 
						|
ROW_FORMAT=COMPACT ENGINE=INNODB;
 | 
						|
 | 
						|
CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT,
 | 
						|
  CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a))
 | 
						|
ROW_FORMAT=COMPACT ENGINE=INNODB;
 | 
						|
 | 
						|
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
 | 
						|
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
 | 
						|
INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3);
 | 
						|
 | 
						|
--echo
 | 
						|
--echo # Test renaming the column in the referenced table.
 | 
						|
--echo
 | 
						|
 | 
						|
# mysqltest first does replace_regex, then replace_result
 | 
						|
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
 | 
						|
# Embedded server doesn't chdir to data directory
 | 
						|
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
 | 
						|
--error ER_ERROR_ON_RENAME
 | 
						|
ALTER TABLE t1 CHANGE a c INT;
 | 
						|
 | 
						|
--echo # Ensure that online column rename works.
 | 
						|
 | 
						|
--enable_info
 | 
						|
ALTER TABLE t1 CHANGE b c INT;
 | 
						|
--disable_info
 | 
						|
 | 
						|
--echo
 | 
						|
--echo # Test renaming the column in the referencing table
 | 
						|
--echo
 | 
						|
 | 
						|
# mysqltest first does replace_regex, then replace_result
 | 
						|
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
 | 
						|
# Embedded server doesn't chdir to data directory
 | 
						|
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
 | 
						|
--error ER_ERROR_ON_RENAME
 | 
						|
ALTER TABLE t2 CHANGE a c INT;
 | 
						|
 | 
						|
--echo # Ensure that online column rename works.
 | 
						|
 | 
						|
--enable_info
 | 
						|
ALTER TABLE t2 CHANGE b c INT;
 | 
						|
--disable_info
 | 
						|
 | 
						|
--echo
 | 
						|
--echo # Test with self-referential constraints
 | 
						|
--echo
 | 
						|
 | 
						|
# mysqltest first does replace_regex, then replace_result
 | 
						|
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
 | 
						|
# Embedded server doesn't chdir to data directory
 | 
						|
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
 | 
						|
--error ER_ERROR_ON_RENAME
 | 
						|
ALTER TABLE t3 CHANGE a d INT;
 | 
						|
 | 
						|
# mysqltest first does replace_regex, then replace_result
 | 
						|
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
 | 
						|
# Embedded server doesn't chdir to data directory
 | 
						|
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
 | 
						|
--error ER_ERROR_ON_RENAME
 | 
						|
ALTER TABLE t3 CHANGE b d INT;
 | 
						|
 | 
						|
--echo # Ensure that online column rename works.
 | 
						|
 | 
						|
--enable_info
 | 
						|
ALTER TABLE t3 CHANGE c d INT;
 | 
						|
--disable_info
 | 
						|
 | 
						|
--echo
 | 
						|
--echo # Cleanup.
 | 
						|
--echo
 | 
						|
 | 
						|
DROP TABLE t3;
 | 
						|
DROP TABLE t2;
 | 
						|
DROP TABLE t1;
 |