Postgresql SQL Server equivalent sysprocesses loginname and program_name

I am moving on to Postgresql, but you are facing a problem.

The “trick” I use with SQL Server is always using a single user (typically sa), and I write program_name in connection with the database to check the number of currently registered users in the application. Each time I connect db for UserX, I set the computer_name in the connection as "MyApp_UserX". Thus, using the following query, I can calculate how many users are connected to my application. I use this to check the license and it is very reliable in sql server.

select count(sp.loginame) as CNT 
from Master.dbo.sysprocesses sp
join Master.dbo.sysdatabases sd on sp.dbid = sd.dbid
where sd.name = MYDATABASE and sp.program_name like 'MyApp%'

Now Postgresql does not allow me to specify a string of type program_name in communication. What can you offer?

For Delphi users: Note. I am using unidac, moving from SDAC. in SDAC I had TMSConnection.ApplicationName but no Postgresql equivalent.

+3
source share
2 answers

You can either wait for 9.0 , or make a few assumptions and calculate (almost all) the connections to the corresponding database.

+3
source

, IP-, pg_stat_activity. , , IP- . , ( 9.0), .

http://www.postgresql.org/docs/current/static/monitoring-stats.html

+1

Source: https://habr.com/ru/post/1752836/


All Articles