Set returning functions in the SELECT list - Mailing list pgsql-general

From Ryan Kelly
Subject Set returning functions in the SELECT list
Date
Msg-id 20121116141433.GA3716@llserver.lakeliving.com
Whole thread Raw
Responses Re: Set returning functions in the SELECT list
List pgsql-general
I have a question about the behavior of SRFs in the SELECT list.
Consider the following example:

select
    generate_series(1,2),
    generate_series(1,2)
;

And its output:

 generate_series | generate_series
-----------------+-----------------
               1 |               1
               2 |               2

And then this example:

select
    generate_series(1,2),
    generate_series(1,3)
;

 generate_series | generate_series
-----------------+-----------------
               1 |               1
               2 |               2
               1 |               3
               2 |               1
               1 |               2
               2 |               3

My question is "why?" I actually expected the second behavior in both
cases. Also, I'm not sure where this difference in behavior is
documented. I looked at:
http://www.postgresql.org/docs/current/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET
but it doesn't seem to be explicitly mentioned there.

And yes, I understand doing this is deprecated and my results would
probably be better achieved with LATERAL when 9.3 comes out.

-Ryan Kelly


pgsql-general by date:

Previous
From: David Johnston
Date:
Subject: Re: Aggeregate funtion calculating the average value of each same index of an array column in a table
Next
From: Merlin Moncure
Date:
Subject: Re: High SYS CPU - need advise