On 2018-Jul-20, Praveen Kumar wrote:

> Regarding UPDATEs on rows that are locked via "SELECT FOR UPDATE" in
> another transaction, I read the above as follows: other transactions that
> attempt UPDATE of these rows will be blocked until the current transaction
> ( which did "SELECT FOR UPDATE" for those rows ) ends, unless the columns
> in these rows being UPDATE'ed are those that don't have a unique index on
> them that can be used in a foreign key.
>
> Is this correct ?

No.  What it means that if you UPDATE the columns-indexed-by-unique-idx
then the FOR UPDATE lock is acquired underneath.  If your UPDATE
modifies some other column, then a FOR NO KEY UPDATE lock is acquired
instead.  In both cases, concurrent transactions would be blocked rather
than erroring out.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Reply via email to