Sorry, just realized that I misread the query's requirements, but youcan play with PG's system catalogs to complete it.
See:http://stream.boxwatch.ru/docs/8.1/static/catalogs.html