Re: Changed SRF in targetlist handling - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Changed SRF in targetlist handling
Date
Msg-id 22513.1465228243@sss.pgh.pa.us
Whole thread Raw
In response to Re: Changed SRF in targetlist handling  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Changed SRF in targetlist handling  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Changed SRF in targetlist handling  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, May 23, 2016 at 4:15 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> 2. Rewrite into LATERAL ROWS FROM (srf1(), srf2(), ...).  This would
>> have the same behavior as before if the SRFs all return the same number
>> of rows, and otherwise would behave differently.

> I thought the idea was to rewrite it as LATERAL ROWS FROM (srf1()),
> LATERAL ROWS FROM (srf2()), ...

No, because then you get the cross-product of multiple SRFs, not the
run-in-lockstep behavior.

> The rewrite you propose here seems to NULL-pad rows after the first
> SRF is exhausted:

Yes.  That's why I said it's not compatible if the SRFs don't all return
the same number of rows.  It seems like a reasonable definition to me
though, certainly much more reasonable than the current run-until-LCM
behavior.

> The latter is how I'd expect SRF-in-targetlist to work.

That's not even close to how it works now.  It would break *every*
existing application that has multiple SRFs in the tlist, not just
the ones whose SRFs return different numbers of rows.  And I'm not
convinced that it's a more useful behavior.
        regards, tom lane



pgsql-hackers by date:

Previous
From: 'Bruce Momjian *EXTERN*'
Date:
Subject: Re: Prepared statements and generic plans
Next
From: "David G. Johnston"
Date:
Subject: Re: Prepared statements and generic plans