| 1 |
-- source include/have_ndb.inc |
| 2 |
-- source include/have_binlog_format_mixed_or_row.inc |
| 3 |
|
| 4 |
# |
| 5 |
# basic insert, update, delete test, alter, rename, drop |
| 6 |
# check that ndb_binlog_index gets the right info |
| 7 |
# |
| 8 |
reset master; |
| 9 |
|
| 10 |
create table t1 (a int primary key) engine=ndb; |
| 11 |
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); |
| 12 |
save_master_pos; |
| 13 |
|
| 14 |
select max(epoch)-1 from mysql.ndb_binlog_index into @max_epoch; |
| 15 |
--replace_column 1 # |
| 16 |
select @max_epoch; |
| 17 |
|
| 18 |
delete from t1; |
| 19 |
alter table t1 add (b_x int); |
| 20 |
|
| 21 |
alter table t1 algorithm=inplace, rename column b_x to b; |
| 22 |
--source include/show_binlog_events.inc |
| 23 |
|
| 24 |
insert into t1 values (3,3),(4,4); |
| 25 |
alter table t1 rename t2; |
| 26 |
|
| 27 |
# get all in one epoch |
| 28 |
begin; |
| 29 |
insert into t2 values (1,1),(2,2); |
| 30 |
update t2 set b=1 where a=3; |
| 31 |
delete from t2 where a=4; |
| 32 |
commit; |
| 33 |
drop table t2; |
| 34 |
|
| 35 |
# check that above is ok |
| 36 |
# (save_master_pos waits for last gcp to complete, ensuring that we have |
| 37 |
# the expected data in the binlog) |
| 38 |
save_master_pos; |
| 39 |
select inserts from mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 5; |
| 40 |
select deletes from mysql.ndb_binlog_index where epoch > @max_epoch and deletes > 5; |
| 41 |
select inserts,updates,deletes from |
| 42 |
mysql.ndb_binlog_index where epoch > @max_epoch and updates > 0; |
| 43 |
|
| 44 |
# |
| 45 |
# check that purge clears the ndb_binlog_index |
| 46 |
# |
| 47 |
flush logs; |
| 48 |
--sleep 1 |
| 49 |
# Fix windows dir separators in file name of the warning |
| 50 |
--replace_regex /\.[\\\/]binlog/.\/binlog/; |
| 51 |
purge master logs before now(); |
| 52 |
|
| 53 |
select count(*) from mysql.ndb_binlog_index; |
| 54 |
|
| 55 |
# |
| 56 |
# several tables in different databases |
| 57 |
# check that same table name in different databases don't mix up |
| 58 |
# |
| 59 |
create table t1 (a int primary key, b int) engine=ndb; |
| 60 |
create database mysqltest; |
| 61 |
use mysqltest; |
| 62 |
create table t1 (c int, d int primary key) engine=ndb; |
| 63 |
use test; |
| 64 |
|
| 65 |
insert into mysqltest.t1 values (2,1),(2,2); |
| 66 |
save_master_pos; |
| 67 |
select max(epoch)-1 from mysql.ndb_binlog_index into @max_epoch; |
| 68 |
--replace_column 1 # |
| 69 |
select @max_epoch; |
| 70 |
|
| 71 |
drop table t1; |
| 72 |
drop database mysqltest; |
| 73 |
select inserts,updates,deletes from |
| 74 |
mysql.ndb_binlog_index where epoch > @max_epoch and inserts > 0; |
| 75 |
|
| 76 |
# |
| 77 |
# Check optimize table does not send any event to binlog |
| 78 |
# |
| 79 |
|
| 80 |
create table t1 (c1 int not null primary key, c2 blob default null) engine=ndbcluster default charset=latin1; |
| 81 |
insert into t1 values (1, null), (2, null), (3, null), (4, null); |
| 82 |
insert into t1 select c1+4,c2 from t1; |
| 83 |
insert into t1 select c1+8,c2 from t1; |
| 84 |
insert into t1 select c1+16,c2 from t1; |
| 85 |
insert into t1 select c1+32,c2 from t1; |
| 86 |
insert into t1 select c1+64,c2 from t1; |
| 87 |
insert into t1 select c1+128,c2 from t1; |
| 88 |
insert into t1 select c1+256,c2 from t1; |
| 89 |
insert into t1 select c1+512,c2 from t1; |
| 90 |
|
| 91 |
# wait for last gcp to complete, ensuring that we have |
| 92 |
# the expected data in the binlog |
| 93 |
save_master_pos; |
| 94 |
|
| 95 |
let $before = `select count(*) |
| 96 |
from mysql.ndb_binlog_index |
| 97 |
where epoch > @max_epoch and |
| 98 |
(inserts > 0 or updates > 0 or deletes > 0)`; |
| 99 |
|
| 100 |
optimize table t1; |
| 101 |
save_master_pos; |
| 102 |
|
| 103 |
# Ensure that optimize have not sent any event to binlog |
| 104 |
let $optimize_diff = `select count(*) <> $before |
| 105 |
from mysql.ndb_binlog_index |
| 106 |
where epoch > @max_epoch and |
| 107 |
(inserts > 0 or updates > 0 or deletes > 0)`; |
| 108 |
|
| 109 |
if ($optimize_diff) |
| 110 |
{ |
| 111 |
die Optimize table should not send any events to binlog; |
| 112 |
} |
| 113 |
|
| 114 |
drop table t1; |
| 115 |
|
| 116 |
# |
| 117 |
# Make binlog to ignore an empty blob column update |
| 118 |
# having before- and after-values 'null' |
| 119 |
# when performed in a separate epoch and |
| 120 |
# empty epochs are not logged. |
| 121 |
# Run the test twice, with ndb_log_empty_epochs ON and OFF. |
| 122 |
# |
| 123 |
|
| 124 |
let $repetitions=2; |
| 125 |
SET GLOBAL ndb_log_empty_epochs=ON; |
| 126 |
while ($repetitions) |
| 127 |
{ |
| 128 |
SHOW VARIABLES LIKE 'ndb_log_empty_epochs'; |
| 129 |
create table t1 (c1 int not null primary key, c2 blob default null) engine=ndbcluster default charset=latin1; |
| 130 |
insert into t1 values (1, null); |
| 131 |
|
| 132 |
# Avoid the following update being performed within the same epoch by |
| 133 |
# synchronising with Binlog |
| 134 |
--disable_result_log |
| 135 |
show binlog events; |
| 136 |
--enable_result_log |
| 137 |
|
| 138 |
update t1 set c2=null; |
| 139 |
select * from t1; |
| 140 |
|
| 141 |
--disable_result_log |
| 142 |
show binlog events; |
| 143 |
--enable_result_log |
| 144 |
|
| 145 |
optimize table t1; |
| 146 |
select * from t1; |
| 147 |
drop table t1; |
| 148 |
|
| 149 |
create table t1 (c1 int not null primary key, c2 varchar(1024) default null) engine=ndbcluster default charset=latin1; |
| 150 |
insert into t1 values (3, null); |
| 151 |
select * from t1; |
| 152 |
|
| 153 |
--disable_result_log |
| 154 |
show binlog events; |
| 155 |
--enable_result_log |
| 156 |
|
| 157 |
optimize table t1; |
| 158 |
select * from t1; |
| 159 |
drop table t1; |
| 160 |
|
| 161 |
# Repeat the test with |
| 162 |
SET GLOBAL ndb_log_empty_epochs=OFF; |
| 163 |
|
| 164 |
--disable_result_log |
| 165 |
show binlog events; |
| 166 |
--enable_result_log |
| 167 |
|
| 168 |
dec $repetitions; |
| 169 |
} |