Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1176
diff -u -r1.1176 common.inc
--- includes/common.inc	9 Jun 2010 14:55:30 -0000	1.1176
+++ includes/common.inc	10 Jun 2010 15:29:57 -0000
@@ -5848,8 +5848,8 @@
  *   An object or array representing the record to write, passed in by
  *   reference. The function will fill in defaults from the schema and add an
  *   ID value to serial fields.
- * @param $primary_keys
- *   If this is an update, specify the primary keys' field names. If this is a
+ * @param $update_keys
+ *   If this is an update, specify the update keys' field names. If this is a
  *   new record, you must not provide this value. If there is only 1 field in
  *   the key, you may pass in a string; if there are multiple fields in the key,
  *   pass in an array.
@@ -5861,10 +5861,10 @@
  *   For example, $object->nid or $object['nid'] will be populated after
  *   inserting a new a new node.
  */
-function drupal_write_record($table, &$object, $primary_keys = array()) {
-  // Standardize $primary_keys to an array.
-  if (is_string($primary_keys)) {
-    $primary_keys = array($primary_keys);
+function drupal_write_record($table, &$object, $update_keys = array()) {
+  // Standardize $update_keys to an array.
+  if (is_string($update_keys)) {
+    $update_keys = array($update_keys);
   }
 
   $schema = drupal_get_schema($table);
@@ -5888,7 +5888,7 @@
   foreach ($schema['fields'] as $field => $info) {
     if ($info['type'] == 'serial') {
       // Skip serial types if we are updating.
-      if (!empty($primary_keys)) {
+      if (!empty($update_keys)) {
         continue;
       }
       // Track serial field so we can helpfully populate them after the query.
@@ -5896,10 +5896,16 @@
       $serial = $field;
     }
 
+    // Skip field if it is an update key as it is unnecessary to update a
+    // column to the value it is already set to.
+    if (in_array($field, $update_keys)) {
+      continue;
+    }
+
     if (!property_exists($object, $field)) {
       // Skip fields that are not provided, unless we are inserting and a
       // default value is provided by the schema.
-      if (!empty($primary_keys) || !isset($info['default'])) {
+      if (!empty($update_keys) || !isset($info['default'])) {
         continue;
       }
       $object->$field = $info['default'];
@@ -5945,7 +5951,7 @@
   }
 
   // Build the SQL.
-  if (empty($primary_keys)) {
+  if (empty($update_keys)) {
     // We are doing an insert.
     $options = array('return' => Database::RETURN_INSERT_ID);
     if (isset($serial) && isset($fields[$serial])) {
@@ -5965,7 +5971,7 @@
   }
   else {
     $query = db_update($table)->fields($fields);
-    foreach ($primary_keys as $key) {
+    foreach ($update_keys as $key) {
       $query->condition($key, $object->$key);
     }
     $return = SAVED_UPDATED;
@@ -5988,7 +5994,7 @@
   // 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 ($query_return === FALSE && count($primary_keys) == 1) {
+  elseif ($query_return === FALSE && count($update_keys) == 1) {
     $return = FALSE;
   }
 
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.63
diff -u -r1.63 path.inc
--- includes/path.inc	18 May 2010 18:26:30 -0000	1.63
+++ includes/path.inc	10 Jun 2010 15:29:57 -0000
@@ -393,7 +393,7 @@
   $path += array('pid' => NULL, 'language' => LANGUAGE_NONE);
 
   // Insert or update the alias.
-  $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : NULL));
+  $status = drupal_write_record('url_alias', $path, (!empty($path['pid']) ? 'pid' : array()));
 
   // Verify that a record was written.
   if (isset($status) && $status) {
