Transactions

Description

These are ordinary SQLite transactions, and they are **not** Dolt commits.

Usage

## S4 method for signature 'DoltliteConnection'
dbBegin(conn, ...)

## S4 method for signature 'DoltliteConnection'
dbCommit(conn, ...)

## S4 method for signature 'DoltliteConnection'
dbRollback(conn, ...)

Arguments

Details

'dbBegin()' / 'dbCommit()' / 'dbRollback()' group statements so that they either all take effect or none do. That is a property of the *working set*: after 'dbCommit()' the rows are in the database, but they are still uncommitted from Dolt's point of view and will show up in [dolt_status()].

[dolt_commit()] is the other kind of commit: it writes a new, content-addressed commit into the version history, the way 'git commit' does. Nothing is recorded in the history until you call it.

A useful mental model: 'dbCommit()' is "save the file", 'dolt_commit()' is "commit to the repository".

Calling [dolt_commit()] inside a 'dbBegin()' block records the commit and **leaves the transaction open**: you began it, so you finish it with 'dbCommit()' or 'dbRollback()'. The Dolt commit is durable as soon as 'dolt_commit()' returns, so a rollback at that point does not undo it.

DoltLite 0.50 behaved differently, ending the enclosing transaction as a side effect of 'dolt_commit()' and of a clean merge; 0.51 leaves it open. This backend reopens a transaction the engine closed, so the behaviour above holds on every version.

Note that DoltLite permits one durable writer at a time. A second connection that begins a write transaction gets 'SQLITE_BUSY' until the first finishes; see the 'busy_timeout' argument to [DBI::dbConnect()].