CREATE POLICY bug ? - Mailing list pgsql-hackers

From Andrea Adami
Subject CREATE POLICY bug ?
Date
Msg-id CAJgnxO_+D_a4syJjZ8Wo4kS-o=FO5sZr2zpVmVQQHq1b-bXpgg@mail.gmail.com
Whole thread Raw
Responses Re: CREATE POLICY bug ?  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
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','manager@scuola247.it');
INSERT INTO public.policy_tab (id, description, usr) VALUES (2,'due','manager@scuola247.it');
INSERT INTO public.policy_tab (id, description, usr) VALUES (3,'tre','manager@scuola247.it');
INSERT INTO public.policy_tab (id, description, usr) VALUES (4,'quattro','teacher@scuola247.it');
INSERT INTO public.policy_tab (id, description, usr) VALUES (5,'cinque','teacher@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: manager@scuola247.it
rows 4,5 for user: teacher@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 


pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: LSN as a recovery target
Next
From: Amit Kapila
Date:
Subject: Re: Should we cacheline align PGXACT?