Deferrable UNIQUE INDEX?

Поиск
Список
Период
Сортировка
От David Fetter
Тема Deferrable UNIQUE INDEX?
Дата
Msg-id 20060104014512.GA27483@fetter.org
обсуждение исходный текст
Ответы Re: Deferrable UNIQUE INDEX?  ("Andrew Dunstan" <andrew@dunslane.net>)
Re: Deferrable UNIQUE INDEX?  (Michael Glaesemann <grzm@myrealbox.com>)
Список pgsql-hackers
Folks,

I just stumbled across a little problem that looks like this:

CREATE TABLE foo (   id SERIAL PRIMARY KEY,   f_text TEXT NOT NULL
);

CREATE UNIQUE INDEX uniq_foo_f_text ON foo(LOWER(TRIM(f_text)));

COPY foo(f_text) FROM stdin;
a
b
c
\.

Oh, shucks.  I'd like to permute these.  Lemme start a transaction:

test@[local]=> BEGIN;
BEGIN
test@[local]=> UPDATE foo set f_text = 'a' where id=3;
ERROR:  duplicate key violates unique constraint "uniq_foo_f_text"

Dang!  Everything was going to be kosher at the end of the
transaction, but I never got a chance.

Is there some way to make the index check INITIALLY DEFERRABLE the way
a regular column/table constraint could be?

I'd much appreciate any insights into this :)

Cheers,
D
-- 
David Fetter david@fetter.org http://fetter.org/
phone: +1 415 235 3778

Remember to vote!


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Inconsistent syntax in GRANT
Следующее
От: "Andrew Dunstan"
Дата:
Сообщение: Re: Deferrable UNIQUE INDEX?