Re: FK v.s unique indexes

2018-07-05 Thread David G. Johnston
On Thu, Jul 5, 2018 at 2:36 PM, Rafal Pietrak wrote: > > > W dniu 05.07.2018 o 23:04, David G. Johnston pisze: > > On Thu, Jul 5, 2018 at 1:45 PM, Rafal Pietrak > >wrote: > > > > I was thinking, that when "add constraint" cannot choose appropriate > > index, may b

Re: FK v.s unique indexes

2018-07-05 Thread Rafal Pietrak
W dniu 05.07.2018 o 23:04, David G. Johnston pisze: > On Thu, Jul 5, 2018 at 1:45 PM, Rafal Pietrak >wrote: > > I was thinking, that when "add constraint" cannot choose appropriate > index, may be some explicit help (like ... using ;) would be > due. > > >

Re: FK v.s unique indexes

2018-07-05 Thread David G. Johnston
On Thu, Jul 5, 2018 at 1:45 PM, Rafal Pietrak wrote: > I was thinking, that when "add constraint" cannot choose appropriate > index, may be some explicit help (like ... using ;) would be > due. > ​Basically all the FK trigger does is: SELECT EXISTS(SELECT 1 FROM pk_table WHERE pk_col1 = val1 AN

Re: FK v.s unique indexes

2018-07-05 Thread Rafal Pietrak
W dniu 05.07.2018 o 10:11, Rob Sargent pisze: [---] >> >> Pls consider in real life: load (a person), can have either a (a kind of >> brest cancer); or b (a kind of prostrate) - this is only a cooked >> example attemping to illustrate, that one may need to put additional >> constrain

Re: FK v.s unique indexes

2018-07-05 Thread Rafal Pietrak
W dniu 05.07.2018 o 15:18, David G. Johnston pisze: > On Thursday, July 5, 2018, Rafal Pietrak > wrote: > > W dniu 04.07.2018 o 00:55, David G. Johnston pisze: > > On Tuesday, July 3, 2018, Rafal Pietrak > >

Re: FK v.s unique indexes

2018-07-05 Thread David G. Johnston
On Thursday, July 5, 2018, Rafal Pietrak wrote: > > W dniu 04.07.2018 o 00:55, David G. Johnston pisze: > > On Tuesday, July 3, 2018, Rafal Pietrak > > wrote: > > > > > > ERROR: there is no unique constraint matching given keys for > referenced > > table "test2" >

Re: FK v.s unique indexes

2018-07-05 Thread pinker
David Rowley-3 wrote > I don't think there were any actual roadblocks, it was more of just > not enough time in the cycle to make it work due to a few technical > details that required extra effort to make work. > > Alvaro managed to simplify the problem and allow foreign keys to be > defined on p

Re: FK v.s unique indexes

2018-07-05 Thread Rob Sargent
> On Jul 5, 2018, at 1:30 AM, Rafal Pietrak wrote: > > > > W dniu 04.07.2018 o 00:55, David G. Johnston pisze: >> On Tuesday, July 3, 2018, Rafal Pietrak > > wrote: >> >> >>ERROR: there is no unique constraint matching given keys for referenced >>table "tes

Re: FK v.s unique indexes

2018-07-05 Thread Rafal Pietrak
W dniu 03.07.2018 o 11:23, David Rowley pisze: > On 3 July 2018 at 19:30, Rafal Pietrak wrote: [---] >> >> Why is this forbidden? > > I don't think there were any actual roadblocks, it was more of just > not enough time in the cycle to make it work due to a few technical > details

Re: FK v.s unique indexes

2018-07-05 Thread Rafal Pietrak
W dniu 04.07.2018 o 00:55, David G. Johnston pisze: > On Tuesday, July 3, 2018, Rafal Pietrak > wrote: > > > ERROR:  there is no unique constraint matching given keys for referenced > table "test2" > > > I cannot see any re

Re: FK v.s unique indexes

2018-07-03 Thread David G. Johnston
On Tuesday, July 3, 2018, Rafal Pietrak wrote: > > ERROR: there is no unique constraint matching given keys for referenced > table "test2" > > > I cannot see any reasons why this functionality is blocked. > > In particular, contrary to what the ERROR says, the target

Re: FK v.s unique indexes

2018-07-03 Thread Tim Cross
Rafal Pietrak writes: > > In particular, contrary to what the ERROR says, the target table *does > have* a "unique constraint matching given keys", admittedly only > partial. Yet, why should that matter at all? A unique index, partial or > not, always yield a single row, and that's all what mat

Re: FK v.s unique indexes

2018-07-03 Thread David Rowley
On 3 July 2018 at 19:30, Rafal Pietrak wrote: > tst=# create table test1(load bigint, a int, b int, c bool) partition by > list (c); > CREATE TABLE > tst=# create table test1_true partition of test1 for values in (true); > CREATE TABLE > tst=# create table test1_false partition of test1 for valu

FK v.s unique indexes

2018-07-03 Thread Rafal Pietrak
Hi, For some time now, I'm withholding new features in my DB application as I wasn't able to have unique constraints on partitioned tables. PG-v11 now has it and I've given it a try, but to my surprise it does not give it fully to the application. Those indexes don't support FK! At this point I've