pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rick Delaney <rick@consumercontact.com>
To: pgsql-sql@postgresql.org
Subject: Permissions for foreign keys
Date: Tue, 30 Jan 2001 19:50:05 -0500
Message-ID: <3A77613D.184BB8D8@consumercontact.com> (raw)

I'm using 7.0 and have noticed that I need to grant SELECT and UPDATE
permissions on any referentially-related tables.  Can/should I get
around this?  A somewhat contrived example:

CREATE TABLE emp (
 id integer PRIMARY KEY,
 salary integer
);
CREATE TABLE proj (
 id integer PRIMARY KEY,
 emp_id integer REFERENCES emp
);
CREATE TABLE bill (
 id integer PRIMARY KEY,
 proj_id integer REFERENCES proj
);
INSERT INTO emp  VALUES (1, 100000);
INSERT INTO proj VALUES (1, 1);
INSERT INTO bill VALUES (1, 1);

GRANT ALL ON proj TO someone;

Connect as someone:
=> INSERT INTO proj VALUES (2, 1);
ERROR:  emp: Permission denied.
=> UPDATE proj SET id = 2;
ERROR:  bill: Permission denied.

It appears that I need to grant:
   SELECT,UPDATE on  emp to UPDATE or INSERT into proj.  
   SELECT,UPDATE on bill to UPDATE proj.  

When I grant these permissions, the above statements succeed.

If I don't want users to have UPDATE (or even SELECT) access on the
other tables (bill and emp), but I want referential integrity, what can
I do?

-- 
Rick Delaney



view thread (7+ messages)  latest in thread

Message-ID: <3A77613D.184BB8D8@consumercontact.com>
Permalink:  ../3A77613D.184BB8D8@consumercontact.com/
Also on:    postgresql.org/message-id/3A77613D.184BB8D8@consumercontact.com

 · 

reply

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-sql@postgresql.org
  Cc: rick@consumercontact.com
  Subject: Re: Permissions for foreign keys
  In-Reply-To: <3A77613D.184BB8D8@consumercontact.com>
  References: <3A77613D.184BB8D8@consumercontact.com>

* 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