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

Deferrable UNIQUE INDEX?

From: David Fetter <david(at)fetter(dot)org>
To: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Deferrable UNIQUE INDEX?
Date: 2006-01-04 01:45:13
Message-ID: 20060104014512.GA27483@fetter.org (view raw or flat)
Thread:
Lists: 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(at)[local]=> BEGIN;
BEGIN
test(at)[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(at)fetter(dot)org http://fetter.org/
phone: +1 415 235 3778

Remember to vote!

Responses

pgsql-hackers by date

Next:From: Euler Taveira de OliveiraDate: 2006-01-04 02:18:06
Subject: Re: Inconsistent syntax in GRANT
Previous:From: Josh BerkusDate: 2006-01-04 01:19:41
Subject: Inconsistent syntax in GRANT

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