--
-- grant_permission/3
--
create or replace function grant_permission(
  p_object_id integer,
  p_grantee_id integer,
  p_privilege character varying
) returns int4 as $$

DECLARE
BEGIN
    insert into acs_permissions
      (object_id, grantee_id, privilege)
    values
      (p_object_id, p_grantee_id, p_privilege);
    
    return 0;
EXCEPTION 
    when unique_violation then
      return 0;
END;
$$ language plpgsql;