Re: [BUGS] BUG #14596: False primary/unique key constraint violations - Mailing list pgsql-bugs

From Tom Lane
Subject Re: [BUGS] BUG #14596: False primary/unique key constraint violations
Date
Msg-id 31317.1490193907@sss.pgh.pa.us
Whole thread Raw
In response to [BUGS] BUG #14596: False primary/unique key constraint violations  (rasmus@mindplay.dk)
Responses Re: [BUGS] BUG #14596: False primary/unique key constraint violations
List pgsql-bugs
rasmus@mindplay.dk writes:
> It looks like constraints are being checked row-by-row while the udpate is
> happening?

This is documented somewhere ... ah, here, in the COMPATIBILITY section of
the CREATE TABLE reference page:

  Non-deferred Uniqueness Constraints

  When a UNIQUE or PRIMARY KEY constraint is not deferrable, PostgreSQL
  checks for uniqueness immediately whenever a row is inserted or
  modified. The SQL standard says that uniqueness should be enforced only
  at the end of the statement; this makes a difference when, for example,
  a single command updates multiple key values. To obtain
  standard-compliant behavior, declare the constraint as DEFERRABLE but
  not deferred (i.e., INITIALLY IMMEDIATE). Be aware that this can be
  significantly slower than immediate uniqueness checking.


            regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: 許耀彰
Date:
Subject: [BUGS] postgresql to mssql
Next
From: bricklen
Date:
Subject: Re: [BUGS] BUG #14596: False primary/unique key constraint violations