2007-02-06 13:35:54 +01:00
|
|
|
################################################################################
|
2008-08-20 17:29:14 +02:00
|
|
|
# t/partition_special_innodb.test #
|
2007-02-06 13:35:54 +01:00
|
|
|
# #
|
|
|
|
# Purpose: #
|
|
|
|
# different Tests #
|
|
|
|
# InnoDB branch #
|
|
|
|
# #
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# Original Author: HH #
|
|
|
|
# Original Date: 2006-08-01 #
|
2008-08-20 17:29:14 +02:00
|
|
|
# Change Author: MattiasJ #
|
|
|
|
# Change Date: 2008-08-20 #
|
|
|
|
# Change: added test for bug#34604 #
|
2007-02-06 13:35:54 +01:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
|
|
|
|
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
|
|
|
|
# THE SOURCED FILES ONLY.
|
|
|
|
#
|
2007-11-20 16:04:07 +01:00
|
|
|
# Please read the README at the end of inc/partition.pre before changing
|
2007-02-06 13:35:54 +01:00
|
|
|
# any of the variables.
|
|
|
|
#
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# General not engine specific settings and requirements
|
|
|
|
|
|
|
|
##### Options, for debugging support #####
|
|
|
|
let $debug= 0;
|
|
|
|
|
|
|
|
# The server must support partitioning.
|
|
|
|
--source include/have_partition.inc
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# Engine specific settings and requirements
|
|
|
|
|
|
|
|
##### Storage engine to be tested
|
2007-08-27 14:12:12 -06:00
|
|
|
--source include/have_innodb.inc
|
2007-11-20 16:04:07 +01:00
|
|
|
let $engine= 'InnoDB';
|
2007-02-06 13:35:54 +01:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# Execute the tests to be applied to all storage engines
|
2007-04-30 16:24:13 +02:00
|
|
|
--source suite/parts/inc/partition_key_4col.inc
|
|
|
|
--source suite/parts/inc/partition_key_8col.inc
|
|
|
|
--source suite/parts/inc/partition_key_16col.inc
|
|
|
|
--source suite/parts/inc/partition_key_32col.inc
|
2008-08-20 17:29:14 +02:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# Execute storage engine specific tests
|
|
|
|
|
|
|
|
--echo # Bug#34604 - Assertion 'inited==RND' failed in handler::ha_rnd_end
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
a INT AUTO_INCREMENT,
|
|
|
|
b VARCHAR(255),
|
|
|
|
PRIMARY KEY (a))
|
|
|
|
ENGINE = InnoDB
|
|
|
|
PARTITION BY HASH (a)
|
|
|
|
PARTITIONS 2;
|
|
|
|
|
2011-01-18 23:55:39 +01:00
|
|
|
connect (con1, localhost, root,,);
|
|
|
|
connect (con2, localhost, root,,);
|
2008-08-20 17:29:14 +02:00
|
|
|
|
|
|
|
--connection con1
|
|
|
|
SET autocommit=OFF;
|
|
|
|
START TRANSACTION;
|
|
|
|
INSERT INTO t1 VALUES (NULL, 'first row t2');
|
|
|
|
|
|
|
|
--connection con2
|
|
|
|
SET autocommit=OFF;
|
2010-02-11 12:59:12 +01:00
|
|
|
SET SESSION lock_wait_timeout= 1;
|
2008-12-04 10:47:25 +01:00
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
2008-08-20 17:29:14 +02:00
|
|
|
ALTER TABLE t1 AUTO_INCREMENT = 10;
|
|
|
|
|
|
|
|
--disconnect con2
|
|
|
|
--disconnect con1
|
|
|
|
--connection default
|
|
|
|
DROP TABLE t1;
|
2010-08-13 09:50:25 +02:00
|
|
|
|
|
|
|
--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;
|
2020-03-30 14:46:44 +03:00
|
|
|
INSERT INTO t1 VALUES (2, 2), (3, 3), (4, 4), (5, 5);
|
2010-08-13 09:50:25 +02:00
|
|
|
|
|
|
|
--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;
|
2020-03-30 14:46:44 +03:00
|
|
|
--echo # Check that we only can select, not insert/update/delete.
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
INSERT INTO t1 VALUES (NULL, 6), (NULL, 7), (10, 10), (11, 11);
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
UPDATE t1 SET i = 5 WHERE f = 2;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
DELETE FROM t1 WHERE i = 10;
|
|
|
|
--sorted_result
|
|
|
|
SELECT * FROM t1;
|
2010-08-13 09:50:25 +02:00
|
|
|
|
|
|
|
--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;
|
Bug#56172: Server crashes in ha_partition::reset on
REBUILD PARTITION under LOCK TABLE
Collapsed patch including updates from the reviews.
In case of failure in ALTER ... PARTITION under LOCK TABLE
the server could crash, due to it had modified the locked
table object, which was not reverted in case of failure,
resulting in a bad table definition used after the failed
command.
Solved by instead of altering the locked table object and
its partition_info struct, creating an internal temporary
intermediate table object used for altering,
just like the non partitioned mysql_alter_table.
So if an error occur before the alter operation is complete,
the original table is not modified at all.
But if the alter operation have succeeded so far that it
must be completed as whole,
the table is properly closed and reopened.
(The completion on failure is done by the ddl_log.)
mysql-test/suite/parts/inc/partition_fail.inc:
Added tests under LOCK TABLE
mysql-test/suite/parts/r/partition_debug_innodb.result:
Updated results
mysql-test/suite/parts/r/partition_debug_myisam.result:
Updated results
mysql-test/suite/parts/r/partition_special_innodb.result:
updated result
mysql-test/suite/parts/t/partition_special_innodb.test:
changing comment, since this patch also fixes this.
sql/sql_partition.cc:
Added TODO, to use DBUG_SUICIDE() instead of abort()
to avoid core-files on expected crashes.
Removed unused arguments to fast_end_partition.
Opening a intermediate table in prep_alter_part_table, instead of altering
(a possible locked) normally opened table.
That way we do not have to do anything more than close
the intermediate table on error,
leaving the ordinary table opened and locked.
Also making sure that the intermediate table are
closed/destroyed on failure. If no error occur
it is later destroyed in the end of fast_alter_partition_table.
Added ha_external_lock to make sure MyISAM flushed the index file
after copying the partitions.
This also leads to removal of the special close and removal from
the table cache for other instances of the table.
sql/sql_partition.h:
Changed the arguments for prep_alter_part_table and
fast_alter_partition_table to use an intermediate table
instead of altering a (possibly locked) normal table.
sql/sql_table.cc:
Using an intermediate table created in prep_alter_part_table
to be used in fast_alter_partition_table, also closing/destroying
it on failure.
2010-10-01 13:22:11 +02:00
|
|
|
--echo # Check table returns the same (not after fixing bug#56172!)
|
2010-08-13 09:50:25 +02:00
|
|
|
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
|
2020-02-28 14:29:05 +05:30
|
|
|
|
|
|
|
# MDEV-21693 ALGORITHM=INSTANT does not work for partitioned tables
|
|
|
|
CREATE TABLE t1(
|
|
|
|
f1 INT, f2 VARCHAR(10) CHARSET ascii,
|
|
|
|
f3 CHAR(150) CHARSET ascii,
|
|
|
|
f4 TEXT CHARSET ascii)ENGINE=InnoDB
|
|
|
|
PARTITION BY RANGE(f1) (PARTITION p1 VALUES LESS THAN(10),
|
|
|
|
PARTITION p2 VALUES LESS THAN (100));
|
|
|
|
ALTER TABLE t1 convert to charset ascii collate ascii_bin, ALGORITHM=INSTANT;
|
|
|
|
DROP TABLE t1;
|
2020-03-30 14:46:44 +03:00
|
|
|
|
|
|
|
--echo # Test WRITE LOCK.
|
|
|
|
--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;
|
|
|
|
INSERT INTO t1 VALUES (3, 3), (4, 4);
|
|
|
|
|
|
|
|
--connect (con2,localhost,root,,)
|
|
|
|
SET lock_wait_timeout = 2;
|
|
|
|
|
|
|
|
--connection con1
|
|
|
|
--echo #Connection 1 locks the table
|
|
|
|
LOCK TABLE t1 WRITE;
|
|
|
|
|
|
|
|
--connection con2
|
|
|
|
--echo # Check that we still can SELECT, but not insert/update/delete.
|
|
|
|
--echo # Check that we only can select, not insert/update/delete.
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
INSERT INTO t1 VALUES (NULL, 1), (NULL, 2), (10, 10), (11, 11);
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
UPDATE t1 SET i = 5 WHERE f = 2;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
DELETE FROM t1 WHERE i = 10;
|
|
|
|
--error ER_LOCK_WAIT_TIMEOUT
|
|
|
|
SELECT * FROM t1;
|
|
|
|
|
|
|
|
--connection con1
|
|
|
|
UNLOCK TABLES;
|
|
|
|
|
|
|
|
--connection con2
|
|
|
|
DROP TABLE t1;
|
|
|
|
|
|
|
|
--disconnect con1
|
|
|
|
--connection default
|