diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 59137614ed3..1e2b799b753 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -908,5 +908,8 @@ ALTER TABLE t1 OPTIMIZE PARTITION p0; SHOW TABLE STATUS; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment t1 MyISAM 10 Fixed 1 7 7 0 1024 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a); +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t1 ENABLE KEYS; DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 245b26758b6..e2adc8a9d15 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1034,4 +1034,12 @@ ALTER TABLE t1 OPTIMIZE PARTITION p0; SHOW TABLE STATUS; DROP TABLE t1; +# +# BUG 19502: ENABLE/DISABLE Keys don't work for partitioned tables +# +CREATE TABLE t1 (a int, index(a)) PARTITION BY KEY(a); +ALTER TABLE t1 DISABLE KEYS; +ALTER TABLE t1 ENABLE KEYS; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index c58df5b2d3c..bb83c0cd3f2 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -5322,6 +5322,82 @@ void ha_partition::init_table_handle_for_HANDLER() } +/**************************************************************************** + MODULE enable/disable indexes +****************************************************************************/ + +/* + Disable indexes for a while + SYNOPSIS + disable_indexes() + mode Mode + RETURN VALUES + 0 Success + != 0 Error +*/ + +int ha_partition::disable_indexes(uint mode) +{ + handler **file; + int error= 0; + + for (file= m_file; *file; file++) + { + if ((error= (*file)->disable_indexes(mode))) + break; + } + return error; +} + + +/* + Enable indexes again + SYNOPSIS + enable_indexes() + mode Mode + RETURN VALUES + 0 Success + != 0 Error +*/ + +int ha_partition::enable_indexes(uint mode) +{ + handler **file; + int error= 0; + + for (file= m_file; *file; file++) + { + if ((error= (*file)->enable_indexes(mode))) + break; + } + return error; +} + + +/* + Check if indexes are disabled + SYNOPSIS + indexes_are_disabled() + + RETURN VALUES + 0 Indexes are enabled + != 0 Indexes are disabled +*/ + +int ha_partition::indexes_are_disabled(void) +{ + handler **file; + int error= 0; + + for (file= m_file; *file; file++) + { + if ((error= (*file)->indexes_are_disabled())) + break; + } + return error; +} + + /**************************************************************************** MODULE Partition Share ****************************************************************************/ diff --git a/sql/ha_partition.h b/sql/ha_partition.h index b31b9af28a3..1443a20133c 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -938,17 +938,18 @@ public: virtual uint checksum() const; virtual bool is_crashed() const; virtual bool auto_repair() const; + */ + /* ------------------------------------------------------------------------- MODULE enable/disable indexes ------------------------------------------------------------------------- - Enable/Disable Indexes are not supported currently (Heap, MyISAM) - This means that the following methods are not implemented: + Enable/Disable Indexes are only supported by HEAP and MyISAM. ------------------------------------------------------------------------- + */ virtual int disable_indexes(uint mode); virtual int enable_indexes(uint mode); virtual int indexes_are_disabled(void); - */ /* -------------------------------------------------------------------------