pg_filenode_relation(0,0) elog
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2021-06-12T02:33:25Z
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();
Commits
-
Ensure pg_filenode_relation(0, 0) returns NULL.
- f479ea94bd24 13.4 landed
- c1ffbbcbca93 9.6.23 landed
- 7681b78fba10 12.8 landed
- 26a0535334ce 10.18 landed
- 25d1ef1aaf6d 11.13 landed
- 1250aad42520 14.0 landed