config root man

Current Path : /home/usr.opt/mysql57/mysql-test/suite/ndb/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/ndb/t/ndb_alter_table_online2.test

# The include statement below is a temp one for tests that are yet to
#be ported to run with InnoDB,
#but needs to be kept for tests that would need MyISAM in future.
--source include/force_myisam_default.inc

#############################################################
# Author: Tomas
# Date: 2007-09
# Purpose: online alter under load test
##############################################################
# Change Author: Jonathan
# Date 2007-10
# Purpose: Add testing for online alter w/partitions
#          and some original test cleanup and additions
##############################################################
-- source include/have_multi_ndb.inc
# test uses mysqlslap, hence not in embedded
-- source include/not_embedded.inc
# mysqlslap seems to be not_windows. remove this when removed from mysqlslap.test
-- source include/not_windows.inc
# -- source include/have_log_bin.inc

connection default;

# This test is really a walking race-condition...
#   and valgrind in PB2..."normally" gets timeout...
#   so ignore this test in valgrind
# In CluB it actually more frequently fails in gcc-madness, not sure why
#   (same timeout)
-- source include/not_valgrind.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
CREATE DATABASE IF NOT EXISTS mysqlslap;
--enable_warnings

# Create utiltity table used to hold the output from ndb_show_table
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)
);


--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ basic online alter test during load
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo

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

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

--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ Starting mysqlslap
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo

let $end_mysqlslap= 2000;
--exec $MYSQL_SLAP --query="update test.t1 set a=a+1 where pk=1; select sleep(0.01);" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &

# wait for 100 updates
--disable_result_log
--disable_query_log
select @end:=100;
let $val= 1;
while ($val)
{
  --sleep 0.1
  select @val:=a from t1 where pk=1;
  let $val= `select @end > @val `;
}
--enable_result_log
--enable_query_log

--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ Alter table t1 add column b
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
--echo

# add a column online
ALTER TABLE t1 algorithm=inplace, ADD b INT;

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

--source ndb_show_tables_result.inc
select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';

--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ Starting mysqlslap using column b
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
--echo

update t1 set b = 0 where pk = 1;
--exec $MYSQL_SLAP --query="update test.t1 set b=b+1 where pk=1; select sleep(0.01);" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &

# wait for 100 updates
--disable_result_log
--disable_query_log
select @end:=100;
let $val= 1;
while ($val)
{
  --sleep 0.1
  select @val:=b from t1 where pk=1;
  let $val= `select @end > @val`;
}
--enable_result_log
--enable_query_log

--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ Alter table t1 add column c
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo

# add a column online
ALTER TABLE t1 algorithm=inplace, ADD c INT;

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

--source ndb_show_tables_result.inc
select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';

--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ Starting mysqlslap using column c
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo

update t1 set c = 0 where pk = 1;
--exec $MYSQL_SLAP --query="update test.t1 set c=c+1 where pk=1; select sleep(0.01);" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &

# wait for mysqlslap to end
--disable_result_log
--disable_query_log
--eval select @end:=$end_mysqlslap
let $val= 1;
# 10 minutes = 600s sleep 0.1 => 6000
let $maxwait = 6000;
while ($val)
{
  --sleep 0.1
  select @val1:=a,@val2:=b,@val3:=c from t1 where pk=1;
  let $val= `select @end > @val1 || @end > @val2 || @end > @val3`;
  dec $maxwait;

  if (!$maxwait)
  {
    let $val = 0;
  }
}
--enable_result_log
--enable_query_log

select * from t1;


--echo
--echo BUG#17400320 algorithm= is not supported for ALTER TABLE with <partition_options>
--echo - thus disabling parts of this test
if (0)
{
--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ Alter table t1 and try to add partitions
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo

--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER TABLE t1 algorithm=inplace, PARTITION BY HASH(pk);
}

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

--source ndb_show_tables_result.inc
select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';


--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ test that aborted online alter rollback DDL transaction
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo

connect (con1,localhost,root,,test);

--echo # Connection default
connection default;
START TRANSACTION;
SELECT * FROM t1;

--echo # Connection con1
--connection con1
SET lock_wait_timeout=1;
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 algorithm=inplace, ADD d INT;
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 algorithm=inplace, ADD d INT;
SELECT * FROM t1;

connection default;
COMMIT;
--source ndb_show_tables_result.inc
select name from ndb_show_tables_results where id = @t1_id and name like '%t1%' and type like '%UserTable%';

--echo
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo ~ cleanup section
--echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--echo

# drop the table
drop table t1, ndb_show_tables_results;
drop database mysqlslap;

Man Man