Current time: 05-24-2012, 12:38 PM Hello There, Guest! (LoginRegister)


 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Missing PostgreSQL concat function
10-21-2008, 02:51 PM
Post: #1
[F] Missing PostgreSQL concat function
MyBB Version: 1.4.2
PHP Version: 4.3.10
DB Version: PostgreSQL 8.3.3

I often got an SQL error, which says that the function concat does not exist.

e.g. in:
/admin/index.php?module=user/users&action=search&results=1&conditions=a:1:{s:9"usergroup";s:1:"5";}

when I wanted to watch users that are not activated.

And in PostgreSQL there is no concat function. Since there is no way for varying parameters in PostgreSQL function (until now), I created my own concat functions. Since I'm new to MyBB, I don't know how many arguments could be used for concat by MyBB. I've got functions for a maximum of four parameters.

After I created theses functions everthing worked fine

Maybe one could create these functions when installing MyBB:

Code:
CREATE OR REPLACE FUNCTION concat(text, text) RETURNS text AS $$
    SELECT $1 || $2;
$$ LANGUAGE 'sql';


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


CREATE OR REPLACE FUNCTION concat(text, text, text, text) RETURNS text AS $$
    SELECT $1 || $2 || $3 || $4;
$$ LANGUAGE 'sql';
Find all posts by this user
10-21-2008, 04:20 PM
Post: #2
RE: Missing PostgreSQL concat function
We use switch statements on the db engine that is currently being used to use the right query
Visit this user's website Find all posts by this user
10-21-2008, 04:57 PM
Post: #3
RE: Missing PostgreSQL concat function
(10-21-2008 04:20 PM)Ryan Gordon Wrote:  We use switch statements on the db engine that is currently being used to use the right query

I see, so I dropped my functions to get back to the errors:

This happens when I am in the admin dashbord and I click on the users awaiting activation:

Quote:SQL Error:
0 - ERROR: function concat(unknown, character varying, unknown) does not exist at character 144 HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Query:
SELECT COUNT(u.uid) AS num_results FROM mybb_users u WHERE 1=1 AND (u.usergroup IN (5) OR ','||additionalgroups||',' LIKE '%,5,%'OR CONCAT(',',additionalgroups,',') LIKE '%,5,%')
Find all posts by this user
10-22-2008, 01:56 AM
Post: #4
RE: Missing PostgreSQL concat function
PHP Code:
switch($db->type)
            {
                case 
"pgsql":
                case 
"sqlite3":
                case 
"sqlite2":
                    
$additional_sql .= " OR ','||additionalgroups||',' LIKE '%,{$usergroup},%'";
                default:
                    
$additional_sql .= "OR CONCAT(',',additionalgroups,',') LIKE '%,{$usergroup},%'";
            } 

Not sure what's wrong. Looks like you've made some modifications
Visit this user's website Find all posts by this user
10-22-2008, 11:06 AM (This post was last modified: 10-22-2008 04:32 PM by DoctorCasino.)
Post: #5
RE: Missing PostgreSQL concat function
(10-22-2008 01:56 AM)Ryan Gordon Wrote:  
PHP Code:
switch($db->type)
            {
                case 
"pgsql":
                case 
"sqlite3":
                case 
"sqlite2":
                    
$additional_sql .= " OR ','||additionalgroups||',' LIKE '%,{$usergroup},%'";
                default:
                    
$additional_sql .= "OR CONCAT(',',additionalgroups,',') LIKE '%,{$usergroup},%'";
            } 

Not sure what's wrong. Looks like you've made some modifications

I can't test it right now, but I think there should be a

PHP Code:
break; 

after the first three cases!?
Ok, I added a

PHP Code:
break; 

at line 1926 and it works properly now.
Find all posts by this user
10-22-2008, 08:51 PM
Post: #6
RE: Missing PostgreSQL concat function
Ah, woops - Must have missed that
Visit this user's website Find all posts by this user
10-24-2008, 09:56 PM
Post: #7
[F] Missing PostgreSQL concat function
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group

Dennis Tsang :: MyBB Developer
Follow me on Twitter: @dennistt
Visit this user's website Find all posts by this user
11-16-2008, 09:13 PM
Post: #8
RE: [F] Missing PostgreSQL concat function
This fix seems to be missing in SVN.

Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Visit this user's website Find all posts by this user
11-17-2008, 12:41 AM
Post: #9
RE: [F] Missing PostgreSQL concat function
The fix should be in the SVN now
Visit this user's website Find all posts by this user


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication