pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)
Date: Thu, 15 Sep 2016 16:48:59 -0400
Message-ID: <14138.1473972539@sss.pgh.pa.us> (raw)
In-Reply-To: <20160915203222.27fmxjme5gehluei@alap3.anarazel.de>
References: <20160912165403.vshr7tazhr6wrpp4@alap3.anarazel.de>
	<8136.1473701180@sss.pgh.pa.us>
	<20160912173815.dlew2xsblcso33sw@alap3.anarazel.de>
	<17324.1473716167@sss.pgh.pa.us>
	<20160912220705.b77smzorutebnbee@alap3.anarazel.de>
	<19682.1473719703@sss.pgh.pa.us>
	<20160912231144.f3nseocp274iq7wg@alap3.anarazel.de>
	<23413.1473723322@sss.pgh.pa.us>
	<20160912234630.caueobrrbg5vse5y@alap3.anarazel.de>
	<557.1473895705@sss.pgh.pa.us>
	<20160915203222.27fmxjme5gehluei@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Andres Freund <andres@anarazel.de> writes:
> Hm. One thing I wonder about with this approach, is how we're going to
> handle something absurd like:
> SELECT generate_series(1, generate_series(1, 2)), generate_series(1, generate_series(2,4));

The patch that I posted would run both the generate_series(1, 2) and
generate_series(2,4) calls in the same SRF node, forcing them to run in
lockstep, after which their results would be fed to the SRF node doing
the top-level SRFs.  We could probably change it to run them in separate
nodes, but I don't see any principled way to decide which one goes first
(and in some variants of this example, it would matter).  I think the
LATERAL approach would face exactly the same issues: how many LATERAL
nodes do you use, and what's their join order?

I think we could get away with defining it like this (ie, SRFs at the same
SRF nesting level run in lockstep) as long as it's documented.  Whatever
the current behavior is for such cases would be pretty bizarre too.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (110+ messages)  latest in thread

Message-ID: <14138.1473972539@sss.pgh.pa.us>
Permalink:  ../14138.1473972539@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14138.1473972539@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de
  Subject: Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)
  In-Reply-To: <14138.1473972539@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox