title: Would this mutex implementation make sense in PostgreSQL?
body: <p>I Need to implement synchronization between database sessions in PostgreSQL.</p>
  
  <p>In SQL Server, I would implement it by creating my own "locking" table.</p>
  
  <pre><code>Create table MyLock(LockName VARCHAR(100) NOT NULL UNIQUE, LockOwner INT NULL)
  </code></pre>
  
  <p>I do not use explicit transaction to avoid really locking things up, I would acquire my "singleton" lock by putting my session Id as "owner".</p>
  
  <pre><code>UPDATE MyLock
    SET LockOwner = *MySessionId*
    WHERE LockName = 'Singleton' 
    AND LockOwner IS NULL;
  </code></pre>
  
  <p>By not using explicit transactions, I am not holding up other processes.
  You could think of this as "soft lock"...</p>
  
  <p>If my update succeeds, then I know I "have" the lock and I can process some bit of code while other(s) would wait.
  If my update updated nothing, I know someone else has the "lock" and I wait, or give up.</p>
  
  <p>I need to implement something similar in PostgreSQL.</p>
  
  <p>Would you do it like this?</p>