db-derby-commits mailing list archives

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

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

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java?rev=1527963&r1=1527962&r2=1527963&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
Tue Oct  1 08:04:20 2013
@@ -140,6 +140,11 @@ class RowResultSetNode extends FromTable
 		}
 	}
 
+    @Override
+    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/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java?rev=1527963&r1=1527962&r2=1527963&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryList.java Tue
Oct  1 08:04:20 2013
@@ -151,7 +151,7 @@ class SubqueryList extends QueryTreeNode
 	{
         for (SubqueryNode sqn : this)
 		{
-            if (sqn.getResultSet().referencesSessionSchema())
+            if (sqn.referencesSessionSchema())
 			{
 				return true;
 			}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=1527963&r1=1527962&r2=1527963&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Tue
Oct  1 08:04:20 2013
@@ -395,6 +395,11 @@ class SubqueryNode extends ValueNode
   		parentComparisonOperator = parent;
   	}
 
+    @Override
+    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/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java?rev=1527963&r1=1527962&r2=1527963&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
Tue Oct  1 08:04:20 2013
@@ -1798,4 +1798,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