gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

sqlite_go18.go (2443B)


      1 // Copyright 2017 The Sqlite Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 //go:build go1.8
      6 // +build go1.8
      7 
      8 package sqlite // import "modernc.org/sqlite"
      9 
     10 import (
     11 	"context"
     12 	"database/sql/driver"
     13 )
     14 
     15 // Ping implements driver.Pinger
     16 func (c *conn) Ping(ctx context.Context) (err error) {
     17 	if dmesgs {
     18 		defer func() {
     19 			dmesg("conn %p, ctx %p: err %v", c, ctx, err)
     20 		}()
     21 	}
     22 	_, err = c.ExecContext(ctx, "select 1", nil)
     23 	return err
     24 }
     25 
     26 // BeginTx implements driver.ConnBeginTx
     27 func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (dt driver.Tx, err error) {
     28 	if dmesgs {
     29 		defer func() {
     30 			dmesg("conn %p, ctx %p, opts %+v: (driver.Tx %v, err %v)", c, ctx, opts, dt, err)
     31 		}()
     32 	}
     33 	return c.begin(ctx, opts)
     34 }
     35 
     36 // PrepareContext implements driver.ConnPrepareContext
     37 func (c *conn) PrepareContext(ctx context.Context, query string) (ds driver.Stmt, err error) {
     38 	if dmesgs {
     39 		defer func() {
     40 			dmesg("conn %p, ctx %p, query %q: (driver.Stmt %v, err %v)", c, ctx, query, ds, err)
     41 		}()
     42 	}
     43 	return c.prepare(ctx, query)
     44 }
     45 
     46 // ExecContext implements driver.ExecerContext
     47 func (c *conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (dr driver.Result, err error) {
     48 	if dmesgs {
     49 		defer func() {
     50 			dmesg("conn %p, ctx %p, query %q, args %v: (driver.Result %p, err %v)", c, ctx, query, args, dr, err)
     51 		}()
     52 	}
     53 	return c.exec(ctx, query, args)
     54 }
     55 
     56 // QueryContext implements driver.QueryerContext
     57 func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (dr driver.Rows, err error) {
     58 	if dmesgs {
     59 		defer func() {
     60 			dmesg("conn %p, ctx %p, query %q, args %v: (driver.Rows %p, err %v)", c, ctx, query, args, dr, err)
     61 		}()
     62 	}
     63 	return c.query(ctx, query, args)
     64 }
     65 
     66 // ExecContext implements driver.StmtExecContext
     67 func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (dr driver.Result, err error) {
     68 	if dmesgs {
     69 		defer func() {
     70 			dmesg("stmt %p, ctx %p, args %v: (driver.Result %p, err %v)", s, ctx, args, dr, err)
     71 		}()
     72 	}
     73 	return s.exec(ctx, args)
     74 }
     75 
     76 // QueryContext implements driver.StmtQueryContext
     77 func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (dr driver.Rows, err error) {
     78 	if dmesgs {
     79 		defer func() {
     80 			dmesg("stmt %p, ctx %p, args %v: (driver.Rows %p, err %v)", s, ctx, args, dr, err)
     81 		}()
     82 	}
     83 	return s.query(ctx, args)
     84 }