diff options
author | Jan Mercl <0xjnml@gmail.com> | 2019-12-31 16:46:08 +0100 |
---|---|---|
committer | Jan Mercl <0xjnml@gmail.com> | 2019-12-31 16:46:08 +0100 |
commit | ef38ac9c3be91d0b0c15bdcfa89e0469f7150ba0 (patch) | |
tree | 6917153245d6dceb223350fa0e37d73484dbaacc /sqlite_go18.go | |
parent | ea2990f2041f1564cf05b1e6510bdae19f2f25ff (diff) |
use sqlite3_unlock_notify, fixes #20.
Diffstat (limited to 'sqlite_go18.go')
-rw-r--r-- | sqlite_go18.go | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/sqlite_go18.go b/sqlite_go18.go index 75d926c..74b3e9d 100644 --- a/sqlite_go18.go +++ b/sqlite_go18.go @@ -9,28 +9,17 @@ package sqlite // import "modernc.org/sqlite" import ( "context" "database/sql/driver" - "errors" ) // Ping implements driver.Pinger func (c *conn) Ping(ctx context.Context) error { - c.Lock() - defer c.Unlock() - - if c.ppdb == 0 { - return errors.New("db is closed") - } - _, err := c.ExecContext(ctx, "select 1", nil) return err } // BeginTx implements driver.ConnBeginTx func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { - return c.begin(ctx, txOptions{ - Isolation: int(opts.Isolation), - ReadOnly: opts.ReadOnly, - }) + return c.begin(ctx, opts) } // PrepareContext implements driver.ConnPrepareContext @@ -40,29 +29,20 @@ func (c *conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, e // ExecContext implements driver.ExecerContext func (c *conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) { - return c.exec(ctx, query, toNamedValues2(args)) + return c.exec(ctx, query, args) } // QueryContext implements driver.QueryerContext func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) { - return c.query(ctx, query, toNamedValues2(args)) + return c.query(ctx, query, args) } // ExecContext implements driver.StmtExecContext func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) { - return s.exec(ctx, toNamedValues2(args)) + return s.exec(ctx, args) } // QueryContext implements driver.StmtQueryContext func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) { - return s.query(ctx, toNamedValues2(args)) -} - -// converts []driver.NamedValue to []namedValue -func toNamedValues2(vals []driver.NamedValue) []namedValue { - args := make([]namedValue, 0, len(vals)) - for _, val := range vals { - args = append(args, namedValue(val)) - } - return args + return s.query(ctx, args) } |