class PgConn::SessionMethods

def pids(database, users)

Like #list but returns the PIDs of the users
def pids(database, users)
  users ||= list(database)
  if !users.empty?
    users_sql = "(" + users.map { |user| "'#{user}'" }.join(", ") + ")"
    conn.values "select pid from pg_stat_activity where datname = '#{database}' and usename in #{users_sql}"
  else
    conn.values "select pid from pg_stat_activity where datname = '#{database}'"
  end
end