db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r896722 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
Date Thu, 07 Jan 2010 00:09:28 GMT
Author: bpendleton
Date: Thu Jan  7 00:09:28 2010
New Revision: 896722

URL: http://svn.apache.org/viewvc?rev=896722&view=rev
Log:
DERBY-4110: Deleting from a table with its synonym throws an exception

When building the ResultColumnList that is used to tie together the
search results from the WHERE clause with the processing of the DELETE,
the result columns will be bound against the exposed table name of the
table named in the DELETE statement, so if the statement used a
synonymTableName, then the result column list should manufacture column
references which use a synonymTableName as well. 

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java?rev=896722&r1=896721&r2=896722&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DMLModStatementNode.java
Thu Jan  7 00:09:28 2010
@@ -361,7 +361,7 @@
 			(FromBaseTable)
 				(getNodeFactory().getNode(
 										C_NodeTypes.FROM_BASE_TABLE,
-										targetTableName,
+										synonymTableName != null ? synonymTableName : targetTableName,
 										null,
 										null,
 										null,

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java?rev=896722&r1=896721&r2=896722&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SynonymTest.java
Thu Jan  7 00:09:28 2010
@@ -27,6 +27,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
 
 /**
  * Synonym testing using junit
@@ -45,7 +46,7 @@
      */
     public static Test suite() {
         TestSuite suite = new TestSuite(SynonymTest.class, "SynonymTest");
-        return suite;
+        return new CleanDatabaseTestSetup(suite);
     }
 
     /**
@@ -68,4 +69,27 @@
         stmt.executeUpdate("drop synonym mySyn");
         stmt.close();
     }
+
+    /**
+     * Test that synonyms are dereferenced properly for a searched DELETE.
+     *
+     * This test verifies that DERBY-4110 is fixed.
+     */
+    public void testSynonymsInSearchedDeleteDERBY4110()
+        throws SQLException
+    {
+        Statement st = createStatement();
+        st.executeUpdate("create schema test1");
+        st.executeUpdate("create schema test2");
+        st.executeUpdate("create table test1.t1 ( id bigint not null )");
+        st.executeUpdate("insert into test1.t1 values (1),(2)");
+        st.executeUpdate("create synonym test2.t1 for test1.t1");
+        st.executeUpdate("create unique index idx4110 on test1.t1 (id)");
+        st.executeUpdate("set schema test2");
+        st.executeUpdate("delete from t1 where id = 2"); // DERBY-4110 here
+        st.executeUpdate("drop synonym test2.t1");
+        st.executeUpdate("drop table test1.t1");
+        st.executeUpdate("drop schema test2 restrict");
+        st.executeUpdate("drop schema test1 restrict");
+    }
 }



Mime
View raw message