--- includes/database.inc
+++ includes/database.inc
@@ -121,7 +121,7 @@
  *
  * @return the name of the previously active database or FALSE if non was found.
  */
-function db_set_active($name = 'default') {
+function db_set_active($name = 'default', $reset = FALSE) {
   global $db_url, $db_type, $active_db;
   static $db_conns, $active_name = FALSE;
 
@@ -130,7 +130,7 @@
     install_goto('install.php');
   }
 
-  if (!isset($db_conns[$name])) {
+  if (!isset($db_conns[$name]) || $reset) {
     // Initiate a new connection, using the named DB URL specified.
     if (is_array($db_url)) {
       $connect_url = array_key_exists($name, $db_url) ? $db_url[$name] : $db_url['default'];
