pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken Lalonde <kenl@gap.ca>
Cc: pgsql-admin@postgresql.org
Subject: Re: DROP ROLE: how to detect active sessions?
Date: Thu, 21 Oct 2010 14:18:52 -0400
Message-ID: <27773.1287685132@sss.pgh.pa.us> (raw)
In-Reply-To: <61A975CD-61CC-40CF-87CA-46BEEC1CEEAF@gap.ca>
References: <61A975CD-61CC-40CF-87CA-46BEEC1CEEAF@gap.ca>

Ken Lalonde <kenl@gap.ca> writes:
> Is there any way to determine if a given role has any active sessions?

Not if you're using SET ROLE.  pg_stat_activity will show you the
login role names for active sessions.  Do you really need SET ROLE
rather than logging in with the appropriate username?

There are going to be race conditions in any case, of course.
Probably the best solution is to just not try to drop roles
except when the system is idle.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <27773.1287685132@sss.pgh.pa.us>
Permalink:  ../27773.1287685132@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27773.1287685132@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kenl@gap.ca
  Subject: Re: DROP ROLE: how to detect active sessions?
  In-Reply-To: <27773.1287685132@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox