| 1 |
# ==== Requirements ==== |
| 2 |
# |
| 3 |
# R1. For all storage engines, when using row based replication, |
| 4 |
# the used columns bitset in a write-row event may have 0 bits |
| 5 |
# assigned to columns with 'DEFAULT' value set. |
| 6 |
# R2. When using NDB storage engine, the used column bit set in a |
| 7 |
# write row event may not be set for all generated columns. |
| 8 |
# R3. Whether or not, bits are set for generated columns in write-row |
| 9 |
# event, slave should be able to replicate. |
| 10 |
# |
| 11 |
# ==== Implementation ==== |
| 12 |
# |
| 13 |
# With row or mixed based replication setup: |
| 14 |
# 1) Iterate over storage engines and |
| 15 |
# a) Create a table with default value columns and generated |
| 16 |
# columns on MASTER. |
| 17 |
# b) Sync SLAVE and ensure that table was replicated. |
| 18 |
# c) Insert records on MASTER, with no values for default |
| 19 |
# value columns. |
| 20 |
# d) Sync SLAVE and ensure that records were replicated. |
| 21 |
# e) Update default values, for inserted records, on MASTER. |
| 22 |
# f) Sync SLAVE and ensure that records were replicated. |
| 23 |
# g) Insert *more* records on MASTER, with values for default |
| 24 |
# value columns. |
| 25 |
# h) Sync SLAVE and ensure if records were replicated. |
| 26 |
# i) Drop table |
| 27 |
# |
| 28 |
# ==== References ==== |
| 29 |
# |
| 30 |
# Bug#25827408 STORED GENERATED COLUMNS REPLICATION FAILURE |
| 31 |
|
| 32 |
# No need to test with statement based replication, since |
| 33 |
# the patch concerns row events. |
| 34 |
# |
| 35 |
-- source include/have_binlog_format_mixed_or_row.inc |
| 36 |
--source include/have_ndb.inc |
| 37 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 38 |
|
| 39 |
--let $engines= InnoDB, MyISAM, NDB |
| 40 |
|
| 41 |
--echo # |
| 42 |
--echo # 1) Iterate over storage engines and |
| 43 |
--echo # |
| 44 |
while ($engines) |
| 45 |
{ |
| 46 |
--let $db_type= `SELECT SUBSTRING_INDEX('$engines', ',', 1)` |
| 47 |
--let $engines= `SELECT LTRIM(SUBSTRING('$engines', LENGTH('$db_type') + 2))` |
| 48 |
|
| 49 |
--connection master |
| 50 |
|
| 51 |
--echo # |
| 52 |
--echo # a) Create a table with default value columns and generated |
| 53 |
--echo # columns on MASTER. |
| 54 |
--echo # |
| 55 |
eval CREATE TABLE t ( |
| 56 |
id INT PRIMARY KEY NOT NULL, |
| 57 |
name VARCHAR(20) NOT NULL, |
| 58 |
nick VARCHAR(20) NOT NULL DEFAULT "", |
| 59 |
state INT DEFAULT 0, |
| 60 |
description varchar(64) GENERATED ALWAYS AS (CONCAT("User#", id, " (", name, ") has state ", state)) STORED, |
| 61 |
welcome varchar(64) GENERATED ALWAYS AS (CONCAT("Welcome ", name, ", your nick is ", nick)) |
| 62 |
) ENGINE= $db_type; |
| 63 |
|
| 64 |
--echo # |
| 65 |
--echo # b) Sync SLAVE and ensure that table was replicated. |
| 66 |
--echo # |
| 67 |
--sync_slave_with_master |
| 68 |
SHOW CREATE TABLE t; |
| 69 |
|
| 70 |
--connection master |
| 71 |
--echo # |
| 72 |
--echo # c) Insert records on MASTER, with no values for default |
| 73 |
--echo # value columns. |
| 74 |
--echo # |
| 75 |
INSERT INTO t (id, name) VALUES (1, "Scott Summers"), (2, "Ororo Munroe"), (3, "Remy LeBeau"), (4, "James Howlett"), (5, "Jean Grey"); |
| 76 |
SELECT CONCAT(welcome, ". Your ", description, ".") FROM t ORDER BY id; |
| 77 |
|
| 78 |
--echo # |
| 79 |
--echo # d) Sync SLAVE and ensure that records were replicated. |
| 80 |
--echo # |
| 81 |
--sync_slave_with_master |
| 82 |
--let $diff_tables= master:t, slave:t |
| 83 |
--source include/diff_tables.inc |
| 84 |
|
| 85 |
--connection master |
| 86 |
--echo # |
| 87 |
--echo # e) Update default values, for inserted records, on MASTER. |
| 88 |
--echo # |
| 89 |
UPDATE t SET nick= "cycl0ps" WHERE id = 1; |
| 90 |
UPDATE t SET nick= "st0rm" WHERE id = 2; |
| 91 |
UPDATE t SET nick= "gamb1t" WHERE id = 3; |
| 92 |
UPDATE t SET nick= "l0gan" WHERE id = 4; |
| 93 |
UPDATE t SET nick= "f3nix" WHERE id = 5; |
| 94 |
SELECT CONCAT(welcome, ". Your ", description, ".") FROM t ORDER BY id; |
| 95 |
|
| 96 |
--echo # |
| 97 |
--echo # f) Sync SLAVE and ensure that records were replicated. |
| 98 |
--echo # |
| 99 |
--sync_slave_with_master |
| 100 |
--let $diff_tables= master:t, slave:t |
| 101 |
--source include/diff_tables.inc |
| 102 |
|
| 103 |
--connection master |
| 104 |
--echo # |
| 105 |
--echo # g) Insert *more* records on MASTER, with values for default |
| 106 |
--echo # value columns. |
| 107 |
--echo # |
| 108 |
INSERT INTO t (id, name, nick, state) VALUES (6, "Anna Marie", "r0gu3", 1), (7, "Alex Summers", "hav0k", 2), (8, "Warren Worthington", "ang3l", 1), (9, "Lorna Dane", "p0lar1s", 1); |
| 109 |
SELECT CONCAT(welcome, ". Your ", description, ".") FROM t ORDER BY id; |
| 110 |
|
| 111 |
--echo # |
| 112 |
--echo # h) Sync SLAVE and ensure if records were replicated. |
| 113 |
--echo # |
| 114 |
--sync_slave_with_master |
| 115 |
--let $diff_tables= master:t, slave:t |
| 116 |
--source include/diff_tables.inc |
| 117 |
|
| 118 |
--connection master |
| 119 |
--echo # |
| 120 |
--echo # i) Drop table |
| 121 |
--echo # |
| 122 |
DROP TABLE t; |
| 123 |
|
| 124 |
--sync_slave_with_master |
| 125 |
} |
| 126 |
|
| 127 |
--source include/rpl_end.inc |