I am trying to debug some Java code that is a client of a PostgreSQL database by stepping through the Java code. I have found a query that is being executed by the client code that is not returning the expected results. In order to understand why the code is failing, I'd like to be able to manually run the query (eg, in pgAdmin or from psql command line tool) to see what the contents of the database is.
The problem with the above is that the Java code I'm trying to debug is executing within an uncommitted transaction. When I paste the query into pgAdmin it fails in a completely different way because it doesn't have visibility into the same data snapshot that the code being debugged has.
Is there a way in either pgAdmin or in psql that I can run a query from a perspective inside the transaction? I know that such a thing is typically prohibited (for good reasons relating to transaction isolation), but it would be very useful thing for debugging.
Please note that I am not asking for other ways to debug my situation (eg, by enabling JDBC logging and watching the statements that are logged). I am aware of other ways to do it - but they are all quite a bit less convenient. Hence, I do not believe that this question should be closed as a duplicate of How to enable logging for SQL statements when using JDBC (indeed, I am aware of more convenient options available to me than using JDBC logging to debug my situation even if the answer to my question is "No, it's not possible.")