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

« back to all changes in this revision

Viewing changes to mysql-test/t/mysqlcheck.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
 
 
2
# Embedded server doesn't support external clients
 
3
--source include/not_embedded.inc
 
4
 
 
5
--source include/have_innodb.inc
 
6
 
 
7
# check that CSV engine was compiled in, as the result of the test
 
8
# depends on the presence of the log tables (which are CSV-based).
 
9
--source include/have_csv.inc
 
10
 
 
11
#
 
12
# Clean up after previous tests
 
13
#
 
14
 
 
15
--disable_warnings
 
16
DROP TABLE IF EXISTS t1, `t``1`, `t 1`;
 
17
drop view if exists v1;
 
18
drop database if exists client_test_db;
 
19
# Repair any tables in mysql, sometimes the slow_log is marked as crashed
 
20
# after server has been killed
 
21
--exec $MYSQL_CHECK --repair  --databases mysql > /dev/null 2>&1
 
22
--enable_warnings
 
23
 
 
24
#
 
25
# Bug #13783  mysqlcheck tries to optimize and analyze information_schema
 
26
#
 
27
--replace_result 'Table is already up to date' OK
 
28
--exec $MYSQL_CHECK --all-databases --analyze
 
29
--exec $MYSQL_CHECK --all-databases --optimize
 
30
--replace_result 'Table is already up to date' OK
 
31
--exec $MYSQL_CHECK --analyze --databases test information_schema mysql
 
32
--exec $MYSQL_CHECK --optimize  --databases test information_schema mysql
 
33
--exec $MYSQL_CHECK --analyze information_schema schemata
 
34
--exec $MYSQL_CHECK --optimize information_schema schemata
 
35
 
 
36
#
 
37
# Bug #16502: mysqlcheck tries to check views
 
38
#
 
39
create table t1 (a int) engine=myisam;
 
40
create view v1 as select * from t1;
 
41
--replace_result 'Table is already up to date' OK
 
42
--exec $MYSQL_CHECK --analyze --databases test
 
43
--exec $MYSQL_CHECK --optimize --databases test
 
44
--replace_result 'Table is already up to date' OK
 
45
--exec $MYSQL_CHECK --all-in-1 --analyze --databases test
 
46
--exec $MYSQL_CHECK --all-in-1 --optimize --databases test
 
47
drop view v1;
 
48
drop table t1;
 
49
 
 
50
#
 
51
# Bug #30654: mysqlcheck fails during upgrade of tables whose names include backticks
 
52
#
 
53
create table `t``1`(a int) engine=myisam;
 
54
create table `t 1`(a int) engine=myisam;
 
55
--replace_result 'Table is already up to date' OK
 
56
--exec $MYSQL_CHECK --databases test
 
57
drop table `t``1`, `t 1`;
 
58
 
 
59
#
 
60
# Bug#25347: mysqlcheck -A -r doesn't repair table marked as crashed
 
61
#
 
62
create database d_bug25347;
 
63
use d_bug25347;
 
64
create table t_bug25347 (a int) engine=myisam;
 
65
create view v_bug25347 as select * from t_bug25347;
 
66
insert into t_bug25347 values (1),(2),(3);
 
67
flush tables;
 
68
let $MYSQLD_DATADIR= `select @@datadir`;
 
69
--echo removing and creating
 
70
--remove_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI
 
71
--write_file $MYSQLD_DATADIR/d_bug25347/t_bug25347.MYI
 
72
EOF
 
73
--exec $MYSQL_CHECK --repair --databases d_bug25347
 
74
--error 130
 
75
insert into t_bug25347 values (4),(5),(6);
 
76
--exec $MYSQL_CHECK --repair --use-frm --databases d_bug25347
 
77
insert into t_bug25347 values (7),(8),(9);
 
78
select * from t_bug25347;
 
79
select * from v_bug25347;
 
80
drop view v_bug25347;
 
81
drop table t_bug25347;
 
82
drop database d_bug25347;
 
83
use test;
 
84
 
 
85
#
 
