db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1577134 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ConstraintCharacteristicsTest.java
Date Thu, 13 Mar 2014 12:29:13 GMT
Author: dag
Date: Thu Mar 13 12:29:13 2014
New Revision: 1577134

URL: http://svn.apache.org/r1577134
Log:
DERBY-532 Support deferrable constraints

Added an extra test case.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ConstraintCharacteristicsTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ConstraintCharacteristicsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ConstraintCharacteristicsTest.java?rev=1577134&r1=1577133&r2=1577134&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ConstraintCharacteristicsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ConstraintCharacteristicsTest.java
Thu Mar 13 12:29:13 2014
@@ -1129,8 +1129,6 @@ public class ConstraintCharacteristicsTe
                         ct + " deferrable initially deferred)");
                 s.executeUpdate(
                         "insert into t values " + rs2Values(initialContents));
-                s.executeUpdate(
-                        "insert into t values " + rs2Values(initialContents));
 
                 declareCalledNested(s);
                 s.executeUpdate("call calledNested(true)");
@@ -1138,6 +1136,23 @@ public class ConstraintCharacteristicsTe
                 rollback();
             }
         }
+        
+        // Check what happens if routine set mode to immediate with
+        // deferred rows inserted by caller
+        for (String ct : checkForms) {
+            try {
+                s.executeUpdate(
+                   ct + " deferrable initially deferred)");
+                s.executeUpdate(
+                   "insert into t values " + rs2Values(negatedInitialContents));
+                declareCalledNestedSetImmediate(s);
+                s.executeUpdate("call calledNestedSetImmediate()");
+            } catch (SQLException e) {
+                assertSQLState(LANG_DEFERRED_CHECK_VIOLATION_S, e);
+            } finally {
+                rollback();
+            }
+        }
     }
 
     public void testDeferredRowsInvalidation() throws SQLException {
@@ -2375,6 +2390,16 @@ public class ConstraintCharacteristicsTe
             ".calledNested' modifies sql data");
     }
 
+    private void declareCalledNestedSetImmediate(final Statement s) 
+            throws SQLException {
+        s.executeUpdate(
+            "create procedure calledNestedSetImmediate()" +
+            "  language java parameter style java" +
+            "  external name '" +
+            this.getClass().getName() +
+            ".calledNestedSetImmediate' modifies sql data");
+    }
+
     public static void calledNested(final boolean isCheckConstraint)
             throws SQLException
     {
@@ -2389,5 +2414,18 @@ public class ConstraintCharacteristicsTe
                         initialContents));
         c.close();
     }
+
+    public static void calledNestedSetImmediate() throws SQLException
+    {
+        final Connection c =
+            DriverManager.getConnection("jdbc:default:connection");
+        final Statement cStmt = c.createStatement();
+
+        try {
+            cStmt.executeUpdate("set constraints c immediate");
+        } finally { 
+            c.close();
+        }
+    }
 }
 



Mime
View raw message