Co myslíš tím "z dotazu sql"? Znamená to SELECT
ing z pg_inherits
není pro vás dost dobrý?
SELECT pg_inherits.*, c.relname AS child, p.relname AS parent
FROM
pg_inherits JOIN pg_class AS c ON (inhrelid=c.oid)
JOIN pg_class as p ON (inhparent=p.oid);