You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When debugging, it is important to easily understand the queries we are dealing with. When needed, getting at their parameters should also be relatively easy.
Similarly, custom loggers should be able to get such basic information without too much hassle.
Currently, it is quite hard to get that information from pgjdbc because it involves a lot of reflection, breaks at every upgrade of the library, and getting certain fields is definitely not easy.
Thus, I suggest the following:
PgPreparedStatement should be public so we can easily cast a PreparedStatement.
The default toString() of PgPreparedStatement and PgCallableStatement should be the raw SQL statement that was used to construct the statement (meaning with '?' for bind parameters).
Before any addBatch(), possibility to get all parameters. This should be done with methods like getParameterCount(), getSqlParameterTypes(), getPgParameterTypes(), getParameterValues() (using null or "?" if not bound, Sql Parameter Type allowing to differentiate).
A bit of background: all our stack goes through methods for statements to execute, add batch, execute batch. We can activate logging and get a lot of information (stacktrace of every call, time to execute, etc.) and with Postgres we are blind: it is not easy to get basic information about the statements. Moreover, when we debug in our IDE we get similar issues.
The text was updated successfully, but these errors were encountered:
There's org.postgresql.PGStatement interface for public API
So, toString() should be defined in this class, with Javadoc specifying what it produces.
I guess we should create org.postgresql.PGPreparedStatement for type-related methods, don't you think?
We would also need org.postgresql.PGCallableStatement, but should it inherit org.postgresql.PGPreparedStatement or just replicate the type-related method definitions?
When debugging, it is important to easily understand the queries we are dealing with. When needed, getting at their parameters should also be relatively easy.
Similarly, custom loggers should be able to get such basic information without too much hassle.
Currently, it is quite hard to get that information from pgjdbc because it involves a lot of reflection, breaks at every upgrade of the library, and getting certain fields is definitely not easy.
Thus, I suggest the following:
PgPreparedStatement
should be public so we can easily cast aPreparedStatement
.toString()
ofPgPreparedStatement
andPgCallableStatement
should be the raw SQL statement that was used to construct the statement (meaning with '?' for bind parameters).addBatch()
, possibility to get all parameters. This should be done with methods likegetParameterCount()
,getSqlParameterTypes()
,getPgParameterTypes()
,getParameterValues()
(usingnull
or"?"
if not bound, Sql Parameter Type allowing to differentiate).A bit of background: all our stack goes through methods for statements to execute, add batch, execute batch. We can activate logging and get a lot of information (stacktrace of every call, time to execute, etc.) and with Postgres we are blind: it is not easy to get basic information about the statements. Moreover, when we debug in our IDE we get similar issues.
The text was updated successfully, but these errors were encountered: