From: Ashish Agarwal Date: November 18 2011 6:07am Subject: bzr push into mysql-trunk branch (ashish.y.agarwal:3623 to 3624) Bug#11760213 List-Archive: http://lists.mysql.com/commits/142029 X-Bug: 11760213 Message-Id: <201111180608.pAI686JL030563@acsmt356.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3624 Ashish Agarwal 2011-11-18 bug#11760213 - 52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED TABLE CORRUPTS MYISAM. ISSUE: Removing partitioning on a not partitioned table was permitted, but wasn't handled properly. As a result storage engine and .frm table definitions may go out of sync. SOLUTION: With this patch removing partitioning on a not partitioned is forbidden. removed: mysql-test/r/disabled_partition.require mysql-test/r/not_partition.require modified: mysql-test/r/not_partition.result mysql-test/r/partition_disabled.result mysql-test/r/partition_myisam.result mysql-test/t/not_partition.test mysql-test/t/partition_disabled.test mysql-test/t/partition_myisam.test sql/sql_partition.cc sql/sql_yacc.yy 3623 Tor Didriksen 2011-11-17 WL#5825 Using C++ Standard Library with MySQL code post-push cleanup: the old workaround to avoid undefined reference to `__pure_virtual' no longer works. The client library contains C++ code, and must be linked with g++ modified: scripts/mysql_config.sh support-files/mysql.spec.sh === removed file 'mysql-test/r/disabled_partition.require' --- a/mysql-test/r/disabled_partition.require 2009-01-08 14:16:44 +0000 +++ b/mysql-test/r/disabled_partition.require 1970-01-01 00:00:00 +0000 @@ -1,2 +0,0 @@ -Variable_name Value -have_partitioning DISABLED === removed file 'mysql-test/r/not_partition.require' --- a/mysql-test/r/not_partition.require 2006-10-26 17:11:09 +0000 +++ b/mysql-test/r/not_partition.require 1970-01-01 00:00:00 +0000 @@ -1,2 +0,0 @@ -Variable_name Value -have_partitioning NO === modified file 'mysql-test/r/not_partition.result' --- a/mysql-test/r/not_partition.result 2010-10-05 10:31:55 +0000 +++ b/mysql-test/r/not_partition.result 2011-11-18 06:06:29 +0000 @@ -85,3 +85,18 @@ explain partitions select * from t1 wher id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 Using where drop table t1; +# +# bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED +# TABLE CORRUPTS MYISAM +DROP TABLE if exists `t1`; +CREATE TABLE `t1`(`a` INT)ENGINE=myisam; +ALTER TABLE `t1` ADD COLUMN `b` INT; +CREATE UNIQUE INDEX `i1` ON `t1`(`b`); +CREATE UNIQUE INDEX `i2` ON `t1`(`a`); +ALTER TABLE `t1` ADD PRIMARY KEY (`a`); +ALTER TABLE `t1` REMOVE PARTITIONING; +ERROR HY000: The 'partitioning' feature is disabled; you need MySQL built with '--with-plugin-partition' to have it working +CHECK TABLE `t1` EXTENDED; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; === modified file 'mysql-test/r/partition_disabled.result' --- a/mysql-test/r/partition_disabled.result 2010-08-30 06:38:09 +0000 +++ b/mysql-test/r/partition_disabled.result 2011-11-18 06:06:29 +0000 @@ -91,3 +91,18 @@ explain partitions select * from t1 wher id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 5 Using where drop table t1; +# +# bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED +# TABLE CORRUPTS MYISAM +DROP TABLE if exists `t1`; +CREATE TABLE `t1`(`a` INT)ENGINE=myisam; +ALTER TABLE `t1` ADD COLUMN `b` INT; +CREATE UNIQUE INDEX `i1` ON `t1`(`b`); +CREATE UNIQUE INDEX `i2` ON `t1`(`a`); +ALTER TABLE `t1` ADD PRIMARY KEY (`a`); +ALTER TABLE `t1` REMOVE PARTITIONING; +ERROR HY000: The MySQL server is running with the --skip-partition option so it cannot execute this statement +CHECK TABLE `t1` EXTENDED; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; === modified file 'mysql-test/r/partition_myisam.result' --- a/mysql-test/r/partition_myisam.result 2011-10-07 14:20:21 +0000 +++ b/mysql-test/r/partition_myisam.result 2011-11-18 06:06:29 +0000 @@ -327,3 +327,18 @@ PARTITION p1 VALUES LESS THAN (100) MAX_ PARTITION pMax VALUES LESS THAN MAXVALUE); INSERT INTO t1 VALUES (1, "Partition p1, first row"); DROP TABLE t1; +# +# bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED +# TABLE CORRUPTS MYISAM +DROP TABLE if exists `t1`; +CREATE TABLE `t1`(`a` INT)ENGINE=myisam; +ALTER TABLE `t1` ADD COLUMN `b` INT; +CREATE UNIQUE INDEX `i1` ON `t1`(`b`); +CREATE UNIQUE INDEX `i2` ON `t1`(`a`); +ALTER TABLE `t1` ADD PRIMARY KEY (`a`); +ALTER TABLE `t1` REMOVE PARTITIONING; +ERROR HY000: Partition management on a not partitioned table is not possible +CHECK TABLE `t1` EXTENDED; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; === modified file 'mysql-test/t/not_partition.test' --- a/mysql-test/t/not_partition.test 2010-08-16 12:53:30 +0000 +++ b/mysql-test/t/not_partition.test 2011-11-18 06:06:29 +0000 @@ -2,9 +2,9 @@ # Run this test only when mysqld don't has partitioning (not compiled with) # the statements are not expected to work, just check that we # can't crash the server --- require r/not_partition.require disable_query_log; -show variables like "have_partitioning"; +--require r/true.require +SELECT (COUNT(*) = 0) AS `TRUE` FROM information_schema.plugins WHERE plugin_name LIKE 'partition%'; enable_query_log; --disable_warnings DROP TABLE IF EXISTS t1; @@ -84,3 +84,18 @@ create table t1 (a varchar(10) charset l insert into t1 values (''),(' '),('a'),('a '),('a '); explain partitions select * from t1 where a='a ' OR a='a'; drop table t1; +--echo # +--echo # bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED +--echo # TABLE CORRUPTS MYISAM +--disable_warnings +DROP TABLE if exists `t1`; +--enable_warnings +CREATE TABLE `t1`(`a` INT)ENGINE=myisam; +ALTER TABLE `t1` ADD COLUMN `b` INT; +CREATE UNIQUE INDEX `i1` ON `t1`(`b`); +CREATE UNIQUE INDEX `i2` ON `t1`(`a`); +ALTER TABLE `t1` ADD PRIMARY KEY (`a`); +--error ER_FEATURE_DISABLED +ALTER TABLE `t1` REMOVE PARTITIONING; +CHECK TABLE `t1` EXTENDED; +DROP TABLE t1; === modified file 'mysql-test/t/partition_disabled.test' --- a/mysql-test/t/partition_disabled.test 2009-08-12 10:03:05 +0000 +++ b/mysql-test/t/partition_disabled.test 2011-11-18 06:06:29 +0000 @@ -2,10 +2,10 @@ # Run this test only when mysqld has partitioning, but it is disabled. # The statements are not expected to work, just check that we # can't crash the server. ---require r/disabled_partition.require ---disable_query_log -show variables like "have_partitioning"; ---enable_query_log +disable_query_log; +--require r/true.require +SELECT (plugin_status = 'DISABLED') AS `TRUE` FROM information_schema.plugins WHERE plugin_name LIKE 'partition%'; +enable_query_log; --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings @@ -83,3 +83,18 @@ create table t1 (a varchar(10) charset l insert into t1 values (''),(' '),('a'),('a '),('a '); explain partitions select * from t1 where a='a ' OR a='a'; drop table t1; +--echo # +--echo # bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED +--echo # TABLE CORRUPTS MYISAM +--disable_warnings +DROP TABLE if exists `t1`; +--enable_warnings +CREATE TABLE `t1`(`a` INT)ENGINE=myisam; +ALTER TABLE `t1` ADD COLUMN `b` INT; +CREATE UNIQUE INDEX `i1` ON `t1`(`b`); +CREATE UNIQUE INDEX `i2` ON `t1`(`a`); +ALTER TABLE `t1` ADD PRIMARY KEY (`a`); +--error ER_OPTION_PREVENTS_STATEMENT +ALTER TABLE `t1` REMOVE PARTITIONING; +CHECK TABLE `t1` EXTENDED; +DROP TABLE t1; === modified file 'mysql-test/t/partition_myisam.test' --- a/mysql-test/t/partition_myisam.test 2011-10-07 14:20:21 +0000 +++ b/mysql-test/t/partition_myisam.test 2011-11-18 06:06:29 +0000 @@ -233,3 +233,18 @@ PARTITION BY RANGE (a) PARTITION pMax VALUES LESS THAN MAXVALUE); INSERT INTO t1 VALUES (1, "Partition p1, first row"); DROP TABLE t1; +--echo # +--echo # bug#11760213-52599: ALTER TABLE REMOVE PARTITIONING ON NON-PARTITIONED +--echo # TABLE CORRUPTS MYISAM +--disable_warnings +DROP TABLE if exists `t1`; +--enable_warnings +CREATE TABLE `t1`(`a` INT)ENGINE=myisam; +ALTER TABLE `t1` ADD COLUMN `b` INT; +CREATE UNIQUE INDEX `i1` ON `t1`(`b`); +CREATE UNIQUE INDEX `i2` ON `t1`(`a`); +ALTER TABLE `t1` ADD PRIMARY KEY (`a`); +--error ER_PARTITION_MGMT_ON_NONPARTITIONED +ALTER TABLE `t1` REMOVE PARTITIONING; +CHECK TABLE `t1` EXTENDED; +DROP TABLE t1; === modified file 'sql/sql_partition.cc' --- a/sql/sql_partition.cc 2011-11-16 15:24:04 +0000 +++ b/sql/sql_partition.cc 2011-11-18 06:06:29 +0000 @@ -4669,6 +4669,12 @@ uint prep_alter_part_table(THD *thd, TAB my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0)); DBUG_RETURN(TRUE); } + /* Remove partitioning on a not partitioned table is not possible */ + if (!table->part_info && (alter_info->flags & ALTER_REMOVE_PARTITIONING)) + { + my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0)); + DBUG_RETURN(TRUE); + } thd->work_part_info= thd->lex->part_info; === modified file 'sql/sql_yacc.yy' --- a/sql/sql_yacc.yy 2011-11-11 17:37:44 +0000 +++ b/sql/sql_yacc.yy 2011-11-18 06:06:29 +0000 @@ -6869,7 +6869,7 @@ alter_commands: ; remove_partitioning: - REMOVE_SYM PARTITIONING_SYM + REMOVE_SYM PARTITIONING_SYM have_partitioning { Lex->alter_info.flags|= ALTER_REMOVE_PARTITIONING; } No bundle (reason: useless for push emails).