Index: common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756.2.101
diff -u -p -r1.756.2.101 common.inc
--- common.inc	3 Nov 2010 18:54:41 -0000	1.756.2.101
+++ common.inc	30 Nov 2010 08:25:01 -0000
@@ -3453,10 +3453,16 @@ function drupal_write_record($table, &$o
     $update = array($update);
   }
 
+  // Save the current connection and switch to the default conection.
+  // drupal_get_schema() needs to access the cache on the default database.
+  $current_db = db_set_active();
   $schema = drupal_get_schema($table);
   if (empty($schema)) {
     return FALSE;
   }
+  if ($current_db != 'default') {
+    db_set_active($current_db);
+  }
 
   // Convert to an object if needed.
   if (is_array($object)) {
