diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-12 13:29:24 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-12 13:29:24 -0400 |
commit | 7681b78fba106b43d9b10d22b52ba2d5cbfc1326 (patch) | |
tree | 9f728bf4ad943e885e78ac936529b1a7e163408c /src | |
parent | 1f280e83314f6000b89046adc786f680e18d902f (diff) | |
download | postgresql-7681b78fba106b43d9b10d22b52ba2d5cbfc1326.tar.gz postgresql-7681b78fba106b43d9b10d22b52ba2d5cbfc1326.zip |
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')
-rw-r--r-- | src/backend/utils/adt/dbsize.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index a87e7214e9f..bdaa341be7b 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); |