Commit 8d0d9e87 authored by Mattias Jonsson's avatar Mattias Jonsson

manual merge of bug#37402

parents 2ae9924a 4454c9cd
--require r/case_insensitive_file_system.require
--disable_query_log
show variables like "lower_case_file_system";
--enable_query_log
--require r/lowercase0.require --require r/lowercase0.require
--disable_query_log --disable_query_log
show variables like 'lower_case_%'; show variables like "lower_case_table_names";
--enable_query_log --enable_query_log
--require r/lowercase2.require
--disable_query_log
show variables like 'lower_case_table_names';
--enable_query_log
...@@ -327,7 +327,6 @@ sub mtr_report_stats ($) { ...@@ -327,7 +327,6 @@ sub mtr_report_stats ($) {
/Sort aborted/ or /Sort aborted/ or
/Time-out in NDB/ or /Time-out in NDB/ or
/One can only use the --user.*root/ or /One can only use the --user.*root/ or
/Setting lower_case_table_names=2/ or
/Table:.* on (delete|rename)/ or /Table:.* on (delete|rename)/ or
/You have an error in your SQL syntax/ or /You have an error in your SQL syntax/ or
/deprecated/ or /deprecated/ or
...@@ -405,7 +404,15 @@ sub mtr_report_stats ($) { ...@@ -405,7 +404,15 @@ sub mtr_report_stats ($) {
/Out of sort memory; increase server sort buffer size/ or /Out of sort memory; increase server sort buffer size/ or
# Bug#35161, test of auto repair --myisam-recover # Bug#35161, test of auto repair --myisam-recover
/able.*_will_crash/ /able.*_will_crash/ or
# lowercase_table3 using case sensitive option on
# case insensitive filesystem (InnoDB error).
/Cannot find or open table test\/BUG29839 from/ or
# When trying to set lower_case_table_names = 2
# on a case sensitive file system. Bug#37402.
/lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive. Now setting lower_case_table_names to 0 to avoid future problems./
) )
{ {
next; # Skip these lines next; # Skip these lines
......
Variable_name Value
lower_case_file_system ON
Variable_name Value Variable_name Value
lower_case_file_system ON
lower_case_table_names 0 lower_case_table_names 0
################################################################################
# inc/partition_mgm.inc #
# #
# Purpose: #
# Test of partition management functions including different Upper/Lower #
# case names of databases, tables and partitions #
# #
# #
# Uses following variables: #
# engine Use specified storage engine #
# can_only_key Storage engine only able to use HASH/KEY (not range/list) #
# (E.g. not ndbcluster) #
# part_optA-D Extra partitioning options (E.g. INDEX/DATA DIR) #
# #
# have_bug33158 NDB case insensitive create, but case sensitive rename #
# have_bug37719 Archive, crash when rename and then select #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
--enable_abort_on_error
let $old_db= `SELECT DATABASE()`;
--echo # Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
--echo # 1.0 KEY partitioning mgm
--echo # Creating KEY partitioned table
eval CREATE TABLE TableA (a INT)
ENGINE = $engine
PARTITION BY KEY (a)
(PARTITION parta $part_optA,
PARTITION partB $part_optB,
PARTITION Partc $part_optC,
PARTITION PartD $part_optD);
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
--sorted_result
SELECT * FROM TableA;
--echo # Test of ADD/COALESCE PARTITIONS
--echo # expecting duplicate partition name
--error ER_SAME_NAME_PARTITION
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
ALTER TABLE TableA COALESCE PARTITION 4;
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of REORGANIZE PARTITIONS
--echo # Should not work on HASH/KEY
--error ER_REORG_HASH_ONLY_ON_SAME_NO
eval ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA $part_optA,
PARTITION partc $part_optC);
--error ER_CONSECUTIVE_REORG_PARTITIONS
eval ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB $part_optA,
PARTITION parta $part_optC);
eval ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB $part_optA COMMENT="Previusly named parta",
PARTITION parta $part_optB COMMENT="Previusly named partB");
if ($fixed_bug20129)
{
ALTER TABLE TableA ANALYZE PARTITION parta, partB, Partc;
ALTER TABLE TableA CHECK PARTITION parta, partB, Partc;
ALTER TABLE TableA OPTIMIZE PARTITION parta, partB, Partc;
ALTER TABLE TableA REPAIR PARTITION parta, partB, Partc;
}
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of RENAME TABLE
RENAME TABLE TableA to TableB;
--sorted_result
SELECT * FROM TableB;
RENAME TABLE TableB to TableA;
--sorted_result
SELECT * FROM TableA;
--echo # Checking name comparision Upper vs Lower case
--echo # Error if lower_case_table_names != 0
let $lower_case_table_names= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'lower_case_table_names'`;
--echo # lower_case_table_names: $lower_case_table_names
if ($lower_case_table_names)
{
--error ER_TABLE_EXISTS_ERROR
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY KEY (a)
(PARTITION parta $part_optA,
PARTITION partB $part_optB,
PARTITION Partc $part_optC,
PARTITION PartD $part_optD);
SHOW TABLES;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE TableA to tablea;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE tablea to TableA;
--sorted_result
SELECT * FROM tablea;
SHOW CREATE TABLE tablea;
}
if (!$lower_case_table_names)
{
if (!$have_bug33158)
{
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY KEY (a)
(PARTITION parta $part_optA,
PARTITION partB $part_optB,
PARTITION Partc $part_optC,
PARTITION PartD $part_optD);
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
if (!$have_bug37719)
{
RENAME TABLE TableA to tableA;
}
--sorted_result
SELECT * FROM tablea;
if (!$have_bug37719)
{
--sorted_result
SELECT * FROM tableA;
RENAME TABLE tableA to TableA;
}
SHOW CREATE TABLE tablea;
DROP TABLE tablea;
}
}
--echo # Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
if (!$can_only_key)
{
--echo # 2.0 HASH partitioning mgm
--echo # expecting duplicate partition name
--error ER_SAME_NAME_PARTITION
eval CREATE TABLE TableA (a INT)
ENGINE = $engine
PARTITION BY HASH (a)
(PARTITION parta $part_optA,
PARTITION partA $part_optB,
PARTITION Parta $part_optC,
PARTITION PartA $part_optD);
--echo # Creating Hash partitioned table
eval CREATE TABLE TableA (a INT)
ENGINE = $engine
PARTITION BY HASH (a)
(PARTITION parta $part_optA,
PARTITION partB $part_optB,
PARTITION Partc $part_optC,
PARTITION PartD $part_optD);
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
--sorted_result
SELECT * FROM TableA;
--echo # Test of ADD/COALESCE PARTITIONS
--echo # expecting duplicate partition name
--error ER_SAME_NAME_PARTITION
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
ALTER TABLE TableA COALESCE PARTITION 4;
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of REORGANIZE PARTITIONS
--echo # Should not work on HASH/KEY
--error ER_REORG_HASH_ONLY_ON_SAME_NO
eval ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA $part_optA,
PARTITION partc $part_optC);
--error ER_CONSECUTIVE_REORG_PARTITIONS
eval ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB $part_optA,
PARTITION parta $part_optC);
eval ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB $part_optA COMMENT="Previusly named parta",
PARTITION parta $part_optB COMMENT="Previusly named partB");
if ($fixed_bug20129)
{
ALTER TABLE TableA ANALYZE PARTITION parta, partB, Partc;
ALTER TABLE TableA CHECK PARTITION parta, partB, Partc;
ALTER TABLE TableA OPTIMIZE PARTITION parta, partB, Partc;
ALTER TABLE TableA REPAIR PARTITION parta, partB, Partc;
}
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of RENAME TABLE
RENAME TABLE TableA to TableB;
--sorted_result
SELECT * FROM TableB;
RENAME TABLE TableB to TableA;
--sorted_result
SELECT * FROM TableA;
--echo # Checking name comparision Upper vs Lower case
--echo # Error if lower_case_table_names != 0
let $lower_case_table_names= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'lower_case_table_names'`;
--echo # lower_case_table_names: $lower_case_table_names
if ($lower_case_table_names)
{
--error ER_TABLE_EXISTS_ERROR
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY HASH (a)
(PARTITION parta $part_optA,
PARTITION partB $part_optB,
PARTITION Partc $part_optC,
PARTITION PartD $part_optD);
SHOW TABLES;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE TableA to tablea;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE tablea to TableA;
--sorted_result
SELECT * FROM tablea;
SHOW CREATE TABLE tablea;
}
if (!$lower_case_table_names)
{
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY HASH (a)
(PARTITION parta $part_optA,
PARTITION partB $part_optB,
PARTITION Partc $part_optC,
PARTITION PartD $part_optD);
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
if (!$have_bug37719)
{
RENAME TABLE TableA to tableA;
}
--sorted_result
SELECT * FROM tablea;
if (!$have_bug37719)
{
--sorted_result
SELECT * FROM tableA;
RENAME TABLE tableA to TableA;
}
SHOW CREATE TABLE tablea;
DROP TABLE tablea;
}
--echo # Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
--echo # 3.0 RANGE partitioning mgm
--echo # Creating RANGE partitioned table
eval CREATE TABLE TableA (a INT)
ENGINE = $engine
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) $part_optA,
PARTITION partB VALUES LESS THAN (7) $part_optB,
PARTITION Partc VALUES LESS THAN (10) $part_optC,
PARTITION PartD VALUES LESS THAN (13) $part_optD);
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
--sorted_result
SELECT * FROM TableA;
--echo # Test of ADD/DROP PARTITIONS
--echo # expecting duplicate partition name
--error ER_SAME_NAME_PARTITION
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of REORGANIZE PARTITIONS
--echo # Error since it must reorganize a consecutive range
--error ER_CONSECUTIVE_REORG_PARTITIONS
eval ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) $part_optA,
PARTITION parta VALUES LESS THAN (11) $part_optC);
eval ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8) $part_optB
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11) $part_optC
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE) $part_optD
COMMENT="Previously partly PartD");
if ($fixed_bug20129)
{
ALTER TABLE TableA ANALYZE PARTITION parta, partB, Partc;
ALTER TABLE TableA CHECK PARTITION parta, partB, Partc;
ALTER TABLE TableA OPTIMIZE PARTITION parta, partB, Partc;
ALTER TABLE TableA REPAIR PARTITION parta, partB, Partc;
}
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of RENAME TABLE
RENAME TABLE TableA to TableB;
--sorted_result
SELECT * FROM TableB;
RENAME TABLE TableB to TableA;
--sorted_result
SELECT * FROM TableA;
--echo # Checking name comparision Upper vs Lower case
--echo # Error if lower_case_table_names != 0
let $lower_case_table_names= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'lower_case_table_names'`;
--echo # lower_case_table_names: $lower_case_table_names
if ($lower_case_table_names)
{
--error ER_TABLE_EXISTS_ERROR
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) $part_optA,
PARTITION partB VALUES LESS THAN (7) $part_optB,
PARTITION Partc VALUES LESS THAN (10) $part_optC,
PARTITION PartD VALUES LESS THAN (13) $part_optD);
SHOW TABLES;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE TableA to tablea;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE tablea to TableA;
--sorted_result
SELECT * FROM tablea;
SHOW CREATE TABLE tablea;
}
if (!$lower_case_table_names)
{
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) $part_optA,
PARTITION partB VALUES LESS THAN (7) $part_optB,
PARTITION Partc VALUES LESS THAN (10) $part_optC,
PARTITION PartD VALUES LESS THAN (13) $part_optD);
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
if (!$have_bug37719)
{
RENAME TABLE TableA to tableA;
}
--sorted_result
SELECT * FROM tablea;
if (!$have_bug37719)
{
--sorted_result
SELECT * FROM tableA;
RENAME TABLE tableA to TableA;
}
SHOW CREATE TABLE tablea;
DROP TABLE tablea;
}
--echo # Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
--echo # 4.0 LIST partitioning mgm
--echo # Creating LIST partitioned table
eval CREATE TABLE TableA (a INT)
ENGINE = $engine
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) $part_optA,
PARTITION partB VALUES IN (2,10,11) $part_optB,
PARTITION Partc VALUES IN (3,4,7) $part_optC,
PARTITION PartD VALUES IN (5,6,12) $part_optD);
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
--sorted_result
SELECT * FROM TableA;
--echo # Test of ADD/DROP PARTITIONS
--echo # expecting duplicate partition name
--error ER_SAME_NAME_PARTITION
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of REORGANIZE PARTITIONS
--error ER_CONSECUTIVE_REORG_PARTITIONS
eval ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7) $part_optA
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9) $part_optC
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8) $part_optC
COMMENT = "Mix 3 of old parta and Partc");
eval ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7) $part_optA
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9) $part_optC
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8) $part_optC
COMMENT = "Mix 3 of old parta and Partc");
if ($fixed_bug20129)
{
ALTER TABLE TableA ANALYZE PARTITION parta, partB, Partc;
ALTER TABLE TableA CHECK PARTITION parta, partB, Partc;
ALTER TABLE TableA OPTIMIZE PARTITION parta, partB, Partc;
ALTER TABLE TableA REPAIR PARTITION parta, partB, Partc;
}
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Test of RENAME TABLE
RENAME TABLE TableA to TableB;
--sorted_result
SELECT * FROM TableB;
RENAME TABLE TableB to TableA;
--sorted_result
SELECT * FROM TableA;
--echo # Checking name comparision Upper vs Lower case
--echo # Error if lower_case_table_names != 0
let $lower_case_table_names= `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'lower_case_table_names'`;
--echo # lower_case_table_names: $lower_case_table_names
if ($lower_case_table_names)
{
--error ER_TABLE_EXISTS_ERROR
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) $part_optA,
PARTITION partB VALUES IN (2,10,11) $part_optB,
PARTITION Partc VALUES IN (3,4,7) $part_optC,
PARTITION PartD VALUES IN (5,6,12) $part_optD);
SHOW TABLES;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE TableA to tablea;
--error ER_TABLE_EXISTS_ERROR
RENAME TABLE tablea to TableA;
--sorted_result
SELECT * FROM tablea;
SHOW CREATE TABLE tablea;
}
if (!$lower_case_table_names)
{
eval CREATE TABLE tablea (a INT)
ENGINE = $engine
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) $part_optA,
PARTITION partB VALUES IN (2,10,11) $part_optB,
PARTITION Partc VALUES IN (3,4,7) $part_optC,
PARTITION PartD VALUES IN (5,6,12) $part_optD);
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
if (!$have_bug37719)
{
RENAME TABLE TableA to tableA;
}
--sorted_result
SELECT * FROM tablea;
if (!$have_bug37719)
{
--sorted_result
SELECT * FROM tableA;
RENAME TABLE tableA to TableA;
}
SHOW CREATE TABLE tablea;
DROP TABLE tablea;
}
--echo # Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
--sorted_result
SELECT * FROM TableA;
SHOW CREATE TABLE TableA;
--echo # Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
}
# End of $can_only_key
--echo # Cleaning up before exit
eval USE $old_db;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE, PARTITION partE ENGINE = ARCHIVE, PARTITION Partf ENGINE = ARCHIVE, PARTITION PartG ENGINE = ARCHIVE) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
SELECT * FROM tablea;
a
1
1
10
10
11
12
2
2
3
4
5
6
7
7
8
8
9
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
1
10
11
12
2
3
4
5
6
7
7
8
8
9
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE, PARTITION partE ENGINE = ARCHIVE, PARTITION Partf ENGINE = ARCHIVE, PARTITION PartG ENGINE = ARCHIVE) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
SELECT * FROM tablea;
a
1
1
10
10
11
12
2
2
3
4
5
6
7
7
8
8
9
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
1
10
10
11
12
2
2
3
4
5
6
7
8
8
9
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (7) ENGINE = ARCHIVE, PARTITION Partc VALUES LESS THAN (10) ENGINE = ARCHIVE, PARTITION PartD VALUES LESS THAN (13) ENGINE = ARCHIVE, PARTITION partE VALUES LESS THAN (16) ENGINE = ARCHIVE, PARTITION Partf VALUES LESS THAN (19) ENGINE = ARCHIVE, PARTITION PartG VALUES LESS THAN (22) ENGINE = ARCHIVE) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (7) ENGINE = ARCHIVE, PARTITION Partc VALUES LESS THAN (10) ENGINE = ARCHIVE, PARTITION PartD VALUES LESS THAN (13) ENGINE = ARCHIVE, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = ARCHIVE, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
SELECT * FROM tablea;
a
1
1
10
10
11
12
2
2
3
4
5
6
7
7
8
8
9
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (7) ENGINE = ARCHIVE, PARTITION Partc VALUES LESS THAN (10) ENGINE = ARCHIVE, PARTITION PartD VALUES LESS THAN (13) ENGINE = ARCHIVE) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
1
10
10
11
12
2
2
3
4
5
6
7
7
8
8
9
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = ARCHIVE, PARTITION partB VALUES IN (2,10,11) ENGINE = ARCHIVE, PARTITION Partc VALUES IN (3,4,7) ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION partE VALUES IN (16) ENGINE = ARCHIVE, PARTITION Partf VALUES IN (19) ENGINE = ARCHIVE, PARTITION PartG VALUES IN (22) ENGINE = ARCHIVE) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = ARCHIVE, PARTITION partB VALUES IN (2,10,11) ENGINE = ARCHIVE, PARTITION Partc VALUES IN (3,4,7) ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = ARCHIVE, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = ARCHIVE, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
SELECT * FROM tablea;
a
1
1
10
12
2
3
4
5
6
7
7
8
8
9
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = ARCHIVE, PARTITION partB VALUES IN (2,10,11) ENGINE = ARCHIVE, PARTITION Partc VALUES IN (3,4,7) ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
1
10
12
2
3
4
5
6
7
7
8
8
9
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB, PARTITION partE ENGINE = InnoDB, PARTITION Partf ENGINE = InnoDB, PARTITION PartG ENGINE = InnoDB) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB, PARTITION partE ENGINE = InnoDB, PARTITION Partf ENGINE = InnoDB, PARTITION PartG ENGINE = InnoDB) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION Partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION PartD VALUES LESS THAN (13) ENGINE = InnoDB, PARTITION partE VALUES LESS THAN (16) ENGINE = InnoDB, PARTITION Partf VALUES LESS THAN (19) ENGINE = InnoDB, PARTITION PartG VALUES LESS THAN (22) ENGINE = InnoDB) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION Partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION PartD VALUES LESS THAN (13) ENGINE = InnoDB, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = InnoDB, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION Partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION PartD VALUES LESS THAN (13) ENGINE = InnoDB) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = InnoDB, PARTITION partB VALUES IN (2,10,11) ENGINE = InnoDB, PARTITION Partc VALUES IN (3,4,7) ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION partE VALUES IN (16) ENGINE = InnoDB, PARTITION Partf VALUES IN (19) ENGINE = InnoDB, PARTITION PartG VALUES IN (22) ENGINE = InnoDB) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = InnoDB, PARTITION partB VALUES IN (2,10,11) ENGINE = InnoDB, PARTITION Partc VALUES IN (3,4,7) ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = InnoDB, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = InnoDB, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = InnoDB, PARTITION partB VALUES IN (2,10,11) ENGINE = InnoDB, PARTITION Partc VALUES IN (3,4,7) ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY, PARTITION partE ENGINE = MEMORY, PARTITION Partf ENGINE = MEMORY, PARTITION PartG ENGINE = MEMORY) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY, PARTITION partE ENGINE = MEMORY, PARTITION Partf ENGINE = MEMORY, PARTITION PartG ENGINE = MEMORY) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (7) ENGINE = MEMORY, PARTITION Partc VALUES LESS THAN (10) ENGINE = MEMORY, PARTITION PartD VALUES LESS THAN (13) ENGINE = MEMORY, PARTITION partE VALUES LESS THAN (16) ENGINE = MEMORY, PARTITION Partf VALUES LESS THAN (19) ENGINE = MEMORY, PARTITION PartG VALUES LESS THAN (22) ENGINE = MEMORY) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (7) ENGINE = MEMORY, PARTITION Partc VALUES LESS THAN (10) ENGINE = MEMORY, PARTITION PartD VALUES LESS THAN (13) ENGINE = MEMORY, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MEMORY, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (7) ENGINE = MEMORY, PARTITION Partc VALUES LESS THAN (10) ENGINE = MEMORY, PARTITION PartD VALUES LESS THAN (13) ENGINE = MEMORY) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MEMORY, PARTITION partB VALUES IN (2,10,11) ENGINE = MEMORY, PARTITION Partc VALUES IN (3,4,7) ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION partE VALUES IN (16) ENGINE = MEMORY, PARTITION Partf VALUES IN (19) ENGINE = MEMORY, PARTITION PartG VALUES IN (22) ENGINE = MEMORY) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MEMORY, PARTITION partB VALUES IN (2,10,11) ENGINE = MEMORY, PARTITION Partc VALUES IN (3,4,7) ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MEMORY, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MEMORY, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MEMORY, PARTITION partB VALUES IN (2,10,11) ENGINE = MEMORY, PARTITION Partc VALUES IN (3,4,7) ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM, PARTITION partE ENGINE = MyISAM, PARTITION Partf ENGINE = MyISAM, PARTITION PartG ENGINE = MyISAM) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM, PARTITION partE ENGINE = MyISAM, PARTITION Partf ENGINE = MyISAM, PARTITION PartG ENGINE = MyISAM) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION Partc VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION PartD VALUES LESS THAN (13) ENGINE = MyISAM, PARTITION partE VALUES LESS THAN (16) ENGINE = MyISAM, PARTITION Partf VALUES LESS THAN (19) ENGINE = MyISAM, PARTITION PartG VALUES LESS THAN (22) ENGINE = MyISAM) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION Partc VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION PartD VALUES LESS THAN (13) ENGINE = MyISAM, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MyISAM, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION Partc VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION PartD VALUES LESS THAN (13) ENGINE = MyISAM) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MyISAM, PARTITION partB VALUES IN (2,10,11) ENGINE = MyISAM, PARTITION Partc VALUES IN (3,4,7) ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION partE VALUES IN (16) ENGINE = MyISAM, PARTITION Partf VALUES IN (19) ENGINE = MyISAM, PARTITION PartG VALUES IN (22) ENGINE = MyISAM) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MyISAM, PARTITION partB VALUES IN (2,10,11) ENGINE = MyISAM, PARTITION Partc VALUES IN (3,4,7) ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MyISAM, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MyISAM, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO tablea VALUES (1), (2), (7), (8), (9), (10);
SHOW TABLES;
Tables_in_MySQL_Test_DB
TableA
tablea
RENAME TABLE TableA to tableA;
SELECT * FROM tablea;
a
1
10
2
7
8
9
SELECT * FROM tableA;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE tableA to TableA;
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MyISAM, PARTITION partB VALUES IN (2,10,11) ENGINE = MyISAM, PARTITION Partc VALUES IN (3,4,7) ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM) */
DROP TABLE tablea;
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'NDBCluster'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ndbcluster, PARTITION partB ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster, PARTITION PartD ENGINE = ndbcluster, PARTITION partE ENGINE = ndbcluster, PARTITION Partf ENGINE = ndbcluster, PARTITION PartG ENGINE = ndbcluster) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ndbcluster, PARTITION partB ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ndbcluster, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 0
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE, PARTITION partE ENGINE = ARCHIVE, PARTITION Partf ENGINE = ARCHIVE, PARTITION PartG ENGINE = ARCHIVE) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE, PARTITION partE ENGINE = ARCHIVE, PARTITION Partf ENGINE = ARCHIVE, PARTITION PartG ENGINE = ARCHIVE) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (7) ENGINE = ARCHIVE, PARTITION Partc VALUES LESS THAN (10) ENGINE = ARCHIVE, PARTITION PartD VALUES LESS THAN (13) ENGINE = ARCHIVE, PARTITION partE VALUES LESS THAN (16) ENGINE = ARCHIVE, PARTITION Partf VALUES LESS THAN (19) ENGINE = ARCHIVE, PARTITION PartG VALUES LESS THAN (22) ENGINE = ARCHIVE) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (7) ENGINE = ARCHIVE, PARTITION Partc VALUES LESS THAN (10) ENGINE = ARCHIVE, PARTITION PartD VALUES LESS THAN (13) ENGINE = ARCHIVE, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = ARCHIVE, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = ARCHIVE, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = ARCHIVE, PARTITION partB VALUES IN (2,10,11) ENGINE = ARCHIVE, PARTITION Partc VALUES IN (3,4,7) ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION partE VALUES IN (16) ENGINE = ARCHIVE, PARTITION Partf VALUES IN (19) ENGINE = ARCHIVE, PARTITION PartG VALUES IN (22) ENGINE = ARCHIVE) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = ARCHIVE, PARTITION partB VALUES IN (2,10,11) ENGINE = ARCHIVE, PARTITION Partc VALUES IN (3,4,7) ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = ARCHIVE, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = ARCHIVE, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = ARCHIVE, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = ARCHIVE, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB, PARTITION partE ENGINE = InnoDB, PARTITION Partf ENGINE = InnoDB, PARTITION PartG ENGINE = InnoDB) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB, PARTITION partE ENGINE = InnoDB, PARTITION Partf ENGINE = InnoDB, PARTITION PartG ENGINE = InnoDB) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION Partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION PartD VALUES LESS THAN (13) ENGINE = InnoDB, PARTITION partE VALUES LESS THAN (16) ENGINE = InnoDB, PARTITION Partf VALUES LESS THAN (19) ENGINE = InnoDB, PARTITION PartG VALUES LESS THAN (22) ENGINE = InnoDB) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION Partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION PartD VALUES LESS THAN (13) ENGINE = InnoDB, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = InnoDB, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = InnoDB, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = InnoDB, PARTITION partB VALUES IN (2,10,11) ENGINE = InnoDB, PARTITION Partc VALUES IN (3,4,7) ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION partE VALUES IN (16) ENGINE = InnoDB, PARTITION Partf VALUES IN (19) ENGINE = InnoDB, PARTITION PartG VALUES IN (22) ENGINE = InnoDB) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = InnoDB, PARTITION partB VALUES IN (2,10,11) ENGINE = InnoDB, PARTITION Partc VALUES IN (3,4,7) ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = InnoDB, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = InnoDB, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = InnoDB, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = InnoDB, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY, PARTITION partE ENGINE = MEMORY, PARTITION Partf ENGINE = MEMORY, PARTITION PartG ENGINE = MEMORY) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY, PARTITION partE ENGINE = MEMORY, PARTITION Partf ENGINE = MEMORY, PARTITION PartG ENGINE = MEMORY) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (7) ENGINE = MEMORY, PARTITION Partc VALUES LESS THAN (10) ENGINE = MEMORY, PARTITION PartD VALUES LESS THAN (13) ENGINE = MEMORY, PARTITION partE VALUES LESS THAN (16) ENGINE = MEMORY, PARTITION Partf VALUES LESS THAN (19) ENGINE = MEMORY, PARTITION PartG VALUES LESS THAN (22) ENGINE = MEMORY) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (7) ENGINE = MEMORY, PARTITION Partc VALUES LESS THAN (10) ENGINE = MEMORY, PARTITION PartD VALUES LESS THAN (13) ENGINE = MEMORY, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MEMORY, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MEMORY, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MEMORY, PARTITION partB VALUES IN (2,10,11) ENGINE = MEMORY, PARTITION Partc VALUES IN (3,4,7) ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION partE VALUES IN (16) ENGINE = MEMORY, PARTITION Partf VALUES IN (19) ENGINE = MEMORY, PARTITION PartG VALUES IN (22) ENGINE = MEMORY) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MEMORY, PARTITION partB VALUES IN (2,10,11) ENGINE = MEMORY, PARTITION Partc VALUES IN (3,4,7) ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MEMORY, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MEMORY, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MEMORY, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MEMORY, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM, PARTITION partE ENGINE = MyISAM, PARTITION Partf ENGINE = MyISAM, PARTITION PartG ENGINE = MyISAM) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM, PARTITION partE ENGINE = MyISAM, PARTITION Partf ENGINE = MyISAM, PARTITION PartG ENGINE = MyISAM) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION Partc VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION PartD VALUES LESS THAN (13) ENGINE = MyISAM, PARTITION partE VALUES LESS THAN (16) ENGINE = MyISAM, PARTITION Partf VALUES LESS THAN (19) ENGINE = MyISAM, PARTITION PartG VALUES LESS THAN (22) ENGINE = MyISAM) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION Partc VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION PartD VALUES LESS THAN (13) ENGINE = MyISAM, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MyISAM, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MyISAM, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MyISAM, PARTITION partB VALUES IN (2,10,11) ENGINE = MyISAM, PARTITION Partc VALUES IN (3,4,7) ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION partE VALUES IN (16) ENGINE = MyISAM, PARTITION Partf VALUES IN (19) ENGINE = MyISAM, PARTITION PartG VALUES IN (22) ENGINE = MyISAM) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MyISAM, PARTITION partB VALUES IN (2,10,11) ENGINE = MyISAM, PARTITION Partc VALUES IN (3,4,7) ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MyISAM, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MyISAM, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MyISAM, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MyISAM, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'NDBCluster'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ndbcluster, PARTITION partB ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster, PARTITION PartD ENGINE = ndbcluster, PARTITION partE ENGINE = ndbcluster, PARTITION Partf ENGINE = ndbcluster, PARTITION PartG ENGINE = ndbcluster) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ndbcluster, PARTITION partB ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ndbcluster, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 1
CREATE TABLE tablea (a INT)
ENGINE = 'NDBCluster'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
tablea
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'tablea' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ndbcluster, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE, PARTITION partE ENGINE = ARCHIVE, PARTITION Partf ENGINE = ARCHIVE, PARTITION PartG ENGINE = ARCHIVE) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE, PARTITION PartD ENGINE = ARCHIVE, PARTITION partE ENGINE = ARCHIVE, PARTITION Partf ENGINE = ARCHIVE, PARTITION PartG ENGINE = ARCHIVE) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = ARCHIVE, PARTITION partB ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ARCHIVE, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ARCHIVE, PARTITION Partc ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (7) ENGINE = ARCHIVE, PARTITION Partc VALUES LESS THAN (10) ENGINE = ARCHIVE, PARTITION PartD VALUES LESS THAN (13) ENGINE = ARCHIVE, PARTITION partE VALUES LESS THAN (16) ENGINE = ARCHIVE, PARTITION Partf VALUES LESS THAN (19) ENGINE = ARCHIVE, PARTITION PartG VALUES LESS THAN (22) ENGINE = ARCHIVE) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (7) ENGINE = ARCHIVE, PARTITION Partc VALUES LESS THAN (10) ENGINE = ARCHIVE, PARTITION PartD VALUES LESS THAN (13) ENGINE = ARCHIVE, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = ARCHIVE, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = ARCHIVE, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = ARCHIVE, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = ARCHIVE, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Archive'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = ARCHIVE, PARTITION partB VALUES IN (2,10,11) ENGINE = ARCHIVE, PARTITION Partc VALUES IN (3,4,7) ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION partE VALUES IN (16) ENGINE = ARCHIVE, PARTITION Partf VALUES IN (19) ENGINE = ARCHIVE, PARTITION PartG VALUES IN (22) ENGINE = ARCHIVE) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = ARCHIVE, PARTITION partB VALUES IN (2,10,11) ENGINE = ARCHIVE, PARTITION Partc VALUES IN (3,4,7) ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = ARCHIVE, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = ARCHIVE, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Archive'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = ARCHIVE, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = ARCHIVE, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = ARCHIVE, PARTITION PartD VALUES IN (5,6,12) ENGINE = ARCHIVE, PARTITION PartE VALUES IN (13) ENGINE = ARCHIVE) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB, PARTITION partE ENGINE = InnoDB, PARTITION Partf ENGINE = InnoDB, PARTITION PartG ENGINE = InnoDB) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB, PARTITION PartD ENGINE = InnoDB, PARTITION partE ENGINE = InnoDB, PARTITION Partf ENGINE = InnoDB, PARTITION PartG ENGINE = InnoDB) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = InnoDB, PARTITION partB ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = InnoDB, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = InnoDB, PARTITION Partc ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION Partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION PartD VALUES LESS THAN (13) ENGINE = InnoDB, PARTITION partE VALUES LESS THAN (16) ENGINE = InnoDB, PARTITION Partf VALUES LESS THAN (19) ENGINE = InnoDB, PARTITION PartG VALUES LESS THAN (22) ENGINE = InnoDB) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION Partc VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION PartD VALUES LESS THAN (13) ENGINE = InnoDB, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = InnoDB, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = InnoDB, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = InnoDB, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'InnoDB'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = InnoDB, PARTITION partB VALUES IN (2,10,11) ENGINE = InnoDB, PARTITION Partc VALUES IN (3,4,7) ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION partE VALUES IN (16) ENGINE = InnoDB, PARTITION Partf VALUES IN (19) ENGINE = InnoDB, PARTITION PartG VALUES IN (22) ENGINE = InnoDB) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = InnoDB, PARTITION partB VALUES IN (2,10,11) ENGINE = InnoDB, PARTITION Partc VALUES IN (3,4,7) ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = InnoDB, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = InnoDB, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'InnoDB'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = InnoDB, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = InnoDB, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = InnoDB, PARTITION PartD VALUES IN (5,6,12) ENGINE = InnoDB, PARTITION PartE VALUES IN (13) ENGINE = InnoDB) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY, PARTITION partE ENGINE = MEMORY, PARTITION Partf ENGINE = MEMORY, PARTITION PartG ENGINE = MEMORY) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY, PARTITION PartD ENGINE = MEMORY, PARTITION partE ENGINE = MEMORY, PARTITION Partf ENGINE = MEMORY, PARTITION PartG ENGINE = MEMORY) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MEMORY, PARTITION partB ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MEMORY, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MEMORY, PARTITION Partc ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (7) ENGINE = MEMORY, PARTITION Partc VALUES LESS THAN (10) ENGINE = MEMORY, PARTITION PartD VALUES LESS THAN (13) ENGINE = MEMORY, PARTITION partE VALUES LESS THAN (16) ENGINE = MEMORY, PARTITION Partf VALUES LESS THAN (19) ENGINE = MEMORY, PARTITION PartG VALUES LESS THAN (22) ENGINE = MEMORY) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (7) ENGINE = MEMORY, PARTITION Partc VALUES LESS THAN (10) ENGINE = MEMORY, PARTITION PartD VALUES LESS THAN (13) ENGINE = MEMORY, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MEMORY, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MEMORY, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MEMORY, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MEMORY, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'Memory'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MEMORY, PARTITION partB VALUES IN (2,10,11) ENGINE = MEMORY, PARTITION Partc VALUES IN (3,4,7) ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION partE VALUES IN (16) ENGINE = MEMORY, PARTITION Partf VALUES IN (19) ENGINE = MEMORY, PARTITION PartG VALUES IN (22) ENGINE = MEMORY) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MEMORY, PARTITION partB VALUES IN (2,10,11) ENGINE = MEMORY, PARTITION Partc VALUES IN (3,4,7) ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MEMORY, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MEMORY, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'Memory'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MEMORY, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MEMORY, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MEMORY, PARTITION PartD VALUES IN (5,6,12) ENGINE = MEMORY, PARTITION PartE VALUES IN (13) ENGINE = MEMORY) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM, PARTITION partE ENGINE = MyISAM, PARTITION Partf ENGINE = MyISAM, PARTITION PartG ENGINE = MyISAM) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# 2.0 HASH partitioning mgm
# expecting duplicate partition name
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partA ,
PARTITION Parta ,
PARTITION PartA );
ERROR HY000: Duplicate partition name parta
# Creating Hash partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM, PARTITION PartD ENGINE = MyISAM, PARTITION partE ENGINE = MyISAM, PARTITION Partf ENGINE = MyISAM, PARTITION PartG ENGINE = MyISAM) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION parta ENGINE = MyISAM, PARTITION partB ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY HASH (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = MyISAM, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = MyISAM, PARTITION Partc ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after HASH PARTITIONING test
DROP TABLE TableA;
# 3.0 RANGE partitioning mgm
# Creating RANGE partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES LESS THAN (MAXVALUE));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES LESS THAN (16),
PARTITION Partf VALUES LESS THAN (19),
PARTITION PartG VALUES LESS THAN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION Partc VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION PartD VALUES LESS THAN (13) ENGINE = MyISAM, PARTITION partE VALUES LESS THAN (16) ENGINE = MyISAM, PARTITION Partf VALUES LESS THAN (19) ENGINE = MyISAM, PARTITION PartG VALUES LESS THAN (22) ENGINE = MyISAM) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES LESS THAN (MAXVALUE));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (7) ENGINE = MyISAM, PARTITION Partc VALUES LESS THAN (10) ENGINE = MyISAM, PARTITION PartD VALUES LESS THAN (13) ENGINE = MyISAM, PARTITION PartE VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
# Error since it must reorganize a consecutive range
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB VALUES LESS THAN (3) ,
PARTITION parta VALUES LESS THAN (11) );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION partB,Partc,PartD,PartE INTO
(PARTITION partD VALUES LESS THAN (8)
COMMENT="Previously partB and partly Partc",
PARTITION partB VALUES LESS THAN (11)
COMMENT="Previously partly Partc and partly PartD",
PARTITION partC VALUES LESS THAN (MAXVALUE)
COMMENT="Previously partly PartD");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MyISAM, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY RANGE (a)
(PARTITION parta VALUES LESS THAN (4) ,
PARTITION partB VALUES LESS THAN (7) ,
PARTITION Partc VALUES LESS THAN (10) ,
PARTITION PartD VALUES LESS THAN (13) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (a) (PARTITION parta VALUES LESS THAN (4) ENGINE = MyISAM, PARTITION partD VALUES LESS THAN (8) COMMENT = 'Previously partB and partly Partc' ENGINE = MyISAM, PARTITION partB VALUES LESS THAN (11) COMMENT = 'Previously partly Partc and partly PartD' ENGINE = MyISAM, PARTITION partC VALUES LESS THAN MAXVALUE COMMENT = 'Previously partly PartD' ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after RANGE PARTITIONING test
DROP TABLE TableA;
# 4.0 LIST partitioning mgm
# Creating LIST partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'MyISAM'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/DROP PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA VALUES IN (0));
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE VALUES IN (16),
PARTITION Partf VALUES IN (19),
PARTITION PartG VALUES IN (22));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MyISAM, PARTITION partB VALUES IN (2,10,11) ENGINE = MyISAM, PARTITION Partc VALUES IN (3,4,7) ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION partE VALUES IN (16) ENGINE = MyISAM, PARTITION Partf VALUES IN (19) ENGINE = MyISAM, PARTITION PartG VALUES IN (22) ENGINE = MyISAM) */
ALTER TABLE TableA DROP PARTITION partE, PartG;
ALTER TABLE TableA DROP PARTITION Partf;
ALTER TABLE TableA ADD PARTITION
(PARTITION PartE VALUES IN (13));
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION parta VALUES IN (1,8,9) ENGINE = MyISAM, PARTITION partB VALUES IN (2,10,11) ENGINE = MyISAM, PARTITION Partc VALUES IN (3,4,7) ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of REORGANIZE PARTITIONS
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION partF VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION parta VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION Partc VALUES IN (1,7)
COMMENT = "Mix 1 of old parta and Partc",
PARTITION parta VALUES IN (3,9)
COMMENT = "Mix 2 of old parta and Partc",
PARTITION partB VALUES IN (4,8)
COMMENT = "Mix 3 of old parta and Partc");
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MyISAM, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MyISAM, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
12
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'MyISAM'
PARTITION BY LIST (a)
(PARTITION parta VALUES IN (1,8,9) ,
PARTITION partB VALUES IN (2,10,11) ,
PARTITION Partc VALUES IN (3,4,7) ,
PARTITION PartD VALUES IN (5,6,12) );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (a) (PARTITION Partc VALUES IN (1,7) COMMENT = 'Mix 1 of old parta and Partc' ENGINE = MyISAM, PARTITION parta VALUES IN (3,9) COMMENT = 'Mix 2 of old parta and Partc' ENGINE = MyISAM, PARTITION partB VALUES IN (4,8) COMMENT = 'Mix 3 of old parta and Partc' ENGINE = MyISAM, PARTITION PartD VALUES IN (5,6,12) ENGINE = MyISAM, PARTITION PartE VALUES IN (13) ENGINE = MyISAM) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
12
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
# Cleaning up after LIST PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
# Creating database MySQL_TEST_DB
CREATE DATABASE MySQL_Test_DB;
USE MySQL_Test_DB;
# 1.0 KEY partitioning mgm
# Creating KEY partitioned table
CREATE TABLE TableA (a INT)
ENGINE = 'NDBCluster'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
INSERT INTO TableA VALUES (1), (2), (7), (8), (9), (10);
INSERT INTO TableA VALUES (3), (4), (5), (6), (11), (12);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Test of ADD/COALESCE PARTITIONS
# expecting duplicate partition name
ALTER TABLE TableA ADD PARTITION
(PARTITION partA,
PARTITION Parta,
PARTITION PartA);
ERROR HY000: Duplicate partition name parta
ALTER TABLE TableA ADD PARTITION
(PARTITION partE,
PARTITION Partf,
PARTITION PartG);
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ndbcluster, PARTITION partB ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster, PARTITION PartD ENGINE = ndbcluster, PARTITION partE ENGINE = ndbcluster, PARTITION Partf ENGINE = ndbcluster, PARTITION PartG ENGINE = ndbcluster) */
ALTER TABLE TableA COALESCE PARTITION 4;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION parta ENGINE = ndbcluster, PARTITION partB ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of REORGANIZE PARTITIONS
# Should not work on HASH/KEY
ALTER TABLE TableA REORGANIZE PARTITION parta,partB,Partc INTO
(PARTITION PARTA ,
PARTITION partc );
ERROR HY000: REORGANISE PARTITION can only be used to reorganise partitions not to change their numbers
ALTER TABLE TableA REORGANIZE PARTITION parta,Partc INTO
(PARTITION partB ,
PARTITION parta );
ERROR HY000: When reorganising a set of partitions they must be in consecutive order
ALTER TABLE TableA REORGANIZE PARTITION parta,partB INTO
(PARTITION partB COMMENT="Previusly named parta",
PARTITION parta COMMENT="Previusly named partB");
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ndbcluster, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of RENAME TABLE
RENAME TABLE TableA to TableB;
SELECT * FROM TableB;
a
1
10
11
12
2
3
4
5
6
7
8
9
RENAME TABLE TableB to TableA;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
# Checking name comparision Upper vs Lower case
# Error if lower_case_table_names != 0
# lower_case_table_names: 2
CREATE TABLE tablea (a INT)
ENGINE = 'NDBCluster'
PARTITION BY KEY (a)
(PARTITION parta ,
PARTITION partB ,
PARTITION Partc ,
PARTITION PartD );
ERROR 42S01: Table 'tablea' already exists
SHOW TABLES;
Tables_in_mysql_test_db
TableA
RENAME TABLE TableA to tablea;
ERROR 42S01: Table 'tablea' already exists
RENAME TABLE tablea to TableA;
ERROR 42S01: Table 'TableA' already exists
SELECT * FROM tablea;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE tablea;
Table Create Table
tablea CREATE TABLE `tablea` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION partB COMMENT = 'Previusly named parta' ENGINE = ndbcluster, PARTITION parta COMMENT = 'Previusly named partB' ENGINE = ndbcluster, PARTITION Partc ENGINE = ndbcluster) */
# Test of REMOVE PARTITIONING
ALTER TABLE TableA REMOVE PARTITIONING;
SELECT * FROM TableA;
a
1
10
11
12
2
3
4
5
6
7
8
9
SHOW CREATE TABLE TableA;
Table Create Table
TableA CREATE TABLE `TableA` (
`a` int(11) DEFAULT NULL
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
# Cleaning up after KEY PARTITIONING test
DROP TABLE TableA;
# Cleaning up before exit
USE test;
DROP DATABASE MySQL_Test_DB;
################################################################################
# t/partition_mgm_lc0_archive.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# Archive branch + lower_case_table_names = 0 #
# (usually Unix like, apart from Mac OS X) #
# Also requires lower_case_file_system OFF #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase0.inc
--source include/have_case_sensitive_file_system.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
let $have_bug37719= 1;
##### Storage engine to be tested
--source include/have_archive.inc
let $engine= 'Archive';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc0_innodb.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# InnoDB branch + lower_case_table_names = 0 #
# (usually Unix like, apart from Mac OS X) #
# Also requires lower_case_file_system OFF #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase0.inc
--source include/have_case_sensitive_file_system.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
--source include/have_innodb.inc
let $engine= 'InnoDB';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc0_memory.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# Memory branch + lower_case_table_names = 0 #
# (usually Unix like, apart from Mac OS X) #
# Also requires lower_case_file_system OFF #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase0.inc
--source include/have_case_sensitive_file_system.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
#--source include/have_memory.inc
let $engine= 'Memory';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc0_myisam.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# MyISAM branch + lower_case_table_names = 0 #
# (usually Unix like, apart from Mac OS X) #
# Also requires lower_case_file_system OFF #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase0.inc
--source include/have_case_sensitive_file_system.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
#--source include/have_myisam.inc
let $engine= 'MyISAM';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc0_ndb.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# NDB branch + lower_case_table_names = 0 #
# (usually Unix like, apart from Mac OS X) #
# Also requires lower_case_file_system OFF #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase0.inc
--source include/have_case_sensitive_file_system.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
let $have_bug33158= 1;
##### Storage engine to be tested
--source include/have_ndb.inc
connection default;
# Use either $can_only_key or new=on option to run test.
let $can_only_key= 1;
# Allow hash/list/range partitioning with ndb
#SET new=on;
let $engine= 'NDBCluster';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc1_archive.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# Archive branch + lower_case_table_names = 1 (usually Windows) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase1.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
--source include/have_archive.inc
let $engine= 'Archive';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc1_innodb.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# InnoDB branch + lower_case_table_names = 1 (usually Windows) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase1.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
--source include/have_innodb.inc
let $engine= 'InnoDB';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc1_memory.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# Memory branch + lower_case_table_names = 1 (usually Windows) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase1.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
#--source include/have_memory.inc
let $engine= 'Memory';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc1_myisam.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# MyISAM branch + lower_case_table_names = 1 (usually Windows) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase1.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
#--source include/have_myisam.inc
let $engine= 'MyISAM';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc1_ndb.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# NDB branch + lower_case_table_names = 1 (usually Windows) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase1.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
let $have_bug33158= 1;
##### Storage engine to be tested
--source include/have_ndb.inc
connection default;
# Use either $can_only_key or new=on option to run test.
let $can_only_key= 1;
# Allow hash/list/range partitioning with ndb
#SET new=on;
let $engine= 'NDBCluster';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc2_archive.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# Archive branch + lower_case_table_names = 2 (usually Mac OS X) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase2.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
--source include/have_archive.inc
let $engine= 'Archive';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc2_innodb.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# InnoDB branch + lower_case_table_names = 2 (usually Mac OS X) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase2.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
--source include/have_innodb.inc
let $engine= 'InnoDB';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc2_memory.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# Memory branch + lower_case_table_names = 2 (usually Mac OS X) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase2.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
#--source include/have_memory.inc
let $engine= 'Memory';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc2_myisam.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# MyISAM branch + lower_case_table_names = 2 (usually Mac OS X) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase2.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
#--source include/have_myisam.inc
let $engine= 'MyISAM';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
################################################################################
# t/partition_mgm_lc2_ndb.test #
# #
# Purpose: #
# Test of partitioning management functions (incl upper/lower case names): #
# NDB branch + lower_case_table_names = 2 (usually Mac OS X) #
# #
#------------------------------------------------------------------------------#
# Original Author: mattiasj #
# Original Date: 2008-06-27 #
################################################################################
# The server must support partitioning.
--source include/have_partition.inc
#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
# TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
# THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#
#------------------------------------------------------------------------------#
# General not engine specific settings and requirements
--source include/have_lowercase2.inc
#------------------------------------------------------------------------------#
# Engine specific settings and requirements
##### Storage engine to be tested
--source include/have_ndb.inc
connection default;
# Use either $can_only_key or new=on option to run test.
let $can_only_key= 1;
# Allow hash/list/range partitioning with ndb
#SET new=on;
let $engine= 'NDBCluster';
#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_mgm.inc
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/have_lowercase0.inc --source include/have_lowercase0.inc
--source include/have_case_insensitive_file_system.inc
--source include/not_windows.inc --source include/not_windows.inc
--disable_warnings --disable_warnings
......
...@@ -593,6 +593,12 @@ int ha_partition::drop_partitions(const char *path) ...@@ -593,6 +593,12 @@ int ha_partition::drop_partitions(const char *path)
int error= 0; int error= 0;
DBUG_ENTER("ha_partition::drop_partitions"); DBUG_ENTER("ha_partition::drop_partitions");
/*
Assert that it works without HA_FILE_BASED and lower_case_table_name = 2.
We use m_file[0] as long as all partitions have the same storage engine.
*/
DBUG_ASSERT(!strcmp(path, get_canonical_filename(m_file[0], path,
part_name_buff)));
do do
{ {
partition_element *part_elem= part_it++; partition_element *part_elem= part_it++;
...@@ -682,6 +688,13 @@ int ha_partition::rename_partitions(const char *path) ...@@ -682,6 +688,13 @@ int ha_partition::rename_partitions(const char *path)
partition_element *part_elem, *sub_elem; partition_element *part_elem, *sub_elem;
DBUG_ENTER("ha_partition::rename_partitions"); DBUG_ENTER("ha_partition::rename_partitions");
/*
Assert that it works without HA_FILE_BASED and lower_case_table_name = 2.
We use m_file[0] as long as all partitions have the same storage engine.
*/
DBUG_ASSERT(!strcmp(path, get_canonical_filename(m_file[0], path,
norm_name_buff)));
if (temp_partitions) if (temp_partitions)
{ {
/* /*
...@@ -1344,6 +1357,12 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, ...@@ -1344,6 +1357,12 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
THD *thd= current_thd; THD *thd= current_thd;
DBUG_ENTER("ha_partition::change_partitions"); DBUG_ENTER("ha_partition::change_partitions");
/*
Assert that it works without HA_FILE_BASED and lower_case_table_name = 2.
We use m_file[0] as long as all partitions have the same storage engine.
*/
DBUG_ASSERT(!strcmp(path, get_canonical_filename(m_file[0], path,
part_name_buff)));
m_reorged_parts= 0; m_reorged_parts= 0;
if (!m_part_info->is_sub_partitioned()) if (!m_part_info->is_sub_partitioned())
no_subparts= 1; no_subparts= 1;
...@@ -1776,8 +1795,10 @@ uint ha_partition::del_ren_cre_table(const char *from, ...@@ -1776,8 +1795,10 @@ uint ha_partition::del_ren_cre_table(const char *from,
{ {
int save_error= 0; int save_error= 0;
int error; int error;
char from_buff[FN_REFLEN], to_buff[FN_REFLEN]; char from_buff[FN_REFLEN], to_buff[FN_REFLEN], from_lc_buff[FN_REFLEN],
to_lc_buff[FN_REFLEN];
char *name_buffer_ptr; char *name_buffer_ptr;
const char *from_path, *to_path;
uint i; uint i;
handler **file, **abort_file; handler **file, **abort_file;
DBUG_ENTER("del_ren_cre_table()"); DBUG_ENTER("del_ren_cre_table()");
...@@ -1785,17 +1806,29 @@ uint ha_partition::del_ren_cre_table(const char *from, ...@@ -1785,17 +1806,29 @@ uint ha_partition::del_ren_cre_table(const char *from,
if (get_from_handler_file(from, current_thd->mem_root)) if (get_from_handler_file(from, current_thd->mem_root))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
DBUG_ASSERT(m_file_buffer); DBUG_ASSERT(m_file_buffer);
DBUG_PRINT("enter", ("from: (%s) to: (%s)", from, to));
name_buffer_ptr= m_name_buffer_ptr; name_buffer_ptr= m_name_buffer_ptr;
file= m_file; file= m_file;
/*
Since ha_partition has HA_FILE_BASED, it must alter underlying table names
if they do not have HA_FILE_BASED and lower_case_table_names == 2.
See Bug#37402, for Mac OS X.
The appended #P#<partname>[#SP#<subpartname>] will remain in current case.
Using the first partitions handler, since mixing handlers is not allowed.
*/
from_path= get_canonical_filename(*file, from, from_lc_buff);
if (to != NULL)
to_path= get_canonical_filename(*file, to, to_lc_buff);
i= 0; i= 0;
do do
{ {
create_partition_name(from_buff, from, name_buffer_ptr, NORMAL_PART_NAME, create_partition_name(from_buff, from_path, name_buffer_ptr,
FALSE); NORMAL_PART_NAME, FALSE);
if (to != NULL) if (to != NULL)
{ // Rename branch { // Rename branch
create_partition_name(to_buff, to, name_buffer_ptr, NORMAL_PART_NAME, create_partition_name(to_buff, to_path, name_buffer_ptr,
FALSE); NORMAL_PART_NAME, FALSE);
error= (*file)->ha_rename_table(from_buff, to_buff); error= (*file)->ha_rename_table(from_buff, to_buff);
} }
else if (table_arg == NULL) // delete branch else if (table_arg == NULL) // delete branch
...@@ -1817,7 +1850,7 @@ uint ha_partition::del_ren_cre_table(const char *from, ...@@ -1817,7 +1850,7 @@ uint ha_partition::del_ren_cre_table(const char *from,
name_buffer_ptr= m_name_buffer_ptr; name_buffer_ptr= m_name_buffer_ptr;
for (abort_file= file, file= m_file; file < abort_file; file++) for (abort_file= file, file= m_file; file < abort_file; file++)
{ {
create_partition_name(from_buff, from, name_buffer_ptr, NORMAL_PART_NAME, create_partition_name(from_buff, from_path, name_buffer_ptr, NORMAL_PART_NAME,
FALSE); FALSE);
VOID((*file)->ha_delete_table((const char*) from_buff)); VOID((*file)->ha_delete_table((const char*) from_buff));
name_buffer_ptr= strend(name_buffer_ptr) + 1; name_buffer_ptr= strend(name_buffer_ptr) + 1;
......
...@@ -1814,8 +1814,8 @@ bool ha_flush_logs(handlerton *db_type) ...@@ -1814,8 +1814,8 @@ bool ha_flush_logs(handlerton *db_type)
return FALSE; return FALSE;
} }
static const char *check_lowercase_names(handler *file, const char *path, const char *get_canonical_filename(handler *file, const char *path,
char *tmp_path) char *tmp_path)
{ {
if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED)) if (lower_case_table_names != 2 || (file->ha_table_flags() & HA_FILE_BASED))
return path; return path;
...@@ -1886,7 +1886,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, ...@@ -1886,7 +1886,7 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path,
! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type))) ! (file=get_new_handler((TABLE_SHARE*)0, thd->mem_root, table_type)))
DBUG_RETURN(ENOENT); DBUG_RETURN(ENOENT);
path= check_lowercase_names(file, path, tmp_path); path= get_canonical_filename(file, path, tmp_path);
if ((error= file->ha_delete_table(path)) && generate_warning) if ((error= file->ha_delete_table(path)) && generate_warning)
{ {
/* /*
...@@ -3422,7 +3422,7 @@ int ha_create_table(THD *thd, const char *path, ...@@ -3422,7 +3422,7 @@ int ha_create_table(THD *thd, const char *path,
if (update_create_info) if (update_create_info)
update_create_info_from_table(create_info, &table); update_create_info_from_table(create_info, &table);
name= check_lowercase_names(table.file, share.path.str, name_buff); name= get_canonical_filename(table.file, share.path.str, name_buff);
error= table.file->ha_create(name, &table, create_info); error= table.file->ha_create(name, &table, create_info);
VOID(closefrm(&table, 0)); VOID(closefrm(&table, 0));
...@@ -3494,7 +3494,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) ...@@ -3494,7 +3494,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name)
update_create_info_from_table(&create_info, &table); update_create_info_from_table(&create_info, &table);
create_info.table_options|= HA_OPTION_CREATE_FROM_ENGINE; create_info.table_options|= HA_OPTION_CREATE_FROM_ENGINE;
check_lowercase_names(table.file, path, path); get_canonical_filename(table.file, path, path);
error=table.file->ha_create(path, &table, &create_info); error=table.file->ha_create(path, &table, &create_info);
VOID(closefrm(&table, 1)); VOID(closefrm(&table, 1));
......
...@@ -2227,6 +2227,8 @@ uint tablename_to_filename(const char *from, char *to, uint to_length); ...@@ -2227,6 +2227,8 @@ uint tablename_to_filename(const char *from, char *to, uint to_length);
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
uint build_table_filename(char *buff, size_t bufflen, const char *db, uint build_table_filename(char *buff, size_t bufflen, const char *db,
const char *table, const char *ext, uint flags); const char *table, const char *ext, uint flags);
const char *get_canonical_filename(handler *file, const char *path,
char *tmp_path);
#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#" #define MYSQL50_TABLE_NAME_PREFIX "#mysql50#"
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9 #define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment