Commit 3f240bff authored by Sergei Golubchik's avatar Sergei Golubchik

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.
parent b6ce68f4
...@@ -92,3 +92,23 @@ t1 CREATE TABLE `t1` ( ...@@ -92,3 +92,23 @@ t1 CREATE TABLE `t1` (
PARTITION p2 VALUES LESS THAN ('2020-10-19') ENGINE = MyISAM) */ PARTITION p2 VALUES LESS THAN ('2020-10-19') ENGINE = MyISAM) */
insert t1 values (2, '2020-01-03', 20); insert t1 values (2, '2020-01-03', 20);
drop table t1; 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;
...@@ -103,3 +103,12 @@ show create table t1; ...@@ -103,3 +103,12 @@ show create table t1;
insert t1 values (2, '2020-01-03', 20); insert t1 values (2, '2020-01-03', 20);
drop table t1; drop table t1;
--list_files $datadir/test --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;
...@@ -2266,7 +2266,8 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *create_info, ...@@ -2266,7 +2266,8 @@ bool ha_myisam::check_if_incompatible_data(HA_CREATE_INFO *create_info,
{ {
uint options= table->s->db_options_in_use; 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->data_file_name != data_file_name ||
create_info->index_file_name != index_file_name || create_info->index_file_name != index_file_name ||
table_changes == IS_EQUAL_NO || table_changes == IS_EQUAL_NO ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment