There is a random, uneccessary "GROUP BY" clause added to the original comment query. But, there are no aggregation functions (COUNT,MAX,MIN,etc.) on the main query. Removes and fixes a couple quries that do that. Below is an example of the problematic query. Notice the GROUP BY added at the end.

$query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d';
      $query_args = array($cid);
      if (!user_access('administer comments')) {
        $query .= ' AND c.status = %d';
        $query_args[] = COMMENT_PUBLISHED;
      }
      $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.status';
CommentFileSizeAuthor
comment_sql_clean_up.patch1.15 KBSouvent22

Comments

Souvent22’s picture

Status: Active » Needs review
chx’s picture

Title: SQL Clean Up (comments) » Comments should not use GROUP BY on a blob
Version: x.y.z » 6.x-dev
Category: bug » task
ChrisKennedy’s picture

Status: Needs review » Closed (duplicate)

Well, so much for this one. Duplicated at http://drupal.org/node/102151 and fixed within 3 hours. Good work finding the bug 3 months earlier though.