List:Internals« Previous MessageNext Message »
From:Jocelyn Fournier Date:March 3 2007 12:14am
Subject:Proposed patch for Bug #25347
View as plain text  
Hi !

Attached for review a patch for bug #25347.
Basically a table with NULL engine is currently skipped because it's 
considered as a view, whereas it could also be a crashed table which 
should not be skipped.
The fix consists in testing more thoroughly if the table with NULL 
engine is a view thanks to SHOW CREATE VIEW.

(fix done in 5.0 tree)

Regards,
 Jocelyn

--- /usr/local/mysql-5.0.36/client/mysqlcheck.c.old	2007-03-02 23:59:39.000000000 +0100
+++ mysqlcheck.c	2007-03-03 00:54:13.000000000 +0100
@@ -448,6 +448,23 @@
   return dest;
 }
 
+static int is_view(MYSQL_ROW *row)
+{
+  MYSQL_RES *res;
+  if (!(*row)[1])
+  {
+     uint length= 18 + strlen((*row)[0]);
+     char query_view_check[length];
+     sprintf(query_view_check,
+                         "SHOW CREATE VIEW %s", (*row)[0]);
+     if (!mysql_query(sock, query_view_check) &&
+            (res= mysql_store_result(sock))) {
+        mysql_free_result(res);
+        return 1;
+     }
+  }
+  return 0;
+}
 
 static int process_all_tables_in_db(char *database)
 {
@@ -483,12 +500,12 @@
     }
     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++= ',';
-      }
+      /* Skip views */
+      if (is_view(&row)) {
+	continue;
+      }     
+      end= fix_table_name(end, row[0]);
+      *end++= ',';
     }
     *--end = 0;
     if (tot_length)
@@ -498,11 +515,13 @@
   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]));
+    {
+      /* Skip views */
+      if (is_view(&row)) {
+        continue;
       }
+      handle_request_for_tables(row[0], strlen(row[0]));
+    }
   }
   mysql_free_result(res);
   return 0;

Thread
Proposed patch for Bug #25347Jocelyn Fournier3 Mar