revision-id: 109463fdb86d (mariadb-10.0.32-54-g0240b866abc)
parent(s): 172cc70bf8c0aea3d2d0c73bcf94f36c172b769a
author: Jan Lindström
committer: Jan Lindström
timestamp: 2017-10-09 14:52:51 +0300
message:
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..."
+Warnings:
+Note 1831 Duplicate index `c4_2`. This is deprecated and will be disallowed in a future release.
@@ -171,3 +172,39 @@ 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=200
+/*!50500 PARTITION BY RANGE COLUMNS(d)
+(PARTITION p20170913 VALUES LESS THAN ('2017-09-14') ENGINE = InnoDB,
+PARTITION p20170914 VALUES LESS THAN ('2017-09-15') ENGINE = InnoDB,
+PARTITION p20170915 VALUES LESS THAN ('2017-09-16') ENGINE = InnoDB,
+PARTITION p20170916 VALUES LESS THAN ('2017-09-17') ENGINE = InnoDB,
+PARTITION p20170917 VALUES LESS THAN ('2017-09-18') 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, t t5, t t6, t t7, t t8, t t9, t t10, t t11, t t12, t t13, t t14;
+
+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;
+
@@ -1625,13 +1606,9 @@ 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);
+ innobase_create_index_field_def(new_clustered,
+ altered_table, &key->key_part[i], &index->fields[i]);
}
DBUG_VOID_RETURN;
@@ -2121,7 +2097,7 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx
/** mapping of old column numbers to new ones, or NULL */
const ulint* col_map;
/** new column names, or NULL if nothing was renamed */
- const char** col_names;
+ const char** col_names;
/** added AUTO_INCREMENT column position, or ULINT_UNDEFINED */
const ulint add_autoinc;
/** default values of ADD COLUMN, or NULL */
@@ -3067,7 +3043,7 @@ prepare_inplace_alter_table_dict(
ctx->add_index[a] = row_merge_create_index(
ctx->trx, ctx->new_table,
- &index_defs[a], ctx->col_names);
+ &index_defs[a]);
add_key_nums[a] = index_defs[a].key_number;