Thread: Re: [SQL] UNIQUE constraint

Re: [SQL] UNIQUE constraint

From
"Mihai Barbos"
Date:
My fault, the correct situation is
create table TEST    (   testkey    something    PRIMARY KEY,   testval    something    UNIQUE,
.....................
);

PRIMARY KEY works OK, but UNIQUE is ignored.

-----Original Message-----
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mihai Barbos <barbos@moon.ro>
Cc: pgsql-sql@hub.org <pgsql-sql@hub.org>
Date: Thursday, August 12, 1999 4:25 PM
Subject: Re: [SQL] UNIQUE constraint


>"Mihai Barbos" <barbos@moon.ro> writes:
>> Maybe I haven't looked in the roght place but here's my problem:
>> I've upgraded to 6.5 and I'm trying to use UNIQUE, something like:
>> create table TEST    (
>>         testval    something    UNIQUE,
>>         .....................,
>> );
>> In 6.4.2 it worked OK, but now it seems it has no effect. Is there any
>> problem with UNIQUE ?
>
>I don't see any:
>
>create table TEST    (
>testval    int4 UNIQUE
>);
>NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'test_testval_key'
for table 'test'
>CREATE
>insert into test values (1);
>INSERT 283276 1
>insert into test values (1);
>ERROR:  Cannot insert a duplicate key into a unique index
>
>You're going to have to be more specific about what problem you
>are observing.
>
> regards, tom lane
>



Re: [SQL] UNIQUE constraint

From
Tom Lane
Date:
"Mihai Barbos" <barbos@moon.ro> writes:
> My fault, the correct situation is
> create table TEST    (
>     testkey    something    PRIMARY KEY,
>     testval    something    UNIQUE,
>          .....................
> );

> PRIMARY KEY works OK, but UNIQUE is ignored.

Oh, OK: that bug was noticed and fixed a couple of weeks ago.  If you
have *both* a PRIMARY KEY and a UNIQUE on a different field, the UNIQUE
gets dropped --- both 6.5 and 6.5.1 have this mistake.  See the patch
Thomas Lockhart posted a week or two back.
        regards, tom lane


Re: [SQL] UNIQUE constraint

From
Bruce Momjian
Date:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> My fault, the correct situation is
> create table TEST    (
>     testkey    something    PRIMARY KEY,
>     testval    something    UNIQUE,
>          .....................
> );
> 
> PRIMARY KEY works OK, but UNIQUE is ignored.

This is now fixed.

create table TEST    (   testkey    int    PRIMARY KEY,   testval    int    UNIQUE
);
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'test_pkey'
for table 'test'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index
'test_testval_key' for table 'test'
CREATE

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026