You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by na...@apache.org on 2024/12/22 08:42:23 UTC
(ignite) branch ignite-2.17 updated: IGNITE-24074 Fix createStatement() throws when tx aware queries enabled (#11765)
This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch ignite-2.17
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/ignite-2.17 by this push:
new 34b21f185f8 IGNITE-24074 Fix createStatement() throws when tx aware queries enabled (#11765)
34b21f185f8 is described below
commit 34b21f185f8e5dc04cab9ec93491367997612751
Author: Nikolay <ni...@apache.org>
AuthorDate: Sun Dec 22 10:32:09 2024 +0300
IGNITE-24074 Fix createStatement() throws when tx aware queries enabled (#11765)
(cherry picked from commit e04be8b252c66d87793ba14e6c338f1a01e5e175)
---
.../jdbc/JdbcThinTransactionalSelfTest.java | 22 ++++++++++++++++++++++
.../internal/jdbc/thin/JdbcThinConnection.java | 4 ++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java
index 22fb84ba4fe..d1e17397d6d 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/jdbc/JdbcThinTransactionalSelfTest.java
@@ -23,6 +23,7 @@ import java.sql.DriverManager;
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;
@@ -292,4 +293,25 @@ public class JdbcThinTransactionalSelfTest extends GridCommonAbstractTest {
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()));
+ }
+ }
+ }
+ }
+
+ }
+ }
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
index 0de9affbc1f..033db9ee9df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
@@ -477,12 +477,12 @@ public class JdbcThinConnection implements Connection {
/** {@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} */