I am migrating to Postgresql, but I am facing a problem.
A “trick” I am using with SQL Server is to login always using a single user (tipically sa) and I write the program_name in the database connection to check the number of currently logged users in the application. Everytime I do a db connection for UserX I set the program_name in the connection as “MyApp_UserX”. In this way with a query like the following I can count how many users are connected to my app. I use this for license check, 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 doesn’t allow me in the connection to specify a string like program_name. What can you suggest?
For Delphi users: Note I am using unidac, migrating from SDAC. in SDAC I had TMSConnection.ApplicationName, but there is no a Postgresql equivalent.
You could either wait for 9.0 or make a few assumptions and count (almost all) connections to the database in question.