mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-34392 Inplace algorithm violates the foreign key constraint
Don't allow the referencing key column from NULL TO NOT NULL when 1) Foreign key constraint type is ON UPDATE SET NULL 2) Foreign key constraint type is ON DELETE SET NULL 3) Foreign key constraint type is UPDATE CASCADE and referenced column declared as NULL Don't allow the referenced key column from NOT NULL to NULL when foreign key constraint type is UPDATE CASCADE and referencing key columns doesn't allow NULL values get_foreign_key_info(): InnoDB sends the information about nullability of the foreign key fields and referenced key fields. fk_check_column_changes(): Enforce the above rules for COPY algorithm innobase_check_foreign_drop_col(): Checks whether the dropped column exists in existing foreign key relation innobase_check_foreign_low() : Enforce the above rules for INPLACE algorithm dict_foreign_t::check_fk_constraint_valid(): This is used by CREATE TABLE statement to check nullability for foreign key relation.
This commit is contained in:
@@ -168,7 +168,7 @@ alter table t4 drop index d;
|
||||
alter table t2 drop index b;
|
||||
--error ER_DROP_INDEX_FK
|
||||
alter table t2 drop index b, drop index c, drop index d;
|
||||
--error ER_FK_COLUMN_CANNOT_CHANGE
|
||||
--error ER_FK_COLUMN_NOT_NULL
|
||||
alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY;
|
||||
# NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on.
|
||||
set @old_sql_mode = @@sql_mode;
|
||||
|
Reference in New Issue
Block a user