PostgreSQL patch
| Project: | Site map |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "u.uid" must appear in the GROUP BY clause or be used in an aggregate function in /usr/share/drupal/includes/database.pgsql.inc on line 125.
* user warning: query: SELECT DISTINCT u.uid, u.name, count(u.uid) AS numitems FROM node n INNER JOIN users u ON u.uid = n.uid WHERE n.type = 'blog' and n.status = 1 GROUP BY n.uid ORDER BY numitems DESC, u.name LIMIT 10 OFFSET 0 in /usr/share/drupal/includes/database.pgsql.inc on line 144.
... the simple fix for this in postgreSQL I believe is:
change:
GROUP BY n.uid
to:
GROUP BY u.uid, u.name, n.uid
results:
uid | name | numitems
-----+----------------+----------
3 | Harry Potter | 21
4 | Albus Dumbledore | 5
5 | Hermione Granger | 4
16 | Cho Chang | 4
11 | Sirius Black | 3
17 | Bathilda Bagshot | 2
13 | Cedric Diggory | 2
22 | Dudley Dursley | 2
20 | Neville Longbottom | 1
25 | Luna Lovegood | 1
(10 rows)
Thanks

#1
+1 (but I am using 6.x-1.0)
#2
If you have time I would appreciate if you could try out the 6-dev version. I have rebuilt this part of the code there.
#3
#4
Marking this as a duplicate of #455840: PostgreSQL: invalid GROUP BY with use of DISTINCT since there is a patch posted there.