File: rpl_transaction_write_set_extraction.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 (329 lines) | stat: -rw-r--r-- 11,866 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# WL#6834 - Group Replication: Extract PKE for certification purposes
#
# This worklog checks for the write set values being generated when group
# replication is in use. The test checks for the values being generted when
# table contains only Primary key, Primary Key and Unique Key and
# Primary Key + Unique Key + Foreign Key constraints.

--source include/have_binlog_format_row.inc
--source include/have_debug.inc
--source include/have_transaction_write_set_extraction.inc
--source include/master-slave.inc

--let $assert_text= The value for transaction_write_set_extraction must be XXHASH64
--let $assert_cond= "[SELECT @@SESSION.transaction_write_set_extraction]" = "XXHASH64"
--source include/assert.inc

# Table with a primary key consisting of a single column with insert and update.

--connection master
CREATE TABLE t1 (a BINARY(1) PRIMARY KEY);
SET @debug_saved= @@GLOBAL.DEBUG;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_insert';
INSERT INTO t1 VALUES(1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_update';
UPDATE t1 SET a=3 WHERE a=1;
SET @@GLOBAL.DEBUG= @debug_saved;
--source include/rpl_sync.inc
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with a primary key consisting of a single invisible column with insert
# and update.

--connection master
CREATE TABLE t1 (a BINARY(1), b BINARY(1) PRIMARY KEY INVISIBLE);
SELECT * FROM t1;
SET @debug_saved= @@GLOBAL.DEBUG;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_insert';
INSERT INTO t1 (a, b) VALUES(0, 1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_update';
UPDATE t1 SET b=3 WHERE b=1;
SET @@GLOBAL.DEBUG= @debug_saved;
--source include/rpl_sync.inc
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with a primary key consisting of more than one column with insert and
# update.

CREATE TABLE t1(a BINARY(1), b BINARY(1), PRIMARY KEY(a, b));
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_key_generated_insert';
INSERT INTO t1 VALUE(1, 2);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_key_generated_update';
UPDATE t1 SET a=3 WHERE a=1;
SET @@GLOBAL.DEBUG= @debug_saved;
--source include/rpl_sync.inc
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with a single primary key and more than one unique key with insert and
# updates.

--connection master
CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1) NOT NULL UNIQUE, c3 BINARY(1) NOT NULL UNIQUE);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_unique_key_generated_insert';
INSERT INTO t1 VALUES (1, 2, 3);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_unique_key_generated_update';
UPDATE t1 SET c1=5 WHERE c1=1;
--source include/rpl_sync.inc
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with a primary key consisting of more than one column and more than one
# unique key with insert and updates.

CREATE TABLE t1 (a BINARY(1), d BINARY(1), b BINARY(1) NOT NULL UNIQUE, c BINARY(1) NOT NULL UNIQUE, PRIMARY KEY(a, d));
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_insert';
INSERT INTO t1 VALUES(1, 2, 3, 4);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_update';
UPDATE t1 SET a=5 WHERE a=1;
SET @@GLOBAL.DEBUG= @debug_saved;
--source include/rpl_sync.inc
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with a primary key consisting of more than columns and more than one
# unique key on invisible columns with insert and updates.

CREATE TABLE t1 (a BINARY(1), d BINARY(1), b BINARY(1) NOT NULL UNIQUE INVISIBLE, c BINARY(1) NOT NULL UNIQUE INVISIBLE, PRIMARY KEY(a, d));
SELECT * FROM t1;
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_insert';
INSERT INTO t1 (a, d, b, c) VALUES (1, 2, 3, 4);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_update';
UPDATE t1 SET a=5 WHERE a=1;
SET @@GLOBAL.DEBUG= @debug_saved;
--source include/rpl_sync.inc
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with Primary Key + Unique Key and Foreign Key

--connection master

CREATE TABLE t1 (a BINARY(1) PRIMARY KEY);
CREATE TABLE t2 (b BINARY(1) PRIMARY KEY);
CREATE TABLE t3 (c1 BINARY(1), c2 BINARY(1) NOT NULL UNIQUE, PRIMARY KEY(c1, c2), FOREIGN KEY(c1) REFERENCES t1(a), FOREIGN KEY(c2) REFERENCES t2(b));

INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (5);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_foreign_key_generated_insert';
INSERT INTO t3 values(1,5);
SET @@GLOBAL.DEBUG= @debug_saved;
INSERT INTO t1 VALUES (3);
--source include/rpl_sync.inc
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_foreign_key_generated_update';
UPDATE t3 SET c1=3 WHERE c1=1;
--source include/rpl_sync.inc
SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t3;
DROP TABLE t2;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with Foreign Key referencing a Unique Key

--connection master

CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1), UNIQUE KEY(c2));
CREATE TABLE t2 (x1 BINARY(1) PRIMARY KEY, x2 BINARY(1), FOREIGN KEY (x2) REFERENCES t1(c2));

