=== modified file 'includes/database/mysql/database.inc'
--- includes/database/mysql/database.inc	2010-06-29 13:42:18 +0000
+++ includes/database/mysql/database.inc	2010-06-29 18:38:02 +0000
@@ -96,7 +96,7 @@ class DatabaseConnection_mysql extends D
       $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID));
     }
     if (!$this->shutdownRegistered) {
-      drupal_register_shutdown_function(array($this, 'nextIdDelete'));
+      register_shutdown_function(array($this, 'nextIdDelete'));
       $shutdownRegistered = TRUE;
     }
     return $new_id;
@@ -110,10 +110,18 @@ class DatabaseConnection_mysql extends D
     // reinitializes the counter for each table for the first INSERT to the
     // table based solely on values from the table so deleting all values would
     // be a problem in this case. Also, TRUNCATE resets the auto increment
-    // counter.
-    $max_id = $this->query('SELECT MAX(value) FROM {sequences}')->fetchField();
-    // We know we are using MySQL here, so need for the slower db_delete().
-    $this->query('DELETE FROM {sequences} WHERE value < :value', array(':value' => $max_id));
+    // counter. 
+    try {
+      $max_id = $this->query('SELECT MAX(value) FROM {sequences}')->fetchField();
+      // We know we are using MySQL here, so need for the slower db_delete().
+      $this->query('DELETE FROM {sequences} WHERE value < :value', array(':value' => $max_id));
+    }
+    // During testing, this function is called from shutdown with the
+    // wrong prefix so we need to ignore the database errors. There is no
+    // problem with completely ignoring errors here, if these queries fail,
+    // the sequence will work just fine just take a bit more space.
+    catch (PDOException $e) {
+    }
   }
 }
 

