pg_relation_filenode() was added in PostgreSQL 9.0.
oid corresponds to the value contained in
pg_class, except for certain system catalog tables where the value is
0. It is therefpre necessary to use this function to reliably determine a relations's filenode.
NULL is returned if the relation is a type such as a view which is does not have on-disk storage.
postgres=# SELECT pg_relation_filenode('foo'); pg_relation_filenode ---------------------- 16499 (1 row)
Attempting to query the relation filenode of a non-existent relation:
postgres=# SELECT pg_relation_filenode('bar'); ERROR: relation "bar" does not exist LINE 1: SELECT pg_relation_filenode('bar');
Attempting to query the relation filenode of a relation which does not store data:
postgres=# CREATE VIEW bar AS SELECT * FROM foo; CREATE VIEW postgres=# SELECT pg_relation_filenode('bar') IS NULL; ?column? ---------- t (1 row)
filenode for further examples.