summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamil Kalimullin <ramil@mysql.com>2008-11-14 11:40:46 +0400
committerRamil Kalimullin <ramil@mysql.com>2008-11-14 11:40:46 +0400
commite3de8d361efbe43d505665ddc959fef77400ca8a (patch)
treec9498f10d81fcc478d8f18c401dce3175599250f
parentf5583481e3439a74e22170eab631755cc094c32c (diff)
downloadmariadb-git-e3de8d361efbe43d505665ddc959fef77400ca8a.tar.gz
Fix for bug#37527: mysqlcheck fails to report entire database
when InnoDB frm file corruption Problem: mysqlcheck runs 'SHOW FULL TABLE' queries to get table lists. The query may fail for some reasons (e.g. null .frm file) then mysqlcheck doesn't process the database tables. Fix: try to run 'SHOW TABLES' if 'SHOW FULL TABLES' failed. client/mysqlcheck.c: Fix for bug#37527: mysqlcheck fails to report entire database when InnoDB frm file corruption - run "SHOW TABLES" query if "SHOW /*!50002 FULL*/ TABLES" failed; - print error info if both failed. mysql-test/r/mysqlcheck.result: Fix for bug#37527: mysqlcheck fails to report entire database when InnoDB frm file corruption - test result. mysql-test/t/mysqlcheck.test: Fix for bug#37527: mysqlcheck fails to report entire database when InnoDB frm file corruption - test case.
-rw-r--r--client/mysqlcheck.c9
-rw-r--r--mysql-test/r/mysqlcheck.result7
-rw-r--r--mysql-test/t/mysqlcheck.test20
3 files changed, 34 insertions, 2 deletions
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 473e172adf9..513d1974ed0 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -488,9 +488,14 @@ static int process_all_tables_in_db(char *database)
LINT_INIT(res);
if (use_db(database))
return 1;
- if (mysql_query(sock, "SHOW /*!50002 FULL*/ TABLES") ||
- !((res= mysql_store_result(sock))))
+ if ((mysql_query(sock, "SHOW /*!50002 FULL*/ TABLES") &&
+ mysql_query(sock, "SHOW TABLES")) ||
+ !(res= mysql_store_result(sock)))
+ {
+ my_printf_error(0, "Error: Couldn't get table list for database %s: %s",
+ MYF(0), database, mysql_error(sock));
return 1;
+ }
num_columns= mysql_num_fields(res);
diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result
index 89f853e88f7..f8dad6a7769 100644
--- a/mysql-test/r/mysqlcheck.result
+++ b/mysql-test/r/mysqlcheck.result
@@ -63,4 +63,11 @@ Table Op Msg_type Msg_text
test.v1 check status OK
information_schema.routines check note The storage engine for the table doesn't support check
drop view v1;
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a INT);
+test.t1
+Error : Incorrect information in file: './test/t1.frm'
+error : Corrupt
+test.t2 OK
+DROP TABLE t1, t2;
End of 5.0 tests
diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test
index 09ca98d01ad..91006d280a8 100644
--- a/mysql-test/t/mysqlcheck.test
+++ b/mysql-test/t/mysqlcheck.test
@@ -65,4 +65,24 @@ create view v1 as select * from information_schema.routines;
check table v1, information_schema.routines;
drop view v1;
+
+#
+# Bug#37527: mysqlcheck fails to report entire database
+# when frm file corruption
+#
+CREATE TABLE t1(a INT);
+CREATE TABLE t2(a INT);
+# backup then null t1.frm
+--copy_file $MYSQLTEST_VARDIR/master-data/test/t1.frm $MYSQLTEST_VARDIR/master-data/test/t1.frm.bak
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+--write_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+EOF
+--exec $MYSQL_CHECK test
+# restore t1.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm
+--copy_file $MYSQLTEST_VARDIR/master-data/test/t1.frm.bak $MYSQLTEST_VARDIR/master-data/test/t1.frm
+--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.frm.bak
+DROP TABLE t1, t2;
+
+
--echo End of 5.0 tests