summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-06-16 00:35:57 +0200
committerSergei Golubchik <serg@mariadb.org>2017-06-22 12:56:33 +0200
commit3f240bff80b51458c85cd8a8b5616872f21fa033 (patch)
tree0238dc8236784e693868eb0fe0007fa176c223ba
parentb6ce68f450ce06db989febf4dc3e2428d6400dd7 (diff)
downloadmariadb-git-3f240bff80b51458c85cd8a8b5616872f21fa033.tar.gz
MDEV-13097 Online alter of a partitioned MyISAM table with auto_increment
MyISAM only allows online alter if autoincrement didn't change. MyISAM detects that by comparing new autoinc value from create_info, with the old one, stored in MYI. But in partitioned tables, create_info->auto_increment_value is for the whole table, max of autoinc values of individual MYI partitions. So *some* MYI partitions will inevitably think that alter table changes auto_increment value and will deny online alter. Fix: only compare autoinc values, if the user has used AUTO_INCREMENT in the ALTER TABLE statement.
-rw-r--r--mysql-test/r/partition_alter.result20
-rw-r--r--mysql-test/t/partition_alter.test9
-rw-r--r--storage/myisam/ha_myisam.cc3
3 files changed, 31 insertions, 1 deletions
diff --git a/mysql-test/r/partition_alter.result b/mysql-test/r/partition_alter.result
index 4aea0045617..4275ef72f24 100644
--- a/mysql-test/r/partition_alter.result
+++ b/mysql-test/r/partition_alter.result
@@ -92,3 +92,23 @@ t1 CREATE TABLE `t1` (
PARTITION p2 VALUES LESS THAN ('2020-10-19') ENGINE = MyISAM) */
insert t1 values (2, '2020-01-03', 20);
drop table t1;
+create table t1 (id_1 int auto_increment, id_2 int, id_3 int, d1 date, dt1 datetime default current_timestamp, dt2 datetime default current_timestamp on update current_timestamp, primary key (id_2, id_3), key(id_1)) partition by hash(id_2) partitions 3 (partition p01, partition p02, partition p03);
+insert into t1 values(0, 1, 1, NULL, now(), now());
+alter online table t1 delay_key_write=1;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id_1` int(11) NOT NULL AUTO_INCREMENT,
+ `id_2` int(11) NOT NULL,
+ `id_3` int(11) NOT NULL,
+ `d1` date DEFAULT NULL,
+ `dt1` datetime DEFAULT CURRENT_TIMESTAMP,
+ `dt2` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id_2`,`id_3`),
+ KEY `id_1` (`id_1`)
+) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 DELAY_KEY_WRITE=1
+/*!50100 PARTITION BY HASH (id_2)
+(PARTITION p01 ENGINE = MyISAM,
+ PARTITION p02 ENGINE = MyISAM,
+ PARTITION p03 ENGINE = MyISAM) */
+drop table t1;
diff --git a/mysql-test/t/partition_alter.test b/mysql-test/t/partition_alter.test
index 2f3c2a319fb..feb792624ab 100644
--- a/mysql-test/t/partition_alter.test
+++ b/mysql-test/t/partition_alter.test
@@ -103,3 +103,12 @@ show create table t1;
insert t1 values (2, '2020-01-03', 20);
drop table t1;
--list_files $datadir/test
+
+#
+# MDEV-13097 Online alter of a partitioned MyISAM table with auto_increment
+#
+create table t1 (id_1 int auto_increment, id_2 int, id_3 int, d1 date, dt1 datetime default current_timestamp, dt2 datetime default current_timestamp on update current_timestamp, primary key (id_2, id_3), key(id_1)) partition by hash(id_2) partitions 3 (partition p01, partition p02, partition p03);
+insert into t1 values(0, 1, 1, NULL, now(), now());
+alter online table t1 delay_key_write=1;
+show create table t1;
+drop table t1;
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index b335d360379..82bcbdb12a9 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -2266,7 +2266,8 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *create_info,
{
uint options= table->s->db_options_in_use;
- if (create_info->auto_increment_value != stats.auto_increment_value ||
+ if ((create_info->used_fields & HA_CREATE_USED_AUTO &&
+ create_info->auto_increment_value != stats.auto_increment_value) ||
create_info->data_file_name != data_file_name ||
create_info->index_file_name != index_file_name ||
table_changes == IS_EQUAL_NO ||