# warning: pg_query() [function.pg-query]: Query failed: ERROR: column "x.status_fb" must appear in the GROUP BY clause or be used in an aggregate function in /home/forum/drupal-6.9/includes/database.pgsql.inc on line 139.
# user warning: query: SELECT * FROM (SELECT uid as fbs_uid, status_fb, status_time, sid FROM facebook_status ORDER BY sid DESC) as x GROUP BY fbs_uid ORDER BY sid DESC LIMIT 1 OFFSET 0 in /home/forum/drupal-6.9/sites/all/modules/facebook_status/facebook_status.module on line 579.
# warning: pg_query() [function.pg-query]: Query failed: ERROR: column "x.status_fb" must appear in the GROUP BY clause or be used in an aggregate function in /home/forum/drupal-6.9/includes/database.pgsql.inc on line 139.
# user warning: query: SELECT * FROM (SELECT uid as fbs_uid, status_fb, status_time, sid FROM facebook_status ORDER BY sid DESC) as x GROUP BY fbs_uid ORDER BY sid DESC LIMIT 1 OFFSET 0 in /home/forum/drupal-6.9/sites/all/modules/facebook_status/facebook_status.module on line 579.
Comments
Comment #1
icecreamyou commentedI don't know much about PostgreSQL but I'll look into it. It looks like the problem is that some users have multiple statuses in the DB that are exactly the same. MySQL and MSSQL just pick the status that appears higher in the table (the newer one in this query) but PGSQL refuses that nicety. ;)
You might try changing the query in line 579 on your local copy to use
GROUP BY fbs_uid, status_fbinstead of justGROUP BY fbs_uid... if that works, I'll change it ASAP.Comment #2
wa2nlinux commentedYour suggestion is not work, I dunno about drupal module, but some error reggarding on this are many in here, may be you could try this link http://drupal.org/node/331692
Comment #3
icecreamyou commentedTry this query:
Comment #4
wa2nlinux commentedIf I running directly on console they were error, because fbs_uid is not exist
Comment #5
icecreamyou commentedI'm sorry, I didn't look at that code very closely. Remember that if you run this from a console you need to remove the curly braces {}.
Comment #6
wa2nlinux commentedok that query is no error in result, :D, where I must replace the code ?
Comment #7
icecreamyou commentedAfter more research, I've realized that simply using DISTINCT() does not achieve the desired result. Getting GROUP BY to comply with PostgreSQL standards makes it return the same result as DISTINCT(). The way around this is to use DISTINCT ON (), which doesn't exist in MySQL. But I should be able to trick PostgreSQL by making the query aggregate by using MAX() on the serial column...
Basically, lines 563-586 should be changed to this:
Thanks for testing... hopefully I haven't made an error here.
Comment #8
icecreamyou commentedComment #9
wa2nlinux commentederror stil came up
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "x.status_fb" must appear in the GROUP BY clause or be used in an aggregate function in /home/forum/drupal-6.9/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT uid as fbs_uid, status_fb, status_time, MAX(sid) FROM (SELECT * FROM facebook_status ORDER BY sid DESC) as x GROUP BY fbs_uid ORDER BY sid DESC LIMIT 1 OFFSET 0 in /home/forum/drupal-6.9/sites/all/modules/facebook_status/facebook_status.module on line 587.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "x.status_fb" must appear in the GROUP BY clause or be used in an aggregate function in /home/forum/drupal-6.9/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT uid as fbs_uid, status_fb, status_time, MAX(sid) FROM (SELECT * FROM facebook_status ORDER BY sid DESC) as x GROUP BY fbs_uid ORDER BY sid DESC LIMIT 1 OFFSET 0 in /home/forum/drupal-6.9/sites/all/modules/facebook_status/facebook_status.module on line 587.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "x.status_fb" must appear in the GROUP BY clause or be used in an aggregate function in /home/forum/drupal-6.9/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT uid as fbs_uid, status_fb, status_time, MAX(sid) FROM (SELECT * FROM facebook_status ORDER BY sid DESC) as x GROUP BY fbs_uid ORDER BY sid DESC LIMIT 1 OFFSET 0 in /home/forum/drupal-6.9/sites/all/modules/facebook_status/facebook_status.module on line 587.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "x.status_fb" must appear in the GROUP BY clause or be used in an aggregate function in /home/forum/drupal-6.9/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT uid as fbs_uid, status_fb, status_time, MAX(sid) FROM (SELECT * FROM facebook_status ORDER BY sid DESC) as x GROUP BY fbs_uid ORDER BY sid DESC LIMIT 1 OFFSET 0 in /home/forum/drupal-6.9/sites/all/modules/facebook_status/facebook_status.module on line 587.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: column "x.status_fb" must appear in the GROUP BY clause or be used in an aggregate function in /home/forum/drupal-6.9/includes/database.pgsql.inc on line 139.
* user warning: query: SELECT uid as fbs_uid, status_fb, status_time, MAX(sid) FROM (SELECT * FROM facebook_status ORDER BY sid DESC) as x GROUP BY fbs_uid ORDER BY sid DESC LIMIT 1 OFFSET 0 in /home/forum/drupal-6.9/sites/all/modules/facebook_status/facebook_status.module on line 587.
Comment #10
icecreamyou commentedPhooey. Are you using PGSQL 8.0 or higher? I was really expecting that to work...
Okay well run this in your console and see if it works, I might just have to switch on $GLOBALS['db_type'] which is ugly but will do the job if I can find a query that works.
Comment #11
wa2nlinux commentedwwwserv2:~$ psql --help
This is psql 8.1.15, the PostgreSQL interactive terminal.
I dunno what you want to do with that query, but you can try the sub select ( forgive me if this not a solution)
Comment #12
icecreamyou commentedBased on the syntax from the query you provided, the query should actually be:
I wasn't aware that
DISTINCT ON (uid) uid as fbs_uidwas valid; in MySQL the function (including parameters) become the column name so you can assign the whole thing an alias. A subquery wouldn't be any different, just less efficient.Comment #13
wa2nlinux commentedmay be subquery is solutions ???
Comment #14
icecreamyou commentedTry this.
If that doesn't work, I'm completely out of ideas.
Comment #15
wa2nlinux commentedhmmm so postgresql will not support then ?
Comment #16
icecreamyou commentedPresumably it's possible, I just don't know how to do it. If you can fool around and figure out a way to make DISTINCT ON (uid) work, that would be great. Otherwise I'll try to ask some gurus on IRC but most people seem to have a hard time understanding this query.
Comment #17
icecreamyou commentedAlright, maybe these will work.
If either of the above work don't bother with this one. If you do try this one, even if it doesn't return an error you need to make sure all the columns are returned:
Comment #18
wa2nlinux commentedAll code need little changed to work, adding table alias, adding missing coulumn name and removing comma
Comment #19
icecreamyou commentedOkay, good. Hopefully I'll get this in sometime this weekend. Thanks for testing.
Comment #20
spydmobile commentedI dont know if anyone told you, but recent PostGres (8.1.x is not recent) has critical syntax changes that drastically affect drupal. (this may not be applicable to this issue)
I just installed your 6.x dev version and got this errors on my drupal 6.9 on postgres 8.3.x
Comment #21
icecreamyou commentedIt's the same error. Line 585 instead of 579 probably because you had different settings.
Comment #22
spydmobile commentedOk, is the proposed patched in the dev im using or am I waiting for a dev release to see the effects?
F
Comment #23
icecreamyou commentedIt's not in yet, which is why this issue is not marked as "Fixed."
Comment #24
spydmobile commentedOk thanks :-)
Comment #25
icecreamyou commentedThis should be fixed locally and will be in the next release (probably a dev).