On Mon, Oct 19, 2015 at 10:24:37AM -0700, David Fetter wrote: > Folks, > > As I was learning how best to add native weighted statistics, coming > soon, I noticed that our ROWS FROM() constructor takes only > set-returning functions, gluing the outputs together side by side > without a join condition of any kind. This is a handy capability, > which I don't find elsewhere in our code, modulo horrible things > involving WITH ORDINALITY and FULL JOIN. > > Did I miss something? > > If not, would it make sense to allow every set-returning construct > inside ROWS FROM(), rather than just some of them?
Based on off-list feedback, this proposal is not as clear as I would have liked. Here's what we get with SRFs: SELECT * FROM ROWS FROM (generate_series(1,5,2),generate_series(4,1,-1)) AS t(i,j); i | j ---+--- 1 | 4 3 | 3 5 | 2 | 1 (4 rows) Here's a similar construct, but not really, from LATERAL: SELECT * FROM generate_series(1,5,2) AS s(i) FULL JOIN LATERAL generate_series(4,1,-1) AS t(j) ON s.i=t.j; i | j ---+--- 1 | 1 | 2 3 | 3 | 4 5 | (5 rows) What I'd like to do is lift the restriction on ROWS FROM(), which currently requires that the stuff inside the parentheses set-returning functions, so constructs something like the following would actually work: SELECT * FROM ROWS FROM ( (VALUES (...), ..., (...)), (SELECT ... ), (INSERT ... RETURNING ... ), my_srf() ) AS t(...) would actually work. What say? Cheers, David. -- David Fetter <da...@fetter.org> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fet...@gmail.com Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers