1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-21 11:01:08 +03:00
This commit is contained in:
Mattias Jonsson
2010-08-13 10:14:37 +02:00
27 changed files with 9100 additions and 172 deletions

View File

@@ -1,5 +1,67 @@
drop table if exists t1, t2;
#
# Bug#50418: DROP PARTITION does not interact with transactions
#
CREATE TABLE t1 (
id INT AUTO_INCREMENT NOT NULL,
name CHAR(50) NOT NULL,
myDate DATE NOT NULL,
PRIMARY KEY (id, myDate),
INDEX idx_date (myDate)
) ENGINE=InnoDB
PARTITION BY RANGE ( TO_DAYS(myDate) ) (
PARTITION p0 VALUES LESS THAN (734028),
PARTITION p1 VALUES LESS THAN (734029),
PARTITION p2 VALUES LESS THAN (734030),
PARTITION p3 VALUES LESS THAN MAXVALUE
) ;
INSERT INTO t1 VALUES
(NULL, 'Lachlan', '2009-09-13'),
(NULL, 'Clint', '2009-09-13'),
(NULL, 'John', '2009-09-14'),
(NULL, 'Dave', '2009-09-14'),
(NULL, 'Jeremy', '2009-09-15'),
(NULL, 'Scott', '2009-09-15'),
(NULL, 'Jeff', '2009-09-16'),
(NULL, 'Joe', '2009-09-16');
SET AUTOCOMMIT=0;
SELECT * FROM t1 FOR UPDATE;
id name myDate
1 Lachlan 2009-09-13
2 Clint 2009-09-13
3 John 2009-09-14
4 Dave 2009-09-14
5 Jeremy 2009-09-15
6 Scott 2009-09-15
7 Jeff 2009-09-16
8 Joe 2009-09-16
UPDATE t1 SET name = 'Mattias' WHERE id = 7;
SELECT * FROM t1 WHERE id = 7;
id name myDate
7 Mattias 2009-09-16
# Connection con1
SET lock_wait_timeout = 1;
# After the patch it will wait and fail on timeout.
ALTER TABLE t1 DROP PARTITION p3;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SHOW WARNINGS;
Level Code Message
Error 1205 Lock wait timeout exceeded; try restarting transaction
# Connection default
SELECT * FROM t1;
id name myDate
1 Lachlan 2009-09-13
2 Clint 2009-09-13
3 John 2009-09-14
4 Dave 2009-09-14
5 Jeremy 2009-09-15
6 Scott 2009-09-15
7 Mattias 2009-09-16
8 Joe 2009-09-16
# No changes.
COMMIT;
DROP TABLE t1;
#
# Bug#51830: Incorrect partition pruning on range partition (regression)
#
CREATE TABLE t1 (a INT NOT NULL)

View File

@@ -0,0 +1,28 @@
# Include file to decrease test code duplication
--eval $create_statement
--eval $insert_statement
--echo # State before crash
--replace_result #p# #P#
--list_files $DATADIR/test
SHOW CREATE TABLE t1;
--sorted_result
SELECT * FROM t1;
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--disable_reconnect
# CR_SERVER_LOST
--error 2013
--eval $crash_statement
--echo # State after crash (before recovery)
--replace_regex /sqlx.*\./sqlx-nnnn_nnnn./ /#p#/#P#/
--list_files $DATADIR/test
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc
--echo # State after crash recovery
--replace_result #p# #P#
--list_files $DATADIR/test
SHOW CREATE TABLE t1;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;

View File

@@ -0,0 +1,33 @@
# To be used with partition mgm commands like
# ALTER TABLE t1 ADD PARTITION (LIST/RANGE PARTITIONING).
--echo # Crash testing ADD PARTITION
SET SESSION debug="+d,crash_add_partition_1";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_1";
SET SESSION debug="+d,crash_add_partition_2";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_2";
SET SESSION debug="+d,crash_add_partition_3";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_3";
SET SESSION debug="+d,crash_add_partition_4";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_4";
SET SESSION debug="+d,crash_add_partition_5";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_5";
SET SESSION debug="+d,crash_add_partition_6";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_6";
SET SESSION debug="+d,crash_add_partition_7";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_7";
SET SESSION debug="+d,crash_add_partition_8";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_8";
SET SESSION debug="+d,crash_add_partition_9";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_9";
SET SESSION debug="+d,crash_add_partition_10";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_add_partition_10";

View File

@@ -0,0 +1,40 @@
# To be used with partition mgm commands like
# ALTER TABLE t1 COALESCE/REBUILD/REORGANIZE PARTITION.
--echo # Test change partition (REORGANIZE/REBUILD/COALESCE
--echo # or ADD HASH PARTITION).
SET SESSION debug="+d,crash_change_partition_1";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_1";
SET SESSION debug="+d,crash_change_partition_2";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_2";
SET SESSION debug="+d,crash_change_partition_3";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_3";
SET SESSION debug="+d,crash_change_partition_4";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_4";
SET SESSION debug="+d,crash_change_partition_5";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_5";
SET SESSION debug="+d,crash_change_partition_6";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_6";
SET SESSION debug="+d,crash_change_partition_7";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_7";
SET SESSION debug="+d,crash_change_partition_8";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_8";
SET SESSION debug="+d,crash_change_partition_9";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_9";
SET SESSION debug="+d,crash_change_partition_10";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_10";
SET SESSION debug="+d,crash_change_partition_11";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_11";
SET SESSION debug="+d,crash_change_partition_12";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_change_partition_12";

View File

@@ -0,0 +1,30 @@
# To be used with partition mgm commands like
# ALTER TABLE t1 DROP PARTITION.
--echo # Test DROP PARTITION
SET SESSION debug="+d,crash_drop_partition_1";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_1";
SET SESSION debug="+d,crash_drop_partition_2";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_2";
SET SESSION debug="+d,crash_drop_partition_3";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_3";
SET SESSION debug="+d,crash_drop_partition_4";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_4";
SET SESSION debug="+d,crash_drop_partition_5";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_5";
SET SESSION debug="+d,crash_drop_partition_6";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_6";
SET SESSION debug="+d,crash_drop_partition_7";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_7";
SET SESSION debug="+d,crash_drop_partition_8";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_8";
SET SESSION debug="+d,crash_drop_partition_9";
--source suite/parts/inc/partition_crash.inc
SET SESSION debug="-d,crash_drop_partition_9";

View File

@@ -0,0 +1,18 @@
# Include file to decrease test code duplication
--eval $create_statement
--eval $insert_statement
--echo # State before failure
--list_files $DATADIR/test
SHOW CREATE TABLE t1;
--sorted_result
SELECT * FROM t1;
--disable_abort_on_error
--eval $fail_statement
--enable_abort_on_error
--echo # State after failure
--list_files $DATADIR/test
SHOW CREATE TABLE t1;
--sorted_result
SELECT * FROM t1;
DROP TABLE t1;

View File

@@ -0,0 +1,33 @@
# To be used with partition mgm commands like
# ALTER TABLE t1 ADD PARTITION (LIST/RANGE PARTITIONING).
--echo # Error recovery testing ADD PARTITION
SET SESSION debug="+d,fail_add_partition_1";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_1";
SET SESSION debug="+d,fail_add_partition_2";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_2";
SET SESSION debug="+d,fail_add_partition_3";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_3";
SET SESSION debug="+d,fail_add_partition_4";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_4";
SET SESSION debug="+d,fail_add_partition_5";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_5";
SET SESSION debug="+d,fail_add_partition_6";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_6";
SET SESSION debug="+d,fail_add_partition_7";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_7";
SET SESSION debug="+d,fail_add_partition_8";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_8";
SET SESSION debug="+d,fail_add_partition_9";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_9";
SET SESSION debug="+d,fail_add_partition_10";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_add_partition_10";

