Skip to content

Commit 33a5678

Browse files
committed
implemented largeMaxRows()
1 parent f6d9cfa commit 33a5678

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class StatementImpl implements Statement, JdbcV2Wrapper {
4141
private String lastStatementSql;
4242
private ParsedStatement parsedStatement;
4343
protected volatile String lastQueryId;
44-
private int maxRows;
44+
private long maxRows;
4545
protected QuerySettings localSettings;
4646

4747
public StatementImpl(ConnectionImpl connection) throws SQLException {
@@ -240,20 +240,12 @@ public void setMaxFieldSize(int max) throws SQLException {
240240
@Override
241241
public int getMaxRows() throws SQLException {
242242
ensureOpen();
243-
return maxRows;
243+
return (int) getLargeMaxRows(); // skip overflow check.
244244
}
245245

246246
@Override
247247
public void setMaxRows(int max) throws SQLException {
248-
ensureOpen();
249-
maxRows = max;
250-
if (max > 0) {
251-
localSettings.setOption(ClientConfigProperties.serverSetting(ServerSettings.MAX_RESULT_ROWS), maxRows);
252-
localSettings.setOption(ClientConfigProperties.serverSetting(ServerSettings.RESULT_OVERFLOW_MODE), "break");
253-
} else {
254-
localSettings.resetOption(ClientConfigProperties.serverSetting(ServerSettings.MAX_RESULT_ROWS));
255-
localSettings.resetOption(ClientConfigProperties.serverSetting(ServerSettings.RESULT_OVERFLOW_MODE));
256-
}
248+
setLargeMaxRows(max);
257249
}
258250

259251
@Override
@@ -509,13 +501,20 @@ public long getLargeUpdateCount() throws SQLException {
509501
@Override
510502
public void setLargeMaxRows(long max) throws SQLException {
511503
ensureOpen();
512-
Statement.super.setLargeMaxRows(max);
504+
maxRows = max;
505+
if (max > 0) {
506+
localSettings.setOption(ClientConfigProperties.serverSetting(ServerSettings.MAX_RESULT_ROWS), maxRows);
507+
localSettings.setOption(ClientConfigProperties.serverSetting(ServerSettings.RESULT_OVERFLOW_MODE), "break");
508+
} else {
509+
localSettings.resetOption(ClientConfigProperties.serverSetting(ServerSettings.MAX_RESULT_ROWS));
510+
localSettings.resetOption(ClientConfigProperties.serverSetting(ServerSettings.RESULT_OVERFLOW_MODE));
511+
}
513512
}
514513

515514
@Override
516515
public long getLargeMaxRows() throws SQLException {
517516
ensureOpen();
518-
return getMaxRows();
517+
return this.maxRows;
519518
}
520519

521520
@Override

0 commit comments

Comments
 (0)