Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 64167632C60 for ; Fri, 11 Dec 2009 04:09:13 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 30326-01 for ; Fri, 11 Dec 2009 08:09:05 +0000 (UTC) X-Greylist: delayed 01:47:04.287838 by SQLgrey-1.7.6 Received: from oldiesmann.fbyneserve.com (unknown [66.187.98.169]) by mail.postgresql.org (Postfix) with ESMTP id C55C96315D5 for ; Fri, 11 Dec 2009 04:09:05 -0400 (AST) Received: from cpe-24-165-117-131.cinci.res.rr.com ([24.165.117.131] helo=[127.0.0.1]) by oldiesmann.fbyneserve.com with esmtpa (Exim 4.69) (envelope-from ) id 1NIyt5-0006Le-4y for pgsql-sql@postgresql.org; Fri, 11 Dec 2009 01:21:59 -0500 Message-ID: <4B21E50A.7090404@oldiesmann.us> Date: Fri, 11 Dec 2009 01:22:02 -0500 From: Michael Eshom User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091130 Thunderbird/3.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: FIND_IN_SET Content-Type: multipart/alternative; boundary="------------040708020903020602020707" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - oldiesmann.fbyneserve.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - oldiesmann.us X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.498 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_MESSAGE=0.001, RDNS_NONE=0.1 X-Spam-Level: X-Archive-Number: 200912/32 X-Sequence-Number: 33470 This is a multi-part message in MIME format. --------------040708020903020602020707 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I am on the marketing team for a popular forum system, and am also the primary PostgreSQL tester/bugfixer. Currently our forum system treats MySQL's FIND_IN_SET() as a boolean (eg whether or not the specified value was found in the given set), which is fine since MySQL will treat any integer greater than 0 as boolean true and 0 as boolean false. I have already managed to write a FIND_IN_SET() function for Postgres that behaves as boolean. However, we would like to be able to use the true functionality of this function (so it will return an integer instead of boolean). This is where I've run into a problem. The mysqlcompat package has a FIND_IN_SET() in it, but it requires plpgsql, and I'd rather not require something that a regular user can't install themselves, regardless of how simple it is for the host to add it. I did find another version of FIND_IN_SET() on a blog with several other MySQL-compatible functions, and while it uses regular SQL, it requires the generate_subscripts() function which isn't available in Postgres 8.1 - the latest version officially supported by CentOS. Is there a way to do this without requiring plpgsql or generate_subscripts? -- Michael "Oldiesmann" Eshom Christian Oldies Fan Cincinnati, Ohio --------------040708020903020602020707 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I am on the marketing team for a popular forum system, and am also the primary PostgreSQL tester/bugfixer. Currently our forum system treats MySQL's FIND_IN_SET() as a boolean (eg whether or not the specified value was found in the given set), which is fine since MySQL will treat any integer greater than 0 as boolean true and 0 as boolean false. I have already managed to write a FIND_IN_SET() function for Postgres that behaves as boolean. However, we would like to be able to use the true functionality of this function (so it will return an integer instead of boolean).

This is where I've run into a problem. The mysqlcompat package has a FIND_IN_SET() in it, but it requires plpgsql, and I'd rather not require something that a regular user can't install themselves, regardless of how simple it is for the host to add it.

I did find another version of FIND_IN_SET() on a blog with several other MySQL-compatible functions, and while it uses regular SQL, it requires the generate_subscripts() function which isn't available in Postgres 8.1 - the latest version officially supported by CentOS.

Is there a way to do this without requiring plpgsql or generate_subscripts?
--
Michael "Oldiesmann" Eshom
Christian Oldies Fan
Cincinnati, Ohio
--------------040708020903020602020707--