2024-05-27 16:46:15 +01:00
|
|
|
package driver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/ncruces/go-sqlite3"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Savepoint establishes a new transaction savepoint.
|
|
|
|
//
|
|
|
|
// https://sqlite.org/lang_savepoint.html
|
|
|
|
func Savepoint(tx *sql.Tx) sqlite3.Savepoint {
|
|
|
|
var ctx saveptCtx
|
|
|
|
tx.ExecContext(&ctx, "")
|
|
|
|
return ctx.Savepoint
|
|
|
|
}
|
|
|
|
|
2024-08-15 01:30:58 +01:00
|
|
|
// A saveptCtx is never canceled, has no values, and has no deadline.
|
2024-05-27 16:46:15 +01:00
|
|
|
type saveptCtx struct{ sqlite3.Savepoint }
|
|
|
|
|
2024-08-15 01:30:58 +01:00
|
|
|
func (*saveptCtx) Deadline() (deadline time.Time, ok bool) {
|
|
|
|
// notest
|
|
|
|
return
|
|
|
|
}
|
2024-05-27 16:46:15 +01:00
|
|
|
|
2024-08-15 01:30:58 +01:00
|
|
|
func (*saveptCtx) Done() <-chan struct{} {
|
|
|
|
// notest
|
|
|
|
return nil
|
|
|
|
}
|
2024-05-27 16:46:15 +01:00
|
|
|
|
2024-08-15 01:30:58 +01:00
|
|
|
func (*saveptCtx) Err() error {
|
|
|
|
// notest
|
|
|
|
return nil
|
|
|
|
}
|
2024-05-27 16:46:15 +01:00
|
|
|
|
2024-08-15 01:30:58 +01:00
|
|
|
func (*saveptCtx) Value(key any) any {
|
|
|
|
// notest
|
|
|
|
return nil
|
|
|
|
}
|