title: SQL function return-type: TABLE vs SETOF records
body: <p>What's the difference between a function that returns <code>TABLE</code> vs <code>SETOF records</code>, all else equal.</p>
  
  <pre><code>CREATE FUNCTION events_by_type_1(text) RETURNS TABLE(id bigint, name text) AS $$
      SELECT id, name FROM events WHERE type = $1;
  $$ LANGUAGE SQL STABLE;
  
  CREATE FUNCTION events_by_type_2(text) RETURNS SETOF record AS $$
      SELECT id, name FROM events WHERE type = $1;
  $$ LANGUAGE SQL STABLE;
  </code></pre>
  
  <p>These functions seem to return the same results. See this <a href="http://sqlfiddle.com/#!15/5f36a/1">SQLFiddle</a>.</p>