Hello list,
Taking this discussion as a base:
http://archives.postgresql.org/pgsql-general/2007-04/msg01034.php
Manuel helped me to develop an audit-trail engine, and even though it works ok, I need to know better its inner workings:
From what I understand, the flow is something like this:
* User sends http request to server to update some record (for example);
* The application server (tomcat) runs the servlet and the servlet gets a connection from the pool
* The servlet runs the "set_session_id(integer)" to set a session for this request and saves the current application user in the lookup table (session_id,user_id)
* The db operation is done (db saved) - the user name is retrieved through a lookup into the table mentioned above by getting this request's session_id by running the "current_session_id" SP
* Each http request gets an instance of a session_id ? Or is it per-connection ?
* Do I really need to call reset_session_id ? Isn't this connection destroyed after it has been used by the application?
* Would it work with an application which does not use a connection pool but a permanent connection (such as desktop apps)?
Thanks in advance!
Marcelo.