title: Call plpgsql function in select's where clause
body: <p>I have a plpgsql function <code>complementwhere(parameter1 date)</code>  which returns a complex where clause as a text, let's say it returns <code>clause2 = filter2</code> just as an example, but it actually returns a bunch of other clauses.</p>
  
  <p>I need to call this function in a select's where clause to complement that clause, this is what I have so far:</p>
  
  <pre><code>SELECT value1 FROM table1 WHERE clause1 = filter1 AND complementwhere(parameter1);
  </code></pre>
  
  <p>But this returns the error </p>
  
  <blockquote>
    <p>argument of WHERE must be type boolean, not type text</p>
  </blockquote>
  
  <p>What is the right way to do this?</p>