View File

@@ -0,0 +1,40 @@
# To be used with partition mgm commands like
# ALTER TABLE t1 COALESCE/REBUILD/REORGANIZE PARTITION.
--echo # Error recovery change partition (REORGANIZE/REBUILD/COALESCE
--echo # or ADD HASH PARTITION).
SET SESSION debug="+d,fail_change_partition_1";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_1";
SET SESSION debug="+d,fail_change_partition_2";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_2";
SET SESSION debug="+d,fail_change_partition_3";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_3";
SET SESSION debug="+d,fail_change_partition_4";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_4";
SET SESSION debug="+d,fail_change_partition_5";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_5";
SET SESSION debug="+d,fail_change_partition_6";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_6";
SET SESSION debug="+d,fail_change_partition_7";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_7";
SET SESSION debug="+d,fail_change_partition_8";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_8";
SET SESSION debug="+d,fail_change_partition_9";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_9";
SET SESSION debug="+d,fail_change_partition_10";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_10";
SET SESSION debug="+d,fail_change_partition_11";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_11";
SET SESSION debug="+d,fail_change_partition_12";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_change_partition_12";

View File

@@ -0,0 +1,30 @@
# To be used with partition mgm commands like
# ALTER TABLE t1 DROP PARTITION.
--echo # Error recovery DROP PARTITION
SET SESSION debug="+d,fail_drop_partition_1";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_1";
SET SESSION debug="+d,fail_drop_partition_2";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_2";
SET SESSION debug="+d,fail_drop_partition_3";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_3";
SET SESSION debug="+d,fail_drop_partition_4";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_4";
SET SESSION debug="+d,fail_drop_partition_5";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_5";
SET SESSION debug="+d,fail_drop_partition_6";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_6";
SET SESSION debug="+d,fail_drop_partition_7";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_7";
SET SESSION debug="+d,fail_drop_partition_8";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_8";
SET SESSION debug="+d,fail_drop_partition_9";
--source suite/parts/inc/partition_fail.inc
SET SESSION debug="-d,fail_drop_partition_9";

View File