INSERT INTO t1 VALUES (1,1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_parent_generated_insert';
INSERT INTO t1 VALUES (2,2);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_insert';
INSERT INTO t2 VALUES (1,1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_update';
UPDATE t2 SET x2=2 WHERE x1=1;
SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t2;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with Foreign Key on an invisible column referencing a Unique
# Key on an invisible column.

--connection master

CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1) INVISIBLE, UNIQUE KEY(c2));
SELECT * FROM t1;
CREATE TABLE t2 (x1 BINARY(1) PRIMARY KEY, x2 BINARY(1) INVISIBLE, FOREIGN KEY (x2) REFERENCES t1(c2));
SELECT * FROM t2;

INSERT INTO t1 (c1, c2) VALUES (1,1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_parent_generated_insert';
INSERT INTO t1 (c1, c2) VALUES (2,2);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_insert';
INSERT INTO t2 (x1, x2) VALUES (1,1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_update';
UPDATE t2 SET x2=2 WHERE x1=1;
SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t2;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with Foreign Key referencing a NON Unique Key

--connection master

CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1), KEY(c2));
CREATE TABLE t2 (x1 BINARY(1) PRIMARY KEY, x2 BINARY(1), FOREIGN KEY (x2) REFERENCES t1(c2));

INSERT INTO t1 VALUES (1,1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_non_unique_key_parent_generated_insert';
INSERT INTO t1 VALUES (2,2);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_non_unique_key_generated_insert';
INSERT INTO t2 VALUES (1,1);
SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_non_unique_key_generated_update';
UPDATE t2 SET x2=2 WHERE x1=1;
SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t2;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with multi column primary key and a foreign key to the multi column primary key

--connection master

CREATE TABLE t1(a BINARY(1), b BINARY(1), c BINARY(1), PRIMARY KEY (a,b,c));
CREATE TABLE t2(d BINARY(1), e BINARY(1), f BINARY(1), PRIMARY KEY (d,e,f), CONSTRAINT foreign_key_t2_t1 FOREIGN KEY (d,e,f) REFERENCES t1(a,b,c));

INSERT INTO t1 VALUES (1,2,3);
INSERT INTO t1 VALUES (4,2,3);

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_primary_key_insert';
INSERT INTO t2 VALUES (1,2,3);

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_primary_key_update';
UPDATE t2 SET d=4 WHERE d=1;

SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t2;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with multi column unique key and a foreign key to the multi column unique key

--connection master

CREATE TABLE t1 (a BINARY(1) PRIMARY KEY, b BINARY(1) NOT NULL, c BINARY(1) NOT NULL, UNIQUE KEY key_b_c(b,c));
CREATE TABLE t2 (d BINARY(1) PRIMARY KEY, e BINARY(1) NOT NULL, f BINARY(1) NOT NULL, UNIQUE KEY key_e_f(e,f), FOREIGN KEY(e,f) REFERENCES t1(b,c));

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_column_unique_key_insert';
INSERT INTO t1 VALUES (1,2,3);
SET @@GLOBAL.DEBUG= @debug_saved;
INSERT INTO t1 VALUES (4,5,6);

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_unique_key_insert';
INSERT INTO t2 VALUES (1,2,3);

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_unique_key_update';
UPDATE t2 SET d=4,e=5,f=6 WHERE d=1;

SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t2;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with single primary key part

--connection master

CREATE TABLE t1(a VARCHAR(64), PRIMARY KEY(a(4)));
INSERT INTO t1 VALUES ('aaaaxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_part_insert';
INSERT INTO t1 VALUES ('ddddxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_part_update';
UPDATE t1 SET a = 'bbbbxxxx' WHERE a = 'ddddxxxx';

SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with multiple primary key part

--connection master

CREATE TABLE t1(a VARCHAR(64), b VARCHAR(64), PRIMARY KEY(a(4), b(4)));
INSERT INTO t1 VALUES ('aaaaxxxx', 'bbbbxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_primary_key_part_insert';
INSERT INTO t1 VALUES ('aaaaxxxx', 'ccccxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_primary_key_part_update';
UPDATE t1 SET b = 'ddddxxxx' WHERE b = 'ccccxxxx';

SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with single unique key part

--connection master

CREATE TABLE t1(p BINARY, a VARCHAR(64), PRIMARY KEY(p), UNIQUE KEY(a(4)));
INSERT INTO t1 VALUES (1, 'aaaaxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_unique_key_part_insert';
INSERT INTO t1 VALUES (2, 'bbbbxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_unique_key_part_update';
UPDATE t1 SET a = 'ddddxxxx' WHERE a = 'bbbbxxxx';

SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t1;
--source include/rpl_sync.inc

# Table with multiple unique key part

--connection master

CREATE TABLE t1(p BINARY, a VARCHAR(64), b VARCHAR(64), PRIMARY KEY(p), UNIQUE KEY(a(4), b(4)));
INSERT INTO t1 VALUES (1, 'aaaaxxxx', 'bbbbxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_unique_key_part_insert';
INSERT INTO t1 VALUES (2, 'aaaaxxxx', 'ccccxxxx');

SET @@GLOBAL.DEBUG= @debug_saved;
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_unique_key_part_update';
UPDATE t1 SET b = 'ddddxxxx' WHERE b = 'ccccxxxx';

SET @@GLOBAL.DEBUG= @debug_saved;
DROP TABLE t1;
--source include/rpl_sync.inc

--source include/rpl_end.inc