-- source include/have_ndb.inc
-- source include/have_multi_ndb.inc
-- source include/have_binlog_format_row.inc

--disable_warnings
connection server2;
drop database if exists mysqltest;
drop table if exists t1,t2;
connection server1;
drop database if exists mysqltest;
drop table if exists t1,t2;
--connection server1
reset master;
--connection server2
reset master;
--enable_warnings

--let $binlog_start=102

#
# basic test to see if ddl distribution works across
# multiple binlogs
#

# create database
--connection server1
create database mysqltest;

# create table
--connection server1
use mysqltest;
create table t1 (a int primary key) engine=ndb;

--connection server2
create table t2 (a int primary key) engine=ndb;
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 # 
--eval show binlog events from $binlog_start

--connection server1
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 # 
--eval show binlog events from $binlog_start


# alter table
--connection server1
reset master;
--connection server2
reset master;

--connection server2
alter table t2 add column (b int);

--connections server1
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 # 
--eval show binlog events from $binlog_start


# alter database
--connection server1
reset master;
--connection server2
reset master;

--connection server2
ALTER DATABASE mysqltest CHARACTER SET latin1;


# drop table and drop should come after data events
--connection server2
drop table mysqltest.t1;

--connection server1
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 # 
--eval show binlog events from $binlog_start


# drop database and drop should come after data events
--connection server1
reset master;
--connection server2
reset master;

--connection server1
use test;
insert into t2 values (1,2);
drop database mysqltest;
create table t1 (a int primary key) engine=ndb;

--connection server2
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 # 
--eval show binlog events from $binlog_start

--connection server2
drop table t2;

# logfile groups and table spaces
--connection server1
reset master;
--connection server2
reset master;

--connection server1
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 16M
UNDO_BUFFER_SIZE = 1M
ENGINE=NDB;

ALTER LOGFILE GROUP lg1
ADD UNDOFILE 'undofile02.dat'
INITIAL_SIZE = 4M 
ENGINE=NDB;

CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 12M
ENGINE NDB;

ALTER TABLESPACE ts1
ADD DATAFILE 'datafile02.dat'
INITIAL_SIZE = 4M 
ENGINE=NDB;

ALTER TABLESPACE ts1 
DROP DATAFILE 'datafile.dat' 
ENGINE = NDB;

ALTER TABLESPACE ts1 
DROP DATAFILE 'datafile02.dat' 
ENGINE = NDB;

DROP TABLESPACE ts1 
ENGINE = NDB;

DROP LOGFILE GROUP lg1 
ENGINE =NDB;

drop table t1;

--connection server2
--replace_result $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 # 
--eval show binlog events from $binlog_start
