-
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, lightning: add partition table test cases (#57619)
close #57623
- Loading branch information
1 parent
bc03ed8
commit 6e22b8c
Showing
19 changed files
with
196 additions
and
37 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,16 @@ | ||
create table `pt_case_2` (a int, b int, unique index idx(a) global) partition by range(b) | ||
(partition p0 values less than (4), | ||
partition p1 values less than (7), | ||
partition p2 values less than (11)); | ||
insert into `pt_case_2` 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); |
11 changes: 11 additions & 0 deletions
11
dumpling/tests/partition_table/result/pt_case_2-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_2` ( | ||
`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 RANGE (`b`) | ||
(PARTITION `p0` VALUES LESS THAN (4), | ||
PARTITION `p1` VALUES LESS THAN (7), | ||
PARTITION `p2` VALUES LESS THAN (11)); |
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_2` 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 2024 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 |
2 changes: 1 addition & 1 deletion
2
lightning/tests/lightning_partitioned-table/data/partitioned.a-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 |
---|---|---|
@@ -1 +1 @@ | ||
create table a (a int, b varchar(16), KEY key_b (`b`)) partition by hash(a) partitions 5; | ||
create table a (a int, b varchar(16), c int, KEY key_b (`b`), unique index key_c(c) global) partition by hash(a) partitions 5; |
16 changes: 8 additions & 8 deletions
16
lightning/tests/lightning_partitioned-table/data/partitioned.a.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
insert into a values | ||
(268435456, '268435456'), | ||
(1, 'adgagdadgagag'), | ||
(262144, 'gadgagaha'), | ||
(32, '32'), | ||
(4, 'hahaha'), | ||
(65536, 'luck dog'), | ||
(8388608, 'heyhey'), | ||
(0, '999'); | ||
(268435456, '268435456', 268435456), | ||
(1, 'adgagdadgagag', 1), | ||
(262144, 'gadgagaha', 262144), | ||
(32, '32', 32), | ||
(4, 'hahaha', 4), | ||
(65536, 'luck dog', 65536), | ||
(8388608, 'heyhey', 8388608), | ||
(0, '999', 0); | ||
|
2 changes: 1 addition & 1 deletion
2
lightning/tests/lightning_partitioned-table/data/partitioned.defaultlist-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 |
---|---|---|
@@ -1 +1 @@ | ||
create table `defaultlist` (a int, b varchar(16), KEY key_b (`b`)) partition by list(a) (partition p1 values in (1,4,8),partition p2 values in (32,default), partition p3 values in (262144,65536)); | ||
create table `defaultlist` (a int, b varchar(16), c int, KEY key_b (`b`), unique index key_c(`c`) global) partition by list(a) (partition p1 values in (1,4,8),partition p2 values in (32,default), partition p3 values in (262144,65536)); |
17 changes: 8 additions & 9 deletions
17
lightning/tests/lightning_partitioned-table/data/partitioned.defaultlist.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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
insert into defaultlist values | ||
(268435456, '268435456'), | ||
(1, 'adgagdadgagag'), | ||
(262144, 'gadgagaha'), | ||
(32, '32'), | ||
(4, 'hahaha'), | ||
(65536, 'luck dog'), | ||
(8388608, 'heyhey'), | ||
(0, '999'); | ||
|
||
(268435456, '268435456', 268435456), | ||
(1, 'adgagdadgagag', 1), | ||
(262144, 'gadgagaha', 262144), | ||
(32, '32', 32), | ||
(4, 'hahaha', 4), | ||
(65536, 'luck dog', 65536), | ||
(8388608, 'heyhey', 8388608), | ||
(0, '999', 0); |
2 changes: 1 addition & 1 deletion
2
lightning/tests/lightning_partitioned-table/data/partitioned.list-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 |
---|---|---|
@@ -1 +1 @@ | ||
create table `list` (a int, b varchar(16), KEY key_b (`b`)) partition by list(a) (partition p1 values in (1,4,8),partition p2 values in (32,8388608,268435456), partition p3 values in (262144,0,65536)); | ||
create table `list` (a int, b varchar(16), c int, KEY key_b (`b`), unique index key_c(`c`) global) partition by list(a) (partition p1 values in (1,4,8),partition p2 values in (32,8388608,268435456), partition p3 values in (262144,0,65536)); |
16 changes: 8 additions & 8 deletions
16
lightning/tests/lightning_partitioned-table/data/partitioned.list.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
insert into list values | ||
(268435456, '268435456'), | ||
(1, 'adgagdadgagag'), | ||
(262144, 'gadgagaha'), | ||
(32, '32'), | ||
(4, 'hahaha'), | ||
(65536, 'luck dog'), | ||
(8388608, 'heyhey'), | ||
(0, '999'); | ||
(268435456, '268435456', 268435456), | ||
(1, 'adgagdadgagag', 1), | ||
(262144, 'gadgagaha', 262144), | ||
(32, '32', 32), | ||
(4, 'hahaha', 4), | ||
(65536, 'luck dog', 65536), | ||
(8388608, 'heyhey', 8388608), | ||
(0, '999', 0); | ||
|
2 changes: 1 addition & 1 deletion
2
lightning/tests/lightning_partitioned-table/data/partitioned.range-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 |
---|---|---|
@@ -1 +1 @@ | ||
create table `range` (a int, b varchar(16), KEY key_b (`b`)) partition by range(a) (partition pNeg values less than (0), partition pMax values less than (maxvalue)); | ||
create table `range` (a int, b varchar(16), c int, KEY key_b (`b`), unique index key_c(`c`) global) partition by range(a) (partition pNeg values less than (0), partition pMax values less than (maxvalue)); |
16 changes: 8 additions & 8 deletions
16
lightning/tests/lightning_partitioned-table/data/partitioned.range.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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
insert into range values | ||
(268435456, '268435456'), | ||
(1, 'adgagdadgagag'), | ||
(262144, 'gadgagaha'), | ||
(32, '32'), | ||
(4, 'hahaha'), | ||
(65536, 'luck dog'), | ||
(8388608, 'heyhey'), | ||
(0, '999'); | ||
(268435456, '268435456', 268435456), | ||
(1, 'adgagdadgagag', 1), | ||
(262144, 'gadgagaha', 262144), | ||
(32, '32', 32), | ||
(4, 'hahaha', 4), | ||
(65536, 'luck dog', 65536), | ||
(8388608, 'heyhey', 8388608), | ||
(0, '999', 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