MCPcopy Create free account
hub / github.com/daodst/chat / EndTransaction

Function EndTransaction

internal/sqlutil/sql.go:42–48  ·  view source on GitHub ↗

EndTransaction ends a transaction. If the transaction succeeded then it is committed, otherwise it is rolledback. You MUST check the error returned from this function to be sure that the transaction was applied correctly. For example, 'database is locked' errors in sqlite will happen here.

(txn Transaction, succeeded *bool)

Source from the content-addressed store, hash-verified

40// You MUST check the error returned from this function to be sure that the transaction
41// was applied correctly. For example, 'database is locked' errors in sqlite will happen here.
42func EndTransaction(txn Transaction, succeeded *bool) error {
43 if *succeeded {
44 return txn.Commit()
45 } else {
46 return txn.Rollback()
47 }
48}
49
50// EndTransactionWithCheck ends a transaction and overwrites the error pointer if its value was nil.
51// If the transaction succeeded then it is committed, otherwise it is rolledback.

Callers 1

EndTransactionWithCheckFunction · 0.85

Calls 2

CommitMethod · 0.65
RollbackMethod · 0.65

Tested by

no test coverage detected