Advertisement:

Author Topic: Problem with Membergroups & Permissions  (Read 6278 times)

Offline ChaosX128

  • Newbie
  • *
  • Posts: 6
Problem with Membergroups & Permissions
« on: March 01, 2012, 12:09:14 PM »
Hi I just successfully installed this software on my site (ver 2.0.2).  I'm using PostgreSQL

I'm still trying to figure out how to set up everything the way I want it and have encounter 2 problems so far in regards to errors.

The first error occurs in the "Forum » Administration Center » Membergroups » Edit Membergroups" section.

I can add Membergroups and see them listed, but whenever I go to the Edit Membergroups I get this error:

Quote
ERROR: function find_in_set(smallint, character varying) is not unique
HINT: Could not choose a best candidate function. You may need to add explicit type casts.
File: /home/chaosxfo/public_html/forum/Sources/Subs-Membergroups.php
Line: 736

No idea what to do there...

2nd error occurs in the "Forum » Administration Center » Permissions » General Permissions" section.

I get the error:

Quote
ERROR: function find_in_set(smallint, character varying) is not unique
HINT: Could not choose a best candidate function. You may need to add explicit type casts.
File: /home/chaosxfo/public_html/forum/Sources/ManagePermissions.php
Line: 306

No idea what to do here either.

If anyone could please help or explain to me why or what these errors mean, I'd really appreciate it.

Thanks.

Online emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,158
  • Gender: Male
  • Because Orange is Orange
Re: Problem with Membergroups & Permissions
« Reply #1 on: March 01, 2012, 03:44:47 PM »
Hello ChaosX128 and welcome to sm.org! :)

find_in_set is a custom function created by SMF during the install.
Two find_in_set functions are created for two different type of data (string and integers).

What version of postgre are you using?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline ChaosX128

  • Newbie
  • *
  • Posts: 6
Re: Problem with Membergroups & Permissions
« Reply #2 on: March 01, 2012, 08:35:13 PM »
Hello ChaosX128 and welcome to sm.org! :)

find_in_set is a custom function created by SMF during the install.
Two find_in_set functions are created for two different type of data (string and integers).

What version of postgre are you using?

It says version 8.1.23 on the phpPgAdmin page.

Offline Oldiesmann

  • Lead Developer
  • SMF Super Hero
  • *
  • Posts: 23,290
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Problem with Membergroups & Permissions
« Reply #3 on: March 02, 2012, 01:26:48 PM »
If you go into phpPgAdmin and view the functions for that particular database, how many different "find_in_set" functions do you see listed?

There should only be two - one for "integer, character varying" and one for "text, text".

Offline ChaosX128

  • Newbie
  • *
  • Posts: 6
Re: Problem with Membergroups & Permissions
« Reply #4 on: March 04, 2012, 02:51:41 PM »
I wasn't sure exactly how to fix this problem... It only had two functions listed with the name "find_in_set" as you described.

However, I just reinstalled using mySQL instead and it works fine now.

Maybe a problem with the way I set up the PostgreSQL, idk...  :-\
« Last Edit: March 04, 2012, 11:51:31 PM by ChaosX128 »

Offline ChaosX128

  • Newbie
  • *
  • Posts: 6
Re: Problem with Membergroups & Permissions
« Reply #5 on: March 04, 2012, 11:50:40 PM »
Ok so I decided to do a fresh install in a test directory just to see if this a bug using PostgreSQL.

One "find_in_set" function is "text, text" and the other is "integer, text"

Is that supposed to be the same as character varying?


Online emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,158
  • Gender: Male
  • Because Orange is Orange
Re: Problem with Membergroups & Permissions
« Reply #6 on: March 11, 2012, 10:20:36 AM »
The two find_in_set should be used by postgre depending on the type of data sent (integers or text).

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Oldiesmann

  • Lead Developer
  • SMF Super Hero
  • *
  • Posts: 23,290
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: Problem with Membergroups & Permissions
« Reply #7 on: March 12, 2012, 12:01:08 PM »
Did some more testing with this.

The error is due to PostgreSQL's habit of being extremely picky with data types...

The first parameter is a "smallint", but we don't have a function to explicitly handle a parameter of that type. PostgreSQL can automatically handle conversion from "smallint" to "integer" and from "smallint" to "text". The problem here is that PostgreSQL doesn't know which function to use.

The simple solution is to just add yet another find_in_set function which explicitly handles smallint:

Code: [Select]
CREATE OR REPLACE FUNCTION FIND_IN_SET(needle smallint, haystack text) RETURNS integer AS '
SELECT i AS result
FROM generate_series(1, array_upper(string_to_array($2,'',''), 1)) AS g(i)
WHERE  (string_to_array($2,'',''))[i] = CAST($1 AS text)
UNION ALL
SELECT 0
LIMIT 1'
LANGUAGE 'sql';

That will fix the issue. I'll commit the change in a bit.

Online emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 12,158
  • Gender: Male
  • Because Orange is Orange
Re: Problem with Membergroups & Permissions
« Reply #8 on: March 27, 2012, 11:31:50 AM »
For the record: committed (ff3655588dc23fe5cfd2bb2ab8735b1d11a30d88).

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.