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

Home » FUDforum Development » Bug Reports » Bug related to file attachments when using FUDforum with PostgreSQL
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Re: New Install: Attachment problem [message #40407 is a reply to message #40403] Tue, 26 February 2008 23:47 Go to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
I am guessing PostgreSQL 8.3 removed the textcat function FUDforum uses for concatenation. The simplest solution would be to create an equivalent function yourself.

CREATE OR REPLACE FUNCTION extcatl(text, text)
RETURNS text AS 'SELECT $1 || $2;' LANGUAGE 'sql' VOLATILE;


FUDforum Core Developer
Re: New Install: Attachment problem [message #40415 is a reply to message #40407] Wed, 27 February 2008 16:46 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
Ilia wrote on Tue, 26 February 2008 23:47

I am guessing PostgreSQL 8.3 removed the textcat function FUDforum uses for concatenation. The simplest solution would be to create an equivalent function yourself.

CREATE OR REPLACE FUNCTION extcatl(text, text)
RETURNS text AS 'SELECT $1 || $2;' LANGUAGE 'sql' VOLATILE;



Ilia, thanks I tried this but got the same error. I also created the function as 'textcat' (as opposed to 'extcatl') in case this was a typo, but still no joy.

Interestingly (maybe) at first I thought it had worked: if replying to a message, attaching a file gives no error but the file is not attached. When creating a topic and attaching a file to the post, the error message is still there. I don't know if this was the case before I created the above functions.

I thought it might be to do with the database owner: all the tables/functions have the owner as 'postgres' but I created the ones above as 'webmaster'. I re-did them as postgres but this did not help.

Interestingly (again maybe) I dropped the 'extcatl' function with no problem, but when I tried to drop 'textcat' I got the message

NOTICE: removing built-in function "textcat"
ERROR:  cannot drop function textcat(text,text) because it is required by the database system


which makes me think that textcat was already there. I think I confirmed this by dropping the 'or replace' part of the sql and getting this error message:

psql:textcat3.sql:6: ERROR:  function "textcat" already exists with same argument types


So back to the drawing board on this one I'm afraid... any other ideas on how to resolve this?

Thanks,

Derek
Re: New Install: Attachment problem [message #40421 is a reply to message #40415] Thu, 28 February 2008 00:22 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Perhaps you don't have permission to run the function?

FUDforum Core Developer
Re: New Install: Attachment problem [message #40429 is a reply to message #40421] Thu, 28 February 2008 07:07 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
How could I tell if permissions were different for this function compared to all the others?

Here are the details of textcat:
   Schema   |  Name   | Result data type | Argument data types | Volatility |  Owner   | Language | Source code | Description 
------------+---------+------------------+---------------------+------------+----------+----------+-------------+-------------
 pg_catalog | textcat | text             | text, text          | immutable  | postgres | internal | textcat     | concatenate


and here are the details of one of the other functions:
   Schema   |    Name    | Result data type | Argument data types | Volatility |  Owner   | Language |           Source code            | Description 
------------+------------+------------------+---------------------+------------+----------+----------+----------------------------------+-------------
 pg_catalog | textanycat | text             | text, anynonarray   | immutable  | postgres | sql      | select $1 || $2::pg_catalog.text | concatenate


The Language & Source code look (significantly?) different, any clues there?

Thanks

[Updated on: Thu, 28 February 2008 08:03]

Report message to a moderator

Re: New Install: Attachment problem [message #40431 is a reply to message #40429] Thu, 28 February 2008 10:31 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
Just another thought: isn't the problem that the textcat function's argument data types are "text, text" in my database, but the error is to do with "function textcat(unknown, integer) does not exist".

So it is not that 'PostgreSQL 8.3 removed the textcat function' but that the types are wrong somehow? If I were to replace the function again, what should I use rather than 'text, text'?

I'll try 'text, integer' but feels like I'm just guessing... Any help very much appreciated...

Derek

Re: New Install: Attachment problem [message #40435 is a reply to message #40431] Fri, 29 February 2008 01:24 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Oh I see...

You need to edit ppost.php.t and attach.inc.t
and change:

$cc = __FUD_SQL_CONCAT__.'('.__FUD_SQL_CONCAT__."('".$FILE_STORE."', id), '.atch')";

to

$cc = __FUD_SQL_CONCAT__.'('.__FUD_SQL_CONCAT__."('".$FILE_STORE."', id::text), '.atch')";


FUDforum Core Developer
Re: New Install: Attachment problem [message #40483 is a reply to message #40403] Sun, 09 March 2008 15:21 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
I replaced the function again using 'text, integer' rather than 'text, text' and this seemed to work.

I also edited ppost.php.t and attach.inc.t as you suggested.

Thanks for your help.
Bug related to file attachments when using FUDforum with PostgreSQL [message #158116] Mon, 02 February 2009 09:44 Go to previous messageGo to next message
lstep is currently offline  lstep   France
Messages: 50
Registered: June 2003
Karma: 0
Member

There is a bug that seems to have slipped below the radar since February 2008. I know there hasn't been any release since that date, but the 2.8.0RC1 doesn't include the patch (I just checked).

So please, naudefj as you have CVS write access now, could you add the patch?

The thread about this bug is here: http://fudforum.org/forum/index.php?t=msg&th=9928&start=0&

To correct it, just edit the ppost.php.t and attach.inc.t files, changing:
$cc = __FUD_SQL_CONCAT__.'('.__FUD_SQL_CONCAT__."('".$FILE_STORE."', id), '.atch')";

to

$cc = __FUD_SQL_CONCAT__.'('.__FUD_SQL_CONCAT__."('".$FILE_STORE."', id::text), '.atch')";



Without this, users can't add attachments (applies to PostgreSQL installations only).
Re: FUDforum 2.8.0RC1 Released [message #158121 is a reply to message #158116] Mon, 02 February 2009 13:11 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Hi Luc,

What does the "::text" part do? It looks like a typecast. Will this patch break MySQL or SQLlite support?

Best regards.

Frank
Re: FUDforum 2.8.0RC1 Released [message #158122 is a reply to message #158121] Mon, 02 February 2009 14:16 Go to previous messageGo to next message
lstep is currently offline  lstep   France
Messages: 50
Registered: June 2003
Karma: 0
Member

naudefj wrote on Mon, 02 February 2009 14:11
Hi Luc,

What does the "::text" part do? It looks like a typecast. Will this patch break MySQL or SQLlite support?



That's because PostgreSQL, when receiving a call from this function, get in id an integer, but the function in PostgreSQL has a signature "text,text", so it doesn't find a "text,integer" signature, and thus doesn't recognize that function.
So here, we force the definition of "text" so that the signature is correct.
As of knowing if that breaks anything if someone is using MySQL or sqlite, I really have no idea, sorry Confused
Re: New Install: Attachment problem [message #158123 is a reply to message #40483] Mon, 02 February 2009 17:51 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Unfortunately it breaks MySQL. So, it cannot be applied until we get a better patch.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near '::text), '.atch') WHERE id IN(5410)' at line 1
icon8.gif  Re: Bug related to file attachments when using FUDforum with PostgreSQL [message #158142 is a reply to message #158116] Wed, 04 February 2009 23:37 Go to previous messageGo to next message
lstep is currently offline  lstep   France
Messages: 50
Registered: June 2003
Karma: 0
Member

naudefj wrote on Tue, 03 February 2009 21:53
Unfortunately we need a better patch as this one breaks MySQL support. Can you please help us to develop a patch that will work against all databases?


Hmm, no, sorry. I'm not a PHP developer at all.

Isn't it possible to add in the code an "If is_postgreSQL_database(), then..." ?

Re: Bug related to file attachments when using FUDforum with PostgreSQL [message #158183 is a reply to message #158142] Sat, 07 February 2009 00:31 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
just test for postgress and run $cc through a regex and replace id with id::text or something. how often will this actually happen? Will a test statement slow it down enough to notice?
Re: Bug related to file attachments when using FUDforum with PostgreSQL [message #158252 is a reply to message #158183] Thu, 12 February 2009 19:54 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Can you guys please test this patch: http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=11861
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: No correct show any symbols
Next Topic: Don't login
Goto Forum:
  

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

Current Time: Sun Nov 10 19:42:30 GMT 2024

Total time taken to generate the page: 0.02508 seconds