db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1084718 - in /db/derby/code/trunk: ./ java/engine/org/apache/derby/iapi/sql/dictionary/ java/engine/org/apache/derby/impl/sql/catalog/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/ java/testing/org/apache/derbyTesting/func...
Date Wed, 23 Mar 2011 20:16:31 GMT
Author: mamta
Date: Wed Mar 23 20:16:31 2011
New Revision: 1084718

URL: http://svn.apache.org/viewvc?rev=1084718&view=rev
Log:
Committing changes to back out DERBY-1482 out of trunk(10.8 codeline, the changes have already
been backed out of 10.7). In addition to engine code backport, it will also disable the tests
that were added for DERBY-1482.

With DERBY-1482, these tests would not read in large object columns into memory because the
triggers didn't need them. But now that DERBY-1482 changes are being backed out, the large
object columns will be read in which can cause the test to run out of memory depending on
how much heap is available to it. I will disable the tests from 10.7 too.

This commit also has a comment in DataDictionaryImpl:getTriggerActionString explaining the
code changes for backout. I will add that comment in 10.7 too.


Modified:
    db/derby/code/trunk/   (props changed)
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/TriggerTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java

Propchange: db/derby/code/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 23 20:16:31 2011
@@ -1,2 +1,2 @@
-/db/derby/code/branches/10.7:1061570,1061578
+/db/derby/code/branches/10.7:1061570,1061578,1082235
 /db/derby/code/trunk:1063809

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java?rev=1084718&r1=1084717&r2=1084718&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/TriggerDescriptor.java
Wed Mar 23 20:16:31 2011
@@ -352,8 +352,7 @@ public class TriggerDescriptor extends T
 		//will then get updated into SYSSTATEMENTS table.
 		if((!actionSPS.isValid() ||
 				 (actionSPS.getPreparedStatement() == null)) && 
-				 isRow &&
-				 referencedColsInTriggerAction != null) 
+				 isRow && (referencingOld || referencingNew))
 		{
 			SchemaDescriptor compSchema;
 			compSchema = getDataDictionary().getSchemaDescriptor(triggerSchemaId, null);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1084718&r1=1084717&r2=1084718&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Wed Mar 23 20:16:31 2011
@@ -4716,8 +4716,13 @@ public final class	DataDictionaryImpl
 			boolean createTriggerTime
 			) throws StandardException
 	{
-		boolean in10_7_orHigherVersion =
-			checkVersion(DataDictionary.DD_VERSION_DERBY_10_7,null);
+		// DERBY-1482 has caused a regression which is being worked
+		// under DERBY-5121. Until DERBY-5121 is fixed, we want
+		// Derby to create triggers same as it is done in 10.6 and
+		// earlier. This in other words means that do not try to
+		// optimize how many columns are read from the trigger table,
+		// simply read all the columns from the trigger table.
+		boolean in10_7_orHigherVersion = false;
 		
 		StringBuffer newText = new StringBuffer();
 		int start = 0;
@@ -5001,6 +5006,14 @@ public final class	DataDictionaryImpl
 			newText.append(triggerDefinition.substring(start, tokBeginOffset-actionOffset));
 			int colPositionInRuntimeResultSet = -1;
 			ColumnDescriptor triggerColDesc = triggerTableDescriptor.getColumnDescriptor(colName);
+			//DERBY-5121 We can come here if the column being used in trigger
+			// action is getting dropped and we have come here through that
+			// ALTER TABLE DROP COLUMN. In that case, we will not find the
+			// column in the trigger table.
+			if (triggerColDesc == null) {
+				throw StandardException.newException(
+		                SQLState.LANG_COLUMN_NOT_FOUND, tableName+"."+colName);
+			}
 			int colPositionInTriggerTable = triggerColDesc.getPosition();
 
 			//This part of code is little tricky and following will help

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=1084718&r1=1084717&r2=1084718&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
Wed Mar 23 20:16:31 2011
@@ -576,6 +576,34 @@ public class TriggerTest extends BaseJDB
         JDBC.assertFullResultSet(rs, result);
     }
     
+    public void testDERBY5121() throws SQLException
+    {
+        Statement s = createStatement();
+
+        s.executeUpdate("CREATE TABLE T1 (A1 int)");
+        s.executeUpdate("CREATE TABLE T2 (B1 int, B2 int, B3 int)");
+        s.executeUpdate("CREATE TRIGGER t2UpdateTrigger "+
+        		"after UPDATE of b1 on t2 " +
+        		"referencing new row as nr for each ROW " +
+        		"insert into t1 values ( nr.b3 ) ");
+        s.executeUpdate("INSERT INTO T2 VALUES(0,0,0)");
+        s.executeUpdate("update t2 set b1 = 100 , b2 = 1");
+        ResultSet rs =s.executeQuery("SELECT * FROM T1");
+        JDBC.assertFullResultSet(rs, new String[][] {{"0"}});
+
+        s.executeUpdate("CREATE TABLE T3 (A1 int)");
+        s.executeUpdate("CREATE TABLE T4 (B1 int, B2 int, B3 int)");
+        s.executeUpdate("CREATE TRIGGER t4UpdateTrigger "+
+        		"after UPDATE of b1 on t4 " +
+        		"referencing new table as nt for each STATEMENT " +
+        		"insert into t3 select b3 from nt");
+        s.executeUpdate("INSERT INTO T4 VALUES(0,0,0)");
+        s.executeUpdate("update t4 set b1 = 100 , b2 = 1");
+        rs =s.executeQuery("SELECT * FROM T3");
+        JDBC.assertFullResultSet(rs, new String[][] {{"0"}});
+
+    }
+    
     /** 
      * Test for DERBY-3238 trigger fails with IOException if triggering table has large lob.
      * 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java?rev=1084718&r1=1084717&r2=1084718&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/memory/TriggerTests.java
Wed Mar 23 20:16:31 2011
@@ -42,7 +42,17 @@ public class TriggerTests extends BaseJD
 
 	final int lobsize = 50000*1024;
 	boolean testWithLargeDataInLOB = true;
-	
+	// DERBY-1482 has caused a regression which is being worked
+	// under DERBY-5121. Until DERBY-5121 is fixed, we want
+	// Derby to create triggers same as it is done in 10.6 and
+	// earlier. This in other words means that do not try to
+	// optimize how many columns are read from the trigger table,
+	// simply read all the columns from the trigger table. 
+	// Because of this, we need to disable the tests that were
+	// added as part of DERBY-1482 to check the column read
+	// optimization.
+	boolean isDerby1482Fixed = false;
+
 	/**
 	 * Insert trigger tests
 	 * ****************
@@ -325,6 +335,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1InsertAfterTrigger() throws SQLException{	
+        if (isDerby1482Fixed == false)
+            return;
+
         basicSetup();
         Statement s = createStatement();
 		s.execute("create trigger trigger1 AFTER INSERT on table1 referencing " +
@@ -342,6 +355,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1InsertAfterTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
         // JSR169 cannot run with tests with stored procedures
         // that do database access - for they require a
         // DriverManager connection to jdbc:default:connection;
@@ -386,6 +402,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1DeleteAfterTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -411,6 +430,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1DeleteAfterTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -461,6 +483,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1UpdateAfterTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
         basicSetup();
         Statement s = createStatement();
 		s.execute("create trigger trigger1 after update of status on table1 referencing " +
@@ -478,6 +503,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1UpdateAfterTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
         // JSR169 cannot run with tests with stored procedures
         // that do database access - for they require a
         // DriverManager connection to jdbc:default:connection;
@@ -518,6 +546,8 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1InsertBeforeTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
 		
         basicSetup();
         Statement s = createStatement();
@@ -536,6 +566,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1InsertBeforeTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
         // JSR169 cannot run with tests with stored procedures
         // that do database access - for they require a
         // DriverManager connection to jdbc:default:connection;
@@ -580,6 +613,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1DeleteBeforeTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -605,6 +641,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1DeleteBeforeTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -657,6 +696,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1UpdateBeforeTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
         basicSetup();
         Statement s = createStatement();
 
@@ -675,6 +717,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test1UpdateBeforeTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
         // JSR169 cannot run with tests with stored procedures
         // that do database access - for they require a
         // DriverManager connection to jdbc:default:connection;
@@ -721,6 +766,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2InsertAfterTriggerAccessLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -757,6 +805,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2DeleteAfterTriggerAccessLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -807,6 +858,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2UpdateAfterTriggerAccessLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -842,6 +896,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2InsertAfterTriggerUpdatedLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -879,6 +936,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2UpdateAfterTriggerUpdatedLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -915,6 +975,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2InsertBeforeTriggerAccessLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -949,6 +1012,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2DeleteBeforeTriggerAccessLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -984,6 +1050,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test2UpdateBeforeTriggerAccessLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -1028,6 +1097,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test3UpdateAfterTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -1052,6 +1124,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test3UpdateAfterTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -1096,6 +1171,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test3UpdateBeforeTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -1121,6 +1199,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test3UpdateBeforeTriggerStoredProc() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -1171,6 +1252,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test4UpdateAfterTriggerAccessLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -1206,6 +1290,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */ 
 	public void test4UpdateAfterTriggerUpdatedLOB() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		
@@ -1244,6 +1331,9 @@ public class TriggerTests extends BaseJD
 	 * @throws SQLException
 	 */
 	public void test4UpdateBeforeTrigger() throws SQLException{
+        if (isDerby1482Fixed == false)
+            return;
+
 		if (testWithLargeDataInLOB)
 			return;
 		



Mime
View raw message