db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r1537881 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Fri, 01 Nov 2013 10:13:45 GMT
Author: dyre
Date: Fri Nov  1 10:13:45 2013
New Revision: 1537881

URL: http://svn.apache.org/r1537881
Log:
DERBY-6228: Add parsing of SQLCARD warnings after next(). Don't commit tx when calling getWarnings().
Fix various locator-release errors when navigating SURs. 

Patch file derby-6228-a.diff. (+ typo fix mentioned in review) 

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LOBStateTracker.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Sqlca.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClientResultSet.java Fri Nov
 1 10:13:45 2013
@@ -139,6 +139,7 @@ public abstract class ClientResultSet im
     // and getter methods cannot be called.
     // Also, if a cursor is exhausted (+100), the cursor position is invalid.
     private boolean isValidCursorPosition_ = false;
+    private boolean savedIsValidCursorPosition_ = false;
 
     public boolean cursorHold_;
 
@@ -378,7 +379,6 @@ public abstract class ClientResultSet im
         // else
         //   fetch the next rowset from the server
         else {
-
             // These flags will only be used for dynamic cursors where we don't know the
row count
             // and can't keep track of the absolute position of the cursor.
             isAfterLast_ = false;
@@ -3802,9 +3802,21 @@ public abstract class ClientResultSet im
                 checkForUpdatableResultSet("moveToInsertRow");
 
                 resetUpdatedColumnsForInsert();
-
+                
+                // Note that even though we navigate "away" from the current row
+                // we do not clean up the current row (i.e. release locators), so
+                // locators will still be valid when returning to the current row.
+                // See DERBY-6228.
                 isOnInsertRow_ = true;
                 isOnCurrentRow_ = false;
+
+                // It is possible to navigate from a row for which 
+                // isValidCursorPosition_==false to the insert row. By
+                // saving the old value here we can restore it when leaving
+                // the insert row. This is important since attempting to 
+                // release locators for a non-valid cursor position will trigger 
+                // an error on the server. See DERBY-6228.
+                savedIsValidCursorPosition_ = isValidCursorPosition_;
                 isValidCursorPosition_ = true;
             }
         }
@@ -3847,7 +3859,8 @@ public abstract class ClientResultSet im
             if (currentRowInRowset_ > 0) {
                 updateColumnInfoFromCache();
             }
