CREATE SCHEMA citus_locks;
SET search_path TO citus_locks;
SET citus.next_shard_id TO 1000;
CREATE TABLE dist_locked_table(id int, data text);
SELECT create_distributed_table('dist_locked_table', 'id');
 create_distributed_table
---------------------------------------------------------------------

(1 row)

BEGIN;
-- Alter a distributed table so that we get some locks
ALTER TABLE dist_locked_table ADD COLUMN new_data_column text;
-- list the locks on relations for current distributed transaction
SELECT relation_name, citus_nodename_for_nodeid(nodeid), citus_nodeport_for_nodeid(nodeid), mode, granted
FROM citus_locks
WHERE global_pid = citus_backend_gpid() AND locktype = 'relation' AND relation_name LIKE '%dist_locked_table%'
ORDER BY 1, 2, 3, 4;
           relation_name            | citus_nodename_for_nodeid | citus_nodeport_for_nodeid |        mode         | granted
---------------------------------------------------------------------
 citus_locks.dist_locked_table      | localhost                 |                     57636 | AccessExclusiveLock | t
 citus_locks.dist_locked_table      | localhost                 |                     57636 | AccessShareLock     | t
 citus_locks.dist_locked_table      | localhost                 |                     57637 | AccessExclusiveLock | t
 citus_locks.dist_locked_table      | localhost                 |                     57637 | AccessShareLock     | t
 citus_locks.dist_locked_table      | localhost                 |                     57638 | AccessExclusiveLock | t
 citus_locks.dist_locked_table      | localhost                 |                     57638 | AccessShareLock     | t
 citus_locks.dist_locked_table_1000 | localhost                 |                     57637 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1000 | localhost                 |                     57637 | AccessShareLock     | t
 citus_locks.dist_locked_table_1000 | localhost                 |                     57638 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1000 | localhost                 |                     57638 | AccessShareLock     | t
 citus_locks.dist_locked_table_1001 | localhost                 |                     57637 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1001 | localhost                 |                     57637 | AccessShareLock     | t
 citus_locks.dist_locked_table_1001 | localhost                 |                     57638 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1001 | localhost                 |                     57638 | AccessShareLock     | t
 citus_locks.dist_locked_table_1002 | localhost                 |                     57637 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1002 | localhost                 |                     57637 | AccessShareLock     | t
 citus_locks.dist_locked_table_1002 | localhost                 |                     57638 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1002 | localhost                 |                     57638 | AccessShareLock     | t
 citus_locks.dist_locked_table_1003 | localhost                 |                     57637 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1003 | localhost                 |                     57637 | AccessShareLock     | t
 citus_locks.dist_locked_table_1003 | localhost                 |                     57638 | AccessExclusiveLock | t
 citus_locks.dist_locked_table_1003 | localhost                 |                     57638 | AccessShareLock     | t
(22 rows)

ROLLBACK;
DROP SCHEMA citus_locks CASCADE;
NOTICE:  drop cascades to table dist_locked_table
