Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1058
diff -u -p -r1.1058 common.inc
--- includes/common.inc	5 Dec 2009 22:16:44 -0000	1.1058
+++ includes/common.inc	6 Dec 2009 03:10:29 -0000
@@ -5875,8 +5875,10 @@ function drupal_write_record($table, &$o
     }
   }
   // If we have a single-field primary key but got no insert ID, the
-  // query failed.
-  elseif (count($primary_keys) == 1) {
+  // query failed. Note that we explicitly check for FALSE, because
+  // a valid update query which doesn't change any values will return
+  // zero (0) affected rows.
+  elseif ($last_insert_id === FALSE && count($primary_keys) == 1) {
     $return = FALSE;
   }
 
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.94
diff -u -p -r1.94 common.test
--- modules/simpletest/tests/common.test	3 Dec 2009 15:33:42 -0000	1.94
+++ modules/simpletest/tests/common.test	6 Dec 2009 03:10:33 -0000
@@ -1476,6 +1476,12 @@ class DrupalDataApiTest extends DrupalWe
     $update_result = drupal_write_record('taxonomy_vocabulary', $vocabulary, array('vid'));
     $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a record updated with drupal_write_record() for table with single-field primary key.'));
 
+    // Run an update query where no field values are changed. The database
+    // layer should return zero for number of affected rows, but
+    // db_write_record() should still return SAVED_UPDATED.
+    $update_result = drupal_write_record('taxonomy_vocabulary', $vocabulary, array('vid'));
+    $this->assertTrue($update_result == SAVED_UPDATED, t('Correct value returned when a valid update is run without changing any values.'));
+
     // Insert an object record for a table with a multi-field primary key.
     $node_access = new stdClass();
     $node_access->nid = mt_rand();