-            isValidCursorPosition_ = true;
+            // Restore the old value when leaving the insert row. See DERBY-6228.
+            isValidCursorPosition_ = savedIsValidCursorPosition_;
         }
         if (isValidCursorPosition_) {
             // isOnInsertRow must be false here.
@@ -5450,7 +5463,6 @@ public abstract class ClientResultSet im
     private final int checkRowsetSqlca(int row) throws SqlException {
         int sqlcode = 0;
         if (!isRowsetCursor_ || rowsetSqlca_ == null || rowsetSqlca_[row] == null) {
-            warnings_ = null;    // clear any previous warnings
             return sqlcode;
         }
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LOBStateTracker.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LOBStateTracker.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LOBStateTracker.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LOBStateTracker.java Fri Nov
 1 10:13:45 2013
@@ -104,7 +104,9 @@ class LOBStateTracker {
      */
     void checkCurrentRow(Cursor cursor)
             throws SqlException {
-        if (this.doRelease) {
+        // If we are on a delete hole, there are no locators to release, and 
+        // trying to release them will cause an error. See DERBY-6228.
+        if (this.doRelease && !cursor.getIsUpdateDeleteHole()) {
             CallableLocatorProcedures procs = cursor.getLocatorProcedures();
             for (int i=0; i < this.columns.length; i++) {
                 // Note the conversion from 1-based to 0-based index when

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Sqlca.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Sqlca.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Sqlca.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Sqlca.java Fri Nov  1 10:13:45
2013
@@ -270,7 +270,10 @@ public abstract class Sqlca {
         synchronized (connection_) {
             try {
                 cs = connection_.prepareMessageProc("call SYSIBM.SQLCAMESSAGE(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
-
+                // Cannot let this statement commit the transaction. Otherwise, 
+                // calling getWarnings while navigating a ResultSet will 
+                // release and invalidate locators used by the cursor.
+                cs.isAutoCommittableStatement_ = false;
                 String errmc = null;
                 String sqlState = null;
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java Fri
Nov  1 10:13:45 2013
@@ -126,6 +126,10 @@ class NetResultSetReply extends NetState
                 }
 
                 peekCP = peekCodePoint();
+                if (peekCP == CodePoint.SQLCARD) {
+                    NetSqlca netSqlca = parseSQLCARD(((ClientResultSet) resultSetI).rowsetSqlca_);
+                    resultSetI.completeSqlca(netSqlca);
+                }
                 if (peekCP == CodePoint.RDBUPDRM) {
                     parseRDBUPDRM();
                     peekCP = peekCodePoint();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java
Fri Nov  1 10:13:45 2013
@@ -421,11 +421,12 @@ public class ConcurrencyTest extends SUR
             ps2.executeUpdate();
             con2.commit();
             
-            ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?)");
+            ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?,?)");
             ps2.setInt(1, firstKey);
             ps2.setInt(2, -1);
             ps2.setInt(3, -1);
             ps2.setString(4, "UPDATED TUPLE");
+            ps2.setString(5, "UPDATED CLOB");
             assertEquals("Expected one record to be inserted", 1, 
                          ps2.executeUpdate());
             println("T4: Inserted record (" + firstKey + ",-1,-1)" );
@@ -505,11 +506,12 @@ public class ConcurrencyTest extends SUR
             con2.commit();
             println("T3: commit");
             
-            ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?)");
+            ps2 = con2.prepareStatement("insert into t1 values(?,?,?,?,?)");
             ps2.setInt(1, firstKey);
             ps2.setInt(2, valA);
             ps2.setInt(3, valB);
             ps2.setString(4, "UPDATE TUPLE " + firstKey);
+            ps2.setString(5, "UPDATED CLOB " + firstKey);
             assertEquals("Expected one record to be inserted", 1, 
                          ps2.executeUpdate());
             println("T4: Inserted record (" + firstKey + "," + valA + "," + 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/HoldabilityTest.java
Fri Nov  1 10:13:45 2013
@@ -473,7 +473,7 @@ public class HoldabilityTest extends SUR
         
         // Now reinsert the tuples:
         PreparedStatement ps = 
-            prepareStatement("insert into t1 values (?,?,?,?)");
+            prepareStatement("insert into t1 values (?,?,?,?,?)");
         
         for (int i=0; i<recordCount*2; i++) {
             int recordId = i + recordCount + 1000;
@@ -481,6 +481,7 @@ public class HoldabilityTest extends SUR
             ps.setInt(2, recordId);
             ps.setInt(3, recordId *2 + 17);
             ps.setString(4, "m" + recordId);
+            ps.setString(5, "c"+recordId);
             ps.addBatch();
         }
         ps.executeBatch();
@@ -544,7 +545,7 @@ public class HoldabilityTest extends SUR
         
         // Now reinsert the tuples:
         PreparedStatement ps = 
-            prepareStatement("insert into t1 values (?,?,?,?)");
+            prepareStatement("insert into t1 values (?,?,?,?,?)");
         
         for (int i=0; i<recordCount*2; i++) {
             int recordId = i + recordCount + 1000;
@@ -552,6 +553,7 @@ public class HoldabilityTest extends SUR
             ps.setInt(2, recordId);
             ps.setInt(3, recordId *2 + 17);
             ps.setString(4, "m" + recordId);
+            ps.setString(5, "c" + recordId);
             ps.addBatch();
         }
         ps.executeBatch();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
Fri Nov  1 10:13:45 2013
@@ -66,8 +66,8 @@ abstract public class SURBaseTest extend
         int b = rs.getInt(3);
         int sum = a + id + 17;
         println("Reading tuple:(" + id + "," + a  + "," + b + ",'" + 
-                rs.getString(4) + "')");
-        assertEquals("Expecting b==id+a+17", b, sum);
+                rs.getString(4) + "', '"+rs.getString(5)+"'");
+        assertEquals("Expecting b==id+a+17", sum, b);
     }
     
     /**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java?rev=1537881&r1=1537880&r2=1537881&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
Fri Nov  1 10:13:45 2013
@@ -79,13 +79,14 @@ public class SURDataModelSetup extends B
         
         /** Populate with data */
         PreparedStatement ps = con.
-            prepareStatement("insert into t1 values (?,?,?,?)");
+            prepareStatement("insert into t1 values (?,?,?,?,?)");
         
         for (int i=0; i<records; i++) {
             ps.setInt(1, i);
             ps.setInt(2, i);
             ps.setInt(3, i*2 + 17);
             ps.setString(4, "Tuple " +i);
+            ps.setString(5, "C-tuple "+i);
             ps.addBatch();
         }
         ps.executeBatch();
@@ -204,8 +205,8 @@ public class SURDataModelSetup extends B
          */
         public String getCreateTableStatement() {
             return hasPrimaryKey() 
-                ? "create table t1 (id int primary key, a int, b int, c varchar(5000))"
-                : "create table t1 (id int, a int, b int, c varchar(5000))";
+                ? "create table t1 (id int primary key, a int, b int, c varchar(5000), d
clob)"
+                : "create table t1 (id int, a int, b int, c varchar(5000), d clob)";
         }
 
         /**



Mime
View raw message