Bug#32948: FKs allowed to reference partitioned table
Problem: when alter to partitioned table, it does not see it as change of engine. Solution: If alter includes partitioning, check if it is possible to change engines (eg. is the table referenced by a FK)
This commit is contained in:
parent
5452a154d6
commit
c27d93c83a
@ -1,3 +1,15 @@
|
|||||||
|
# Bug#32948
|
||||||
|
CREATE TABLE t1 (c1 INT, PRIMARY KEY (c1)) ENGINE=INNODB;
|
||||||
|
CREATE TABLE t2 (c1 INT, PRIMARY KEY (c1),
|
||||||
|
FOREIGN KEY (c1) REFERENCES t1 (c1)
|
||||||
|
ON DELETE CASCADE)
|
||||||
|
ENGINE=INNODB;
|
||||||
|
ALTER TABLE t1 PARTITION BY HASH(c1) PARTITIONS 5;
|
||||||
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
||||||
|
ALTER TABLE t1 ENGINE=MyISAM;
|
||||||
|
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
||||||
|
DROP TABLE t2;
|
||||||
|
DROP TABLE t1;
|
||||||
create table t1 (a int) engine=innodb partition by hash(a) ;
|
create table t1 (a int) engine=innodb partition by hash(a) ;
|
||||||
show table status like 't1';
|
show table status like 't1';
|
||||||
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
|
||||||
|
@ -1,6 +1,21 @@
|
|||||||
--source include/have_partition.inc
|
--source include/have_partition.inc
|
||||||
--source include/have_innodb.inc
|
--source include/have_innodb.inc
|
||||||
|
|
||||||
|
# Bug#32948 - FKs allowed to reference partitioned table
|
||||||
|
#
|
||||||
|
-- echo # Bug#32948
|
||||||
|
CREATE TABLE t1 (c1 INT, PRIMARY KEY (c1)) ENGINE=INNODB;
|
||||||
|
CREATE TABLE t2 (c1 INT, PRIMARY KEY (c1),
|
||||||
|
FOREIGN KEY (c1) REFERENCES t1 (c1)
|
||||||
|
ON DELETE CASCADE)
|
||||||
|
ENGINE=INNODB;
|
||||||
|
--error ER_ROW_IS_REFERENCED
|
||||||
|
ALTER TABLE t1 PARTITION BY HASH(c1) PARTITIONS 5;
|
||||||
|
--error ER_ROW_IS_REFERENCED
|
||||||
|
ALTER TABLE t1 ENGINE=MyISAM;
|
||||||
|
DROP TABLE t2;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Bug #14673: Wrong InnoDB default row format
|
# Bug #14673: Wrong InnoDB default row format
|
||||||
#
|
#
|
||||||
|
@ -5974,7 +5974,8 @@ view_err:
|
|||||||
goto err;
|
goto err;
|
||||||
new_db_type= create_info->db_type;
|
new_db_type= create_info->db_type;
|
||||||
|
|
||||||
if (new_db_type != old_db_type &&
|
if ((new_db_type != old_db_type ||
|
||||||
|
alter_info->flags & ALTER_PARTITION) &&
|
||||||
!table->file->can_switch_engines())
|
!table->file->can_switch_engines())
|
||||||
{
|
{
|
||||||
my_error(ER_ROW_IS_REFERENCED, MYF(0));
|
my_error(ER_ROW_IS_REFERENCED, MYF(0));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user