Re: RangeVarGetRelid() - Mailing list pgsql-hackers

From Robert Haas
Subject Re: RangeVarGetRelid()
Date
Msg-id CA+TgmobXVpKS_v-f05Qdas6Kd6g=5yvkt0z+ivOzzk7p2JmR6w@mail.gmail.com
Whole thread Raw
In response to Re: RangeVarGetRelid()  (Noah Misch <noah@leadboat.com>)
Responses Re: RangeVarGetRelid()  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
On Fri, Dec 16, 2011 at 10:32 AM, Noah Misch <noah@leadboat.com> wrote:
>> I agree, but my point is that so far we have no callbacks that differ
>> only in that detail.  I accept that we'd probably want to avoid that.
>
> To illustrate what I had in mind, here's a version of your patch that has five
> callers sharing a callback.  The patch is against d039fd51f79e, just prior to
> your recent commits.

I don't think RenameRelation() ought to wait until we've taken the
lock before doing this:

+       aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(), ACL_CREATE);
+       if (aclresult != ACLCHECK_OK)
+               aclcheck_error(aclresult, ACL_KIND_NAMESPACE,
+                                          get_namespace_name(namespaceId));

I'm not sure how we can distinguished in a principled way between
permissions checks that must be conducted before locking the relation
and those that can be done afterwards.  And I don't really want to
make that distinction, anyhow.

But I see your point, otherwise.  What I'm tempted to do is define a
new function RangeVarGetRelidCheckOwner(RangeVar *relation, LOCKMODE
lockmode, bool system_tables_ok) that will arrange to look up the OID,
check that you own it, optionally check that it's not a system table,
and acquire the specified lock.  Internally that will call
RangeVarGetRelidExtended() with a callback; the callback arg can be
used to pass through the system_tables_ok flag.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: pratikchirania
Date:
Subject: Re: pgstat wait timeout
Next
From: Peter Eisentraut
Date:
Subject: pg_upgrade with plpython is broken