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

Commit 7681b78

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 1f280e8 commit 7681b78

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/utils/adt/dbsize.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,11 @@ pg_filenode_relation(PG_FUNCTION_ARGS)
921921
{
922922
Oid reltablespace = PG_GETARG_OID(0);
923923
Oid relfilenode = PG_GETARG_OID(1);
924-
Oid heaprel = InvalidOid;
924+
Oid heaprel;
925+
926+
/* test needed so RelidByRelfilenode doesn't misbehave */
927+
if (!OidIsValid(relfilenode))
928+
PG_RETURN_NULL();
925929

926930
heaprel = RelidByRelfilenode(reltablespace, relfilenode);
927931

0 commit comments

Comments
 (0)