small bug in ADD CONSTRAINT

Started by Joseph Shraibmanabout 22 years ago3 messagesbugs
Jump to latest
#1Joseph Shraibman
jks@selectacast.net

This works:

ALTER TABLE segment ADD CONSTRAINT name unique(textfield, reseller);

This doesn't:
ALTER TABLE segment ADD CONSTRAINT name unique(lower(textfield),
reseller);

I had to create a unique index.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joseph Shraibman (#1)
Re: small bug in ADD CONSTRAINT

Joseph Shraibman <jks@selectacast.net> writes:

This works:
ALTER TABLE segment ADD CONSTRAINT name unique(textfield, reseller);

This doesn't:
ALTER TABLE segment ADD CONSTRAINT name unique(lower(textfield),
reseller);

I don't think this is a bug. The unique-constraint syntax is defined by
the SQL spec and it only allows simple column names. If we extended it
as you suggest, we would break code that expects constraints to apply to
columns (there is some in the backend as well as in clients).

regards, tom lane

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Joseph Shraibman (#1)
Re: small bug in ADD CONSTRAINT

On Wed, 10 Mar 2004, Joseph Shraibman wrote:

This works:

ALTER TABLE segment ADD CONSTRAINT name unique(textfield, reseller);

This doesn't:
ALTER TABLE segment ADD CONSTRAINT name unique(lower(textfield),
reseller);

I had to create a unique index.

I don't think this is a bug since it means that we properly accept a
column name list in the unique constraint as per at least SQL92.