I get these issues when I run cron
warning: pg_query() [function.pg-query]: Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list LINE 1: ...NCT hostname FROM sessions WHERE uid = 2 ORDER BY timestamp ... ^ in /u1/www/www.cincitdi.com/includes/database.pgsql.inc on line 139.
user warning: query: SELECT DISTINCT hostname FROM sessions WHERE uid = 2 ORDER BY timestamp DESC in /u1/www/www.cincitdi.com/sites/all/modules/spambot/spambot.module on line 337.
warning: pg_query() [function.pg-query]: Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list LINE 1: ...CT hostname FROM accesslog WHERE uid = 2 ORDER BY timestamp ... ^ in /u1/www/www.cincitdi.com/includes/database.pgsql.inc on line 139.
user warning: query: SELECT DISTINCT hostname FROM accesslog WHERE uid = 2 ORDER BY timestamp DESC in /u1/www/www.cincitdi.com/sites/all/modules/spambot/spambot.module on line 352.
warning: pg_query() [function.pg-query]: Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list LINE 1: ...NCT hostname FROM sessions WHERE uid = 4 ORDER BY timestamp ... ^ in /u1/www/www.cincitdi.com/includes/database.pgsql.inc on line 139.
user warning: query: SELECT DISTINCT hostname FROM sessions WHERE uid = 4 ORDER BY timestamp DESC in /u1/www/www.cincitdi.com/sites/all/modules/spambot/spambot.module on line 337.
warning: pg_query() [function.pg-query]: Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list LINE 1: ...CT hostname FROM accesslog WHERE uid = 4 ORDER BY timestamp ... ^ in /u1/www/www.cincitdi.com/includes/database.pgsql.inc on line 139.
user warning: query: SELECT DISTINCT hostname FROM accesslog WHERE uid = 4 ORDER BY timestamp DESC in /u1/www/www.cincitdi.com/sites/all/modules/spambot/spambot.module on line 352.
Comments
Comment #1
bengtan commentedFixed and commited (http://drupal.org/cvs?commit=497166).
Now the question is ... are you okay with handpatching your own site, or do you need me to make a development release?
If okay with handpatching, you can try the patch from cvs, or you can modify the function spambot_account_ip_addresses() in the file spambot.module so it reads like the following:
Note: Copy and paste this, don't attempt to type it by hand. And always have a backup handy.
Comment #2
andy_read commentedI also got this error today and came up with my own fix before searching the issue queue. Your suggested fix has simply dropped the ORDER BY timestamp DESC, but if the timestamp ordering is valuable the following alternative fix works in Postgres as well as MySQL:
SELECT hostname FROM {_table_} WHERE uid = %d GROUP BY hostname ORDER BY MAX(timestamp) DESC
Where _table_ is sessions, comments or accesslog
Comment #3
bengtan commented@2:
Thanks for the suggestion, but I'd have to politely decline.
Timestamp ordering was a nice-to-have at the beginning when it was retrieving ip addresses from a single table. However, now that multiple tables are used, it's more trouble than it's worth (in my opinion).
After using spambot.module myself, I haven't found timestamp ordering useful at all.