db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1527980 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/impl/sql/compile/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Tue, 01 Oct 2013 09:08:25 GMT
Author: kahatlen
Date: Tue Oct  1 09:08:25 2013
New Revision: 1527980

URL: http://svn.apache.org/r1527980
Log:
DERBY-6357: CREATE TRIGGER doesn't detect all illegal references to SESSION schema

Merged revision 1527963 from trunk.

Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1527963

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java?rev=1527980&r1=1527979&r2=1527980&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
Tue Oct  1 09:08:25 2013
@@ -143,6 +143,10 @@ public class RowResultSetNode extends Fr
 		}
 	}
 
+    public boolean referencesSessionSchema() throws StandardException {
+        return subquerys != null && subquerys.referencesSessionSchema();
+    }
+
 	/**
 	 * Modify the RCL of this node to match the target of the insert.
 	 */

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java?rev=1527980&r1=1527979&r2=1527980&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
Tue Oct  1 09:08:25 2013
@@ -167,7 +167,7 @@ public class SubqueryList extends QueryT
 
 			subqueryNode = (SubqueryNode) elementAt(index);
 
-			if (subqueryNode.getResultSet().referencesSessionSchema())
+            if (subqueryNode.referencesSessionSchema())
 			{
 				return true;
 			}

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=1527980&r1=1527979&r2=1527980&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
(original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
Tue Oct  1 09:08:25 2013
@@ -403,6 +403,10 @@ public class SubqueryNode extends ValueN
   		parentComparisonOperator = parent;
   	}
 
+    public boolean referencesSessionSchema() throws StandardException {
+        return resultSet.referencesSessionSchema();
+    }
+
 	/**
 	 * Remap all ColumnReferences in this tree to be clones of the
 	 * underlying expression.

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java?rev=1527980&r1=1527979&r2=1527980&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Tue Oct  1 09:08:25 2013
@@ -1797,4 +1797,48 @@ public class TriggerTest extends BaseJDB
                     { "tr6", "1" },
                 });
     }
+
+    /**
+     * Verify that CREATE TRIGGER fails if a temporary table is referenced.
+     * Regression test case for DERBY-6357.
+     */
+    public void testDerby6357TempTable() throws SQLException {
+        Statement s = createStatement();
+        s.execute("declare global temporary table temptable(x int) not logged");
+        s.execute("create table t1(x int)");
+        s.execute("create table t2(i int, b boolean)");
+
+        assertCompileError("XCL51",
+                "create trigger tr1 after insert on session.temptable "
+                + "referencing new table as new "
+                + "insert into t1(i) select x from new");
+
+        assertCompileError("XCL51",
+                "create trigger tr2 after insert on t1 "
+                + "insert into t2(i) select x from session.temptable");
+
+        assertCompileError("XCL51",
+                "create trigger tr3 after insert on t1 "
+                + "insert into session.temptable values 1");
+
+        // Used to fail
+        assertCompileError("XCL51",
+                "create trigger tr4 after insert on t1 "
+                + "insert into t2(b) values exists("
+                + "select * from session.temptable)");
+
+        // Used to fail
+        assertCompileError("XCL51",
+                "create trigger tr5 after insert on t1 "
+                + "insert into t2(i) values case when "
+                + "exists(select * from session.temptable) then 1 else 2 end");
+
+        // Used to fail
+        assertCompileError("XCL51",
+                "create trigger tr6 after insert on t1 "
+                + "insert into t2(b) values "
+                + "(select count(*) from session.temptable) = "
+                + "(select count(*) from sysibm.sysdummy1)");
+
+    }
 }



Mime
View raw message