• Welcome to SQLitening Support Forum.
 

News:

Welcome to the SQLitening support forums!

Main Menu

Wait if all transaction are read-only?

Started by mikedoty, September 12, 2007, 10:03:07 AM

Previous topic - Next topic

mikedoty

Is a transaction held before passing to sqlite if all transactions before it are read-only transactions?
Is there even a pragma for opening a database in exclusive mode?

Paul Squires

Do you mean that you are issuing an "BEGIN" transaction, then performing additional sql statements? It is my understanding that a transaction remains open when the "BEGIN" is issued until the final "COMMIT" is issued. If no "COMMIT" is issued then sql3server will issue a "COMMIT" before it closes the database on exit.

Having said that, the "Definitive Guide (page 147)" states that ALL Sqlite statements are implicitly wrapped in transactions if no explicit BEGIN/COMMIT pair is given. I guess the only real downside to this is that a transaction is opened/closed for every individual sql statement whereas if you send a block of statements with an explicit starting "BEGIN" and an ending "COMMIT" then all of those statements will exist within the one transaction. May be a little bit of a performance gain?

I am not sure if there is a pragma for exclusive mode but maybe it is not needed anyway because the database is always put into exclusive lock mode prior to any writes.
Paul Squires <br />http://www.planetsquires.com<br />support@planetsquires.com

mikedoty

Sorry, I was mistaken in thinking your code held transactions before passing to SQLite.