Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1250aad

Browse files
committed
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
1 parent fe6a20c commit 1250aad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/utils/adt/dbsize.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,11 @@ pg_filenode_relation(PG_FUNCTION_ARGS)
903903
{
904904
Oid reltablespace = PG_GETARG_OID(0);
905905
Oid relfilenode = PG_GETARG_OID(1);
906-
Oid heaprel = InvalidOid;
906+
Oid heaprel;
907+
908+
/* test needed so RelidByRelfilenode doesn't misbehave */
909+
if (!OidIsValid(relfilenode))
910+
PG_RETURN_NULL();
907911

908912
heaprel = RelidByRelfilenode(reltablespace, relfilenode);
909913

0 commit comments

Comments
 (0)