Re: leaky views, yet again
Kevin Grittner <kevin.grittner@wicourts.gov>
From: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
To: "Robert Haas" <robertmhaas@gmail.com>, "Tom Lane" <tgl@sss.pgh.pa.us>
Cc: "KaiGai Kohei" <kaigai@ak.jp.nec.com>, "Heikki Linnakangas" <heikki.linnakangas@enterprisedb.com>, "Itagaki Takahiro" <itagaki.takahiro@gmail.com>, "KaiGai Kohei" <kaigai@kaigai.gr.jp>, <pgsql-hackers@postgresql.org>
Date: 2010-10-05T17:31:54Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> wrote:
> What is the use case for the status quo?
Much simplified:
create table party
(
countyno smallint not null,
caseno varchar(14) not null,
partyno smallint not null,
name text not null,
address text,
isaddrsealed boolean not null,
primary key (countyno, caseno, partyno)
);
create table sealedaddrauth
(
userid text not null primary key
);
create view partyview as
select countyno, caseno, partyno,
case
when isaddrsealed and not exists
(select * from sealedaddrauth
where userid = current_user)
then '*** SEALED ***'
else address
end as address,
isaddrsealed
from party
;
insert into party values (1,'2010FA000123',1,'Jane Doe',
'123 Victim Ave., Anytown, WI 53599',true);
insert into party values (1,'2010FA000123',2,'John Doe',
'123 Stalker St., Hometown, WI 53666',false);
-- Kevin