Skip to content
  • Dmitry Lenev's avatar
    febe02d6
    Bug#29173134 "FOREIGN KEY CONSTRAINT NAMES TAKING INDEX NAME". · febe02d6
    Dmitry Lenev authored
    In MySQL 8.0, for InnoDB tables, name of key specified in FOREIGN KEY <name>
    part of foreign key definition was used as a name of the foreign key created
    in cases when there was no name specified using CONSTRAINT <name>
    clause. In MySQL 5.7 the name of foreign key was automatically generated
    in the same situation.
    
    Such a change in behavior this has broken user applications which relied on
    the fact that it was possible to create several foreign keys using the same
    name in FOREIGN KEY <name> part of foreign key definition within the same
    database. This also could have caused problems when replicating DDL adding/
    dropping such foreign keys from MySQL 5.7 to 8.0.
    
    Note that for NDB tables name from the FOREIGN KEY <name> part of
    definition was used as foreign key name in absence of name in CONSTRAINT
    clause in both 5.7 and 8.0.
    
    This patch fixes the issue by changing 8.0 behavior for InnoDB tables
    to be the same as in 5.7. This is an incompatible change for 8.0 branch,
    which, for example, can break user applications written with old 8.0
    behavior in mind or DDL replication from earlier version of 8.0.
    However, we prefer to do it to restore compatibility with 5.7 and
    fix cross-version replication from 5.7 branch.
    
    Behavior for foreign keys on NDB tables is changed to be consistent with
    InnoDB, i.e. to be the same as behavior for foreign keys on InnoDB tables
    in 5.7. This is incompatible change, but it makes behavior uniform and
    is much smaller than existing difference in foreign key name handling for
    NDB tables between 5.7 and 8.0 (the latter requires foreign key names to
    be unique within same schema and uses different format for auto-generated
    foreign key names than 5.7).
    
    Approved by: Sivert Sorumgaard <sivert.sorumgaard@oracle.com>
    febe02d6
    Bug#29173134 "FOREIGN KEY CONSTRAINT NAMES TAKING INDEX NAME".
    Dmitry Lenev authored
    In MySQL 8.0, for InnoDB tables, name of key specified in FOREIGN KEY <name>
    part of foreign key definition was used as a name of the foreign key created
    in cases when there was no name specified using CONSTRAINT <name>
    clause. In MySQL 5.7 the name of foreign key was automatically generated
    in the same situation.
    
    Such a change in behavior this has broken user applications which relied on
    the fact that it was possible to create several foreign keys using the same
    name in FOREIGN KEY <name> part of foreign key definition within the same
    database. This also could have caused problems when replicating DDL adding/
    dropping such foreign keys from MySQL 5.7 to 8.0.
    
    Note that for NDB tables name from the FOREIGN KEY <name> part of
    definition was used as foreign key name in absence of name in CONSTRAINT
    clause in both 5.7 and 8.0.
    
    This patch fixes the issue by changing 8.0 behavior for InnoDB tables
    to be the same as in 5.7. This is an incompatible change for 8.0 branch,
    which, for example, can break user applications written with old 8.0
    behavior in mind or DDL replication from earlier version of 8.0.
    However, we prefer to do it to restore compatibility with 5.7 and
    fix cross-version replication from 5.7 branch.
    
    Behavior for foreign keys on NDB tables is changed to be consistent with
    InnoDB, i.e. to be the same as behavior for foreign keys on InnoDB tables
    in 5.7. This is incompatible change, but it makes behavior uniform and
    is much smaller than existing difference in foreign key name handling for
    NDB tables between 5.7 and 8.0 (the latter requires foreign key names to
    be unique within same schema and uses different format for auto-generated
    foreign key names than 5.7).
    
    Approved by: Sivert Sorumgaard <sivert.sorumgaard@oracle.com>
Loading