Re: Failure loading materialized view with pg_restore

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brian Sutherland <brian(at)vanguardistas(dot)net>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Failure loading materialized view with pg_restore
Date: 2015-02-18 15:34:33
Message-ID: 1380.1424273673@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Brian Sutherland <brian(at)vanguardistas(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2015-02-18 15:53:08 Re: #Personal#: Reg: Multiple queries in a transaction
Previous Message Medhavi Mahansaria 2015-02-18 15:06:45 #Personal#: Reg: Multiple queries in a transaction