db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r492734 - in /db/derby/code/branches/10.2/java: engine/org/apache/derby/impl/sql/conn/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Thu, 04 Jan 2007 20:55:20 GMT
Author: bpendleton
Date: Thu Jan  4 12:55:19 2007
New Revision: 492734

URL: http://svn.apache.org/viewvc?view=rev&rev=492734
Log:
DERBY-2183: Trigger recompilation problem when not qualified with schema

This patch was contributed by Yip Ng (yipng168@gmail.com)

This change applies derby2183-10.2-diff01.txt to the 10.2 branch.


Modified:
    db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql
    db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral_app.properties

Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?view=diff&rev=492734&r1=492733&r2=492734
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Thu Jan  4 12:55:19 2007
@@ -1832,13 +1832,31 @@
 
 	/**
 	 * Push a CompilerContext on the context stack with
-	 * the passed in default schema as the default schema
+	 * the passed in schema sd as the default schema
 	 * we compile against.
 	 *
 	 * @param sd the default schema 
 	 *
 	 * @return the compiler context
 	 *
+	 * For the parameter sd, there are 3 possible values(of interest) that can 
+	 * get passed into this method:
+	 * 
+	 * a) A null SchemaDescriptor which indicates to the system to use the 
+	 *    CURRENT SCHEMA as the compilation schema.
+	 *    
+	 * b) A SchemaDescriptor with its UUID == null, this indicates that either 
+	 *    the schema has not been physically created yet or that the LCC's 
+	 *    getDefaultSchema() is not yet up-to-date with its actual UUID. 
+	 *    The system will use the CURRENT SCHEMA as the compilation schema. 
+	 *    
+	 * c) A SchemaDescriptor with its UUID != null, this means that the schema 
+	 *    has been physically created.  The system will use this schema as the 
+	 *    compilation schema (e.g.: for trigger or view recompilation cases, 
+	 *    etc.). 
+	 *    
+	 * The compiler context's compilation schema will be set accordingly based 
+	 * on the given input above.   
 	 */
 	public	CompilerContext pushCompilerContext(SchemaDescriptor sd)
 	{
@@ -1877,6 +1895,24 @@
 		if (sc.getSystemCode())
 			cc.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);
 
+		/*
+		 * Set the compilation schema when its UUID is available.
+		 * i.e.:  Schema may not have been physically created yet, so
+		 *        its UUID will be null.
+		 * 
+		 * o For trigger SPS recompilation, the system must use its
+		 *   compilation schema to recompile the statement. 
+		 * 
+		 * o For view recompilation, we set the compilation schema
+		 *   for this compiler context if its UUID is available.
+		 *   Otherwise, the compilation schema will be determined
+		 *   at execution time of view creation.
+		 */
+		if (sd != null && sd.getUUID() != null)
+		{
+			cc.setCompilationSchema(sd);
+		}
+		
 		return	cc;
 	}
 

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out?view=diff&rev=492734&r1=492733&r2=492734
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
Thu Jan  4 12:55:19 2007
@@ -1388,4 +1388,114 @@
 0 rows inserted/updated/deleted
 ij> drop table y;
 0 rows inserted/updated/deleted
-ij> 
+ij> -- DERBY-2183
+-- trigger recompilation test
+connect 'jdbc:derby:wombat' user 'user1' as user1;
+ij(USER1)> set schema app;
+0 rows inserted/updated/deleted
+ij(USER1)> drop trigger app.tr1;
+ERROR 42X94: TRIGGER 'APP.TR1' does not exist.
+ij(USER1)> drop table app.t1;
+0 rows inserted/updated/deleted
+ij(USER1)> create table app.t1 (i int, j int);
+0 rows inserted/updated/deleted
+ij(USER1)> insert into app.t1 values (1,10);
+1 row inserted/updated/deleted
+ij(USER1)> create trigger app.tr1 after update of i on app.t1 referencing old as old for
each row mode db2sql update t1 set j = old.j+1;
+0 rows inserted/updated/deleted
+ij(USER1)> update app.t1 set i=i+1;
+1 row inserted/updated/deleted
+ij(USER1)> select * from app.t1;
+I          |J          
+-----------------------
+2          |11         
+ij(USER1)> call sqlj.install_jar('file:dcl_emc1.jar', 'APP.dcl_emc1', 0);
+0 rows inserted/updated/deleted
+ij(USER1)> connect 'jdbc:derby:wombat' user 'user2' as user2;
+ij(USER2)> -- ok
+update app.t1 set i=i+1;
+1 row inserted/updated/deleted
+ij(USER2)> select * from app.t1;
+I          |J          
+-----------------------
+3          |12         
+ij(USER2)> call sqlj.replace_jar('file:dcl_emc1.jar', 'APP.dcl_emc1');
+0 rows inserted/updated/deleted
+ij(USER2)> update app.t1 set i=i+1;
+1 row inserted/updated/deleted
+ij(USER2)> select * from app.t1;
+I          |J          
+-----------------------
+4          |13         
+ij(USER2)> call sqlj.remove_jar('APP.dcl_emc1', 0);
+0 rows inserted/updated/deleted
+ij(USER2)> update app.t1 set i=i+1;
+1 row inserted/updated/deleted
+ij(USER2)> select * from app.t1;
+I          |J          
+-----------------------
+5          |14         
+ij(USER2)> drop trigger app.tr1;
+0 rows inserted/updated/deleted
+ij(USER2)> drop table app.t1;
+0 rows inserted/updated/deleted
+ij(USER2)> set connection user1;
+ij(USER1)> set schema app;
+0 rows inserted/updated/deleted
+ij(USER1)> create table app.t1 (id int, i int, j int);
+0 rows inserted/updated/deleted
+ij(USER1)> insert into app.t1 values (1,10, 100);
+1 row inserted/updated/deleted
+ij(USER1)> insert into app.t1 values (2,20, 200);
+1 row inserted/updated/deleted
+ij(USER1)> insert into app.t1 values (3,30, 300);
+1 row inserted/updated/deleted
+ij(USER1)> create trigger app.tr1 after update on app.t1 referencing old as oldt  new
as newt 
+for each row mode db2sql update t1 set t1.j = CASE WHEN (oldt.j < 100) THEN (oldt.j +
1) ELSE 1 END WHERE
+((newt.j is null) OR (oldt.j = newt.j)) AND newt.id = t1.id;
+0 rows inserted/updated/deleted
+ij(USER1)> update app.t1 set i=i+1;
+3 rows inserted/updated/deleted
+ij(USER1)> select * from app.t1;
+ID         |I          |J          
+-----------------------------------
+1          |11         |1          
+2          |21         |1          
+3          |31         |1          
+ij(USER1)> call sqlj.install_jar('file:dcl_emc1.jar', 'APP.dcl_emc1', 0);
+0 rows inserted/updated/deleted
+ij(USER1)> set connection user2;
+ij(USER2)> -- ok
+update app.t1 set i=i+1;
+3 rows inserted/updated/deleted
+ij(USER2)> select * from app.t1;
+ID         |I          |J          
+-----------------------------------
+1          |12         |2          
+2          |22         |2          
+3          |32         |2          
+ij(USER2)> call sqlj.replace_jar('file:dcl_emc1.jar', 'APP.dcl_emc1');
+0 rows inserted/updated/deleted
+ij(USER2)> update app.t1 set i=i+1;
+3 rows inserted/updated/deleted
+ij(USER2)> select * from app.t1;
+ID         |I          |J          
+-----------------------------------
+1          |13         |3          
+2          |23         |3          
+3          |33         |3          
+ij(USER2)> call sqlj.remove_jar('APP.dcl_emc1', 0);
+0 rows inserted/updated/deleted
+ij(USER2)> update app.t1 set i=i+1;
+3 rows inserted/updated/deleted
+ij(USER2)> select * from app.t1;
+ID         |I          |J          
+-----------------------------------
+1          |14         |4          
+2          |24         |4          
+3          |34         |4          
+ij(USER2)> drop trigger app.tr1;
+0 rows inserted/updated/deleted
+ij(USER2)> drop table app.t1;
+0 rows inserted/updated/deleted
+ij(USER2)> 

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql?view=diff&rev=492734&r1=492733&r2=492734
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql
Thu Jan  4 12:55:19 2007
@@ -773,3 +773,55 @@
 drop table x;
 drop table y;
 
+-- DERBY-2183
+-- trigger recompilation test
+connect 'jdbc:derby:wombat' user 'user1' as user1;
+set schema app;
+drop trigger app.tr1;
+drop table app.t1;
+create table app.t1 (i int, j int);
+insert into app.t1 values (1,10);
+create trigger app.tr1 after update of i on app.t1 referencing old as old for each row mode
db2sql update t1 set j = old.j+1;
+update app.t1 set i=i+1;
+select * from app.t1;
+call sqlj.install_jar('file:dcl_emc1.jar', 'APP.dcl_emc1', 0);
+
+connect 'jdbc:derby:wombat' user 'user2' as user2;
+-- ok
+update app.t1 set i=i+1;
+select * from app.t1;
+call sqlj.replace_jar('file:dcl_emc1.jar', 'APP.dcl_emc1');
+update app.t1 set i=i+1;
+select * from app.t1;
+call sqlj.remove_jar('APP.dcl_emc1', 0);
+update app.t1 set i=i+1;
+select * from app.t1;
+drop trigger app.tr1;
+drop table app.t1;
+
+set connection user1;
+set schema app;
+create table app.t1 (id int, i int, j int);
+insert into app.t1 values (1,10, 100);
+insert into app.t1 values (2,20, 200);
+insert into app.t1 values (3,30, 300);
+create trigger app.tr1 after update on app.t1 referencing old as oldt  new as newt 
+for each row mode db2sql update t1 set t1.j = CASE WHEN (oldt.j < 100) THEN (oldt.j +
1) ELSE 1 END WHERE
+((newt.j is null) OR (oldt.j = newt.j)) AND newt.id = t1.id;
+update app.t1 set i=i+1;
+select * from app.t1;
+call sqlj.install_jar('file:dcl_emc1.jar', 'APP.dcl_emc1', 0);
+
+set connection user2;
+-- ok
+update app.t1 set i=i+1;
+select * from app.t1;
+call sqlj.replace_jar('file:dcl_emc1.jar', 'APP.dcl_emc1');
+update app.t1 set i=i+1;
+select * from app.t1;
+call sqlj.remove_jar('APP.dcl_emc1', 0);
+update app.t1 set i=i+1;
+select * from app.t1;
+drop trigger app.tr1;
+drop table app.t1;
+

Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral_app.properties
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral_app.properties?view=diff&rev=492734&r1=492733&r2=492734
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral_app.properties
(original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral_app.properties
Thu Jan  4 12:55:19 2007
@@ -1,5 +1,9 @@
 ij.protocol=jdbc:derby:
 usedefaults=true
+supportfiles=tests/lang/dcl_emc1.jar
 
 #Exclude for J2ME/Foundation - test requires java.sql.DriverManager
-runwithfoundation=false
\ No newline at end of file
+runwithfoundation=false
+
+# disable security manager for now 
+noSecurityManager=true



Mime
View raw message