Re: Rethinking LOCK TABLE's behavior on views - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Rethinking LOCK TABLE's behavior on views
Date
Msg-id 20201109144233.GA4469@alvherre.pgsql
Whole thread Raw
In response to Re: Rethinking LOCK TABLE's behavior on views  (Noah Misch <noah@leadboat.com>)
Responses Re: Rethinking LOCK TABLE's behavior on views
List pgsql-hackers
On 2020-Nov-07, Noah Misch wrote:

> On Sat, Nov 07, 2020 at 11:57:20AM -0500, Tom Lane wrote:

> > A completely different approach we could consider is to weaken the
> > permissions requirements for LOCK on a view, say "allow it if either
> > the calling user or the view owner has the needed permission".  This
> > seems generally pretty messy and so I don't much like it, but we
> > should consider as many solutions as we can think of.
> 
> This is the best of what you've listed by a strong margin, and I don't know of
> better options you've not listed.  +1 for it.  Does it work for you?

It does sound attractive from a user complexity perspective, even if it
does sound messy form an implementation perspective.

> I think
> the mess arises from LOCK TABLE serving "get locks sufficient for $ACTIONS" as
> a family of use cases.  For views only, different $ACTIONS want different
> behavior.  $ACTIONS==SELECT wants today's behavior; pg_get_viewdef() wants
> shallower recursion and caller permissions; DROP VIEW wants no recursion.

Maybe we can tackle this problem directly, by adding a clause to LOCK
TABLE to indicate a purpose for the lock that the server can use to
determine the level of recursion.  For example
  LOCK TABLE xyz IN <mode> FOR <purpose>
where <purpose> can be READ, DROP, DEFINE.

(For back-patch purposes we could store the purpose in LockStmt->mode,
which has more than enough unused bits).



pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Prevent printing "next step instructions" in initdb and pg_upgrade
Next
From: Peter Eisentraut
Date:
Subject: Re: pg_upgrade analyze script