title: postgresql privileges Ensuring inserts are only done through functions
body: <p>Let's say I have a table persons which contains only a name(varchar) and a user client.</p>
  
  <p>I'd like that the only way for client to insert to persons is through the function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION add_a_person(a_name varying character)
    RETURNS void AS
  $BODY$
  BEGIN
      INSERT INTO persons VALUES(a_name);
  END;
  $BODY$
    LANGUAGE plpgsql VOLATILE COST 100;
  </code></pre>
  
  <p>So, I don't want to grant client insert privileges on persons and only give execute privilege for add_a_person. 
  But without doing so, I'd get a permission denied because of the use of insert inside the function.</p>
  
  <p>I have not found a way to this in the postgres documentation about granting privileges. 
  Is there a way to do this?</p>