Re: pg_filenode_relation(0,0) elog
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2021-06-12T15:12:34Z
Lists: pgsql-hackers
On Fri, Jun 11, 2021 at 11:51:35PM -0400, Tom Lane wrote: > Justin Pryzby <pryzby@telsasoft.com> writes: > > Per sqlsmith. > > postgres=# SELECT pg_filenode_relation(0,0); > > ERROR: unexpected duplicate for tablespace 0, relfilenode 0 > > Ugh. > > > The usual expectation is that sql callable functions should return null rather > > than hitting elog(). > > Agreed, but you should put the short-circuit into the SQL-callable > function, ie pg_filenode_relation. Lower-level callers ought not be > passing junk data. Right. I spent inadequate time reading output of git grep. > Likely it should check the reltablespace, too. I don't think so. The docs say: https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-DBLOCATION |For a relation in the database's default tablespace, the tablespace can be specified as zero. Also, that would breaks expected/alter_table.out for the same reason. diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index 3c70bb5943..144aca1099 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -905,6 +905,9 @@ pg_filenode_relation(PG_FUNCTION_ARGS) Oid relfilenode = PG_GETARG_OID(1); Oid heaprel = InvalidOid; + if (!OidIsValid(relfilenode)) + PG_RETURN_NULL(); + heaprel = RelidByRelfilenode(reltablespace, relfilenode); if (!OidIsValid(heaprel))
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