db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Korneliussen (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-1251) cancelRowUpdates() affects rows updated with updateRow() in scrollable updatable resultsets
Date Tue, 25 Apr 2006 09:34:06 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1251?page=comments#action_12376218 ] 

Andreas Korneliussen commented on DERBY-1251:
---------------------------------------------

The bug was detected while adding the following testcase in SURTest:
    /**
     * Test that you can correctly run multiple updateXXX() + updateRow() 
     * combined with cancelRowUpdates().
     */
    public void testMultiUpdateRow1() 
        throws SQLException 
    {
        Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                          ResultSet.CONCUR_UPDATABLE);
        s.setCursorName(getNextCursorName());
        ResultSet rs = s.executeQuery("select * from t1");
        rs.absolute(5);
        final int oldCol2 = rs.getInt(2);
        final int newCol2 = -2222;
        final int oldCol3 = rs.getInt(3);
        final int newCol3 = -3333;
                
        rs.updateInt(2, newCol2);
        assertEquals("Expected the resultset to be updated after updateInt", 
                     newCol2, rs.getInt(2));
        rs.cancelRowUpdates();
        assertEquals("Expected updateXXX to have no effect after cancelRowUpdated", 
                     oldCol2, rs.getInt(2));
        rs.updateInt(2, newCol2);
        assertEquals("Expected the resultset to be updated after updateInt", 
                     newCol2, rs.getInt(2));
        assertTrue("Expected rs.rowUpdated() to be false before updateRow", 
                   !rs.rowUpdated());
        rs.updateRow();
        
        assertTrue("Expected rs.rowUpdated() to be true after updateRow", 
                   rs.rowUpdated());
==== FAILS HERE ======
        assertEquals("Expected the resultset detect the updates of previous " + 
                     "updateRow", newCol2, rs.getInt(2));
====================       
        rs.updateInt(3, newCol3);
        
        assertEquals("Expected the resultset to be updated after updateInt", 
                     newCol3, rs.getInt(3));
        assertEquals("Expected the resultset detect the updates of previous " + 
                     "updateRow", newCol2, rs.getInt(2));
        
        rs.cancelRowUpdates();
        
        assertEquals("Expected updateXXX to have no effect after " +
                     "cancelRowUpdated", oldCol3, rs.getInt(3));
        assertEquals("Expected the resultset detect the updates of previous " +
                     "updateRow after cancelRowUpdated", newCol2, rs.getInt(2));
        rs.updateInt(3, newCol3);
        rs.updateRow();
        assertEquals("Expected the resultset to be updated after updateInt", 
                     newCol3, rs.getInt(3));
        rs.cancelRowUpdates();
        
        assertEquals("Expected the resultset detect the updates of previous" + 
                     "updateRow after cancelRowUpdates", newCol2, rs.getInt(2));
        assertEquals("Expected the resultset detect the updates of previous" + 
                     "updateRow after cacnelRowUpdates", newCol2, rs.getInt(2));
        assertTrue("Expected rs.rowUpdated() to be true after " + 
                   "updateRow and cancelRowUpdates", rs.rowUpdated());
        
        rs.close();
    }

The test fails with:
1) testMultiUpdateRow1(org.apache.derbyTesting.functionTests.tests.jdbcapi.SURTest)junit.framework.AssertionFailedError:
Expected the resultset detect the updates of previous updateRow expected:<-2222> but
was:<4>
        at org.apache.derbyTesting.functionTests.tests.jdbcapi.SURTest.testMultiUpdateRow1(SURTest.java:203)
...


> cancelRowUpdates() affects rows updated with updateRow() in scrollable updatable resultsets
> -------------------------------------------------------------------------------------------
>
>          Key: DERBY-1251
>          URL: http://issues.apache.org/jira/browse/DERBY-1251
>      Project: Derby
>         Type: Bug

>   Components: JDBC, Network Client
>     Versions: 10.2.0.0
>     Reporter: Andreas Korneliussen
>     Assignee: Andreas Korneliussen
>     Priority: Minor

>
> If an application does the following:
> rs.updateInt(1, newValueCol1);
> rs.updateRow();
> rs.updateInt(2, newValueCol2);
> rs.cancelRowUpdates();
> Then, when calling rs.getInt(1), it will return the old value. Instead it should return
the new value.
> Workaround: after calling rs.updateRow(), the application could call rs.relative(0).
> This problem does not affect forward only resultsets, since after an updateRow() they
get positoned before the next row, leaving it impossible to do anything with the current row.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message