@@ -0,0 +1,34 @@
# collection of tests which crashes the server and checks recovery.
# also using error injection to test recovery of failures.
# uses $DATADIR and $engine
--echo #
--echo # Bug#53676: Unexpected errors and possible table corruption on
--echo # ADD PARTITION and LOCK TABLE
--echo # Bug#53770: Server crash at handler.cc:2076 on LOAD DATA
--echo # after timed out COALESCE PARTITION
--echo # Extended crash recovery testing of fast_alter_partition_table.
call mtr.add_suppression("Attempting backtrace. You can use the following information to find out");
let $create_statement= CREATE TABLE t1 (a INT, b VARCHAR(64))
ENGINE = $engine
PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (0,1,2,3,4,5,6,7,8,9),
PARTITION p10 VALUES IN (11,12,13,14,15,16,17,18,19));
let $insert_statement= INSERT INTO t1 VALUES (1, "Original from partition p0"), (2, "Original from partition p0"), (3, "Original from partition p0"), (4, "Original from partition p0"), (11, "Original from partition p1"), (12, "Original from partition p1"), (13, "Original from partition p1"), (14, "Original from partition p1");
let $crash_statement= ALTER TABLE t1 ADD PARTITION
(PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29));
--source suite/parts/inc/partition_crash_add.inc
let $fail_statement= $crash_statement;
--source suite/parts/inc/partition_fail_add.inc
let $crash_statement= ALTER TABLE t1 DROP PARTITION p10;
--source suite/parts/inc/partition_crash_drop.inc
let $fail_statement= $crash_statement;
--source suite/parts/inc/partition_fail_drop.inc
let $crash_statement= ALTER TABLE t1 REORGANIZE PARTITION p10 INTO
(PARTITION p10 VALUES IN (10,11,12,13,14,15,16,17,18,19),
PARTITION p20 VALUES IN (20,21,22,23,24,25,26,27,28,29));
--source suite/parts/inc/partition_crash_change.inc
let $fail_statement= $crash_statement;
--source suite/parts/inc/partition_fail_change.inc

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -216,3 +216,71 @@ SET SESSION lock_wait_timeout= 1;
ALTER TABLE t1 AUTO_INCREMENT = 10;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
DROP TABLE t1;
#
# Bug#53676: Unexpected errors and possible table corruption on
# ADD PARTITION and LOCK TABLE
CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;
SET lock_wait_timeout = 2;
#Connection 1 locks the table
LOCK TABLE t1 READ;
# Connection 2 tries to add partitions:
# First attempt: lock wait timeout (as expected)
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
# Second attempt: says that partition already exists
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
# Connection 1 unlocks the table and locks it again:
UNLOCK TABLES;
LOCK TABLE t1 READ;
# Connection 2 tries again to add partitions:
# Third attempt: says that the table does not exist
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
# Check table returns the same
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check Error Lock wait timeout exceeded; try restarting transaction
test.t1 check error Corrupt
UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t2 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;
SET lock_wait_timeout = 2;
LOCK TABLE t2 READ;
ALTER TABLE t2 ADD PARTITION PARTITIONS 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ALTER TABLE t2 ADD PARTITION PARTITIONS 2;
UNLOCK TABLES;
CHECK TABLE t2;
Table Op Msg_type Msg_text
test.t2 check status OK
SELECT * FROM t2;
i f
DROP TABLE t2;
CREATE TABLE t3 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;
SET lock_wait_timeout = 2;
# Connection 1 locks the table
LOCK TABLE t3 READ;
# Connection 2 tries to add partitions (timeout):
ALTER TABLE t3 ADD PARTITION PARTITIONS 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
SET lock_wait_timeout = 2;
# Connection 3 tries to add partitions (partition already exists):
ALTER TABLE t3 ADD PARTITION PARTITIONS 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
# Connection 4 tries to rename the table:
RENAME TABLE t3 TO t4;
# Connection 1 unlocks the table:
UNLOCK TABLES;
# Connection 4 gets error on rename:
# SHOW TABLES returns the table (not renamed):
SHOW TABLES;
Tables_in_test
t4
# Connection 5 attempts to read from the table (table does not exist):
SELECT * FROM t3;
ERROR 42S02: Table 'test.t3' doesn't exist
DROP TABLE t4;

View File

@@ -200,3 +200,22 @@ a b c d e f g h a1 b1 c1 d1 e1 f1 g1 h1 a2 b2 c2 d2 e2 f2 g2 h2 a3 b3 c3 d3 e3 f
1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 1983-12-31 cdef srtbvsr w 45634 13452.56 3452346456 127 liuugbzvdmrlti b itiortudirtfgtibm dfi
1975-01-01 abcde abcde m 1234 123.45 32412341234 113 1975-01-01 abcde abcde m 1234 123.45 32412341234 113 1975-01-01 abcde abcde m 1234 123.45 32412341234 113 1975-01-01 abcde abcde m 1234 123.45 32412341234 113 tbhth nrzh ztfghgfh fzh ftzhj fztjh
drop table t1;
#
# Bug#53770: Server crash at handler.cc:2076 on LOAD DATA
# after timed out COALESCE PARTITION
CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = MyISAM PARTITION BY HASH(i) PARTITIONS 3;
# Connection 1 starts transaction and gets lock
START TRANSACTION;
SELECT * FROM t1;
i f
SET lock_wait_timeout = 2;
# Connection 2 tries to coalesce partitions (timeout):
ALTER TABLE t1 COALESCE PARTITION 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
# Connection 3 tries to load into the table:
LOAD DATA LOCAL INFILE '/tmp/load.in' INTO TABLE t1 (f);
# Connection 1 commits the transaction
COMMIT;
# Connection 3...
DROP TABLE t1;

