summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-12-24 18:39:00 +0100
committerSergei Golubchik <serg@mariadb.org>2017-12-25 15:18:21 +0100
commit5377242fff5d2260510e65c58e4e52d7c4b222f6 (patch)
tree33a6811ae6c700d0971a2abfb2e0102105d78742
parent6d8b1bd6204899afa57121cf1f7adf305118d380 (diff)
downloadmariadb-git-5377242fff5d2260510e65c58e4e52d7c4b222f6.tar.gz
MDEV-14026 ALTER TABLE ... DELAY_KEY_WRITE=1 creates table copy for partitioned MyISAM table with DATA DIRECTORY/INDEX DIRECTORY options
set data_file_name and index_file_name in HA_CREATE_INFO before calling check_if_incompatible_data()
-rw-r--r--mysql-test/r/partition_windows.result4
-rw-r--r--mysql-test/suite/parts/r/partition_alter_myisam.result13
-rw-r--r--mysql-test/suite/parts/t/partition_alter_myisam.test19
-rw-r--r--sql/ha_partition.cc34
4 files changed, 57 insertions, 13 deletions
diff --git a/mysql-test/r/partition_windows.result b/mysql-test/r/partition_windows.result
index dabcedcb3f9..756690925f8 100644
--- a/mysql-test/r/partition_windows.result
+++ b/mysql-test/r/partition_windows.result
@@ -26,9 +26,5 @@ ALTER TABLE t1 ADD PARTITION (PARTITION p3 DATA DIRECTORY = 'G:/mysqltest/p3Data
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
Warning 1618 <INDEX DIRECTORY> option ignored
-Warning 1618 <DATA DIRECTORY> option ignored
-Warning 1618 <INDEX DIRECTORY> option ignored
-Warning 1618 <DATA DIRECTORY> option ignored
-Warning 1618 <INDEX DIRECTORY> option ignored
INSERT INTO t1 VALUES (NULL, "last", 4);
DROP TABLE t1;
diff --git a/mysql-test/suite/parts/r/partition_alter_myisam.result b/mysql-test/suite/parts/r/partition_alter_myisam.result
index 9f2381039d3..41af6af72fc 100644
--- a/mysql-test/suite/parts/r/partition_alter_myisam.result
+++ b/mysql-test/suite/parts/r/partition_alter_myisam.result
@@ -42,3 +42,16 @@ PARTITION p3 VALUES IN (4,5,6)
);
ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition
DROP TABLE t1;
+create table t1 ( c1 int, c2 int, c3 varchar(100)) delay_key_write=1
+partition by key(c1) (
+partition p01 data directory = 'MYSQL_TMP_DIR'
+ index directory = 'MYSQL_TMP_DIR',
+partition p02 data directory = 'MYSQL_TMP_DIR'
+ index directory = 'MYSQL_TMP_DIR');
+insert into t1 values (1, 1, repeat('a', 100));
+insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1;
+insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1;
+insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1;
+alter online table t1 delay_key_write=0;
+alter online table t1 delay_key_write=1;
+drop table t1;
diff --git a/mysql-test/suite/parts/t/partition_alter_myisam.test b/mysql-test/suite/parts/t/partition_alter_myisam.test
index a53fa333abd..b2bd0e72e4c 100644
--- a/mysql-test/suite/parts/t/partition_alter_myisam.test
+++ b/mysql-test/suite/parts/t/partition_alter_myisam.test
@@ -1,3 +1,22 @@
--source include/have_partition.inc
--let $engine=MyISAM
--source inc/part_alter_values.inc
+
+#
+# MDEV-14026 ALTER TABLE ... DELAY_KEY_WRITE=1 creates table copy for partitioned MyISAM table with DATA DIRECTORY/INDEX DIRECTORY options
+#
+
+replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR;
+eval create table t1 ( c1 int, c2 int, c3 varchar(100)) delay_key_write=1
+ partition by key(c1) (
+ partition p01 data directory = '$MYSQL_TMP_DIR'
+ index directory = '$MYSQL_TMP_DIR',
+ partition p02 data directory = '$MYSQL_TMP_DIR'
+ index directory = '$MYSQL_TMP_DIR');
+insert into t1 values (1, 1, repeat('a', 100));
+insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1;
+insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1;
+insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1;
+alter online table t1 delay_key_write=0;
+alter online table t1 delay_key_write=1;
+drop table t1;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 459af18f737..34c253cc48a 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -8133,20 +8133,36 @@ uint ha_partition::alter_table_flags(uint flags)
bool ha_partition::check_if_incompatible_data(HA_CREATE_INFO *create_info,
uint table_changes)
{
- handler **file;
- bool ret= COMPATIBLE_DATA_YES;
-
/*
The check for any partitioning related changes have already been done
in mysql_alter_table (by fix_partition_func), so it is only up to
the underlying handlers.
*/
- for (file= m_file; *file; file++)
- if ((ret= (*file)->check_if_incompatible_data(create_info,
- table_changes)) !=
- COMPATIBLE_DATA_YES)
- break;
- return ret;
+ List_iterator<partition_element> part_it(m_part_info->partitions);
+ HA_CREATE_INFO dummy_info= *create_info;
+ uint i=0;
+ while (partition_element *part_elem= part_it++)
+ {
+ if (m_is_sub_partitioned)
+ {
+ List_iterator<partition_element> subpart_it(part_elem->subpartitions);
+ while (partition_element *sub_elem= subpart_it++)
+ {
+ dummy_info.data_file_name= sub_elem->data_file_name;
+ dummy_info.index_file_name= sub_elem->index_file_name;
+ if (m_file[i++]->check_if_incompatible_data(&dummy_info, table_changes))
+ return COMPATIBLE_DATA_NO;
+ }
+ }
+ else
+ {
+ dummy_info.data_file_name= part_elem->data_file_name;
+ dummy_info.index_file_name= part_elem->index_file_name;
+ if (m_file[i++]->check_if_incompatible_data(&dummy_info, table_changes))
+ return COMPATIBLE_DATA_NO;
+ }
+ }
+ return COMPATIBLE_DATA_YES;
}