DROP TABLE IF EXISTS t1;
CREATE DATABASE IF NOT EXISTS mysqlslap;
CREATE TEMPORARY TABLE IF NOT EXISTS ndb_show_tables_results (
id INT,
type VARCHAR(20),
state VARCHAR(20),
logging VARCHAR(20),
_database VARCHAR(255),
_schema VARCHAR(20),
name VARCHAR(255)
);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ basic online alter test during load
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

create table t1 (pk int key, a int) engine ndb;
insert into t1 values (1,0);

ndb_show_tables completed.....

set @t1_id = (select id from ndb_show_tables_results where name like '%t1%' and type like '%UserTable%');

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Starting mysqlslap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Alter table t1 add column b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

ALTER ONLINE TABLE t1 ADD b INT;
Warnings:
Warning	1478	Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Check table t1 ID has not changed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


ndb_show_tables completed.....

select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';
name
't1'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Starting mysqlslap using column b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

update t1 set b= 0;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Alter table t1 add column c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ALTER ONLINE TABLE t1 ADD c INT;
Warnings:
Warning	1478	Converted FIXED field to DYNAMIC to enable on-line ADD COLUMN

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Check table t1 ID has not changed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


ndb_show_tables completed.....

select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';
name
't1'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Starting mysqlslap using column c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

update t1 set c= 0;
select * from t1;
pk	a	b	c
1	5000	5000	5000

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Alter table t1 and try to add partitions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ALTER ONLINE TABLE t1 PARTITION BY HASH(pk);
ERROR 42000: This version of MySQL doesn't yet support 'ALTER ONLINE TABLE t1 PARTITION BY HASH(pk)'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Check table t1 ID has not changed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


ndb_show_tables completed.....

select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';
name
't1'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ cleanup section
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drop table t1, ndb_show_tables_results;
drop database mysqlslap;
