On Drupal 6 and PostgreSQL with book and book_manager modules enabled I get these errors when viewing a book content:
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "n.uid" must appear in the GROUP BY clause or be used in an aggregate function in MY_SITE/includes/database.pgsql.inc on line 139.
* user warning: query: _book_manager_get_book_owner SELECT n.uid FROM book b LEFT JOIN node n ON n.nid = b.bid WHERE n.nid = 328 GROUP BY n.nid in MY_SITE/sites/all/modules/book_manager/book_manager.module on line 184.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "n.uid" must appear in the GROUP BY clause or be used in an aggregate function in MY_SITE/includes/database.pgsql.inc on line 139.
* user warning: query: _book_manager_get_book_owner SELECT n.uid FROM book b LEFT JOIN node n ON n.nid = b.bid WHERE n.nid = 328 GROUP BY n.nid in MY_SITE/sites/all/modules/book_manager/book_manager.module on line 184.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | book_manager-546630.patch | 938 bytes | jgraham |
| #4 | book_manager-pgsql-546630-4.patch | 628 bytes | Vector- |
Comments
Comment #1
marcp commentedI don't have pgsql to test against, but I suspect you'll need to change the line that says:
to
If someone on pgsql could confirm that this fixes the problem I'll commit the fix. Otherwise this will probably sit around unfixed for a while [longer].
Comment #2
marcp commentedI committed the fix in #1 above. It doesn't break mysql and it will, hopefully, fix the problem on pgsql. Re-open this if it's still broken.
Comment #4
Vector- commentedThis issue is still present - the theorized fix above does not work.
I think the proper fix looks more like this:
if ($result = db_query("SELECT n.uid FROM {book} b LEFT JOIN {node} n ON n.nid = b.bid WHERE n.nid = %d GROUP BY n.nid, n.uid", $bid)) {I've done some basic testing (in a pgsql environment) and haven't found any problems with this query...
I've got this running on a live site now, so if any users manage to find holes in it, I'll post something new up here.
So long as this doesn't break anything in MySQL (and I don't think it will?)...
Here's the patch I used against v2.1 - if it doesn't break MySQL, I think this is what you want.
Comment #5
jgraham commentedPlease review the attached patch which cleans up the query and should avoid the 'group by' issue altogether.
This applies clean for MySQL, I do not have a PostgreSQL environment to test on.
Comment #6
jgraham commentedCommited: http://drupal.org/cvs?commit=458764