Skip to content

Commit

Permalink
returning written rows right from response
Browse files Browse the repository at this point in the history
  • Loading branch information
chernser committed Dec 20, 2024
1 parent 11206f1 commit d793e65
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jdbc-v2/src/main/java/com/clickhouse/jdbc/StatementImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,18 @@ public int executeUpdate(String sql, QuerySettings settings) throws SQLException
QuerySettings mergedSettings = QuerySettings.merge(connection.getDefaultQuerySettings(), settings);
mergedSettings.serverSetting(ServerSettings.WAIT_END_OF_QUERY, "1");
lastSql = parseJdbcEscapeSyntax(sql);
int updateCount = 0;
try (QueryResponse response = queryTimeout == 0 ? connection.client.query(lastSql, mergedSettings).get()
: connection.client.query(lastSql, mergedSettings).get(queryTimeout, TimeUnit.SECONDS)) {
currentResultSet = null;
updateCount = (int) response.getWrittenRows();
metrics = response.getMetrics();
lastQueryId = response.getQueryId();
} catch (Exception e) {
throw ExceptionUtils.toSqlState(e);
}

return (int) metrics.getMetric(ServerMetrics.NUM_ROWS_WRITTEN).getLong();
return updateCount;
}

@Override
Expand Down

0 comments on commit d793e65

Please sign in to comment.