title: inconsistent behaviour of set-returning functions in sub-query with random()
body: <p>I'm often using the WHERE clause <code>random() &gt; 0.5</code> to pick a random subset of my data. Now I noticed that when using a set-returning function in a sub-query, I either get the whole set or none (meaning that the WHERE random() > 0.5 clause is interpreted <em>before</em> the set is being generated).
  e.g.:</p>
  
  <pre><code>SELECT num 
  FROM (
      SELECT unnest(Array[1,2,3,4,5,6,7,8,9,10]) num
  ) AS foo 
  WHERE random() &gt; 0.5;
  </code></pre>
  
  <p>This seems inconsistent because the following query <em>does</em> take the whole set into account:</p>
  
  <pre><code>SELECT num 
  FROM (
      SELECT unnest(Array[1,2,3,4,5,6,7,8,9,10]) num
  ) AS foo 
  WHERE random() &gt; 0.1 * num;
  </code></pre>
  
  <p>Am I correct that this is inconsistent or does it make sense?</p>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>couldn't find another function to test apart from random(), but likely there is some</p></li>
  <li><p>I tested with generate_series as well  </p></li>
  </ul>