pg_relation_filepath() is a system function for obtaining the filepath of a relation, relative to the data directory.
pg_relation_filepath() was added in PostgreSQL 9.0.
An ERROR is raised if the provided relation does not exist. This can also mean the relation is not visible in the current search path.
Basic usage example for
postgres=# SELECT pg_relation_filepath('foo'); pg_relation_filepath ---------------------- base/13832/16499 (1 row)
Attempting to query the filepath of a non-existent relation:
postgres=# SELECT pg_relation_filepath('bar'); ERROR: relation "bar" does not exist LINE 1: SELECT pg_relation_filepath('bar');
filenode for further examples.