Skip site navigation (1) Skip section navigation (2)

Re: BUG #5115: ADD UNIQUE table_constraint with expression

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Vladimir Kokovic" <vladimir(dot)kokovic(at)a-asoft(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5115: ADD UNIQUE table_constraint with expression
Date: 2009-10-14 15:16:27
Message-ID: 13665.1255533387@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Vladimir Kokovic" <vladimir(dot)kokovic(at)a-asoft(dot)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

In response to

Responses

pgsql-bugs by date

Next:From: Heikki LinnakangasDate: 2009-10-14 15:23:32
Subject: Re: BUG #5115: ADD UNIQUE table_constraint with expression
Previous:From: Kevin GrittnerDate: 2009-10-14 15:15:00
Subject: Re: BUG #5115: ADD UNIQUE table_constraint with expression

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group