summaryrefslogtreecommitdiff
path: root/mysql-test/suite/parts/t/partition_special_innodb.test
blob: 1fc9ac7fafc867d47b6aecec7c584406c539432c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
################################################################################
# t/partition_special_innodb.test                                              #
#                                                                              #
# Purpose:                                                                     #
#  different Tests                                                             #
#        InnoDB branch                                                         #
#                                                                              #
#------------------------------------------------------------------------------#
# Original Author: HH                                                          #
# Original Date: 2006-08-01                                                    #
# Change Author: MattiasJ                                                      #
# Change Date: 2008-08-20                                                      #
# Change: added test for bug#34604                                             #
################################################################################

#
# NOTE: PLEASE DO NOT ADD NOT INNODB SPECIFIC TESTCASES HERE !
#       TESTCASES WHICH MUST BE APPLIED TO ALL STORAGE ENGINES MUST BE ADDED IN
#       THE SOURCED FILES ONLY.
#
# Please read the README at the end of inc/partition.pre before changing
# any of the variables.
#

#------------------------------------------------------------------------------#
# General not engine specific settings and requirements

##### Options, for debugging support #####
let $debug= 0;

# The server must support partitioning.
--source include/have_partition.inc

#------------------------------------------------------------------------------#
# Engine specific settings and requirements

##### Storage engine to be tested
--source include/have_innodb.inc
let $engine= 'InnoDB';

#------------------------------------------------------------------------------#
# Execute the tests to be applied to all storage engines
--source suite/parts/inc/partition_key_4col.inc
--source suite/parts/inc/partition_key_8col.inc
--source suite/parts/inc/partition_key_16col.inc
--source suite/parts/inc/partition_key_32col.inc

#------------------------------------------------------------------------------#
# Execute storage engine specific tests

--echo # Bug#34604 - Assertion 'inited==RND' failed in handler::ha_rnd_end

CREATE TABLE t1 (
  a INT AUTO_INCREMENT,
  b VARCHAR(255),
  PRIMARY KEY (a))
ENGINE = InnoDB
PARTITION BY HASH (a)
PARTITIONS 2;

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

--connection con1
SET autocommit=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (NULL, 'first row t2');

--connection con2
SET autocommit=OFF;
SET SESSION lock_wait_timeout= 1;
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 AUTO_INCREMENT = 10;

--disconnect con2
--disconnect con1
--connection default
DROP TABLE t1;

--echo #
--echo # Bug#53676: Unexpected errors and possible table corruption on
--echo #            ADD PARTITION and LOCK TABLE
--connect (con1,localhost,root,,)
CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
        ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;

--connect (con2,localhost,root,,)
SET lock_wait_timeout = 2;

--connection con1
--echo #Connection 1 locks the table
LOCK TABLE t1 READ;

--connection con2
--echo # Connection 2 tries to add partitions:
--echo # First attempt: lock wait timeout (as expected)
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
--echo # Second attempt: says that partition already exists
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;

--connection con1
--echo # Connection 1 unlocks the table and locks it again:
UNLOCK TABLES;
--real_sleep 1
LOCK TABLE t1 READ;

--connection con2
--echo # Connection 2 tries again to add partitions:
--echo # Third attempt: says that the table does not exist
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
--echo # Check table returns the same (not after fixing bug#56172!)
CHECK TABLE t1;

--connection con1
UNLOCK TABLES;

--connection con2
DROP TABLE t1;

# End of Test1

# Test2

--connection con1

CREATE TABLE t2 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
        ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;

--connection con2
SET lock_wait_timeout = 2;

--connection con1
LOCK TABLE t2 READ;

--connection con2
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t2 ADD PARTITION PARTITIONS 2;
send ALTER TABLE t2 ADD PARTITION PARTITIONS 2;

--connection con1
UNLOCK TABLES;

--connection con2
--reap

--connect (con3,localhost,root,,)
CHECK TABLE t2;
SELECT * FROM t2;
DROP TABLE t2;

# End of Test2
# Test #3

--connection con1

CREATE TABLE t3 ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, f INT )
        ENGINE = InnoDB PARTITION BY HASH(i) PARTITIONS 2;

--connection con2
SET lock_wait_timeout = 2;

--connection con1
--echo # Connection 1 locks the table
LOCK TABLE t3 READ;

--connection con2
--echo # Connection 2 tries to add partitions (timeout):
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t3 ADD PARTITION PARTITIONS 2;

--connection con3
SET lock_wait_timeout = 2;
--echo # Connection 3 tries to add partitions (partition already exists):
--error ER_LOCK_WAIT_TIMEOUT
ALTER TABLE t3 ADD PARTITION PARTITIONS 2;

--connect (con4,localhost,root,,)
--echo # Connection 4 tries to rename the table:
send RENAME TABLE t3 TO t4;

--connection con1
--real_sleep 1
--echo # Connection 1 unlocks the table:
UNLOCK TABLES;

--connection con4
--echo # Connection 4 gets error on rename:
--reap

--connect (con5,localhost,root,,)
--echo # SHOW TABLES returns the table (not renamed):
SHOW TABLES;
--echo # Connection 5 attempts to read from the table (table does not exist):
--error ER_NO_SUCH_TABLE
SELECT * FROM t3;
DROP TABLE t4;

--disconnect con5
--disconnect con4
--disconnect con3
--disconnect con2
--disconnect con1
--connection default
# End of Test #3