2
# Embedded server doesn't support external clients
3
--source include/not_embedded.inc
5
--source include/have_innodb.inc
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
12
# Clean up after previous tests
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
25
# Bug #13783 mysqlcheck tries to optimize and analyze information_schema
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
37
# Bug #16502: mysqlcheck tries to check views
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
51
# Bug #30654: mysqlcheck fails during upgrade of tables whose names include backticks
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`;
60
# Bug#25347: mysqlcheck -A -r doesn't repair table marked as crashed
62
create database 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);
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
73
--exec $MYSQL_CHECK --repair --databases d_bug25347
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;
81
drop table t_bug25347;
82
drop database d_bug25347;
86
# Bug#39541 CHECK TABLE on information_schema myisam tables produces error
88
create view v1 as select * from information_schema.routines;
89
check table v1, information_schema.routines;
93
# Bug#37527: mysqlcheck fails to report entire database
94
# when frm file corruption
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
103
--exec $MYSQL_CHECK test
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
111
--echo End of 5.0 tests
115
# Bug #30679: 5.1 name encoding not performed for views during upgrade
117
create table t1(a int) engine=myisam;
118
create view v1 as select * from t1;
120
let $MYSQLD_DATADIR= `select @@datadir`;
121
--copy_file $MYSQLD_DATADIR/test/v1.frm $MYSQLD_DATADIR/test/v-1.frm
123
--exec $MYSQL_CHECK --check-upgrade --databases test
124
--exec $MYSQL_CHECK --fix-table-names --databases test
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
136
CREATE TABLE `#mysql50#@` (a INT) engine=myisam;
139
--echo mysqlcheck --fix-table-names --databases test
140
--exec $MYSQL_CHECK --fix-table-names --databases test
145
CREATE TABLE `я` (a INT) engine=myisam;
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
158
CREATE DATABASE `#mysql50#a@b`;
160
CREATE TABLE `#mysql50#c@d` (a INT) engine=myisam;
161
CREATE TABLE t1 (a INT) engine=myisam;
163
# Create 5.0 like triggers
164
let $MYSQLTEST_VARDIR= `select @@datadir`;
165
--write_file $MYSQLTEST_VARDIR/a@b/c@d.TRG
167
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr1 BEFORE INSERT ON `c@d` FOR EACH ROW SET NEW.a = 10 * NEW.a'
169
definers='root@localhost'
171
--write_file $MYSQLTEST_VARDIR/a@b/tr1.TRN
175
--write_file $MYSQLTEST_VARDIR/a@b/t1.TRG
177
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER tr2 BEFORE INSERT ON `a@b`.t1 FOR EACH ROW SET NEW.a = 100 * NEW.a'
179
definers='root@localhost'
181
--write_file $MYSQLTEST_VARDIR/a@b/tr2.TRN
186
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
187
WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name;
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
193
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
194
WHERE TRIGGER_SCHEMA="a@b" ORDER BY trigger_name;
196
INSERT INTO `c@d` VALUES (2), (1);
198
INSERT INTO t1 VALUES (3), (5);
206
--echo # Bug #31821: --all-in-1 and --fix-table-names don't work together
210
drop table if exists `#mysql50#t1-1`;
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';
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';
224
# WL#3126 TCP address binding for mysql client library;
225
# - running mysqlcheck --protcol=tcp --bind-address=127.0.0.1
227
--exec $MYSQL_CHECK --protocol=tcp --bind-address=127.0.0.1 --databases test
229
--echo End of 5.1 tests
232
--echo # Bug #35269: mysqlcheck behaves different depending on order of parameters
236
--exec $MYSQL_CHECK -a --fix-table-names test "#mysql50#t1-1"
238
--exec $MYSQL_CHECK -aoc test "#mysql50#t1-1"
242
--echo # Bug#11755431 47205: MAP 'REPAIR TABLE' TO RECREATE +ANALYZE FOR
243
--echo # ENGINES NOT SUPPORTING NATIVE
247
DROP TABLE IF EXISTS bug47205;
251
--echo # Test 1: Check that ALTER TABLE ... rebuilds the table
253
CREATE TABLE bug47205(a VARCHAR(20) PRIMARY KEY)
254
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci engine=innodb;
256
INSERT INTO bug47205 VALUES ("foobar");
257
FLUSH TABLE bug47205;
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
264
--echo # Should indicate that ALTER TABLE ... FORCE is needed
265
CHECK TABLE bug47205 FOR UPGRADE;
267
--echo # ALTER TABLE ... FORCE should rebuild the table
268
--echo # and therefore output "affected rows: 1"
270
ALTER TABLE bug47205 FORCE;
273
--echo # Table should now be ok
274
CHECK TABLE bug47205 FOR UPGRADE;
279
--echo # Test 2: InnoDB - REPAIR not supported
281
CREATE TABLE bug47205(a VARCHAR(20) PRIMARY KEY)
282
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci engine=innodb;
284
FLUSH TABLE bug47205;
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
291
--echo # Should indicate that ALTER TABLE .. FORCE is needed
292
CHECK TABLE bug47205 FOR UPGRADE;
294
--echo # Running mysqlcheck to check and upgrade
295
--exec $MYSQL_CHECK --check-upgrade --auto-repair test
297
--echo # Table should now be ok
298
CHECK TABLE bug47205 FOR UPGRADE;
303
--echo # Test 3: MyISAM - REPAIR supported
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
310
--echo # Should indicate that REPAIR TABLE is needed
311
CHECK TABLE bug47205 FOR UPGRADE;
313
--echo # Running mysqlcheck to check and upgrade
314
--exec $MYSQL_CHECK --check-upgrade --auto-repair test
316
--echo # Table should now be ok
317
CHECK TABLE bug47205 FOR UPGRADE;
323
--echo # Bug#12688860 : SECURITY RECOMMENDATION: PASSWORDS ON CLI
327
DROP DATABASE IF EXISTS b12688860_db;
330
CREATE DATABASE b12688860_db;
331
--exec $MYSQL_CHECK -uroot --password="" --fix-db-names b12688860_db 2>&1
332
DROP DATABASE b12688860_db;