title: PostgreSQL: how do I set the search_path from inside a function?
body: <p>I need to set the search_path before a query. The new search path should be based on a function parameter. How exactly can I Do it? Right now I have:</p>
  
  <pre><code>CREATE FUNCTION get_sections(integer) RETURNS 
  table(id integer, name varchar, type varchar) as $$
      SET search_path to $1, public;
      select id, name, type from sections;
  $$ language 'sql';
  </code></pre>
  
  <p>But it simply won't accept $1. I also tried with quote_ident($1) but it did not work.</p>
  
  <p>Thanks!</p>