Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-6946

Argument checking for EmbedResultSet_setFetchSize(int) may be incorrect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 10.12.1.1
    • None
    • JDBC
    • None

    Description

      The EmbedResultSet_setFetchSize method has the following code to check its argument:

      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;
      	}
      

      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:

      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;
      		}
      	}
      

      The fixed code is:

      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;
      		}
      	}
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            haozhong Hao Zhong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: