From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
Cc: | Kaiting Chen <ktchen14(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, hellopfm(at)gmail(dot)com |
Subject: | Re: Allow foreign keys to reference a superset of unique columns |
Date: | 2022-06-10 03:47:34 |
Message-ID: | CAApHDvpL88UCbBv3VxY1Z4UVv+5RwGm0A6zZi3JZ=dmPU0=S9A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 10 Jun 2022 at 15:08, Peter Eisentraut
<peter(dot)eisentraut(at)enterprisedb(dot)com> wrote:
>
> On 07.06.22 20:59, Kaiting Chen wrote:
> > 2. The FOREIGN KEY constraint syntax gains a [ USING INDEX index_name ] clause
> > optionally following the referenced column list.
> >
> > The index specified by this clause is used to support the foreign key
> > constraint, and it must be a non-deferrable unique or primary key index on
> > the referenced table compatible with the referenced columns.
> >
> > Here, compatible means that the columns of the index are a subset (the same,
> > or a strict subset) of the referenced columns.
>
> I think this should be referring to constraint name, not an index name.
Can you explain why you think that?
My thoughts are that it should be an index name. I'm basing that on
the fact that transformFkeyCheckAttrs() look for valid unique indexes
rather than constraints. The referenced table does not need any
primary key or unique constraints to be referenced by a foreign key.
It just needs a unique index matching the referencing columns.
It would seem very strange to me if we required a unique or primary
key constraint to exist only when this new syntax is being used. Maybe
I'm missing something though?
David
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2022-06-10 04:14:11 | Re: Allow foreign keys to reference a superset of unique columns |
Previous Message | Peter Eisentraut | 2022-06-10 03:08:31 | Re: Allow foreign keys to reference a superset of unique columns |