summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane2021-06-12 17:29:24 +0000
committerTom Lane2021-06-12 17:29:24 +0000
commit25d1ef1aaf6d104fa0b315e2f5f9840f0b164334 (patch)
treee5047056da0f9cda6b2fdaf64dbec865287f73d9 /src/backend
parent9eecea7f373ab6bdff61d31666d6d3b0c435763f (diff)
Ensure pg_filenode_relation(0, 0) returns NULL.
Previously, a zero value for the relfilenode resulted in a confusing error message about "unexpected duplicate". This function returns NULL for other invalid relfilenode values, so zero should be treated likewise. It's been like this all along, so back-patch to all supported branches. Justin Pryzby Discussion: https://postgr.es/m/20210612023324.GT16435@telsasoft.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/adt/dbsize.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 07e5e78caa8..aa4bc571959 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -921,7 +921,11 @@ pg_filenode_relation(PG_FUNCTION_ARGS)
{
Oid reltablespace = PG_GETARG_OID(0);
Oid relfilenode = PG_GETARG_OID(1);
- Oid heaprel = InvalidOid;
+ Oid heaprel;
+
+ /* test needed so RelidByRelfilenode doesn't misbehave */
+ if (!OidIsValid(relfilenode))
+ PG_RETURN_NULL();
heaprel = RelidByRelfilenode(reltablespace, relfilenode);