Glossary: PostgreSQL for Developers
FOR UPDATE
Also written: SELECT ... FOR UPDATE
Added to a SELECT, it reads rows and locks them at once, so no other session can change them until your transaction ends. It prevents two customers buying the last mug.