? -x-681760.patch
? -y681760-node-query_1.patch
? 1001242-select-exists.patch
? 1011706-countQuery.patch
? 681760-node-query_1.patch
? 986296-21-node-type-status.patch
? 993026-sort-nodes-with-test.patch
? authorize_remove_check_plain.patch
? x100.patch
? sites/fullpreview
? sites/all/modules/ctools
? sites/all/modules/delay
? sites/all/modules/devel
? sites/all/modules/domain
? sites/all/modules/domain_prefix
? sites/all/modules/domain_user
? sites/all/modules/domain_views
? sites/all/modules/example
? sites/all/modules/fullpreview
? sites/all/modules/fullpreview.zip
? sites/all/modules/mega_menu
? sites/all/modules/pathauto
? sites/all/modules/pimp
? sites/all/modules/rainbow
? sites/all/modules/role_access
? sites/all/modules/role_edit
? sites/all/modules/secure_permissions
? sites/all/modules/styleguide
? sites/all/modules/token
? sites/all/modules/views
? sites/all/modules/workbench
? sites/all/themes/austin
? sites/all/themes/zen
? sites/default/files
Index: includes/database/select.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/select.inc,v
retrieving revision 1.58
diff -u -p -r1.58 select.inc
--- includes/database/select.inc	28 Dec 2010 18:49:51 -0000	1.58
+++ includes/database/select.inc	31 Dec 2010 18:31:40 -0000
@@ -1362,51 +1362,28 @@ class SelectQuery extends Query implemen
     // Create our new query object that we will mutate into a count query.
     $count = clone($this);
 
-    $group_by = $count->getGroupBy();
+    // Zero-out existing fields and expressions.
+    $fields =& $count->getFields();
+    $fields = array();
+    $expressions =& $count->getExpressions();
+    $expressions = array();
 
-    if (!$count->distinct) {
-      // When not executing a distinct query, we can zero-out existing fields
-      // and expressions that are not used by a GROUP BY.  Fields listed in
-      // the GROUP BY clause need to be present in the query.
-      $fields =& $count->getFields();
-      foreach (array_keys($fields) as $field) {
-        if (empty($group_by[$field])) {
-          unset($fields[$field]);
-        }
-      }
-      $expressions =& $count->getExpressions();
-      foreach (array_keys($expressions) as $field) {
-        if (empty($group_by[$field])) {
-          unset($expressions[$field]);
-        }
-      }
-
-      // Also remove 'all_fields' statements, which are expanded into tablename.*
-      // when the query is executed.
-      foreach ($count->tables as $alias => &$table) {
-        unset($table['all_fields']);
-      }
+    // Also remove 'all_fields' statements, which are expanded into tablename.*
+    // when the query is executed.
+    $tables = &$count->getTables();
+    foreach ($tables as $alias => &$table) {
+      unset($table['all_fields']);
     }
 
-    // If we've just removed all fields from the query, make sure there is at
-    // least one so that the query still runs.
-    $count->addExpression('1');
-
     // Ordering a count query is a waste of cycles, and breaks on some
     // databases anyway.
     $orders = &$count->getOrderBy();
     $orders = array();
 
-    if ($count->distinct && !empty($group_by)) {
-      // If the query is distinct and contains a GROUP BY, we need to remove the
-      // distinct because SQL99 does not support counting on distinct multiple fields.
-      $count->distinct = FALSE;
-    }
-
-    $query = $this->connection->select($count);
-    $query->addExpression('COUNT(*)');
+    // COUNT() is an expression, so we add that back in.
+    $count->addExpression('COUNT(*)');
 
-    return $query;
+    return $count;
   }
 
   public function __toString() {
