| 1 |
################################################################################ |
| 2 |
# The aim of this test is to verify that Group Replication does not affect |
| 3 |
# partitioning of tables. |
| 4 |
# |
| 5 |
# 0. Start 3 servers with Group Replication |
| 6 |
# 1. Create a table with "list" partition. |
| 7 |
# 2. Perform few DMLs on the table and check it is replicated properly on other servers. |
| 8 |
# 3. Clean-up |
| 9 |
################################################################################ |
| 10 |
|
| 11 |
--source include/big_test.inc |
| 12 |
--source include/have_group_replication_plugin.inc |
| 13 |
|
| 14 |
--let $rpl_server_count= 3 |
| 15 |
--source include/group_replication.inc |
| 16 |
|
| 17 |
--let $rpl_connection_name= server1 |
| 18 |
--source include/rpl_connection.inc |
| 19 |
--echo ## List Partitioning ## |
| 20 |
CREATE TABLE t1 (id int PRIMARY KEY, c2 int) |
| 21 |
CHARSET=utf8mb4 |
| 22 |
PARTITION BY LIST (id) |
| 23 |
(PARTITION p1 VALUES in (5, 10, 15), |
| 24 |
PARTITION p2 VALUES in (2, 3), |
| 25 |
PARTITION p3 VALUES in (11, 21)); |
| 26 |
|
| 27 |
--source include/rpl_sync.inc |
| 28 |
|
| 29 |
--let $rpl_connection_name= server2 |
| 30 |
--source include/rpl_connection.inc |
| 31 |
|
| 32 |
SHOW CREATE TABLE t1; |
| 33 |
# Insert some values into table |
| 34 |
# This record should belong to partition p1 |
| 35 |
INSERT INTO t1 VALUES (05, 2); |
| 36 |
|
| 37 |
# This record should belong to partition p1 |
| 38 |
INSERT INTO t1 VALUES (10, 5); |
| 39 |
|
| 40 |
# This record should belong to partition p2 |
| 41 |
INSERT INTO t1 VALUES (03, 1); |
| 42 |
|
| 43 |
# This should throw an error as the value is not defined in any partition of t2 |
| 44 |
--error ER_NO_PARTITION_FOR_GIVEN_VALUE |
| 45 |
INSERT INTO t1 VALUES (100, 50); |
| 46 |
|
| 47 |
--source include/rpl_sync.inc |
| 48 |
|
| 49 |
--let $rpl_connection_name= server1 |
| 50 |
--source include/rpl_connection.inc |
| 51 |
|
| 52 |
# Perform some DMLs |
| 53 |
# This record should belong to partition p3 |
| 54 |
INSERT INTO t1 VALUES (11, 5); |
| 55 |
|
| 56 |
# This record should belong to partition p3 |
| 57 |
INSERT INTO t1 VALUES (21, 10); |
| 58 |
|
| 59 |
DELETE FROM t1 WHERE id= 5; |
| 60 |
|
| 61 |
--source include/rpl_sync.inc |
| 62 |
|
| 63 |
--let $rpl_connection_name= server3 |
| 64 |
--source include/rpl_connection.inc |
| 65 |
|
| 66 |
# Validate record counts |
| 67 |
# Assert that partition p1 has 1 row. |
| 68 |
--let $assert_text= 'Check that partition p1 on table t1 has 1 row' |
| 69 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p1), count, 1]= 1 |
| 70 |
--source include/assert.inc |
| 71 |
|
| 72 |
# Assert that partition p2 has 1 row. |
| 73 |
--let $assert_text= 'Check that partition p2 on table t1 has 1 row' |
| 74 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p2), count, 1]= 1 |
| 75 |
--source include/assert.inc |
| 76 |
|
| 77 |
# Assert that partition p3 has 2 rows. |
| 78 |
--let $assert_text= 'Check that partition p3 on table t1 has 2 rows' |
| 79 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 PARTITION (p3), count, 1]= 2 |
| 80 |
--source include/assert.inc |
| 81 |
|
| 82 |
# Clean-up |
| 83 |
DROP TABLE t1; |
| 84 |
--source include/rpl_sync.inc |
| 85 |
|
| 86 |
--source include/group_replication_end.inc |