diff options
author | Georgi Kodinov <joro@sun.com> | 2009-09-29 10:34:37 +0300 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2009-09-29 10:34:37 +0300 |
commit | e004e266245a57033cfad5a589fa882fdb8d3b50 (patch) | |
tree | c8c55d86bcb3e2fc15ef222f2bbcdf564f023dbf /mysql-test | |
parent | 2118bd104c4dd7c2aab0b80fa7053d8a491a90c4 (diff) | |
parent | ccae404afaddf98c16889fdd21c613b551ee5e5e (diff) | |
download | mariadb-git-e004e266245a57033cfad5a589fa882fdb8d3b50.tar.gz |
merge mysql-trunk-wl4444_4571 to mysql-wl3220-next-mr
Diffstat (limited to 'mysql-test')
26 files changed, 1724 insertions, 0 deletions
diff --git a/mysql-test/r/partition_truncate.result b/mysql-test/r/partition_truncate.result new file mode 100644 index 00000000000..8f594a319df --- /dev/null +++ b/mysql-test/r/partition_truncate.result @@ -0,0 +1,18 @@ +drop table if exists t1, t2, t3, t4; +create table t1 (a int) +partition by list (a) +(partition p1 values in (0)); +alter table t1 truncate partition p1,p1; +ERROR HY000: Incorrect partition name +alter table t1 truncate partition p0; +ERROR HY000: Incorrect partition name +drop table t1; +create table t1 (a int) +partition by list (a) +subpartition by hash (a) +subpartitions 1 +(partition p1 values in (1) +(subpartition sp1)); +alter table t1 truncate partition sp1; +ERROR HY000: Incorrect partition name +drop table t1; diff --git a/mysql-test/suite/large_tests/r/lock_tables_big.result b/mysql-test/suite/large_tests/r/lock_tables_big.result new file mode 100644 index 00000000000..de639143055 --- /dev/null +++ b/mysql-test/suite/large_tests/r/lock_tables_big.result @@ -0,0 +1 @@ +all done diff --git a/mysql-test/suite/large_tests/t/lock_tables_big.test b/mysql-test/suite/large_tests/t/lock_tables_big.test new file mode 100644 index 00000000000..41dcff3577c --- /dev/null +++ b/mysql-test/suite/large_tests/t/lock_tables_big.test @@ -0,0 +1,32 @@ +# +# Bug#24509 cannot use more than 2048 file descriptors on windows +# +--disable_query_log +create database many_tables; +use many_tables; +let $max_tables=3000; +let $i=$max_tables; + +--disable_warnings +create table t (i int); +let $table_list=t READ; + +while ($i) +{ + eval create table t$i (i int); + let $table_list= $table_list ,t$i READ; + dec $i; +} + +#lock all tables we just created (resembles mysqldump startup is doing with --all-databases operation) +#There will be 3 descriptors for each table (table.FRM, table.MYI and table.MYD files) means 9000 files +#descriptors altogether. For Microsoft C runtime, this is way too many. + +eval LOCK TABLES $table_list; +unlock tables; + +drop database many_tables; +--disable_query_log +--echo all done + + diff --git a/mysql-test/suite/parts/inc/partition_mgm.inc b/mysql-test/suite/parts/inc/partition_mgm.inc index 1ab548222a8..9dfa2b2ffb3 100644 --- a/mysql-test/suite/parts/inc/partition_mgm.inc +++ b/mysql-test/suite/parts/inc/partition_mgm.inc @@ -13,6 +13,7 @@ # part_optA-D Extra partitioning options (E.g. INDEX/DATA DIR) # # # # have_bug33158 NDB case insensitive create, but case sensitive rename # +# no_truncate No support for truncate partition # #------------------------------------------------------------------------------# # Original Author: mattiasj # # Original Date: 2008-06-27 # @@ -518,6 +519,95 @@ DROP TABLE TableA; } # End of $can_only_key +if ($no_truncate) +{ +--echo # Verify that TRUNCATE PARTITION gives error +eval CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, + b VARCHAR(255)) +ENGINE = $engine +PARTITION BY KEY (a) +(PARTITION LT1000, + PARTITION LT2000, + PARTITION MAX); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +--error ER_PARTITION_MGMT_ON_NONPARTITIONED, ER_ILLEGAL_HA +ALTER TABLE t1 TRUNCATE PARTITION MAX; +} +if (!$no_truncate) +{ +--echo # Testing TRUNCATE PARTITION +eval CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, + b VARCHAR(255)) +ENGINE = $engine +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), + PARTITION LT2000 VALUES LESS THAN (2000), + PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +SELECT * FROM t1 ORDER BY a; +ALTER TABLE t1 ANALYZE PARTITION MAX; +--echo # Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +--echo # Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +--echo # Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +--echo # Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +--echo # Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +--echo # Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +--echo # Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +--echo # Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +--echo # Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +--echo # Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +--echo # Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +--echo # Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +DROP TABLE t1; +} --echo # Cleaning up before exit eval USE $old_db; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result index 30ff27df298..4f623813386 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_archive.result @@ -915,6 +915,18 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Verify that TRUNCATE PARTITION gives error +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'Archive' +PARTITION BY KEY (a) +(PARTITION LT1000, +PARTITION LT2000, +PARTITION MAX); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +ALTER TABLE t1 TRUNCATE PARTITION MAX; +Got one of the listed errors # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result index cd55ffbad03..19f16780d13 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result @@ -915,6 +915,170 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'InnoDB' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = InnoDB, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = InnoDB, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +MySQL_Test_DB.t1 analyze status OK +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result index faf776e03a3..69a43b64d87 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result @@ -915,6 +915,170 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=MEMORY DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'Memory' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=MEMORY AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = MEMORY, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = MEMORY, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +MySQL_Test_DB.t1 analyze note The storage engine for the table doesn't support analyze +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result index 827f7a15c24..9b4e85be9d0 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result @@ -915,6 +915,170 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'MyISAM' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = MyISAM, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = MyISAM, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +MySQL_Test_DB.t1 analyze status OK +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result b/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result index 45b674638e7..15b3f424527 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_ndb.result @@ -181,6 +181,18 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 # Cleaning up after KEY PARTITIONING test DROP TABLE TableA; +# Verify that TRUNCATE PARTITION gives error +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'NDBCluster' +PARTITION BY KEY (a) +(PARTITION LT1000, +PARTITION LT2000, +PARTITION MAX); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +ALTER TABLE t1 TRUNCATE PARTITION MAX; +Got one of the listed errors # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result index 443453a2d70..4cd8cafa3ee 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_archive.result @@ -882,6 +882,18 @@ TableA CREATE TABLE `tablea` ( ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Verify that TRUNCATE PARTITION gives error +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'Archive' +PARTITION BY KEY (a) +(PARTITION LT1000, +PARTITION LT2000, +PARTITION MAX); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +ALTER TABLE t1 TRUNCATE PARTITION MAX; +Got one of the listed errors # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result index 49ccc7b1808..952f4136cb6 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result @@ -882,6 +882,170 @@ TableA CREATE TABLE `tablea` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'InnoDB' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = InnoDB, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = InnoDB, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +mysql_test_db.t1 analyze status OK +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result index 6f34054428c..435a0d8313e 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result @@ -882,6 +882,170 @@ TableA CREATE TABLE `tablea` ( ) ENGINE=MEMORY DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'Memory' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=MEMORY AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = MEMORY, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = MEMORY, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +mysql_test_db.t1 analyze note The storage engine for the table doesn't support analyze +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result index ac230e29c66..3a90ce4d73c 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result @@ -882,6 +882,170 @@ TableA CREATE TABLE `tablea` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'MyISAM' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = MyISAM, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = MyISAM, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +mysql_test_db.t1 analyze status OK +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result b/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result index 0a53e1b4a9b..1d221caa163 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_ndb.result @@ -219,6 +219,18 @@ TableA CREATE TABLE `tablea` ( ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 # Cleaning up after KEY PARTITIONING test DROP TABLE TableA; +# Verify that TRUNCATE PARTITION gives error +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'NDBCluster' +PARTITION BY KEY (a) +(PARTITION LT1000, +PARTITION LT2000, +PARTITION MAX); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +ALTER TABLE t1 TRUNCATE PARTITION MAX; +Got one of the listed errors # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result index fc0390c238d..6e8abfef06d 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_archive.result @@ -882,6 +882,18 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Verify that TRUNCATE PARTITION gives error +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'Archive' +PARTITION BY KEY (a) +(PARTITION LT1000, +PARTITION LT2000, +PARTITION MAX); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +ALTER TABLE t1 TRUNCATE PARTITION MAX; +Got one of the listed errors # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result index da111137068..8e42bc9eb62 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_innodb.result @@ -882,6 +882,170 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'InnoDB' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=InnoDB AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = InnoDB, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = InnoDB, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +mysql_test_db.t1 analyze status OK +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result index a1716ea36c8..24047912ab1 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_memory.result @@ -882,6 +882,170 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=MEMORY DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'Memory' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=MEMORY AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = MEMORY, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = MEMORY, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +mysql_test_db.t1 analyze note The storage engine for the table doesn't support analyze +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result index 6bdfa149de0..7a61a811ea3 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_myisam.result @@ -882,6 +882,170 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 # Cleaning up after LIST PARTITIONING test DROP TABLE TableA; +# Testing TRUNCATE PARTITION +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'MyISAM' +PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000), +PARTITION LT2000 VALUES LESS THAN (2000), +PARTITION MAX VALUES LESS THAN MAXVALUE); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(20) NOT NULL AUTO_INCREMENT, + `b` varchar(255) DEFAULT NULL, + PRIMARY KEY (`a`) +) ENGINE=MyISAM AUTO_INCREMENT=2002 DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY RANGE (a) +(PARTITION LT1000 VALUES LESS THAN (1000) ENGINE = MyISAM, + PARTITION LT2000 VALUES LESS THAN (2000) ENGINE = MyISAM, + PARTITION MAX VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ +SELECT * FROM t1 ORDER BY a; +a b +1 First +2 Second +999 Last in LT1000 +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First in MAX +2001 Second in MAX +ALTER TABLE t1 ANALYZE PARTITION MAX; +Table Op Msg_type Msg_text +mysql_test_db.t1 analyze status OK +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (1)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION MAX; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (2)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (3)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION MAX; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE MAX (4)"); +SELECT * FROM t1 WHERE a >= 2000; +a b +2000 First after TRUNCATE MAX (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT1000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT1000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +1000 First in LT2000 +1001 Second in LT2000 +1999 Last in LT2000 +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +# Truncate without FLUSH +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (1)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +# Truncate with FLUSH after +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +FLUSH TABLES; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (2)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +# Truncate with FLUSH before +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (3)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +# Truncate with FLUSH after INSERT +FLUSH TABLES; +ALTER TABLE t1 TRUNCATE PARTITION LT2000; +INSERT INTO t1 VALUES (NULL, "First after TRUNCATE LT2000 (4)"); +SELECT * FROM t1 ORDER BY a; +a b +2000 First after TRUNCATE MAX (4) +2001 First after TRUNCATE LT1000 (1) +2002 First after TRUNCATE LT1000 (2) +2003 First after TRUNCATE LT1000 (3) +2004 First after TRUNCATE LT1000 (4) +2005 First after TRUNCATE LT2000 (1) +2006 First after TRUNCATE LT2000 (2) +2007 First after TRUNCATE LT2000 (3) +2008 First after TRUNCATE LT2000 (4) +DROP TABLE t1; # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result b/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result index 8b9c5be1fb6..2f5dfe5e08e 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc2_ndb.result @@ -219,6 +219,18 @@ TableA CREATE TABLE `TableA` ( ) ENGINE=ndbcluster DEFAULT CHARSET=latin1 # Cleaning up after KEY PARTITIONING test DROP TABLE TableA; +# Verify that TRUNCATE PARTITION gives error +CREATE TABLE t1 +(a BIGINT AUTO_INCREMENT PRIMARY KEY, +b VARCHAR(255)) +ENGINE = 'NDBCluster' +PARTITION BY KEY (a) +(PARTITION LT1000, +PARTITION LT2000, +PARTITION MAX); +INSERT INTO t1 VALUES (NULL, "First"), (NULL, "Second"), (999, "Last in LT1000"), (NULL, "First in LT2000"), (NULL, "Second in LT2000"), (1999, "Last in LT2000"), (NULL, "First in MAX"), (NULL, "Second in MAX"); +ALTER TABLE t1 TRUNCATE PARTITION MAX; +Got one of the listed errors # Cleaning up before exit USE test; DROP DATABASE MySQL_Test_DB; diff --git a/mysql-test/suite/parts/t/partition_mgm_lc0_archive.test b/mysql-test/suite/parts/t/partition_mgm_lc0_archive.test index 5b4f2568d46..313da329a9f 100644 --- a/mysql-test/suite/parts/t/partition_mgm_lc0_archive.test +++ b/mysql-test/suite/parts/t/partition_mgm_lc0_archive.test @@ -35,6 +35,7 @@ ##### Storage engine to be tested --source include/have_archive.inc let $engine= 'Archive'; +let $no_truncate= 1; #------------------------------------------------------------------------------# # Execute the tests to be applied to all storage engines diff --git a/mysql-test/suite/parts/t/partition_mgm_lc0_ndb.test b/mysql-test/suite/parts/t/partition_mgm_lc0_ndb.test index 686c69cca25..736e45067bc 100644 --- a/mysql-test/suite/parts/t/partition_mgm_lc0_ndb.test +++ b/mysql-test/suite/parts/t/partition_mgm_lc0_ndb.test @@ -41,6 +41,8 @@ let $can_only_key= 1; # Allow hash/list/range partitioning with ndb #SET new=on; let $engine= 'NDBCluster'; +# NDB does not yet support TRUNCATE PARTITION +let $no_truncate= 1; #------------------------------------------------------------------------------# # Execute the tests to be applied to all storage engines diff --git a/mysql-test/suite/parts/t/partition_mgm_lc1_archive.test b/mysql-test/suite/parts/t/partition_mgm_lc1_archive.test index 2bc643db75f..58eef828f06 100644 --- a/mysql-test/suite/parts/t/partition_mgm_lc1_archive.test +++ b/mysql-test/suite/parts/t/partition_mgm_lc1_archive.test @@ -32,6 +32,7 @@ ##### Storage engine to be tested --source include/have_archive.inc let $engine= 'Archive'; +let $no_truncate= 1; #------------------------------------------------------------------------------# # Execute the tests to be applied to all storage engines diff --git a/mysql-test/suite/parts/t/partition_mgm_lc1_ndb.test b/mysql-test/suite/parts/t/partition_mgm_lc1_ndb.test index a70b9b5c41c..ac425eb84ff 100644 --- a/mysql-test/suite/parts/t/partition_mgm_lc1_ndb.test +++ b/mysql-test/suite/parts/t/partition_mgm_lc1_ndb.test @@ -38,6 +38,8 @@ let $can_only_key= 1; # Allow hash/list/range partitioning with ndb #SET new=on; let $engine= 'NDBCluster'; +# NDB does not yet support TRUNCATE PARTITION +let $no_truncate= 1; #------------------------------------------------------------------------------# # Execute the tests to be applied to all storage engines diff --git a/mysql-test/suite/parts/t/partition_mgm_lc2_archive.test b/mysql-test/suite/parts/t/partition_mgm_lc2_archive.test index d0e2591804d..92036178e59 100644 --- a/mysql-test/suite/parts/t/partition_mgm_lc2_archive.test +++ b/mysql-test/suite/parts/t/partition_mgm_lc2_archive.test @@ -32,6 +32,7 @@ ##### Storage engine to be tested --source include/have_archive.inc let $engine= 'Archive'; +let $no_truncate= 1; #------------------------------------------------------------------------------# # Execute the tests to be applied to all storage engines diff --git a/mysql-test/suite/parts/t/partition_mgm_lc2_ndb.test b/mysql-test/suite/parts/t/partition_mgm_lc2_ndb.test index 67fdfdde70b..725ba3b5e74 100644 --- a/mysql-test/suite/parts/t/partition_mgm_lc2_ndb.test +++ b/mysql-test/suite/parts/t/partition_mgm_lc2_ndb.test @@ -37,6 +37,8 @@ let $can_only_key= 1; # Allow hash/list/range partitioning with ndb #SET new=on; let $engine= 'NDBCluster'; +# NDB does not yet support TRUNCATE PARTITION +let $no_truncate= 1; #------------------------------------------------------------------------------# # Execute the tests to be applied to all storage engines diff --git a/mysql-test/t/partition_truncate.test b/mysql-test/t/partition_truncate.test new file mode 100644 index 00000000000..93b9cf62d14 --- /dev/null +++ b/mysql-test/t/partition_truncate.test @@ -0,0 +1,26 @@ +# +# Simple tests to verify truncate partition syntax +# +--source include/have_partition.inc +--disable_warnings +drop table if exists t1, t2, t3, t4; +--enable_warnings + +create table t1 (a int) +partition by list (a) +(partition p1 values in (0)); +--error ER_WRONG_PARTITION_NAME +alter table t1 truncate partition p1,p1; +--error ER_WRONG_PARTITION_NAME +alter table t1 truncate partition p0; +drop table t1; + +create table t1 (a int) +partition by list (a) +subpartition by hash (a) +subpartitions 1 +(partition p1 values in (1) + (subpartition sp1)); +--error ER_WRONG_PARTITION_NAME +alter table t1 truncate partition sp1; +drop table t1; |