diff options
author | Mattias Jonsson <mattias.jonsson@oracle.com> | 2011-09-15 20:49:39 +0200 |
---|---|---|
committer | Mattias Jonsson <mattias.jonsson@oracle.com> | 2011-09-15 20:49:39 +0200 |
commit | ab761db8d5c4d59229c94687abf5030130a168b2 (patch) | |
tree | 2e0c5c3951ea9c5742508de17b2790c27bfbc4bc /mysql-test | |
parent | 39175b922504c8e459040657e48c89ea14256683 (diff) | |
download | mariadb-git-ab761db8d5c4d59229c94687abf5030130a168b2.tar.gz |
Bug#12696518: MEMORY LEAKS IN HA_PARTITION (VALGRIND TESTS ON TRUNK)
(also 5.5+ solution for bug#11766879/bug#60106)
The valgrind warning was due to an unused 'new handler_add_index(...)'
which was never freed.
The error handling did not work (fails as in bug#11766879) and
the implementation was not as transparant as it could, therefore I
made it a bit simpler and more transparant to the underlying handlers.
This way it follows the api better and the error handling works and
is also now tested.
Also added a debug test to verify the error handling.
Improved according to Jon Olavs review:
Added class ha_partition_add_index.
Also added base class Sql_alloc to handler_add_index.
Update 3.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/partition_innodb_plugin.result | 34 | ||||
-rw-r--r-- | mysql-test/suite/parts/r/partition_debug_innodb.result | 71 | ||||
-rw-r--r-- | mysql-test/suite/parts/t/partition_debug_innodb.test | 35 | ||||
-rw-r--r-- | mysql-test/t/partition_innodb_plugin.test | 27 |
4 files changed, 167 insertions, 0 deletions
diff --git a/mysql-test/r/partition_innodb_plugin.result b/mysql-test/r/partition_innodb_plugin.result index aa0944e96b5..f30dbd20119 100644 --- a/mysql-test/r/partition_innodb_plugin.result +++ b/mysql-test/r/partition_innodb_plugin.result @@ -1,3 +1,37 @@ +# +# Bug#11766879/Bug#60106: DIFF BETWEEN # OF INDEXES IN MYSQL VS INNODB, +# PARTITONING, ON INDEX CREATE +# Bug#12696518: MEMORY LEAKS IN HA_PARTITION (VALGRIND TESTS ON TRUNK) +# +CREATE TABLE t1 ( +id bigint NOT NULL AUTO_INCREMENT, +time date, +id2 bigint not null, +PRIMARY KEY (id,time) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +/*!50100 PARTITION BY RANGE(TO_DAYS(time)) +(PARTITION p10 VALUES LESS THAN (734708) ENGINE = InnoDB, +PARTITION p20 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */; +INSERT INTO t1 (time,id2) VALUES ('2011-07-24',1); +INSERT INTO t1 (time,id2) VALUES ('2011-07-25',1); +INSERT INTO t1 (time,id2) VALUES ('2011-07-25',1); +CREATE UNIQUE INDEX uk_time_id2 on t1(time,id2); +ERROR 23000: Duplicate entry '2011-07-25-1' for key 'uk_time_id2' +SELECT COUNT(*) FROM t1; +COUNT(*) +3 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `time` date NOT NULL DEFAULT '0000-00-00', + `id2` bigint(20) NOT NULL, + PRIMARY KEY (`id`,`time`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 +/*!50100 PARTITION BY RANGE (TO_DAYS(time)) +(PARTITION p10 VALUES LESS THAN (734708) ENGINE = InnoDB, + PARTITION p20 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ +DROP TABLE t1; call mtr.add_suppression("nnoDB: Error: table `test`.`t1` .* Partition.* InnoDB internal"); # # Bug#55091: Server crashes on ADD PARTITION after a failed attempt diff --git a/mysql-test/suite/parts/r/partition_debug_innodb.result b/mysql-test/suite/parts/r/partition_debug_innodb.result index 49d863bca8e..bae4faf434e 100644 --- a/mysql-test/suite/parts/r/partition_debug_innodb.result +++ b/mysql-test/suite/parts/r/partition_debug_innodb.result @@ -1,4 +1,75 @@ DROP TABLE IF EXISTS t1; +# +# Bug#12696518/Bug#11766879/60106:DIFF BETWEEN # OF INDEXES IN MYSQL +# VS INNODB, PARTITONING, ON INDEX CREATE +# +CREATE TABLE t1 +(a INT PRIMARY KEY, +b VARCHAR(64)) +ENGINE = InnoDB +PARTITION BY HASH (a) PARTITIONS 3; +INSERT INTO t1 VALUES (0, 'first row'), (1, 'second row'), (2, 'Third row'); +INSERT INTO t1 VALUES (3, 'row id 3'), (4, '4 row'), (5, 'row5'); +INSERT INTO t1 VALUES (6, 'X 6 row'), (7, 'Seventh row'), (8, 'Last row'); +ALTER TABLE t1 ADD INDEX new_b_index (b); +ALTER TABLE t1 DROP INDEX new_b_index; +SET SESSION debug= "+d,ha_partition_fail_final_add_index"; +ALTER TABLE t1 ADD INDEX (b); +ERROR HY000: Table has no partition for value 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` varchar(64) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +PARTITIONS 3 */ +SELECT * FROM t1; +a b +0 first row +1 second row +2 Third row +3 row id 3 +4 4 row +5 row5 +6 X 6 row +7 Seventh row +8 Last row +FLUSH TABLES; +CREATE INDEX new_index ON t1 (b); +ERROR HY000: Table has no partition for value 0 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` varchar(64) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +PARTITIONS 3 */ +SELECT * FROM t1; +a b +0 first row +1 second row +2 Third row +3 row id 3 +4 4 row +5 row5 +6 X 6 row +7 Seventh row +8 Last row +SET SESSION debug= "-d,ha_partition_fail_final_add_index"; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` varchar(64) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY HASH (a) +PARTITIONS 3 */ +DROP TABLE t1; call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was"); call mtr.add_suppression("InnoDB: Error: table .* does not exist in the InnoDB internal"); call mtr.add_suppression("InnoDB: Warning: MySQL is trying to drop table "); diff --git a/mysql-test/suite/parts/t/partition_debug_innodb.test b/mysql-test/suite/parts/t/partition_debug_innodb.test index c5d8df33213..b546f6d73f8 100644 --- a/mysql-test/suite/parts/t/partition_debug_innodb.test +++ b/mysql-test/suite/parts/t/partition_debug_innodb.test @@ -12,6 +12,41 @@ DROP TABLE IF EXISTS t1; --let $DATADIR= `SELECT @@datadir;` +--echo # +--echo # Bug#12696518/Bug#11766879/60106:DIFF BETWEEN # OF INDEXES IN MYSQL +--echo # VS INNODB, PARTITONING, ON INDEX CREATE +--echo # +CREATE TABLE t1 +(a INT PRIMARY KEY, + b VARCHAR(64)) +ENGINE = InnoDB +PARTITION BY HASH (a) PARTITIONS 3; +INSERT INTO t1 VALUES (0, 'first row'), (1, 'second row'), (2, 'Third row'); +INSERT INTO t1 VALUES (3, 'row id 3'), (4, '4 row'), (5, 'row5'); +INSERT INTO t1 VALUES (6, 'X 6 row'), (7, 'Seventh row'), (8, 'Last row'); + +ALTER TABLE t1 ADD INDEX new_b_index (b); +ALTER TABLE t1 DROP INDEX new_b_index; + +SET SESSION debug= "+d,ha_partition_fail_final_add_index"; + +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +ALTER TABLE t1 ADD INDEX (b); +SHOW CREATE TABLE t1; +--sorted_result +SELECT * FROM t1; + +FLUSH TABLES; +--error ER_NO_PARTITION_FOR_GIVEN_VALUE +CREATE INDEX new_index ON t1 (b); +SHOW CREATE TABLE t1; +--sorted_result +SELECT * FROM t1; + +SET SESSION debug= "-d,ha_partition_fail_final_add_index"; +SHOW CREATE TABLE t1; +DROP TABLE t1; + # Checking with #innodb what this is... call mtr.add_suppression("InnoDB: Warning: allocated tablespace .*, old maximum was"); # If there is a crash or failure between the ddl_log is written and the diff --git a/mysql-test/t/partition_innodb_plugin.test b/mysql-test/t/partition_innodb_plugin.test index e8b73687177..ee428e0662f 100644 --- a/mysql-test/t/partition_innodb_plugin.test +++ b/mysql-test/t/partition_innodb_plugin.test @@ -3,6 +3,33 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo # +--echo # Bug#11766879/Bug#60106: DIFF BETWEEN # OF INDEXES IN MYSQL VS INNODB, +--echo # PARTITONING, ON INDEX CREATE +--echo # Bug#12696518: MEMORY LEAKS IN HA_PARTITION (VALGRIND TESTS ON TRUNK) +--echo # +CREATE TABLE t1 ( + id bigint NOT NULL AUTO_INCREMENT, + time date, + id2 bigint not null, + PRIMARY KEY (id,time) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 +/*!50100 PARTITION BY RANGE(TO_DAYS(time)) +(PARTITION p10 VALUES LESS THAN (734708) ENGINE = InnoDB, + PARTITION p20 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */; + +INSERT INTO t1 (time,id2) VALUES ('2011-07-24',1); +INSERT INTO t1 (time,id2) VALUES ('2011-07-25',1); +INSERT INTO t1 (time,id2) VALUES ('2011-07-25',1); + +--error ER_DUP_ENTRY +CREATE UNIQUE INDEX uk_time_id2 on t1(time,id2); + +SELECT COUNT(*) FROM t1; +SHOW CREATE TABLE t1; + +DROP TABLE t1; + call mtr.add_suppression("nnoDB: Error: table `test`.`t1` .* Partition.* InnoDB internal"); --echo # --echo # Bug#55091: Server crashes on ADD PARTITION after a failed attempt |