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
|
--echo # Replicating simple inserts
--echo [Connection Master]
--connection master
# Check if lock mode is changed on master
SELECT @@global.innodb_autoinc_lock_mode;
CREATE TABLE t1 (pkey INT NOT NULL AUTO_INCREMENT PRIMARY KEY, aa INT);
INSERT INTO t1 VALUES (NULL,10),
(NULL,20),
(NULL,30);
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
# Check if lock mode is changed on slave
SELECT @@global.innodb_autoinc_lock_mode;
SELECT * FROM t1;
--let $diff_tables = master:t1, slave:t1
--source include/diff_tables.inc
--echo [Connection Master]
--connection master
# Check with insert on duplicate key update
INSERT INTO t1 VALUES (3,35)
ON DUPLICATE KEY UPDATE aa = aa+1;
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
SELECT * FROM t1;
--let $diff_tables = master:t1, slave:t1
--source include/diff_tables.inc
--echo [Connection Master]
--connection master
# Change the auto_increment_offset and auto_increment_increment values
SET @default_auto_increment_offset = @@auto_increment_offset;
SET @default_auto_increment_increment = @@auto_increment_increment;
SET auto_increment_offset = 5;
SET auto_increment_increment = 15;
INSERT INTO t1 VALUES (NULL,40),
(NULL,50),
(NULL,60),
(NULL,70),
(NULL,80);
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
SELECT * FROM t1;
--let $diff_tables = master:t1, slave:t1
--source include/diff_tables.inc
--echo [Conenction Master]
--connection master
# Delete records
DELETE FROM t1 WHERE aa IN (40,60);
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
SELECT * FROM t1;
--let $diff_tables = master:t1, slave:t1
--source include/diff_tables.inc
--echo [Connection Master]
--connection master
SET @@auto_increment_offset = @default_auto_increment_offset;
SET @@auto_increment_increment= @default_auto_increment_increment;
DROP TABLE t1;
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
--error ER_NO_SUCH_TABLE
SELECT * FROM t1;
--echo # Replicating bulk inserts
--echo [Connection Master]
--connection master
CREATE TABLE t1(aa INT);
INSERT INTO t1 VALUES(5),(10),(15),(20),(25),(30),(35),(40);
CREATE TABLE t2(pkey INT NOT NULL AUTO_INCREMENT PRIMARY KEY, aa INT);
--disable_warnings
INSERT INTO t2(aa) SELECT * FROM t1;
INSERT INTO t2(aa) SELECT * FROM t1;
--enable_warnings
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
SELECT COUNT(*) FROM t2;
--let $diff_tables = master:t2, slave:t2
--source include/diff_tables.inc
--echo [Connection Master]
--connection master
# Bulk inserts with auto increment offset
SET auto_increment_offset = 4;
SET auto_increment_increment = 16;
--disable_warnings
INSERT INTO t2(aa) SELECT * FROM t1;
INSERT INTO t2(aa) SELECT * FROM t1;
--enable_warnings
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
SELECT COUNT(*) FROM t2;
--let $diff_tables = master:t2, slave:t2
--source include/diff_tables.inc
--echo [Connection Master]
--connection master
SET @@auto_increment_offset = @default_auto_increment_offset;
SET @@auto_increment_increment = @default_auto_increment_increment;
DROP TABLE t1;
DROP TABLE t2;
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
--error ER_NO_SUCH_TABLE
SELECT * FROM t2;
--echo # Replicating mixed mode inserts
--echo [Connection Master]
--connection master
CREATE TABLE t1(pkey INT NOT NULL AUTO_INCREMENT PRIMARY KEY, bb INT);
INSERT INTO t1 VALUES(NULL,20),
(20,40),
(NULL,60),
(NULL,80),
(30,100),
(NULL,120);
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
SELECT COUNT(*) FROM t1;
--let $diff_tables = master:t1, slave:t1
--source include/diff_tables.inc
--echo [Connection Master]
--connection master
DROP TABLE t1;
--source include/sync_slave_sql_with_master.inc
--echo [Connection Slave]
--error ER_NO_SUCH_TABLE
SELECT * FROM t1;
|