In MSSQL I am using sp_getapplock, sp_releaseapplock.
How can I achieve the same functionality in PostgreSql?