pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #13318: refresh materilaized view privileges
2+ messages / 2 participants
[nested] [flat]
* BUG #13318: refresh materilaized view privileges
@ 2015-05-19 21:07 Adrien.Sales@gmail.com
2015-05-19 22:39 ` Re: BUG #13318: refresh materilaized view privileges John R Pierce <pierce@hogranch.com>
0 siblings, 1 reply; 2+ messages in thread
From: Adrien.Sales@gmail.com @ 2015-05-19 21:07 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 13318
Logged by: Adrien Sales
Email address: Adrien.Sales@gmail.com
PostgreSQL version: 9.3.6
Operating system: Linux, Windows
Description:
Introduction : I don't think it's a bug but rather a Work As Designed
feature, indeed, it would be very useful to make it work the same way Oracle
does.
Description : A user (user_usr) needs to refresh a materialized view that he
does not own (the owner is user_adm). This user has all DML privileges on
user_adm schema but no DDL privileges.
On oracle, when we have the same need (for example for truncating a table),
we embed the sql in a stored procedure, grant execute privilege on the
procedure... and the job is done...but it does not work on PostgreSQL as it
does still complain that "ERROR: must be owner of relation".
Please find deblow the script used to test :
psql -U user_adm test
create table titi(i integer);
insert into titi values (1);
insert into titi values (2);
insert into titi values (3);
insert into titi values (4);
select * from titi;
create materialized view vm_titi as select * from titi;
REFRESH MATERIALIZED VIEW vm_titi with data;
CREATE OR REPLACE FUNCTION refresh_astre()
RETURNS void
AS $$
BEGIN
REFRESH MATERIALIZED VIEW vm_titi with data;
RETURN;
END;
$$ LANGUAGE plpgsql;
select refresh_astre();
grant execute on function refresh_astre() to user_usr;
psql -U user_usr test
test=> select refresh_astre();
ERROR: must be owner of relation vm_titi
CONTEXT: SQL statement "REFRESH MATERIALIZED VIEW vm_titi with data"
PL/pgSQL function refresh_astre() line 6 at EXECUTE statement
Any feedback would be appreciated on this behavior. The constraint is that
we don't want the user_usr user to own any objects, but only to use the
user_adm ones.
Thank you in advance for your help.
Best Regards,
Adrien
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #13318: refresh materilaized view privileges
2015-05-19 21:07 BUG #13318: refresh materilaized view privileges Adrien.Sales@gmail.com
@ 2015-05-19 22:39 ` John R Pierce <pierce@hogranch.com>
0 siblings, 0 replies; 2+ messages in thread
From: John R Pierce @ 2015-05-19 22:39 UTC (permalink / raw)
To: pgsql-bugs
On 5/19/2015 2:07 PM, Adrien.Sales@gmail.com wrote:
> CREATE OR REPLACE FUNCTION refresh_astre()
> RETURNS void
> SECURITY DEFINER -- <== added this
> AS $$
> BEGIN
> REFRESH MATERIALIZED VIEW vm_titi with data;
> RETURN;
> END;
> $$ LANGUAGE plpgsql;
>
> select refresh_astre();
>
> grant execute on function refresh_astre() to user_usr;
>
> psql -U user_usr test
>
> test=> select refresh_astre();
> ...
try again, with SECURITY DEFINER in the function declaration. This
says when this function is run, it runs with the permissions of the
function owner, rather than the caller.
.
--
john r pierce, recycling bits in santa cruz
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2015-05-19 22:39 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19 21:07 BUG #13318: refresh materilaized view privileges Adrien.Sales@gmail.com
2015-05-19 22:39 ` John R Pierce <pierce@hogranch.com>
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