Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 77751 invoked from network); 2 Jul 2010 21:17:33 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jul 2010 21:17:33 -0000 Received: (qmail 89152 invoked by uid 500); 2 Jul 2010 21:17:33 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 89111 invoked by uid 500); 2 Jul 2010 21:17:33 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 89103 invoked by uid 99); 2 Jul 2010 21:17:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jul 2010 21:17:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jul 2010 21:17:30 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5C64B23888E8; Fri, 2 Jul 2010 21:16:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: derby-commits@db.apache.org From: mikem@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100702211628.5C64B23888E8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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"); + } + }