diff options
author | unknown <cmiller@zippy.cornsilk.net> | 2007-04-03 18:12:31 -0400 |
---|---|---|
committer | unknown <cmiller@zippy.cornsilk.net> | 2007-04-03 18:12:31 -0400 |
commit | 34a102d909f6bc0e0676e8bb6ff09da691dcbcb6 (patch) | |
tree | 277a34e01d31a440fe065df2535c9f5ed815d67e | |
parent | 698d98bea0522c913ba67159673b8290805b1f33 (diff) | |
download | mariadb-git-34a102d909f6bc0e0676e8bb6ff09da691dcbcb6.tar.gz |
Backport:
Patch contributed by Jocelyn Fournier. CLA received 2007-02-27.
B-g#25347: mysqlcheck -A -r doesn't repair table marked as crashed
mysqlcheck tests nullness of the engine type to know whether the
"table" is a view or not. That also falsely catches tables that
are severly damaged.
Instead, use SHOW FULL TABLES to test whether a "table" is a view
or not.
(Don't add new function. Instead, get original data a smarter way.)
Make it safe for use against databases before when views appeared.
client/mysqlcheck.c:
Use SHOW FULL TABLES to test better whether a name in the table
list is one of a view. Checking that the engine is NULL is
insufficient.
Implemented suggestion from jimw that involved removing most of
original patch and getting data a better way
mysql-test/r/mysqlcheck.result:
Verify that tables that have NULL/unreadable engine types are
processed and not interpreted as views.
mysql-test/t/mysqlcheck.test:
Verify that tables that have NULL/unreadable engine types are
processed and not interpreted as views.
-rw-r--r-- | client/mysqlcheck.c | 27 | ||||
-rw-r--r-- | mysql-test/r/mysqlcheck.result | 10 | ||||
-rw-r--r-- | mysql-test/t/mysqlcheck.test | 16 |
3 files changed, 41 insertions, 12 deletions
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index b69e9201a28..2c23a0bdd14 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -453,14 +453,17 @@ static int process_all_tables_in_db(char *database) { MYSQL_RES *res; MYSQL_ROW row; + uint num_columns; LINT_INIT(res); if (use_db(database)) return 1; - if (mysql_query(sock, "SHOW TABLE STATUS") || + if (mysql_query(sock, "SHOW /*!50002 FULL*/ TABLES") || !((res= mysql_store_result(sock)))) return 1; + num_columns= mysql_num_fields(res); + if (opt_all_in_1) { /* @@ -483,12 +486,11 @@ static int process_all_tables_in_db(char *database) } for (end = tables + 1; (row = mysql_fetch_row(res)) ;) { - /* Skip tables with an engine of NULL (probably a view). */ - if (row[1]) - { - end= fix_table_name(end, row[0]); - *end++= ','; - } + if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) + continue; + + end= fix_table_name(end, row[0]); + *end++= ','; } *--end = 0; if (tot_length) @@ -498,11 +500,12 @@ static int process_all_tables_in_db(char *database) else { while ((row = mysql_fetch_row(res))) - /* Skip tables with an engine of NULL (probably a view). */ - if (row[1]) - { - handle_request_for_tables(row[0], strlen(row[0])); - } + { + if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0)) + continue; + + handle_request_for_tables(row[0], strlen(row[0])); + } } mysql_free_result(res); return 0; diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index b2820df8f4c..81a30267e04 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -41,4 +41,14 @@ test.t1 OK test.t1 OK drop view v1; drop table t1; +create database d_bug25347; +use d_bug25347; +create table t_bug25347 (a int); +create view v_bug25347 as select * from t_bug25347; +removing and creating +d_bug25347.t_bug25347 OK +drop view v_bug25347; +drop table t_bug25347; +drop database d_bug25347; +use test; End of 5.0 tests diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index f4e18d4004f..eb732a05909 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -31,4 +31,20 @@ create view v1 as select * from t1; drop view v1; drop table t1; +# +# Bug#25347: mysqlcheck -A -r doesn't repair table marked as crashed +# +create database d_bug25347; +use d_bug25347; +create table t_bug25347 (a int); +create view v_bug25347 as select * from t_bug25347; +--echo removing and creating +--exec rm $MYSQLTEST_VARDIR/master-data/d_bug25347/t_bug25347.MYI; +--exec touch $MYSQLTEST_VARDIR/master-data/d_bug25347/t_bug25347.MYI; +--exec $MYSQL_CHECK --repair --databases d_bug25347 +drop view v_bug25347; +drop table t_bug25347; +drop database d_bug25347; +use test; + --echo End of 5.0 tests |