Search Postgresql Archives

UPDATE ... RETURNING atomicity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

In this query:
UPDATE foo
SET allocated_to=?
WHERE id=(SELECT MIN(id) FROM foo WHERE allocated_to IS NULL)
	AND allocated_to IS NULL
RETURNING id


Is it guaranteed in any way that there will only be one id allocated and returned even if multiple clients are executing this query concurrently? Or is there a possibility that some other client executing this query (or another query modifying allocated_to) might set allocated_to to non-NULL and commit right after the inner select finds it as NULL, so the outer "AND allocated_to IS NULL" will no longer be true, and the outer query will return nothing?

Thanks.

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux