Thread: BUG with UNIQUE clause

BUG with UNIQUE clause

From
"Stéphane FILLON"
Date:
Hi,
 
The UNIQUE constraint doesn't work on a field if I use a DEFAULT clause on a table.
 
The following table works with UNIQUE constraint:
 
create table cltclt001(
  tcid int2,
  tcnom text unique
);
 
but this one accept several same tcnom value:
 
create table cltclt001(
  tcid int2 default nextval('cltcls001'),
  tcnom text unique
);
 
 
What's wrong with my table ?
 
Thanks in advance.
 
Stephane FILLON

Re: [HACKERS] BUG with UNIQUE clause

From
Tom Lane
Date:
"=?iso-8859-1?Q?St=E9phane_FILLON?=" <fillons@offratel.nc> writes:
> The UNIQUE constraint doesn't work on a field if I use a DEFAULT clause
> on a table.

This sounds closely related to a fix that Thomas Lockhart just made.
IIRC the complained-of symptom was that PRIMARY KEY on one column plus
UNIQUE on another didn't work, but the real problem was that PRIMARY
KEY implies UNIQUE and the table declaration code was getting confused
by two different UNIQUE columns in one table.  It could be that his fix
addresses your problem too.  Check the pghackers archives for the
last couple weeks to find the patch.

            regards, tom lane