Index: meta.php
===================================================================
--- meta.php	(revision 17320)
+++ meta.php	(working copy)
@@ -93,9 +93,11 @@
  * @param string $meta_value Metadata value
  * @param string $prev_value Optional.  If specified, only update existing metadata entries with
  * 		the specified value.  Otherwise, update all entries.
+ * @param int $metaId ID of the metadata, Optional.  If specified, only update existing metadata entry with
+ * 		the specified value.  Otherwise, update all entities or entities where $prev_value is specified.
  * @return bool True on successful update, false on failure.
  */
-function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value = '') {
+function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_value = '', $metaId = '') {
 	if ( !$meta_type || !$meta_key )
 		return false;
 
@@ -141,15 +143,20 @@
 		$where['meta_value'] = $prev_value;
 	}
 
-	do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
+	if ( !empty( $metaId ) ) {
+		$metaId = intval($metaId);
+		$where['meta_id'] = $metaId;
+	}
 
+	do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value, $metaId );
+
 	$wpdb->update( $table, $data, $where );
 	wp_cache_delete($object_id, $meta_type . '_meta');
 	// users cache stores usermeta that must be cleared.
 	if ( 'user' == $meta_type )
 		clean_user_cache($object_id);
 
-	do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
+	do_action( "updated_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value, $metaId );
 
 	return true;
 }
@@ -323,7 +330,7 @@
 
 	// Get meta info
 	$id_list = join(',', $ids);
-	$meta_list = $wpdb->get_results( $wpdb->prepare("SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list)",
+	$meta_list = $wpdb->get_results( $wpdb->prepare("SELECT $column, meta_key, meta_value, meta_id FROM $table WHERE $column IN ($id_list)",
 		$meta_type), ARRAY_A );
 
 	if ( !empty($meta_list) ) {
@@ -331,6 +338,7 @@
 			$mpid = intval($metarow[$column]);
 			$mkey = $metarow['meta_key'];
 			$mval = $metarow['meta_value'];
+			$mid = intval($metarow['meta_id']);
 
 			// Force subkeys to be array type:
 			if ( !isset($cache[$mpid]) || !is_array($cache[$mpid]) )
@@ -338,8 +346,8 @@
 			if ( !isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey]) )
 				$cache[$mpid][$mkey] = array();
 
-			// Add a value to the current pid/key:
-			$cache[$mpid][$mkey][] = $mval;
+			// Add a meta id and value to the current pid/key:
+			$cache[$mpid][$mkey][] = array('id' => $mid, 'value' => $mval);
 		}
 	}
 
Index: post.php
===================================================================
--- post.php	(revision 17320)
+++ post.php	(working copy)
@@ -1441,14 +1441,15 @@
  * @param string $meta_key Metadata key.
  * @param mixed $meta_value Metadata value.
  * @param mixed $prev_value Optional. Previous value to check before removing.
+ * @param mixed $meta_id Optional. Meta ID value to check before changing.
  * @return bool False on failure, true if success.
  */
-function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
+function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '', $meta_id = '') {
 	// make sure meta is added to the post, not a revision
 	if ( $the_post = wp_is_post_revision($post_id) )
 		$post_id = $the_post;
 
-	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
+	return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value, $meta_id);
 }
 
 /**
