Re: WITH RECUSIVE patches 0723 - Mailing list pgsql-hackers

From Andrew Gierth
Subject Re: WITH RECUSIVE patches 0723
Date
Msg-id 87d4kyrtlk.fsf@news-spur.riddles.org.uk
Whole thread Raw
In response to Re: WITH RECUSIVE patches 0723  (Tatsuo Ishii <ishii@postgresql.org>)
List pgsql-hackers
>>>>> "Tatsuo" == Tatsuo Ishii <ishii@postgresql.org> writes:
>> This behaviour is clearly intentional, since the entire mechanism of>> estate-> es_disallow_tuplestore exists for no
otherreason, but it>> seems to me to be clearly wrong. What is the justification for it?
 
Tatsuo> Yes, this is due to prevent infinit recursion caused byTatsuo> following case for example.

[...]
Tatsuo> WITH RECURSIVE x AS (Tatsuo>   SELECT * FROM test WHERE a = 'aaa'
Tatsuo>   UNION ALL
Tatsuo>   SELECT test.* FROM x LEFT JOIN test on test.a = x.bTatsuo> ) SELECT * FROM x;
Tatsuo> Now we think that we were wrong. This type of query shouldTatsuo> run into infinit recursion and it's user's
responsibilityTatsuo>that he does not make such a query.
 

I agree.
Tatsuo> Another idea would be prohibiting *any* outer joins in theTatsuo> recursive term (DB2 style), but this may be
overkill.

There are legitimate cases for wanting to do a left join in the
recursion - for example, to use the content of another table to
prune the tree where matching records exist (consider the standard
bill-of-materials example with the addition of another table listing
components already in stock).

-- 
Andrew (irc:RhodiumToad)


pgsql-hackers by date:

Previous
From: "Heikki Linnakangas"
Date:
Subject: Re: [PATCHES] odd output in restore mode
Next
From: Zdenek Kotala
Date:
Subject: Re: Review: DTrace probes (merged version) ver_03