summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/dbsize.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-06-12 13:29:24 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2021-06-12 13:29:24 -0400
commit26a0535334ce31b12baf146ad0860c10c4947913 (patch)
tree4d8fd3f5d1c9ee2710d80ceb17188762048b4eb2 /src/backend/utils/adt/dbsize.c
parent4745c119e01a09f927cc67cecab68c24e21b622c (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/utils/adt/dbsize.c')
-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 515e30d1777..ff2a0160bfb 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -926,7 +926,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);