Add Execute Immediate prepared statements support to JDBC#19022
Add Execute Immediate prepared statements support to JDBC#19022hashhar merged 1 commit intotrinodb:masterfrom
Conversation
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDriverUri.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDriverUri.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoLegacyPreparedStatements.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoLegacyPreparedStatements.java
Outdated
Show resolved
Hide resolved
c743c83 to
0c768f3
Compare
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDriverUri.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Calling instance methods in a constructor can be dangerous, because the callee is an uninitialized object. Also, taking the hit for every connection may be undesirable. We should consider caching whether this capability is supported by a Trino instance at the class level. Or given the fact that support for EXECUTE IMMEDIATE has been available for a while now, perhaps we skip detection and turn it on by default. @hashhar , @findepi WDYT?
There was a problem hiding this comment.
Since this is a fairly new feature in Trino, we should make this disabled by default. Users can opt-in, and we can make this a default in the future after it is better tested.
I don't think it makes sense to test this behavior, since the entire purpose is to reduce round trips. If the user is on an old version of Trino, they can disable this behavior in the driver.
There was a problem hiding this comment.
Fair enough, code changed accordingly
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoLegacyPreparedStatements.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Since this is a fairly new feature in Trino, we should make this disabled by default. Users can opt-in, and we can make this a default in the future after it is better tested.
I don't think it makes sense to test this behavior, since the entire purpose is to reduce round trips. If the user is on an old version of Trino, they can disable this behavior in the driver.
client/trino-jdbc/src/test/java/io/trino/jdbc/TestTrinoLegacyPreparedStatements.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
0c768f3 to
245cc63
Compare
There was a problem hiding this comment.
cc: @wendigo since you were recently unifying TrinoUri and ConnectionProperties.
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-client/src/main/java/io/trino/client/uri/ConnectionProperties.java
Outdated
Show resolved
Hide resolved
245cc63 to
7f68197
Compare
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcPreparedStatement.java
Outdated
Show resolved
Hide resolved
7f68197 to
f539ffa
Compare
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
f539ffa to
bb7f5ea
Compare
hashhar
left a comment
There was a problem hiding this comment.
mostly looks good, still trying to make sense of testLegacyPreparedStatementsSetting though.
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoPreparedStatement.java
Outdated
Show resolved
Hide resolved
client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcPreparedStatement.java
Outdated
Show resolved
Hide resolved
bb7f5ea to
d1d0c60
Compare
|
@lpoulain please rebase and resolve the conflict. This looks good to go otherwise. |
d1d0c60 to
9089f55
Compare
|
@hashhar rebased. |
Add Execute Immediate prepared statements support to JDBC
9089f55 to
9daca15
Compare
|
@lpoulain are you sending a doc update PR? |
|
@electrum @dain @wendigo @hashhar and myself discussed this a bit more on slack. We need to get this refactored in terms of naming of the property. And maybe also default value. Current suggested names are |
|
@mosabua I can definitely update the doc PR to also modify the name of the property name. But the first step is to have an agreement on what should the new name be. |
Description
Supports the use of
EXECUTE IMMEDIATEwhen executing prepared statements. Adds a new JDBC boolean propertyLegacyPreparedStatementsto control whether this feature should be used or not.Additional context and related issues
By default, prepared statements requires to execute two queries and have the main SQL query passed back and forth between the client and the server three times. Those changes use Trino's recently introduced
EXECUTE IMMEDIATEsyntax which allows to execute a prepared statement with a single query.Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(X) Release notes are required, with the following suggested text: