-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dumpling: add partition table test cases
- Loading branch information
1 parent
d42a36d
commit 97d437f
Showing
7 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
create table `pt_case_0` (a int, b int, unique index idx(a) global) partition by hash(b) partitions 5; | ||
insert into `pt_case_0` values | ||
(0, 10), | ||
(1, 9), | ||
(2, 8), | ||
(3, 7), | ||
(4, 6), | ||
(5, 5), | ||
(6, 4), | ||
(7, 3), | ||
(8, 2), | ||
(9, 1), | ||
(10, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
create table `pt_case_1` (a int, b int, unique index idx(a) global) partition by list(b) | ||
(partition p0 values in (0, 1, 2, 3), | ||
partition p1 values in (4, 5, 6), | ||
partition p2 values in (7, 8, 9, 10)); | ||
insert into `pt_case_1` values | ||
(0, 10), | ||
(1, 9), | ||
(2, 8), | ||
(3, 7), | ||
(4, 6), | ||
(5, 5), | ||
(6, 4), | ||
(7, 3), | ||
(8, 2), | ||
(9, 1), | ||
(10, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
CREATE TABLE `pt_case_0` ( | ||
`a` int DEFAULT NULL, | ||
`b` int DEFAULT NULL, | ||
UNIQUE KEY `idx` (`a`) /*T![global_index] GLOBAL */ | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY HASH (`b`) PARTITIONS 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `pt_case_0` VALUES | ||
(0,10), | ||
(1,9), | ||
(2,8), | ||
(3,7), | ||
(4,6), | ||
(5,5), | ||
(6,4), | ||
(7,3), | ||
(8,2), | ||
(9,1), | ||
(10,0); |
11 changes: 11 additions & 0 deletions
11
dumpling/tests/partition_table/result/pt_case_1-schema.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
CREATE TABLE `pt_case_1` ( | ||
`a` int DEFAULT NULL, | ||
`b` int DEFAULT NULL, | ||
UNIQUE KEY `idx` (`a`) /*T![global_index] GLOBAL */ | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin | ||
PARTITION BY LIST (`b`) | ||
(PARTITION `p0` VALUES IN (0,1,2,3), | ||
PARTITION `p1` VALUES IN (4,5,6), | ||
PARTITION `p2` VALUES IN (7,8,9,10)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*!40014 SET FOREIGN_KEY_CHECKS=0*/; | ||
/*!40101 SET NAMES binary*/; | ||
INSERT INTO `pt_case_1` VALUES | ||
(0,10), | ||
(1,9), | ||
(2,8), | ||
(3,7), | ||
(4,6), | ||
(5,5), | ||
(6,4), | ||
(7,3), | ||
(8,2), | ||
(9,1), | ||
(10,0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0. | ||
|
||
set -eu | ||
|
||
export DUMPLING_TEST_PORT=4000 | ||
|
||
run_sql "drop database if exists partition_table" | ||
run_sql "create database partition_table DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" | ||
export DUMPLING_TEST_DATABASE=partition_table | ||
|
||
for data in "$DUMPLING_BASE_NAME"/data/*; do | ||
run_sql_file "$data" | ||
done | ||
|
||
run_dumpling | ||
|
||
for file_path in "$DUMPLING_BASE_NAME"/data/*; do | ||
base_name=$(basename "$file_path") | ||
table_name="${base_name%.sql}" | ||
file_should_exist "$DUMPLING_BASE_NAME/result/$table_name.sql" | ||
file_should_exist "$DUMPLING_OUTPUT_DIR/partition_table.$table_name.000000000.sql" | ||
file_should_exist "$DUMPLING_OUTPUT_DIR/partition_table.$table_name-schema.sql" | ||
diff "$DUMPLING_BASE_NAME/result/$table_name.sql" "$DUMPLING_OUTPUT_DIR/partition_table.$table_name.000000000.sql" | ||
diff "$DUMPLING_BASE_NAME/result/$table_name-schema.sql" "$DUMPLING_OUTPUT_DIR/partition_table.$table_name-schema.sql" | ||
done |