blob: aa3c86fc664d80a1eb4867fb2b605a9a38ff9124 [file] [log] [blame]
1:drop view if exists concurrent_drop_view cascade;
DROP
1:create view concurrent_drop_view as select * from pg_class;
CREATE
1:select viewname from pg_views where viewname = 'concurrent_drop_view';
viewname
----------------------
concurrent_drop_view
(1 row)
-- One transaction drops the view, and before it commits, another
-- transaction selects its definition from pg_views. The view is still
-- visible to the second transaction, but deparsing the view's
-- definition will block until the first transaction ends. And if the
-- first transaction committed, the definition cannot be fetched.
-- It's returned as NULL in that case. (PostgreSQL throws an ERROR,
-- but getting a spurious ERROR when all you do is query pg_views is
-- not nice.)
1:begin;
BEGIN
1:drop view concurrent_drop_view;
DROP
2&:select viewname, definition from pg_views where viewname = 'concurrent_drop_view'; <waiting ...>
-- wait till halts for AccessShareLock on QD
3: SELECT wait_until_waiting_for_required_lock('concurrent_drop_view', 'AccessShareLock', -1);
wait_until_waiting_for_required_lock
--------------------------------------
t
(1 row)
1:commit;
COMMIT
2<: <... completed>
viewname | definition
----------------------+------------
concurrent_drop_view |
(1 row)