Re: Implementing pg_dump_sort.c topological sorting in sql/plpgsql/plperl? - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: Implementing pg_dump_sort.c topological sorting in sql/plpgsql/plperl?
Date
Msg-id 87mxngfw8r.fsf@hi-media-techno.com
Whole thread Raw
In response to Implementing pg_dump_sort.c topological sorting in sql/plpgsql/plperl?  (Joel Jacobson <joel@gluefinance.com>)
List pgsql-hackers
Joel Jacobson <joel@gluefinance.com> writes:
> It's not possible to use a plain recursive query to do the trick (due
> to 'i' bidirectional dependencies and dependency loops).

Well I came up with that while working on some extension related fun
dependency problems, I guess it could help you:

~:5490=# WITH RECURSIVE depends AS (select 16385 as nsp, objid, refobjid, array[refobjid] as deps  from pg_depend where
refobjid= 16854 and deptype != 'p'UNION ALLselect p.nsp, p.objid, d.refobjid, deps || d.refobjid  from pg_depend d JOIN
dependsp ON d.objid = p.objid where d.deptype != 'p' and not d.refobjid = any(deps)
 
)
select * from depends; nsp  | objid | refobjid |        deps        
-------+-------+----------+--------------------16385 | 16851 |    16854 | {16854}16385 | 16852 |    16854 |
{16854}16385| 16853 |    16854 | {16854}16385 | 16851 |     2200 | {16854,2200}16385 | 16852 |     2200 |
{16854,2200}16385| 16852 |    16851 | {16854,16851}16385 | 16853 |     2200 | {16854,2200}16385 | 16852 |     2200 |
{16854,16851,2200}16385| 16852 |    16851 | {16854,2200,16851}
 
(9 rows)

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: WIP: Range Types
Next
From: David Fetter
Date:
Subject: Re: Implementing pg_dump_sort.c topological sorting in sql/plpgsql/plperl?