warning: pg_query(): Query failed - Mailing list pgsql-general

From Aaron Steele
Subject warning: pg_query(): Query failed
Date
Msg-id 5852F6CA-635A-11D9-B587-000A95C0C442@berkeley.edu
Whole thread Raw
List pgsql-general
hi bruno,

yeah, the postgresql problem was fixed by changing IF statements to
CASE statements in forum.module code:

// remove:
-- $topic = db_fetch_object(db_query_range('SELECT DISTINCT(n.nid),
l.last_comment_timestamp, IF(l.last_comment_uid, cu.name,
l.last_comment_name) as last_comment_name, l.last_comment_uid FROM
{node} n ' . node_access_join_sql() . ", {node_comment_statistics} l
/*! USE INDEX (node_comment_timestamp) */, {users} cu, {term_node} r
WHERE n.nid = r.nid AND r.tid = %d AND n.status = 1 AND n.type =
'forum' AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND " .
node_access_where_sql() . ' ORDER BY l.last_comment_timestamp DESC',
$forum->tid, 0, 1));

// add:
++ $topic = db_fetch_object(db_query_range('SELECT DISTINCT(n.nid),
l.last_comment_timestamp, CASE WHEN l.last_comment_uid = 1 THEN cu.name
ELSE l.last_comment_name END as last_comment_name, l.last_comment_uid
FROM {node} n ' . node_access_join_sql() . ", {node_comment_statistics}
l, {users} cu, {term_node} r WHERE n.nid = r.nid AND r.tid = %d AND
n.status = 1 AND n.type = 'forum' AND l.last_comment_uid = cu.uid AND
n.nid = l.nid AND " . node_access_where_sql() . ' ORDER BY
l.last_comment_timestamp DESC', $forum->tid, 0, 1));

thanks for all the support!

aaron

On Jan 6, 2005, at 10:25 PM, Bruno Wolff III wrote:

> On Thu, Jan 06, 2005 at 17:32:30 -0800,
>   Aaron Steele <asteele@berkeley.edu> wrote:
>> hi bruno,
>>
>> turns out that l.last_comment_uid and l.last_comment_name are integer
>> and char var respectively. since i'm using 7.4.1 with strict boolean
>> casting, is there a better alternative to instantiating a different
>> version of pgsql on my server?
>
> A better solution is fixing your code. What do you expect it to do
> anyhow? Once you figure out what you want it to do, you should be able
> to write a boolean expression that is true, false or null when you
> want it to be. If fact from what I saw it seems that you could just use
> a CASE expression and skip the function call altogether.
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>


pgsql-general by date:

Previous
From: Phil Endecott
Date:
Subject: to_char(0,'9999.99') -> ".00"
Next
From: Daniel Schuchardt
Date:
Subject: Re: PostgreSQL 8 on windows very slow