From: Justin Pryzby <pryzby@telsasoft.com>
To: pgsql-hackers@lists.postgresql.org
Subject: pg_filenode_relation(0,0) elog
Date: Fri, 11 Jun 2021 21:33:25 -0500
Message-ID: <20210612023324.GT16435@telsasoft.com> (raw)
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.
inline patch 1: src/backend/utils/cache/relfilenodemap.c (+3/-0 lines) download inline-1.patchdiff --git a/src/backend/utils/cache/relfilenodemap.c b/src/backend/utils/cache/relfilenodemap.cindex 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();
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: pryzby@telsasoft.com, pgsql-hackers@lists.postgresql.org
Subject: Re: pg_filenode_relation(0,0) elog
In-Reply-To: <20210612023324.GT16435@telsasoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox