Re: Set returning functions in select column list

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: Jack Christensen <jackc(at)hylesanderson(dot)edu>, pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Set returning functions in select column list
Date: 2012-02-17 15:30:47
Message-ID: 26377.1329492647@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Johnston <polobo(at)yahoo(dot)com> writes:
> On Feb 16, 2012, at 14:19, Jack Christensen <jackc(at)hylesanderson(dot)edu> wrote:
>> Can someone explain how set returning functions in a select clause work?

> You apparently just did...it CROSS JOINs except in the special case where multiple functions each return the same number of records (generally due to them all operating on the same sized input - like unnest(array) - in which case it synchronizes the generated rows.

I believe the number of rows you get is the least common multiple of the
lengths of the SRF results. This behavior is widely disliked, but we're
unlikely to change it for fear of breaking working apps. The long-term
plan is to implement LATERAL in FROM and then deprecate using SRFs in
target lists altogether.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David W Noon 2012-02-17 15:31:40 Re: Set returning functions in select column list
Previous Message Adrian Klaver 2012-02-17 15:13:41 Re: MySQL search query is not executing in Postgres DB