Re: Forbid to DROP temp tables of other sessions
От | Steven Niu |
---|---|
Тема | Re: Forbid to DROP temp tables of other sessions |
Дата | |
Msg-id | f77435e7-e7ea-46c3-b425-5c17075c9a3e@gmail.com обсуждение исходный текст |
Ответ на | Re: Forbid to DROP temp tables of other sessions (Daniil Davydov <3danissimo@gmail.com>) |
Ответы |
Re: Forbid to DROP temp tables of other sessions
|
Список | pgsql-hackers |
在 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
В списке pgsql-hackers по дате отправления: