From 755d5be32c971580a8ae5ed32a6bd5ff774d722d Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 4 Nov 2016 15:15:16 +0900 Subject: [PATCH] add BeginContext --- sqlite3.go | 4 ++++ sqlite3_go18.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sqlite3.go b/sqlite3.go index bef5627..cf5e99a 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -514,6 +514,10 @@ func (c *SQLiteConn) execQuery(cmd string) (driver.Result, error) { // Begin transaction. func (c *SQLiteConn) Begin() (driver.Tx, error) { + return c.begin(context.Background()) +} + +func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) { if _, err := c.execQuery(c.txlock); err != nil { return nil, err } diff --git a/sqlite3_go18.go b/sqlite3_go18.go index 5832a92..7109d58 100644 --- a/sqlite3_go18.go +++ b/sqlite3_go18.go @@ -37,6 +37,10 @@ func (c *SQLiteConn) PrepareContext(ctx context.Context, query string) (driver.S return c.prepare(ctx, query) } +func (c *SQLiteConn) BeginContext(ctx context.Context) (driver.Tx, error) { + return c.begin(ctx) +} + func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) { list := make([]namedValue, len(args)) for i, nv := range args {