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

time of constraint checking

From: Markus Bertheau <twanger(at)bluetwanger(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: time of constraint checking
Date: 2004-10-20 15:58:12
Message-ID: 1098287892.2649.15.camel@dicaprio.akademie1.de (view raw or flat)
Thread:
Lists: pgsql-sql
Hi,

http://www.postgresql.org/docs/current/static/sql-createtable.html says,
down at the explanation of DEFERRABLE, that constraints are checked
after every command. Why does the following not work then:

CREATE TABLE foo (
    pos INT UNIQUE
);
 
INSERT INTO foo (pos) VALUES (1);
INSERT INTO foo (pos) VALUES (2);
 
UPDATE foo SET pos = CASE WHEN pos = 2 THEN 1 ELSE 2 END;
ERROR:  duplicate key violates unique constraint "foo_pos_key"

Also, are deferrable constraints other that FK constraints in the works?
I also noticed, that the docs don't state whether INITIALLY IMMEDIATE or
INITIALLY DEFERRED is the default.

Thanks.

-- 
Markus Bertheau <twanger(at)bluetwanger(dot)de>


Responses

pgsql-sql by date

Next:From: Markus BertheauDate: 2004-10-20 16:16:04
Subject: Re: time of constraint checking
Previous:From: WeipingDate: 2004-10-20 14:57:34
Subject: Re: the problem of createlang!

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