stable function called for every row? - Mailing list pgsql-general

From Gerhard Heift
Subject stable function called for every row?
Date
Msg-id 20090107183113.GB21538@kawo1.rwth-aachen.de
Whole thread Raw
Responses Re: stable function called for every row?  (Gerhard Heift <ml-postgresql-20081012-3518@gheift.de>)
Re: stable function called for every row?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hello,

I have a query like this:

SELECT * FROM table WHERE has_permission('permission_name');

and the function

CREATE FUNCTION has_permission(IN pname text, OUT is_ok boolean) RETURNING boolean AS
$BODY$
BEGIN
  SELECT has_perm INTO is_ok FROM permission WHERE title = pname;

  RAISE INFO 'function called';

  IF is_ok IS FALSE THEN
    -- this function is VOLATILE
    PERFORM log.exception('permission denied');
  END IF;

  RETURN;
END
$BODY$ LANGUAGE 'plpgsql' STABLE SECURITY DEFINER;

The function is called for every row in the table if it is stable or
volatile and only once if it is immutable?

I thought it had to be called only once, if it is stable.

(PostgreSQL 8.3.5)

Regards,
 Gerhard

Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: FreeBSD and large shared_buffers a no-go?
Next
From: Kirk Strauser
Date:
Subject: Re: FreeBSD and large shared_buffers a no-go?