--source include/ndb_have_online_alter.inc
-- source include/have_ndb.inc
-- source include/not_embedded.inc
--result_format 2

--exec $NDB_MGM -e show

CREATE LOGFILE GROUP lg_1
    ADD UNDOFILE 'undo_1.dat'
    INITIAL_SIZE 4M
    UNDO_BUFFER_SIZE 2M
    ENGINE NDB;

CREATE TABLESPACE ts_1
    ADD DATAFILE 'data_1.dat'
    USE LOGFILE GROUP lg_1
    INITIAL_SIZE 4M
    ENGINE NDB;

create table t1(id int NOT NULL PRIMARY KEY, data char(8)) engine=ndb;
create table t2(id int NOT NULL PRIMARY KEY, data char(8))
TABLESPACE ts_1 STORAGE DISK engine=ndb;

load data local infile 'suite/ndb/data/table_data10000.dat' into table t1 fields terminated by ' ' lines terminated by '\n';
load data local infile 'suite/ndb/data/table_data10000.dat' into table t2 fields terminated by ' ' lines terminated by '\n';

## Create nodegroup for "new" nodes
--exec $NDB_MGM -e "create nodegroup 3,4"

# Cluster running after adding two ndbd nodes
--exec $NDB_MGM -e show

## Drop
--exec $NDB_MGM -e "drop nodegroup 1"
## and create
--exec $NDB_MGM -e "create nodegroup 3,4"

create table t3(id int NOT NULL PRIMARY KEY, data char(8)) engine=ndb;
create table t4(id int NOT NULL PRIMARY KEY, data char(8))
TABLESPACE ts_1 STORAGE DISK engine=ndb;

insert into t3(id, data) VALUES 
(1,'new'), (2,'new'),(3,'new'),(4,'new'),(5,'new'),
(6,'new'),(7,'new'),(8,'new'),(9,'new'),(10,'new');
insert into t4(id, data) VALUES
(1,'new'), (2,'new'),(3,'new'),(4,'new'),(5,'new'),
(6,'new'),(7,'new'),(8,'new'),(9,'new'),(10,'new');

alter online table t1 reorganize partition;
alter online table t2 reorganize partition;

## Drop nodegroup with "new" nodes is not allowed with data one those nodes
# NOTE: --error=0 is due to return codes doesnt work on windoze
--error 0,255
--exec $NDB_MGM -e "drop nodegroup 1"

## Nodegroup with "new" nodes still exist after dropping it as shown:
--exec $NDB_MGM -e show

drop table t1,t2,t3,t4;

## Drop nodegroup with "new" nodes
--exec $NDB_MGM -e "drop nodegroup 1"

## Nodegroup with "new" nodes still exists after dropping it as shown:
--exec $NDB_MGM -e show

# Cleanup
ALTER TABLESPACE ts_1 DROP DATAFILE 'data_1.dat' ENGINE NDB;
DROP TABLESPACE ts_1 ENGINE NDB;
DROP LOGFILE GROUP lg_1 ENGINE NDB;

exit;
