Retrieve username inside a trigger function
问题 In our database we have a login table featuring coloumns username and password . How can this username be retrieved inside a trigger function so that it can also be audited. user keyword inside the trigger function retrieves the postgresql username, what I need is the application username. Any suggestions? 回答1: You can set a custom GUC up in postgresql.conf . Use it to store the application username at login using SET myapp_username . Access that in triggers with current_setting(myapp