Re: [HACKERS] lateral function as a subquery - WIP patch

2012-03-10 Thread Antonin Houska
On 03/10/2012 02:15 AM, Tom Lane wrote: Um ... how do you get the subquery result rows to join to only the correct rows of the other tables? The subquery just restricts the set of rows that the function has to evaluate. The main query is supposed to perform the join. I understand, such a join ca

Re: [HACKERS] lateral function as a subquery - WIP patch

2012-03-10 Thread Robert Haas
On Sat, Mar 10, 2012 at 4:16 AM, Tom Lane wrote: > Robert Haas writes: >> On Fri, Mar 9, 2012 at 8:15 PM, Tom Lane wrote: >>> Um ... how do you get the subquery result rows to join to only the >>> correct rows of the other tables?  This looks like an unconstrained join >>> to me, which is not wh

Re: [HACKERS] lateral function as a subquery - WIP patch

2012-03-10 Thread Tom Lane
Robert Haas writes: > On Fri, Mar 9, 2012 at 8:15 PM, Tom Lane wrote: >> Um ... how do you get the subquery result rows to join to only the >> correct rows of the other tables?  This looks like an unconstrained join >> to me, which is not what I believe the SQL spec for LATERAL to be, and >> it d

Re: [HACKERS] lateral function as a subquery - WIP patch

2012-03-09 Thread Robert Haas
On Fri, Mar 9, 2012 at 8:15 PM, Tom Lane wrote: > Antonin Houska writes: >> For example: > >> SELECT * >> FROM  a, b, func(a.i, b.j) as c, d >> WHERE a.i=b.j and b.j = d.k and c>1 > >> may become > >> SELECT * >> FROM  a, b, as c, d >> WHERE a.i=b.j and b.j = d.k and c>1 > >> where is > >> SELE

Re: [HACKERS] lateral function as a subquery - WIP patch

2012-03-09 Thread Tom Lane
Antonin Houska writes: > For example: > SELECT * > FROM a, b, func(a.i, b.j) as c, d > WHERE a.i=b.j and b.j = d.k and c>1 > may become > SELECT * > FROM a, b, as c, d > WHERE a.i=b.j and b.j = d.k and c>1 > where is > SELECT func(a.i, b.j) > FROM a,b > WHERE a.i=b.j Um ... how do you ge

[HACKERS] lateral function as a subquery - WIP patch

2012-03-09 Thread Antonin Houska
Hello, in the related discussions mentioned on TODO list http://archives.postgresql.org/pgsql-hackers/2009-09/msg00292.php http://archives.postgresql.org/pgsql-hackers/2009-10/msg00991.php (The 1st is rather on SQL, I didn't focuss on it yet.) the implementation is discussed from optimizer/execu