You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2015/11/21 01:42:59 UTC
[34/42] incubator-mynewt-newt git commit: Move newt source into a
"newt" subdirectory.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3.go b/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3.go
deleted file mode 100644
index 233e7e9..0000000
--- a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3.go
+++ /dev/null
@@ -1,675 +0,0 @@
-// Copyright (C) 2014 Yasuhiro Matsumoto <ma...@gmail.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-
-package sqlite3
-
-/*
-#cgo CFLAGS: -std=gnu99
-#cgo CFLAGS: -DSQLITE_ENABLE_RTREE -DSQLITE_THREADSAFE
-#cgo CFLAGS: -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS
-#include <sqlite3-binding.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef __CYGWIN__
-# include <errno.h>
-#endif
-
-#ifndef SQLITE_OPEN_READWRITE
-# define SQLITE_OPEN_READWRITE 0
-#endif
-
-#ifndef SQLITE_OPEN_FULLMUTEX
-# define SQLITE_OPEN_FULLMUTEX 0
-#endif
-
-static int
-_sqlite3_open_v2(const char *filename, sqlite3 **ppDb, int flags, const char *zVfs) {
-#ifdef SQLITE_OPEN_URI
- return sqlite3_open_v2(filename, ppDb, flags | SQLITE_OPEN_URI, zVfs);
-#else
- return sqlite3_open_v2(filename, ppDb, flags, zVfs);
-#endif
-}
-
-static int
-_sqlite3_bind_text(sqlite3_stmt *stmt, int n, char *p, int np) {
- return sqlite3_bind_text(stmt, n, p, np, SQLITE_TRANSIENT);
-}
-
-static int
-_sqlite3_bind_blob(sqlite3_stmt *stmt, int n, void *p, int np) {
- return sqlite3_bind_blob(stmt, n, p, np, SQLITE_TRANSIENT);
-}
-
-#include <stdio.h>
-#include <stdint.h>
-
-static int
-_sqlite3_exec(sqlite3* db, const char* pcmd, long* rowid, long* changes)
-{
- int rv = sqlite3_exec(db, pcmd, 0, 0, 0);
- *rowid = (long) sqlite3_last_insert_rowid(db);
- *changes = (long) sqlite3_changes(db);
- return rv;
-}
-
-static int
-_sqlite3_step(sqlite3_stmt* stmt, long* rowid, long* changes)
-{
- int rv = sqlite3_step(stmt);
- sqlite3* db = sqlite3_db_handle(stmt);
- *rowid = (long) sqlite3_last_insert_rowid(db);
- *changes = (long) sqlite3_changes(db);
- return rv;
-}
-
-*/
-import "C"
-import (
- "database/sql"
- "database/sql/driver"
- "errors"
- "fmt"
- "io"
- "net/url"
- "runtime"
- "strconv"
- "strings"
- "time"
- "unsafe"
-)
-
-// Timestamp formats understood by both this module and SQLite.
-// The first format in the slice will be used when saving time values
-// into the database. When parsing a string from a timestamp or
-// datetime column, the formats are tried in order.
-var SQLiteTimestampFormats = []string{
- "2006-01-02 15:04:05.999999999",
- "2006-01-02T15:04:05.999999999",
- "2006-01-02 15:04:05",
- "2006-01-02T15:04:05",
- "2006-01-02 15:04",
- "2006-01-02T15:04",
- "2006-01-02",
- "2006-01-02 15:04:05-07:00",
-}
-
-func init() {
- sql.Register("sqlite3", &SQLiteDriver{})
-}
-
-// Return SQLite library Version information.
-func Version() (libVersion string, libVersionNumber int, sourceId string) {
- libVersion = C.GoString(C.sqlite3_libversion())
- libVersionNumber = int(C.sqlite3_libversion_number())
- sourceId = C.GoString(C.sqlite3_sourceid())
- return libVersion, libVersionNumber, sourceId
-}
-
-// Driver struct.
-type SQLiteDriver struct {
- Extensions []string
- ConnectHook func(*SQLiteConn) error
-}
-
-// Conn struct.
-type SQLiteConn struct {
- db *C.sqlite3
- loc *time.Location
- txlock string
-}
-
-// Tx struct.
-type SQLiteTx struct {
- c *SQLiteConn
-}
-
-// Stmt struct.
-type SQLiteStmt struct {
- c *SQLiteConn
- s *C.sqlite3_stmt
- nv int
- nn []string
- t string
- closed bool
- cls bool
-}
-
-// Result struct.
-type SQLiteResult struct {
- id int64
- changes int64
-}
-
-// Rows struct.
-type SQLiteRows struct {
- s *SQLiteStmt
- nc int
- cols []string
- decltype []string
- cls bool
-}
-
-// Commit transaction.
-func (tx *SQLiteTx) Commit() error {
- _, err := tx.c.exec("COMMIT")
- return err
-}
-
-// Rollback transaction.
-func (tx *SQLiteTx) Rollback() error {
- _, err := tx.c.exec("ROLLBACK")
- return err
-}
-
-// AutoCommit return which currently auto commit or not.
-func (c *SQLiteConn) AutoCommit() bool {
- return int(C.sqlite3_get_autocommit(c.db)) != 0
-}
-
-func (c *SQLiteConn) lastError() Error {
- return Error{
- Code: ErrNo(C.sqlite3_errcode(c.db)),
- ExtendedCode: ErrNoExtended(C.sqlite3_extended_errcode(c.db)),
- err: C.GoString(C.sqlite3_errmsg(c.db)),
- }
-}
-
-// Implements Execer
-func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, error) {
- if len(args) == 0 {
- return c.exec(query)
- }
-
- for {
- s, err := c.Prepare(query)
- if err != nil {
- return nil, err
- }
- var res driver.Result
- if s.(*SQLiteStmt).s != nil {
- na := s.NumInput()
- if len(args) < na {
- return nil, fmt.Errorf("Not enough args to execute query. Expected %d, got %d.", na, len(args))
- }
- res, err = s.Exec(args[:na])
- if err != nil && err != driver.ErrSkip {
- s.Close()
- return nil, err
- }
- args = args[na:]
- }
- tail := s.(*SQLiteStmt).t
- s.Close()
- if tail == "" {
- return res, nil
- }
- query = tail
- }
-}
-
-// Implements Queryer
-func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, error) {
- for {
- s, err := c.Prepare(query)
- if err != nil {
- return nil, err
- }
- s.(*SQLiteStmt).cls = true
- na := s.NumInput()
- if len(args) < na {
- return nil, fmt.Errorf("Not enough args to execute query. Expected %d, got %d.", na, len(args))
- }
- rows, err := s.Query(args[:na])
- if err != nil && err != driver.ErrSkip {
- s.Close()
- return nil, err
- }
- args = args[na:]
- tail := s.(*SQLiteStmt).t
- if tail == "" {
- return rows, nil
- }
- rows.Close()
- s.Close()
- query = tail
- }
-}
-
-func (c *SQLiteConn) exec(cmd string) (driver.Result, error) {
- pcmd := C.CString(cmd)
- defer C.free(unsafe.Pointer(pcmd))
-
- var rowid, changes C.long
- rv := C._sqlite3_exec(c.db, pcmd, &rowid, &changes)
- if rv != C.SQLITE_OK {
- return nil, c.lastError()
- }
- return &SQLiteResult{int64(rowid), int64(changes)}, nil
-}
-
-// Begin transaction.
-func (c *SQLiteConn) Begin() (driver.Tx, error) {
- if _, err := c.exec(c.txlock); err != nil {
- return nil, err
- }
- return &SQLiteTx{c}, nil
-}
-
-func errorString(err Error) string {
- return C.GoString(C.sqlite3_errstr(C.int(err.Code)))
-}
-
-// Open database and return a new connection.
-// You can specify DSN string with URI filename.
-// test.db
-// file:test.db?cache=shared&mode=memory
-// :memory:
-// file::memory:
-// go-sqlite handle especially query parameters.
-// _loc=XXX
-// Specify location of time format. It's possible to specify "auto".
-// _busy_timeout=XXX
-// Specify value for sqlite3_busy_timeout.
-// _txlock=XXX
-// Specify locking behavior for transactions. XXX can be "immediate",
-// "deferred", "exclusive".
-func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
- if C.sqlite3_threadsafe() == 0 {
- return nil, errors.New("sqlite library was not compiled for thread-safe operation")
- }
-
- var loc *time.Location
- txlock := "BEGIN"
- busy_timeout := 5000
- pos := strings.IndexRune(dsn, '?')
- if pos >= 1 {
- params, err := url.ParseQuery(dsn[pos+1:])
- if err != nil {
- return nil, err
- }
-
- // _loc
- if val := params.Get("_loc"); val != "" {
- if val == "auto" {
- loc = time.Local
- } else {
- loc, err = time.LoadLocation(val)
- if err != nil {
- return nil, fmt.Errorf("Invalid _loc: %v: %v", val, err)
- }
- }
- }
-
- // _busy_timeout
- if val := params.Get("_busy_timeout"); val != "" {
- iv, err := strconv.ParseInt(val, 10, 64)
- if err != nil {
- return nil, fmt.Errorf("Invalid _busy_timeout: %v: %v", val, err)
- }
- busy_timeout = int(iv)
- }
-
- // _txlock
- if val := params.Get("_txlock"); val != "" {
- switch val {
- case "immediate":
- txlock = "BEGIN IMMEDIATE"
- case "exclusive":
- txlock = "BEGIN EXCLUSIVE"
- case "deferred":
- txlock = "BEGIN"
- default:
- return nil, fmt.Errorf("Invalid _txlock: %v", val)
- }
- }
-
- if !strings.HasPrefix(dsn, "file:") {
- dsn = dsn[:pos]
- }
- }
-
- var db *C.sqlite3
- name := C.CString(dsn)
- defer C.free(unsafe.Pointer(name))
- rv := C._sqlite3_open_v2(name, &db,
- C.SQLITE_OPEN_FULLMUTEX|
- C.SQLITE_OPEN_READWRITE|
- C.SQLITE_OPEN_CREATE,
- nil)
- if rv != 0 {
- return nil, Error{Code: ErrNo(rv)}
- }
- if db == nil {
- return nil, errors.New("sqlite succeeded without returning a database")
- }
-
- rv = C.sqlite3_busy_timeout(db, C.int(busy_timeout))
- if rv != C.SQLITE_OK {
- return nil, Error{Code: ErrNo(rv)}
- }
-
- conn := &SQLiteConn{db: db, loc: loc, txlock: txlock}
-
- if len(d.Extensions) > 0 {
- rv = C.sqlite3_enable_load_extension(db, 1)
- if rv != C.SQLITE_OK {
- return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
- }
-
- for _, extension := range d.Extensions {
- cext := C.CString(extension)
- defer C.free(unsafe.Pointer(cext))
- rv = C.sqlite3_load_extension(db, cext, nil, nil)
- if rv != C.SQLITE_OK {
- return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
- }
- }
-
- rv = C.sqlite3_enable_load_extension(db, 0)
- if rv != C.SQLITE_OK {
- return nil, errors.New(C.GoString(C.sqlite3_errmsg(db)))
- }
- }
-
- if d.ConnectHook != nil {
- if err := d.ConnectHook(conn); err != nil {
- return nil, err
- }
- }
- runtime.SetFinalizer(conn, (*SQLiteConn).Close)
- return conn, nil
-}
-
-// Close the connection.
-func (c *SQLiteConn) Close() error {
- rv := C.sqlite3_close_v2(c.db)
- if rv != C.SQLITE_OK {
- return c.lastError()
- }
- c.db = nil
- runtime.SetFinalizer(c, nil)
- return nil
-}
-
-// Prepare query string. Return a new statement.
-func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error) {
- pquery := C.CString(query)
- defer C.free(unsafe.Pointer(pquery))
- var s *C.sqlite3_stmt
- var tail *C.char
- rv := C.sqlite3_prepare_v2(c.db, pquery, -1, &s, &tail)
- if rv != C.SQLITE_OK {
- return nil, c.lastError()
- }
- var t string
- if tail != nil && *tail != '\000' {
- t = strings.TrimSpace(C.GoString(tail))
- }
- nv := int(C.sqlite3_bind_parameter_count(s))
- var nn []string
- for i := 0; i < nv; i++ {
- pn := C.GoString(C.sqlite3_bind_parameter_name(s, C.int(i+1)))
- if len(pn) > 1 && pn[0] == '$' && 48 <= pn[1] && pn[1] <= 57 {
- nn = append(nn, C.GoString(C.sqlite3_bind_parameter_name(s, C.int(i+1))))
- }
- }
- ss := &SQLiteStmt{c: c, s: s, nv: nv, nn: nn, t: t}
- runtime.SetFinalizer(ss, (*SQLiteStmt).Close)
- return ss, nil
-}
-
-// Close the statement.
-func (s *SQLiteStmt) Close() error {
- if s.closed {
- return nil
- }
- s.closed = true
- if s.c == nil || s.c.db == nil {
- return errors.New("sqlite statement with already closed database connection")
- }
- rv := C.sqlite3_finalize(s.s)
- if rv != C.SQLITE_OK {
- return s.c.lastError()
- }
- runtime.SetFinalizer(s, nil)
- return nil
-}
-
-// Return a number of parameters.
-func (s *SQLiteStmt) NumInput() int {
- return s.nv
-}
-
-type bindArg struct {
- n int
- v driver.Value
-}
-
-func (s *SQLiteStmt) bind(args []driver.Value) error {
- rv := C.sqlite3_reset(s.s)
- if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
- return s.c.lastError()
- }
-
- var vargs []bindArg
- narg := len(args)
- vargs = make([]bindArg, narg)
- if len(s.nn) > 0 {
- for i, v := range s.nn {
- if pi, err := strconv.Atoi(v[1:]); err == nil {
- vargs[i] = bindArg{pi, args[i]}
- }
- }
- } else {
- for i, v := range args {
- vargs[i] = bindArg{i + 1, v}
- }
- }
-
- for _, varg := range vargs {
- n := C.int(varg.n)
- v := varg.v
- switch v := v.(type) {
- case nil:
- rv = C.sqlite3_bind_null(s.s, n)
- case string:
- if len(v) == 0 {
- b := []byte{0}
- rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(0))
- } else {
- b := []byte(v)
- rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))
- }
- case int64:
- rv = C.sqlite3_bind_int64(s.s, n, C.sqlite3_int64(v))
- case bool:
- if bool(v) {
- rv = C.sqlite3_bind_int(s.s, n, 1)
- } else {
- rv = C.sqlite3_bind_int(s.s, n, 0)
- }
- case float64:
- rv = C.sqlite3_bind_double(s.s, n, C.double(v))
- case []byte:
- var p *byte
- if len(v) > 0 {
- p = &v[0]
- }
- rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(p), C.int(len(v)))
- case time.Time:
- b := []byte(v.UTC().Format(SQLiteTimestampFormats[0]))
- rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))
- }
- if rv != C.SQLITE_OK {
- return s.c.lastError()
- }
- }
- return nil
-}
-
-// Query the statement with arguments. Return records.
-func (s *SQLiteStmt) Query(args []driver.Value) (driver.Rows, error) {
- if err := s.bind(args); err != nil {
- return nil, err
- }
- return &SQLiteRows{s, int(C.sqlite3_column_count(s.s)), nil, nil, s.cls}, nil
-}
-
-// Return last inserted ID.
-func (r *SQLiteResult) LastInsertId() (int64, error) {
- return r.id, nil
-}
-
-// Return how many rows affected.
-func (r *SQLiteResult) RowsAffected() (int64, error) {
- return r.changes, nil
-}
-
-// Execute the statement with arguments. Return result object.
-func (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
- if err := s.bind(args); err != nil {
- C.sqlite3_reset(s.s)
- C.sqlite3_clear_bindings(s.s)
- return nil, err
- }
- var rowid, changes C.long
- rv := C._sqlite3_step(s.s, &rowid, &changes)
- if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
- err := s.c.lastError()
- C.sqlite3_reset(s.s)
- C.sqlite3_clear_bindings(s.s)
- return nil, err
- }
- return &SQLiteResult{int64(rowid), int64(changes)}, nil
-}
-
-// Close the rows.
-func (rc *SQLiteRows) Close() error {
- if rc.s.closed {
- return nil
- }
- if rc.cls {
- return rc.s.Close()
- }
- rv := C.sqlite3_reset(rc.s.s)
- if rv != C.SQLITE_OK {
- return rc.s.c.lastError()
- }
- return nil
-}
-
-// Return column names.
-func (rc *SQLiteRows) Columns() []string {
- if rc.nc != len(rc.cols) {
- rc.cols = make([]string, rc.nc)
- for i := 0; i < rc.nc; i++ {
- rc.cols[i] = C.GoString(C.sqlite3_column_name(rc.s.s, C.int(i)))
- }
- }
- return rc.cols
-}
-
-// Move cursor to next.
-func (rc *SQLiteRows) Next(dest []driver.Value) error {
- rv := C.sqlite3_step(rc.s.s)
- if rv == C.SQLITE_DONE {
- return io.EOF
- }
- if rv != C.SQLITE_ROW {
- rv = C.sqlite3_reset(rc.s.s)
- if rv != C.SQLITE_OK {
- return rc.s.c.lastError()
- }
- return nil
- }
-
- if rc.decltype == nil {
- rc.decltype = make([]string, rc.nc)
- for i := 0; i < rc.nc; i++ {
- rc.decltype[i] = strings.ToLower(C.GoString(C.sqlite3_column_decltype(rc.s.s, C.int(i))))
- }
- }
-
- for i := range dest {
- switch C.sqlite3_column_type(rc.s.s, C.int(i)) {
- case C.SQLITE_INTEGER:
- val := int64(C.sqlite3_column_int64(rc.s.s, C.int(i)))
- switch rc.decltype[i] {
- case "timestamp", "datetime", "date":
- unixTimestamp := strconv.FormatInt(val, 10)
- var t time.Time
- if len(unixTimestamp) == 13 {
- duration, err := time.ParseDuration(unixTimestamp + "ms")
- if err != nil {
- return fmt.Errorf("error parsing %s value %d, %s", rc.decltype[i], val, err)
- }
- epoch := time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)
- t = epoch.Add(duration)
- } else {
- t = time.Unix(val, 0)
- }
- if rc.s.c.loc != nil {
- t = t.In(rc.s.c.loc)
- }
- dest[i] = t
- case "boolean":
- dest[i] = val > 0
- default:
- dest[i] = val
- }
- case C.SQLITE_FLOAT:
- dest[i] = float64(C.sqlite3_column_double(rc.s.s, C.int(i)))
- case C.SQLITE_BLOB:
- p := C.sqlite3_column_blob(rc.s.s, C.int(i))
- if p == nil {
- dest[i] = nil
- continue
- }
- n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i)))
- switch dest[i].(type) {
- case sql.RawBytes:
- dest[i] = (*[1 << 30]byte)(unsafe.Pointer(p))[0:n]
- default:
- slice := make([]byte, n)
- copy(slice[:], (*[1 << 30]byte)(unsafe.Pointer(p))[0:n])
- dest[i] = slice
- }
- case C.SQLITE_NULL:
- dest[i] = nil
- case C.SQLITE_TEXT:
- var err error
- var timeVal time.Time
-
- n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i)))
- s := C.GoStringN((*C.char)(unsafe.Pointer(C.sqlite3_column_text(rc.s.s, C.int(i)))), C.int(n))
-
- switch rc.decltype[i] {
- case "timestamp", "datetime", "date":
- var t time.Time
- s = strings.TrimSuffix(s, "Z")
- for _, format := range SQLiteTimestampFormats {
- if timeVal, err = time.ParseInLocation(format, s, time.UTC); err == nil {
- t = timeVal
- break
- }
- }
- if err != nil {
- // The column is a time value, so return the zero time on parse failure.
- t = time.Time{}
- }
- if rc.s.c.loc != nil {
- t = t.In(rc.s.c.loc)
- }
- dest[i] = t
- default:
- dest[i] = []byte(s)
- }
-
- }
- }
- return nil
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_fts3_test.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_fts3_test.go b/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_fts3_test.go
deleted file mode 100644
index a1cd217..0000000
--- a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_fts3_test.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (C) 2015 Yasuhiro Matsumoto <ma...@gmail.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-
-package sqlite3
-
-import (
- "database/sql"
- "os"
- "testing"
-)
-
-func TestFTS3(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("DROP TABLE foo")
- _, err = db.Exec("CREATE VIRTUAL TABLE foo USING fts3(id INTEGER PRIMARY KEY, value TEXT)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- _, err = db.Exec("INSERT INTO foo(id, value) VALUES(?, ?)", 1, `今日の 晩御飯は 天麩羅よ`)
- if err != nil {
- t.Fatal("Failed to insert value:", err)
- }
-
- _, err = db.Exec("INSERT INTO foo(id, value) VALUES(?, ?)", 2, `今日は いい 天気だ`)
- if err != nil {
- t.Fatal("Failed to insert value:", err)
- }
-
- rows, err := db.Query("SELECT id, value FROM foo WHERE value MATCH '今日* 天*'")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
- defer rows.Close()
-
- for rows.Next() {
- var id int
- var value string
-
- if err := rows.Scan(&id, &value); err != nil {
- t.Error("Unable to scan results:", err)
- continue
- }
-
- if id == 1 && value != `今日の 晩御飯は 天麩羅よ` {
- t.Error("Value for id 1 should be `今日の 晩御飯は 天麩羅よ`, but:", value)
- } else if id == 2 && value != `今日は いい 天気だ` {
- t.Error("Value for id 2 should be `今日は いい 天気だ`, but:", value)
- }
- }
-
- rows, err = db.Query("SELECT value FROM foo WHERE value MATCH '今日* 天麩羅*'")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
- defer rows.Close()
-
- var value string
- if !rows.Next() {
- t.Fatal("Result should be only one")
- }
-
- if err := rows.Scan(&value); err != nil {
- t.Fatal("Unable to scan results:", err)
- }
-
- if value != `今日の 晩御飯は 天麩羅よ` {
- t.Fatal("Value should be `今日の 晩御飯は 天麩羅よ`, but:", value)
- }
-
- if rows.Next() {
- t.Fatal("Result should be only one")
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_other.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_other.go b/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_other.go
deleted file mode 100644
index a20d02c..0000000
--- a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_other.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright (C) 2014 Yasuhiro Matsumoto <ma...@gmail.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-// +build !windows
-
-package sqlite3
-
-/*
-#cgo CFLAGS: -I.
-#cgo linux LDFLAGS: -ldl
-*/
-import "C"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test.go b/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test.go
deleted file mode 100644
index 423f30e..0000000
--- a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test.go
+++ /dev/null
@@ -1,1058 +0,0 @@
-// Copyright (C) 2014 Yasuhiro Matsumoto <ma...@gmail.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-
-package sqlite3
-
-import (
- "crypto/rand"
- "database/sql"
- "database/sql/driver"
- "encoding/hex"
- "errors"
- "fmt"
- "net/url"
- "os"
- "path/filepath"
- "strings"
- "testing"
- "time"
-
- "github.com/mattn/go-sqlite3/sqlite3_test"
-)
-
-func TempFilename() string {
- randBytes := make([]byte, 16)
- rand.Read(randBytes)
- return filepath.Join(os.TempDir(), "foo"+hex.EncodeToString(randBytes)+".db")
-}
-
-func doTestOpen(t *testing.T, option string) (string, error) {
- var url string
- tempFilename := TempFilename()
- if option != "" {
- url = tempFilename + option
- } else {
- url = tempFilename
- }
- db, err := sql.Open("sqlite3", url)
- if err != nil {
- return "Failed to open database:", err
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("drop table foo")
- _, err = db.Exec("create table foo (id integer)")
- if err != nil {
- return "Failed to create table:", err
- }
-
- if stat, err := os.Stat(tempFilename); err != nil || stat.IsDir() {
- return "Failed to create ./foo.db", nil
- }
-
- return "", nil
-}
-
-func TestOpen(t *testing.T) {
- cases := map[string]bool{
- "": true,
- "?_txlock=immediate": true,
- "?_txlock=deferred": true,
- "?_txlock=exclusive": true,
- "?_txlock=bogus": false,
- }
- for option, expectedPass := range cases {
- result, err := doTestOpen(t, option)
- if result == "" {
- if !expectedPass {
- errmsg := fmt.Sprintf("_txlock error not caught at dbOpen with option: %s", option)
- t.Fatal(errmsg)
- }
- } else if expectedPass {
- if err == nil {
- t.Fatal(result)
- } else {
- t.Fatal(result, err)
- }
- }
- }
-}
-
-func TestClose(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
-
- _, err = db.Exec("drop table foo")
- _, err = db.Exec("create table foo (id integer)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- stmt, err := db.Prepare("select id from foo where id = ?")
- if err != nil {
- t.Fatal("Failed to select records:", err)
- }
-
- db.Close()
- _, err = stmt.Exec(1)
- if err == nil {
- t.Fatal("Failed to operate closed statement")
- }
-}
-
-func TestInsert(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("drop table foo")
- _, err = db.Exec("create table foo (id integer)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- res, err := db.Exec("insert into foo(id) values(123)")
- if err != nil {
- t.Fatal("Failed to insert record:", err)
- }
- affected, _ := res.RowsAffected()
- if affected != 1 {
- t.Fatalf("Expected %d for affected rows, but %d:", 1, affected)
- }
-
- rows, err := db.Query("select id from foo")
- if err != nil {
- t.Fatal("Failed to select records:", err)
- }
- defer rows.Close()
-
- rows.Next()
-
- var result int
- rows.Scan(&result)
- if result != 123 {
- t.Errorf("Fetched %q; expected %q", 123, result)
- }
-}
-
-func TestUpdate(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("drop table foo")
- _, err = db.Exec("create table foo (id integer)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- res, err := db.Exec("insert into foo(id) values(123)")
- if err != nil {
- t.Fatal("Failed to insert record:", err)
- }
- expected, err := res.LastInsertId()
- if err != nil {
- t.Fatal("Failed to get LastInsertId:", err)
- }
- affected, _ := res.RowsAffected()
- if err != nil {
- t.Fatal("Failed to get RowsAffected:", err)
- }
- if affected != 1 {
- t.Fatalf("Expected %d for affected rows, but %d:", 1, affected)
- }
-
- res, err = db.Exec("update foo set id = 234")
- if err != nil {
- t.Fatal("Failed to update record:", err)
- }
- lastId, err := res.LastInsertId()
- if err != nil {
- t.Fatal("Failed to get LastInsertId:", err)
- }
- if expected != lastId {
- t.Errorf("Expected %q for last Id, but %q:", expected, lastId)
- }
- affected, _ = res.RowsAffected()
- if err != nil {
- t.Fatal("Failed to get RowsAffected:", err)
- }
- if affected != 1 {
- t.Fatalf("Expected %d for affected rows, but %d:", 1, affected)
- }
-
- rows, err := db.Query("select id from foo")
- if err != nil {
- t.Fatal("Failed to select records:", err)
- }
- defer rows.Close()
-
- rows.Next()
-
- var result int
- rows.Scan(&result)
- if result != 234 {
- t.Errorf("Fetched %q; expected %q", 234, result)
- }
-}
-
-func TestDelete(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("drop table foo")
- _, err = db.Exec("create table foo (id integer)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- res, err := db.Exec("insert into foo(id) values(123)")
- if err != nil {
- t.Fatal("Failed to insert record:", err)
- }
- expected, err := res.LastInsertId()
- if err != nil {
- t.Fatal("Failed to get LastInsertId:", err)
- }
- affected, err := res.RowsAffected()
- if err != nil {
- t.Fatal("Failed to get RowsAffected:", err)
- }
- if affected != 1 {
- t.Errorf("Expected %d for cout of affected rows, but %q:", 1, affected)
- }
-
- res, err = db.Exec("delete from foo where id = 123")
- if err != nil {
- t.Fatal("Failed to delete record:", err)
- }
- lastId, err := res.LastInsertId()
- if err != nil {
- t.Fatal("Failed to get LastInsertId:", err)
- }
- if expected != lastId {
- t.Errorf("Expected %q for last Id, but %q:", expected, lastId)
- }
- affected, err = res.RowsAffected()
- if err != nil {
- t.Fatal("Failed to get RowsAffected:", err)
- }
- if affected != 1 {
- t.Errorf("Expected %d for cout of affected rows, but %q:", 1, affected)
- }
-
- rows, err := db.Query("select id from foo")
- if err != nil {
- t.Fatal("Failed to select records:", err)
- }
- defer rows.Close()
-
- if rows.Next() {
- t.Error("Fetched row but expected not rows")
- }
-}
-
-func TestBooleanRoundtrip(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("DROP TABLE foo")
- _, err = db.Exec("CREATE TABLE foo(id INTEGER, value BOOL)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- _, err = db.Exec("INSERT INTO foo(id, value) VALUES(1, ?)", true)
- if err != nil {
- t.Fatal("Failed to insert true value:", err)
- }
-
- _, err = db.Exec("INSERT INTO foo(id, value) VALUES(2, ?)", false)
- if err != nil {
- t.Fatal("Failed to insert false value:", err)
- }
-
- rows, err := db.Query("SELECT id, value FROM foo")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
- defer rows.Close()
-
- for rows.Next() {
- var id int
- var value bool
-
- if err := rows.Scan(&id, &value); err != nil {
- t.Error("Unable to scan results:", err)
- continue
- }
-
- if id == 1 && !value {
- t.Error("Value for id 1 should be true, not false")
-
- } else if id == 2 && value {
- t.Error("Value for id 2 should be false, not true")
- }
- }
-}
-
-func TestTimestamp(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("DROP TABLE foo")
- _, err = db.Exec("CREATE TABLE foo(id INTEGER, ts timeSTAMP, dt DATETIME)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- timestamp1 := time.Date(2012, time.April, 6, 22, 50, 0, 0, time.UTC)
- timestamp2 := time.Date(2006, time.January, 2, 15, 4, 5, 123456789, time.UTC)
- timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC)
- tests := []struct {
- value interface{}
- expected time.Time
- }{
- {"nonsense", time.Time{}},
- {"0000-00-00 00:00:00", time.Time{}},
- {timestamp1, timestamp1},
- {timestamp1.Unix(), timestamp1},
- {timestamp1.UnixNano() / int64(time.Millisecond), timestamp1},
- {timestamp1.In(time.FixedZone("TEST", -7*3600)), timestamp1},
- {timestamp1.Format("2006-01-02 15:04:05.000"), timestamp1},
- {timestamp1.Format("2006-01-02T15:04:05.000"), timestamp1},
- {timestamp1.Format("2006-01-02 15:04:05"), timestamp1},
- {timestamp1.Format("2006-01-02T15:04:05"), timestamp1},
- {timestamp2, timestamp2},
- {"2006-01-02 15:04:05.123456789", timestamp2},
- {"2006-01-02T15:04:05.123456789", timestamp2},
- {"2012-11-04", timestamp3},
- {"2012-11-04 00:00", timestamp3},
- {"2012-11-04 00:00:00", timestamp3},
- {"2012-11-04 00:00:00.000", timestamp3},
- {"2012-11-04T00:00", timestamp3},
- {"2012-11-04T00:00:00", timestamp3},
- {"2012-11-04T00:00:00.000", timestamp3},
- }
- for i := range tests {
- _, err = db.Exec("INSERT INTO foo(id, ts, dt) VALUES(?, ?, ?)", i, tests[i].value, tests[i].value)
- if err != nil {
- t.Fatal("Failed to insert timestamp:", err)
- }
- }
-
- rows, err := db.Query("SELECT id, ts, dt FROM foo ORDER BY id ASC")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
- defer rows.Close()
-
- seen := 0
- for rows.Next() {
- var id int
- var ts, dt time.Time
-
- if err := rows.Scan(&id, &ts, &dt); err != nil {
- t.Error("Unable to scan results:", err)
- continue
- }
- if id < 0 || id >= len(tests) {
- t.Error("Bad row id: ", id)
- continue
- }
- seen++
- if !tests[id].expected.Equal(ts) {
- t.Errorf("Timestamp value for id %v (%v) should be %v, not %v", id, tests[id].value, tests[id].expected, dt)
- }
- if !tests[id].expected.Equal(dt) {
- t.Errorf("Datetime value for id %v (%v) should be %v, not %v", id, tests[id].value, tests[id].expected, dt)
- }
- }
-
- if seen != len(tests) {
- t.Errorf("Expected to see %d rows", len(tests))
- }
-}
-
-func TestBoolean(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("CREATE TABLE foo(id INTEGER, fbool BOOLEAN)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- bool1 := true
- _, err = db.Exec("INSERT INTO foo(id, fbool) VALUES(1, ?)", bool1)
- if err != nil {
- t.Fatal("Failed to insert boolean:", err)
- }
-
- bool2 := false
- _, err = db.Exec("INSERT INTO foo(id, fbool) VALUES(2, ?)", bool2)
- if err != nil {
- t.Fatal("Failed to insert boolean:", err)
- }
-
- bool3 := "nonsense"
- _, err = db.Exec("INSERT INTO foo(id, fbool) VALUES(3, ?)", bool3)
- if err != nil {
- t.Fatal("Failed to insert nonsense:", err)
- }
-
- rows, err := db.Query("SELECT id, fbool FROM foo where fbool = ?", bool1)
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
- counter := 0
-
- var id int
- var fbool bool
-
- for rows.Next() {
- if err := rows.Scan(&id, &fbool); err != nil {
- t.Fatal("Unable to scan results:", err)
- }
- counter++
- }
-
- if counter != 1 {
- t.Fatalf("Expected 1 row but %v", counter)
- }
-
- if id != 1 && fbool != true {
- t.Fatalf("Value for id 1 should be %v, not %v", bool1, fbool)
- }
-
- rows, err = db.Query("SELECT id, fbool FROM foo where fbool = ?", bool2)
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
-
- counter = 0
-
- for rows.Next() {
- if err := rows.Scan(&id, &fbool); err != nil {
- t.Fatal("Unable to scan results:", err)
- }
- counter++
- }
-
- if counter != 1 {
- t.Fatalf("Expected 1 row but %v", counter)
- }
-
- if id != 2 && fbool != false {
- t.Fatalf("Value for id 2 should be %v, not %v", bool2, fbool)
- }
-
- // make sure "nonsense" triggered an error
- rows, err = db.Query("SELECT id, fbool FROM foo where id=?;", 3)
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
-
- rows.Next()
- err = rows.Scan(&id, &fbool)
- if err == nil {
- t.Error("Expected error from \"nonsense\" bool")
- }
-}
-
-func TestFloat32(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("CREATE TABLE foo(id INTEGER)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- _, err = db.Exec("INSERT INTO foo(id) VALUES(null)")
- if err != nil {
- t.Fatal("Failed to insert null:", err)
- }
-
- rows, err := db.Query("SELECT id FROM foo")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
-
- if !rows.Next() {
- t.Fatal("Unable to query results:", err)
- }
-
- var id interface{}
- if err := rows.Scan(&id); err != nil {
- t.Fatal("Unable to scan results:", err)
- }
- if id != nil {
- t.Error("Expected nil but not")
- }
-}
-
-func TestNull(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- defer os.Remove(tempFilename)
- defer db.Close()
-
- rows, err := db.Query("SELECT 3.141592")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
-
- if !rows.Next() {
- t.Fatal("Unable to query results:", err)
- }
-
- var v interface{}
- if err := rows.Scan(&v); err != nil {
- t.Fatal("Unable to scan results:", err)
- }
- f, ok := v.(float64)
- if !ok {
- t.Error("Expected float but not")
- }
- if f != 3.141592 {
- t.Error("Expected 3.141592 but not")
- }
-}
-
-func TestTransaction(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("CREATE TABLE foo(id INTEGER)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- tx, err := db.Begin()
- if err != nil {
- t.Fatal("Failed to begin transaction:", err)
- }
-
- _, err = tx.Exec("INSERT INTO foo(id) VALUES(1)")
- if err != nil {
- t.Fatal("Failed to insert null:", err)
- }
-
- rows, err := tx.Query("SELECT id from foo")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
-
- err = tx.Rollback()
- if err != nil {
- t.Fatal("Failed to rollback transaction:", err)
- }
-
- if rows.Next() {
- t.Fatal("Unable to query results:", err)
- }
-
- tx, err = db.Begin()
- if err != nil {
- t.Fatal("Failed to begin transaction:", err)
- }
-
- _, err = tx.Exec("INSERT INTO foo(id) VALUES(1)")
- if err != nil {
- t.Fatal("Failed to insert null:", err)
- }
-
- err = tx.Commit()
- if err != nil {
- t.Fatal("Failed to commit transaction:", err)
- }
-
- rows, err = tx.Query("SELECT id from foo")
- if err == nil {
- t.Fatal("Expected failure to query")
- }
-}
-
-func TestWAL(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- defer os.Remove(tempFilename)
- defer db.Close()
- if _, err = db.Exec("PRAGMA journal_mode=WAL;"); err != nil {
- t.Fatal("Failed to Exec PRAGMA journal_mode:", err)
- }
- if _, err = db.Exec("PRAGMA locking_mode=EXCLUSIVE;"); err != nil {
- t.Fatal("Failed to Exec PRAGMA locking_mode:", err)
- }
- if _, err = db.Exec("CREATE TABLE test (id SERIAL, user TEXT NOT NULL, name TEXT NOT NULL);"); err != nil {
- t.Fatal("Failed to Exec CREATE TABLE:", err)
- }
- if _, err = db.Exec("INSERT INTO test (user, name) VALUES ('user','name');"); err != nil {
- t.Fatal("Failed to Exec INSERT:", err)
- }
-
- trans, err := db.Begin()
- if err != nil {
- t.Fatal("Failed to Begin:", err)
- }
- s, err := trans.Prepare("INSERT INTO test (user, name) VALUES (?, ?);")
- if err != nil {
- t.Fatal("Failed to Prepare:", err)
- }
-
- var count int
- if err = trans.QueryRow("SELECT count(user) FROM test;").Scan(&count); err != nil {
- t.Fatal("Failed to QueryRow:", err)
- }
- if _, err = s.Exec("bbbb", "aaaa"); err != nil {
- t.Fatal("Failed to Exec prepared statement:", err)
- }
- if err = s.Close(); err != nil {
- t.Fatal("Failed to Close prepared statement:", err)
- }
- if err = trans.Commit(); err != nil {
- t.Fatal("Failed to Commit:", err)
- }
-}
-
-func TestTimezoneConversion(t *testing.T) {
- zones := []string{"UTC", "US/Central", "US/Pacific", "Local"}
- for _, tz := range zones {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename+"?_loc="+url.QueryEscape(tz))
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec("DROP TABLE foo")
- _, err = db.Exec("CREATE TABLE foo(id INTEGER, ts TIMESTAMP, dt DATETIME)")
- if err != nil {
- t.Fatal("Failed to create table:", err)
- }
-
- loc, err := time.LoadLocation(tz)
- if err != nil {
- t.Fatal("Failed to load location:", err)
- }
-
- timestamp1 := time.Date(2012, time.April, 6, 22, 50, 0, 0, time.UTC)
- timestamp2 := time.Date(2006, time.January, 2, 15, 4, 5, 123456789, time.UTC)
- timestamp3 := time.Date(2012, time.November, 4, 0, 0, 0, 0, time.UTC)
- tests := []struct {
- value interface{}
- expected time.Time
- }{
- {"nonsense", time.Time{}.In(loc)},
- {"0000-00-00 00:00:00", time.Time{}.In(loc)},
- {timestamp1, timestamp1.In(loc)},
- {timestamp1.Unix(), timestamp1.In(loc)},
- {timestamp1.In(time.FixedZone("TEST", -7*3600)), timestamp1.In(loc)},
- {timestamp1.Format("2006-01-02 15:04:05.000"), timestamp1.In(loc)},
- {timestamp1.Format("2006-01-02T15:04:05.000"), timestamp1.In(loc)},
- {timestamp1.Format("2006-01-02 15:04:05"), timestamp1.In(loc)},
- {timestamp1.Format("2006-01-02T15:04:05"), timestamp1.In(loc)},
- {timestamp2, timestamp2.In(loc)},
- {"2006-01-02 15:04:05.123456789", timestamp2.In(loc)},
- {"2006-01-02T15:04:05.123456789", timestamp2.In(loc)},
- {"2012-11-04", timestamp3.In(loc)},
- {"2012-11-04 00:00", timestamp3.In(loc)},
- {"2012-11-04 00:00:00", timestamp3.In(loc)},
- {"2012-11-04 00:00:00.000", timestamp3.In(loc)},
- {"2012-11-04T00:00", timestamp3.In(loc)},
- {"2012-11-04T00:00:00", timestamp3.In(loc)},
- {"2012-11-04T00:00:00.000", timestamp3.In(loc)},
- }
- for i := range tests {
- _, err = db.Exec("INSERT INTO foo(id, ts, dt) VALUES(?, ?, ?)", i, tests[i].value, tests[i].value)
- if err != nil {
- t.Fatal("Failed to insert timestamp:", err)
- }
- }
-
- rows, err := db.Query("SELECT id, ts, dt FROM foo ORDER BY id ASC")
- if err != nil {
- t.Fatal("Unable to query foo table:", err)
- }
- defer rows.Close()
-
- seen := 0
- for rows.Next() {
- var id int
- var ts, dt time.Time
-
- if err := rows.Scan(&id, &ts, &dt); err != nil {
- t.Error("Unable to scan results:", err)
- continue
- }
- if id < 0 || id >= len(tests) {
- t.Error("Bad row id: ", id)
- continue
- }
- seen++
- if !tests[id].expected.Equal(ts) {
- t.Errorf("Timestamp value for id %v (%v) should be %v, not %v", id, tests[id].value, tests[id].expected, ts)
- }
- if !tests[id].expected.Equal(dt) {
- t.Errorf("Datetime value for id %v (%v) should be %v, not %v", id, tests[id].value, tests[id].expected, dt)
- }
- if tests[id].expected.Location().String() != ts.Location().String() {
- t.Errorf("Location for id %v (%v) should be %v, not %v", id, tests[id].value, tests[id].expected.Location().String(), ts.Location().String())
- }
- if tests[id].expected.Location().String() != dt.Location().String() {
- t.Errorf("Location for id %v (%v) should be %v, not %v", id, tests[id].value, tests[id].expected.Location().String(), dt.Location().String())
- }
- }
-
- if seen != len(tests) {
- t.Errorf("Expected to see %d rows", len(tests))
- }
- }
-}
-
-func TestSuite(t *testing.T) {
- db, err := sql.Open("sqlite3", ":memory:")
- if err != nil {
- t.Fatal(err)
- }
- defer db.Close()
-
- sqlite3_test.RunTests(t, db, sqlite3_test.SQLITE)
-}
-
-// TODO: Execer & Queryer currently disabled
-// https://github.com/mattn/go-sqlite3/issues/82
-func TestExecer(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec(`
- create table foo (id integer); -- one comment
- insert into foo(id) values(?);
- insert into foo(id) values(?);
- insert into foo(id) values(?); -- another comment
- `, 1, 2, 3)
- if err != nil {
- t.Error("Failed to call db.Exec:", err)
- }
-}
-
-func TestQueryer(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec(`
- create table foo (id integer);
- `)
- if err != nil {
- t.Error("Failed to call db.Query:", err)
- }
-
- rows, err := db.Query(`
- insert into foo(id) values(?);
- insert into foo(id) values(?);
- insert into foo(id) values(?);
- select id from foo order by id;
- `, 3, 2, 1)
- if err != nil {
- t.Error("Failed to call db.Query:", err)
- }
- defer rows.Close()
- n := 1
- if rows != nil {
- for rows.Next() {
- var id int
- err = rows.Scan(&id)
- if err != nil {
- t.Error("Failed to db.Query:", err)
- }
- if id != n {
- t.Error("Failed to db.Query: not matched results")
- }
- }
- }
-}
-
-func TestStress(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- db.Exec("CREATE TABLE foo (id int);")
- db.Exec("INSERT INTO foo VALUES(1);")
- db.Exec("INSERT INTO foo VALUES(2);")
- db.Close()
-
- for i := 0; i < 10000; i++ {
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- for j := 0; j < 3; j++ {
- rows, err := db.Query("select * from foo where id=1;")
- if err != nil {
- t.Error("Failed to call db.Query:", err)
- }
- for rows.Next() {
- var i int
- if err := rows.Scan(&i); err != nil {
- t.Errorf("Scan failed: %v\n", err)
- }
- }
- if err := rows.Err(); err != nil {
- t.Errorf("Post-scan failed: %v\n", err)
- }
- rows.Close()
- }
- db.Close()
- }
-}
-
-func TestDateTimeLocal(t *testing.T) {
- zone := "Asia/Tokyo"
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename+"?_loc="+zone)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- db.Exec("CREATE TABLE foo (dt datetime);")
- db.Exec("INSERT INTO foo VALUES('2015-03-05 15:16:17');")
-
- row := db.QueryRow("select * from foo")
- var d time.Time
- err = row.Scan(&d)
- if err != nil {
- t.Fatal("Failed to scan datetime:", err)
- }
- if d.Hour() == 15 || !strings.Contains(d.String(), "JST") {
- t.Fatal("Result should have timezone", d)
- }
- db.Close()
-
- db, err = sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- row = db.QueryRow("select * from foo")
- err = row.Scan(&d)
- if err != nil {
- t.Fatal("Failed to scan datetime:", err)
- }
- if d.UTC().Hour() != 15 || !strings.Contains(d.String(), "UTC") {
- t.Fatalf("Result should not have timezone %v %v", zone, d.String())
- }
-
- _, err = db.Exec("DELETE FROM foo")
- if err != nil {
- t.Fatal("Failed to delete table:", err)
- }
- dt, err := time.Parse("2006/1/2 15/4/5 -0700 MST", "2015/3/5 15/16/17 +0900 JST")
- if err != nil {
- t.Fatal("Failed to parse datetime:", err)
- }
- db.Exec("INSERT INTO foo VALUES(?);", dt)
-
- db.Close()
- db, err = sql.Open("sqlite3", tempFilename+"?_loc="+zone)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
-
- row = db.QueryRow("select * from foo")
- err = row.Scan(&d)
- if err != nil {
- t.Fatal("Failed to scan datetime:", err)
- }
- if d.Hour() != 15 || !strings.Contains(d.String(), "JST") {
- t.Fatalf("Result should have timezone %v %v", zone, d.String())
- }
-}
-
-func TestVersion(t *testing.T) {
- s, n, id := Version()
- if s == "" || n == 0 || id == "" {
- t.Errorf("Version failed %q, %d, %q\n", s, n, id)
- }
-}
-
-func TestNumberNamedParams(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec(`
- create table foo (id integer, name text, extra text);
- `)
- if err != nil {
- t.Error("Failed to call db.Query:", err)
- }
-
- _, err = db.Exec(`insert into foo(id, name, extra) values($1, $2, $2)`, 1, "foo")
- if err != nil {
- t.Error("Failed to call db.Exec:", err)
- }
-
- row := db.QueryRow(`select id, extra from foo where id = $1 and extra = $2`, 1, "foo")
- if row == nil {
- t.Error("Failed to call db.QueryRow")
- }
- var id int
- var extra string
- err = row.Scan(&id, &extra)
- if err != nil {
- t.Error("Failed to db.Scan:", err)
- }
- if id != 1 || extra != "foo" {
- t.Error("Failed to db.QueryRow: not matched results")
- }
-}
-
-func TestStringContainingZero(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer os.Remove(tempFilename)
- defer db.Close()
-
- _, err = db.Exec(`
- create table foo (id integer, name, extra text);
- `)
- if err != nil {
- t.Error("Failed to call db.Query:", err)
- }
-
- const text = "foo\x00bar"
-
- _, err = db.Exec(`insert into foo(id, name, extra) values($1, $2, $2)`, 1, text)
- if err != nil {
- t.Error("Failed to call db.Exec:", err)
- }
-
- row := db.QueryRow(`select id, extra from foo where id = $1 and extra = $2`, 1, text)
- if row == nil {
- t.Error("Failed to call db.QueryRow")
- }
-
- var id int
- var extra string
- err = row.Scan(&id, &extra)
- if err != nil {
- t.Error("Failed to db.Scan:", err)
- }
- if id != 1 || extra != text {
- t.Error("Failed to db.QueryRow: not matched results")
- }
-}
-
-const CurrentTimeStamp = "2006-01-02 15:04:05"
-
-type TimeStamp struct{ *time.Time }
-
-func (t TimeStamp) Scan(value interface{}) error {
- var err error
- switch v := value.(type) {
- case string:
- *t.Time, err = time.Parse(CurrentTimeStamp, v)
- case []byte:
- *t.Time, err = time.Parse(CurrentTimeStamp, string(v))
- default:
- err = errors.New("invalid type for current_timestamp")
- }
- return err
-}
-
-func (t TimeStamp) Value() (driver.Value, error) {
- return t.Time.Format(CurrentTimeStamp), nil
-}
-
-func TestDateTimeNow(t *testing.T) {
- tempFilename := TempFilename()
- db, err := sql.Open("sqlite3", tempFilename)
- if err != nil {
- t.Fatal("Failed to open database:", err)
- }
- defer db.Close()
-
- var d time.Time
- err = db.QueryRow("SELECT datetime('now')").Scan(TimeStamp{&d})
- if err != nil {
- t.Fatal("Failed to scan datetime:", err)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test/sqltest.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test/sqltest.go b/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test/sqltest.go
deleted file mode 100644
index fc82782..0000000
--- a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_test/sqltest.go
+++ /dev/null
@@ -1,412 +0,0 @@
-package sqlite3_test
-
-import (
- "database/sql"
- "fmt"
- "math/rand"
- "regexp"
- "strconv"
- "sync"
- "testing"
- "time"
-)
-
-type Dialect int
-
-const (
- SQLITE Dialect = iota
- POSTGRESQL
- MYSQL
-)
-
-type DB struct {
- *testing.T
- *sql.DB
- dialect Dialect
- once sync.Once
-}
-
-var db *DB
-
-// the following tables will be created and dropped during the test
-var testTables = []string{"foo", "bar", "t", "bench"}
-
-var tests = []testing.InternalTest{
- {"TestBlobs", TestBlobs},
- {"TestManyQueryRow", TestManyQueryRow},
- {"TestTxQuery", TestTxQuery},
- {"TestPreparedStmt", TestPreparedStmt},
-}
-
-var benchmarks = []testing.InternalBenchmark{
- {"BenchmarkExec", BenchmarkExec},
- {"BenchmarkQuery", BenchmarkQuery},
- {"BenchmarkParams", BenchmarkParams},
- {"BenchmarkStmt", BenchmarkStmt},
- {"BenchmarkRows", BenchmarkRows},
- {"BenchmarkStmtRows", BenchmarkStmtRows},
-}
-
-// RunTests runs the SQL test suite
-func RunTests(t *testing.T, d *sql.DB, dialect Dialect) {
- db = &DB{t, d, dialect, sync.Once{}}
- testing.RunTests(func(string, string) (bool, error) { return true, nil }, tests)
-
- if !testing.Short() {
- for _, b := range benchmarks {
- fmt.Printf("%-20s", b.Name)
- r := testing.Benchmark(b.F)
- fmt.Printf("%10d %10.0f req/s\n", r.N, float64(r.N)/r.T.Seconds())
- }
- }
- db.tearDown()
-}
-
-func (db *DB) mustExec(sql string, args ...interface{}) sql.Result {
- res, err := db.Exec(sql, args...)
- if err != nil {
- db.Fatalf("Error running %q: %v", sql, err)
- }
- return res
-}
-
-func (db *DB) tearDown() {
- for _, tbl := range testTables {
- switch db.dialect {
- case SQLITE:
- db.mustExec("drop table if exists " + tbl)
- case MYSQL, POSTGRESQL:
- db.mustExec("drop table if exists " + tbl)
- default:
- db.Fatal("unkown dialect")
- }
- }
-}
-
-// q replaces ? parameters if needed
-func (db *DB) q(sql string) string {
- switch db.dialect {
- case POSTGRESQL: // repace with $1, $2, ..
- qrx := regexp.MustCompile(`\?`)
- n := 0
- return qrx.ReplaceAllStringFunc(sql, func(string) string {
- n++
- return "$" + strconv.Itoa(n)
- })
- }
- return sql
-}
-
-func (db *DB) blobType(size int) string {
- switch db.dialect {
- case SQLITE:
- return fmt.Sprintf("blob[%d]", size)
- case POSTGRESQL:
- return "bytea"
- case MYSQL:
- return fmt.Sprintf("VARBINARY(%d)", size)
- }
- panic("unkown dialect")
-}
-
-func (db *DB) serialPK() string {
- switch db.dialect {
- case SQLITE:
- return "integer primary key autoincrement"
- case POSTGRESQL:
- return "serial primary key"
- case MYSQL:
- return "integer primary key auto_increment"
- }
- panic("unkown dialect")
-}
-
-func (db *DB) now() string {
- switch db.dialect {
- case SQLITE:
- return "datetime('now')"
- case POSTGRESQL:
- return "now()"
- case MYSQL:
- return "now()"
- }
- panic("unkown dialect")
-}
-
-func makeBench() {
- if _, err := db.Exec("create table bench (n varchar(32), i integer, d double, s varchar(32), t datetime)"); err != nil {
- panic(err)
- }
- st, err := db.Prepare("insert into bench values (?, ?, ?, ?, ?)")
- if err != nil {
- panic(err)
- }
- defer st.Close()
- for i := 0; i < 100; i++ {
- if _, err = st.Exec(nil, i, float64(i), fmt.Sprintf("%d", i), time.Now()); err != nil {
- panic(err)
- }
- }
-}
-
-func TestResult(t *testing.T) {
- db.tearDown()
- db.mustExec("create temporary table test (id " + db.serialPK() + ", name varchar(10))")
-
- for i := 1; i < 3; i++ {
- r := db.mustExec(db.q("insert into test (name) values (?)"), fmt.Sprintf("row %d", i))
- n, err := r.RowsAffected()
- if err != nil {
- t.Fatal(err)
- }
- if n != 1 {
- t.Errorf("got %v, want %v", n, 1)
- }
- n, err = r.LastInsertId()
- if err != nil {
- t.Fatal(err)
- }
- if n != int64(i) {
- t.Errorf("got %v, want %v", n, i)
- }
- }
- if _, err := db.Exec("error!"); err == nil {
- t.Fatalf("expected error")
- }
-}
-
-func TestBlobs(t *testing.T) {
- db.tearDown()
- var blob = []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
- db.mustExec("create table foo (id integer primary key, bar " + db.blobType(16) + ")")
- db.mustExec(db.q("insert into foo (id, bar) values(?,?)"), 0, blob)
-
- want := fmt.Sprintf("%x", blob)
-
- b := make([]byte, 16)
- err := db.QueryRow(db.q("select bar from foo where id = ?"), 0).Scan(&b)
- got := fmt.Sprintf("%x", b)
- if err != nil {
- t.Errorf("[]byte scan: %v", err)
- } else if got != want {
- t.Errorf("for []byte, got %q; want %q", got, want)
- }
-
- err = db.QueryRow(db.q("select bar from foo where id = ?"), 0).Scan(&got)
- want = string(blob)
- if err != nil {
- t.Errorf("string scan: %v", err)
- } else if got != want {
- t.Errorf("for string, got %q; want %q", got, want)
- }
-}
-
-func TestManyQueryRow(t *testing.T) {
- if testing.Short() {
- t.Log("skipping in short mode")
- return
- }
- db.tearDown()
- db.mustExec("create table foo (id integer primary key, name varchar(50))")
- db.mustExec(db.q("insert into foo (id, name) values(?,?)"), 1, "bob")
- var name string
- for i := 0; i < 10000; i++ {
- err := db.QueryRow(db.q("select name from foo where id = ?"), 1).Scan(&name)
- if err != nil || name != "bob" {
- t.Fatalf("on query %d: err=%v, name=%q", i, err, name)
- }
- }
-}
-
-func TestTxQuery(t *testing.T) {
- db.tearDown()
- tx, err := db.Begin()
- if err != nil {
- t.Fatal(err)
- }
- defer tx.Rollback()
-
- _, err = tx.Exec("create table foo (id integer primary key, name varchar(50))")
- if err != nil {
- t.Fatal(err)
- }
-
- _, err = tx.Exec(db.q("insert into foo (id, name) values(?,?)"), 1, "bob")
- if err != nil {
- t.Fatal(err)
- }
-
- r, err := tx.Query(db.q("select name from foo where id = ?"), 1)
- if err != nil {
- t.Fatal(err)
- }
- defer r.Close()
-
- if !r.Next() {
- if r.Err() != nil {
- t.Fatal(err)
- }
- t.Fatal("expected one rows")
- }
-
- var name string
- err = r.Scan(&name)
- if err != nil {
- t.Fatal(err)
- }
-}
-
-func TestPreparedStmt(t *testing.T) {
- db.tearDown()
- db.mustExec("CREATE TABLE t (count INT)")
- sel, err := db.Prepare("SELECT count FROM t ORDER BY count DESC")
- if err != nil {
- t.Fatalf("prepare 1: %v", err)
- }
- ins, err := db.Prepare(db.q("INSERT INTO t (count) VALUES (?)"))
- if err != nil {
- t.Fatalf("prepare 2: %v", err)
- }
-
- for n := 1; n <= 3; n++ {
- if _, err := ins.Exec(n); err != nil {
- t.Fatalf("insert(%d) = %v", n, err)
- }
- }
-
- const nRuns = 10
- ch := make(chan bool)
- for i := 0; i < nRuns; i++ {
- go func() {
- defer func() {
- ch <- true
- }()
- for j := 0; j < 10; j++ {
- count := 0
- if err := sel.QueryRow().Scan(&count); err != nil && err != sql.ErrNoRows {
- t.Errorf("Query: %v", err)
- return
- }
- if _, err := ins.Exec(rand.Intn(100)); err != nil {
- t.Errorf("Insert: %v", err)
- return
- }
- }
- }()
- }
- for i := 0; i < nRuns; i++ {
- <-ch
- }
-}
-
-// Benchmarks need to use panic() since b.Error errors are lost when
-// running via testing.Benchmark() I would like to run these via go
-// test -bench but calling Benchmark() from a benchmark test
-// currently hangs go.
-
-func BenchmarkExec(b *testing.B) {
- for i := 0; i < b.N; i++ {
- if _, err := db.Exec("select 1"); err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkQuery(b *testing.B) {
- for i := 0; i < b.N; i++ {
- var n sql.NullString
- var i int
- var f float64
- var s string
-// var t time.Time
- if err := db.QueryRow("select null, 1, 1.1, 'foo'").Scan(&n, &i, &f, &s); err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkParams(b *testing.B) {
- for i := 0; i < b.N; i++ {
- var n sql.NullString
- var i int
- var f float64
- var s string
-// var t time.Time
- if err := db.QueryRow("select ?, ?, ?, ?", nil, 1, 1.1, "foo").Scan(&n, &i, &f, &s); err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkStmt(b *testing.B) {
- st, err := db.Prepare("select ?, ?, ?, ?")
- if err != nil {
- panic(err)
- }
- defer st.Close()
-
- for n := 0; n < b.N; n++ {
- var n sql.NullString
- var i int
- var f float64
- var s string
-// var t time.Time
- if err := st.QueryRow(nil, 1, 1.1, "foo").Scan(&n, &i, &f, &s); err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkRows(b *testing.B) {
- db.once.Do(makeBench)
-
- for n := 0; n < b.N; n++ {
- var n sql.NullString
- var i int
- var f float64
- var s string
- var t time.Time
- r, err := db.Query("select * from bench")
- if err != nil {
- panic(err)
- }
- for r.Next() {
- if err = r.Scan(&n, &i, &f, &s, &t); err != nil {
- panic(err)
- }
- }
- if err = r.Err(); err != nil {
- panic(err)
- }
- }
-}
-
-func BenchmarkStmtRows(b *testing.B) {
- db.once.Do(makeBench)
-
- st, err := db.Prepare("select * from bench")
- if err != nil {
- panic(err)
- }
- defer st.Close()
-
- for n := 0; n < b.N; n++ {
- var n sql.NullString
- var i int
- var f float64
- var s string
- var t time.Time
- r, err := st.Query()
- if err != nil {
- panic(err)
- }
- for r.Next() {
- if err = r.Scan(&n, &i, &f, &s, &t); err != nil {
- panic(err)
- }
- }
- if err = r.Err(); err != nil {
- panic(err)
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_windows.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_windows.go b/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_windows.go
deleted file mode 100644
index abc8384..0000000
--- a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3_windows.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (C) 2014 Yasuhiro Matsumoto <ma...@gmail.com>.
-//
-// Use of this source code is governed by an MIT-style
-// license that can be found in the LICENSE file.
-// +build windows
-
-package sqlite3
-
-/*
-#cgo CFLAGS: -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe
-#cgo windows,386 CFLAGS: -D_localtime32=localtime
-#cgo LDFLAGS: -lmingwex -lmingw32
-*/
-import "C"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3ext.h
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3ext.h b/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3ext.h
deleted file mode 100644
index 7cc58b6..0000000
--- a/Godeps/_workspace/src/github.com/mattn/go-sqlite3/sqlite3ext.h
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
-** 2006 June 7
-**
-** The author disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
-**
-*************************************************************************
-** This header file defines the SQLite interface for use by
-** shared libraries that want to be imported as extensions into
-** an SQLite instance. Shared libraries that intend to be loaded
-** as extensions by SQLite should #include this file instead of
-** sqlite3.h.
-*/
-#ifndef _SQLITE3EXT_H_
-#define _SQLITE3EXT_H_
-#include "sqlite3-binding.h"
-
-typedef struct sqlite3_api_routines sqlite3_api_routines;
-
-/*
-** The following structure holds pointers to all of the SQLite API
-** routines.
-**
-** WARNING: In order to maintain backwards compatibility, add new
-** interfaces to the end of this structure only. If you insert new
-** interfaces in the middle of this structure, then older different
-** versions of SQLite will not be able to load each others' shared
-** libraries!
-*/
-struct sqlite3_api_routines {
- void * (*aggregate_context)(sqlite3_context*,int nBytes);
- int (*aggregate_count)(sqlite3_context*);
- int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
- int (*bind_double)(sqlite3_stmt*,int,double);
- int (*bind_int)(sqlite3_stmt*,int,int);
- int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
- int (*bind_null)(sqlite3_stmt*,int);
- int (*bind_parameter_count)(sqlite3_stmt*);
- int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
- const char * (*bind_parameter_name)(sqlite3_stmt*,int);
- int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
- int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
- int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
- int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
- int (*busy_timeout)(sqlite3*,int ms);
- int (*changes)(sqlite3*);
- int (*close)(sqlite3*);
- int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
- int eTextRep,const char*));
- int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
- int eTextRep,const void*));
- const void * (*column_blob)(sqlite3_stmt*,int iCol);
- int (*column_bytes)(sqlite3_stmt*,int iCol);
- int (*column_bytes16)(sqlite3_stmt*,int iCol);
- int (*column_count)(sqlite3_stmt*pStmt);
- const char * (*column_database_name)(sqlite3_stmt*,int);
- const void * (*column_database_name16)(sqlite3_stmt*,int);
- const char * (*column_decltype)(sqlite3_stmt*,int i);
- const void * (*column_decltype16)(sqlite3_stmt*,int);
- double (*column_double)(sqlite3_stmt*,int iCol);
- int (*column_int)(sqlite3_stmt*,int iCol);
- sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
- const char * (*column_name)(sqlite3_stmt*,int);
- const void * (*column_name16)(sqlite3_stmt*,int);
- const char * (*column_origin_name)(sqlite3_stmt*,int);
- const void * (*column_origin_name16)(sqlite3_stmt*,int);
- const char * (*column_table_name)(sqlite3_stmt*,int);
- const void * (*column_table_name16)(sqlite3_stmt*,int);
- const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
- const void * (*column_text16)(sqlite3_stmt*,int iCol);
- int (*column_type)(sqlite3_stmt*,int iCol);
- sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
- void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
- int (*complete)(const char*sql);
- int (*complete16)(const void*sql);
- int (*create_collation)(sqlite3*,const char*,int,void*,
- int(*)(void*,int,const void*,int,const void*));
- int (*create_collation16)(sqlite3*,const void*,int,void*,
- int(*)(void*,int,const void*,int,const void*));
- int (*create_function)(sqlite3*,const char*,int,int,void*,
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
- void (*xStep)(sqlite3_context*,int,sqlite3_value**),
- void (*xFinal)(sqlite3_context*));
- int (*create_function16)(sqlite3*,const void*,int,int,void*,
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
- void (*xStep)(sqlite3_context*,int,sqlite3_value**),
- void (*xFinal)(sqlite3_context*));
- int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
- int (*data_count)(sqlite3_stmt*pStmt);
- sqlite3 * (*db_handle)(sqlite3_stmt*);
- int (*declare_vtab)(sqlite3*,const char*);
- int (*enable_shared_cache)(int);
- int (*errcode)(sqlite3*db);
- const char * (*errmsg)(sqlite3*);
- const void * (*errmsg16)(sqlite3*);
- int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
- int (*expired)(sqlite3_stmt*);
- int (*finalize)(sqlite3_stmt*pStmt);
- void (*free)(void*);
- void (*free_table)(char**result);
- int (*get_autocommit)(sqlite3*);
- void * (*get_auxdata)(sqlite3_context*,int);
- int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
- int (*global_recover)(void);
- void (*interruptx)(sqlite3*);
- sqlite_int64 (*last_insert_rowid)(sqlite3*);
- const char * (*libversion)(void);
- int (*libversion_number)(void);
- void *(*malloc)(int);
- char * (*mprintf)(const char*,...);
- int (*open)(const char*,sqlite3**);
- int (*open16)(const void*,sqlite3**);
- int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
- int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
- void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
- void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
- void *(*realloc)(void*,int);
- int (*reset)(sqlite3_stmt*pStmt);
- void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
- void (*result_double)(sqlite3_context*,double);
- void (*result_error)(sqlite3_context*,const char*,int);
- void (*result_error16)(sqlite3_context*,const void*,int);
- void (*result_int)(sqlite3_context*,int);
- void (*result_int64)(sqlite3_context*,sqlite_int64);
- void (*result_null)(sqlite3_context*);
- void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
- void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
- void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
- void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
- void (*result_value)(sqlite3_context*,sqlite3_value*);
- void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
- int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
- const char*,const char*),void*);
- void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
- char * (*snprintf)(int,char*,const char*,...);
- int (*step)(sqlite3_stmt*);
- int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
- char const**,char const**,int*,int*,int*);
- void (*thread_cleanup)(void);
- int (*total_changes)(sqlite3*);
- void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
- int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
- void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
- sqlite_int64),void*);
- void * (*user_data)(sqlite3_context*);
- const void * (*value_blob)(sqlite3_value*);
- int (*value_bytes)(sqlite3_value*);
- int (*value_bytes16)(sqlite3_value*);
- double (*value_double)(sqlite3_value*);
- int (*value_int)(sqlite3_value*);
- sqlite_int64 (*value_int64)(sqlite3_value*);
- int (*value_numeric_type)(sqlite3_value*);
- const unsigned char * (*value_text)(sqlite3_value*);
- const void * (*value_text16)(sqlite3_value*);
- const void * (*value_text16be)(sqlite3_value*);
- const void * (*value_text16le)(sqlite3_value*);
- int (*value_type)(sqlite3_value*);
- char *(*vmprintf)(const char*,va_list);
- /* Added ??? */
- int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
- /* Added by 3.3.13 */
- int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
- int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
- int (*clear_bindings)(sqlite3_stmt*);
- /* Added by 3.4.1 */
- int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
- void (*xDestroy)(void *));
- /* Added by 3.5.0 */
- int (*bind_zeroblob)(sqlite3_stmt*,int,int);
- int (*blob_bytes)(sqlite3_blob*);
- int (*blob_close)(sqlite3_blob*);
- int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
- int,sqlite3_blob**);
- int (*blob_read)(sqlite3_blob*,void*,int,int);
- int (*blob_write)(sqlite3_blob*,const void*,int,int);
- int (*create_collation_v2)(sqlite3*,const char*,int,void*,
- int(*)(void*,int,const void*,int,const void*),
- void(*)(void*));
- int (*file_control)(sqlite3*,const char*,int,void*);
- sqlite3_int64 (*memory_highwater)(int);
- sqlite3_int64 (*memory_used)(void);
- sqlite3_mutex *(*mutex_alloc)(int);
- void (*mutex_enter)(sqlite3_mutex*);
- void (*mutex_free)(sqlite3_mutex*);
- void (*mutex_leave)(sqlite3_mutex*);
- int (*mutex_try)(sqlite3_mutex*);
- int (*open_v2)(const char*,sqlite3**,int,const char*);
- int (*release_memory)(int);
- void (*result_error_nomem)(sqlite3_context*);
- void (*result_error_toobig)(sqlite3_context*);
- int (*sleep)(int);
- void (*soft_heap_limit)(int);
- sqlite3_vfs *(*vfs_find)(const char*);
- int (*vfs_register)(sqlite3_vfs*,int);
- int (*vfs_unregister)(sqlite3_vfs*);
- int (*xthreadsafe)(void);
- void (*result_zeroblob)(sqlite3_context*,int);
- void (*result_error_code)(sqlite3_context*,int);
- int (*test_control)(int, ...);
- void (*randomness)(int,void*);
- sqlite3 *(*context_db_handle)(sqlite3_context*);
- int (*extended_result_codes)(sqlite3*,int);
- int (*limit)(sqlite3*,int,int);
- sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
- const char *(*sql)(sqlite3_stmt*);
- int (*status)(int,int*,int*,int);
- int (*backup_finish)(sqlite3_backup*);
- sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
- int (*backup_pagecount)(sqlite3_backup*);
- int (*backup_remaining)(sqlite3_backup*);
- int (*backup_step)(sqlite3_backup*,int);
- const char *(*compileoption_get)(int);
- int (*compileoption_used)(const char*);
- int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
- void (*xStep)(sqlite3_context*,int,sqlite3_value**),
- void (*xFinal)(sqlite3_context*),
- void(*xDestroy)(void*));
- int (*db_config)(sqlite3*,int,...);
- sqlite3_mutex *(*db_mutex)(sqlite3*);
- int (*db_status)(sqlite3*,int,int*,int*,int);
- int (*extended_errcode)(sqlite3*);
- void (*log)(int,const char*,...);
- sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
- const char *(*sourceid)(void);
- int (*stmt_status)(sqlite3_stmt*,int,int);
- int (*strnicmp)(const char*,const char*,int);
- int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
- int (*wal_autocheckpoint)(sqlite3*,int);
- int (*wal_checkpoint)(sqlite3*,const char*);
- void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
- int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
- int (*vtab_config)(sqlite3*,int op,...);
- int (*vtab_on_conflict)(sqlite3*);
- /* Version 3.7.16 and later */
- int (*close_v2)(sqlite3*);
- const char *(*db_filename)(sqlite3*,const char*);
- int (*db_readonly)(sqlite3*,const char*);
- int (*db_release_memory)(sqlite3*);
- const char *(*errstr)(int);
- int (*stmt_busy)(sqlite3_stmt*);
- int (*stmt_readonly)(sqlite3_stmt*);
- int (*stricmp)(const char*,const char*);
- int (*uri_boolean)(const char*,const char*,int);
- sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
- const char *(*uri_parameter)(const char*,const char*);
- char *(*vsnprintf)(int,char*,const char*,va_list);
- int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
-};
-
-/*
-** The following macros redefine the API routines so that they are
-** redirected throught the global sqlite3_api structure.
-**
-** This header file is also used by the loadext.c source file
-** (part of the main SQLite library - not an extension) so that
-** it can get access to the sqlite3_api_routines structure
-** definition. But the main library does not want to redefine
-** the API. So the redefinition macros are only valid if the
-** SQLITE_CORE macros is undefined.
-*/
-#ifndef SQLITE_CORE
-#define sqlite3_aggregate_context sqlite3_api->aggregate_context
-#ifndef SQLITE_OMIT_DEPRECATED
-#define sqlite3_aggregate_count sqlite3_api->aggregate_count
-#endif
-#define sqlite3_bind_blob sqlite3_api->bind_blob
-#define sqlite3_bind_double sqlite3_api->bind_double
-#define sqlite3_bind_int sqlite3_api->bind_int
-#define sqlite3_bind_int64 sqlite3_api->bind_int64
-#define sqlite3_bind_null sqlite3_api->bind_null
-#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
-#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
-#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
-#define sqlite3_bind_text sqlite3_api->bind_text
-#define sqlite3_bind_text16 sqlite3_api->bind_text16
-#define sqlite3_bind_value sqlite3_api->bind_value
-#define sqlite3_busy_handler sqlite3_api->busy_handler
-#define sqlite3_busy_timeout sqlite3_api->busy_timeout
-#define sqlite3_changes sqlite3_api->changes
-#define sqlite3_close sqlite3_api->close
-#define sqlite3_collation_needed sqlite3_api->collation_needed
-#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
-#define sqlite3_column_blob sqlite3_api->column_blob
-#define sqlite3_column_bytes sqlite3_api->column_bytes
-#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
-#define sqlite3_column_count sqlite3_api->column_count
-#define sqlite3_column_database_name sqlite3_api->column_database_name
-#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
-#define sqlite3_column_decltype sqlite3_api->column_decltype
-#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
-#define sqlite3_column_double sqlite3_api->column_double
-#define sqlite3_column_int sqlite3_api->column_int
-#define sqlite3_column_int64 sqlite3_api->column_int64
-#define sqlite3_column_name sqlite3_api->column_name
-#define sqlite3_column_name16 sqlite3_api->column_name16
-#define sqlite3_column_origin_name sqlite3_api->column_origin_name
-#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
-#define sqlite3_column_table_name sqlite3_api->column_table_name
-#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
-#define sqlite3_column_text sqlite3_api->column_text
-#define sqlite3_column_text16 sqlite3_api->column_text16
-#define sqlite3_column_type sqlite3_api->column_type
-#define sqlite3_column_value sqlite3_api->column_value
-#define sqlite3_commit_hook sqlite3_api->commit_hook
-#define sqlite3_complete sqlite3_api->complete
-#define sqlite3_complete16 sqlite3_api->complete16
-#define sqlite3_create_collation sqlite3_api->create_collation
-#define sqlite3_create_collation16 sqlite3_api->create_collation16
-#define sqlite3_create_function sqlite3_api->create_function
-#define sqlite3_create_function16 sqlite3_api->create_function16
-#define sqlite3_create_module sqlite3_api->create_module
-#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
-#define sqlite3_data_count sqlite3_api->data_count
-#define sqlite3_db_handle sqlite3_api->db_handle
-#define sqlite3_declare_vtab sqlite3_api->declare_vtab
-#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
-#define sqlite3_errcode sqlite3_api->errcode
-#define sqlite3_errmsg sqlite3_api->errmsg
-#define sqlite3_errmsg16 sqlite3_api->errmsg16
-#define sqlite3_exec sqlite3_api->exec
-#ifndef SQLITE_OMIT_DEPRECATED
-#define sqlite3_expired sqlite3_api->expired
-#endif
-#define sqlite3_finalize sqlite3_api->finalize
-#define sqlite3_free sqlite3_api->free
-#define sqlite3_free_table sqlite3_api->free_table
-#define sqlite3_get_autocommit sqlite3_api->get_autocommit
-#define sqlite3_get_auxdata sqlite3_api->get_auxdata
-#define sqlite3_get_table sqlite3_api->get_table
-#ifndef SQLITE_OMIT_DEPRECATED
-#define sqlite3_global_recover sqlite3_api->global_recover
-#endif
-#define sqlite3_interrupt sqlite3_api->interruptx
-#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
-#define sqlite3_libversion sqlite3_api->libversion
-#define sqlite3_libversion_number sqlite3_api->libversion_number
-#define sqlite3_malloc sqlite3_api->malloc
-#define sqlite3_mprintf sqlite3_api->mprintf
-#define sqlite3_open sqlite3_api->open
-#define sqlite3_open16 sqlite3_api->open16
-#define sqlite3_prepare sqlite3_api->prepare
-#define sqlite3_prepare16 sqlite3_api->prepare16
-#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
-#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
-#define sqlite3_profile sqlite3_api->profile
-#define sqlite3_progress_handler sqlite3_api->progress_handler
-#define sqlite3_realloc sqlite3_api->realloc
-#define sqlite3_reset sqlite3_api->reset
-#define sqlite3_result_blob sqlite3_api->result_blob
-#define sqlite3_result_double sqlite3_api->result_double
-#define sqlite3_result_error sqlite3_api->result_error
-#define sqlite3_result_error16 sqlite3_api->result_error16
-#define sqlite3_result_int sqlite3_api->result_int
-#define sqlite3_result_int64 sqlite3_api->result_int64
-#define sqlite3_result_null sqlite3_api->result_null
-#define sqlite3_result_text sqlite3_api->result_text
-#define sqlite3_result_text16 sqlite3_api->result_text16
-#define sqlite3_result_text16be sqlite3_api->result_text16be
-#define sqlite3_result_text16le sqlite3_api->result_text16le
-#define sqlite3_result_value sqlite3_api->result_value
-#define sqlite3_rollback_hook sqlite3_api->rollback_hook
-#define sqlite3_set_authorizer sqlite3_api->set_authorizer
-#define sqlite3_set_auxdata sqlite3_api->set_auxdata
-#define sqlite3_snprintf sqlite3_api->snprintf
-#define sqlite3_step sqlite3_api->step
-#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
-#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
-#define sqlite3_total_changes sqlite3_api->total_changes
-#define sqlite3_trace sqlite3_api->trace
-#ifndef SQLITE_OMIT_DEPRECATED
-#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
-#endif
-#define sqlite3_update_hook sqlite3_api->update_hook
-#define sqlite3_user_data sqlite3_api->user_data
-#define sqlite3_value_blob sqlite3_api->value_blob
-#define sqlite3_value_bytes sqlite3_api->value_bytes
-#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
-#define sqlite3_value_double sqlite3_api->value_double
-#define sqlite3_value_int sqlite3_api->value_int
-#define sqlite3_value_int64 sqlite3_api->value_int64
-#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
-#define sqlite3_value_text sqlite3_api->value_text
-#define sqlite3_value_text16 sqlite3_api->value_text16
-#define sqlite3_value_text16be sqlite3_api->value_text16be
-#define sqlite3_value_text16le sqlite3_api->value_text16le
-#define sqlite3_value_type sqlite3_api->value_type
-#define sqlite3_vmprintf sqlite3_api->vmprintf
-#define sqlite3_overload_function sqlite3_api->overload_function
-#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
-#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
-#define sqlite3_clear_bindings sqlite3_api->clear_bindings
-#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
-#define sqlite3_blob_bytes sqlite3_api->blob_bytes
-#define sqlite3_blob_close sqlite3_api->blob_close
-#define sqlite3_blob_open sqlite3_api->blob_open
-#define sqlite3_blob_read sqlite3_api->blob_read
-#define sqlite3_blob_write sqlite3_api->blob_write
-#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
-#define sqlite3_file_control sqlite3_api->file_control
-#define sqlite3_memory_highwater sqlite3_api->memory_highwater
-#define sqlite3_memory_used sqlite3_api->memory_used
-#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
-#define sqlite3_mutex_enter sqlite3_api->mutex_enter
-#define sqlite3_mutex_free sqlite3_api->mutex_free
-#define sqlite3_mutex_leave sqlite3_api->mutex_leave
-#define sqlite3_mutex_try sqlite3_api->mutex_try
-#define sqlite3_open_v2 sqlite3_api->open_v2
-#define sqlite3_release_memory sqlite3_api->release_memory
-#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
-#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
-#define sqlite3_sleep sqlite3_api->sleep
-#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
-#define sqlite3_vfs_find sqlite3_api->vfs_find
-#define sqlite3_vfs_register sqlite3_api->vfs_register
-#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
-#define sqlite3_threadsafe sqlite3_api->xthreadsafe
-#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
-#define sqlite3_result_error_code sqlite3_api->result_error_code
-#define sqlite3_test_control sqlite3_api->test_control
-#define sqlite3_randomness sqlite3_api->randomness
-#define sqlite3_context_db_handle sqlite3_api->context_db_handle
-#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
-#define sqlite3_limit sqlite3_api->limit
-#define sqlite3_next_stmt sqlite3_api->next_stmt
-#define sqlite3_sql sqlite3_api->sql
-#define sqlite3_status sqlite3_api->status
-#define sqlite3_backup_finish sqlite3_api->backup_finish
-#define sqlite3_backup_init sqlite3_api->backup_init
-#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
-#define sqlite3_backup_remaining sqlite3_api->backup_remaining
-#define sqlite3_backup_step sqlite3_api->backup_step
-#define sqlite3_compileoption_get sqlite3_api->compileoption_get
-#define sqlite3_compileoption_used sqlite3_api->compileoption_used
-#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
-#define sqlite3_db_config sqlite3_api->db_config
-#define sqlite3_db_mutex sqlite3_api->db_mutex
-#define sqlite3_db_status sqlite3_api->db_status
-#define sqlite3_extended_errcode sqlite3_api->extended_errcode
-#define sqlite3_log sqlite3_api->log
-#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
-#define sqlite3_sourceid sqlite3_api->sourceid
-#define sqlite3_stmt_status sqlite3_api->stmt_status
-#define sqlite3_strnicmp sqlite3_api->strnicmp
-#define sqlite3_unlock_notify sqlite3_api->unlock_notify
-#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
-#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
-#define sqlite3_wal_hook sqlite3_api->wal_hook
-#define sqlite3_blob_reopen sqlite3_api->blob_reopen
-#define sqlite3_vtab_config sqlite3_api->vtab_config
-#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
-/* Version 3.7.16 and later */
-#define sqlite3_close_v2 sqlite3_api->close_v2
-#define sqlite3_db_filename sqlite3_api->db_filename
-#define sqlite3_db_readonly sqlite3_api->db_readonly
-#define sqlite3_db_release_memory sqlite3_api->db_release_memory
-#define sqlite3_errstr sqlite3_api->errstr
-#define sqlite3_stmt_busy sqlite3_api->stmt_busy
-#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
-#define sqlite3_stricmp sqlite3_api->stricmp
-#define sqlite3_uri_boolean sqlite3_api->uri_boolean
-#define sqlite3_uri_int64 sqlite3_api->uri_int64
-#define sqlite3_uri_parameter sqlite3_api->uri_parameter
-#define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf
-#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
-#endif /* SQLITE_CORE */
-
-#ifndef SQLITE_CORE
- /* This case when the file really is being compiled as a loadable
- ** extension */
-# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
-# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
-# define SQLITE_EXTENSION_INIT3 \
- extern const sqlite3_api_routines *sqlite3_api;
-#else
- /* This case when the file is being statically linked into the
- ** application */
-# define SQLITE_EXTENSION_INIT1 /*no-op*/
-# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
-# define SQLITE_EXTENSION_INIT3 /*no-op*/
-#endif
-
-#endif /* _SQLITE3EXT_H_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mitchellh/mapstructure/.travis.yml
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mitchellh/mapstructure/.travis.yml b/Godeps/_workspace/src/github.com/mitchellh/mapstructure/.travis.yml
deleted file mode 100644
index 7f3fe9a..0000000
--- a/Godeps/_workspace/src/github.com/mitchellh/mapstructure/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: go
-
-go:
- - 1.4
-
-script:
- - go test
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/mitchellh/mapstructure/LICENSE
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/mitchellh/mapstructure/LICENSE b/Godeps/_workspace/src/github.com/mitchellh/mapstructure/LICENSE
deleted file mode 100644
index f9c841a..0000000
--- a/Godeps/_workspace/src/github.com/mitchellh/mapstructure/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2013 Mitchell Hashimoto
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.