MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / ExecuteTx

Function ExecuteTx

client/tx.go:29–38  ·  view source on GitHub ↗

ExecuteTx starts a transaction, and runs fn in it.

(
	ctx context.Context, db *sql.DB, txopts *sql.TxOptions, fn func(*sql.Tx) error,
)

Source from the content-addressed store, hash-verified

27
28// ExecuteTx starts a transaction, and runs fn in it.
29func ExecuteTx(
30 ctx context.Context, db *sql.DB, txopts *sql.TxOptions, fn func(*sql.Tx) error,
31) error {
32 // Start a transaction.
33 tx, err := db.BeginTx(ctx, txopts)
34 if err != nil {
35 return err
36 }
37 return ExecuteInTx(tx, func() error { return fn(tx) })
38}
39
40// ExecuteInTx runs fn inside tx which should already have begun.
41func ExecuteInTx(tx driver.Tx, fn func() error) (err error) {

Callers 6

SetattrMethod · 0.92
WriteMethod · 0.92
createMethod · 0.92
removeMethod · 0.92
renameMethod · 0.92
TestStmtFunction · 0.85

Calls 2

ExecuteInTxFunction · 0.85
BeginTxMethod · 0.80

Tested by 1

TestStmtFunction · 0.68