Re: Common Table Expressions (WITH RECURSIVE) patch

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tatsuo Ishii <ishii(at)postgresql(dot)org>, Yoshiyuki Asaba <y-asaba(at)sraoss(dot)co(dot)jp>
Subject: Re: Common Table Expressions (WITH RECURSIVE) patch
Date: 2008-09-08 20:25:18
Message-ID: 1220905518.7743.42.camel@dell.linuxdev.us.dell.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2008-09-08 at 21:13 +0100, Gregory Stark wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
>
> > * Mutual Recursion:
> >
> > with recursive
> > foo(i) as (values(1) union all select i+1 from bar where i < 10),
> > bar(i) as (values(1) union all select i+1 from foo where i < 10)
> > select * from foo;
> > ERROR: mutual recursive call is not supported
> >
> > The standard allows mutual recursion.
>
> This seems to be a point of confusion. I originally read the standard and
> concluded that mutual recursion was an optional feature. Itagaki-san showed me
> a copy of the spec where it seemed there was a clear blanket prohibition on
> mutually recursive queries and in fact anything but simple linearly expandable
> queries. I wonder if there are different versions of the spec floating around
> on this point.
>
> Take a second look at your spec and read on to where it defines "linear" and
> "expandable". If it doesn't define those terms then it's definitely different
> from what I read. If it does, read on to see what it does with them. The main
> reason to define them appeared to be to use them to say that supporting mutual
> recursion is not required.

I think we're reading the same version of the spec. I'm reading 200n.

My interpretation (Syntax Rule 2.h) is that expandable is only used to
determine whether it can contain a <search or cycle>.

That being said, I don't think it should be a requirement for 8.4. The
CTE patch is an important feature, and we shouldn't hold it up over
something comparatively obscure like mutual recursion. As Andrew Gierth
cited, other systems don't support it anyway. It should be kept in mind
for future work though.

Regards,
Jeff Davis

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Martin Pihlak 2008-09-08 21:10:48 Re: reducing statistics write overhead
Previous Message Gregory Stark 2008-09-08 20:13:34 Re: Common Table Expressions (WITH RECURSIVE) patch