~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to mysql-test/suite/ndb/t/ndb_single_user.test

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
drop 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
 
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'
 
31
INITIAL_SIZE 16M
 
32
UNDO_BUFFER_SIZE = 1M
 
33
ENGINE=NDB;
 
34
show warnings;
 
35
 
 
36
# test some sql on first mysqld
 
37
--connection server1
 
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'
 
42
INITIAL_SIZE 16M
 
43
UNDO_BUFFER_SIZE = 1M
 
44
ENGINE=NDB;
 
45
--connection server2
 
46
--error ER_CREATE_FILEGROUP_FAILED
 
47
CREATE TABLESPACE ts1
 
48
ADD DATAFILE 'datafile.dat'
 
49
USE LOGFILE GROUP lg1
 
50
INITIAL_SIZE 12M
 
51
ENGINE NDB;
 
52
show warnings;
 
53
--error ER_DROP_FILEGROUP_FAILED
 
54
DROP LOGFILE GROUP lg1 
 
55
ENGINE =NDB;
 
56
show warnings;
 
57
--connection server1
 
58
CREATE TABLESPACE ts1
 
59
ADD DATAFILE 'datafile.dat'
 
60
USE LOGFILE GROUP lg1
 
61
INITIAL_SIZE 12M
 
62
ENGINE NDB;
 
63
--connection server2
 
64
--error ER_ALTER_FILEGROUP_FAILED
 
65
ALTER TABLESPACE ts1
 
66
DROP DATAFILE 'datafile.dat'
 
67
ENGINE NDB;
 
68
show warnings;
 
69
--connection server1
 
70
ALTER TABLESPACE ts1
 
71
DROP DATAFILE 'datafile.dat'
 
72
ENGINE NDB;
 
73
--connection server2
 
74
--error ER_DROP_FILEGROUP_FAILED
 
75
DROP TABLESPACE ts1
 
76
ENGINE NDB;
 
77
show warnings;
 
78
--connection server1
 
79
DROP TABLESPACE ts1
 
80
ENGINE NDB;
 
81
DROP LOGFILE GROUP lg1 
 
82
ENGINE =NDB;
 
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;
 
85
# read with pk
 
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;
 
91
# update with pk
 
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
 
100
delete from t1;
 
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);
 
105
 
 
106
drop table t2;
 
107
 
 
108
# test some sql on other mysqld
 
109
--connection server2
 
110
--error 1051
 
111
drop table t1;
 
112
--error 1296
 
113
create index new_index_fail on t1 (c);
 
114
--error 1296
 
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);
 
116
--error 1296
 
117
select * from t1 where a = 1;
 
118
--error 1296
 
119
select * from t1 where b = 4;
 
120
--error 1296
 
121
update t1 set b=102 where a = 2;
 
122
--error 1296
 
123
update t1 set b=103 where b = 3;
 
124
--error 1296
 
125
update t1 set b=b+100;
 
126
--error 1296
 
127
update 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
 
136
BEGIN;
 
137
update t1 set b=b+100 where a=1;
 
138
 
 
139
--connection server2
 
140
BEGIN;
 
141
update 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
 
148
update t1 set b=b+100 where a=3;
 
149
COMMIT;
 
150
 
 
151
# while on other mysqld it should be aborted
 
152
--connection server2
 
153
--error 1296
 
154
update t1 set b=b+100 where a=4;
 
155
ROLLBACK;
 
156
 
 
157
# Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb
 
158
# tables for other mysqld nodes
 
159
--connection server2
 
160
create table t2 (a int) engine myisam;
 
161
alter 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
 
169
drop table t2;
 
170
--connection server1
 
171
drop table t1;
 
172
 
 
173
# End of 5.0 tests
 
174