2 # Get the mysqlbinlog tool --verbose mode to dump the Binlog contents with
3 # 'SQL' statements in triple-comments over multiple lines, e.g. :
10 # Then munch this output into single-line statements
12 # INSERT SET @1=1 @2=2
14 # Then filter + sort to get deterministic order independent of Ndb table
15 # fragmentation, epoch in ndb_apply_status etc.
19 let $MYSQLD_DATADIR= `select @@datadir;`;
20 --exec $MYSQL_BINLOG --verbose $MYSQLD_DATADIR/mysqld-bin.000001 > $MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql
22 create
table raw_binlog_rows (txt varchar(1000));
24 --eval load data local infile
'$MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql' into
table raw_binlog_rows columns terminated by
'\n';
26 create
table binlog_stmt_parts_unassoc (txt varchar(1000), line_count
int, stmt_boundary
int);
31 # Use replace() here to get rid of any unwanted Windows
33 insert into binlog_stmt_parts_unassoc
35 @line_count:= @line_count + 1, # So we can preserve order later
36 (txt like
'%INSERT%' or # Identify
statement boundaries
37 txt like
'%UPDATE%' or
41 txt like
'###%'; # Discard non verbose output
43 #select * from binlog_stmt_parts_unassoc;
45 create
table binlog_stmt_parts_assoc (txt varchar(1000), line_count
int, stmt_num
int);
49 insert into binlog_stmt_parts_assoc
52 @stmt_count:= @stmt_count + stmt_boundary # All rows from same stmt will
54 from binlog_stmt_parts_unassoc order by line_count;
57 #select * from binlog_stmt_parts_assoc;
59 create
table binlog_stmts (txt varchar(1000), stmt_num
int);
61 insert into binlog_stmts
62 select group_concat(right(txt, # Combine rows in statment into 1
63 length(txt) - 4) # Trim ### from line start
65 separator
' '), stmt_num
66 from binlog_stmt_parts_assoc
69 #select * from binlog_stmts;
71 # Drop ndb_apply_status entries and sort by the statment
72 # text to get a deterministic order.
74 # Reasonable order would be sort by (PK-cols, stmt_num)
75 # - Sorting by PK-cols would give determinism between events from different
77 # - Multiple ops on same pk would be in order of application
79 # However, as that's harder, and unnecessary given that we just want
80 # deterministic output, not applicable SQL, we will just sort by
84 --eval select txt from binlog_stmts where txt $binlog_condition order by txt
87 drop
table raw_binlog_rows;
88 drop
table binlog_stmt_parts_unassoc;
89 drop
table binlog_stmt_parts_assoc;
90 drop
table binlog_stmts;