From: Tom Lane <tgl@sss.pgh.pa.us>
To: hkauchi@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14613: Referencing foreign key needs privileges of table owner?
Date: Wed, 05 Apr 2017 23:00:36 -0400
Message-ID: <14343.1491447636@sss.pgh.pa.us> (raw)
In-Reply-To: <20170406020941.25934.30410@wrigleys.postgresql.org>
References: <20170406020941.25934.30410@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
hkauchi@gmail.com writes:
> create role user1;
> create role user2 login;
> create table table1(id int primary key);
> create table table2(id int primary key, table1_id integer references
> table1(id));
> alter table table1 owner to user1;
> alter table table2 owner to user2;
> grant select,insert,update,delete on table1 to user2;
> grant select,insert,update,delete on table2 to user2;
> revoke all on schema public from public; // To prevent creation of
> objects.
You realize that that's much more draconian than needed to prevent
creation of objects? In particular, you've left user1 unable to
reference the table it owns, which hardly seems like a useful
arrangement.
> test=# insert into table2(id, table1_id) values(1,1);
> ERROR: permission denied for schema public
> LINE 1: SELECT 1 FROM ONLY "public"."table1" x WHERE "id" OPERATOR(p...
> ^
> QUERY: SELECT 1 FROM ONLY "public"."table1" x WHERE "id"
> OPERATOR(pg_catalog.=) $1 FOR KEY SHARE OF x
This is not a bug. That foreign key check query is executed as the owner
of table1. If it were not, you'd probably be complaining about some
other permissions problem.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, hkauchi@gmail.com
Subject: Re: BUG #14613: Referencing foreign key needs privileges of table owner?
In-Reply-To: <14343.1491447636@sss.pgh.pa.us>
References: <20170406020941.25934.30410@wrigleys.postgresql.org> <14343.1491447636@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox