2
Copyright 2009 Canonical Ltd. This software is licensed under the
3
GNU Affero General Public License version 3 (see the file LICENSE).
5
Stored procedures designed for use only by the test suite. These
6
will not be loaded onto the production database
9
CREATE OR REPLACE FUNCTION _killall_backends(text)
12
from signal import SIGTERM
15
"SELECT procpid FROM pg_stat_activity WHERE datname=$1", ['text']
18
for row in plpy.execute(plan, args):
20
plpy.info("Killing %d" % row['procpid'])
21
os.kill(row['procpid'], SIGTERM)
26
$$ LANGUAGE plpythonu;
28
COMMENT ON FUNCTION _killall_backends(text) IS 'Kill all backend processes connected to the given database. Note that this is unlikely to work if you are connected to the database you are killing, as you are likely to kill your own connection before all the others have been killed.';