454
-- this variant tickled a whole-row-variable bug in 8.4devel
455
WITH RECURSIVE t(id, path) AS (
456
VALUES(1,ARRAY[]::integer[])
458
SELECT tree.id, t.path || tree.id
459
FROM tree JOIN t ON (tree.parent_id = t.id)
461
SELECT t1.id, t2.path, t2 FROM t AS t1 JOIN t AS t2 ON
464
----+-------------+--------------------
468
4 | {2,4} | (4,"{2,4}")
469
5 | {2,5} | (5,"{2,5}")
470
6 | {2,6} | (6,"{2,6}")
471
7 | {3,7} | (7,"{3,7}")
472
8 | {3,8} | (8,"{3,8}")
473
9 | {2,4,9} | (9,"{2,4,9}")
474
10 | {2,4,10} | (10,"{2,4,10}")
475
11 | {3,7,11} | (11,"{3,7,11}")
476
12 | {3,7,12} | (12,"{3,7,12}")
477
13 | {3,7,13} | (13,"{3,7,13}")
478
14 | {2,4,9,14} | (14,"{2,4,9,14}")
479
15 | {3,7,11,15} | (15,"{3,7,11,15}")
480
16 | {3,7,11,16} | (16,"{3,7,11,16}")
455
484
-- test cycle detection