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
This commit is contained in:
Tom Lane 2021-06-12 13:29:24 -04:00
parent fe6a20ce54
commit 1250aad425
1 changed files with 5 additions and 1 deletions

View File

@ -903,7 +903,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);