1
--source include/have_ndb.inc
2
--source include/have_log_bin.inc
3
--source include/have_debug.inc
5
# Bug#35217 Strange ndb_binlog_index error inserting rows in MyISAM table
6
# Verify that mysql.ndb_binlog_index is getting unique epoch values
7
# Do this by dropping the PK, inserting some data and checking
10
alter table mysql.ndb_binlog_index drop primary key;
14
create table t1 (a int) engine=ndb;
17
create procedure ins (rows int)
21
insert into t1 values (1);
31
# Did any of the epochs have > 1 entry?
32
# (Answer should be no !)
33
--echo Duplicate epochs according to mysql.ndb_binlog_index
34
select epoch >> 32 as gci,
35
(epoch << 32) >> 32 as ugci,
37
from mysql.ndb_binlog_index
41
# Now look at what's in the Binlog events themselves, in case they also
42
# carry duplicate epochs
44
# Code here similar to ndb_binlog_get_binlog_stmts.inc
47
let $MYSQLD_DATADIR= `select @@datadir;`;
48
--exec $MYSQL_BINLOG --verbose $MYSQLD_DATADIR/mysqld-bin.000001 > $MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql
50
create table raw_binlog_rows (txt varchar(1000));
52
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql' into table raw_binlog_rows columns terminated by '\n';
54
create table binlog_stmt_parts_unassoc (txt varchar(1000), line_count int, stmt_boundary int);
59
# Use replace() here to get rid of any unwanted Windows
61
insert into binlog_stmt_parts_unassoc
62
select replace(txt, '\r', ''),
63
@line_count:= @line_count + 1, # So we can preserve order later
64
(txt like '%INSERT%' or # Identify statement boundaries
65
txt like '%UPDATE%' or
69
txt like '###%'; # Discard non verbose output
71
create table binlog_stmt_parts_assoc (txt varchar(1000), line_count int, stmt_num int);
75
insert into binlog_stmt_parts_assoc
78
@stmt_count:= @stmt_count + stmt_boundary # All rows from same stmt will
80
from binlog_stmt_parts_unassoc order by line_count;
82
create table binlog_stmts (txt varchar(1000), stmt_num int);
84
insert into binlog_stmts
85
select group_concat(right(txt, # Combine rows in statment into 1
86
length(txt) - 4) # Trim ### from line start
88
separator ' '), stmt_num
89
from binlog_stmt_parts_assoc
93
create table epochs_in_binlog (epoch bigint);
95
# Trim INSERT INTO mysql.ndb_apply_status SET @1=1 @2=144115213845659648 @3='' @4=0 @5=0
96
# down to a list of epochs
98
insert into epochs_in_binlog
99
select substring_index(right(txt, length(txt) - instr(txt, '@2=') - 3),' ', 1)
101
where txt like '%ndb_apply_status%'
105
--echo Duplicate epochs according to MySQLD Binlog entries
106
select epoch >> 32 as gci,
107
(epoch << 32) >> 32 as ugci,
109
from epochs_in_binlog
114
drop table raw_binlog_rows;
115
drop table binlog_stmt_parts_unassoc;
116
drop table binlog_stmt_parts_assoc;
117
drop table binlog_stmts;
118
drop table epochs_in_binlog;
124
alter table mysql.ndb_binlog_index add primary key (epoch, orig_server_id, orig_epoch);