On 13 Apr 2017, at 6:51pm, Keith Medcalf <kmedc...@dessus.com> wrote:

> The only real problem I see with SQLite3's implementation of SAVEPOINT is 
> that if you issue SAVEPOINT outside of a transaction (ie, when in autocommit 
> mode) it should throw an error, not start a transaction for you.

A question on this list a few months ago prompted me to look up how 
transactions were originally intended to work.

Originally, the specs said that if you issued a SQL command and hadn’t already 
executed BEGIN, you’d get an error back complaining that you’d tried to execute 
a command outside a transaction.

Early implementations ignored this and if you executed a command outside a 
transaction they’d issue a BEGIN for you.  However, they would not execute a 
COMMIT !  So if you just issued a stream of SQL commands then closed the 
connection, nothing would be committed.  Documentation on this was spotty, 
since everyone assumed that you would be issuing a BEGIN, and the problem 
should hardly ever occur.  Instead it mostly appeared as a FAQ: "My commands 
are accepted without errors, but nothing in the database changes.  They’re 
obviously being processed because if I get entity names wrong I get an error 
message.  What am I doing wrong ?".

SQLite goes further: as well as doing the BEGIN it does the COMMIT.  So instead 
of a FAQ we get a bunch of users who have never issued BEGIN or COMMIT and have 
no idea what they’re for.

My conclusion is that in all those implementations issuing SAVEPOINT outside a 
transaction is always wrong.

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

Reply via email to