86
# Bug#39541 CHECK TABLE on information_schema myisam tables produces error
 
87
#
 
88
create view v1 as select * from information_schema.routines;
 
89
check table v1, information_schema.routines;
 
90
drop view v1;
 
91
 
 
92
#
 
93
# Bug#37527: mysqlcheck fails to report entire database 
 
94
# when frm file corruption
 
95
#
 
96
CREATE TABLE t1(a INT) engine=myisam;
 
97
CREATE TABLE t2(a INT) engine=myisam;
 
98
# backup then null t1.frm
 
99
--copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/t1.frm.bak
 
100
--remove_file $MYSQLD_DATADIR/test/t1.frm
 
101
--write_file $MYSQLD_DATADIR/test/t1.frm
 
102
EOF
 
103
--exec $MYSQL_CHECK test
 
104
# restore t1.frm
 
105
--remove_file $MYSQLD_DATADIR/test/t1.frm
 
106
--copy_file $MYSQLD_DATADIR/test/t1.frm.bak $MYSQLD_DATADIR/test/t1.frm
 
107
--remove_file $MYSQLD_DATADIR/test/t1.frm.bak
 
108
DROP TABLE t1, t2;
 
109
 
 
110
 
 
111
--echo End of 5.0 tests
 
112
 
 
113
 
 
114
#
 
115
# Bug #30679: 5.1 name encoding not performed for views during upgrade
 
116
#
 
117
create table t1(a int) engine=myisam;
 
118
create view v1 as select * from t1;
 
119
show tables;
 
120
let $MYSQLD_DATADIR= `select @@datadir`;
 
121
--copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm
 
122
show tables;
 
123
--exec $MYSQL_CHECK --check-upgrade --databases test
 
124
--exec $MYSQL_CHECK --fix-table-names --databases test
 
125
show tables;
 
126
drop view v1, `v-1`;
 
127
drop table t1;
 
128
 
 
129
 
 
130
#
 
131
# Bug #33094: Error in upgrading from 5.0 to 5.1 when table contains triggers
 
132
# Bug #41385: Crash when attempting to repair a #mysql50# upgraded table with
 
133
#             triggers
 
134
#
 
135
SET NAMES utf8;
 
136
CREATE TABLE `#mysql50#@` (a INT) engine=myisam;
 
137
SHOW TABLES;
 
138
SET NAMES DEFAULT;
 
139
--echo mysqlcheck --fix-table-names --databases test
 
140
--exec $MYSQL_CHECK --fix-table-names --databases test
 
141
SET NAMES utf8;
 
142
SHOW TABLES;
 
143
DROP TABLE `@`;
 
144
 
 
145
CREATE TABLE `я` (a INT) engine=myisam;
 
146
SET NAMES DEFAULT;
 
147
--echo mysqlcheck --default-character-set="latin1" --databases test
 
148
# Error returned depends on platform, replace it with "Table doesn't exist"
 
149
call mtr.add_suppression("Can't find file: '..test.@003f.frm'");
 
150
--replace_result "Can't find file: './test/@003f.frm' (errno: 22 - Invalid argument)" "Table doesn't exist" "Table 'test.?' doesn't exist" "Table doesn't exist"
 
151
--exec $MYSQL_CHECK --default-character-set="latin1" --databases test
 
152
--echo mysqlcheck --default-character-set="utf8" --databases test
 
153
--exec $MYSQL_CHECK --default-character-set="utf8" --databases test
 
154
SET NAMES utf8;
 
155
DROP TABLE `я`;
 
156
SET NAMES DEFAULT;
 
157
 
 
158
CREATE DATABASE `#mysql50#a@b`;
 
159
USE `#mysql50#a@b`;
 
160
CREATE TABLE `#mysql50#c@d` (a INT) engine=myisam;
 
161
CREATE TABLE t1 (a INT) engine=myisam;
 
162
 
 
163
# Create 5.0 like triggers
 
164
let $MYSQLTEST_VARDIR= `select @@datadir`;
 
