DROP ROLE: how to detect active sessions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I need to track db activity by role.   All web-related connections to the db use the same user name.
When a user logs in via the web, the application code runs:
	SET ROLE "n"
where n is the ID value for the user in the "users" table.
(These numeric roles are created dynamically as needed).
We can then use the value of "current_user" to track activity.

So far so good.

The problem happens when we periodically drop roles for inactive users.
If I run DROP ROLE "n", and there happens to be an active session for that role,
we have a problem: in that session, "select current_user" fails with "invalid role OID: nnnn".

Is there any way to determine if a given role has any active sessions?

Thanks a bunch,

Ken Lalonde
Gap Adventures, Toronto
-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux