Forum OpenACS Q&A: Response to locking and deadlocks

Collapse
Posted by Jonathan Ellis on
Ack, I shouldn't post at night. That didn't make sense at all. Ignore that last example. Here's what I mean:
update foo f set i = i * 2 where 1 < (select count(*) from foo f2 where ft.field = f.field)
Could a query like this deadlock with itself, or is postgres smart enough to see the update and grab an exclusive lock before evaluating the subquery and getting a shared lock?