=== modified file 'includes/entity.inc'
--- includes/entity.inc	2010-07-07 13:13:44 +0000
+++ includes/entity.inc	2010-07-21 07:20:21 +0000
@@ -434,6 +434,15 @@ class EntityFieldQuery {
   public $age = FIELD_LOAD_CURRENT;
 
   /**
+   * A list of tags.
+   *
+   * @var array
+   *
+   * @see EntityFieldQuery::addTag()
+   */
+  public $tags = array();
+
+  /**
    * The ordered results.
    *
    * @var array
@@ -735,6 +744,29 @@ class EntityFieldQuery {
   }
 
   /**
+   * Adds a tag to a query.
+   *
+   * Tags are strings that identify a query. A query may have any number of
+   * tags. Tags are used to mark a query so that alter hooks may decide if they
+   * wish to take action. Tags should be all lower-case and contain only letters,
+   * numbers, and underscore, and start with a letter. That is, they should
+   * follow the same rules as PHP identifiers in general.
+   *
+   * For example, queries involving nodes need to add the tag node_access,
+   * taxonomy_terms need term_access. If a query has tags it must also have
+   * an entity type specified because it needs the entity base table.
+   *
+   * @param $tag
+   *   The tag to add.
+   * @return EntityFieldQuery
+   *   The called object.
+   */
+  public function addTag($tag) {
+    $this->tags[] = $tag;
+    return $this;
+  }
+
+  /**
    * Executes the query.
    *
    * After executing the query, $this->orderedResults will contain a list of
@@ -889,7 +921,7 @@ class EntityFieldQuery {
   /**
    * Finishes the query.
    *
-   * Adds the range and returns the requested list.
+   * Adds tags, range and returns the requested list or count.
    *
    * @param SelectQuery $select_query
    *   A SelectQuery which has entity_type, entity_id, revision_id and bundle
@@ -901,6 +933,9 @@ class EntityFieldQuery {
    *   See EntityFieldQuery::execute().
    */
   function finishQuery($select_query, $id_key = 'entity_id') {
+    foreach ($this->tags as $tag) {
+      $select_query->addTag($tag);
+    }
     if ($this->range) {
       $select_query->range($this->range['start'], $this->range['length']);
     }

=== modified file 'modules/field/modules/field_sql_storage/field_sql_storage.module'
--- modules/field/modules/field_sql_storage/field_sql_storage.module	2010-06-26 02:16:23 +0000
+++ modules/field/modules/field_sql_storage/field_sql_storage.module	2010-07-21 07:19:17 +0000
@@ -546,7 +546,8 @@ function field_sql_storage_field_storage
   if (isset($query->deleted)) {
     $select_query->condition("$field_base_table.deleted", (int) $query->deleted);
   }
-  if ($query->propertyConditions || $query->propertyOrder) {
+
+  if ($query->propertyConditions || $query->propertyOrder || $query->tags) {
     if (empty($query->entityConditions['entity_type']['value'])) {
       throw new EntityFieldQueryException('Property conditions and orders must have an entity type defined.');
     }

