Unix Technical Forum

Re: [PATCHES] WITH RECUSIVE patches 0717

This is a discussion on Re: [PATCHES] WITH RECUSIVE patches 0717 within the pgsql Hackers forums, part of the PostgreSQL category; --> On Mon, Jul 21, 2008 at 08:19:35AM +0900, Tatsuo Ishii wrote: > > > Thus I think we should ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-22-2008, 06:58 AM
David Fetter
 
Posts: n/a
Default Re: [PATCHES] WITH RECUSIVE patches 0717

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
)

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-22-2008, 06:58 AM
Tatsuo Ishii
 
Posts: n/a
Default Re: [PATCHES] WITH RECUSIVE patches 0717

> 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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:47 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com