Debian Codegraph @

mysql-test/suite/group_replication/t/gr_create_table_as_select.test

raw
1 ################################################################################
2 # Validate the behaviour of 'CREATE TABLE ... AS SELECT' with respect to
3 # write-set parallel applier.
4 #
5 # 1. Create a table using select statement from a empty table.
6 # 2. Create a table using select statement from a non empty table.
7 # 3. Verify that we fail to execution DML on table without PK.
8 # 4. Assert parallel applier indexes.
9 # 5. Check data consistency.
10 # 6. Clean-up
11 ################################################################################
12 --source include/have_group_replication_plugin.inc
13 --source include/group_replication.inc
14
15 SET SESSION sql_log_bin= 0;
16 call mtr.add_suppression("Plugin group_replication reported: 'Table t5 does not have any PRIMARY KEY. This is not compatible with Group Replication.'");
17 SET SESSION sql_log_bin= 1;
18
19 --echo
20 --echo ############################################################
21 --echo # 1. Create a table using select statement from a empty table.
22 --let $rpl_connection_name= server1
23 --source include/rpl_connection.inc
24 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
25 CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) AS SELECT * FROM t1;
26 INSERT INTO t2 VALUES (1);
27
28
29 --echo
30 --echo ############################################################
31 --echo # 2. Create a table using select statement from a non empty table.
32 --let $rpl_connection_name= server1
33 --source include/rpl_connection.inc
34 CREATE TABLE t3 (c1 INT NOT NULL PRIMARY KEY);
35 INSERT INTO t3 VALUES (1);
36 CREATE TABLE t4 (c1 INT NOT NULL PRIMARY KEY) AS SELECT * FROM t3;
37 INSERT INTO t4 VALUES (2);
38
39
40 --echo
41 --echo # 3. Verify that we fail to execution DML on table without PK.
42 --echo ############################################################
43 --error ER_BEFORE_DML_VALIDATION_ERROR
44 CREATE TABLE t5 (c1 INT NOT NULL) AS SELECT * FROM t3;
45 --echo # Allow table creation when there is no DML executed.
46 CREATE TABLE t5 (c1 INT NOT NULL) AS SELECT * FROM t1;
47
48
49 --echo
50 --echo # 4. Assert parallel applier indexes.
51 --echo ############################################################
52 --source include/rpl_sync.inc
53 --let $rpl_connection_name= server2
54 --source include/rpl_connection.inc
55 --let $binlog_file= server-relay-log-group_replication_applier.000002
56 --let $logical_timestamps= 0 0;1 2;2 3;3 4;4 5;5 6;6 7;7 8;8 9
57 --source include/assert_logical_timestamps.inc
58 --let $is_relay_log= 1
59 --source include/assert_transaction_length.inc
60
61
62 --echo
63 --echo ############################################################
64 --echo # 5. Check data consistency.
65 --let $diff_tables=server1:test.t1 ,server2:test.t1
66 --source include/diff_tables.inc
67 --let $diff_tables=server1:test.t2 ,server2:test.t2
68 --source include/diff_tables.inc
69 --let $diff_tables=server1:test.t3 ,server2:test.t3
70 --source include/diff_tables.inc
71 --let $diff_tables=server1:test.t4 ,server2:test.t4
72 --source include/diff_tables.inc
73
74
75 --echo
76 --echo ############################################################
77 --echo # 5. Clean-up
78 --let $rpl_connection_name= server1
79 --source include/rpl_connection.inc
80 DROP TABLE t1;
81 DROP TABLE t2;
82 DROP TABLE t3;
83 DROP TABLE t4;
84 DROP TABLE t5;
85
86 --source include/group_replication_end.inc