View File

@@ -0,0 +1 @@
--innodb-file-format-check --innodb-file-per-table=1 --skip-stack-trace --skip-core-file

View File

@@ -0,0 +1,26 @@
# Partitioning test that require debug features
# including crashing tests.
--source include/have_debug.inc
--source include/have_innodb.inc
--source include/have_partition.inc
--source include/not_valgrind.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $DATADIR= `SELECT @@datadir;`
# 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
# operation is completed, mysql will try to drop a not yet created partition
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 ");
let $engine= 'InnoDB';
--echo # Test crash and failure recovery in fast_alter_partition_table.
--source suite/parts/inc/partition_mgm_crash.inc

View File

@@ -0,0 +1 @@
--skip-stack-trace --skip-core-file

View File

@@ -0,0 +1,17 @@
# Partitioning test that require debug features
# including crashing tests.
--source include/have_debug.inc
--source include/have_partition.inc
--source include/not_valgrind.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--let $DATADIR= `SELECT @@datadir;`
let $engine= 'MyISAM';
--echo # Test crash and failure recovery in fast_alter_partition_table.
--source suite/parts/inc/partition_mgm_crash.inc

View File

@@ -1 +1 @@
--innodb_lock_wait_timeout=2
--innodb_lock_wait_timeout=2 --innodb-file-per-table=1

View File

@@ -76,3 +76,132 @@ ALTER TABLE t1 AUTO_INCREMENT = 10;
--disconnect con1
--connection default
DROP TABLE t1;
--echo #
--echo # Bug#53676: Unexpected errors and possible table corruption on
--echo # ADD PARTITION and LOCK TABLE
--connect (con1,localhost,root,,)
CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;
--connect (con2,localhost,root,,)
SET lock_wait_timeout = 2;
--connection con1
--echo #Connection 1 locks the table
LOCK TABLE t1 READ;
--connection con2
--echo # Connection 2 tries to add partitions:
--echo # First attempt: lock wait timeout (as expected)
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
--echo # Second attempt: says that partition already exists
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
--connection con1
--echo # Connection 1 unlocks the table and locks it again:
UNLOCK TABLES;
--real_sleep 1
LOCK TABLE t1 READ;
--connection con2
--echo # Connection 2 tries again to add partitions:
--echo # Third attempt: says that the table does not exist
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
--echo # Check table returns the same
CHECK TABLE t1;
--connection con1
UNLOCK TABLES;
--connection con2
DROP TABLE t1;
# End of Test1
# Test2
--connection con1
CREATE TABLE t2 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;
--connection con2
SET lock_wait_timeout = 2;
--connection con1
LOCK TABLE t2 READ;
--connection con2
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t2 ADD PARTITION PARTITIONS 2;
send ALTER TABLE t2 ADD PARTITION PARTITIONS 2;
--connection con1
UNLOCK TABLES;
--connection con2
--reap
--connect (con3,localhost,root,,)
CHECK TABLE t2;
SELECT * FROM t2;
DROP TABLE t2;
# End of Test2
# Test #3
--connection con1
CREATE TABLE t3 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;
--connection con2
SET lock_wait_timeout = 2;
--connection con1
--echo # Connection 1 locks the table
LOCK TABLE t3 READ;
--connection con2
--echo # Connection 2 tries to add partitions (timeout):
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t3 ADD PARTITION PARTITIONS 2;
--connection con3
SET lock_wait_timeout = 2;
--echo # Connection 3 tries to add partitions (partition already exists):
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t3 ADD PARTITION PARTITIONS 2;
--connect (con4,localhost,root,,)
--echo # Connection 4 tries to rename the table:
send RENAME TABLE t3 TO t4;
--connection con1
--real_sleep 1
--echo # Connection 1 unlocks the table:
UNLOCK TABLES;
--connection con4
--echo # Connection 4 gets error on rename:
--reap
--connect (con5,localhost,root,,)
--echo # SHOW TABLES returns the table (not renamed):
SHOW TABLES;
--echo # Connection 5 attempts to read from the table (table does not exist):
--error ER_NO_SUCH_TABLE
SELECT * FROM t3;
DROP TABLE t4;
--disconnect con5
--disconnect con4
--disconnect con3
--disconnect con2
--disconnect con1
--connection default
# End of Test #3

