feat(agentcompat): add SQLite hold scoped attribution

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
naiba
2026-07-20 04:29:21 +00:00
co-authored by naiba/CloudCode
parent 26e92da33b
commit 0c6eb416a5
39 changed files with 5527 additions and 6 deletions
@@ -0,0 +1,52 @@
//go:build agentcompat && linux
package singleton
import (
"context"
"database/sql/driver"
"errors"
)
func (connection *sqliteAttributionConnection) Exec(query string, values []driver.Value) (driver.Result, error) {
statement, err := connection.Prepare(query)
if err != nil {
return nil, err
}
defer statement.Close()
return statement.Exec(values)
}
func (connection *sqliteAttributionConnection) ExecContext(ctx context.Context, query string, values []driver.NamedValue) (driver.Result, error) {
statement, err := connection.PrepareContext(ctx, query)
if err != nil {
return nil, err
}
defer statement.Close()
return statement.(driver.StmtExecContext).ExecContext(ctx, values)
}
func (connection *sqliteAttributionConnection) Query(query string, values []driver.Value) (driver.Rows, error) {
statement, err := connection.Prepare(query)
if err != nil {
return nil, err
}
wrapped := statement.(*sqliteAttributionStatement)
return wrapped.queryOwned(func() (driver.Rows, error) { return wrapped.statement.Query(values) }, statement)
}
func (connection *sqliteAttributionConnection) QueryContext(ctx context.Context, query string, values []driver.NamedValue) (driver.Rows, error) {
statement, err := connection.PrepareContext(ctx, query)
if err != nil {
return nil, err
}
return connection.queryContextStatement(ctx, statement.(*sqliteAttributionStatement), values, statement)
}
func (connection *sqliteAttributionConnection) queryContextStatement(ctx context.Context, statement *sqliteAttributionStatement, values []driver.NamedValue, owner driver.Stmt) (driver.Rows, error) {
contextStatement, ok := statement.statement.(driver.StmtQueryContext)
if !ok {
return nil, errors.Join(driver.ErrSkip, owner.Close())
}
return statement.queryOwned(func() (driver.Rows, error) { return contextStatement.QueryContext(ctx, values) }, owner)
}