diff options
author | David Rowley <drowley@postgresql.org> | 2024-01-30 10:16:42 +1300 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2024-01-30 10:16:42 +1300 |
commit | 973e14028e85364d81c78270ff00440e21e281fd (patch) | |
tree | 30910d60220e15d29a586dd39da29fcd5d9af229 /doc/src/sgml/ref/create_table.sgml | |
parent | 29e25a6b1eb1b77ecfdbcb5b8dc07c8a6cdcf089 (diff) |
Doc: mention foreign keys can reference unique indexes
We seem to have only documented a foreign key can reference the columns of
a primary key or unique constraint. Here we adjust the documentation
to mention columns in a non-partial unique index can be mentioned too.
The header comment for transformFkeyCheckAttrs() also didn't mention
unique indexes, so fix that too. In passing make that header comment
reflect reality in the various other aspects where it deviated from it.
Bug: 18295
Reported-by: Gilles PARC
Author: Laurenz Albe, David Rowley
Discussion: https://www.postgresql.org/message-id/18295-0ed0fac5c9f7b17b%40postgresql.org
Backpatch-through: 12
Diffstat (limited to 'doc/src/sgml/ref/create_table.sgml')
-rw-r--r-- | doc/src/sgml/ref/create_table.sgml | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 43127940e41..a538283d8ec 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1098,10 +1098,11 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM column(s) of some row of the referenced table. If the <replaceable class="parameter">refcolumn</replaceable> list is omitted, the primary key of the <replaceable class="parameter">reftable</replaceable> - is used. The referenced columns must be the columns of a non-deferrable - unique or primary key constraint in the referenced table. The user - must have <literal>REFERENCES</literal> permission on the referenced table - (either the whole table, or the specific referenced columns). The + is used. Otherwise, the <replaceable class="parameter">refcolumn</replaceable> + list must refer to the columns of a non-deferrable unique or primary key + constraint or be the columns of a non-partial unique index. The user + must have <literal>REFERENCES</literal> permission on the referenced + table (either the whole table, or the specific referenced columns). The addition of a foreign key constraint requires a <literal>SHARE ROW EXCLUSIVE</literal> lock on the referenced table. Note that foreign key constraints cannot be defined between temporary @@ -2234,6 +2235,16 @@ CREATE TABLE cities_partdef </refsect2> <refsect2> + <title>Foreign Key Constraints</title> + + <para> + It is a <productname>PostgreSQL</productname> extension that a + foreign key constraint may reference columns of a unique index instead of + columns of a primary key or unique constraint. + </para> + </refsect2> + + <refsect2> <title><literal>NULL</literal> <quote>Constraint</quote></title> <para> |