Re: BUG #5115: ADD UNIQUE table_constraint with expression - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5115: ADD UNIQUE table_constraint with expression
Date
Msg-id 13665.1255533387@sss.pgh.pa.us
Whole thread Raw
In response to BUG #5115: ADD UNIQUE table_constraint with expression  ("Vladimir Kokovic" <vladimir.kokovic@a-asoft.com>)
List pgsql-bugs
"Vladimir Kokovic" <vladimir.kokovic@a-asoft.com> writes:
> For ALTER TABLE ADD CONSTRAINT documentation says:
> ADD table_constraint
>     This form adds a new constraint to a table using the same syntax as
> CREATE TABLE.

> But if expression is used in the constraint definition
> server says:
> # ALTER TABLE asoft_finansije.gk_promene ADD CONSTRAINT vk2
> UNIQUE((substring(broj,10)),id)
> asoft-# ;
> ERROR:  42601: syntax error at or near "("
> LINE 1: ...ft_finansije.gk_promene ADD CONSTRAINT vk2 UNIQUE((substring...
>                                                              ^

Yeah, if you tried writing that in CREATE TABLE, it would complain too.

> Create index is OK:
> *# CREATE UNIQUE INDEX vk2 on
> adefault_finansije.gk_promene((substring(broj,10)),id);
> CREATE INDEX

This is not a CONSTRAINT clause in a CREATE TABLE.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: BUG #5115: ADD UNIQUE table_constraint with expression
Next
From: Heikki Linnakangas
Date:
Subject: Re: BUG #5115: ADD UNIQUE table_constraint with expression