views to behave differently according to user and schema
От | Samuel Thoraval |
---|---|
Тема | views to behave differently according to user and schema |
Дата | |
Msg-id | 42F09E46.1010109@librophyt.com обсуждение исходный текст |
Ответы |
Re: views to behave differently according to user and schema
|
Список | pgsql-general |
Hi, I'd like views to behave differently according to the user and schema. For instance, having 3 schemas corresponding to 3 users : -- AS USER nsp1 : CREATE TABLE nsp1.test (id integer); CREATE VIEW nsp2.test AS SELECT * FROM nsp1.test WHERE id <= 10; CREATE VIEW nsp3.test AS SELECT * FROM nsp1.test WHERE id <= 50; CREATE or REPLACE VIEW public.vtest AS SELECT * FROM test WHERE id <=5; Here, test in VIEW vtest is actually being tied up to the first relation/view it found in the search path (nsp1,public) : \d public.vtest; View "public.vtest" Column | Type | Modifiers --------+---------+----------- id | integer | View definition: SELECT test.id FROM nsp1.test WHERE test.id <= 10; Is it possible to change this behavior so that the VIEW will dynamically use the search_path variable (when the schema was not specifically set) ? In this case, when user nsp2 loggs in, the VIEW vtest would be using VIEW nsp2.test, when user nsp3 loggs in it would use VIEW nsp3.test, for user nsp1 TABLE nsp1.test ... Cheers, -- Samuel Thoraval LIBROPHYT, Bioinformatique Centre de Cadarache
В списке pgsql-general по дате отправления: