MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //usr/share/mysql-test/suite/innodb_plugin/t/innodb_bug47621.test
# This is the test for bug #47621, column rename operation should
# not result in column definition inconsistency between MySQL and
# InnoDB

-- source include/have_innodb_plugin.inc

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;