MCPcopy
hub / github.com/autobrr/qui / Tx

Struct Tx

internal/database/db.go:255–267  ·  view source on GitHub ↗

Tx wraps sql.Tx to provide prepared statement caching for transaction queries

Source from the content-addressed store, hash-verified

253
254// Tx wraps sql.Tx to provide prepared statement caching for transaction queries
255type Tx struct {
256 tx *sql.Tx
257 db *DB
258 ctx context.Context // context from BeginTx, used for commit/rollback
259 isWriteTx bool // true if this is a write transaction that needs serialized commit
260 unlockFn func() // function to unlock writerMu when transaction completes (write tx only)
261 unlockOnce sync.Once // ensures unlock happens only once
262
263 // Track statements prepared during this transaction for promotion to DB cache after commit
264 txStmts map[string]struct{} // query -> struct{} (used as set to track which queries to cache)
265 tempTables map[string]struct{} // temp table names created/used in this transaction
266 txMu sync.Mutex // protects transaction-local cache metadata
267}
268
269// markQueryForCaching records a successfully executed query for post-commit
270// statement promotion and tracks temp-table lifecycle within the transaction.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected