pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
time of constraint checking
3+ messages / 2 participants
[nested] [flat]

* time of constraint checking
@ 2004-10-20 15:58  Markus Bertheau <twanger@bluetwanger.de>
  0 siblings, 2 replies; 3+ messages in thread

From: Markus Bertheau @ 2004-10-20 15:58 UTC (permalink / raw)
  To: 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@bluetwanger.de>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: time of constraint checking
@ 2004-10-20 16:16  Markus Bertheau <twanger@bluetwanger.de>
  parent: Markus Bertheau <twanger@bluetwanger.de>
  1 sibling, 0 replies; 3+ messages in thread

From: Markus Bertheau @ 2004-10-20 16:16 UTC (permalink / raw)
  To: pgsql-sql

В Срд, 20.10.2004, в 17:58, Markus Bertheau пишет:

> I also noticed, that the docs don't state whether INITIALLY IMMEDIATE or
> INITIALLY DEFERRED is the default.

I just overlooked that, sorry, it is stated.

-- 
Markus Bertheau <twanger@bluetwanger.de>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: time of constraint checking
@ 2004-10-20 16:56  Stephan Szabo <sszabo@megazone.bigpanda.com>
  parent: Markus Bertheau <twanger@bluetwanger.de>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2004-10-20 16:56 UTC (permalink / raw)
  To: Markus Bertheau <twanger@bluetwanger.de>; +Cc: pgsql-sql

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.



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-10-20 16:56 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-10-20 15:58 time of constraint checking Markus Bertheau <twanger@bluetwanger.de>
2004-10-20 16:16 ` Markus Bertheau <twanger@bluetwanger.de>
2004-10-20 16:56 ` Stephan Szabo <sszabo@megazone.bigpanda.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox