From: Dian Fay <dian.m.fay@gmail.com>
To: Dave Cramer <davecramer@gmail.com>
To: Jonathan Katz <jonathan.katz@excoventures.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: docs: note ownership requirement for refreshing materialized views
Date: Fri, 17 Aug 2018 09:14:10 -0400
Message-ID: <009dad19-e8bb-1e98-2899-06451f1db443@gmail.com> (raw)
In-Reply-To: <CADK3HHL49W2wkMyb4A19-2__s2cCbvaAzUdZoqa6VOymhtPzow@mail.gmail.com>
References: <745abbd2-a1a0-ead8-2cb2-768c16747d97@gmail.com>
<55498B5B-0155-4B0E-9B97-23167F8CB380@excoventures.com>
<20180816011534.GK3681@paquier.xyz>
<D603A730-137F-48ED-A879-BAB0D135AF1F@excoventures.com>
<862321D6-495D-4A62-94D2-17D6EDF87A41@excoventures.com>
<CADK3HHL49W2wkMyb4A19-2__s2cCbvaAzUdZoqa6VOymhtPzow@mail.gmail.com>
Jonathan's patch seems like a good idea to me from a user POV, but then
I just showed up the other day so I don't really have anything of
substance to add.
On 8/17/18 9:08 AM, Dave Cramer wrote:
>
> Dave Cramer
>
>
> On Thu, 16 Aug 2018 at 18:27, Jonathan S. Katz
> <jonathan.katz@excoventures.com
> <mailto:jonathan.katz@excoventures.com>> wrote:
>
>
>> On Aug 16, 2018, at 1:05 AM, Jonathan S. Katz
>> <jonathan.katz@excoventures.com
>> <mailto:jonathan.katz@excoventures.com>> wrote:
>>
>>>
>>> On Aug 15, 2018, at 9:15 PM, Michael Paquier
>>> <michael@paquier.xyz <mailto:michael@paquier.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.
>
> With encouragement from Dave, let me demonstrate what the proposed
> patch
> does to fix the behavior. The steps, running from my “jkatz” user:
>
> CREATE ROLE bar LOGIN;
> CREATE TABLE a (x int);
> CREATE MATERIALIZED VIEW b AS SELECT * FROM a;
> \c - bar
> REFRESH MATERIALIZED VIEW b;
> ERROR: must be owner of materialized view b
>
> vs. the existing error message which I posted further upthread.
>
> Thanks,
>
> Jonathan
>
>
> So it seems this patch is being ignored in this thread.
> AFAICT, in aclcheck_error() the only way to get to the following sub
> case in the case ACLCHECK_NOT_OWNER
>
> case OBJECT_MATVIEW:
> msg = gettext_noop("must be owner of materialized view %s");
> break;
>
> is if the patch is applied ?
>
> Regards,
>
> Dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: dian.m.fay@gmail.com, davecramer@gmail.com, jonathan.katz@excoventures.com, michael@paquier.xyz, pgsql-hackers@lists.postgresql.org
Subject: Re: docs: note ownership requirement for refreshing materialized views
In-Reply-To: <009dad19-e8bb-1e98-2899-06451f1db443@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox