[
https://issues.apache.org/jira/browse/DERBY-6946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16075697#comment-16075697
]
Hao Zhong commented on DERBY-6946:
----------------------------------
It turns out that my repository is out of date. I will update my repository.
> Argument checking for EmbedResultSet_setFetchSize(int) may be incorrect
> -----------------------------------------------------------------------
>
> Key: DERBY-6946
> URL: https://issues.apache.org/jira/browse/DERBY-6946
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.12.1.1
> Reporter: Hao Zhong
>
> The EmbedResultSet_setFetchSize method has the following code to check its
> argument:
> {code}
> public void setFetchSize(int rows) throws SQLException {
> checkStatus();
> if (rows < 0 || (this.getMaxRows() != 0 &&
> rows > this.getMaxRows()))
> {
> throw newSQLException(SQLState.INVALID_ST_FETCH_SIZE, rows);
> }else if ( rows > 0 ) // ignore the call if the value is zero
> fetchSize = rows;
> }
> {code}
> The check seems to be incorrect. DERBY-3573 fixed a similar problem, and
> explained why the check is incorrect. The buggy code is as follow:
> {code}
> public void setFetchSize(int rows) throws SQLException {
> checkIfClosed("setFetchSize");
> if (rows < 0 || (stmt.getMaxRows() != 0 && rows >
> stmt.getMaxRows())) {
> throw
> Util.generateCsSQLException(SQLState.INVALID_FETCH_SIZE,
> new Integer(rows));
> } else if (rows > 0) // if it is zero ignore the call
> {
> fetchSize = rows;
> }
> }
> {code}
> The fixed code is:
> {code}
> public void setFetchSize(int rows) throws SQLException {
> checkIfClosed("setFetchSize");
> if (rows < 0) {
> throw
> Util.generateCsSQLException(SQLState.INVALID_FETCH_SIZE,
> new Integer(rows));
> } else if (rows > 0) // if it is zero ignore the call
> {
> fetchSize = rows;
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)