Re: [GENERAL] Unique index problem

2015-12-21 Thread John McKown
On Mon, Dec 21, 2015 at 1:00 PM, Scott Marlowe wrote: > On Sun, Dec 20, 2015 at 11:39 PM, Sterpu Victor wrote: > > Thank you. > > > > I used the syntax with 2 indexes, it works for me. > > But why does NULL != NULL? > > Because NULL literally means "an unknown, possibly unknowable value." > > Yo

Re: [GENERAL] Unique index problem

2015-12-21 Thread Scott Marlowe
On Sun, Dec 20, 2015 at 11:39 PM, Sterpu Victor wrote: > Thank you. > > I used the syntax with 2 indexes, it works for me. > But why does NULL != NULL? Because NULL literally means "an unknown, possibly unknowable value." You need to stop thinking of NULL as A value. It is not. -- Sent via pg

Re: [GENERAL] Unique index problem

2015-12-21 Thread Sterpu Victor
t;Sterpu Victor" Cc: "Marc Mamin" ; "PostgreSQL General" ; "Andreas Kretschmer" ; "Scott Marlowe" Sent: 12/21/2015 8:44:14 AM Subject: Re: [GENERAL] Unique index problem 2015-12-21 7:39 GMT+01:00 Sterpu Victor : Thank you. I used the synta

Re: [GENERAL] Unique index problem

2015-12-20 Thread Pavel Stehule
"Marc Mamin" > To: "Sterpu Victor" > Cc: "PostgreSQL General" ; "Andreas > Kretschmer" ; "Scott Marlowe" < > scott.marl...@gmail.com> > Sent: 12/20/2015 11:44:35 PM > Subject: AW: [GENERAL] Unique index problem >

Re: [GENERAL] Unique index problem

2015-12-20 Thread Sterpu Victor
/20/2015 11:44:35 PM Subject: AW: [GENERAL] Unique index problem pgsql-general-ow...@postgresql.org [pgsql-general-ow...@postgresql.org]" im Auftrag von "Scott Marlowe [scott.marl...@gmail.com] ndet: Sonntag, 20. Dezember 2015 17:02 Sterpu Victor Po

Re: [GENERAL] Unique index problem

2015-12-20 Thread Jim Nasby
On 12/20/15 10:18 AM, Andreas Kretschmer wrote: test=*# create unique index on foo(a,b,c) where a is not null and b is not null and c is not null; CREATE INDEX As you discovered, you'd have to build separate indexes for each of the nullable fields: UNIQUE ON (a,b) WHERE c IS NULL a,c WHERE b

Re: [GENERAL] Unique index problem

2015-12-20 Thread Marc Mamin
pgsql-general-ow...@postgresql.org [pgsql-general-ow...@postgresql.org]" im Auftrag von "Scott Marlowe [scott.marl...@gmail.com] ndet: Sonntag, 20. Dezember 2015 17:02 Sterpu Victor PostgreSQL General eff: Re: [GENERAL] Unique index problem un, De

Re: [GENERAL] Unique index problem

2015-12-20 Thread Andreas Kretschmer
Andreas Kretschmer wrote: > Andreas Kretschmer wrote: > > > > > Maybe there are better solutions, it's a quick hack ;-) > > better solution: sorry, doesn't work =:( Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect.

Re: [GENERAL] Unique index problem

2015-12-20 Thread Andreas Kretschmer
Andreas Kretschmer wrote: > > Maybe there are better solutions, it's a quick hack ;-) better solution: test=*# create unique index on foo(a,b,c) where a is not null and b is not null and c is not null; CREATE INDEX (partial index) Andreas -- Really, I'm not out to destroy Microsoft. That w

Re: [GENERAL] Unique index problem

2015-12-20 Thread Andreas Kretschmer
Sterpu Victor wrote: > Hello > > I created a unique index that doesn't seem to work when one column is NULL. > Index is created like this: CREATE UNIQUE INDEX lab_tests_groups_siui_uni ON > lab_tests_groups_siui(id_lab_tests_siui, id_lab_tests_groups, valid_from, > id_lab_sample_types); > Now I

Re: [GENERAL] Unique index problem

2015-12-20 Thread Scott Marlowe
On Sun, Dec 20, 2015 at 9:00 AM, Scott Marlowe wrote: > On Sun, Dec 20, 2015 at 8:50 AM, Sterpu Victor wrote: >> Hello >> >> I created a unique index that doesn't seem to work when one column is NULL. >> Index is created like this: CREATE UNIQUE INDEX lab_tests_groups_siui_uni ON >> lab_tests_gro

Re: [GENERAL] Unique index problem

2015-12-20 Thread Scott Marlowe
On Sun, Dec 20, 2015 at 8:50 AM, Sterpu Victor wrote: > Hello > > I created a unique index that doesn't seem to work when one column is NULL. > Index is created like this: CREATE UNIQUE INDEX lab_tests_groups_siui_uni ON > lab_tests_groups_siui(id_lab_tests_siui, id_lab_tests_groups, valid_from, >

[GENERAL] Unique index problem

2015-12-20 Thread Sterpu Victor
Hello I created a unique index that doesn't seem to work when one column is NULL. Index is created like this: CREATE UNIQUE INDEX lab_tests_groups_siui_uni ON lab_tests_groups_siui(id_lab_tests_siui, id_lab_tests_groups, valid_from, id_lab_sample_types); Now I can run this insert twice and I w