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: signature.asc
Description: Digital signature

Reply via email to