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
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;
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 postmasterselect count(*) from foo;count-----10 (1 row)