title: JOIN on set returning function results
body: <p>I am trying to join table and function which returns rows:</p>
  
  <pre><code>SELECT p.id, p.name, f.action, f.amount
  FROM person p
  JOIN calculate_payments(p.id) f(id, action, amount) ON (f.id = p.id);
  </code></pre>
  
  <p>This function returns 0, 1 or more rows for each id.
  The query works on PostgreSQL 9.3, but on <strong>9.1</strong> it shows following error:</p>
  
  <blockquote>
  <pre><code>ERROR:  invalid reference to FROM-clause entry for table "p"
  HINT:  There is an entry for table "p", but it cannot be referenced from this part of the query
  </code></pre>
  </blockquote>
  
  <p>I cannot move out calculations from function into the query.<br>
  I cannot use <strong>JOIN LATERAL</strong> which is a new feature in 9.3 as I understand.<br>
  Is there any workaround to this problem?</p>