Non-unique values problem after 'add column' - Mailing list pgsql-general

From dima.kagan@gmail.com
Subject Non-unique values problem after 'add column'
Date
Msg-id 87677990-ef0d-4104-8216-092106341455@i29g2000prf.googlegroups.com
Whole thread Raw
Responses Re: Non-unique values problem after 'add column'
Re: Non-unique values problem after 'add column'
List pgsql-general
Hello!

I've encountered a very strange problem with Postgresql 7.3.
I have the following set of queries running in transaction, using
libpqxx 2.6.9:

ALTER TABLE my_table ADD new_column TEXT
UPDATE my_table SET new_column = 'disable'
ALTER TABLE my_table ALTER COLUMN new_column SET DEFAULT 'disable'
CREATE UNIQUE INDEX my_index ON my_table (old_column)

The last query fails with:
ERROR:  Cannot create unique index. Table contains non-unique values

Running the same set of queries manually causes no problems. Moreover,
running the last query in a separate transaction works as well.

Why is a new column affecting unique index creation on an already
existing one? Is there any workaround for this issue?

Thank you,
Dima Kagan

pgsql-general by date:

Previous
From: Wolfgang Keller
Date:
Subject: Re: Linux v.s. Mac OS-X Performance
Next
From: "Pau Marc Munoz Torres"
Date:
Subject: indexing tables using my owns functions