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

2014-08-09 Thread Tom Lane
David Rowley dgrowle...@gmail.com writes: On Sat, Aug 9, 2014 at 3:34 PM, Tom Lane t...@sss.pgh.pa.us 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

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

2014-08-08 Thread Tom Lane
David Rowley dgrowle...@gmail.com 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)

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

2014-08-08 Thread Tom Lane
I wrote: David Rowley dgrowle...@gmail.com 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

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 t...@sss.pgh.pa.us 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

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

2014-08-08 Thread Tom Lane
David Rowley dgrowle...@gmail.com writes: On Sat, Aug 9, 2014 at 12:13 PM, Tom Lane t...@sss.pgh.pa.us 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

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 t...@sss.pgh.pa.us wrote: David Rowley dgrowle...@gmail.com writes: On Sat, Aug 9, 2014 at 12:13 PM, Tom Lane t...@sss.pgh.pa.us wrote: So I'm thinking you're right: we should rewrite this code so that only indexes having all columns distinct can