pg_filenode_relation(0,0) elog

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: pg_filenode_relation(0,0) elog
Date: 2021-06-12 02:33:25
Message-ID: 20210612023324.GT16435@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Per sqlsmith.

postgres=# SELECT pg_filenode_relation(0,0);
ERROR: unexpected duplicate for tablespace 0, relfilenode 0

postgres=# \errverbose
ERROR: XX000: unexpected duplicate for tablespace 0, relfilenode 0
LOCATION: RelidByRelfilenode, relfilenodemap.c:220

The usual expectation is that sql callable functions should return null rather
than hitting elog(). This also means that sqlsmith has one fewer
false-positive error.

I think it should return NULL if passed invalid relfilenode, rather than
searching pg_class and then writing a pretty scary message about duplicates.

diff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.c
index 56d7c73d33..5a5cf853bd 100644
--- a/src/backend/utils/cache/relfilenodemap.c
+++ b/src/backend/utils/cache/relfilenodemap.c
@@ -146,6 +146,9 @@ RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
ScanKeyData skey[2];
Oid relid;

+ if (!OidIsValid(relfilenode))
+ return InvalidOid;
+
if (RelfilenodeMapHash == NULL)
InitializeRelfilenodeMap();

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2021-06-12 02:35:07 Re: An out-of-date comment in nodeIndexonlyscan.c
Previous Message Ranier Vilela 2021-06-12 02:05:29 Signed vs. Unsigned (some)