Hi,

I am on Drupal 4.5.0 and PostgreSQL 7.4.6

I had to add c.format column to GROUP BY clause in line 776 of comment.module to avoid Postgress error messages:

Errors were:

user error: 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 FROM drpl_comments c INNER JOIN drpl_users u ON c.uid = u.uid WHERE c.cid = 139 AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users in .../includes/database.pgsql.inc on line 121.

warning: pg_query(): Query failed: ERROR: column "c.format" must appear in the GROUP BY clause or be used in an aggregate function in .../includes/database.pgsql.inc on line 104.

It was:

$result = db_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 FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid);

After the fix:

$result = db_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 FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 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', $cid);

Not sure whether it is known issue.

Comments

Ddaffyd’s picture

I am sorry for "node.module" in the subject. I thought I found another issue in node.module, but it turned out to be not-yet-supported case in my own code, node module works correctly. I forgot to change the subject line.

Ddaffyd’s picture

I just upgraded to 4.5.1.

I had to fix the line 776 in comment.module again.

Moreover, the same bug exists in line 1546. It lacks v.weight in GROUP BY clause.

The fixed line 1546 should look like:

$result = db_query('SELECT v.mid, v.vote, MAX(r.value) AS value FROM {moderation_votes} v INNER JOIN {moderation_roles} r ON r.mid = v.mid WHERE r.rid IN (%s) GROUP BY v.mid, v.vote, v.weight ORDER BY weight', implode(', ', array_keys($user->roles)));