Re: docs: note ownership requirement for refreshing materialized views

From: "Jonathan S(dot) Katz" <jonathan(dot)katz(at)excoventures(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Dian Fay <dian(dot)m(dot)fay(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: docs: note ownership requirement for refreshing materialized views
Date: 2018-08-16 05:05:54
Message-ID: D603A730-137F-48ED-A879-BAB0D135AF1F@excoventures.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> On Aug 15, 2018, at 9:15 PM, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Wed, Aug 15, 2018 at 09:06:34PM -0400, Jonathan S. Katz wrote:
>> I played around with this feature a bit and did see this was the case.
>> Also while playing around I noticed the error message was as such:
>>
>> test=> REFRESH MATERIALIZED VIEW blah;
>> ERROR: must be owner of relation blah
>>
>> But it’s not a relation, it’s a materialized view. I attached a patch
>> that I think should fix this. Kudos to Dave Cramer who was
>> sitting next to me helping me to locate files and confirm assumptions.
>
> A relation may be a materialized view, no? The ACL check happens in
> RangeVarCallbackOwnsTable by the way (look at ExecRefreshMatView in
> matview.c).

Comment on the RangeVarCallbackOwnsTable func (abbr):

/*
* This is intended as a callback for RangeVarGetRelidExtended(). It allows
* the relation to be locked only if (1) it's a plain table, materialized
* view, or TOAST table and (2) the current user is the owner (or the
* superuser). This meets the permission-checking needs of CLUSTER, REINDEX
* TABLE, and REFRESH MATERIALIZED VIEW; we expose it here so that it can be
* used by all.
*/

So it’s sharing the permission checking needs amongst all of those commands.

As a user I could be confused if I saw the above error message, esp. because
the behavior of REFRESH .. is specific to materialized views.

Jonathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuro Yamada 2018-08-16 05:20:15 Re: Add a semicolon to query related to search_path
Previous Message Tom Lane 2018-08-16 04:47:25 Re: A slightly misleading comment in GetNewObjectId()