]> granicus.if.org Git - postgresql/commit
For foreign keys, check REFERENCES privilege only on the referenced table.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 31 Mar 2017 22:11:25 +0000 (18:11 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 31 Mar 2017 22:11:30 +0000 (18:11 -0400)
commit64d4da511c012faff8ac309595620938a43c6817
tree9e33373fbe92f59174e28d92232564cac2f14ed5
parent8f18a880a5f138d4da94173d15514142331f8de6
For foreign keys, check REFERENCES privilege only on the referenced table.

We were requiring that the user have REFERENCES permission on both the
referenced and referencing tables --- but this doesn't seem to have any
support in the SQL standard, which says only that you need REFERENCES
permission on the referenced table.  And ALTER TABLE ADD FOREIGN KEY has
already checked that you own the referencing table, so the check could
only fail if a table owner has revoked his own REFERENCES permission.
Moreover, the symmetric interpretation of this permission is unintuitive
and confusing, as per complaint from Paul Jungwirth.  So let's drop the
referencing-side check.

In passing, do a bit of wordsmithing on the GRANT reference page so that
all the privilege types are described in similar fashion.

Discussion: https://postgr.es/m/8940.1490906755@sss.pgh.pa.us
doc/src/sgml/ref/create_table.sgml
doc/src/sgml/ref/grant.sgml
src/backend/commands/tablecmds.c