Unique index problem - Mailing list pgsql-general

From Sterpu Victor
Subject Unique index problem
Date
Msg-id em17f49055-156c-40e5-ae9d-252d62bed17d@victor-pc
Whole thread Raw
Responses Re: Unique index problem
Re: Unique index problem
List pgsql-general
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 will have 2 records in the database that seem to violate this index:
INSERT INTO lab_tests_groups_siui(id_lab_tests_siui, id_lab_tests_groups, valid_from) VALUES(463, 9183, '2014-06-01');
 
When I create the index 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);" index works fine.
 
I tested this on postgres 9.1.4 and 9.1.9.
 
Thank you.

DISCLAIMER:
Acest mesaj de posta electronica si documentele aferente sunt confidentiale. Este interzisa distribuirea, dezvaluirea sau orice alt mod de utilizare a lor. Daca nu sunteti destinatarul acestui mesaj, este interzis sa actionati in baza acestor informatii. Citirea, copierea, distribuirea, dezvaluirea sau utilizarea in alt mod a informatiei continute in acest mesaj constituie o incalcare a legii. Daca ati primit mesajul din greseala, va rugam sa il distrugeti, anuntand expeditorul de eroarea comisa. Intrucat nu poate fi garantat faptul ca posta electronica este un mod sigur si lipsit de erori de transmitere a informatiilor, este responsabilitatea dvs. sa va asigurati ca mesajul (inclusiv documentele alaturate lui) este validat si autorizat spre a fi utilizat in mediul dvs.

pgsql-general by date:

Previous
From: oleg yusim
Date:
Subject: Session Identifiers
Next
From: Scott Marlowe
Date:
Subject: Re: Unique index problem