Upon visiting project/issues/user I receive this drupal error message:

* warning: pg_query() [function.pg-query]: Query failed: ERROR: argument of OR must be type boolean, not type bigint in /srv/www/htdocs/deepend/html/secure/includes/database.pgsql.inc on line 139.

* user warning: query: SELECT COUNT(*) FROM (SELECT node.nid AS nid FROM node node INNER JOIN project_issues project_issues ON node.nid = project_issues.nid INNER JOIN users users_project_issues ON project_issues.assigned = users_project_issues.uid LEFT JOIN node node_project_issues ON project_issues.rid = node_project_issues.nid INNER JOIN node node_project_issues_1 ON project_issues.pid = node_project_issues_1.nid INNER JOIN project_projects node_project_issues_1__project_projects ON node_project_issues_1.nid = node_project_issues_1__project_projects.nid LEFT JOIN history history_user ON node.nid = history_user.nid AND history_user.uid = 1 LEFT JOIN project_release_nodes node_project_issues__project_release_nodes ON node_project_issues.nid = node_project_issues__project_release_nodes.nid INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid WHERE (node.status <> 0 OR node.uid = 1 or 1 = 1) AND (project_issues.sid in ('1', '2', '4 in /srv/www/htdocs/deepend/html/secure/sites/all/modules/views/includes/view.inc on line 705.

* warning: pg_query() [function.pg-query]: Query failed: ERROR: argument of OR must be type boolean, not type bigint in /srv/www/htdocs/deepend/html/secure/includes/database.pgsql.inc on line 139.

* user warning: query: SELECT node.nid AS nid, node_project_issues_1.title AS node_project_issues_1_title, node_project_issues_1.nid AS node_project_issues_1_nid, node_project_issues_1__project_projects.uri AS node_project_issues_1__project_projects_uri, node.title AS node_title, history_user.timestamp AS history_user_timestamp, history_user.nid AS history_user_nid, node.created AS node_created, node.changed AS node_changed, project_issues.sid AS project_issues_sid, project_issues.priority AS project_issues_priority, project_issues.category AS project_issues_category, node_project_issues__project_release_nodes.version AS node_project_issues__project_release_nodes_version, node_project_issues__project_release_nodes.nid AS node_project_issues__project_release_nodes_nid, node_comment_statistics.comment_count AS node_comment_statistics_comment_count, node.type AS node_type, node_comment_statistics.last_comment_timestamp AS node_comment_statistics_last_comment_timestamp, users_ in /srv/www/htdocs/deepend/html/secure/sites/all/modules/views/includes/view.inc on line 731.

CommentFileSizeAuthor
#11 454754-11.views_comment_where_pgsql.patch1.99 KBdww
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dww’s picture

Status: Active » Postponed (maintainer needs more info)

- These queries look like they're generated from views.
- The path you mention in the post is "project/issues/user" which is the "My issues" page.

However, the title of this says "create issue" page.

Which is it? ;)

danielb’s picture

Title: PGSQL errors on 'create issue' page. » PGSQL errors on 'my issues' page.
Status: Postponed (maintainer needs more info) » Active
dww’s picture

Issue tags: +6.x-1.0 blocker

Thanks for the clarification.

I'm not sure what would be causing that -- this page is entirely constructed via views, and AFAIK, views should be fully pgsql-compliant. My pgsql test site has fallen into a terrible state of disrepair, so I don't have a great way to test/debug this now. :(

To clarify: you don't change any of the exposed filters at all, right? You just visit the page for the first time and you get the errors?

I hope someone with pgsql installed can look into this... We should make sure this is working before we ship 6.x-1.0 officially.

dww’s picture

Project: Project » Project issue tracking
Component: Projects » Views integration

Moving to the appropriate queue + component.

danielb’s picture

Do you understand where the problem in the query is? I don't actually understand the error message.

What does "argument of OR" refer to?
Is it this? I notice the second OR is lowercase.... does postgres confuse this for an arg? I don't get it.

(node.status <> 0 OR node.uid = 1 or 1 = 1) 

I am fairly familiar with the views api, and can look through and play around with some of the views includes in the project_issue module.

This is my first drupal installation with pgsql, but I am in the process of learning to become a pgsql developer, so I am keen to work this out.

dww’s picture

No, I'm not sure what error pgsql is complaining about. It does seem likely this is a views + pgsql problem, not specific to project_issue. A couple of years ago I was using pgsql for a little while, but hardly consider myself an expert...

danielb’s picture

OK I'm on to something.

The original query that fails:

SELECT COUNT(*) FROM (
	SELECT node.nid AS nid 
	FROM node node 
	INNER JOIN project_issues project_issues ON node.nid = project_issues.nid 
	INNER JOIN users users_project_issues ON project_issues.assigned = users_project_issues.uid 
	LEFT JOIN node node_project_issues ON project_issues.rid = node_project_issues.nid 
	INNER JOIN node node_project_issues_1 ON project_issues.pid = node_project_issues_1.nid 
	INNER JOIN project_projects node_project_issues_1__project_projects ON node_project_issues_1.nid = node_project_issues_1__project_projects.nid 
	LEFT JOIN history history_user ON node.nid = history_user.nid AND history_user.uid = 1 
	LEFT JOIN project_release_nodes node_project_issues__project_release_nodes ON node_project_issues.nid = node_project_issues__project_release_nodes.nid 
	INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid 
	WHERE (node.status <> 0 OR node.uid = 1 OR 1 = 1) 
	AND (project_issues.sid in ('1', '2', '4')) 
	AND (node.uid = 1 OR (SELECT COUNT(*) FROM comments c WHERE c.uid = 1 AND c.nid = node.nid)) 
) count_alias

Here is a query that works:

SELECT COUNT(*) FROM (
	SELECT node.nid AS nid 
	FROM node node 
	INNER JOIN project_issues project_issues ON node.nid = project_issues.nid 
	INNER JOIN users users_project_issues ON project_issues.assigned = users_project_issues.uid 
	LEFT JOIN node node_project_issues ON project_issues.rid = node_project_issues.nid 
	INNER JOIN node node_project_issues_1 ON project_issues.pid = node_project_issues_1.nid 
	INNER JOIN project_projects node_project_issues_1__project_projects ON node_project_issues_1.nid = node_project_issues_1__project_projects.nid 
	LEFT JOIN history history_user ON node.nid = history_user.nid AND history_user.uid = 1 
	LEFT JOIN project_release_nodes node_project_issues__project_release_nodes ON node_project_issues.nid = node_project_issues__project_release_nodes.nid 
	INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid 
	WHERE (node.status <> 0 OR node.uid = 1 OR 1 = 1) 
	AND (project_issues.sid in ('1', '2', '4')) 
	AND (node.uid = 1 OR (SELECT COUNT(*) FROM comments c WHERE c.uid = 1 AND c.nid = node.nid) > 0) 
) count_alias

Pay attention to the 2nd last line. In the original query the syntax is "AND (x compared to y OR n)" whereas I've changed it to "AND (x compared to y OR n compared to m)" . I believe postgres expects each part of the WHERE to evaluate to a boolean TRUE or FALSE. Simply evaluating to a postive number does not equal TRUE.

dww’s picture

Yup, that's definitely it. I don't have time now to see where that part of the query is coming from, but that's clearly the right part to investigate.

Thanks!

danielb’s picture

I believe this is coming from /views/modules/comment/views_handler_filter_comment_user_uid.inc (and possibly similar) files.

<?php
    $this->query->add_where($this->options['group'], "$this->table_alias.uid " . $condition . " OR
      (SELECT COUNT(*) FROM {comments} c WHERE c.uid " . $condition . " AND c.nid = $this->table_alias.nid)",
      $args);
?>

I'll leave it to you whether to move this to the views project.

danielb’s picture

No I was wrong it's coming from an almost identical piece of code in /views/modules/comment/views_handler_argument_comment_user_uid.inc

dww’s picture

Title: PGSQL errors on 'my issues' page. » PGSQL errors with comment_user_uid (filter and argument)
Project: Project issue tracking » Views (for Drupal 7)
Version: 6.x-1.x-dev » 6.x-2.x-dev
Component: Views integration » comment data
Assigned: Unassigned » dww
Issue tags: -6.x-1.0 blocker
FileSize
1.99 KB

This is definitely a bug in views, not project_issue. I grepped through all the views code and these two spots you identified are the only places that do a subselect as part of a WHERE clause that try to use the COUNT(*) value directly as a boolean instead of comparing it to 0. So, this can safely by classified as a "comment data" issue. ;)

Attached patch is tested as still working in MySQL. I don't have a PgSQL test site, so I'm not positive it fixes the bug, but it definitely should...

@danielb: Note: the argument is used for the "my issues" page, but the filter would be used on any "advanced search" page if you entered a username in the "participant" field. So, you should be able to test both spots that this patch touches. If you can confirm it solves the problem in pgsql, please set the status to "reviewed & tested by the community" (RTBC) so that merlinofchaos can commit it.

Thanks!
-Derek

dww’s picture

Status: Active » Needs review
danielb’s picture

I have not applied your patch, but looking at it, these are the exact changes I made to fix the problem earlier today. Even if the patch fails to apply for some reason the changes indicated in it are correct.
I can test it out tomorrow to confirm, and try the advanced search function.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Liam Morland’s picture

Issue tags: +PostgreSQL

Tagging