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

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

When I choose "main pages" in the administration-->registers menu, I get this error:
--------------------------------------------------------------------------------------------
/?q=admin/logs/pages
pg_query(): Query failed: ERROR: column "accesslog.title" 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/pages
query: SELECT COUNT(path) AS hits, path, title, AVG(timer) AS average_time, SUM(timer) AS total_time FROM accesslog GROUP BY path 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-36936_0.diff913 bytesCvbge
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Cvbge’s picture

Component: admin.module » statistics.module
Status: Active » Needs review
FileSize
913 bytes

Hi,
thank you for your report.

As error suggests for postgres some other fields (namely title) 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 field 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)