View File

@@ -43,3 +43,43 @@ let $engine= 'MyISAM';
--source suite/parts/inc/partition_key_8col.inc
--source suite/parts/inc/partition_key_16col.inc
--source suite/parts/inc/partition_key_32col.inc
--echo #
--echo # Bug#53770: Server crash at handler.cc:2076 on LOAD DATA
--echo # after timed out COALESCE PARTITION
CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
ENGINE = MyISAM PARTITION BY HASH(i) PARTITIONS 3;
--echo # Connection 1 starts transaction and gets lock
START TRANSACTION;
SELECT * FROM t1;
--connect (con2,localhost,root,,)
SET lock_wait_timeout = 2;
--echo # Connection 2 tries to coalesce partitions (timeout):
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 COALESCE PARTITION 2;
--connect (con3,localhost,root,,)
perl;
open( LD, ">" . "/tmp/load.in" ) || die "Could not open file for writing " . $ENV{'MYSQLTEST_DATADIR'} . "/test/load.in";
print LD "1\n2\n3\n";
close( LD );
EOF
--echo # Connection 3 tries to load into the table:
send LOAD DATA LOCAL INFILE '/tmp/load.in' INTO TABLE t1 (f);
--connection default
--real_sleep 1
--echo # Connection 1 commits the transaction
COMMIT;
--connection con3
--echo # Connection 3...
--reap
DROP TABLE t1;
--disconnect con3
--disconnect con2
--connection default

View File

@@ -8,6 +8,50 @@ drop table if exists t1, t2;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
--echo # Bug#50418: DROP PARTITION does not interact with transactions
--echo #
CREATE TABLE t1 (
id INT AUTO_INCREMENT NOT NULL,
name CHAR(50) NOT NULL,
myDate DATE NOT NULL,
PRIMARY KEY (id, myDate),
INDEX idx_date (myDate)
) ENGINE=InnoDB
PARTITION BY RANGE ( TO_DAYS(myDate) ) (
PARTITION p0 VALUES LESS THAN (734028),
PARTITION p1 VALUES LESS THAN (734029),
PARTITION p2 VALUES LESS THAN (734030),
PARTITION p3 VALUES LESS THAN MAXVALUE
) ;
INSERT INTO t1 VALUES
(NULL, 'Lachlan', '2009-09-13'),
(NULL, 'Clint', '2009-09-13'),
(NULL, 'John', '2009-09-14'),
(NULL, 'Dave', '2009-09-14'),
(NULL, 'Jeremy', '2009-09-15'),
(NULL, 'Scott', '2009-09-15'),
(NULL, 'Jeff', '2009-09-16'),
(NULL, 'Joe', '2009-09-16');
SET AUTOCOMMIT=0;
SELECT * FROM t1 FOR UPDATE;
UPDATE t1 SET name = 'Mattias' WHERE id = 7;
SELECT * FROM t1 WHERE id = 7;
--connect (con1, localhost, root,,)
--echo # Connection con1
SET lock_wait_timeout = 1;
--echo # After the patch it will wait and fail on timeout.
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 DROP PARTITION p3;
SHOW WARNINGS;
--disconnect con1
--connection default
--echo # Connection default
SELECT * FROM t1;
--echo # No changes.
COMMIT;
DROP TABLE t1;
--echo #
--echo # Bug#51830: Incorrect partition pruning on range partition (regression)
--echo #