X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EE1DE329F2E for ; Wed, 20 Oct 2004 17:56:16 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36268-07 for ; Wed, 20 Oct 2004 16:56:05 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id BDD76329CFB for ; Wed, 20 Oct 2004 17:56:05 +0100 (BST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 3706435751; Wed, 20 Oct 2004 09:56:04 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 06EF835587; Wed, 20 Oct 2004 09:56:04 -0700 (PDT) Date: Wed, 20 Oct 2004 09:56:03 -0700 (PDT) From: Stephan Szabo To: Markus Bertheau Cc: pgsql-sql@postgresql.org Subject: Re: time of constraint checking In-Reply-To: <1098287892.2649.15.camel@dicaprio.akademie1.de> Message-ID: <20041020095039.N4154@megazone.bigpanda.com> References: <1098287892.2649.15.camel@dicaprio.akademie1.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/148 X-Sequence-Number: 19251 On Wed, 20 Oct 2004, Markus Bertheau wrote: > 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" Unique constraints are currently non-compliant in that it checks on each changed row rather than at the end of the statement. I thought this was mentioned somewhere, but it might make sense to mention it in the compatibility section. > Also, are deferrable constraints other that FK constraints in the works? I don't think anyone's looking at it right now.