pg_terminate_backend.out 936 字节
Newer Older
1 2 3 4 5 6 7
create table foo as select i a, i b from generate_series(1, 10) i;
CREATE 10

-- expect this query terminated by 'test pg_terminate_backend'
1&:create temp table t as select count(*) from foo where pg_sleep(20) is null;  <waiting ...>

-- extract the pid for the previous query
8
SELECT pg_terminate_backend(procpid,'test pg_terminate_backend') FROM pg_stat_activity WHERE current_query like 'create temp table t as select%' ORDER BY procpid LIMIT 1;
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
pg_terminate_backend
--------------------
t                   
(1 row)

-- EXPECT: session 1 terminated with 'test pg_terminate_backend'
1<:  <... completed>
FATAL:  terminating connection due to administrator command: "test pg_terminate_backend"
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

-- query backend to ensure no PANIC on postmaster
select count(*) from foo;
count
-----
10   
(1 row)