title: PostgreSQL generate_series() with SQL function as arguments
body: <p>I have a SQL function called <code>get_forecast_history(integer,integer)</code> that takes two arguments, a month and a year. The function returns a CUSTOM TYPE created with:</p>
  
  <pre><code>CREATE TYPE fcholder AS (y integer, m integer, product varchar, actual real);
  </code></pre>
  
  <p>The first line of the function definition is:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION get_forecast_history(integer, integer)
    RETURNS SETOF fcholder AS $$
  </code></pre>
  
  <p>Calling:</p>
  
  <pre><code>SELECT * FROM get_forecast_history(10, 2011);
  </code></pre>
  
  <p>For example produces the following table (the result type of the function is a table i.e. <code>SETOF</code>):</p>
  
  <pre>
    y   m product  actual
  ---- -- -------- ------
  2011 10 Product1  29
  2011 10 Product2  10
  2011 10 Product3  8
  2011 10 Product4  0
  2011 10 Product5  2
  </pre>
  
  <p>etc. (about 30 products total). This is the history for the given month.</p>
  
  <p>I also have another query that generates a series of months:</p>
  
  <pre><code>SELECT to_char(DATE '2008-01-01'
              + (interval '1 month' * generate_series(0,57)), 'YYYY-MM-DD') AS ym
  </code></pre>
  
  <p>Which products a list like this:</p>
  
  <pre>
  ym
  ----------
  2008-01-01
  2008-02-01
  2008-03-01
  2008-04-01
  ...
  2011-10-01
  </pre>
  
  <p>I need to somehow <code>LEFT JOIN</code> the results of the <code>generate_series</code> of year/month combinations on the function above by taking the results of the <code>generate_series</code> and passing them as arguments to the function. This way I'll get the results of the function, but for every year/month combination from the <code>generate_series</code>. At this point I'm stuck.</p>
  
  <p>I'm using PostgreSQL 8.3.14.</p>