1# test uses multiple mysqld by necessity, hence not in embedded 2-- source include/not_embedded.inc 3-- source include/have_multi_ndb.inc 4-- source include/ndb_default_cluster.inc 5 6--disable_warnings 7drop table if exists t1,t2; 8--enable_warnings 9 10# operations allowed while cluster is in single user mode 11 12--connection server1 13--let $node_id= `SHOW STATUS LIKE 'Ndb_cluster_node_id'` 14--disable_query_log 15--eval set @node_id= SUBSTRING('$node_id', 20)+0 16--enable_query_log 17--let $node_id= `SELECT @node_id` 18--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT 19--exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" --single-user >> $NDB_TOOLS_OUTPUT 20 21# verify that we are indeed in single user mode 22# and test that some operations give correct errors 23--connection server2 24--error 1005 25create table t1 (a int key, b int unique, c int) engine ndb; 26# Bug #27712 Single user mode. Creating logfile group and tablespace is allowed 27# - before bug fix these would succeed 28--error ER_CREATE_FILEGROUP_FAILED 29CREATE LOGFILE GROUP lg1 30ADD UNDOFILE 'undofile.dat' 31INITIAL_SIZE 16M 32UNDO_BUFFER_SIZE = 1M 33ENGINE=NDB; 34show warnings; 35 36# test some sql on first mysqld 37--connection server1 38create table t1 (a int key, b int unique, c int) engine ndb; 39# Check that we can create logfile group 40CREATE LOGFILE GROUP lg1 41ADD UNDOFILE 'undofile.dat' 42INITIAL_SIZE 16M 43UNDO_BUFFER_SIZE = 1M 44ENGINE=NDB; 45--connection server2 46--error ER_CREATE_FILEGROUP_FAILED 47CREATE TABLESPACE ts1 48ADD DATAFILE 'datafile.dat' 49USE LOGFILE GROUP lg1 50INITIAL_SIZE 12M 51ENGINE NDB; 52show warnings; 53--error ER_DROP_FILEGROUP_FAILED 54DROP LOGFILE GROUP lg1 55ENGINE =NDB; 56show warnings; 57--connection server1 58CREATE TABLESPACE ts1 59ADD DATAFILE 'datafile.dat' 60USE LOGFILE GROUP lg1 61INITIAL_SIZE 12M 62ENGINE NDB; 63--connection server2 64--error ER_ALTER_FILEGROUP_FAILED 65ALTER TABLESPACE ts1 66DROP DATAFILE 'datafile.dat' 67ENGINE NDB; 68show warnings; 69--connection server1 70ALTER TABLESPACE ts1 71DROP DATAFILE 'datafile.dat' 72ENGINE NDB; 73--connection server2 74--error ER_DROP_FILEGROUP_FAILED 75DROP TABLESPACE ts1 76ENGINE NDB; 77show warnings; 78--connection server1 79DROP TABLESPACE ts1 80ENGINE NDB; 81DROP LOGFILE GROUP lg1 82ENGINE =NDB; 83insert into t1 values (1,1,0),(2,2,0),(3,3,0),(4,4,0),(5,5,0),(6,6,0),(7,7,0),(8,8,0),(9,9,0),(10,10,0); 84create table t2 as select * from t1; 85# read with pk 86select * from t1 where a = 1; 87# read with unique index 88select * from t1 where b = 4; 89# read with ordered index 90select * from t1 where a > 4 order by a; 91# update with pk 92update t1 set b=102 where a = 2; 93# update with unique index 94update t1 set b=103 where b = 3; 95# update with full table scan 96update t1 set b=b+100; 97# update with ordered insex scan 98update t1 set b=b+100 where a > 7; 99# delete with full table scan 100delete from t1; 101insert into t1 select * from t2; 102# Bug #27710 Creating unique index fails during single user mode 103# - prior to bugfix this would fail 104create unique index new_index on t1 (b,c); 105 106drop table t2; 107 108# test some sql on other mysqld 109--connection server2 110--error 1051 111drop table t1; 112--error 1296 113create index new_index_fail on t1 (c); 114--error 1296 115insert into t1 values (21,21,0),(22,22,0),(23,23,0),(24,24,0),(25,25,0),(26,26,0),(27,27,0),(28,28,0),(29,29,0),(210,210,0); 116--error 1296 117select * from t1 where a = 1; 118--error 1296 119select * from t1 where b = 4; 120--error 1296 121update t1 set b=102 where a = 2; 122--error 1296 123update t1 set b=103 where b = 3; 124--error 1296 125update t1 set b=b+100; 126--error 1296 127update t1 set b=b+100 where a > 7; 128 129--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT 130--exec $NDB_WAITER --no-defaults >> $NDB_TOOLS_OUTPUT 131 132# 133# we should be able to run transaction while in single user mode 134# 135--connection server1 136BEGIN; 137update t1 set b=b+100 where a=1; 138 139--connection server2 140BEGIN; 141update t1 set b=b+100 where a=2; 142 143# enter single user mode 144--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "enter single user mode $node_id" >> $NDB_TOOLS_OUTPUT 145--exec $NDB_WAITER --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" --single-user >> $NDB_TOOLS_OUTPUT 146 147--connection server1 148update t1 set b=b+100 where a=3; 149COMMIT; 150 151# while on other mysqld it should be aborted 152--connection server2 153--error 1296 154update t1 set b=b+100 where a=4; 155ROLLBACK; 156 157# Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb 158# tables for other mysqld nodes 159--connection server2 160create table t2 (a int) engine myisam; 161alter table t2 add column (b int); 162 163# exit single user mode 164--exec $NDB_MGM --no-defaults --ndb-connectstring="$NDB_CONNECTSTRING" -e "exit single user mode" >> $NDB_TOOLS_OUTPUT 165--exec $NDB_WAITER --no-defaults >> $NDB_TOOLS_OUTPUT 166 167# cleanup 168--connection server2 169drop table t2; 170--connection server1 171drop table t1; 172 173# End of 5.0 tests 174 175