Complete the code to acquire a session-level advisory lock with key 12345.
SELECT pg_advisory_lock([1]);The function pg_advisory_lock takes an integer key to acquire a session-level advisory lock. The key should be a number, not a string.
Complete the code to release the advisory lock with key 12345.
SELECT pg_advisory_unlock([1]);The pg_advisory_unlock function releases the advisory lock identified by the integer key. The key must be a number without quotes.
Fix the error in the code to check if the advisory lock with key 12345 is held by the current session.
SELECT pg_try_advisory_lock([1]);The pg_try_advisory_lock function attempts to acquire the lock and returns true if successful. The key must be an integer without quotes.
Fill both blanks to acquire a transaction-level advisory lock with two 32-bit keys 123 and 456.
SELECT pg_advisory_xact_lock([1], [2]);
The pg_advisory_xact_lock function takes two integer keys to acquire a transaction-level advisory lock. Both keys must be integers without quotes.
Fill all three blanks to check if the advisory lock with keys 789 and 1011 is currently held by any session.
SELECT pg_try_advisory_lock_shared([1], [2]) AS acquired, pg_advisory_unlock_shared([3], [2]);
The functions pg_try_advisory_lock_shared and pg_advisory_unlock_shared use two integer keys to manage shared advisory locks. Keys must be integers without quotes. The first and third blanks use the same key 789.