db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r960105 - in /db/derby/code/branches/10.5: ./ java/engine/org/apache/derby/impl/sql/execute/CreateTableConstantAction.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/RenameTableTest.java
Date Fri, 02 Jul 2010 21:16:27 GMT
Author: mikem
Date: Fri Jul  2 21:16:26 2010
New Revision: 960105

URL: http://svn.apache.org/viewvc?rev=960105&view=rev
Log:
DERBY-4479: RENAME TABLE needs to invalidate any cached CREATE TABLE statement

backporting fix svn #909176 from trunk to 10.5 branch.

The problem involves a missing dependency between the CREATE TABLE statement
and the table that it is creating. For other types of statements, the
dependency of the statement on the table is generally registered during
compilation.

However, this isn't quite so easy with the CREATE TABLE statement, because
the table descriptor doesn't exist during compilation, since the table isn't
created until the statement is actually executed.

This change registers the dependency at execution time. At the very end of
CreateTableConstantAction.executeConstantAction, there is
some new code added to register a dependency from the CREATE TABLE
statement to the table we have just finished creating. 




Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CreateTableConstantAction.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RenameTableTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul  2 21:16:26 2010
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.6:957000
-/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,881074,881444,882732,884163,887246,892912,897161,898635,901165,901648,901760,903108,908418,911315,915733,916075,916897,918359,921028,927430,928065,942286,942476,942480,942587,946794,948045,948069,951346,954748,955001,955634,956075,956445,956659,958163,959550
+/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793089,793588,794106,794303,794955,795166,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,829022,832379,833430,835286,881074,881444,882732,884163,887246,892912,897161,898635,901165,901648,901760,903108,908418,909176,911315,915733,916075,916897,918359,921028,927430,928065,942286,942476,942480,942587,946794,948045,948069,951346,954748,955001,955634,956075,956445,956659,958163,959550

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CreateTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CreateTableConstantAction.java?rev=960105&r1=960104&r2=960105&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CreateTableConstantAction.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/sql/execute/CreateTableConstantAction.java
Fri Jul  2 21:16:26 2010
@@ -371,6 +371,16 @@ class CreateTableConstantAction extends 
 		{
 			lcc.addDeclaredGlobalTempTable(td);
 		}
+
+		// Indicate that the CREATE TABLE statement itself depends on the
+		// table it is creating. Normally such statement dependencies are
+		// added during compilation, but here we have a bootstrapping issue
+		// because the table doesn't exist until the CREATE TABLE statement
+		// has been executed, so we had to defer the creation of this
+		// dependency until now. (DERBY-4479)
+		dd.getDependencyManager().addDependency(
+			activation.getPreparedStatement(), td, lcc.getContextManager());
+
 	}
 
 

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RenameTableTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RenameTableTest.java?rev=960105&r1=960104&r2=960105&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RenameTableTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RenameTableTest.java
Fri Jul  2 21:16:26 2010
@@ -230,4 +230,26 @@ public class RenameTableTest extends Bas
         // select * from tcheck1;
         s.executeUpdate("drop table tcheck1");
     }
+
+    /**
+     * Tests that rename table invalidates stored statement plans (DERBY-4479).
+     *
+     * By issuing the *identical* create table statement after the rename,
+     * we check to see whether the compiled statements from the first
+     * create table statement were properly invalidated by the rename.
+     * 
+     * @exception SQLException
+     */
+    public void testRenameInvalidation_derby_4479()
+        throws SQLException
+    {
+        getConnection().setAutoCommit(true);
+        Statement s = createStatement();
+        s.executeUpdate("create table a (x int not null primary key)");
+        s.executeUpdate("rename table a to b");
+        s.executeUpdate("create table a (x int not null primary key)");
+        s.executeUpdate("drop table a");
+        s.executeUpdate("drop table b");
+    }
+
 }



Mime
View raw message