Multiple SRF right after SELECT

From: "Nikolay Samokhvalov" <samokhvalov(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Multiple SRF right after SELECT
Date: 2008-03-19 12:03:48
Message-ID: e431ff4c0803190503m49eeef76pb91a692009a30331@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I wonder, if the following is correct and provides expected result:

test=# select generate_series(1, 2), generate_series(1, 4);
generate_series | generate_series
-----------------+-----------------
1 | 1
2 | 2
1 | 3
2 | 4
(4 rows)

Actually I have two questions on this:
1. Is it correct at all to use SRF in select list, w/o explicit FROM?
Why then we do not allow using subselects that return multiple rows?
I'd rather expect that these two things work in similar manner.
2. Why the query above provides 4 rows, not 2*4=8? Actually, that's
interesting -- I can use this query to find l.c.m. But it's defenetely
not that I'd expect before my try...
--
Best regards,
Nikolay

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Albert Cervera i Areny 2008-03-19 12:20:33 Re: Multiple SRF right after SELECT
Previous Message Simon Riggs 2008-03-19 10:22:11 Re: fast count(*) through statistics collector