Bilal Shaikh
Bilal Shaikh

Reputation: 47

how to know machine name and program name in postgresql?

select secure_decrypt_log_id_seq.nextval,**v.PROGRAM**, 
'CONTRACT_PAYMENT_ID = '||to_Char(:new.CONTRACT_PAYMENT_ID), sysdate, user, **v.MACHINE**, ls_transaction_type
from v$session v
where v.sid =  (select sid from **v$mystat** where rownum = 1)

I am not able to find equivalent functions in PostgreSQL. The above code is of oracle and I cannot find any proper references to Program, Machine & mystat. AWS-SCT cannot find similar functions in Postgres

Upvotes: 1

Views: 636

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246698

You can have the client address: client_addr in pg_stat_activity (or client_hostname if you have enabled log_hostname).

There is no way to access the name of the client executable on the server, as such information is not reliable, but my recommendation is that the client sets the application_name parameter and the server fetches it from pg_stat_activity.

Upvotes: 2

Related Questions