Re: WITH RECUSIVE patches 0723

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: WITH RECUSIVE patches 0723
Date: 2008-07-28 17:39:33
Message-ID: 873altsyay.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

>> I think it needs this change in addition; without it, incorrect
>> results are returned when you reference a recursive view from
>> within the recursive query, due to the RecursionScan nodes
>> becoming linked to the wrong tuplestores.

Tom> That whole business of using the EState to pass tuplestores back
Tom> and forth looks fundamentally broken to me anyway; there's just
Tom> no way it'll be certain to link the right nodes together in
Tom> complicated cases with multiple recursions.

Mutual recursion is not allowed; as far as I can determine, every
remaining case is such that any RecursiveScan node should be
referencing the nearest parent Recursion node, which is what the patch
(with the above fix) does.

If you have a counterexample I'd be interested to see it; I've spent a
significant amount of time looking at this code, and I can't find one.

Tom> The nodes should be carrying IDs (such as the name of the WITH
Tom> item) which they use to search a lookaside list.

create view v0 as with recursive t(id) as (select ...);
with recursive t(id) as (select ... from v0 ...) select ...;

That gives you two WITH items with the same name. You would need
additional qualification of some sort.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Cramer 2008-07-28 17:54:36 Re: Protocol 3, Execute, maxrows to return, impact?
Previous Message David E. Wheeler 2008-07-28 17:27:21 Re: Do we really want to migrate plproxy and citext into PG core distribution?

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2008-07-28 18:49:01 Re: WITH RECUSIVE patches 0723
Previous Message Tom Lane 2008-07-28 17:06:53 Re: WITH RECUSIVE patches 0723