Re: Different views with same name for different users - Mailing list pgsql-general

From Harald Massa
Subject Re: Different views with same name for different users
Date
Msg-id 014001c1a1f7$c1b2a930$0100a8c0@tog2
Whole thread Raw
In response to Re: Different views with same name for different users  (Darren Ferguson <darren@crystalballinc.com>)
List pgsql-general
I found (thank you, Holger Krug) a way to do the access-problem


create view pers as select * from totaldatabase
where case currentuser="userA" then beraterid in (1256,2523,2521,623,124)
else beraterid in (9123, 12312,12313) end

(or more case statements.)

But NOW there are 2 drawbacks

1.) INSERT and UPDATE became MUCH MORE complicated. I have defined rules (do
instead insert ....), but now partial inserts (only SOME columns of the
orignal table) do not work.

2.) there is some bad performance penality. If I do a
explain select * from totaldatabase
where case currentuser="userA" then beraterid in (1256,2523,2521,623,124)
else beraterid in (9123, 12312,12313) end
allways the sequential scan is used - also that only 2% of the rows are
visible. The Planner seems not to realise, that currentuser="userA" DOES NOT
change with each row.

I think I'll ask my question in another way again..

Thank you all,

HArald


pgsql-general by date:

Previous
From: alavoor
Date:
Subject: PostgreSQL Licence: GNU/GPL
Next
From: "Harald Massa"
Date:
Subject: row based security ... was Different views with same name for different users