165
--write_file $MYSQLTEST_VARDIR/a@b/c@d.TRG
 
166
TYPE=TRIGGERS
 
167
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON `c@d` FOR EACH ROW SET NEW.a = 10 * NEW.a'
 
168
sql_modes=0
 
169
definers='root@localhost'
 
170
EOF
 
171
--write_file $MYSQLTEST_VARDIR/a@b/tr1.TRN
 
172
TYPE=TRIGGERNAME
 
173
trigger_table=c@d
 
174
EOF
 
175
--write_file $MYSQLTEST_VARDIR/a@b/t1.TRG
 
176
TYPE=TRIGGERS
 
177
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr2 BEFORE INSERT ON `a@b`.t1 FOR EACH ROW SET NEW.a = 100 * NEW.a'
 
178
sql_modes=0
 
179
definers='root@localhost'
 
180
EOF
 
181
--write_file $MYSQLTEST_VARDIR/a@b/tr2.TRN
 
182
TYPE=TRIGGERNAME
 
183
trigger_table=t1
 
184
EOF
 
185
 
 
186
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
 
187
  WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name;
 
188
 
 
189
--echo mysqlcheck --fix-db-names --fix-table-names --all-databases
 
190
--exec $MYSQL_CHECK --default-character-set=utf8 --fix-db-names --fix-table-names --all-databases
 
191
 
 
192
USE `a@b`;
 
193
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
 
194
  WHERE TRIGGER_SCHEMA="a@b" ORDER BY trigger_name;
 
195
 
 
196
INSERT INTO `c@d` VALUES (2), (1);
 
197
SELECT * FROM `c@d`;
 
198
INSERT INTO t1 VALUES (3), (5);
 
199
SELECT * FROM t1;
 
200
 
 
201
DROP DATABASE `a@b`;
 
202
 
 
203
USE test;
 
204
 
 
205
--echo #
 
206
--echo # Bug #31821: --all-in-1 and --fix-table-names don't work together
 
207
--echo #
 
208
 
 
209
--disable_warnings
 
210
drop table if exists `#mysql50#t1-1`;
 
211
--enable_warnings
 
212
 
 
213
create table `#mysql50#t1-1` (a int) engine=myisam;
 
214
--exec $MYSQL_CHECK --all-in-1 --fix-table-names --databases test
 
215
show tables like 't1-1';
 
216
drop table `t1-1`;
 
217
 
 
218
create table `#mysql50#t1-1` (a int) engine=myisam;
 
219
--exec $MYSQL_CHECK --all-in-1 --fix-table-names test "#mysql50#t1-1"
 
220
show tables like 't1-1';
 
221
drop table `t1-1`;
 
222
 
 
223
#
 
224
# WL#3126 TCP address binding for mysql client library;
 
225
# - running mysqlcheck --protcol=tcp --bind-address=127.0.0.1
 
226
#
 
227
--exec $MYSQL_CHECK --protocol=tcp --bind-address=127.0.0.1 --databases test
 
228
 
 
229
--echo End of 5.1 tests
 
230
 
 
231
--echo #
 
232
--echo # Bug #35269: mysqlcheck behaves different depending on order of parameters
 
233
--echo #
 
234
 
 
235
--error 13
 
236
--exec $MYSQL_CHECK -a --fix-table-names test "#mysql50#t1-1"
 
237
--error 1
 
238
--exec $MYSQL_CHECK -aoc test "#mysql50#t1-1"
 
239
 
 
240
 
 
241
--echo #
 
242
--echo # Bug#11755431 47205: MAP 'REPAIR TABLE' TO RECREATE +ANALYZE FOR
 
243
--echo #              ENGINES NOT SUPPORTING NATIVE
 
244
--echo #
 
245
 
 
246
--disable_warnings
 
247
DROP TABLE IF EXISTS bug47205;
 
248
--enable_warnings
 
249
 
 
250
--echo #
 
251
--echo # Test 1: Check that ALTER TABLE ... rebuilds the table
 
252
 
 
253
CREATE TABLE bug47205(a VARCHAR(20) PRIMARY KEY)
 
