title: How do I use string as a key to PostgreSQL advisory lock?
body: <p>There is a locking mechanism in PostgreSQL called <a href="http://www.postgresql.org/docs/9.4/static/explicit-locking.html#ADVISORY-LOCKS">advisory locking</a>. It provides the following <a href="http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS">API functions</a>.</p>
  
  <p>The function that allows us to obtain such a lock accepts an big integer argument: <code>pg_advisory_lock(key bigint)</code> or two integer keys: <code>pg_advisory_lock(key1 int, key2 int)</code> (second form).</p>
  
  <p>What abstraction mechanism can I use to be able to use string keys instead of integer ones? Maybe some hashing functions will be able to do the job?</p>
  
  <p>Is it possible to implement this solely in the PostgreSQL without the need to cast string to integer on the application level?</p>
  
  <p>If the desired goal is hard to achieve maybe I can use two integer to identify the row in the table. The second integer could be a primary key of the row, but what integer can I use as a table identifier?</p>