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 :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
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 18:47 Go to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
add to buddy list
ignore all messages by this user
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 11:46 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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] Wed, 27 February 2008 19: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
add to buddy list
ignore all messages by this user
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 02:07 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 03:03]

Report message to a moderator

Re: New Install: Attachment problem [message #40431 is a reply to message #40429] Thu, 28 February 2008 05:31 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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] Thu, 28 February 2008 20: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
add to buddy list
ignore all messages by this user
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 11:21 Go to previous messageGo to next message
derek is currently offline  derek   United Kingdom
Messages: 21
Registered: May 2007
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 04:44 Go to previous messageGo to next message
lstep is currently offline  lstep   France
Messages: 50
Registered: June 2003
Karma: 0
Member
add to buddy list
ignore all messages by this user

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 08:11 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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 09:16 Go to previous messageGo to next message
lstep is currently offline  lstep   France
Messages: 50
Registered: June 2003
Karma: 0
Member
add to buddy list
ignore all messages by this user

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 12:51 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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 18:37 Go to previous messageGo to next message
lstep is currently offline  lstep   France
Messages: 50
Registered: June 2003
Karma: 0
Member
add to buddy list
ignore all messages by this user

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] Fri, 06 February 2009 19:31 Go to previous messageGo to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
add to buddy list
ignore all messages by this user
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 14:54 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3624
Registered: December 2004
Karma: 17
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
Can you guys please test this patch: http://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=11861
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: No correct show any symbols
Next Topic: Don't login
Goto Forum:
  

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

Current Time: Thu Oct 19 18:07:45 EDT 2017

Total time taken to generate the page: 0.00730 seconds