From: | David Fetter <david(at)fetter(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: ROWS FROM(): A Foolish (In)Consistency? |
Date: | 2015-10-19 18:07:55 |
Message-ID: | 20151019180755.GA17257@fetter.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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 <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua D. Drake | 2015-10-19 18:09:57 | Re: pg_restore cancel TODO |
Previous Message | Robbie Harwood | 2015-10-19 18:01:01 | Re: [PATCH v3] GSSAPI encryption support |