Search Postgresql Archives

views to behave differently according to user and schema

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux