db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1078693 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java testing/org/apache/derbyTesting/functionTests/tests/lang/AlterTableTest.java
Date Mon, 07 Mar 2011 06:30:50 GMT
Author: mamta
Date: Mon Mar  7 06:30:50 2011
New Revision: 1078693

URL: http://svn.apache.org/viewvc?rev=1078693&view=rev
Log:
DERBY-5079 (DERBY-4984 caused a regression which will not allow users to drop a table if the
table was involved in a trigger action rebind during ALTER TABLE DROP COLUMN)

Trigger action sql should be rebound using the statement and not the trigger table. Also,
dependency between the trigger table and trigger action SPS should be established.



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AlterTableTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?rev=1078693&r1=1078692&r2=1078693&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
Mon Mar  7 06:30:50 2011
@@ -1801,8 +1801,11 @@ class AlterTableConstantAction extends D
 				pa = newCC.getParser();
 				stmtnode = (StatementNode)pa.parseStatement(triggerActionSPSD.getText());
 				// need a current dependent for bind
-				newCC.setCurrentDependent(td);
-				stmtnode.bindStatement();				
+				newCC.setCurrentDependent(triggerActionSPSD.getPreparedStatement());
+				stmtnode.bindStatement();
+				//Register the dependency between trigger table and trigger 
+				// action SPS
+				dm.addDependency(triggerActionSPSD, td, lcc.getContextManager());
 			} catch (StandardException se)
 			{
 				if (se.getMessageId().equals(SQLState.LANG_COLUMN_NOT_FOUND))

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AlterTableTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AlterTableTest.java?rev=1078693&r1=1078692&r2=1078693&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AlterTableTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AlterTableTest.java
Mon Mar  7 06:30:50 2011
@@ -2297,10 +2297,9 @@ public final class AlterTableTest extend
         JDBC.assertEmpty(st.executeQuery(
         		" select triggername from sys.systriggers where " +
         		"triggername in ('ATDC_12_TRIGGER_1', 'ATDC_12_TRIGGER_2')"));
-        //Following returns incorrect rows for SYS.SYSDEPENDS DERBY-5079
-//        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should reduce",
-  //      		numberOfRowsInSysdepends(st),sysdependsRowCountBeforeCreateTrigger);
-  //      st.executeUpdate("drop table ATDC_12");
+        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should reduce",
+        		numberOfRowsInSysdepends(st),sysdependsRowCountBeforeCreateTrigger);
+        st.executeUpdate("drop table ATDC_12");
 
         // Another test
         // drop column restrict should fail because there is a table level
@@ -2347,10 +2346,9 @@ public final class AlterTableTest extend
         		" select triggername from sys.systriggers where " +
         		"triggername in ('ATDC_13_TRIGGER_1', "+
         		"'ATDC_13_TRIGGER_2', 'ATDC_13_TRIGGER_3')"));
-        //Following returns incorrect rows for SYS.SYSDEPENDS DERBY-5079
-//        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should reduce",
-  //      		numberOfRowsInSysdepends(st),sysdependsRowCountBeforeCreateTrigger);
-    //    st.executeUpdate("drop table ATDC_13");
+        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should reduce",
+        		numberOfRowsInSysdepends(st),sysdependsRowCountBeforeCreateTrigger);
+        st.executeUpdate("drop table ATDC_13");
         
         // Another test DERBY-5044
         // ALTER TABLE DROP COLUMN in following test case causes the column
@@ -2390,10 +2388,10 @@ public final class AlterTableTest extend
         rs =
             st.executeQuery(" select * from atdc_16_tab2");
         JDBC.assertFullResultSet(rs, new String[][]{{"1","11","333"}});
-        //Following returns incorrect rows for SYS.SYSDEPENDS DERBY-5079
-//        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should reduce",
-  //            		numberOfRowsInSysdepends(st),sysdependsRowCountAfterCreateTrigger);
-    //    st.executeUpdate("drop table ATDC_13");
+        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should reduce",
+              		numberOfRowsInSysdepends(st),sysdependsRowCountAfterCreateTrigger);
+        st.executeUpdate("drop table ATDC_16_TAB1");
+        st.executeUpdate("drop table ATDC_16_TAB2");
         
         // Another test DERBY-5044
         //Following test case involves two tables. The trigger is defined 
@@ -2470,9 +2468,8 @@ public final class AlterTableTest extend
             st.executeQuery(" select * from atdc_15_tab2");
         JDBC.assertFullResultSet(rs, new String[][]{{"1","22"}});
         st.executeUpdate("alter table atdc_15_tab1 drop column a1 restrict");
-        //Following returns incorrect rows for SYS.SYSDEPENDS DERBY-5079
-//        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should not change",
-  //      		numberOfRowsInSysdepends(st),sysdependsRowCountAfterCreateTrigger);
+        Assert.assertEquals("# of rows in SYS.SYSDEPENDS should not change",
+        		numberOfRowsInSysdepends(st),sysdependsRowCountAfterCreateTrigger);
         st.executeUpdate("update atdc_15_tab1 set b1=33");
         rs =
             st.executeQuery(" select * from atdc_15_tab1");
@@ -2481,7 +2478,7 @@ public final class AlterTableTest extend
             st.executeQuery(" select * from atdc_15_tab2");
         JDBC.assertFullResultSet(rs, new String[][]{{"1","33"}});
         st.executeUpdate("drop table ATDC_15_TAB1");
-//        st.executeUpdate("drop table ATDC_15_TAB2");
+        st.executeUpdate("drop table ATDC_15_TAB2");
 
         st.executeUpdate(
                 " create table atdc_7 (a int, b int, c int, primary key (a))");



Mime
View raw message