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
7
drop table if exists t1,t2;
10
# operations allowed while cluster is in single user mode
13
--let $node_id= `SHOW STATUS LIKE 'Ndb_cluster_node_id'`
15
--eval set @node_id= SUBSTRING('$node_id', 20)+0
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
21
# verify that we are indeed in single user mode
22
# and test that some operations give correct errors
25
create 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
29
CREATE LOGFILE GROUP lg1
30
ADD UNDOFILE 'undofile.dat'
36
# test some sql on first mysqld
38
create table t1 (a int key, b int unique, c int) engine ndb;
39
# Check that we can create logfile group
40
CREATE LOGFILE GROUP lg1
41
ADD UNDOFILE 'undofile.dat'
46
--error ER_CREATE_FILEGROUP_FAILED
48
ADD DATAFILE 'datafile.dat'
53
--error ER_DROP_FILEGROUP_FAILED
54
DROP LOGFILE GROUP lg1
59
ADD DATAFILE 'datafile.dat'
64
--error ER_ALTER_FILEGROUP_FAILED
66
DROP DATAFILE 'datafile.dat'
71
DROP DATAFILE 'datafile.dat'
74
--error ER_DROP_FILEGROUP_FAILED
81
DROP LOGFILE GROUP lg1
83
insert 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);
84
create table t2 as select * from t1;
86
select * from t1 where a = 1;
87
# read with unique index
88
select * from t1 where b = 4;
89
# read with ordered index
90
select * from t1 where a > 4 order by a;
92
update t1 set b=102 where a = 2;
93
# update with unique index
94
update t1 set b=103 where b = 3;
95
# update with full table scan
96
update t1 set b=b+100;
97
# update with ordered insex scan
98
update t1 set b=b+100 where a > 7;
99
# delete with full table scan
101
insert into t1 select * from t2;
102
# Bug #27710 Creating unique index fails during single user mode
103
# - prior to bugfix this would fail
104
create unique index new_index on t1 (b,c);
108
# test some sql on other mysqld
113
create index new_index_fail on t1 (c);
115
insert 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);
117
select * from t1 where a = 1;
119
select * from t1 where b = 4;
121
update t1 set b=102 where a = 2;
123
update t1 set b=103 where b = 3;
125
update t1 set b=b+100;
127
update t1 set b=b+100 where a > 7;
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
133
# we should be able to run transaction while in single user mode
137
update t1 set b=b+100 where a=1;
141
update t1 set b=b+100 where a=2;
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
148
update t1 set b=b+100 where a=3;
151
# while on other mysqld it should be aborted
154
update t1 set b=b+100 where a=4;
157
# Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb
158
# tables for other mysqld nodes
160
create table t2 (a int) engine myisam;
161
alter table t2 add column (b int);
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