On 17 Sep 2012, at 7:23am, Sven Bloesl <sven.blo...@bayer.com> wrote:

> BEGIN IMMEDIATE
> 
> SAVEPOINT SP1
> CREATE TABLE a(key number primary key);
> 
> SAVEPOINT SP2
> INSERT INTO a VALUES(666);
> SELECT count(1) FROM a               Expected: 1, Got: 1
> 
> SAVEPOINT SP3
> INSERT INTO a VALUES(13);
> SELECT count(1) FROM a               Expected: 2, Got: 2
> 
> ROLLBACK TRANSACTION TO SP3
> SELECT count(1) FROM a               Expected: 1, Got: 2
> 
> If I rollback to SP1 instead the last select throws as expected an exception, 
>  since the table vanished.
> Has anyone an idea, what I'm doeing wrong or is this a bug?

I just tried this with the SQLite shell and it worked as you expected:

dyn-171-250:~ simon$ sqlite3 ~/Desktop/fred.q
SQLite version 3.7.12 2012-04-03 19:43:07
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> BEGIN IMMEDIATE;
sqlite> SAVEPOINT SP1;
sqlite> CREATE TABLE a(key number primary key);
sqlite> SAVEPOINT SP2;
sqlite> INSERT INTO a VALUES(666);
sqlite> SELECT count(1) FROM a;
1
sqlite> SAVEPOINT SP3;
sqlite> INSERT INTO a VALUES(13);
sqlite> SELECT count(1) FROM a;
2
sqlite> ROLLBACK TRANSACTION TO SP3;
sqlite> SELECT count(1) FROM a;
1
sqlite> 

I'm wondering whether your API is creating different contexts (connections ?) 
for each individual statement.  But that would mean that all BEGIN and 
SAVEPOINT statements would be pointless and surely something like that would be 
in its documentation.  Can anyone think of a quick way to check whether each 
statement is being executed by a separate context ?

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to