marklogic-community / ml-jdbc-driver

Making JDBC connections to MarkLogic SQL/ODBC Server
Other
2 stars 4 forks source link

PgConnection.setReadOnly() throws exception whenever you interact with it #2

Closed awal11 closed 5 years ago

awal11 commented 5 years ago

I am trying to use the driver together with PrestoDB. I encountered few issues, this would be the one of them.

Presto sets the JDBC driver to read only mode and this triggers an exception

org.postgresql.util.PSQLException: A result was returned when none was expected.
    at org.postgresql.jdbc.PgConnection.execSQLUpdate(PgConnection.java:440)
    at org.postgresql.jdbc.PgConnection.setReadOnly(PgConnection.java:699)
    at Main.main(Main.java:11)

no matter what I do

  1. without any prior configuration of the connection URL, just by invoking conn.setReadOnly(true);
  2. adding readonly=true suggested in Readme.md does nothing because it is case sensitive and should be readOnly=true
  3. if I add proper readOnly=true to the connection url - it throws exception directly from this line DriverManager.getConnection("jdbc:marklogic://localhost:8077/?readOnly=true","user","pw") as the PG driver was not adopted properly

AFAIK the driver will be always read only so my suggestion is to

  1. get rid of all the code related to handling readOnly
  2. fix the readme to indicate it more clearly

Would you accept a pull request to implement it?

bobstarbird commented 5 years ago

It looks like there is a difference between how "SET application_name =" and "SET SESSION CHARACTERISTICS AS TRANSACTION" are handled internally. PgConnection execSQLUpdate executeWithFlags checks the results and produces the error because there is a result. The setTransactionIsolation suffers from the same. The solution is not clear to me. Ignoring the boolean is one option.

awal11 commented 5 years ago

The invocation of setReadOnly is done by presto, beyond my control, so I think if we want to have the driver usable - we should not throw exceptions here. I am not familiar enough with the driver to come up with better ideas than ignoring the attempt to change the setting. Btw-I mixed up pull requests for issue 1 and 2, i can redo 2 with separate branch etc, next week. On Tue, 5 Feb 2019 at 01:58, bobstarbird notifications@github.com wrote:

It looks like there is a difference between how "SET application_name =" and "SET SESSION CHARACTERISTICS AS TRANSACTION" are handled internally. PgConnection execSQLUpdate executeWithFlags checks the results and produces the error because there is a result. The setTransactionIsolation suffers from the same. The solution is not clear to me. Ignoring the boolean is one option.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/marklogic-community/ml-jdbc-driver/issues/2#issuecomment-460474268, or mute the thread https://github.com/notifications/unsubscribe-auth/AGQQxPrGFFPNwZ1qPgs_xdm-QB418IvMks5vKNc5gaJpZM4Z3ci2 .