aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-01-30 10:15:17 +1300
committerDavid Rowley <drowley@postgresql.org>2024-01-30 10:15:17 +1300
commitc85977d8fef7b18f69e0be72923ddb8dcc8165b5 (patch)
tree1535114a9ac962e41bbc8d2326d491820b1cdec6 /src/backend/commands
parent97287bdfae41b8ea16b27dccb63771fcc196a55a (diff)
downloadpostgresql-c85977d8fef7b18f69e0be72923ddb8dcc8165b5.tar.gz
postgresql-c85977d8fef7b18f69e0be72923ddb8dcc8165b5.zip
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 'src/backend/commands')
-rw-r--r--src/backend/commands/tablecmds.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 68f658e834e..9f51696740e 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -12117,15 +12117,19 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
/*
* transformFkeyCheckAttrs -
*
- * Make sure that the attributes of a referenced table belong to a unique
- * (or primary key) constraint. Return the OID of the index supporting
- * the constraint, as well as the opclasses associated with the index
- * columns.
+ * Validate that the 'attnums' columns in the 'pkrel' relation are valid to
+ * reference as part of a foreign key constraint.
+ *
+ * Returns the OID of the unique index supporting the constraint and
+ * populates the caller-provided 'opclasses' array with the opclasses
+ * associated with the index columns.
+ *
+ * Raises an ERROR on validation failure.
*/
static Oid
transformFkeyCheckAttrs(Relation pkrel,
int numattrs, int16 *attnums,
- Oid *opclasses) /* output parameter */
+ Oid *opclasses)
{
Oid indexoid = InvalidOid;
bool found = false;