On Sat, 07 Sep 2002 10:26:36 -0700
Joe Conway <mail@joeconway.com> wrote:
>
> OK -- patch submitted to fix this. Once the patch is applied, this case
> gives:
>
> test=# SELECT * FROM connectby('connectby_tree', 'keyid',
> 'parent_keyid', '2', 0, '~') AS t(keyid int, parent_keyid int, level
> int, branch text);
> ERROR: infinite recursion detected
Thank you for your patch.
>
> If you specifically limit the depth to less than where the repeated key
> is hit, everything works as before:
And I also think this approach is reasonable.
>
> test=# SELECT * FROM connectby('connectby_tree', 'keyid',
> 'parent_keyid', '2', 4, '~') AS t(keyid int, parent_keyid int, level
> int, branch text);
> keyid | parent_keyid | level | branch
> -------+--------------+-------+-------------
> 2 | | 0 | 2
> 4 | 2 | 1 | 2~4
> 6 | 4 | 2 | 2~4~6
> 8 | 6 | 3 | 2~4~6~8
> 5 | 2 | 1 | 2~5
> 9 | 5 | 2 | 2~5~9
> 10 | 9 | 3 | 2~5~9~10
> 11 | 10 | 4 | 2~5~9~10~11
> (8 rows)
>
> Thanks for the feedback!
>
> Joe
>
>
Regards,
Masaru Sugawara