Folks,
While working to write the Sieve of Eratosthenes using CTEs, I ran
across a strange error, namely that it appears I'm not allowed to nest
WITH. Is this a bug?
Cheers,
David.
WITH RECURSIVE t1(n) AS (
VALUES(2)
UNION ALL
SELECT n+1 FROM t1 WHERE n 1000
),
t2 (n, i) AS (
David Fetter da...@fetter.org writes:
WITH RECURSIVE t1(n) AS (
VALUES(2)
UNION ALL
SELECT n+1 FROM t1 WHERE n 1000
),
t2 (n, i) AS (
SELECT 2*n+2, 2
FROM t1 WHERE 2*n+2 = 1000
UNION ALL
WITH t3(k) AS (
SELECT max(i) FROM t2
)
SELECT k*n+k, k
On Tue, Sep 08, 2009 at 11:37:14PM -0400, Tom Lane wrote:
I wrote:
David Fetter da...@fetter.org writes:
WITH RECURSIVE t(j) AS (
WITH RECURSIVE s(i) AS (
VALUES (1)
UNION ALL
SELECT i+1 FROM s WHERE i 10
) SELECT i AS j FROM s
UNION ALL
SELECT
On Tue, Sep 08, 2009 at 11:37:14PM -0400, Tom Lane wrote:
I wrote:
David Fetter da...@fetter.org writes:
WITH RECURSIVE t(j) AS (
WITH RECURSIVE s(i) AS (
VALUES (1)
UNION ALL
SELECT i+1 FROM s WHERE i 10
) SELECT i AS j FROM s
UNION ALL
SELECT
David Fetter da...@fetter.org writes:
Should the outer query be able to reference further-in CTEs?
No, why would you expect that?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
On Wed, Sep 09, 2009 at 03:00:39PM -0400, Tom Lane wrote:
David Fetter da...@fetter.org writes:
Should the outer query be able to reference further-in CTEs?
No, why would you expect that?
No particular reason, I suppose. I'm not clear on what the standard
says about this.
Cheers,
David.
David Fetter da...@fetter.org writes:
On Wed, Sep 09, 2009 at 03:00:39PM -0400, Tom Lane wrote:
David Fetter da...@fetter.org writes:
Should the outer query be able to reference further-in CTEs?
No, why would you expect that?
No particular reason, I suppose. I'm not clear on what the
Folks,
I tried the following and it broke:
WITH RECURSIVE t(j) AS (
WITH RECURSIVE s(i) AS (
VALUES (1)
UNION ALL
SELECT i+1 FROM s WHERE i 10
) SELECT i AS j FROM s
UNION ALL
SELECT j+1 FROM t WHERE j 10
)
SELECT * FROM t;
ERROR: relation s does not exist
LINE
David Fetter da...@fetter.org writes:
WITH RECURSIVE t(j) AS (
WITH RECURSIVE s(i) AS (
VALUES (1)
UNION ALL
SELECT i+1 FROM s WHERE i 10
) SELECT i AS j FROM s
UNION ALL
SELECT j+1 FROM t WHERE j 10
)
SELECT * FROM t;
ERROR: relation s does not exist
I wrote:
David Fetter da...@fetter.org writes:
WITH RECURSIVE t(j) AS (
WITH RECURSIVE s(i) AS (
VALUES (1)
UNION ALL
SELECT i+1 FROM s WHERE i 10
) SELECT i AS j FROM s
UNION ALL
SELECT j+1 FROM t WHERE j 10
)
SELECT * FROM t;
ERROR: relation s does
10 matches
Mail list logo