Brian Sutherland <brian@vanguardistas.net> writes:
> If I run this set of commands against PostgreSQL 9.4.1 I pg_restore
> throws an error with a permission problem. Why it does so is a mystery
> to me, given that the user performing the restore is a superuser:
The same thing would happen without any dump and restore:
regression=# create user nobody;
CREATE ROLE
regression=# CREATE TABLE x (y int);
CREATE TABLE
regression=# CREATE MATERIALIZED VIEW myview AS select * from x;
SELECT 0
regression=# ALTER TABLE myview OWNER TO "nobody";
ALTER TABLE
regression=# REFRESH MATERIALIZED VIEW myview;
ERROR: permission denied for relation x
User "nobody" does not have permission to read table x, so the REFRESH
fails, because the view's query executes as the view's owner.
regards, tom lane