-- source include/have_ndb.inc
-- source include/not_embedded.inc

--disable_warnings
drop table if exists t1;
--enable_warnings

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

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

create table t1 (a int column_format DYNAMIC STORAGE DISK) TABLESPACE ts1 engine NDB;
select column_name, storage, format from information_schema.columns
where table_name = "t1";
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
drop table t1;

create table t1 (a int column_format DYNAMIC,
                 a1 int column_format FIXED,
                 b int NOT NULL column_format DYNAMIC,
                 b1 int NOT NULL column_format FIXED storage DISK,
                 c VARCHAR(100) column_format FIXED,
                 c1 VARCHAR(100) column_format DYNAMIC storage memory,
                 d VARCHAR(100) NOT NULL column_format FIXED,
                 d1 VARCHAR(100) NOT NULL column_format DYNAMIC,
                 e CHAR(100) column_format FIXED,
                 e1 CHAR(100) column_format DYNAMIC,
                 f CHAR(100) NOT NULL column_format FIXED,
                 f1 char(100) NOT NULL column_format DYNAMIC storage DISK,
                 index (b)) TABLESPACE ts1 engine NDB;
insert into t1 (b, b1, d,d1,f,f1) values
(1,1,"1","1","1","1"),
(2,2,"2","2","2","2"),
(3,3,"3","3","3","3");
alter table t1 change column a a int column_format FIXED;
show create table t1;
select column_name, storage, format from information_schema.columns
where table_name = "t1";
alter table t1 change column a a int storage disk;
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
alter table t1 change column a a int storage memory;
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
alter table t1 change column b b int NOT NULL storage memory;
alter table t1 add column a2 int column_format FIXED;
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
alter table t1 add column c2 VARCHAR(100) column_format DYNAMIC;
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
alter table t1 add column c3 VARCHAR(100) column_format FIXED;
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='

drop table t1;
create table t1 (a int storage disk column_format FIXED) TABLESPACE ts1 engine NDB;
alter table t1 change column a a int storage memory column_format DYNAMIC;
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
drop table t1;

# Checking keywords
create table t1 (column_format int storage disk column_format FIXED, storage int storage disk column_format FIXED) TABLESPACE ts1 engine NDB;
show create table t1;
--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep 'ST='
drop table t1;

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

drop tablespace ts1
engine ndb;

drop logfile group lg1
engine ndb;
