提交 2c705386 authored 作者: Thomas Mueller's avatar Thomas Mueller

ResultSet.setFetchSize is now supported.

上级 effa19c7
......@@ -2437,7 +2437,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
try {
debugCodeCall("getFetchSize");
checkClosed();
return 0;
return result.getFetchSize();
} catch (Exception e) {
throw logAndConvert(e);
}
......@@ -2446,25 +2446,30 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
/**
* Sets the number of rows suggested to read in one step. This value cannot
* be higher than the maximum rows (setMaxRows) set by the statement or
* prepared statement, otherwise an exception is throws.
* prepared statement, otherwise an exception is throws. Setting the value
* to 0 will set the default value. The default value can be changed using
* the system property h2.serverResultSetFetchSize.
*
* @param rowCount the number of rows
* @param rows the number of rows
*/
public void setFetchSize(int rowCount) throws SQLException {
public void setFetchSize(int rows) throws SQLException {
try {
debugCodeCall("setFetchSize", rowCount);
debugCodeCall("setFetchSize", rows);
checkClosed();
if (rowCount < 0) {
throw Message.getInvalidValueException("" + rowCount, "rowCount");
}
if (rowCount > 0) {
if (rows < 0) {
throw Message.getInvalidValueException("" + rows, "rows");
} else if (rows > 0) {
if (stat != null) {
int maxRows = stat.getMaxRows();
if (maxRows > 0 && rowCount > maxRows) {
throw Message.getInvalidValueException("" + rowCount, "rowCount");
if (maxRows > 0 && rows > maxRows) {
throw Message.getInvalidValueException("" + rows, "rows");
}
}
} else {
rows = SysProperties.SERVER_RESULT_SET_FETCH_SIZE;
}
result.setFetchSize(rows);
} catch (Exception e) {
throw logAndConvert(e);
}
......
......@@ -470,4 +470,12 @@ public class LocalResult implements ResultInterface {
return closed;
}
public int getFetchSize() {
return 0;
}
public void setFetchSize(int fetchSize) {
// ignore
}
}
......@@ -143,5 +143,19 @@ public interface ResultInterface {
* @return Column.NULLABLE_*
*/
int getNullable(int i);
/**
* Set the fetch size for this result set.
*
* @param fetchSize the new fetch size
*/
void setFetchSize(int fetchSize);
/**
* Get the current fetch size for this result set.
*
* @return the fetch size
*/
int getFetchSize();
}
......@@ -24,7 +24,7 @@ import org.h2.value.Value;
*/
public class ResultRemote implements ResultInterface {
private final int fetchSize;
private int fetchSize;
private SessionRemote session;
private Transfer transfer;
private int id;
......@@ -241,4 +241,12 @@ public class ResultRemote implements ResultInterface {
return "columns: " + columns.length + " rows: " + rowCount + " pos: " + rowId;
}
public int getFetchSize() {
return fetchSize;
}
public void setFetchSize(int fetchSize) {
this.fetchSize = fetchSize;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论