Hello, i'm testing the new row security level functionality in postgresql 9.5. To do that i run this script:
-----------cut here ---------------------- CREATE TABLE public.policy_tab ( id bigint NOT NULL, description character varying(160) NOT NULL, usr name NOT NULL, CONSTRAINT policy_tab_pk PRIMARY KEY (id) ); ALTER TABLE public.policy_tab OWNER TO postgres; GRANT ALL ON TABLE public.policy_tab TO public; CREATE OR REPLACE VIEW public.policy_view AS SELECT id, description, usr FROM public.policy_tab; ALTER TABLE public.policy_view OWNER TO postgres; GRANT ALL ON TABLE public.policy_view TO public; ALTER TABLE public.policy_tab ENABLE ROW LEVEL SECURITY; CREATE POLICY standard ON public.policy_tab FOR ALL TO PUBLIC USING (usr = current_user); INSERT INTO public.policy_tab (id, description, usr) VALUES (1,'uno',' mana...@scuola247.it'); INSERT INTO public.policy_tab (id, description, usr) VALUES (2,'due',' mana...@scuola247.it'); INSERT INTO public.policy_tab (id, description, usr) VALUES (3,'tre',' mana...@scuola247.it'); INSERT INTO public.policy_tab (id, description, usr) VALUES (4,'quattro',' teac...@scuola247.it'); INSERT INTO public.policy_tab (id, description, usr) VALUES (5,'cinque',' teac...@scuola247.it'); -----------cut here ---------------------- after that i run the query: "select * from public.policy_tab" and the the oupt was what i excpected: rows 1,2,3 for user: mana...@scuola247.it rows 4,5 for user: teac...@scuola247.it rows 1,2,3,4,5 for user: postgres (the policy doesn't work for him) but when i run the query: "select * from public.policy_view" the ouput is the same (all rows) for all users i'm doing some mistakes or this is a bug ? thank you in advance for the time you would like dedicate to me. Andrea Adami