On Mon, 12 Aug 2019 at 16:55, Kira Backes <kira.bac...@nrwsoft.de> wrote:
> > When you do not use explicit transactions, SQLite will automatically > create implicit transactions. > > But the documentation only says that an implicit transaction is > created for data-changing queries like INSERT: > > https://www.sqlite.org/lang_transaction.html > > > Any command that changes the database (basically, any SQL command other > than SELECT) will automatically start a transaction if one is not already > in effect > Yeah I see what you mean... That sentence should not be taken in isolation, but I agree it's misleading! It's clarified a few paragraphs down (after noting that a "deferred" transaction is the default mode of operation): Thus with a deferred transaction, the BEGIN statement itself does nothing > to the filesystem. Locks are not acquired until the first read or write > operation. The first read operation against a database creates a SHARED > <https://www.sqlite.org/lockingv3.html#shared_lock> lock and the first > write operation creates a RESERVED > <https://www.sqlite.org/lockingv3.html#reserved_lock> lock. > I think the initial statement should read: "Any command that changes or reads the database will automatically start a transaction if one is not already in effect" Because the actual SQL command is irrelevant -- you can still run INSERT/CREATE or other queries which represent write operations on a database which is EXCLUSIVELY locked by another process, as long as the query only involves temporary tables (which is kind of a cop-out because such queries don't have to touch the database, but it just further highlights the fact that DB access/modification is the crucial component and not the SQL command). Btw your original comment said "as far as I can tell this is not documented anywhere," but the behaviour is unsurprising after understanding sqlite's locking model, which is documented here: https://www.sqlite.org/lockingv3.html -Rowan _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users