Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-24074 Fix createStatement() throws when tx aware queries enabled #11765

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays;
import java.util.List;
import org.apache.ignite.calcite.CalciteQueryEngineConfiguration;
Expand Down Expand Up @@ -292,4 +293,25 @@ public void testCloseConnectionWithoutCommit() throws Exception {
assertTrue(rs0.isClosed());
assertTrue(rs1.isClosed());
}

/** */
@Test
public void testCreateStatementOnDefaults() throws Exception {
try (Connection conn = DriverManager.getConnection(URL)) {
conn.setAutoCommit(false);

try (Statement stmt = conn.createStatement()) {
try (ResultSet rs = stmt.executeQuery("SELECT 1")) {
assertEquals(1, F.size(grid().context().cache().context().tm().activeTransactions()));

try (Statement stmt2 = conn.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY)) {
try (ResultSet rs2 = stmt.executeQuery("SELECT 1")) {
assertEquals(1, F.size(grid().context().cache().context().tm().activeTransactions()));
}
}
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ void addBatch(String sql, List<Object> args) throws SQLException {

/** {@inheritDoc} */
@Override public Statement createStatement() throws SQLException {
return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT);
return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, holdability);
}

/** {@inheritDoc} */
@Override public Statement createStatement(int resSetType, int resSetConcurrency) throws SQLException {
return createStatement(resSetType, resSetConcurrency, HOLD_CURSORS_OVER_COMMIT);
return createStatement(resSetType, resSetConcurrency, holdability);
}

/** {@inheritDoc} */
Expand Down
Loading