db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r545910 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/CallableLocatorProcedures.java engine/org/apache/derby/loc/messages.xml testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
Date Sun, 10 Jun 2007 17:14:50 GMT
Author: kahatlen
Date: Sun Jun 10 10:14:48 2007
New Revision: 545910

URL: http://svn.apache.org/viewvc?view=rev&rev=545910
Log:
DERBY-2770: testBlobAfterCommit(....jdbcapi.BlobClob4BlobTest) fails
with 'Unexpected SQL state. expected:<XJ[073]> but was:<XJ[215]>'

Changed error message to reflect that XJ215 is used both after free()
has been called on a Lob and after the lob's transaction has been
committed.

Changed SQL state when locators are invalid from XJ073 to XJ215 on the
client driver.

Patch contributed by Øystein Grøvlen.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableLocatorProcedures.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableLocatorProcedures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableLocatorProcedures.java?view=diff&rev=545910&r1=545909&r2=545910
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableLocatorProcedures.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableLocatorProcedures.java
Sun Jun 10 10:14:48 2007
@@ -1047,30 +1047,29 @@
      * If the given exception indicates that locator was not valid, we
      * assume the locator has been garbage-collected due to
      * transaction commit, and wrap the exception in an exception with
-     * SQL state <code>BLOB_ACCESSED_AFTER_COMMIT</code>.
+     * SQL state <code>LOB_OBJECT_INVALID</code>.
      * @param sqle Exception to be checked
      * @return If <code>sqle</code> indicates that locator was
      *         invalid, an <code>SqlException</code> with SQL state
-     *         <code>BLOB_ACCESSED_AFTER_COMMIT</code>. Otherwise, the
+     *         <code>LOB_OBJECT_INVALID</code>. Otherwise, the
      *         incoming exception is returned.
      */
     private SqlException handleInvalidLocator(SqlException sqle)
     {
-        if ((sqle.getMessage().indexOf(ExceptionUtil
-                .getSQLStateFromIdentifier(SQLState.LOB_LOCATOR_INVALID)) >= 0)
-            // With Java 6, the reason for the failure of the
-            // procedure call is not reported, just
-            // LANG_UNEXPECTED_USER_EXCEPTION (see DERBY-1629).
-            // Until this is fixed, treat all such errors as INVALID_LOCATOR
-            || (sqle.getSQLState().compareTo
+        SqlException ex = sqle;
+        while (ex != null) {
+            if (ex.getSQLState().compareTo
                 (ExceptionUtil.getSQLStateFromIdentifier
-                 (SQLState.LANG_UNEXPECTED_USER_EXCEPTION)) == 0)) {
-            return new SqlException(connection.agent_.logWriter_,
-                    new ClientMessageId(SQLState.BLOB_ACCESSED_AFTER_COMMIT),
-                    null,
-                    sqle);
-        } else {
-            return sqle;
+                 (SQLState.LOB_LOCATOR_INVALID)) == 0) {
+                return new SqlException(connection.agent_.logWriter_,
+                               new ClientMessageId(SQLState.LOB_OBJECT_INVALID),
+                               null,
+                               sqle);
+            }
+            ex = ex.getNextException();
         }
+
+        // LOB_LOCATOR_INVALID not found, return original exception
+        return sqle;
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?view=diff&rev=545910&r1=545909&r2=545910
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Sun Jun 10 10:14:48
2007
@@ -4497,7 +4497,7 @@
 
             <msg>
                 <name>XJ215.S</name>
-                <text>You cannot invoke other java.sql.Clob/java.sql.Blob methods after
calling the free() method.</text>
+                <text>You cannot invoke other java.sql.Clob/java.sql.Blob methods after
calling the free() method or after the Blob/Clob's transaction has been committed or rolled
back.</text>
             </msg>
 	    
 	    <msg>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java?view=diff&rev=545910&r1=545909&r2=545910
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/BlobClob4BlobTest.java
Sun Jun 10 10:14:48 2007
@@ -1259,7 +1259,7 @@
             //The same SQLState String BLOB_ACCESSED_AFTER_COMMIT
             //is used for LOB's(Both Clob and Blob). Ensure that
             //we get the expected exception by comparing the SQLState.
-            checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            checkException(INVALID_LOB, e);
             //In the embedded clobs of small size are
             //accessible after commit. Hence ensure that
             //we are dealing with the Embedded side here.
@@ -1278,7 +1278,11 @@
             //The same SQLState String BLOB_ACCESSED_AFTER_COMMIT
             //is used for LOB's(Both Clob and Blob). Ensure that
             //we get the expected exception by comparing the SQLState.
-            checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            if (usingEmbedded()) {
+                checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            } else {
+                checkException(INVALID_LOB, e);
+            }
         }
         try {
             clob.getSubString(2,3);
@@ -1290,7 +1294,11 @@
             //The same SQLState String BLOB_ACCESSED_AFTER_COMMIT
             //is used for LOB's(Both Clob and Blob). Ensure that
             //we get the expected exception by comparing the SQLState.
-            checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            if (usingEmbedded()) {
+                checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            } else {
+                checkException(INVALID_LOB, e);
+            }
         }
         try {
             clob.getAsciiStream();
@@ -1302,7 +1310,11 @@
             //The same SQLState String BLOB_ACCESSED_AFTER_COMMIT
             //is used for LOB's(Both Clob and Blob). Ensure that
             //we get the expected exception by comparing the SQLState.
-            checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            if (usingEmbedded()) {
+                checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            } else {
+                checkException(INVALID_LOB, e);
+            }
         }
         try {
             clob.position("foo",2);
@@ -1314,7 +1326,11 @@
             //The same SQLState String BLOB_ACCESSED_AFTER_COMMIT
             //is used for LOB's(Both Clob and Blob). Ensure that
             //we get the expected exception by comparing the SQLState.
-            checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            if (usingEmbedded()) {
+                checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            } else {
+                checkException(INVALID_LOB, e);
+            }
         }
         try {
             clob.position(clob,2);
@@ -1326,7 +1342,11 @@
             //The same SQLState String BLOB_ACCESSED_AFTER_COMMIT
             //is used for LOB's(Both Clob and Blob). Ensure that
             //we get the expected exception by comparing the SQLState.
-            checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            if (usingEmbedded()) {
+                checkException(BLOB_ACCESSED_AFTER_COMMIT, e);
+            } else {
+                checkException(INVALID_LOB, e);
+            }
         }
     }
 
