• Marko Mäkelä's avatar
    Bug#24397406 INNODB: ALGORITHM=INPLACE FAILS TO PROMOTE UNIQUE KEY TO CLUSTERED INDEX · 01389ee8
    Marko Mäkelä authored
    When a table has no PRIMARY KEY, but there is a UNIQUE INDEX
    defined on NOT NULL columns that are not column prefixes,
    that unique index must be treated as the primary key.
    
    This property was being violated by InnoDB when a column was changed
    to NOT NULL, such that a UNIQUE INDEX on that column became eligible
    to being treated as a primary key.
    
    innobase_create_key_defs(): Instead of checking each ADD [UNIQUE] INDEX
    request, check if a GEN_CLUST_INDEX can be replaced with any unique index
    in the altered_table definition. So, we can have new_primary even
    if n_add==0.
    
    prepare_inplace_alter_table_dict(): When the table is not being rebuilt,
    assert that TABLE_SHARE::primary_key is not changing.
    
    RB: 13595
    Reviewed-by: default avatarKevin Lewis <kevin.lewis@oracle.com>
    01389ee8
handler0alter.cc 258 KB