Re: RangeVarGetRelid()

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: RangeVarGetRelid()
Date: 2011-12-19 15:11:23
Message-ID: CA+TgmobXVpKS_v-f05Qdas6Kd6g=5yvkt0z+ivOzzk7p2JmR6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 16, 2011 at 10:32 AM, Noah Misch <noah(at)leadboat(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2011-12-19 15:16:44 pg_upgrade with plpython is broken
Previous Message pratikchirania 2011-12-19 15:02:46 Re: pgstat wait timeout