title: SQL state: 42883, No function matches the given name and argument types. But that function actually exists
body: <p>I have a server with PostgreSQL 8.1.23, with a function that works perfectly when it runs with <code>postgres</code> user, but with another user shows the SQL STATE: </p>
  
  <blockquote>
  <pre><code>SQL state: 42883
  </code></pre>
  </blockquote>
  
  <p>This is my function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION fun_validatepost(integer, integer)
    RETURNS integer AS
  $BODY$
  ...
  $BODY$
  LANGUAGE plpgsql VOLATILE;
  ALTER FUNCTION fun_validatepost(integer, integer)
    OWNER TO postgres;
  GRANT EXECUTE ON FUNCTION fun_validatepost(integer, integer) TO public;
  GRANT EXECUTE ON FUNCTION fun_validatepost(integer, integer) TO postgres;
  GRANT EXECUTE ON FUNCTION fun_validatepost(integer, integer) TO someuser;
  </code></pre>
  
  <p>If I run this with postgres user like this:</p>
  
  <pre><code>select fun_validatepost(1,230465);
  </code></pre>
  
  <p>The result is like this:</p>
  
  <pre><code>-[ RECORD 1 ]-----------+--
  fun_validatepost        | 1
  </code></pre>
  
  <p>But if I execute the same query as someuser, shows me this message:</p>
  
  <blockquote>
  <pre><code>ERROR:  function fun_validatepost(integer, integer) does not exist
  SQL state: 42883
  HINT:  No function matches the given name and argument types. You may need to add explicit type casts
  </code></pre>
  </blockquote>
  
  <p>Even if a do a explicit cast I get the same result:</p>
  
  <pre><code>select fun_validatepost from fun_validatepost(1::integer,230465::integer);
  </code></pre>
  
  <p>Same error message.</p>
  
  <p>What can I do so <code>someuser</code> can execute the same function?<br>
  Is there something wrong with my function or cast?</p>