My apologies in advance for this confusing report. I am hoping someone will recognize the SQL below and can tell me what module is or might be creating it.
I am a programmer (mostly perl but I have written a couple of simple Drupal modules for unique customer needs and submitted a couple of Drupal module PostgreSQL patches) and very familiar with SQL. We are running Drupal 7.22 with PostgreSQL 9.1 on both a dev site and a production site which both show this same issue.
This is from the PostgreSQL logs. I do not see anything in the Drupal report of recent log entries.
CDT ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list at character 363
CDT STATEMENT: SELECT DISTINCT nc.nid FROM node_comment_statistics nc INNER JOIN node_access na ON na.nid = nc.nid LEFT JOIN node n ON nc.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'domain_site') OR (na.gid = 0 AND na.realm = 'domain_id'))) AND (n.type <> 'webform_report') AND ( nc.comment_count > 0 )ORDER BY nc.last_comment_timestamp DESC LIMIT 10 OFFSET 0
This should be an easy, easy fix...BUT what is making me crazy is that I can not find the module that is generating this SQL. I have recursively grepped in the (debian) /usr/share/drupal7/ directory for "node_comment_statistics" and "last_comment_timestamp" and examined every file that contains that table or field name. As far as I have been able to find, no Drupal7 module or file in drupal7/includes is generating this SQL either statically or dynamically using the d7 API.
So, does anyone recognize this SQL and can tell me where it might be coming from?
Thank you.