| 1 |
################################################################################ |
| 2 |
# Validate that Group Replication pre-conditions are |
| 3 |
# properly checked, in particular the existence of primary |
| 4 |
# key on tables. |
| 5 |
# |
| 6 |
# Test: |
| 7 |
# 0. The test requires two servers: M1 and M2. |
| 8 |
# 1. With both the members ONLINE. Create a table t1 without primary key on M1. |
| 9 |
# Sync data in the group. |
| 10 |
# 2. Execute a query on the table on M1 that will fail on pre-conditions check. |
| 11 |
# 3. Check that table t1 is empty on M1. |
| 12 |
# 4. Check that table t1 is empty on M2. |
| 13 |
# 5. Clean up. |
| 14 |
################################################################################ |
| 15 |
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420003 |
| 16 |
--source include/have_group_replication_plugin.inc |
| 17 |
--source include/group_replication.inc |
| 18 |
|
| 19 |
|
| 20 |
--echo |
| 21 |
--echo ############################################################ |
| 22 |
--echo # 1. Create the test table without primary key on all group |
| 23 |
--echo # members. |
| 24 |
--connection server1 |
| 25 |
|
| 26 |
CREATE TABLE `t1` ( |
| 27 |
`col_bit_64` bit(64), |
| 28 |
`col_varchar_255_utf8_key` varchar(255) CHARACTER SET utf8, |
| 29 |
`col_bigint` bigint, |
| 30 |
`col_varchar_255_binary_key` varchar(255) CHARACTER SET binary, |
| 31 |
`col_varchar_255_utf8` varchar(255) CHARACTER SET utf8, |
| 32 |
`col_text_utf8` text CHARACTER SET utf8, |
| 33 |
`col_set_binary_key` set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET binary, |
| 34 |
`col_text_binary` text CHARACTER SET binary, |
| 35 |
`col_varchar_255_binary` varchar(255) CHARACTER SET binary, |
| 36 |
`col_bigint_key` bigint, |
| 37 |
`col_set_utf8` set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8, |
| 38 |
`col_text_binary_key` text CHARACTER SET binary, |
| 39 |
`col_set_binary` set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET binary, |
| 40 |
`col_set_utf8_key` set ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z') CHARACTER SET utf8, |
| 41 |
`col_text_utf8_key` text CHARACTER SET utf8, |
| 42 |
`col_bit_64_key` bit(64), |
| 43 |
key (`col_varchar_255_utf8_key`), |
| 44 |
key (`col_varchar_255_binary_key`), |
| 45 |
key (`col_set_binary_key`), |
| 46 |
key (`col_bigint_key`), |
| 47 |
key (`col_text_binary_key`(255)), |
| 48 |
key (`col_set_utf8_key`), |
| 49 |
key (`col_text_utf8_key` (255)), |
| 50 |
key (`col_bit_64_key`) |
| 51 |
) ENGINE=InnoDB; |
| 52 |
--source include/rpl_sync.inc |
| 53 |
|
| 54 |
--echo |
| 55 |
--echo ############################################################ |
| 56 |
--echo # 2. Execute a query on the table without primary key on |
| 57 |
--echo # server 1 that will fail on pre-conditions check. |
| 58 |
--connection server1 |
| 59 |
|
| 60 |
SET SESSION sql_log_bin= 0; |
| 61 |
call mtr.add_suppression("Plugin group_replication reported: 'Table t1 does not have any PRIMARY KEY. This is not compatible with Group Replication.'"); |
| 62 |
SET SESSION sql_log_bin= 1; |
| 63 |
|
| 64 |
--error ER_BEFORE_DML_VALIDATION_ERROR |
| 65 |
INSERT /*! IGNORE */ INTO t1 VALUES (NULL, NULL, -1188668826649100288, 'x', NULL, 'can\'t', 'p', 'didn\'t', 'we', 8, 'what', 'who', NULL, 'can', 'not', 1); |
| 66 |
|
| 67 |
|
| 68 |
--echo |
| 69 |
--echo ############################################################ |
| 70 |
--echo # 3. Check that table t1 is empty on server 1. |
| 71 |
--connection server1 |
| 72 |
--let $assert_text= 'Table t1 is empty' |
| 73 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0 |
| 74 |
--source include/assert.inc |
| 75 |
|
| 76 |
|
| 77 |
--echo |
| 78 |
--echo ############################################################ |
| 79 |
--echo # 4. Check that table t1 is empty on server 2. |
| 80 |
--connection server2 |
| 81 |
--let $assert_text= 'Table t1 is empty' |
| 82 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0 |
| 83 |
--source include/assert.inc |
| 84 |
|
| 85 |
|
| 86 |
--echo |
| 87 |
--echo ############################################################ |
| 88 |
--echo # 5. Clean data. |
| 89 |
--connection server1 |
| 90 |
DROP TABLE t1; |
| 91 |
|
| 92 |
--source include/group_replication_end.inc |