FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » postgresql 8.2 sql query error (operator precedence)
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
postgresql 8.2 sql query error (operator precedence) [message #35425] Wed, 10 January 2007 13:18 Go to previous message
Oli123 is currently offline  Oli123   Germany
Messages: 1
Registered: January 2007
Karma:
Junior Member
Hi,

with fudforum 2.7.6, php5.1.5 and postgresql 8.2.0 I had the problem, that a normal user does not see any forum after login. Where anonymous and Administrators just see everything as expected.
The following error was found in the pgsql.log:

LOG:  statement: SELECT
                                        m.subject, m.id, m.post_stamp,
                                        u.id, u.alias,
                                        f.cat_id, f.forum_icon, f.id, f.last_post_id, f.moderators, f.name, f.descr, f.post_count, f.
thread_count,
                                        fr.last_view, mo.id, COALESCE(g2.group_cache_opt, g1.group_cache_opt) AS group_cache_opt,
                                        c.cat_opt & 4
                                FROM fud26_fc_view v
                                INNER JOIN fud26_cat c ON c.id=v.c
                                INNER JOIN fud26_forum f ON f.id=v.f
                                INNER JOIN fud26_group_cache g1 ON g1.user_id=2147483647 AND g1.resource_id=f.id
                                LEFT JOIN fud26_msg m ON f.last_post_id=m.id
                                LEFT JOIN fud26_users u ON u.id=m.poster_id  LEFT JOIN fud26_forum_read fr ON fr.forum_id=f.id AND fr
.user_id=27 LEFT JOIN fud26_mod mo ON mo.user_id=27 AND mo.forum_id=f.id LEFT JOIN fud26_group_cache g2 ON g2.user_id=27 AND g2.resou
rce_id=f.id WHERE  (mo.id IS NOT NULL OR (COALESCE(g2.group_cache_opt, g1.group_cache_opt)) & 1)>0 ORDER BY v.id
ERROR:  argument of OR must be type boolean, not type integer


It seems, that it is a operator precedence bug in postgresql, because the operator '>' should precede operator 'OR'.

I solved the issue with the following patch:

diff -Naur ./theme/default/index.php.orig ./theme/default/index.php
--- ./theme/default/index.php.orig      2007-01-10 13:55:29.000000000 +0100
+++ ./theme/default/index.php   2007-01-10 13:54:13.000000000 +0100
@@ -147,7 +147,7 @@
                        LEFT JOIN fud26_users u ON u.id=m.poster_id '.
                        (_uid ? ' LEFT JOIN fud26_forum_read fr ON fr.forum_id=f.id AND fr.user_id='._uid.' LEFT JOIN fud26_mod mo ON mo.user_id='._uid.' AND mo.forum_id=f.id LEFT JOIN fud26_group_cache g2 ON g2.user_id='._uid.' AND g2.resource_id=f.id' : '').
                        ((!$is_a || $cat_id) ?  ' WHERE ' : '') .
-                       ($is_a ? '' : (_uid ? ' (mo.id IS NOT NULL OR (COALESCE(g2.group_cache_opt, g1.group_cache_opt))' : ' (g1.group_cache_opt').' & 1)>0') .
+                       ($is_a ? '' : (_uid ? ' (mo.id IS NOT NULL OR ((COALESCE(g2.group_cache_opt, g1.group_cache_opt))' : ' ((g1.group_cache_opt').' & 1)>0)') .
                        ($cat_id ? ($is_a ? '' : ' AND ') . ' v.c IN('.implode(',', ($cf = $cidxc[$cat_id][5])).') ' : '').' ORDER BY v.id');

        $post_count = $thread_count = $last_msg_id = $cat = 0;


It is just enclosing the COALESCE part up to >0 in brackets.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Reply to PM with Message Quote?
Next Topic: NNTP Mime type addition
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 14:57:41 GMT 2024

Total time taken to generate the page: 0.05378 seconds