@@ -2285,11 +2305,7 @@
             shortBlob.length();
             fail("FAIL - should not be able to access Blob after commit");
         } catch (SQLException e) {
-            if (usingEmbedded()) {
-                checkException(INVALID_BLOB, e);
-            } else {
-                checkException(INVALID_LOCATOR, e);
-            }
+            checkException(INVALID_LOB, e);
         }
 
         assertTrue("FAIL - blob is NULL", blob != null);
@@ -2298,51 +2314,31 @@
             blob.length();
             fail("FAIL - should not be able to access large Blob after commit");
         } catch (SQLException e) {
-            if (usingEmbedded()) {
-                checkException(INVALID_BLOB, e);
-            } else {
-                checkException(INVALID_LOCATOR, e);
-            }
+            checkException(INVALID_LOB, e);
         }
         try {
             blob.getBytes(2,3);
             fail("FAIL - should not be able to access large Blob after commit");
         } catch (SQLException e) {
-            if (usingEmbedded()) {
-                checkException(INVALID_BLOB, e);
-            } else {
-                checkException(INVALID_LOCATOR, e);
-            }
+            checkException(INVALID_LOB, e);
         }
         try {
             blob.getBinaryStream();
             fail("FAIL - should not be able to access large Blob after commit");
         } catch (SQLException e) {
-            if (usingEmbedded()) {
-                checkException(INVALID_BLOB, e);
-            } else {
-                checkException(INVALID_LOCATOR, e);
-            }
+            checkException(INVALID_LOB, e);
         }
         try {
             blob.position("foo".getBytes("US-ASCII"),2);
             fail("FAIL - should not be able to access large Blob after commit");
         } catch (SQLException e) {
-            if (usingEmbedded()) {
-                checkException(INVALID_BLOB, e);
-            } else {
-                checkException(INVALID_LOCATOR, e);
-            }
+            checkException(INVALID_LOB, e);
         }
         try {
             blob.position(blob,2);
             fail("FAIL - should not be able to access large Blob after commit");
         } catch (SQLException e) {
-            if (usingEmbedded()) {
-                checkException(INVALID_BLOB, e);
-            } else {
-                checkException(INVALID_LOCATOR, e);
-            }
+            checkException(INVALID_LOB, e);
         }
     }
 
@@ -3245,7 +3241,7 @@
     private static final String LOCK_TIMEOUT = "40XL1";
     private static final String BLOB_ACCESSED_AFTER_COMMIT = "XJ073";
     private static final String NO_CURRENT_CONNECTION = "08003";
-    private static final String INVALID_BLOB = "XJ215";
+    private static final String INVALID_LOB = "XJ215";
     private static final String INVALID_LOCATOR = "XJ217";
 
 }



Mime
View raw message