Re: Example. Foreign Keys Constraints. Wrong Columns - Mailing list pgsql-docs

From David G. Johnston
Subject Re: Example. Foreign Keys Constraints. Wrong Columns
Date
Msg-id CAKFQuwbm4BD49A8ZqjZnxHKW8MsEURa6hrEvAWKxw0_nu=FZwg@mail.gmail.com
Whole thread
In response to Example. Foreign Keys Constraints. Wrong Columns  (PG Doc comments form <noreply@postgresql.org>)
Responses Re: Example. Foreign Keys Constraints. Wrong Columns
List pgsql-docs
On Wed, Apr 15, 2026 at 7:51 AM PG Doc comments form <noreply@postgresql.org> wrote:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/18/ddl-constraints.html
Description:

https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK

 
Given that users has:
    PRIMARY KEY (tenant_id, user_id)


This:


    FOREIGN KEY (tenant_id, author_id) REFERENCES users ON DELETE SET NULL
(author_id)

 
And this:
 
    FOREIGN KEY (tenant_id, author_id) REFERENCES users (tenant_id, user_id)
ON DELETE SET NULL (author_id)

Produce an identical outcome.

The absence of a column list on the former causes the system to look at the primary key for the named table and use its column list - which is (tenant_id, user_id), same as the later explicit version.

David J.

pgsql-docs by date:

Previous
From: Yushu Chen
Date:
Subject: Re: doc: Clarify ANALYZE VERBOSE output
Next
From: "David G. Johnston"
Date:
Subject: Re: Logical Replication upgrade