include/master-slave.inc
[connection master]
SET binlog_format = STATEMENT;

*** Test 1 ***

create table t1 (a int key, b int) engine innodb;
create table t2 (a int key, b int) engine innodb;

alter table t1 engine ndb;
alter table t2 engine ndb;

insert into t1 values (1,2);

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

# Now check that that is in the apply_status table is consistant
# with what is in the binlog

# since insert is done with transactional engine, expect a BEGIN
# at <start_pos>

show binlog events from <binlog_start> limit 1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	BEGIN

# Now the insert, one step after

show binlog events from <binlog_start> limit 1,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (1,2)

# and the COMMIT should be at <end_pos>

show binlog events from <binlog_start> limit 2,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	#	#	COMMIT /* XID */

begin;
insert into t1 values (2,3);
insert into t2 values (3,4);
commit;

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>
show binlog events from <binlog_start> limit 1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	BEGIN

show binlog events from <binlog_start> limit 1,2;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	use `test`; insert into t1 values (2,3)
master-bin.000001	#	Query	#	#	use `test`; insert into t2 values (3,4)

show binlog events from <binlog_start> limit 3,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	#	#	COMMIT /* XID */

DROP TABLE test.t1, test.t2;
SHOW TABLES;
Tables_in_test

*** Test 2 ***

DROP DATABASE IF EXISTS tpcb;
CREATE DATABASE tpcb;

CREATE TABLE tpcb.account (id INT, bid INT, balance DECIMAL(10,2),
filler CHAR(255), PRIMARY KEY(id));

CREATE TABLE tpcb.branch (bid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(bid));

CREATE TABLE tpcb.teller (tid INT, balance DECIMAL(10,2), filler VARCHAR(255),
PRIMARY KEY(tid));

CREATE TABLE tpcb.history (id MEDIUMINT NOT NULL AUTO_INCREMENT,aid INT,
tid INT, bid INT,  amount DECIMAL(10,2),
tdate DATETIME, teller CHAR(20), uuidf LONGBLOB,
filler CHAR(80),PRIMARY KEY (id));

--- Create stored procedures & functions ---


*** Stored Procedures Created ***

USE tpcb;
ALTER TABLE account ENGINE NDB;
ALTER TABLE branch ENGINE NDB;
ALTER TABLE teller ENGINE NDB;
ALTER TABLE history ENGINE NDB;

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

show binlog events in 'master-bin.000001'  from <start_pos> limit 6,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	1	<end_pos>	COMMIT /* XID */

** Test 3 **

FLUSH LOGS;

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

show binlog events in 'master-bin.000002'  from <start_pos> limit 6,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000002	#	Xid	1	<end_pos>	COMMIT /* XID */

** Test 4 **

include/rpl_reset.inc

select @log_name:=log_name, @start_pos:=start_pos, @end_pos:=end_pos
from mysql.ndb_apply_status;
@log_name:=log_name	@start_pos:=start_pos	@end_pos:=end_pos
<log_name>	<start_pos>	<end_pos>

show binlog events in 'master-bin.000001'  from <start_pos> limit 6,1;
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Xid	1	<end_pos>	COMMIT /* XID */

*** DUMP MASTER & SLAVE FOR COMPARE ********
DROP DATABASE tpcb;
****** Do dumps compare ************
include/rpl_end.inc
