-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathgr_DML_error.test
86 lines (69 loc) · 2.59 KB
/
gr_DML_error.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
################################################################################
# This test verifies the DML errors when replicating in a group
#
# Test:
# 0. The test requires two servers: M1 and M2.
# 1. With both members ONLINE. Create two tables. Insert data in each table.
# 2. Now verify that DML(INSERT/UPDATE) operations with duplicate data, error
# out gracefully. Thus, nothing is inserted/updated in such cases. Verify
# the data on both the members M1 and M2.
################################################################################
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc
--echo # Verify the statements can be binlogged correctly when error happens
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE t2(c1 INT PRIMARY KEY) ENGINE=innodb;
INSERT INTO t1 VALUES(1);
INSERT INTO t2 VALUES(1);
--echo
--echo # Nothing is inserted.
--let $binlog_start= query_get_value(SHOW BINARY LOG STATUS, Position, 1)
--error 1062
INSERT INTO t1 VALUES(1),(2);
source include/rpl/deprecated/show_binlog_events.inc;
--let $assert_text= No new row inserted in the table
--let $assert_cond= [SELECT count(*) FROM t1] = 1
--source include/assert.inc
--source include/rpl/sync.inc
--let $diff_tables= server1:test.t1, server2:test.t1
--source include/diff_tables.inc
--echo
--echo # Nothing is inserted.
--connection server1
--let $binlog_start= query_get_value(SHOW BINARY LOG STATUS, Position, 1)
--error 1062
INSERT INTO t1 SELECT 1 UNION SELECT 2;
--source include/rpl/deprecated/show_binlog_events.inc
# The row count will still be 1
--let $assert_text= The row count will still be 1
--let $assert_cond= [SELECT count(*) FROM t1] = 1
--source include/assert.inc
--echo # 2 rows are inserted.
INSERT INTO t1 SELECT 3 UNION SELECT 2;
--source include/rpl/sync.inc
# The row count will be 3
--let $assert_text= A row is inserted in the table t1
--let $assert_cond= [SELECT count(*) FROM t1] = 3
--source include/assert.inc
--source include/diff_tables.inc
--echo
--echo # Nothing is updated.
--connection server1
--let $binlog_start= query_get_value(SHOW BINARY LOG STATUS, Position, 1)
--error 1062
UPDATE t1 SET c1=4;
--source include/rpl/sync.inc
--connection server1
--source include/diff_tables.inc
--source include/rpl/deprecated/show_binlog_events.inc
--echo
--echo # Nothing is updated.
--connection server1
--error 1062
UPDATE t1, t2 SET t1.c1= 5, t2.c1=5;
--source include/rpl/sync.inc
--connection server1
--source include/diff_tables.inc
--source include/rpl/deprecated/show_binlog_events.inc
DROP TABLE t1, t2;
--source include/group_replication_end.inc