Fix for REFRESH MATERIALIZED VIEW ownership error message

From: "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>
To: pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix for REFRESH MATERIALIZED VIEW ownership error message
Date: 2018-08-17 21:21:20
Message-ID: B611CA13-0AF0-4FD8-9A33-0CC44F3B861B@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I Initially pointed out here[1] that running REFRESH MATERIALIZED VIEW as a
non-superuser or table owner yields the following message:

test=> REFRESH MATERIALIZED VIEW blah;
ERROR: must be owner of relation blah

The error message should say "...owner of materialized view..."

The attached patch corrects this by setting the "relkind" for the
REFRESH MATERIALIZED VIEW command to be "OBJECT_MATVIEW" so that the aclcheck
returns the appropriate error message. The updated patch can be tested as such:

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

I'm happy to generate the backpatches for it but wanted to receive feedback
first.

Thanks,

Jonathan

[1] https://www.postgresql.org/message-id/55498B5B-0155-4B0E-9B97-23167F8CB380%40excoventures.com <https://www.postgresql.org/message-id/55498B5B-0155-4B0E-9B97-23167F8CB380@excoventures.com>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-08-17 21:23:09 Re: [PATCH] Improve geometric types
Previous Message Tom Lane 2018-08-17 21:20:53 Re: [HACKERS] WIP: long transactions on hot standby feedback replica / proof of concept