Closed (duplicate)
Project:
Drupal core
Component:
forum.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Oct 2004 at 06:50 UTC
Updated:
26 Oct 2005 at 13:42 UTC
Jump to comment: Most recent file
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));
Comments
Comment #1
ttt commentedReplaced the 2 occurrences of IF() with the CASE WHEN ... END statement, since PostgreSQL 7.4 does work with IF().
Comment #2
killes@www.drop.org commentedDoesn't apply anymore.
Comment #3
adrian commentedI have an IF function in the database.pgsql that emulates the mysql IF function.
Was the database created with plpgsql support ?
Comment #4
crnbrdeater commentedI 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
Comment #5
Cvbge commentedThe same bug is described in http://drupal.org/node/35061 and I have posted a patch there, thus marking this issue as duplicate.