pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <kgrittn@ymail.com>
To: bemanuel.pe@gmail.com <bemanuel.pe@gmail.com>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #11208: Refresh Materialized View Concurrently bug using user Postgres
Date: Mon, 18 Aug 2014 15:25:31 -0700
Message-ID: <1408400731.9362.YahooMailNeo@web122304.mail.ne1.yahoo.com> (raw)
In-Reply-To: <20140818212803.2536.42468@wrigleys.postgresql.org>
References: <20140818212803.2536.42468@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

"bemanuel.pe@gmail.com" <bemanuel.pe@gmail.com> wrote:

> tjma_dw=> set role user_dw;
>
> tjma_dw=> CREATE TABLE foo_data AS SELECT i, md5(random()::text) FROM
> generate_series(1, 10) i;
> SELECT 10
> tjma_dw=> CREATE MATERIALIZED VIEW mv_foo AS SELECT * FROM foo_data;
> SELECT 10
> tjma_dw=> ALTER MATERIALIZED VIEW mv_foo OWNER TO user_dw;
> ALTER MATERIALIZED VIEW
> tjma_dw=> REFRESH MATERIALIZED VIEW mv_foo;
> REFRESH MATERIALIZED VIEW
> tjma_dw=> ALTER TABLE foo_data OWNER TO user_dw;
> ALTER TABLE
> tjma_dw=> REFRESH MATERIALIZED VIEW mv_foo;
> REFRESH MATERIALIZED VIEW
> tjma_dw=> create unique index on mv_foo (i);
> CREATE INDEX

> /pgsql/pg94/bin/psql -Upostgres -p 5434 tjma_dw

> tjma_dw=# refresh materialized view CONCURRENTLY mv_foo;
> ERROR:  permission denied for relation pg_temp_432971_2
> CONTEXT:  SQL statement "DELETE FROM public.mv_foo mv WHERE ctid
> OPERATOR(pg_catalog.=) ANY (SELECT diff.tid FROM pg_temp_10.pg_temp_432971_2
> diff WHERE diff.tid IS NOT NULL AND diff.newdata IS NULL)"

Yeah, that's a bug; or probably two.  I can simplify the test case:

CREATE ROLE user_dw;
SET ROLE user_dw;
CREATE TABLE foo_data AS SELECT i, md5(random()::text)
  FROM generate_series(1, 10) i;
CREATE MATERIALIZED VIEW mv_foo AS SELECT * FROM foo_data;
CREATE UNIQUE INDEX ON mv_foo (i);
RESET ROLE;
REFRESH MATERIALIZED VIEW CONCURRENTLY mv_foo;

It is running afoul of a security measure (the query to repopulate
data is run as the owner of the materialized view, to prevent
placing trojan horses for a superuser).  But it seems to be
creating the temporary table as the superuser, preventing even the
owner from running the REFRESH ... CONCURRENTLY.  The query that is
being displayed is internal; we should probably find a way to show
the statement that was run at the top level instead.

I'll look at fixing both.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (4+ messages)  latest in thread

Message-ID: <1408400731.9362.YahooMailNeo@web122304.mail.ne1.yahoo.com>
Permalink:  ../1408400731.9362.YahooMailNeo@web122304.mail.ne1.yahoo.com/
Also on:    postgresql.org/message-id/1408400731.9362.YahooMailNeo@web122304.mail.ne1.yahoo.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: kgrittn@ymail.com, bemanuel.pe@gmail.com
  Subject: Re: BUG #11208: Refresh Materialized View Concurrently bug using user Postgres
  In-Reply-To: <1408400731.9362.YahooMailNeo@web122304.mail.ne1.yahoo.com>
  References: <20140818212803.2536.42468@wrigleys.postgresql.org> <1408400731.9362.YahooMailNeo@web122304.mail.ne1.yahoo.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