System:
------------
PHP 4.4.1
Apache 1.3.34
Drupal CVS-HEAD
Postgresql 8.0.4

Problem:
-------------

When I choose "top visitors" in the administration-->registers menu, I get this error:
--------------------------------------------------------------------------------------------
/?q=admin/logs/visitors
pg_query(): Query failed: ERROR: column "a.uid" must appear in the GROUP BY clause or be used in an aggregate function en la línea 78 del archivo /home/erl/drupal-cvs/includes/database.pgsql.inc.

/?q=admin/logs/visitors
query: SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, ac.aid FROM accesslog a LEFT JOIN access ac ON ac.type = 'host' AND LOWER(a.hostname) LIKE (ac.mask) LEFT JOIN users u ON a.uid = u.uid GROUP BY a.hostname ORDER BY hits DESC LIMIT 30 OFFSET 0 en la línea 95 del archivo /home/erl/drupal-cvs/includes/database.pgsql.inc.
--------------------------------------------------------------------------------------------

This error makes impossible to get these statistics if you are using postgresql as the database. Thanks for your time.

CommentFileSizeAuthor
#1 drupal-head-statistics-36937_0.diff1.13 KBCvbge
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Cvbge’s picture

Component: admin.module » statistics.module
Status: Active » Needs review
FileSize
1.13 KB

Hi,
thank you for your report.

As error suggest for postgres some other fields (namely a.uid, u.name, ac.aid) need to be added to GROUP BY clause.

Mysql in this case gets a random value for fields that are not in group by - treats them as unique in the group. From http://dev.mysql.com/doc/refman/4.1/en/group-by-hidden-fields.html

Do not use this feature if the columns you omit from the GROUP BY part are not unique in the group! You get unpredictable results.

Attached patch adds the fields to the group by clause.

ralfm’s picture

Thanks, I applied this patch and everything works ok now ....... cvs can be updated

Steven’s picture

Status: Needs review » Fixed

Committed to HEAD, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)