db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1549948 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Date Tue, 10 Dec 2013 19:48:28 GMT
Author: rhillegas
Date: Tue Dec 10 19:48:28 2013
New Revision: 1549948

URL: http://svn.apache.org/r1549948
Log:
DERBY-3155: Add tests to verify that BEFORE triggers can't fire MERGE statements, just as
they can't fire INSERT/UPDATE/DELETE statements; commit derby-3155-11-ab-beforeTriggersCantFireMerge.diff.

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java?rev=1549948&r1=1549947&r2=1549948&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Tue Dec 10 19:48:28 2013
@@ -70,6 +70,7 @@ public class MergeStatementTest extends 
     private static  final   String      DUPLICATE_SET_COLUMNS = "42X16";
     private static  final   String      MISSING_TABLE = "42X05";
     private static  final   String      NO_ROWS_AFFECTED = "02000";
+    private static  final   String      NO_DML_IN_BEFORE_TRIGGERS = "42Z9D";
 
     private static  final   String[]    TRIGGER_HISTORY_COLUMNS = new String[] { "ACTION",
"ACTION_VALUE" };
 
@@ -4155,6 +4156,150 @@ public class MergeStatementTest extends 
     }
     
     ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Verify that BEFORE triggers can't fire MERGE statements.
+     * </p>
+     */
+    public  void    test_024_mergeNotAllowedInBeforeTriggers()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+
+        //
+        // create schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_024( c1 int, c2 int, c3 int generated always as ( c1 + c2 ),
c1_4 int )"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t2_024( c1 int, c2 int, c3 int, c4 int, c5 varchar( 5 ) )"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t3_024( a int )"
+             );
+
+        //
+        // BEFORE DELETE triggers can't fire DML statements.
+        //
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_del_insert_before\n" +
+              "no cascade before delete on t3_024\n" +
+              "for each statement\n" +
+              "insert into t1_024( c1, c2 ) values ( 1, 2 )\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_del_update_before\n" +
+              "no cascade before delete on t3_024\n" +
+              "for each statement\n" +
+              "update t1_024 set c1 = 1\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_del_delete_before\n" +
+              "no cascade before delete on t3_024\n" +
+              "for each statement\n" +
+              "delete from t1_024\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_del_merge_before\n" +
+              "no cascade before delete on t3_024\n" +
+              "for each statement\n" +
+              "merge into t1_024\n" +
+              "using t2_024\n" +
+              "on t1_024.c1 = t2_024.c1\n" +
+              "when matched then delete\n"
+              );
+
+        //
+        // BEFORE INSERT triggers can't fire DML statements.
+        //
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_ins_insert_before\n" +
+              "no cascade before insert on t3_024\n" +
+              "for each statement\n" +
+              "insert into t1_024( c1, c2 ) values ( 1, 2 )\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_ins_update_before\n" +
+              "no cascade before insert on t3_024\n" +
+              "for each statement\n" +
+              "update t1_024 set c1 = 1\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_ins_delete_before\n" +
+              "no cascade before insert on t3_024\n" +
+              "for each statement\n" +
+              "delete from t1_024\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_ins_merge_before\n" +
+              "no cascade before insert on t3_024\n" +
+              "for each statement\n" +
+              "merge into t1_024\n" +
+              "using t2_024\n" +
+              "on t1_024.c1 = t2_024.c1\n" +
+              "when matched then delete\n"
+              );
+        
+        //
+        // BEFORE UPDATE triggers can't fire DML statements.
+        //
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_upd_insert_before\n" +
+              "no cascade before update on t3_024\n" +
+              "for each statement\n" +
+              "insert into t1_024( c1, c2 ) values ( 1, 2 )\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_upd_update_before\n" +
+              "no cascade before update on t3_024\n" +
+              "for each statement\n" +
+              "update t1_024 set c1 = 1\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_upd_delete_before\n" +
+              "no cascade before update on t3_024\n" +
+              "for each statement\n" +
+              "delete from t1_024\n"
+              );
+        expectCompilationError
+            ( dboConnection, NO_DML_IN_BEFORE_TRIGGERS,
+              "create trigger t3_024_upd_merge_before\n" +
+              "no cascade before update on t3_024\n" +
+              "for each statement\n" +
+              "merge into t1_024\n" +
+              "using t2_024\n" +
+              "on t1_024.c1 = t2_024.c1\n" +
+              "when matched then delete\n"
+              );
+
+        //
+        // drop schema
+        //
+        goodStatement( dboConnection, "drop table t3_024" );
+        goodStatement( dboConnection, "drop table t2_024" );
+        goodStatement( dboConnection, "drop table t1_024" );
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
     //
     // ROUTINES
     //



Mime
View raw message