Skip to content
  • Lakshmi Narayanan Sreethar's avatar
    c00419fb
    Bug#22110051 : ASSERTION IN PROTOCOL::END_STATEMENT DURING DROP INDEX · c00419fb
    Lakshmi Narayanan Sreethar authored
    Drop index query on an ndb table crashes the server if the table has
    foreign keys. Internally, 'drop index' query is mapped to an 'alter table'
    query. But the thd->lex->sql_command value is different for the queries.
    For alter table, the value is SQLCOM_ALTER_TABLE and for drop index it
    is SQLCOM_DROP_INDEX. and the functions create and drop_table_impl
    don't handle SQLCOM_DROP_INDEX query type. This is fixed by proper
    handling of SQLCOM_DROP_INDEX type in the above said functions.
    
    This patch also fixes the following issue.
    
    For a table without any primary key, mysqld server passes any available,
    not nullable column with an unique key as the implicit primary key. If
    an 'alter table' either dropping the unique index on that column or
    removing the constraint not null is issued, the implicit primary key
    gets changed. If any foreign key was referencing that column, during the
    alter query, its parent key has to be updated. But
    copy_fk_for_offline_alter() function while copying the foreign keys from
    the old table to the new table, copies the parent index as it is, if the
    index was previously a primary key. This leads to an inconsistent
    foreign key constraint.
    
    This patch fixes that by checking if the pk is intact during the alter.
    It either preserves the fk's parent key if the pk is intact or else
    finds for a better matching index. If a matching index is not found, it
    returns an error and the alter is aborted.
    c00419fb
    Bug#22110051 : ASSERTION IN PROTOCOL::END_STATEMENT DURING DROP INDEX
    Lakshmi Narayanan Sreethar authored
    Drop index query on an ndb table crashes the server if the table has
    foreign keys. Internally, 'drop index' query is mapped to an 'alter table'
    query. But the thd->lex->sql_command value is different for the queries.
    For alter table, the value is SQLCOM_ALTER_TABLE and for drop index it
    is SQLCOM_DROP_INDEX. and the functions create and drop_table_impl
    don't handle SQLCOM_DROP_INDEX query type. This is fixed by proper
    handling of SQLCOM_DROP_INDEX type in the above said functions.
    
    This patch also fixes the following issue.
    
    For a table without any primary key, mysqld server passes any available,
    not nullable column with an unique key as the implicit primary key. If
    an 'alter table' either dropping the unique index on that column or
    removing the constraint not null is issued, the implicit primary key
    gets changed. If any foreign key was referencing that column, during the
    alter query, its parent key has to be updated. But
    copy_fk_for_offline_alter() function while copying the foreign keys from
    the old table to the new table, copies the parent index as it is, if the
    index was previously a primary key. This leads to an inconsistent
    foreign key constraint.
    
    This patch fixes that by checking if the pk is intact during the alter.
    It either preserves the fk's parent key if the pk is intact or else
    finds for a better matching index. If a matching index is not found, it
    returns an error and the alter is aborted.
Loading