Обсуждение: small bug in ADD CONSTRAINT

Поиск
Список
Период
Сортировка

small bug in ADD CONSTRAINT

От
Joseph Shraibman
Дата:
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.

Re: small bug in ADD CONSTRAINT

От
Stephan Szabo
Дата:
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.

Re: small bug in ADD CONSTRAINT

От
Tom Lane
Дата:
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