multiple SRFs in SELECT clause. - Mailing list pgsql-bugs

From Kris Jurka
Subject multiple SRFs in SELECT clause.
Date
Msg-id Pine.BSO.4.64.0611270549540.13818@leary2.csoft.net
Whole thread Raw
Responses Re: multiple SRFs in SELECT clause.
List pgsql-bugs
I'm getting some odd results when running two generate_series calls in a
SELECT.  When the two calls return the same number of rows you get that
many rows out:

# SELECT generate_series(1,3), generate_series(1,3);
  generate_series | generate_series
-----------------+-----------------
                1 |               1
                2 |               2
                3 |               3
(3 rows)

When the row counts differ you get the least common multiple number of
rows.

# SELECT generate_series(1,4), generate_series(1,2);
  generate_series | generate_series
-----------------+-----------------
                1 |               1
                2 |               2
                3 |               1
                4 |               2
(4 rows)

I was personally expecting a cross join between them that would be
equivalent to

# SELECT * FROM generate_series(1,4) a, generate_series(1,2) b;
  a | b
---+---
  1 | 1
  1 | 2
  2 | 1
  2 | 2
  3 | 1
  3 | 2
  4 | 1
  4 | 2
(8 rows)

Tested on 8.1.3 and CVS HEAD.

Kris Jurka

pgsql-bugs by date:

Previous
From: "Thomas H."
Date:
Subject: Re: 8.2rc1: vacuum full fills up disk space
Next
From: "Jeremy Haile"
Date:
Subject: fsync and semctl errors with 8.1.5/win32