mirror of
https://github.com/MariaDB/server.git
synced 2025-12-09 08:01:34 +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:
@@ -185,3 +185,44 @@ ticket CREATE TABLE `ticket` (
|
||||
KEY `org_id` (`org_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
DROP TABLE ticket;
|
||||
CREATE TABLE t (
|
||||
id bigint(20) unsigned NOT NULL auto_increment,
|
||||
d date NOT NULL,
|
||||
a bigint(20) unsigned NOT NULL,
|
||||
b smallint(5) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (id,d)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs STATS_SAMPLE_PAGES=2
|
||||
PARTITION BY RANGE COLUMNS(d)
|
||||
(
|
||||
PARTITION p20170914 VALUES LESS THAN ('2017-09-15') ENGINE = InnoDB,
|
||||
PARTITION p99991231 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB);
|
||||
insert into t(d,a,b) values ('2017-09-15',rand()*10000,rand()*10);
|
||||
insert into t(d,a,b) values ('2017-09-15',rand()*10000,rand()*10);
|
||||
replace into t(d,a,b) select '2017-09-15',rand()*10000,rand()*10 from t t1, t t2, t t3, t t4;
|
||||
select count(*) from t where d ='2017-09-15';
|
||||
count(*)
|
||||
18
|
||||
ALTER TABLE t CHANGE b c smallint(5) unsigned , ADD KEY idx_d_a (d, a);
|
||||
SHOW CREATE TABLE t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`d` date NOT NULL,
|
||||
`a` bigint(20) unsigned NOT NULL,
|
||||
`c` smallint(5) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`,`d`),
|
||||
KEY `idx_d_a` (`d`,`a`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs STATS_SAMPLE_PAGES=2
|
||||
/*!50500 PARTITION BY RANGE COLUMNS(d)
|
||||
(PARTITION p20170914 VALUES LESS THAN ('2017-09-15') ENGINE = InnoDB,
|
||||
PARTITION p99991231 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB) */
|
||||
analyze table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t analyze status OK
|
||||
select count(*) from t where d ='2017-09-15';
|
||||
count(*)
|
||||
18
|
||||
select count(*) from t force index(primary) where d ='2017-09-15';
|
||||
count(*)
|
||||
18
|
||||
DROP TABLE t;
|
||||
|
||||
@@ -540,9 +540,6 @@ ERROR 42000: Key column 'c2' doesn't exist in table
|
||||
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY;
|
||||
ERROR 42000: Key column 'c2' doesn't exist in table
|
||||
ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
|
||||
ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE;
|
||||
ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE;
|
||||
SHOW CREATE TABLE t1n;
|
||||
Table Create Table
|
||||
t1n CREATE TABLE `t1n` (
|
||||
@@ -559,9 +556,6 @@ ALTER TABLE t1n DROP INDEX c4;
|
||||
ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE;
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
|
||||
ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE;
|
||||
ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE;
|
||||
SHOW CREATE TABLE t1n;
|
||||
Table Create Table
|
||||
t1n CREATE TABLE `t1n` (
|
||||
@@ -640,10 +634,11 @@ CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE t1o DROP INDEX ct, DROP INDEX FTS_DOC_ID_INDEX,
|
||||
CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL;
|
||||
ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id);
|
||||
call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o");
|
||||
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
|
||||
ADD FULLTEXT INDEX(ct);
|
||||
ERROR HY000: Incorrect key file for table 't1o'; try to repair it
|
||||
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
|
||||
ALGORITHM=INPLACE;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try ALGORITHM=COPY.
|
||||
DROP TABLE sys_indexes;
|
||||
CREATE TABLE sys_indexes SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_INDEXES i
|
||||
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
|
||||
@@ -651,9 +646,16 @@ SELECT i.NAME,i.POS,i.MTYPE,i.PRTYPE,i.LEN
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS i
|
||||
INNER JOIN sys_tables st ON i.TABLE_ID=st.TABLE_ID;
|
||||
NAME POS MTYPE PRTYPE LEN
|
||||
FTS_DOC_ID 0 6 1800 8
|
||||
c2 1 6 1027 4
|
||||
ct 2 5 524540 10
|
||||
cu 3 5 524540 10
|
||||
SELECT si.NAME,i.POS,i.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS i
|
||||
INNER JOIN sys_indexes si ON i.INDEX_ID=si.INDEX_ID;
|
||||
NAME POS NAME
|
||||
PRIMARY 0 FTS_DOC_ID
|
||||
FTS_DOC_ID_INDEX 0 FTS_DOC_ID
|
||||
ct 0 ct
|
||||
SELECT i.* FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS i
|
||||
INNER JOIN sys_foreign sf ON i.ID = sf.ID;
|
||||
ID FOR_COL_NAME REF_COL_NAME POS
|
||||
|
||||
@@ -1010,9 +1010,6 @@ ERROR 42000: Key column 'c2' doesn't exist in table
|
||||
ALTER TABLE t1n ADD INDEX(c2), CHANGE c2 c4 INT, ALGORITHM=COPY;
|
||||
ERROR 42000: Key column 'c2' doesn't exist in table
|
||||
ALTER TABLE t1n ADD INDEX(c4), CHANGE c2 c4 INT, ALGORITHM=INPLACE;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
|
||||
ALTER TABLE t1n CHANGE c2 c4 INT, LOCK=NONE;
|
||||
ALTER TABLE t1n ADD INDEX(c4), LOCK=NONE;
|
||||
### files in MYSQL_DATA_DIR/test
|
||||
FTS_AUX_INDEX_1.ibd
|
||||
FTS_AUX_INDEX_2.ibd
|
||||
@@ -1113,9 +1110,6 @@ tt.ibd
|
||||
ALTER TABLE t1n CHANGE c4 c1 INT, ADD INDEX(c1), ALGORITHM=INPLACE;
|
||||
ERROR 42S21: Duplicate column name 'c1'
|
||||
ALTER TABLE t1n CHANGE c4 c11 INT, ADD INDEX(c11), ALGORITHM=INPLACE;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY.
|
||||
ALTER TABLE t1n CHANGE c4 c11 INT, LOCK=NONE;
|
||||
ALTER TABLE t1n ADD INDEX(c11), LOCK=NONE;
|
||||
### files in MYSQL_DATA_DIR/test
|
||||
FTS_AUX_INDEX_1.ibd
|
||||
FTS_AUX_INDEX_2.ibd
|
||||
@@ -1201,13 +1195,9 @@ tt.isl
|
||||
t1c.ibd
|
||||
t1p.ibd
|
||||
tt.ibd
|
||||
call mtr.add_suppression("Error: no matching column for .FTS_DOC_ID. in index .ct.--temporary-- of table .test...t1o");
|
||||
ALTER TABLE t1o ADD FULLTEXT INDEX(ct),
|
||||
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
|
||||
ALGORITHM=INPLACE;
|
||||
ERROR HY000: Incorrect key file for table 't1o'; try to repair it
|
||||
ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
|
||||
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
|
||||
### files in MYSQL_DATA_DIR/test
|
||||
FTS_AUX_INDEX_1.ibd
|
||||
FTS_AUX_INDEX_2.ibd
|
||||
@@ -1249,6 +1239,9 @@ tt.isl
|
||||
t1c.ibd
|
||||
t1p.ibd
|
||||
tt.ibd
|
||||
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
|
||||
LOCK=NONE;
|
||||
ERROR 0A000: LOCK=NONE is not supported. Reason: Cannot drop or rename FTS_DOC_ID. Try LOCK=SHARED.
|
||||
SELECT sc.pos FROM information_schema.innodb_sys_columns sc
|
||||
INNER JOIN information_schema.innodb_sys_tables st
|
||||
ON sc.TABLE_ID=st.TABLE_ID
|
||||
@@ -1352,9 +1345,6 @@ tt.isl
|
||||
tt.ibd
|
||||
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
|
||||
ADD FULLTEXT INDEX(ct);
|
||||
ERROR HY000: Incorrect key file for table 't1o'; try to repair it
|
||||
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
|
||||
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
|
||||
### files in MYSQL_DATA_DIR/test
|
||||
FTS_AUX_INDEX_1.ibd
|
||||
FTS_AUX_INDEX_2.ibd
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
--source include/innodb_page_size.inc
|
||||
--source include/have_partition.inc
|
||||
|
||||
#
|
||||
# MMDEV-8386: MariaDB creates very big tmp file and hangs on xtradb
|
||||
@@ -171,3 +172,35 @@ ALTER TABLE ticket
|
||||
SHOW CREATE TABLE ticket;
|
||||
|
||||
DROP TABLE ticket;
|
||||
|
||||
#
|
||||
# MDEV-13838: Wrong result after altering a partitioned table
|
||||
#
|
||||
|
||||
CREATE TABLE t (
|
||||
id bigint(20) unsigned NOT NULL auto_increment,
|
||||
d date NOT NULL,
|
||||
a bigint(20) unsigned NOT NULL,
|
||||
b smallint(5) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (id,d)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs STATS_SAMPLE_PAGES=2
|
||||
PARTITION BY RANGE COLUMNS(d)
|
||||
(
|
||||
PARTITION p20170914 VALUES LESS THAN ('2017-09-15') ENGINE = InnoDB,
|
||||
PARTITION p99991231 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB);
|
||||
|
||||
insert into t(d,a,b) values ('2017-09-15',rand()*10000,rand()*10);
|
||||
insert into t(d,a,b) values ('2017-09-15',rand()*10000,rand()*10);
|
||||
|
||||
replace into t(d,a,b) select '2017-09-15',rand()*10000,rand()*10 from t t1, t t2, t t3, t t4;
|
||||
|
||||
select count(*) from t where d ='2017-09-15';
|
||||
|
||||
ALTER TABLE t CHANGE b c smallint(5) unsigned , ADD KEY idx_d_a (d, a);
|
||||
SHOW CREATE TABLE t;
|
||||
analyze table t;
|
||||
|
||||
select count(*) from t where d ='2017-09-15';
|
||||
select count(*) from t force index(primary) where d ='2017-09-15';
|
||||
|
||||
DROP TABLE t;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -447,12 +447,7 @@ 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;
|
||||
|
||||
--echo ### files in MYSQL_DATA_DIR/test
|
||||
--replace_regex $regexp
|
||||
@@ -474,11 +469,7 @@ 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;
|
||||
|
||||
--echo ### files in MYSQL_DATA_DIR/test
|
||||
--replace_regex $regexp
|
||||
@@ -500,17 +491,10 @@ ALTER TABLE t1o MODIFY c1 BIGINT UNSIGNED NOT NULL;
|
||||
--replace_regex $regexp
|
||||
--list_files $MYSQL_TMP_DIR/alt_dir/test
|
||||
|
||||
# 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 ADD FULLTEXT INDEX(ct),
|
||||
CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
|
||||
ALGORITHM=INPLACE;
|
||||
|
||||
ALTER TABLE t1o CHANGE c1 FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
|
||||
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
|
||||
# end of MDEV-9469 FIXME
|
||||
|
||||
--echo ### files in MYSQL_DATA_DIR/test
|
||||
--replace_regex $regexp
|
||||
--list_files $MYSQL_DATA_DIR/test
|
||||
@@ -519,11 +503,9 @@ ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
|
||||
--list_files $MYSQL_TMP_DIR/alt_dir/test
|
||||
|
||||
# This would create a hidden FTS_DOC_ID column, which cannot be done online.
|
||||
# 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,
|
||||
#LOCK=NONE;
|
||||
#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,
|
||||
LOCK=NONE;
|
||||
|
||||
# This should not show duplicates.
|
||||
SELECT sc.pos FROM information_schema.innodb_sys_columns sc
|
||||
@@ -534,7 +516,6 @@ WHERE st.NAME='test/t1o' AND sc.NAME='FTS_DOC_ID';
|
||||
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
|
||||
SHOW CREATE TABLE t1o;
|
||||
|
||||
# FIXME: MDEV-13668
|
||||
ALTER TABLE t1o CHANGE FTS_DOC_ID foo_id BIGINT UNSIGNED NOT NULL,
|
||||
DROP INDEX ct, LOCK=NONE;
|
||||
|
||||
@@ -572,15 +553,9 @@ ALTER TABLE t1o ADD UNIQUE INDEX FTS_DOC_ID_INDEX(foo_id);
|
||||
--replace_regex $regexp
|
||||
--list_files $MYSQL_TMP_DIR/alt_dir/test
|
||||
|
||||
# FIXME: MDEV-9469 'Incorrect key file' on ALTER TABLE
|
||||
--error ER_NOT_KEYFILE
|
||||
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
|
||||
ADD FULLTEXT INDEX(ct);
|
||||
|
||||
ALTER TABLE t1o CHANGE foo_id FTS_DOC_ID BIGINT UNSIGNED NOT NULL, LOCK=NONE;
|
||||
ALTER TABLE t1o ADD FULLTEXT INDEX(ct), ALGORITHM=INPLACE;
|
||||
#end of MDEV-9469 FIXME
|
||||
|
||||
--echo ### files in MYSQL_DATA_DIR/test
|
||||
--replace_regex $regexp
|
||||
--list_files $MYSQL_DATA_DIR/test
|
||||
|
||||
@@ -642,40 +642,6 @@ dict_table_get_col_name(
|
||||
return(s);
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
Returns a column's name.
|
||||
@return column name. NOTE: not guaranteed to stay valid if table is
|
||||
modified in any way (columns added, etc.). */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_table_get_col_name_for_mysql(
|
||||
/*==============================*/
|
||||
const dict_table_t* table, /*!< in: table */
|
||||
const char* col_name)/*! in: MySQL table column name */
|
||||
{
|
||||
ulint i;
|
||||
const char* s;
|
||||
|
||||
ut_ad(table);
|
||||
ut_ad(col_name);
|
||||
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
||||
|
||||
s = table->col_names;
|
||||
if (s) {
|
||||
/* If we have many virtual columns MySQL key_part->fieldnr
|
||||
could be larger than number of columns in InnoDB table
|
||||
when creating new indexes. */
|
||||
for (i = 0; i < table->n_def; i++) {
|
||||
|
||||
if (!innobase_strcasecmp(s, col_name)) {
|
||||
break; /* Found */
|
||||
}
|
||||
s += strlen(s) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return(s);
|
||||
}
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
/** Allocate and init the autoinc latch of a given table.
|
||||
This function must not be called concurrently on the same table object.
|
||||
|
||||
@@ -4971,8 +4971,6 @@ innobase_match_index_columns(
|
||||
if (innodb_idx_fld >= innodb_idx_fld_end) {
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
mtype = innodb_idx_fld->col->mtype;
|
||||
}
|
||||
|
||||
// MariaDB-5.5 compatibility
|
||||
|
||||
@@ -222,34 +222,6 @@ innobase_need_rebuild(
|
||||
return(false);
|
||||
}
|
||||
|
||||
/* If alter table changes column name and adds a new
|
||||
index, we need to check is this new index created
|
||||
to new column name. This is because column name
|
||||
changes are done normally after creating indexes. */
|
||||
if ((ha_alter_info->handler_flags
|
||||
& Alter_inplace_info::ALTER_COLUMN_NAME) &&
|
||||
((ha_alter_info->handler_flags
|
||||
& Alter_inplace_info::ADD_INDEX) ||
|
||||
(ha_alter_info->handler_flags
|
||||
& Alter_inplace_info::ADD_FOREIGN_KEY))) {
|
||||
for (ulint i = 0; i < ha_alter_info->index_add_count; i++) {
|
||||
const KEY* key = &ha_alter_info->key_info_buffer[
|
||||
ha_alter_info->index_add_buffer[i]];
|
||||
|
||||
for (ulint j = 0; j < key->user_defined_key_parts; j++) {
|
||||
const KEY_PART_INFO* key_part = &(key->key_part[j]);
|
||||
const Field* field = altered_table->field[key_part->fieldnr];
|
||||
|
||||
/* Field used on added index is renamed on
|
||||
this same alter table. We need table
|
||||
rebuild. */
|
||||
if (field && field->flags & FIELD_IS_RENAMED) {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(!!(ha_alter_info->handler_flags & INNOBASE_ALTER_REBUILD));
|
||||
}
|
||||
|
||||
@@ -1512,38 +1484,49 @@ name_ok:
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*******************************************************************//**
|
||||
Create index field definition for key part */
|
||||
/** Create index field definition for key part
|
||||
@param[in] new_clustered true if alter is generating a new clustered
|
||||
index
|
||||
@param[in] altered_table MySQL table that is being altered
|
||||
@param[in] key_part MySQL key definition
|
||||
@param[out] index_field index field defition for key_part */
|
||||
static MY_ATTRIBUTE((nonnull(2,3)))
|
||||
void
|
||||
innobase_create_index_field_def(
|
||||
/*============================*/
|
||||
const TABLE* altered_table, /*!< in: MySQL table that is
|
||||
being altered, or NULL
|
||||
if a new clustered index is
|
||||
not being created */
|
||||
const KEY_PART_INFO* key_part, /*!< in: MySQL key definition */
|
||||
index_field_t* index_field, /*!< out: index field
|
||||
definition for key_part */
|
||||
const Field** fields) /*!< in: MySQL table fields */
|
||||
bool new_clustered,
|
||||
const TABLE* altered_table,
|
||||
const KEY_PART_INFO* key_part,
|
||||
index_field_t* index_field)
|
||||
{
|
||||
const Field* field;
|
||||
ibool is_unsigned;
|
||||
ulint col_type;
|
||||
ulint innodb_fieldnr=0;
|
||||
|
||||
DBUG_ENTER("innobase_create_index_field_def");
|
||||
|
||||
ut_ad(key_part);
|
||||
ut_ad(index_field);
|
||||
ut_ad(altered_table);
|
||||
|
||||
field = altered_table
|
||||
? altered_table->field[key_part->fieldnr]
|
||||
/* Virtual columns are not stored in InnoDB data dictionary, thus
|
||||
if there is virtual columns we need to skip them to find the
|
||||
correct field. */
|
||||
for(ulint i = 0; i < key_part->fieldnr; i++) {
|
||||
const Field* table_field = altered_table->field[i];
|
||||
if (!table_field->stored_in_db) {
|
||||
continue;
|
||||
}
|
||||
innodb_fieldnr++;
|
||||
}
|
||||
|
||||
field = new_clustered ?
|
||||
altered_table->field[key_part->fieldnr]
|
||||
: key_part->field;
|
||||
|
||||
ut_a(field);
|
||||
|
||||
index_field->col_no = key_part->fieldnr;
|
||||
index_field->col_name = altered_table ? field->field_name : fields[key_part->fieldnr]->field_name;
|
||||
|
||||
index_field->col_no = innodb_fieldnr;
|
||||
col_type = get_innobase_type_from_mysql_type(&is_unsigned, field);
|
||||
|
||||
if (DATA_BLOB == col_type
|
||||
@@ -1577,10 +1560,8 @@ innobase_create_index_def(
|
||||
bool key_clustered, /*!< in: true if this is
|
||||
the new clustered index */
|
||||
index_def_t* index, /*!< out: index definition */
|
||||
mem_heap_t* heap, /*!< in: heap where memory
|
||||
mem_heap_t* heap) /*!< in: heap where memory
|
||||
is allocated */
|
||||
const Field** fields) /*!< in: MySQL table fields
|
||||
*/
|
||||
{
|
||||
const KEY* key = &keys[key_number];
|
||||
ulint i;
|
||||
@@ -1591,10 +1572,10 @@ innobase_create_index_def(
|
||||
DBUG_ENTER("innobase_create_index_def");
|
||||
DBUG_ASSERT(!key_clustered || new_clustered);
|
||||
|
||||
ut_ad(altered_table);
|
||||
|
||||
index->fields = static_cast<index_field_t*>(
|
||||
mem_heap_alloc(heap, n_fields * sizeof *index->fields));
|
||||
memset(index->fields, 0, n_fields * sizeof *index->fields);
|
||||
|
||||
index->ind_type = 0;
|
||||
index->key_number = key_number;
|
||||
index->n_fields = n_fields;
|
||||
@@ -1625,13 +1606,12 @@ innobase_create_index_def(
|
||||
index->ind_type |= DICT_FTS;
|
||||
}
|
||||
|
||||
if (!new_clustered) {
|
||||
altered_table = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_fields; i++) {
|
||||
innobase_create_index_field_def(
|
||||
altered_table, &key->key_part[i], &index->fields[i], fields);
|
||||
new_clustered,
|
||||
altered_table,
|
||||
&key->key_part[i],
|
||||
&index->fields[i]);
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
@@ -1957,7 +1937,7 @@ innobase_create_key_defs(
|
||||
/* Create the PRIMARY key index definition */
|
||||
innobase_create_index_def(
|
||||
altered_table, key_info, primary_key_number,
|
||||
TRUE, TRUE, indexdef++, heap, (const Field **)altered_table->field);
|
||||
TRUE, TRUE, indexdef++, heap);
|
||||
|
||||
created_clustered:
|
||||
n_add = 1;
|
||||
@@ -1969,7 +1949,7 @@ created_clustered:
|
||||
/* Copy the index definitions. */
|
||||
innobase_create_index_def(
|
||||
altered_table, key_info, i, TRUE, FALSE,
|
||||
indexdef, heap, (const Field **)altered_table->field);
|
||||
indexdef, heap);
|
||||
|
||||
if (indexdef->ind_type & DICT_FTS) {
|
||||
n_fts_add++;
|
||||
@@ -2014,7 +1994,7 @@ created_clustered:
|
||||
for (ulint i = 0; i < n_add; i++) {
|
||||
innobase_create_index_def(
|
||||
altered_table, key_info, add[i], FALSE, FALSE,
|
||||
indexdef, heap, (const Field **)altered_table->field);
|
||||
indexdef, heap);
|
||||
|
||||
if (indexdef->ind_type & DICT_FTS) {
|
||||
n_fts_add++;
|
||||
@@ -2031,7 +2011,6 @@ created_clustered:
|
||||
|
||||
index->fields = static_cast<index_field_t*>(
|
||||
mem_heap_alloc(heap, sizeof *index->fields));
|
||||
memset(index->fields, 0, sizeof *index->fields);
|
||||
index->n_fields = 1;
|
||||
index->fields->col_no = fts_doc_id_col;
|
||||
index->fields->prefix_len = 0;
|
||||
@@ -3066,8 +3045,7 @@ prepare_inplace_alter_table_dict(
|
||||
for (ulint a = 0; a < ctx->num_to_add_index; a++) {
|
||||
|
||||
ctx->add_index[a] = row_merge_create_index(
|
||||
ctx->trx, ctx->new_table,
|
||||
&index_defs[a], ctx->col_names);
|
||||
ctx->trx, ctx->new_table, &index_defs[a]);
|
||||
|
||||
add_key_nums[a] = index_defs[a].key_number;
|
||||
|
||||
|
||||
@@ -605,17 +605,6 @@ dict_table_get_col_name(
|
||||
ulint col_nr) /*!< in: column number */
|
||||
MY_ATTRIBUTE((nonnull, warn_unused_result));
|
||||
/**********************************************************************//**
|
||||
Returns a column's name.
|
||||
@return column name. NOTE: not guaranteed to stay valid if table is
|
||||
modified in any way (columns added, etc.). */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_table_get_col_name_for_mysql(
|
||||
/*==============================*/
|
||||
const dict_table_t* table, /*!< in: table */
|
||||
const char* col_name)/*!< in: MySQL table column name */
|
||||
MY_ATTRIBUTE((nonnull, warn_unused_result));
|
||||
/**********************************************************************//**
|
||||
Prints a table data. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
|
||||
@@ -95,7 +95,6 @@ struct index_field_t {
|
||||
ulint col_no; /*!< column offset */
|
||||
ulint prefix_len; /*!< column prefix length, or 0
|
||||
if indexing the whole column */
|
||||
const char* col_name; /*!< column name or NULL */
|
||||
};
|
||||
|
||||
/** Definition of an index being created */
|
||||
@@ -252,11 +251,7 @@ row_merge_create_index(
|
||||
/*===================*/
|
||||
trx_t* trx, /*!< in/out: trx (sets error_state) */
|
||||
dict_table_t* table, /*!< in: the index is on this table */
|
||||
const index_def_t* index_def,
|
||||
/*!< in: the index definition */
|
||||
const char** col_names);
|
||||
/*! in: column names if columns are
|
||||
renamed or NULL */
|
||||
const index_def_t* index_def); /*!< in: the index definition */
|
||||
/*********************************************************************//**
|
||||
Check if a transaction can use an index.
|
||||
@return TRUE if index can be used by the transaction else FALSE */
|
||||
|
||||
@@ -3532,11 +3532,7 @@ row_merge_create_index(
|
||||
/*===================*/
|
||||
trx_t* trx, /*!< in/out: trx (sets error_state) */
|
||||
dict_table_t* table, /*!< in: the index is on this table */
|
||||
const index_def_t* index_def,
|
||||
/*!< in: the index definition */
|
||||
const char** col_names)
|
||||
/*! in: column names if columns are
|
||||
renamed or NULL */
|
||||
const index_def_t* index_def) /*!< in: the index definition */
|
||||
{
|
||||
dict_index_t* index;
|
||||
dberr_t err;
|
||||
@@ -3556,28 +3552,10 @@ row_merge_create_index(
|
||||
|
||||
for (i = 0; i < n_fields; i++) {
|
||||
index_field_t* ifield = &index_def->fields[i];
|
||||
const char * col_name;
|
||||
|
||||
/*
|
||||
Alter table renaming a column and then adding a index
|
||||
to this new name e.g ALTER TABLE t
|
||||
CHANGE COLUMN b c INT NOT NULL, ADD UNIQUE INDEX (c);
|
||||
requires additional check as column names are not yet
|
||||
changed when new index definitions are created. Table's
|
||||
new column names are on a array of column name pointers
|
||||
if any of the column names are changed. */
|
||||
|
||||
if (col_names && col_names[i]) {
|
||||
col_name = col_names[i];
|
||||
} else {
|
||||
col_name = ifield->col_name ?
|
||||
dict_table_get_col_name_for_mysql(table, ifield->col_name) :
|
||||
dict_table_get_col_name(table, ifield->col_no);
|
||||
}
|
||||
|
||||
dict_mem_index_add_field(
|
||||
index,
|
||||
col_name,
|
||||
dict_table_get_col_name(table, ifield->col_no),
|
||||
ifield->prefix_len);
|
||||
}
|
||||
|
||||
|
||||
@@ -642,40 +642,6 @@ dict_table_get_col_name(
|
||||
return(s);
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
Returns a column's name.
|
||||
@return column name. NOTE: not guaranteed to stay valid if table is
|
||||
modified in any way (columns added, etc.). */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_table_get_col_name_for_mysql(
|
||||
/*==============================*/
|
||||
const dict_table_t* table, /*!< in: table */
|
||||
const char* col_name)/*! in: MySQL table column name */
|
||||
{
|
||||
ulint i;
|
||||
const char* s;
|
||||
|
||||
ut_ad(table);
|
||||
ut_ad(col_name);
|
||||
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
|
||||
|
||||
s = table->col_names;
|
||||
if (s) {
|
||||
/* If we have many virtual columns MySQL key_part->fieldnr
|
||||
could be larger than number of columns in InnoDB table
|
||||
when creating new indexes. */
|
||||
for (i = 0; i < table->n_def; i++) {
|
||||
|
||||
if (!innobase_strcasecmp(s, col_name)) {
|
||||
break; /* Found */
|
||||
}
|
||||
s += strlen(s) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return(s);
|
||||
}
|
||||
#ifndef UNIV_HOTBACKUP
|
||||
/** Allocate and init the autoinc latch of a given table.
|
||||
This function must not be called concurrently on the same table object.
|
||||
|
||||
@@ -5636,8 +5636,6 @@ innobase_match_index_columns(
|
||||
if (innodb_idx_fld >= innodb_idx_fld_end) {
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
mtype = innodb_idx_fld->col->mtype;
|
||||
}
|
||||
|
||||
if (col_type != mtype) {
|
||||
|
||||
@@ -222,34 +222,6 @@ innobase_need_rebuild(
|
||||
return(false);
|
||||
}
|
||||
|
||||
/* If alter table changes column name and adds a new
|
||||
index, we need to check is this new index created
|
||||
to new column name. This is because column name
|
||||
changes are done normally after creating indexes. */
|
||||
if ((ha_alter_info->handler_flags
|
||||
& Alter_inplace_info::ALTER_COLUMN_NAME) &&
|
||||
((ha_alter_info->handler_flags
|
||||
& Alter_inplace_info::ADD_INDEX) ||
|
||||
(ha_alter_info->handler_flags
|
||||
& Alter_inplace_info::ADD_FOREIGN_KEY))) {
|
||||
for (ulint i = 0; i < ha_alter_info->index_add_count; i++) {
|
||||
const KEY* key = &ha_alter_info->key_info_buffer[
|
||||
ha_alter_info->index_add_buffer[i]];
|
||||
|
||||
for (ulint j = 0; j < key->user_defined_key_parts; j++) {
|
||||
const KEY_PART_INFO* key_part = &(key->key_part[j]);
|
||||
const Field* field = altered_table->field[key_part->fieldnr];
|
||||
|
||||
/* Field used on added index is renamed on
|
||||
this same alter table. We need table
|
||||
rebuild. */
|
||||
if (field && field->flags & FIELD_IS_RENAMED) {
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(!!(ha_alter_info->handler_flags & INNOBASE_ALTER_REBUILD));
|
||||
}
|
||||
|
||||
@@ -1513,38 +1485,49 @@ name_ok:
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*******************************************************************//**
|
||||
Create index field definition for key part */
|
||||
/** Create index field definition for key part
|
||||
@param[in] new_clustered true if alter is generating a new clustered
|
||||
index
|
||||
@param[in] altered_table MySQL table that is being altered
|
||||
@param[in] key_part MySQL key definition
|
||||
@param[out] index_field index field defition for key_part */
|
||||
static MY_ATTRIBUTE((nonnull(2,3)))
|
||||
void
|
||||
innobase_create_index_field_def(
|
||||
/*============================*/
|
||||
const TABLE* altered_table, /*!< in: MySQL table that is
|
||||
being altered, or NULL
|
||||
if a new clustered index is
|
||||
not being created */
|
||||
const KEY_PART_INFO* key_part, /*!< in: MySQL key definition */
|
||||
index_field_t* index_field, /*!< out: index field
|
||||
definition for key_part */
|
||||
const Field** fields) /*!< in: MySQL table fields */
|
||||
bool new_clustered,
|
||||
const TABLE* altered_table,
|
||||
const KEY_PART_INFO* key_part,
|
||||
index_field_t* index_field)
|
||||
{
|
||||
const Field* field;
|
||||
ibool is_unsigned;
|
||||
ulint col_type;
|
||||
ulint innodb_fieldnr=0;
|
||||
|
||||
DBUG_ENTER("innobase_create_index_field_def");
|
||||
|
||||
ut_ad(key_part);
|
||||
ut_ad(index_field);
|
||||
ut_ad(altered_table);
|
||||
|
||||
field = altered_table
|
||||
? altered_table->field[key_part->fieldnr]
|
||||
/* Virtual columns are not stored in InnoDB data dictionary, thus
|
||||
if there is virtual columns we need to skip them to find the
|
||||
correct field. */
|
||||
for(ulint i = 0; i < key_part->fieldnr; i++) {
|
||||
const Field* table_field = altered_table->field[i];
|
||||
if (!table_field->stored_in_db) {
|
||||
continue;
|
||||
}
|
||||
innodb_fieldnr++;
|
||||
}
|
||||
|
||||
field = new_clustered ?
|
||||
altered_table->field[key_part->fieldnr]
|
||||
: key_part->field;
|
||||
|
||||
ut_a(field);
|
||||
|
||||
index_field->col_no = key_part->fieldnr;
|
||||
index_field->col_name = altered_table ? field->field_name : fields[key_part->fieldnr]->field_name;
|
||||
|
||||
index_field->col_no = innodb_fieldnr;
|
||||
col_type = get_innobase_type_from_mysql_type(&is_unsigned, field);
|
||||
|
||||
if (DATA_BLOB == col_type
|
||||
@@ -1578,10 +1561,8 @@ innobase_create_index_def(
|
||||
bool key_clustered, /*!< in: true if this is
|
||||
the new clustered index */
|
||||
index_def_t* index, /*!< out: index definition */
|
||||
mem_heap_t* heap, /*!< in: heap where memory
|
||||
mem_heap_t* heap) /*!< in: heap where memory
|
||||
is allocated */
|
||||
const Field** fields) /*!< in: MySQL table fields
|
||||
*/
|
||||
{
|
||||
const KEY* key = &keys[key_number];
|
||||
ulint i;
|
||||
@@ -1592,11 +1573,10 @@ innobase_create_index_def(
|
||||
DBUG_ENTER("innobase_create_index_def");
|
||||
DBUG_ASSERT(!key_clustered || new_clustered);
|
||||
|
||||
ut_ad(altered_table);
|
||||
|
||||
index->fields = static_cast<index_field_t*>(
|
||||
mem_heap_alloc(heap, n_fields * sizeof *index->fields));
|
||||
|
||||
memset(index->fields, 0, n_fields * sizeof *index->fields);
|
||||
|
||||
index->ind_type = 0;
|
||||
index->key_number = key_number;
|
||||
index->n_fields = n_fields;
|
||||
@@ -1627,13 +1607,12 @@ innobase_create_index_def(
|
||||
index->ind_type |= DICT_FTS;
|
||||
}
|
||||
|
||||
if (!new_clustered) {
|
||||
altered_table = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < n_fields; i++) {
|
||||
innobase_create_index_field_def(
|
||||
altered_table, &key->key_part[i], &index->fields[i], fields);
|
||||
new_clustered,
|
||||
altered_table,
|
||||
&key->key_part[i],
|
||||
&index->fields[i]);
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
@@ -1959,7 +1938,7 @@ innobase_create_key_defs(
|
||||
/* Create the PRIMARY key index definition */
|
||||
innobase_create_index_def(
|
||||
altered_table, key_info, primary_key_number,
|
||||
TRUE, TRUE, indexdef++, heap, (const Field **)altered_table->field);
|
||||
TRUE, TRUE, indexdef++, heap);
|
||||
|
||||
created_clustered:
|
||||
n_add = 1;
|
||||
@@ -1971,7 +1950,7 @@ created_clustered:
|
||||
/* Copy the index definitions. */
|
||||
innobase_create_index_def(
|
||||
altered_table, key_info, i, TRUE, FALSE,
|
||||
indexdef, heap, (const Field **)altered_table->field);
|
||||
indexdef, heap);
|
||||
|
||||
if (indexdef->ind_type & DICT_FTS) {
|
||||
n_fts_add++;
|
||||
@@ -2016,7 +1995,7 @@ created_clustered:
|
||||
for (ulint i = 0; i < n_add; i++) {
|
||||
innobase_create_index_def(
|
||||
altered_table, key_info, add[i], FALSE, FALSE,
|
||||
indexdef, heap, (const Field **)altered_table->field);
|
||||
indexdef, heap);
|
||||
|
||||
if (indexdef->ind_type & DICT_FTS) {
|
||||
n_fts_add++;
|
||||
@@ -2033,7 +2012,6 @@ created_clustered:
|
||||
|
||||
index->fields = static_cast<index_field_t*>(
|
||||
mem_heap_alloc(heap, sizeof *index->fields));
|
||||
memset(index->fields, 0, sizeof *index->fields);
|
||||
index->n_fields = 1;
|
||||
index->fields->col_no = fts_doc_id_col;
|
||||
index->fields->prefix_len = 0;
|
||||
@@ -3072,8 +3050,7 @@ prepare_inplace_alter_table_dict(
|
||||
for (ulint a = 0; a < ctx->num_to_add_index; a++) {
|
||||
|
||||
ctx->add_index[a] = row_merge_create_index(
|
||||
ctx->trx, ctx->new_table,
|
||||
&index_defs[a], ctx->col_names);
|
||||
ctx->trx, ctx->new_table, &index_defs[a]);
|
||||
|
||||
add_key_nums[a] = index_defs[a].key_number;
|
||||
|
||||
|
||||
@@ -604,17 +604,6 @@ dict_table_get_col_name(
|
||||
ulint col_nr) /*!< in: column number */
|
||||
MY_ATTRIBUTE((nonnull, warn_unused_result));
|
||||
/**********************************************************************//**
|
||||
Returns a column's name.
|
||||
@return column name. NOTE: not guaranteed to stay valid if table is
|
||||
modified in any way (columns added, etc.). */
|
||||
UNIV_INTERN
|
||||
const char*
|
||||
dict_table_get_col_name_for_mysql(
|
||||
/*==============================*/
|
||||
const dict_table_t* table, /*!< in: table */
|
||||
const char* col_name)/*!< in: MySQL table column name */
|
||||
__attribute__((nonnull, warn_unused_result));
|
||||
/**********************************************************************//**
|
||||
Prints a table data. */
|
||||
UNIV_INTERN
|
||||
void
|
||||
|
||||
@@ -95,7 +95,6 @@ struct index_field_t {
|
||||
ulint col_no; /*!< column offset */
|
||||
ulint prefix_len; /*!< column prefix length, or 0
|
||||
if indexing the whole column */
|
||||
const char* col_name; /*!< column name or NULL */
|
||||
};
|
||||
|
||||
/** Definition of an index being created */
|
||||
@@ -252,11 +251,7 @@ row_merge_create_index(
|
||||
/*===================*/
|
||||
trx_t* trx, /*!< in/out: trx (sets error_state) */
|
||||
dict_table_t* table, /*!< in: the index is on this table */
|
||||
const index_def_t* index_def,
|
||||
/*!< in: the index definition */
|
||||
const char** col_names);
|
||||
/*! in: column names if columns are
|
||||
renamed or NULL */
|
||||
const index_def_t* index_def); /*!< in: the index definition */
|
||||
/*********************************************************************//**
|
||||
Check if a transaction can use an index.
|
||||
@return TRUE if index can be used by the transaction else FALSE */
|
||||
|
||||
@@ -3536,11 +3536,7 @@ row_merge_create_index(
|
||||
/*===================*/
|
||||
trx_t* trx, /*!< in/out: trx (sets error_state) */
|
||||
dict_table_t* table, /*!< in: the index is on this table */
|
||||
const index_def_t* index_def,
|
||||
/*!< in: the index definition */
|
||||
const char** col_names)
|
||||
/*! in: column names if columns are
|
||||
renamed or NULL */
|
||||
const index_def_t* index_def) /*!< in: the index definition */
|
||||
{
|
||||
dict_index_t* index;
|
||||
dberr_t err;
|
||||
@@ -3560,28 +3556,10 @@ row_merge_create_index(
|
||||
|
||||
for (i = 0; i < n_fields; i++) {
|
||||
index_field_t* ifield = &index_def->fields[i];
|
||||
const char * col_name;
|
||||
|
||||
/*
|
||||
Alter table renaming a column and then adding a index
|
||||
to this new name e.g ALTER TABLE t
|
||||
CHANGE COLUMN b c INT NOT NULL, ADD UNIQUE INDEX (c);
|
||||
requires additional check as column names are not yet
|
||||
changed when new index definitions are created. Table's
|
||||
new column names are on a array of column name pointers
|
||||
if any of the column names are changed. */
|
||||
|
||||
if (col_names && col_names[i]) {
|
||||
col_name = col_names[i];
|
||||
} else {
|
||||
col_name = ifield->col_name ?
|
||||
dict_table_get_col_name_for_mysql(table, ifield->col_name) :
|
||||
dict_table_get_col_name(table, ifield->col_no);
|
||||
}
|
||||
|
||||
dict_mem_index_add_field(
|
||||
index,
|
||||
col_name,
|
||||
dict_table_get_col_name(table, ifield->col_no),
|
||||
ifield->prefix_len);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user