Non-unique values problem after 'add column'

Поиск
Список
Период
Сортировка
От dima.kagan@gmail.com
Тема Non-unique values problem after 'add column'
Дата
Msg-id 87677990-ef0d-4104-8216-092106341455@i29g2000prf.googlegroups.com
обсуждение исходный текст
Ответы Re: Non-unique values problem after 'add column'
Re: Non-unique values problem after 'add column'
Список 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 по дате отправления:

Предыдущее
От: Wolfgang Keller
Дата:
Сообщение: Re: Linux v.s. Mac OS-X Performance
Следующее
От: "Pau Marc Munoz Torres"
Дата:
Сообщение: indexing tables using my owns functions