From: Tom Lane <tgl@sss.pgh.pa.us>
To: rasmus@mindplay.dk
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14596: False primary/unique key constraint violations
Date: Wed, 22 Mar 2017 10:45:07 -0400
Message-ID: <31317.1490193907@sss.pgh.pa.us> (raw)
In-Reply-To: <20170322123053.1421.55154@wrigleys.postgresql.org>
References: <20170322123053.1421.55154@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, rasmus@mindplay.dk
Subject: Re: BUG #14596: False primary/unique key constraint violations
In-Reply-To: <31317.1490193907@sss.pgh.pa.us>
References: <20170322123053.1421.55154@wrigleys.postgresql.org> <31317.1490193907@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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