|
I thought Derby uses nested user transaction to commit generated
identity values, to avoid holding locks. See getSetAutoincrementValue()
in org/apache/derby/impl/sql/execute/InsertResultSet.java. I tried the
following using IJ, using default isolation levels. I couldn't
see the problem. Satheesh ij> create table auto(i int generated always as identity, j int, k int); 0 rows inserted/updated/deleted ij> insert into auto(j, k) values (1,1); 1 row inserted/updated/deleted ij> select * from auto; I |J |K ----------------------------------- 1 |1 |1 1 row selected ij> autocommit off; <<<<<<<<<<<<< Start a transaction on CONNECTION0 ij> insert into auto(j, k) values (2,2); 1 row inserted/updated/deleted ij> select * from auto; I |J |K ----------------------------------- 1 |1 |1 2 |2 |2 2 rows selected ij> connect 'tdb'; <<<<<<<<<<<<<<<< Get a second connection, CONNECTION1 ij(CONNECTION1)> insert into auto(j, k) values (3,3); 1 row inserted/updated/deleted ij(CONNECTION1)> select * from auto with UR; <<<<==== Use Uncommitted read isolation. I |J |K <<<<===== Would block otherwise. ----------------------------------- 1 |1 |1 2 |2 |2 3 |3 |3 3 rows selected ij(CONNECTION1)> commit; ij(CONNECTION1)> set connection connection0; <<<<<<<<==== Switch back to CONNECTION0 ij(CONNECTION0)> select * from auto; I |J |K ----------------------------------- 1 |1 |1 2 |2 |2 3 |3 |3 3 rows selected ij(CONNECTION0)> commit; <<<<<<<<<<<<<<=== == COMMIT. ij(CONNECTION0)> select * from auto; I |J |K ----------------------------------- 1 |1 |1 2 |2 |2 3 |3 |3 3 rows selected ij(CONNECTION0)> Craig Russell wrote:
|
- Re: Auto generation of database keys TomohitoNakayama
- Re: Auto generation of database keys Mike Matrigali
- Re: Auto generation of database keys TomohitoNakayama
- Re: Fwd: Auto generation of database keys Satheesh Bandaram
- Re: Fwd: Auto generation of database keys Mike Matrigali
- Re: Fwd: Auto generation of database keys Sunitha Kambhampati
- Re: Fwd: Auto generation of database keys Mike Matrigali
- Re: Auto generation of database keys Craig Russell
- Re: Auto generation of database keys TomohitoNakayama
