-- source include/have_ndb.inc

set storage_engine=ndb;
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
INITIAL_SIZE 4M
UNDO_BUFFER_SIZE = 1M;

set storage_engine=myisam;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 4M
ENGINE NDB;

CREATE TABLE t1
(pk1 INT NOT NULL PRIMARY KEY, b INT NOT NULL, c INT NOT NULL)
TABLESPACE ts1 STORAGE DISK
ENGINE=NDB;

SHOW CREATE TABLE t1;

INSERT INTO t1 VALUES (0, 0, 0);
SELECT * FROM t1;

INSERT INTO t1 VALUES 
(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5);

SELECT COUNT(*) FROM t1;
--replace_column 9 #
SELECT * FROM INFORMATION_SCHEMA.TABLESPACES WHERE ENGINE='NDBCLUSTER';

drop table t1;

CREATE TABLESPACE ts2
ADD DATAFILE 'ts2_datafile.dat'
USE LOGFILE GROUP lg1
INITIAL_SIZE 4M
ENGINE NDB;

--replace_column 9 #
SELECT * FROM INFORMATION_SCHEMA.TABLESPACES WHERE ENGINE='NDBCLUSTER';

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

--replace_column 9 #
SELECT * FROM INFORMATION_SCHEMA.TABLESPACES WHERE ENGINE='NDBCLUSTER';

ALTER TABLESPACE ts2
DROP DATAFILE 'ts2_datafile.dat' 
ENGINE = NDB;

--replace_column 9 #
SELECT * FROM INFORMATION_SCHEMA.TABLESPACES WHERE ENGINE='NDBCLUSTER';

DROP TABLESPACE ts1 
ENGINE = NDB;

--replace_column 9 #
SELECT * FROM INFORMATION_SCHEMA.TABLESPACES WHERE ENGINE='NDBCLUSTER';

DROP TABLESPACE ts2
ENGINE = NDB;

--replace_column 9 #
SELECT * FROM INFORMATION_SCHEMA.TABLESPACES WHERE ENGINE='NDBCLUSTER';

DROP LOGFILE GROUP lg1 
ENGINE =NDB;
