2016-01-12 13:08:43 +01:00
|
|
|
#!/usr/bin/env bash
|
2015-09-28 19:45:35 +02:00
|
|
|
set -e
|
|
|
|
|
|
|
|
cd /
|
|
|
|
|
2019-01-16 04:32:27 +01:00
|
|
|
tables="$(printf "'%s'," "${@//\'/\'\'}")"
|
|
|
|
tables="${tables%,}"
|
2015-09-28 19:45:35 +02:00
|
|
|
|
2020-06-16 01:36:02 +02:00
|
|
|
psql postgres -v ON_ERROR_STOP=1 <<EOF
|
2019-04-23 23:41:42 +02:00
|
|
|
SELECT pg_terminate_backend(s.pid)
|
|
|
|
FROM pg_stat_activity s, pg_roles r
|
|
|
|
WHERE
|
|
|
|
s.datname IN ($tables)
|
|
|
|
AND r.rolname = CURRENT_USER
|
2020-02-26 08:34:57 +01:00
|
|
|
AND (s.usename = r.rolname OR r.rolsuper = 't')
|
|
|
|
AND s.pid <> pg_backend_pid();
|
2015-09-28 19:45:35 +02:00
|
|
|
EOF
|