SELECT pg_try_advisory_lock(42)::integer AS gotlock \gset
\if :gotlock
        alter table p detach partition p3 concurrently ;
        alter table p attach partition p3 for values from (2) to (3);
	select nextval('detaches');
	select pg_advisory_unlock(42);
\endif
