1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-13838: Wrong result after altering a partitioned table

Reverted incorrect changes done on MDEV-7367 and MDEV-9469. Fixes properly
also related bugs:

MDEV-13668: InnoDB unnecessarily rebuilds table when renaming a column and adding index
MDEV-9469: 'Incorrect key file' on ALTER TABLE
MDEV-9548: Alter table (renaming and adding index) fails with "Incorrect key file for table"
MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash
MDEV-13640: ALTER TABLE CHANGE and ADD INDEX on auto_increment column fails with "Incorrect key file for table..."

Root cause for all these bugs is the fact that MariaDB .frm file
can contain virtual columns but InnoDB dictionary does not and
previous fixes were incorrect or unnecessarily forced table
rebuilt. In index creation key_part->fieldnr can be bigger than
number of columns in InnoDB data dictionary. We need to skip not
stored fields when calculating correct column number for InnoDB
data dictionary.

dict_table_get_col_name_for_mysql
        Remove

innobase_match_index_columns
        Revert incorrect change done on MDEV-7367

innobase_need_rebuild
        Remove unnecessary rebuild force when column is renamed.

innobase_create_index_field_def
        Calculate InnoDB column number correctly and remove
        unnecessary column name set.

innobase_create_index_def, innobase_create_key_defs
        Remove unneeded fields parameter. Revert unneeded memset.

prepare_inplace_alter_table_dict
        Remove unneeded col_names parameter

index_field_t
        Remove unneeded col_name member.

row_merge_create_index
        Remove unneeded col_names parameter and resolution.

Effected tests:
         innodb-alter-table : Add test case for MDEV-13668
         innodb-alter : Remove MDEV-13668, MDEV-9469 FIXMEs
                        and restore original tests
         innodb-wl5980-alter : Remove MDEV-13668,  MDEV-9469 FIXMEs
                        and restore original tests
This commit is contained in:
Jan Lindström
2017-10-10 10:19:10 +03:00
parent 2db5e4d1f9
commit fc9ff69578
18 changed files with 178 additions and 346 deletions

View File

@ -298,21 +298,12 @@ SHOW CREATE TABLE t1n;
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
--error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY;
# FIXME: MDEV-13668 InnoDB unnecessarily rebuilds table
# when renaming a column and adding index
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE;
SHOW CREATE TABLE t1n;
ALTER TABLE t1n DROP INDEX c4;
--error ER_DUP_FIELDNAME
ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE;
# FIXME: MDEV-13668
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE;
ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE;
ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE;
SHOW CREATE TABLE t1n;
DROP TABLE t1n;
@ -370,16 +361,12 @@ CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL;
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id);
# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE
call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o");
--error ER_NOT_KEYFILE
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
ADD FULLTEXT INDEX(ct);
# FIXME: MDEV-9469 (enable this)
#--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
#ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
#ALGORITHM=INPLACE;
#end of MDEV-9469 FIXME
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
ALGORITHM=INPLACE;
DROP TABLE sys_indexes;
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
@ -494,6 +481,3 @@ eval ALTER TABLE $source_db.t1 DROP INDEX index2, algorithm=inplace;
eval DROP TABLE $source_db.t1;
eval DROP DATABASE $source_db;
eval DROP DATABASE $dest_db;