Contents

The Postgres functions used for logging transactions can only track server-side actions and parameters, not client-side ones. E.g. if multiple users work against the database by using one database role would be referenced to this role. Sure, there is the client_name field (IP) in transaction_log, but if all users are using the same remote client you cannot make distictions on the client IP. In order to log information specific to each database interaction pgMemento provides a JSONB field in the transaction_log table. Everything a client connection needs to do is to set a local configuration parameter, named pgmemento.session_info:

sql SELECT set_config( 'pgmemento.session_info', '{"client_user":"fxku", "message":"Added new category to table"}'::text, FALSE );

Note: The value of session_info should be valid JSON to later query the session_info column with JSONB operators. Otherwise, the text is converted with to_jsonb which might not produce valid JSON.

The configuration parameter lives as long as the session lasts. If you want it to last only during a single transaction change the last argument to TRUE.