From: Justin Pryzby <pryzby@telsasoft.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pg_filenode_relation(0,0) elog
Date: Sat, 12 Jun 2021 10:12:34 -0500
Message-ID: <20210612151234.GW16435@telsasoft.com> (raw)
In-Reply-To: <2146777.1623469895@sss.pgh.pa.us>
References: <20210612023324.GT16435@telsasoft.com>
<2146777.1623469895@sss.pgh.pa.us>
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.
inline patch 1: src/backend/utils/adt/dbsize.c (+3/-0 lines) download inline-1.patchdiff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.cindex 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))
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, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
Subject: Re: pg_filenode_relation(0,0) elog
In-Reply-To: <20210612151234.GW16435@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