Thread

Commits

  1. Mention ownership requirements for REFRESH MATERIALIZED VIEW in docs

  1. docs: note ownership requirement for refreshing materialized views

    Dian Fay <dian.m.fay@gmail.com> — 2018-08-15T23:46:49Z

    hi all! I discovered today that the REFRESH MATERIALIZED VIEW 
    documentation doesn't mention that only the owner (or a superuser) may 
    actually perform the refresh operation. This patch adds a note to that 
    effect.
    
    Dian Fay
    
    
  2. Re: docs: note ownership requirement for refreshing materialized views

    Michael Paquier <michael@paquier.xyz> — 2018-08-16T01:03:55Z

    On Wed, Aug 15, 2018 at 07:46:49PM -0400, Dian Fay wrote:
    > hi all! I discovered today that the REFRESH MATERIALIZED VIEW documentation
    > doesn't mention that only the owner (or a superuser) may actually perform
    > the refresh operation. This patch adds a note to that effect.
    
    I think that's a good idea.  I would rewrite that a bit differently, like:
    To refresh a materialized view, one must be the materalized view's owner
    or a superuser.
    
    Thougts or objections?
    --
    Michael
    
  3. Re: docs: note ownership requirement for refreshing materialized views

    Jonathan Katz <jonathan.katz@excoventures.com> — 2018-08-16T01:06:34Z

    Hi Dian,
    
    > On Aug 15, 2018, at 7:46 PM, Dian Fay <dian.m.fay@gmail.com> wrote:
    > 
    > hi all! I discovered today that the REFRESH MATERIALIZED VIEW documentation doesn't mention that only the owner (or a superuser) may actually perform the refresh operation. This patch adds a note to that effect.
    
    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.
    
    Jonathan
    
    
  4. Re: docs: note ownership requirement for refreshing materialized views

    Michael Paquier <michael@paquier.xyz> — 2018-08-16T01:15:34Z

    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).
    --
    Michael
    
  5. Re: docs: note ownership requirement for refreshing materialized views

    Dian Fay <dian.m.fay@gmail.com> — 2018-08-16T01:44:46Z

    I feel resorting to the infinitive asks more involvement of the reader, 
    while leading with the responsible role(s) helps shortcut the process of 
    determining whether what follows is relevant. Efficiency is always a 
    virtue, although this is admittedly more than a little academic for a 
    one-sentence addition!
    
    On 8/15/18 9:03 PM, Michael Paquier wrote:
    > On Wed, Aug 15, 2018 at 07:46:49PM -0400, Dian Fay wrote:
    >> hi all! I discovered today that the REFRESH MATERIALIZED VIEW documentation
    >> doesn't mention that only the owner (or a superuser) may actually perform
    >> the refresh operation. This patch adds a note to that effect.
    > I think that's a good idea.  I would rewrite that a bit differently, like:
    > To refresh a materialized view, one must be the materalized view's owner
    > or a superuser.
    >
    > Thougts or objections?
    > --
    > Michael
    
    
    
  6. Re: docs: note ownership requirement for refreshing materialized views

    Tom Lane <tgl@sss.pgh.pa.us> — 2018-08-16T04:07:30Z

    Dian Fay <dian.m.fay@gmail.com> writes:
    > I feel resorting to the infinitive asks more involvement of the reader, 
    > while leading with the responsible role(s) helps shortcut the process of 
    > determining whether what follows is relevant. Efficiency is always a 
    > virtue, although this is admittedly more than a little academic for a 
    > one-sentence addition!
    
    I think Michael's point is that this formulation is unlike what we have
    elsewhere for similar statements.  Looking around, it seems like the
    typical phraseology would be more like
    
    "You must own the materialized view to use REFRESH MATERIALIZED VIEW."
    
    It is not really customary to call out the superuser exception
    explicitly, because if we did, we'd be mentioning superusers in every
    other sentence.  The point is covered by existing documentation that
    says something to the effect of superusers bypassing all permissions
    checks; and I think there's also a statement somewhere about superusers
    implicitly being members of every role, which is a different way of
    arriving at the same conclusion.
    
    In any case, it's definitely an oversight that the REFRESH reference
    page fails to address permissions at all.  +1 for adding something.
    
    			regards, tom lane
    
    
    
  7. Re: docs: note ownership requirement for refreshing materialized views

    Jonathan Katz <jonathan.katz@excoventures.com> — 2018-08-16T05:05:54Z

    > On Aug 15, 2018, at 9:15 PM, Michael Paquier <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.
    
    Jonathan
    
  8. Re: docs: note ownership requirement for refreshing materialized views

    Dian Fay <dian.m.fay@gmail.com> — 2018-08-16T13:36:29Z

    Fair enough! Here's a new version.
    
    
    On 8/16/18 12:07 AM, Tom Lane wrote:
    > Dian Fay <dian.m.fay@gmail.com> writes:
    >> I feel resorting to the infinitive asks more involvement of the reader,
    >> while leading with the responsible role(s) helps shortcut the process of
    >> determining whether what follows is relevant. Efficiency is always a
    >> virtue, although this is admittedly more than a little academic for a
    >> one-sentence addition!
    > I think Michael's point is that this formulation is unlike what we have
    > elsewhere for similar statements.  Looking around, it seems like the
    > typical phraseology would be more like
    >
    > "You must own the materialized view to use REFRESH MATERIALIZED VIEW."
    >
    > It is not really customary to call out the superuser exception
    > explicitly, because if we did, we'd be mentioning superusers in every
    > other sentence.  The point is covered by existing documentation that
    > says something to the effect of superusers bypassing all permissions
    > checks; and I think there's also a statement somewhere about superusers
    > implicitly being members of every role, which is a different way of
    > arriving at the same conclusion.
    >
    > In any case, it's definitely an oversight that the REFRESH reference
    > page fails to address permissions at all.  +1 for adding something.
    >
    > 			regards, tom lane
    
  9. Re: docs: note ownership requirement for refreshing materialized views

    Jonathan Katz <jonathan.katz@excoventures.com> — 2018-08-16T22:27:56Z

    > On Aug 16, 2018, at 1:05 AM, Jonathan S. Katz <jonathan.katz@excoventures.com> wrote:
    > 
    >> 
    >> On Aug 15, 2018, at 9:15 PM, Michael Paquier <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
    
  10. Re: docs: note ownership requirement for refreshing materialized views

    Michael Paquier <michael@paquier.xyz> — 2018-08-17T02:36:32Z

    On Thu, Aug 16, 2018 at 09:36:29AM -0400, Dian Fay wrote:
    > Fair enough! Here's a new version.
    
    Thanks, pushed.  Instead of putting the new sentence in the "Notes"
    section, I have added it in the "Description" section, which is more
    consistent with other commands, like DROP MATERIALIZED VIEW, etc.
    --
    Michael
    
  11. Re: docs: note ownership requirement for refreshing materialized views

    Dave Cramer <davecramer@gmail.com> — 2018-08-17T13:08:23Z

    Dave Cramer
    
    
    On Thu, 16 Aug 2018 at 18:27, Jonathan S. Katz <
    jonathan.katz@excoventures.com> wrote:
    
    >
    > On Aug 16, 2018, at 1:05 AM, Jonathan S. Katz <
    > jonathan.katz@excoventures.com> wrote:
    >
    >
    > On Aug 15, 2018, at 9:15 PM, Michael Paquier <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
    
  12. Re: docs: note ownership requirement for refreshing materialized views

    Dian Fay <dian.m.fay@gmail.com> — 2018-08-17T13:14:10Z

    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
    
  13. Re: docs: note ownership requirement for refreshing materialized views

    Tom Lane <tgl@sss.pgh.pa.us> — 2018-08-17T13:21:16Z

    Dave Cramer <davecramer@gmail.com> writes:
    > So it seems this patch is being ignored in this thread.
    
    Well, Jonathan did kind of hijack what appears to be a thread about
    documentation (with an already-committed fix).
    
    I'd suggest reposting that patch in its own thread and adding it to
    the next CF.
    
    			regards, tom lane
    
    
    
  14. Re: docs: note ownership requirement for refreshing materialized views

    Jonathan Katz <jonathan.katz@excoventures.com> — 2018-08-17T21:12:42Z

    > On Aug 17, 2018, at 9:21 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
    > 
    > Dave Cramer <davecramer@gmail.com> writes:
    >> So it seems this patch is being ignored in this thread.
    > 
    > Well, Jonathan did kind of hijack what appears to be a thread about
    > documentation (with an already-committed fix).
    
    I apologize if it was interpreted as hijacking, I had brought it up in
    my initial reply to Dian, as I’ve seen others do similarly on threads.
    
    > I'd suggest reposting that patch in its own thread and adding it to
    > the next CF.
    
    I will go ahead and do this.
    
    Thanks, and thank you for the patch Dian.
    
    Jonathan
    
    
  15. Re: docs: note ownership requirement for refreshing materialized views

    Michael Paquier <michael@paquier.xyz> — 2018-08-18T08:08:18Z

    On Fri, Aug 17, 2018 at 05:12:42PM -0400, Jonathan S. Katz wrote:
    >> On Aug 17, 2018, at 9:21 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
    >> Dave Cramer <davecramer@gmail.com> writes:
    >>> So it seems this patch is being ignored in this thread.
    >> 
    >> Well, Jonathan did kind of hijack what appears to be a thread about
    >> documentation (with an already-committed fix).
    > 
    > I apologize if it was interpreted as hijacking, I had brought it up in
    > my initial reply to Dian, as I’ve seen others do similarly on threads.
    
    Don't worry, we all learn here ;)
    I saw your patch, looked at it a couple of seconds and got really
    surprised by its logic, moving to something else before lookng back at
    it.
    
    >> I'd suggest reposting that patch in its own thread and adding it to
    >> the next CF.
    > 
    > I will go ahead and do this.
    
    Thanks for spawning a different thread.  That helps in attracting the
    correct attention to the correct issues.
    --
    Michael