Re: pg_filenode_relation(0,0) elog
От | Justin Pryzby |
---|---|
Тема | Re: pg_filenode_relation(0,0) elog |
Дата | |
Msg-id | 20210612151234.GW16435@telsasoft.com обсуждение исходный текст |
Ответ на | Re: pg_filenode_relation(0,0) elog (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: pg_filenode_relation(0,0) elog
|
Список | 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))
В списке pgsql-hackers по дате отправления: