Skip to content

Commit 9e532cf

Browse files
committed
reset update count
1 parent 2790aeb commit 9e532cf

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ public void setObject(int parameterIndex, Object x) throws SQLException {
293293
@Override
294294
public boolean execute() throws SQLException {
295295
ensureOpen();
296+
currentUpdateCount = -1;
296297
if (parsedPreparedStatement.isHasResultSet()) {
297298
currentResultSet = super.executeQueryImpl(buildSQL(), localSettings);
298299
return currentResultSet != null;

jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ public boolean execute(String sql) throws SQLException {
364364
ensureOpen();
365365
parsedStatement = connection.getSqlParser().parsedStatement(sql);
366366
currentUpdateCount = -1;
367-
currentResultSet = null;
368367
if (parsedStatement.isHasResultSet()) {
369368
currentResultSet = executeQueryImpl(sql, localSettings);
370369
return currentResultSet != null;

jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ void testDateWithAndWithoutCalendar() throws Exception {
17871787
}
17881788

17891789
@Test(groups = {"integration"})
1790-
public void testUnknownStatementTest() throws Exception {
1790+
public void testUnknownStatement() throws Exception {
17911791
try (Connection conn = getJdbcConnection()) {
17921792
try (PreparedStatement stmt = conn.prepareStatement("SELECT number, FROM system.numbers LIMIT 3")) {
17931793
Assert.assertTrue(stmt.execute());
@@ -1815,7 +1815,7 @@ public void testUnknownStatementTest() throws Exception {
18151815
String tmpTable = "tmp_no_result_" + RandomStringUtils.randomAlphanumeric(8);
18161816
// PreparedStatement: execute() should return false, executeQuery() should throw
18171817
try (PreparedStatement stmt = conn.prepareStatement(
1818-
"CREATE TEMPORARY TABLE " + tmpTable + " (x Int32)")) {
1818+
"CREATE TABLE " + tmpTable + " (x Int32) Engine MergeTree ORDER BY()")) {
18191819
Assert.assertFalse(stmt.execute(), "DDL should not produce a ResultSet");
18201820
Assert.assertNull(stmt.getResultSet(), "ResultSet should be null for DDL");
18211821
assertThrows(SQLException.class, stmt::executeQuery);
@@ -1824,11 +1824,11 @@ public void testUnknownStatementTest() throws Exception {
18241824
String tmpTable2 = "tmp_no_result_" + RandomStringUtils.randomAlphanumeric(8);
18251825
try (Statement stmt = conn.createStatement()) {
18261826
Assert.assertFalse(
1827-
stmt.execute("CREATE TEMPORARY TABLE " + tmpTable2 + " (x Int32)"),
1827+
stmt.execute("CREATE TABLE " + tmpTable2 + " (x Int32) Engine MergeTree ORDER BY()"),
18281828
"DDL should not produce a ResultSet");
18291829
Assert.assertNull(stmt.getResultSet(), "ResultSet should be null for DDL");
18301830
assertThrows(SQLException.class,
1831-
() -> stmt.executeQuery("CREATE TEMPORARY TABLE " + tmpTable2 + " (x Int32)"));
1831+
() -> stmt.executeQuery("CREATE TABLE " + tmpTable2 + " (x Int32) Engine MergeTree ORDER BY()"));
18321832
}
18331833
}
18341834
}

jdbc-v2/src/test/java/com/clickhouse/jdbc/StatementTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ public void testDescribeStatement() throws Exception {
13231323
}
13241324

13251325
@Test(groups = {"integration"}, dataProvider = "testUnknownStatementTest_DP")
1326-
public void testUnknownStatementTest(String parserName) throws Exception {
1326+
public void testUnknownStatement(String parserName) throws Exception {
13271327
Properties properties = new Properties();
13281328
properties.setProperty(DriverProperties.SQL_PARSER.getKey(), parserName);
13291329
try (Connection conn = getJdbcConnection(properties)) {

0 commit comments

Comments
 (0)