On Wed, Jul 21, 2010 at 9:02 PM, Stephen Frost <sfrost@snowman.net> wrote:
> * Robert Haas (robertmhaas@gmail.com) wrote:
>> I think the relevant case might be where ymj owns fk_tbl but not
>> pk_tbl, and has REFERENCES but not SELECT on pk_tbl.
>>
>> Come to think of it, I wonder if REFERENCES on fk_tbl ought to be
>> sufficient to create a foreign key. Currently, it requires ownership:
>>
>> rhaas=> ALTER TABLE fk_tbl ADD FOREIGN KEY (x) REFERENCES pk_tbl (a);
>> ERROR: must be owner of relation fk_tbl
>
> Errr, no. If I grant you REFERENCES on my table, it means you can
> create a FK to it from some other table.
Well, in that case, we should fix the fine documentation:
To create a foreign key constraint, it is necessary to have this privilege on both the referencing and
referencedcolumns. The privilege may be granted for all columns of a table, or just specific columns.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company