Hao Zhong created DERBY-6946:
--------------------------------

             Summary: 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 identical, and 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