List:Internals« Previous MessageNext Message »
From:David Tymon Date:May 4 2004 8:31am
Subject:DROP DATABASE problem on Linux 2.6, patch included
View as plain text  
Hi,

I have been having problems dropping databases using development snapshots
from the MySQL 4.1 codebase. The problem is more fundamental than those
experienced recently by others with the foreign key constraints.

It appears that in mysql_rm_known_files() in sql_db.cc there is an assumption
that the directory entries for . and .. will be in the first and second
positions. This does not seem to be the case, at least under Linux 2.6 ext3. 
This results in no files being deleted at all from the database directory.

I have included a simple patch that skips the . and .. entries regardless of
their position in the directory entries list which seems to fix the problem.
This patch was based on a snapshot around the 4th May.

I hope it is of some use to you.

David

diff -r -u mysql-4.1.1-20040504.orig/sql/sql_db.cc mysql-4.1.1-20040504/sql/sql_db.cc
--- mysql-4.1.1-20040504.orig/sql/sql_db.cc	2004-05-03 10:48:11.000000000 +1000
+++ mysql-4.1.1-20040504/sql/sql_db.cc	2004-05-04 18:13:44.279538798 +1000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2003 MySQL AB
+/* Copyright (C) 1999-2003 MySQL AB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -462,7 +462,7 @@
 
   tot_list_next= &tot_list;
 
-  for (uint idx=2 ;
+  for (uint idx=0 ;
        idx < (uint) dirp->number_off_files && !thd->killed ;
        idx++)
   {
@@ -470,6 +470,12 @@
     char *extension;
     DBUG_PRINT("info",("Examining: %s", file->name));
 
+    if ( ( strcmp( file->name, "." ) == 0 ) ||
+         ( strcmp( file->name, ".." ) == 0 ) )
+    {
+        continue;
+    }
+
     /* Check if file is a raid directory */
     if ((my_isdigit(&my_charset_latin1, file->name[0]) ||
 	 (file->name[0] >= 'a' && file->name[0] <= 'f')) &&


-- 
David Tymon
Senior Software Engineer                       mailto:dtymon@stripped
Clarity Visual Intelligence                    http://www.clarityvi.com
Tel: +61 3 9417 4466 Fax: +61 3 9417 5566

Thread
DROP DATABASE problem on Linux 2.6, patch includedDavid Tymon4 May
  • Re: DROP DATABASE problem on Linux 2.6, patch includedSergei Golubchik4 May
    • Re: DROP DATABASE problem on Linux 2.6, patch includedDavid Tymon5 May