create table drink (
	id serial primary key,
	name text,
	price integer,
	cost integer,
	alcohol bool
);
insert into drink(name, price, cost, alcohol) values('coffee', 120, 80, false);
insert into drink(name, price, cost, alcohol) values('tea', 120, 70, false);
insert into drink(name, price, cost, alcohol) values('wine', 360, 260, true);
insert into drink(name, price, cost, alcohol) values('beer', 240, 180, true);
insert into drink(name, price, cost, alcohol) values('water', 110, 40, false);
insert into drink(name, price, cost, alcohol) values('coke', 110, 50, false);

update drink set security_context = 'user_u:object_r:sepgsql_table_t:s0:c0'
	where alcohol = true; 

create table person (
	uid serial primary key,
	uname text,
	passwd varchar(24)
);

insert into person (uname, passwd) values('KaiGai', 'aaa');
insert into person (uname, passwd) values('ymj', 'bbb');
insert into person (uname, passwd) values('tak', 'xyz');

create or replace function check_person_passwd (integer, text)
	returns bool language 'sql'
	as 'select passwd = $2 from person where uid=$1';

update pg_attribute set attselcon = 'user_u:object_r:sepgsql_table_t:s0:c1'
	where attrelid in (select tableoid from person) and attname='passwd';
update pg_proc set proselcon = 'user_u:object_r:sepgsql_trusted_proc_t:s0';
