[Thread Prev][Thread Next][Index]

mysql bug prevents las ui regenerate



all,

There is a bug in versions of mysql up to 4.0.19 having to do with
deleting databases. After a "drop database" command, some of the
table files may still exist and the database directory would not
be deleted. This affects running make in the $lasroot/las/server
directory causing error messages like the following:

DBD::mysql::db do failed: Can't create database 'las0'. Database exists at 
../xml/perl/LASDB.pm line 430, <STDIN> line 3.
DBD::mysql::db do failed: Can't create database 'las0'. Database exists at 
../xml/perl/LASDB.pm line 430, <STDIN> line 3.
make: *** [../ui/config.js] Error 255


The attached patch to $lasroot/las/xml/perl/LASDB.pm is a work around
for this issue for LAS v6.4. to apply:
in $lasroot/las/xml/perl/ run patch -p0 < LASDB.pm.diff

The bug has to do with mysql's assumption that the first two entries
in the directory structure are "." and ".." and skipping them. This
assumption is not valid on all filesystem implementations. Fedora Core2
is affected(and probably all previous versions). Fedora Core3
distributes a patched version of mysql 3.23.58 which fixes this issue.
It may be possible to use this package on Core2.

The workaround implemented in the attached patch simply deletes each
table individually before calling drop database.

ref: http://lists.mysql.com/internals/13765

-brandon
--- LASDB.pm.orig	2004-11-24 12:15:39.995206159 -0600
+++ LASDB.pm	2004-11-24 14:11:28.826577442 -0600
@@ -219,6 +219,14 @@
 }
 
 ##
+#  Returns an array of table names
+#
+sub Tables {
+    my ($self) = @_;
+    return $self->{dbh}->tables("", "", "%", "");
+}
+
+##
 # Drops a table with
 # <pre>
 #   DROP TABLE IF EXISTS $table
@@ -424,9 +432,20 @@
 	}
 
 # Create db schema for XML. Trashes any old database
-	eval {			# Ignore any errors
-	    $dbh->do(qq(drop database $dbname));
-	};
+        if ($self->dbExists($dbname)) {
+	    eval {			# Ignore any errors
+	        $dbh->do(qq(use $dbname));
+                # work around a mysql bug where databases
+                # are not completely removed because sql_db.cc
+                # assumes that "." and ".." are the first entries
+                # in the directory and skips them.
+                foreach my $table ($self->Tables()) {
+#                   print "Deleting Table = ", $table, "\n";
+                    $self->dropTable($table);
+                }
+	        $dbh->do(qq(drop database $dbname));
+	    };
+        }
 	$dbh->do(qq(create database $dbname));
 	$dbh->do(qq(use $dbname));
 	$dbh->do(qq{CREATE TABLE elements (oid int NOT NULL primary key, name varchar(128) NOT NULL, path varchar(255) NOT NULL)});

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement