Skip site navigation (1) Skip section navigation (2)

PERFORM bug with FOUND?

From: david(at)fetter(dot)org (David Fetter)
To: pgsql-bugs(at)postgresql(dot)org
Subject: PERFORM bug with FOUND?
Date: 2003-11-21 22:02:34
Message-ID: G-KdnQUw2qLnFiOiXTWc-w@speakeasy.net (view raw or flat)
Thread:
Lists: pgsql-bugs
Kind people,

I've written a little hack, here included, which is supposed to find
whether a user is in a group.  I'd intended to do a PERFORM instead of
SELECT INTO, but PERFORM appears to set FOUND to true no matter what.
What's going on here?

The hack in question...

CREATE OR REPLACE FUNCTION in_group (text, text) RETURNS BOOLEAN AS '
DECLARE
    the_user  ALIAS FOR $1;
    the_group ALIAS FOR $2;
    dummy text; -- SELECT INTO dummy because PERFORM always returns true.
                -- Is this a bug?
BEGIN
    SELECT INTO dummy u.usename
    FROM
      pg_user u
    , pg_group g
    WHERE
        u.usename = the_user
    AND g.groname = the_group
    AND u.usesysid = ANY (g.grolist);

    IF FOUND
    THEN
        RETURN true;
    ELSE
        RETURN false;
    END IF;
END;
' LANGUAGE 'plpgsql' STRICT IMMUTABLE;

TIA for any hints, tips or pointers :)

Cheers,
D
-- 
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100    cell: +1 415 235 3778

If you don't vote, don't bitch.

Responses

pgsql-bugs by date

Next:From: Andrew Holm-HansenDate: 2003-11-21 22:39:50
Subject: inner query bug
Previous:From: Tom LaneDate: 2003-11-21 16:05:16
Subject: Re: Notes about behaviour of SIMILAR TO operator

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group