Re: Forbid to DROP temp tables of other sessions
Steven Niu <niushiji@gmail.com>
From: Steven Niu <niushiji@gmail.com>
To: Daniil Davydov <3danissimo@gmail.com>
Cc: "David G. Johnston" <david.g.johnston@gmail.com>,
"Andrey M. Borodin" <x4mmm@yandex-team.ru>,
Andres Freund <andres@anarazel.de>, Thomas Munro <thomas.munro@gmail.com>,
Rafia Sabih <rafia.pghackers@gmail.com>,
Michael Paquier <michael@paquier.xyz>, Tom Lane <tgl@sss.pgh.pa.us>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2025-03-17T13:28:50Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pg_basebackup: Add missing PQclear in error path
- a19db0827496 18.0 landed
在 2025/3/17 18:56, Daniil Davydov 写道:
> Hi,
>
> On Mon, Mar 17, 2025 at 5:33 PM Steven Niu <niushiji@gmail.com> wrote:
>>
>> I mean RangeVarGetRelidExtended(), you deleted the following code:
>>
>> if (!OidIsValid(myTempNamespace))
>> relId = InvalidOid; /* this probably can't happen? */
>
> Hm, I got it. Let's start with the fact that the comment "this
> probably can't happen?" is incorrect. Even if we don't have a
> temporary namespace in our session, we still can specify "pg_temp_N"
> in the psql query.
> Next, if relation->schemaname is pg_temp, then we firstly call
> LookupExplicitNamespace, where you can find if
> (!OidIsValid(myTempNamespace)) check.
>
> --
> Best regards,
> Daniil Davydov
If the (relation->relpersistence == RELPERSISTENCE_TEMP) can ensure the
myTempNamespace is always valid, then my comment can be ignored.
Otherwise I think the modified RangeVarGetRelidExtended() should keep
check of myTempNamespace, like this:
if (relation->relpersistence == RELPERSISTENCE_TEMP)
{
Oid namespaceId;
if (!OidIsValid(myTempNamespace))
relId = InvalidOid; /* this probably can't happen? */
else
{
if (relation->schemaname)
{
namespaceId = LookupExplicitNamespace(relation->schemaname,
missing_ok);
if (namespaceId != myTempNamespace)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("could not access temporary relations of other
sessions")));
}
}
else
{
namespaceId = myTempNamespace;
Assert(OidIsValid(namespaceId));
}
if (missing_ok && !OidIsValid(namespaceId))
relId = InvalidOid;
else
relId = get_relname_relid(relation->relname, namespaceId);
}
...
...
Thanks,
Steven