You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ba...@apache.org on 2005/05/18 22:17:03 UTC

svn commit: r170809 - in /incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/autoincrement.out tests/lang/autoincrement.sql

Author: bandaram
Date: Wed May 18 13:17:02 2005
New Revision: 170809

URL: http://svn.apache.org/viewcvs?rev=170809&view=rev
Log:
Patch to enhance multiple connection test for autoincrement.

Submitted by Mamta Satoor(msatoor@gmail.com)
 

Modified:
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out?rev=170809&r1=170808&r2=170809&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/autoincrement.out Wed May 18 13:17:02 2005
@@ -1431,6 +1431,44 @@
 1                              
 -------------------------------
 201                            
+ij(CONN2)> -- notice that rolling the transaction does not affect IDENTITY_VAL_LOCAL()
+values IDENTITY_VAL_LOCAL();
+1                              
+-------------------------------
+201                            
+ij(CONN2)> drop table t1;
+0 rows inserted/updated/deleted
+ij(CONN2)> drop table t2;
+0 rows inserted/updated/deleted
+ij(CONN2)> -- A table with identity column has an insert trigger which inserts into another table 
+-- with identity column. IDENTITY_VAL_LOCAL will return the generated value for the 
+-- statement table and not for the table that got modified by the trigger
+create table t1 (c11 int generated always as identity (start with 101, increment by 3), c12 int);
+0 rows inserted/updated/deleted
+ij(CONN2)> create table t2 (c21 int generated always as identity (start with 201, increment by 5), c22 int);
+0 rows inserted/updated/deleted
+ij(CONN2)> create trigger t1tr1 after insert on t1 for each row mode db2sql insert into t2 (c22) values (1);
+0 rows inserted/updated/deleted
+ij(CONN2)> values IDENTITY_VAL_LOCAL();
+1                              
+-------------------------------
+201                            
+ij(CONN2)> insert into t1 (c12) values (1);
+1 row inserted/updated/deleted
+ij(CONN2)> -- IDENTITY_VAL_LOCAL will return 101 which got generated for table t1. 
+-- It will not return 201 which got generated for t2 as a result of the trigger fire.
+values IDENTITY_VAL_LOCAL();
+1                              
+-------------------------------
+101                            
+ij(CONN2)> select * from t1;
+C11        |C12        
+-----------------------
+101        |1          
+ij(CONN2)> select * from t2;
+C21        |C22        
+-----------------------
+201        |1          
 ij(CONN2)> drop table t1;
 0 rows inserted/updated/deleted
 ij(CONN2)> drop table t2;

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql?rev=170809&r1=170808&r2=170809&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/autoincrement.sql Wed May 18 13:17:02 2005
@@ -719,6 +719,24 @@
 -- notice that committing the transaction does not affect IDENTITY_VAL_LOCAL()
 commit;
 values IDENTITY_VAL_LOCAL();
+-- notice that rolling the transaction does not affect IDENTITY_VAL_LOCAL()
+values IDENTITY_VAL_LOCAL();
+drop table t1;
+drop table t2;
+
+-- A table with identity column has an insert trigger which inserts into another table 
+-- with identity column. IDENTITY_VAL_LOCAL will return the generated value for the 
+-- statement table and not for the table that got modified by the trigger
+create table t1 (c11 int generated always as identity (start with 101, increment by 3), c12 int);
+create table t2 (c21 int generated always as identity (start with 201, increment by 5), c22 int);
+create trigger t1tr1 after insert on t1 for each row mode db2sql insert into t2 (c22) values (1);
+values IDENTITY_VAL_LOCAL();
+insert into t1 (c12) values (1);
+-- IDENTITY_VAL_LOCAL will return 101 which got generated for table t1. 
+-- It will not return 201 which got generated for t2 as a result of the trigger fire.
+values IDENTITY_VAL_LOCAL();
+select * from t1;
+select * from t2;
 drop table t1;
 drop table t2;