About connectby() again - Mailing list pgsql-hackers

From Masaru Sugawara
Subject About connectby() again
Date
Msg-id 20020927020159.216C.RK73@sea.plala.or.jp
Whole thread Raw
Responses Re: About connectby() again  (Masaru Sugawara <rk73@sea.plala.or.jp>)
List pgsql-hackers
On Sat, 07 Sep 2002 10:21:21 -0700
Joe Conway <mail@joeconway.com> wrote:

> I just sent in a patch using the ancestor check method. It turned out 
> that the performance hit was pretty small on a moderate sized tree.
> 
> My test case was a 220000 record bill-of-material table. The tree built 
> was 9 levels deep with about 3800 nodes. The performance hit was only 
> about 1%.


The previous patch fixed an infinite recursion bug in 
contrib/tablefunc/tablefunc.c:connectby. But, other unmanageable error
seems to occur even if a table has commonplace tree data(see below).


I would think the patch, ancestor check, should be
 if (strstr(branch_delim || branchstr->data || branch_delim,                      branch_delim || current_key ||
branch_delim))

This is my image, not a real code. However, if branchstr->data includes
branch_delim, my image will not be perfect.




-- test connectby with int based hierarchy
DROP TABLE connectby_tree;
CREATE TABLE connectby_tree(keyid int, parent_keyid int);

INSERT INTO connectby_tree VALUES(11,NULL);
INSERT INTO connectby_tree VALUES(10,11);
INSERT INTO connectby_tree VALUES(111,11);
INSERT INTO connectby_tree VALUES(1,111);

SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', '11', 0, '-')  AS t(keyid int, parent_keyid int,
levelint, branch text)
 

ERROR:  infinite recursion detected



Regards,
Masaru Sugawara




pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [GENERAL] Performance while loading data and indexing
Next
From: Doug cNaught
Date:
Subject: Re: [GENERAL] Performance while loading data and indexing