1
0
mirror of https://github.com/MariaDB/server.git synced 2025-10-24 07:13:33 +03:00

WL#4444 Added TRUNCATE partition support, fixes bug#19405 and bug #35111

This commit is contained in:
Mikael Ronstrom
2009-09-10 11:15:39 +02:00
parent 905d715f10
commit d0d52e9f11
32 changed files with 1810 additions and 11 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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