summaryrefslogtreecommitdiff
path: root/client/mysqlcheck.c
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2008-01-23 11:37:46 -0500
committerunknown <cmiller@zippy.cornsilk.net>2008-01-23 11:37:46 -0500
commit616fd5575363669bd4037dda852ec8732fc71705 (patch)
tree29dbbb37112d2a2fdc21d47f0bae8070cc78a21b /client/mysqlcheck.c
parent349c2acc212ca09a8fa52e520debfb43d455dca3 (diff)
downloadmariadb-git-616fd5575363669bd4037dda852ec8732fc71705.tar.gz
Patch contributed by Jocelyn Fournier. CLA received 2007-02-27.
Bug#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.
Diffstat (limited to 'client/mysqlcheck.c')
-rw-r--r--client/mysqlcheck.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 3b504eb50b0..473e172adf9 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -483,14 +483,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)
{
/*
@@ -513,12 +516,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)
@@ -531,6 +533,9 @@ static int process_all_tables_in_db(char *database)
/* Skip tables with an engine of NULL (probably a view). */
if (row[1])
{
+ if ((num_columns == 2) && (strcmp(row[1], "VIEW") == 0))
+ continue;
+
handle_request_for_tables(row[0], fixed_name_length(row[0]));
}
}