\c show_open_tables_b
set search_path to show_open_tables_scm;
set role user1 password 'Show@123';
-- 1 and 1+ locks waiting on table
select pg_sleep(2);
pg_sleep
----------
(1 row)
lock tables show_open_tables_test_1 write;
SHOW OPEN TABLES IN show_open_tables_scm;
Database | Table | In_use | Name_locked
----------------------+-------------------------+--------+-------------
show_open_tables_scm | show_open_tables_test_1 | 1 | 1
show_open_tables_scm | show_open_tables_test_2 | 0 | 0
(2 rows)
unlock tables;
SHOW OPEN TABLES IN show_open_tables_scm;
Database | Table | In_use | Name_locked
----------------------+-------------------------+--------+-------------
show_open_tables_scm | show_open_tables_test_1 | 0 | 0
show_open_tables_scm | show_open_tables_test_2 | 0 | 0
(2 rows)
select pg_sleep(2);
pg_sleep
----------
(1 row)
begin;
lock table show_open_tables_test_1 in EXCLUSIVE mode;
SHOW OPEN TABLES IN show_open_tables_scm;
Database | Table | In_use | Name_locked
----------------------+-------------------------+--------+-------------
show_open_tables_scm | show_open_tables_test_1 | 1 | 0
show_open_tables_scm | show_open_tables_test_2 | 0 | 0
(2 rows)
commit;
SHOW OPEN TABLES IN show_open_tables_scm;
Database | Table | In_use | Name_locked
----------------------+-------------------------+--------+-------------
show_open_tables_scm | show_open_tables_test_1 | 0 | 0
show_open_tables_scm | show_open_tables_test_2 | 0 | 0
(2 rows)