[ 
https://issues.apache.org/jira/browse/DERBY-6946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16074790#comment-16074790
 ] 

Bryan Pendleton commented on DERBY-6946:
----------------------------------------

I'm confused. Where did you find this code? The code I see in the Derby trunk 
matches the code you refer to as "the fixed code".

Are you looking at this code: 
https://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?revision=1531854&view=markup&pathrev=1531854

Are you running a test which gives different results? Can you share your test? 
Can you run it against the Derby trunk?

> 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)

Reply via email to