| 1 |
# WL#6834 - Group Replication: Extract PKE for certification purposes |
| 2 |
# |
| 3 |
# This worklog checks for the write set values being generated when group |
| 4 |
# replication is in use. The test checks for the values being generted when |
| 5 |
# table contains only Primary key, Primary Key and Unique Key and |
| 6 |
# Primary Key + Unique Key + Foreign Key constraints. |
| 7 |
|
| 8 |
--source include/have_binlog_format_row.inc |
| 9 |
--source include/have_debug.inc |
| 10 |
--source include/have_transaction_write_set_extraction.inc |
| 11 |
--source include/master-slave.inc |
| 12 |
|
| 13 |
--let $assert_text= The value for transaction_write_set_extraction must be XXHASH64 |
| 14 |
--let $assert_cond= "[SELECT @@SESSION.transaction_write_set_extraction]" = "XXHASH64" |
| 15 |
--source include/assert.inc |
| 16 |
|
| 17 |
# Table with a primary key consisting of a single column with insert and update. |
| 18 |
|
| 19 |
--connection master |
| 20 |
CREATE TABLE t1 (a BINARY(1) PRIMARY KEY); |
| 21 |
SET @debug_saved= @@GLOBAL.DEBUG; |
| 22 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_insert'; |
| 23 |
INSERT INTO t1 VALUES(1); |
| 24 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 25 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_update'; |
| 26 |
UPDATE t1 SET a=3 WHERE a=1; |
| 27 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 28 |
--source include/rpl_sync.inc |
| 29 |
DROP TABLE t1; |
| 30 |
--source include/rpl_sync.inc |
| 31 |
|
| 32 |
# Table with a primary key consisting of a single invisible column with insert |
| 33 |
# and update. |
| 34 |
|
| 35 |
--connection master |
| 36 |
CREATE TABLE t1 (a BINARY(1), b BINARY(1) PRIMARY KEY INVISIBLE); |
| 37 |
SELECT * FROM t1; |
| 38 |
SET @debug_saved= @@GLOBAL.DEBUG; |
| 39 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_insert'; |
| 40 |
INSERT INTO t1 (a, b) VALUES(0, 1); |
| 41 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 42 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_generated_update'; |
| 43 |
UPDATE t1 SET b=3 WHERE b=1; |
| 44 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 45 |
--source include/rpl_sync.inc |
| 46 |
DROP TABLE t1; |
| 47 |
--source include/rpl_sync.inc |
| 48 |
|
| 49 |
# Table with a primary key consisting of more than one column with insert and |
| 50 |
# update. |
| 51 |
|
| 52 |
CREATE TABLE t1(a BINARY(1), b BINARY(1), PRIMARY KEY(a, b)); |
| 53 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 54 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_key_generated_insert'; |
| 55 |
INSERT INTO t1 VALUE(1, 2); |
| 56 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 57 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_key_generated_update'; |
| 58 |
UPDATE t1 SET a=3 WHERE a=1; |
| 59 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 60 |
--source include/rpl_sync.inc |
| 61 |
DROP TABLE t1; |
| 62 |
--source include/rpl_sync.inc |
| 63 |
|
| 64 |
# Table with a single primary key and more than one unique key with insert and |
| 65 |
# updates. |
| 66 |
|
| 67 |
--connection master |
| 68 |
CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1) NOT NULL UNIQUE, c3 BINARY(1) NOT NULL UNIQUE); |
| 69 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 70 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_unique_key_generated_insert'; |
| 71 |
INSERT INTO t1 VALUES (1, 2, 3); |
| 72 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 73 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_unique_key_generated_update'; |
| 74 |
UPDATE t1 SET c1=5 WHERE c1=1; |
| 75 |
--source include/rpl_sync.inc |
| 76 |
DROP TABLE t1; |
| 77 |
--source include/rpl_sync.inc |
| 78 |
|
| 79 |
# Table with a primary key consisting of more than one column and more than one |
| 80 |
# unique key with insert and updates. |
| 81 |
|
| 82 |
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)); |
| 83 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 84 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_insert'; |
| 85 |
INSERT INTO t1 VALUES(1, 2, 3, 4); |
| 86 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 87 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_update'; |
| 88 |
UPDATE t1 SET a=5 WHERE a=1; |
| 89 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 90 |
--source include/rpl_sync.inc |
| 91 |
DROP TABLE t1; |
| 92 |
--source include/rpl_sync.inc |
| 93 |
|
| 94 |
# Table with a primary key consisting of more than columns and more than one |
| 95 |
# unique key on invisible columns with insert and updates. |
| 96 |
|
| 97 |
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)); |
| 98 |
SELECT * FROM t1; |
| 99 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 100 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_insert'; |
| 101 |
INSERT INTO t1 (a, d, b, c) VALUES (1, 2, 3, 4); |
| 102 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 103 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_primary_unique_key_generated_update'; |
| 104 |
UPDATE t1 SET a=5 WHERE a=1; |
| 105 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 106 |
--source include/rpl_sync.inc |
| 107 |
DROP TABLE t1; |
| 108 |
--source include/rpl_sync.inc |
| 109 |
|
| 110 |
# Table with Primary Key + Unique Key and Foreign Key |
| 111 |
|
| 112 |
--connection master |
| 113 |
|
| 114 |
CREATE TABLE t1 (a BINARY(1) PRIMARY KEY); |
| 115 |
CREATE TABLE t2 (b BINARY(1) PRIMARY KEY); |
| 116 |
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)); |
| 117 |
|
| 118 |
INSERT INTO t1 VALUES (1); |
| 119 |
INSERT INTO t2 VALUES (5); |
| 120 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 121 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_foreign_key_generated_insert'; |
| 122 |
INSERT INTO t3 values(1,5); |
| 123 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 124 |
INSERT INTO t1 VALUES (3); |
| 125 |
--source include/rpl_sync.inc |
| 126 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_foreign_key_generated_update'; |
| 127 |
UPDATE t3 SET c1=3 WHERE c1=1; |
| 128 |
--source include/rpl_sync.inc |
| 129 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 130 |
DROP TABLE t3; |
| 131 |
DROP TABLE t2; |
| 132 |
DROP TABLE t1; |
| 133 |
--source include/rpl_sync.inc |
| 134 |
|
| 135 |
# Table with Foreign Key referencing a Unique Key |
| 136 |
|
| 137 |
--connection master |
| 138 |
|
| 139 |
CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1), UNIQUE KEY(c2)); |
| 140 |
CREATE TABLE t2 (x1 BINARY(1) PRIMARY KEY, x2 BINARY(1), FOREIGN KEY (x2) REFERENCES t1(c2)); |
| 141 |
|
| 142 |
INSERT INTO t1 VALUES (1,1); |
| 143 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 144 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_parent_generated_insert'; |
| 145 |
INSERT INTO t1 VALUES (2,2); |
| 146 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 147 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_insert'; |
| 148 |
INSERT INTO t2 VALUES (1,1); |
| 149 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 150 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_update'; |
| 151 |
UPDATE t2 SET x2=2 WHERE x1=1; |
| 152 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 153 |
DROP TABLE t2; |
| 154 |
DROP TABLE t1; |
| 155 |
--source include/rpl_sync.inc |
| 156 |
|
| 157 |
# Table with Foreign Key on an invisible column referencing a Unique |
| 158 |
# Key on an invisible column. |
| 159 |
|
| 160 |
--connection master |
| 161 |
|
| 162 |
CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1) INVISIBLE, UNIQUE KEY(c2)); |
| 163 |
SELECT * FROM t1; |
| 164 |
CREATE TABLE t2 (x1 BINARY(1) PRIMARY KEY, x2 BINARY(1) INVISIBLE, FOREIGN KEY (x2) REFERENCES t1(c2)); |
| 165 |
SELECT * FROM t2; |
| 166 |
|
| 167 |
INSERT INTO t1 (c1, c2) VALUES (1,1); |
| 168 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 169 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_parent_generated_insert'; |
| 170 |
INSERT INTO t1 (c1, c2) VALUES (2,2); |
| 171 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 172 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_insert'; |
| 173 |
INSERT INTO t2 (x1, x2) VALUES (1,1); |
| 174 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 175 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_unique_key_generated_update'; |
| 176 |
UPDATE t2 SET x2=2 WHERE x1=1; |
| 177 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 178 |
DROP TABLE t2; |
| 179 |
DROP TABLE t1; |
| 180 |
--source include/rpl_sync.inc |
| 181 |
|
| 182 |
# Table with Foreign Key referencing a NON Unique Key |
| 183 |
|
| 184 |
--connection master |
| 185 |
|
| 186 |
CREATE TABLE t1 (c1 BINARY(1) PRIMARY KEY, c2 BINARY(1), KEY(c2)); |
| 187 |
CREATE TABLE t2 (x1 BINARY(1) PRIMARY KEY, x2 BINARY(1), FOREIGN KEY (x2) REFERENCES t1(c2)); |
| 188 |
|
| 189 |
INSERT INTO t1 VALUES (1,1); |
| 190 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 191 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_non_unique_key_parent_generated_insert'; |
| 192 |
INSERT INTO t1 VALUES (2,2); |
| 193 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 194 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_non_unique_key_generated_insert'; |
| 195 |
INSERT INTO t2 VALUES (1,1); |
| 196 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 197 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_foreign_key_on_referenced_non_unique_key_generated_update'; |
| 198 |
UPDATE t2 SET x2=2 WHERE x1=1; |
| 199 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 200 |
DROP TABLE t2; |
| 201 |
DROP TABLE t1; |
| 202 |
--source include/rpl_sync.inc |
| 203 |
|
| 204 |
# Table with multi column primary key and a foreign key to the multi column primary key |
| 205 |
|
| 206 |
--connection master |
| 207 |
|
| 208 |
CREATE TABLE t1(a BINARY(1), b BINARY(1), c BINARY(1), PRIMARY KEY (a,b,c)); |
| 209 |
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)); |
| 210 |
|
| 211 |
INSERT INTO t1 VALUES (1,2,3); |
| 212 |
INSERT INTO t1 VALUES (4,2,3); |
| 213 |
|
| 214 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 215 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_primary_key_insert'; |
| 216 |
INSERT INTO t2 VALUES (1,2,3); |
| 217 |
|
| 218 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 219 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_primary_key_update'; |
| 220 |
UPDATE t2 SET d=4 WHERE d=1; |
| 221 |
|
| 222 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 223 |
DROP TABLE t2; |
| 224 |
DROP TABLE t1; |
| 225 |
--source include/rpl_sync.inc |
| 226 |
|
| 227 |
# Table with multi column unique key and a foreign key to the multi column unique key |
| 228 |
|
| 229 |
--connection master |
| 230 |
|
| 231 |
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)); |
| 232 |
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)); |
| 233 |
|
| 234 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 235 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_column_unique_key_insert'; |
| 236 |
INSERT INTO t1 VALUES (1,2,3); |
| 237 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 238 |
INSERT INTO t1 VALUES (4,5,6); |
| 239 |
|
| 240 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 241 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_unique_key_insert'; |
| 242 |
INSERT INTO t2 VALUES (1,2,3); |
| 243 |
|
| 244 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 245 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multi_column_foreign_key_on_multiple_column_unique_key_update'; |
| 246 |
UPDATE t2 SET d=4,e=5,f=6 WHERE d=1; |
| 247 |
|
| 248 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 249 |
DROP TABLE t2; |
| 250 |
DROP TABLE t1; |
| 251 |
--source include/rpl_sync.inc |
| 252 |
|
| 253 |
# Table with single primary key part |
| 254 |
|
| 255 |
--connection master |
| 256 |
|
| 257 |
CREATE TABLE t1(a VARCHAR(64), PRIMARY KEY(a(4))); |
| 258 |
INSERT INTO t1 VALUES ('aaaaxxxx'); |
| 259 |
|
| 260 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 261 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_part_insert'; |
| 262 |
INSERT INTO t1 VALUES ('ddddxxxx'); |
| 263 |
|
| 264 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 265 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_primary_key_part_update'; |
| 266 |
UPDATE t1 SET a = 'bbbbxxxx' WHERE a = 'ddddxxxx'; |
| 267 |
|
| 268 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 269 |
DROP TABLE t1; |
| 270 |
--source include/rpl_sync.inc |
| 271 |
|
| 272 |
# Table with multiple primary key part |
| 273 |
|
| 274 |
--connection master |
| 275 |
|
| 276 |
CREATE TABLE t1(a VARCHAR(64), b VARCHAR(64), PRIMARY KEY(a(4), b(4))); |
| 277 |
INSERT INTO t1 VALUES ('aaaaxxxx', 'bbbbxxxx'); |
| 278 |
|
| 279 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 280 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_primary_key_part_insert'; |
| 281 |
INSERT INTO t1 VALUES ('aaaaxxxx', 'ccccxxxx'); |
| 282 |
|
| 283 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 284 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_primary_key_part_update'; |
| 285 |
UPDATE t1 SET b = 'ddddxxxx' WHERE b = 'ccccxxxx'; |
| 286 |
|
| 287 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 288 |
DROP TABLE t1; |
| 289 |
--source include/rpl_sync.inc |
| 290 |
|
| 291 |
# Table with single unique key part |
| 292 |
|
| 293 |
--connection master |
| 294 |
|
| 295 |
CREATE TABLE t1(p BINARY, a VARCHAR(64), PRIMARY KEY(p), UNIQUE KEY(a(4))); |
| 296 |
INSERT INTO t1 VALUES (1, 'aaaaxxxx'); |
| 297 |
|
| 298 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 299 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_unique_key_part_insert'; |
| 300 |
INSERT INTO t1 VALUES (2, 'bbbbxxxx'); |
| 301 |
|
| 302 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 303 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_single_unique_key_part_update'; |
| 304 |
UPDATE t1 SET a = 'ddddxxxx' WHERE a = 'bbbbxxxx'; |
| 305 |
|
| 306 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 307 |
DROP TABLE t1; |
| 308 |
--source include/rpl_sync.inc |
| 309 |
|
| 310 |
# Table with multiple unique key part |
| 311 |
|
| 312 |
--connection master |
| 313 |
|
| 314 |
CREATE TABLE t1(p BINARY, a VARCHAR(64), b VARCHAR(64), PRIMARY KEY(p), UNIQUE KEY(a(4), b(4))); |
| 315 |
INSERT INTO t1 VALUES (1, 'aaaaxxxx', 'bbbbxxxx'); |
| 316 |
|
| 317 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 318 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_unique_key_part_insert'; |
| 319 |
INSERT INTO t1 VALUES (2, 'aaaaxxxx', 'ccccxxxx'); |
| 320 |
|
| 321 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 322 |
SET @@GLOBAL.DEBUG= '+d,PKE_assert_multiple_unique_key_part_update'; |
| 323 |
UPDATE t1 SET b = 'ddddxxxx' WHERE b = 'ccccxxxx'; |
| 324 |
|
| 325 |
SET @@GLOBAL.DEBUG= @debug_saved; |
| 326 |
DROP TABLE t1; |
| 327 |
--source include/rpl_sync.inc |
| 328 |
|
| 329 |
--source include/rpl_end.inc |