254
  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci engine=innodb;
 
255
 
 
256
INSERT INTO bug47205 VALUES ("foobar");
 
257
FLUSH TABLE bug47205;
 
258
 
 
259
--echo # Replace the FRM with a 5.0 FRM that will require upgrade
 
260
let $MYSQLD_DATADIR= `select @@datadir`;
 
261
--remove_file $MYSQLD_DATADIR/test/bug47205.frm
 
262
--copy_file std_data/bug47205.frm $MYSQLD_DATADIR/test/bug47205.frm
 
263
 
 
264
--echo # Should indicate that ALTER TABLE ... FORCE is needed
 
265
CHECK TABLE bug47205 FOR UPGRADE;
 
266
 
 
267
--echo # ALTER TABLE ... FORCE should rebuild the table
 
268
--echo # and therefore output "affected rows: 1"
 
269
--enable_info
 
270
ALTER TABLE bug47205 FORCE;
 
271
--disable_info
 
272
 
 
273
--echo # Table should now be ok
 
274
CHECK TABLE bug47205 FOR UPGRADE;
 
275
 
 
276
DROP TABLE bug47205;
 
277
 
 
278
--echo #
 
279
--echo # Test 2: InnoDB - REPAIR not supported
 
280
 
 
281
CREATE TABLE bug47205(a VARCHAR(20) PRIMARY KEY)
 
282
  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci engine=innodb;
 
283
 
 
284
FLUSH TABLE bug47205;
 
285
 
 
286
--echo # Replace the FRM with a 5.0 FRM that will require upgrade
 
287
let $MYSQLD_DATADIR= `select @@datadir`;
 
288
--remove_file $MYSQLD_DATADIR/test/bug47205.frm
 
289
--copy_file std_data/bug47205.frm $MYSQLD_DATADIR/test/bug47205.frm
 
290
 
 
291
--echo # Should indicate that ALTER TABLE .. FORCE is needed
 
292
CHECK TABLE bug47205 FOR UPGRADE;
 
293
 
 
294
--echo # Running mysqlcheck to check and upgrade
 
295
--exec $MYSQL_CHECK --check-upgrade --auto-repair test
 
296
 
 
297
--echo # Table should now be ok
 
298
CHECK TABLE bug47205 FOR UPGRADE;
 
299
 
 
300
DROP TABLE bug47205;
 
301
 
 
302
--echo #
 
303
--echo # Test 3: MyISAM - REPAIR supported
 
304
 
 
305
--echo # Use an old FRM that will require upgrade
 
306
--copy_file std_data/bug36055.frm $MYSQLD_DATADIR/test/bug47205.frm
 
307
--copy_file std_data/bug36055.MYD $MYSQLD_DATADIR/test/bug47205.MYD
 
308
--copy_file std_data/bug36055.MYI $MYSQLD_DATADIR/test/bug47205.MYI
 
309
 
 
310
--echo # Should indicate that REPAIR TABLE is needed
 
311
CHECK TABLE bug47205 FOR UPGRADE;
 
312
 
 
313
--echo # Running mysqlcheck to check and upgrade
 
314
--exec $MYSQL_CHECK --check-upgrade --auto-repair test
 
315
 
 
316
--echo # Table should now be ok
 
317
CHECK TABLE bug47205 FOR UPGRADE;
 
318
 
 
319
DROP TABLE bug47205;
 
320
 
 
321
 
 
322
--echo #
 
323
--echo # Bug#12688860 : SECURITY RECOMMENDATION: PASSWORDS ON CLI
 
324
--echo #
 
325
 
 
326
--disable_warnings
 
327
DROP DATABASE IF EXISTS b12688860_db;
 
328
--enable_warnings
 
329
 
 
330
CREATE DATABASE b12688860_db;
 
331
--exec $MYSQL_CHECK -uroot --password="" --fix-db-names b12688860_db 2>&1
 
332
DROP DATABASE b12688860_db;
 
333
 
 
334
--echo
 
335
--echo End of tests