unique constraint - bug? - Mailing list pgsql-general

From Merrill Oveson
Subject unique constraint - bug?
Date
Msg-id 39762A1F.B5089BED@actiontarget.com
Whole thread Raw
Responses Re: unique constraint - bug?
List pgsql-general
All:

Run the following script:

                    drop table letter;
                    create table letter (
                                a char(1),
                                b char(1),
                                c char(1),
                                unique (a, b, c)
                        );

                        insert into letter values('1','2','3');
                        insert into letter values('1','2','3');

                        insert into letter (a,c) values ('1','3');
                        insert into letter (a,c) values ('1','3');

Notice that the second insert of ('1','2','3') yields an error message,
which is the correct behavior - (that is the unique constaint is
working),
while the last insert of ('1','3') does not yield an error message -
(that is
the unique constraint doesn't work in this case - I think it should).

It appears as though the null value inserted for column b causes an
abrogation
of the unique constaint.

Is this intended or is it a bug?
Or should I be doing something different?

Thanks

Merrill






pgsql-general by date:

Previous
From: "Swaminathan R. Iyer"
Date:
Subject: Retrieving images from PG using Java
Next
From: "Joel Burton"
Date:
Subject: Re: Does CREATE FUNCTION... WITH (ISCACHABLE) work?