Re: [PATCHES] WITH RECUSIVE patches 0717 - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: [PATCHES] WITH RECUSIVE patches 0717
Date
Msg-id 20080721.101358.68047354.t-ishii@sraoss.co.jp
Whole thread Raw
In response to Re: [PATCHES] WITH RECUSIVE patches 0717  (David Fetter <david@fetter.org>)
List pgsql-hackers
> On Mon, Jul 21, 2008 at 08:19:35AM +0900, Tatsuo Ishii wrote:
> > > > Thus I think we should avoid this kind of ORDER BY. Probably we should
> > > > avoid LIMIT/OFFSET and FOR UPDATE as well.
> > >
> > > What of index-optimized SELECT max(...) ?
> >
> > Aggregate functions in a recursive term is prohibited by the
> > standard. For example,
> >
> > WITH RECURSIVE x(n) AS (SELECT 1 UNION ALL SELECT max(n) FROM x)
> >   SELECT * FROM x;
> >
> > produces an error.
>
> On the other side of UNION ALL, it's OK, right?  For example,
>
> WITH RECURSIVE x(n) AS (
>     SELECT max(i) FROM t
> UNION ALL
>     SELECT n+1 FROM x WHERE n < 20
> )

Yes, aggregate functions in the non-recursive term is allowed by the
standard.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: [PATCHES] WITH RECUSIVE patches 0717
Next
From: "Radek Strnad"
Date:
Subject: Re: [WIP] collation support revisited (phase 1)