The following query (line 377 in forum.module) uses IF function, which does not exist in PostgreSQL.

$topic = db_fetch_object(db_query_range('SELECT n.nid, l.last_comment_timestamp, IF(l.last_comm\
ent_uid, cu.name, l.last_comment_name) as last_comment_name, l.last_comment_uid FROM {node} n ' . n\
ode_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.la\
st_comment_timestamp DESC', $forum->tid, 0, 1));
CommentFileSizeAuthor
#1 drupal_783.44 KBttt

Comments

ttt’s picture

StatusFileSize
new3.44 KB

Replaced the 2 occurrences of IF() with the CASE WHEN ... END statement, since PostgreSQL 7.4 does work with IF().

killes@www.drop.org’s picture

Doesn't apply anymore.

adrian’s picture

I have an IF function in the database.pgsql that emulates the mysql IF function.

Was the database created with plpgsql support ?

crnbrdeater’s picture

I had to create the Postgresql function:

CREATE OR REPLACE FUNCTION if( integer, anyelement, anyelement) RETURNS anyelement AS
'SELECT CASE WHEN $1<>0 THEN $2 ELSE $3 END;'
LANGUAGE 'sql' VOLATILE;

to get forums.module to work with Postgresql 8.0

Cvbge’s picture

Status: Active » Closed (duplicate)

The same bug is described in http://drupal.org/node/35061 and I have posted a patch there, thus marking this issue as duplicate.