The number of SQL errors is growing after new updates of drupal or contibuted modules.

some examples :

Submit personal blog entry
warning: pg_query(): Query failed: ERROR: pg_atoi: error in "blog": can't parse "blog"
. in /usr/local/apache/drupal/includes/database.pgsql.inc on line 104.

user error:
query: SELECT n.*, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid WHERE n.nid = 'blog' in /usr/local/apache/drupal/includes/database.pgsql.inc on line 121.

what can I do to fix these SQL errors in drupal?
Some errors are mentioned here as issues before and are stil not fixed !

CommentFileSizeAuthor
#11 taxonomy_context.module_0.patch1.06 KBpaulgear
#9 taxonomy_context.module.patch1.06 KBAnonymous (not verified)

Comments

erwin’s picture

After selecting a node I get these errors.

warning: pg_query(): Query failed: ERROR: parser: parse error at or near "'1'" at character 219
. in /usr/local/apache/drupal/includes/database.pgsql.inc on line 104.

user error:
query: SELECT DISTINCT(n.nid), n.title, n.body, n.type, n.created, n.changed, n.uid, n.sticky, u.name FROM node n LEFT JOIN term_node r ON n.nid = r.nid LEFT JOIN users u ON n.uid = u.uid WHERE r.tid = 55 AND n.status = '1' '1' ORDER BY sticky DESC, created DESC in /usr/local/apache/drupal/includes/database.pgsql.inc on line 121.

warning: pg_query(): Query failed: ERROR: parser: parse error at or near "'1'" at character 218
. in /usr/local/apache/drupal/includes/database.pgsql.inc on line 104.

user error:
query: SELECT DISTINCT(n.nid), n.title, n.body, n.type, n.created, n.changed, n.uid, n.sticky, u.name FROM node n LEFT JOIN term_node r ON n.nid = r.nid LEFT JOIN users u ON n.uid = u.uid WHERE r.tid = 1 AND n.status = '1' '1' ORDER BY sticky DESC, created DESC in /usr/local/apache/drupal/includes/database.pgsql.inc on line 121.

warning: pg_query(): Query failed: ERROR: parser: parse error at or near "'1'" at character 218
. in /usr/local/apache/drupal/includes/database.pgsql.inc on line 104.

user error:
query: SELECT DISTINCT(n.nid), n.title, n.body, n.type, n.created, n.changed, n.uid, n.sticky, u.name FROM node n LEFT JOIN term_node r ON n.nid = r.nid LEFT JOIN users u ON n.uid = u.uid WHERE r.tid = 0 AND n.status = '1' '1' ORDER BY sticky DESC, created DESC in /usr/local/apache/drupal/includes/database.pgsql.inc on line 121.

jeremy’s picture

Project: Database Administration » Drupal core
Component: Code » postgresql database
Category: support » bug

This is mis-filed as a dba.module bug - but the examples given are with other modules, such as the core's blog.module, and simply viewing nodes. Moving to 'Drupal' project, 'postgresql database' component. Marking as 'bug report'. (It's not clear what version of what modules are being used, though it was marked as a 4.4.2 bug)

jeremy’s picture

Switching back to cvs version against which it was originally filed.

killes@www.drop.org’s picture

Priority: Critical » Normal

It appears to me that you have some contrib module sinstalled which might be buggy. I did not find the queries in the Drupal core. Please send a list of modules.

Anonymous’s picture

Are you sure you're running an up-to-date version of 4.5? Although these queries look vaguely familiar, I think they've been changed / fixed several months ago. Make sure you replace all 4.4 files with the new 4.5 ones... also, see if you can reproduce the problem with a clean install. That would rule out any old files accidentially left hanging around.

As killes suggested, these bad queries might still exist in a contributed module. A list of any you're using would also be helpful.

erwin’s picture

It seems that taxonomy_context is the touble maker here.
I'm using the latest version from cvs, the version information is like :
// $Id: taxonomy_context.module,v 1.26 2004/10/01 00:08:36 uwe Exp $

If I remove this module it seems that all sql errors are gone.

The aggregator module stil has an error.
warning: pg_query(): Query failed: ERROR: Attribute f.title must be GROUPed or used in an aggregate function
. in /usr/local/apache/drupal/includes/database.pgsql.inc on line 104.

user error:
query: SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM aggregator_feed f LEFT JOIN aggregator_item i ON f.fid = i.fid GROUP BY f.fid in /usr/local/apache/drupal/includes/database.pgsql.inc on line 121.

and can be solved by the following line
SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM aggregator_feed f LEFT JOIN aggregator_item i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image

dries’s picture

Project: Drupal core » Taxonomy context
Component: postgresql database » Code

I moved this bug report to the 'taxonomy_content' project.

nedjo’s picture

Title: Is PostgreSQL dropped ? » Query errors

This is likely a duplicate of http://drupal.org/node/11337, "SQL error for anonymous users", which has been fixed in the 4.5 release (though the changes hadn't been merged into the head version).

Anonymous’s picture

StatusFileSize
new1.06 KB

I'm not sure whether this is the same problem or a different one, but i was receiving errors like these:

warning: pg_query(): Query failed: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list in /var/www/drupal/includes/database.pgsql.inc on line 104.

user error:
query: SELECT DISTINCT(n.nid), n.title, n.teaser, n.sticky FROM node n LEFT JOIN term_node r ON n.nid = r.nid LEFT JOIN users u ON n.uid = u.uid WHERE r.tid = 4 AND n.status = '1' AND '1' ORDER BY n.sticky DESC, n.created DESC in /var/www/drupal/includes/database.pgsql.inc on line 121.

This appears to be a very similar problem to that described in http://drupal.org/node/12250, and i fixed it with the attached patch.

paulgear’s picture

Whoops - wasn't logged in. You can contact me via this login if you need any further information about the errors or the patch...

paulgear’s picture

StatusFileSize
new1.06 KB

Sorry - that was a bit cut off, wasn't it? :-)