File: gr_storage_engines.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (112 lines) | stat: -rw-r--r-- 3,860 bytes parent folder | download
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
################################################################################
# The aim of this test is to verify that Group Replication successfully
# blocks DML's on non-transactional tables.
#
# 0. Start a server with Group Replication
# 1. Create tables with different storage engines, this should not be blocked
#    (INNODB, CSV, MyISAM, MEMORY, ARCHIVE, BLACKHOLE, MRG_MyISAM)
# 2. Perform DML's on non-transactional tables, the instructions should FAIL.
# 3. Execute a DML(INSERT..SELECT) on innodb table where select is from
#    non-transactional table. The instruction should FAIL.
# 4. Alter the non-transactional table's engine to INNODB and execute
#    DML(INSERT..SELECT) again. This time instruction should SUCCEED.
# 5. Clean-up
#
################################################################################

--source include/have_group_replication_plugin.inc

--source include/group_replication.inc

--connection server1
--echo Create tables with different storage engines, Group Replication should not block this.

USE test;
# Create table with INNODB
CREATE TABLE tn (c1 int PRIMARY KEY, c2 int) ENGINE=INNODB;

# Create table with CSV
CREATE TABLE t1 (c1 int not null, c2 int not null) ENGINE=CSV;

# Create table with MyISAM
CREATE TABLE t2 (c1 int PRIMARY KEY, c2 int) ENGINE=MyISAM;

# Create table with MEMORY
CREATE TABLE t3 (c1 int PRIMARY KEY, c2 int) ENGINE=MEMORY;

# Create table with ARCHIVE
CREATE TABLE t4 (c1 int, c2 int) ENGINE=ARCHIVE;

# Create table with BLACKHOLE
CREATE TABLE t5 (c1 int PRIMARY KEY, c2 int) ENGINE=BLACKHOLE;

# Create table with MRG_MyISAM
CREATE TABLE t6 (C1 INT PRIMARY KEY, c2 int) ENGINE=MERGE UNION=(t2) INSERT_METHOD=LAST;

--echo
--echo Group Replication Should block DML's on non-transactional tables
--echo

--let $tables_count= 6
while ($tables_count)
{
  # These statements are expected to fail with ER_BEFORE_DML_VALIDATION_ERROR.
  # The ARCHIVE storage engine is an exception, as it rejects UPDATE and DELETE
  # statements with ER_ILLEGAL_HA during resolving.
  --let $update_delete_error = ER_BEFORE_DML_VALIDATION_ERROR
  if ($tables_count == 4) {
    --let $update_delete_error = ER_ILLEGAL_HA
  }

  # Test the INSERT instruction
  --error ER_BEFORE_DML_VALIDATION_ERROR
  --eval INSERT INTO t$tables_count (c1,c2) VALUES(1, 2)
  --eval INSERT INTO tn (c1) VALUES ($tables_count+10)

  # Test the UPDATE instruction
  --error $update_delete_error
  --eval UPDATE t$tables_count SET c2= 100

  # Test the REPLACE instructions
  --error ER_BEFORE_DML_VALIDATION_ERROR
  --eval REPLACE INTO t$tables_count(c1) VALUES(2)

  # Test the REPLACE...SELECT instruction
  --error ER_BEFORE_DML_VALIDATION_ERROR
  --eval REPLACE INTO t$tables_count (c1) SELECT tn.c1 FROM tn

  # Test the UPDATE_MULTI instruction
  --error $update_delete_error
  --eval UPDATE t$tables_count, tn SET t$tables_count.c1= 100, tn.c1= 100

  # Test the DELETE instruction
  --error $update_delete_error
  --eval DELETE FROM t$tables_count

  --eval DELETE FROM tn
  --dec $tables_count
}

--echo Check that INSERT...SELECT statement on InnoDB table(tn) from a non-transactional table(Eg:MyISAM t2) fails
--error ER_BEFORE_DML_VALIDATION_ERROR
INSERT INTO tn (c1) SELECT (t2.c1) FROM t2;

--echo change storage engine to "InnoDB" on t2 and check INSERT...SELECT on tn succeeds
ALTER TABLE t2 ENGINE=INNODB;
INSERT INTO tn (c1) SELECT (t2.c1) FROM t2;

# clean up
DROP TABLE tn;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
DROP TABLE t4;
DROP TABLE t5;
DROP TABLE t6;

SET SESSION sql_log_bin= 0;
call mtr.add_suppression("Table.*does not have any PRIMARY KEY. This is not compatible with Group Replication.");
call mtr.add_suppression("Table.*does not use the InnoDB storage engine. This is not compatible with Group Replication.");
SET SESSION sql_log_bin= 1;

--source include/group_replication_end.inc