Track the SQL history inside a SQL transaction in PostgreSQL and dump it to the log on request