Re: [HACKERS] Defining a foreign key with a duplicate column is broken

2014-08-09 Thread Tom Lane
David Rowley writes: > On Sat, Aug 9, 2014 at 3:34 PM, Tom Lane wrote: >> There's no need for a new error message I think, because we should just >> ignore such indexes. After all, there might be a valid matching index >> later on. > hmm, but if the user attempts to define the foreign key that

Re: [HACKERS] Defining a foreign key with a duplicate column is broken

2014-08-08 Thread David Rowley
On Sat, Aug 9, 2014 at 3:34 PM, Tom Lane wrote: > David Rowley writes: > > On Sat, Aug 9, 2014 at 12:13 PM, Tom Lane wrote: > >> So I'm thinking you're right: we should rewrite this code so that only > >> indexes having all columns distinct can match, thereby ensuring that > there > >> is only

Re: [HACKERS] Defining a foreign key with a duplicate column is broken

2014-08-08 Thread Tom Lane
David Rowley writes: > On Sat, Aug 9, 2014 at 12:13 PM, Tom Lane wrote: >> So I'm thinking you're right: we should rewrite this code so that only >> indexes having all columns distinct can match, thereby ensuring that there >> is only one possible interpretation of the equality semantics for the

Re: [HACKERS] Defining a foreign key with a duplicate column is broken

2014-08-08 Thread David Rowley
On Sat, Aug 9, 2014 at 12:13 PM, Tom Lane wrote: > > So I'm thinking you're right: we should rewrite this code so that only > indexes having all columns distinct can match, thereby ensuring that there > is only one possible interpretation of the equality semantics for the > foreign key. > > I've

Re: [HACKERS] Defining a foreign key with a duplicate column is broken

2014-08-08 Thread Tom Lane
I wrote: > David Rowley writes: >> The attached seems to fix the problem, but the whole thing makes me wonder >> if this is even meant to be allowed? I was thinking that this might be a >> good time to disallow this altogether, since it's already broken and looks >> like it has been for about 11 y

Re: [HACKERS] Defining a foreign key with a duplicate column is broken

2014-08-08 Thread Tom Lane
David Rowley writes: > I wasn't quite sure if it was possible to include the same column twice in > a foreign key, so I tested > create table r1 (a int); > create table r2 (b int); > create unique index on r2(b,b); > alter table r1 add constraint r2_b_fkey foreign key (a,a) references r2 > (b

[HACKERS] Defining a foreign key with a duplicate column is broken

2014-08-08 Thread David Rowley
In master I've been testing some new code that I'm working on around foreign keys. I wasn't quite sure if it was possible to include the same column twice in a foreign key, so I tested create table r1 (a int); create table r2 (b int); create unique index on r2(b,b); alter table r1 add constrai