Browse Source

git mod vendor

Teran McKinney 2 years ago
parent
commit
e1df2a5a5a
  1. 29
      vendor/github.com/bvinc/go-sqlite-lite/LICENSE
  2. 89
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/backup.go
  3. 238
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/const.go
  4. 182
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/io.go
  5. 460
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/session.go
  6. 222880
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/sqlite3.c
  7. 1339
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/sqlite3.go
  8. 11753
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/sqlite3.h
  9. 14
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/upgrading.md
  10. 385
      vendor/github.com/bvinc/go-sqlite-lite/sqlite3/util.go
  11. 24
      vendor/github.com/sporestack/settlers/LICENSE.md
  12. 13
      vendor/github.com/sporestack/settlers/README.md
  13. 11
      vendor/github.com/sporestack/settlers/errors.go
  14. 58
      vendor/github.com/sporestack/settlers/onion.go
  15. 26
      vendor/github.com/sporestack/settlers/request_types.go
  16. 204
      vendor/github.com/sporestack/settlers/settlers.go
  17. 13
      vendor/github.com/sporestack/settlers/settlersd.service
  18. 71
      vendor/github.com/sporestack/settlers/test.sh
  19. 3
      vendor/golang.org/x/net/AUTHORS
  20. 3
      vendor/golang.org/x/net/CONTRIBUTORS
  21. 27
      vendor/golang.org/x/net/LICENSE
  22. 22
      vendor/golang.org/x/net/PATENTS
  23. 168
      vendor/golang.org/x/net/internal/socks/client.go
  24. 317
      vendor/golang.org/x/net/internal/socks/socks.go
  25. 54
      vendor/golang.org/x/net/proxy/dial.go
  26. 31
      vendor/golang.org/x/net/proxy/direct.go
  27. 155
      vendor/golang.org/x/net/proxy/per_host.go
  28. 149
      vendor/golang.org/x/net/proxy/proxy.go
  29. 42
      vendor/golang.org/x/net/proxy/socks5.go
  30. 9
      vendor/gopkg.in/alexcesaro/statsd.v2/.travis.yml
  31. 64
      vendor/gopkg.in/alexcesaro/statsd.v2/CHANGELOG.md
  32. 20
      vendor/gopkg.in/alexcesaro/statsd.v2/LICENSE
  33. 50
      vendor/gopkg.in/alexcesaro/statsd.v2/README.md
  34. 270
      vendor/gopkg.in/alexcesaro/statsd.v2/conn.go
  35. 29
      vendor/gopkg.in/alexcesaro/statsd.v2/doc.go
  36. 250
      vendor/gopkg.in/alexcesaro/statsd.v2/options.go
  37. 169
      vendor/gopkg.in/alexcesaro/statsd.v2/statsd.go
  38. 9
      vendor/modules.txt

29
vendor/github.com/bvinc/go-sqlite-lite/LICENSE generated vendored

@ -0,0 +1,29 @@
Copyright (c) 2018 The go-sqlite-lite Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.
* Neither the name of the go-sqlite-lite project nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

89
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/backup.go generated vendored

@ -0,0 +1,89 @@
// Copyright 2018 The go-sqlite-lite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite3
/*
#include "sqlite3.h"
*/
import "C"
import (
"io"
)
// Backup is a handle to an online backup operation between two databases.
// https://www.sqlite.org/c3ref/backup.html
type Backup struct {
src *Conn
dst *Conn
bkup *C.sqlite3_backup
}
// newBackup initializes an online backup operation from src.srcName to
// dst.dstName.
func newBackup(src *Conn, srcName string, dst *Conn, dstName string) (*Backup, error) {
srcName += "\x00"
dstName += "\x00"
bkup := C.sqlite3_backup_init(dst.db, cStr(dstName), src.db, cStr(srcName))
if bkup == nil {
return nil, libErr(C.sqlite3_errcode(dst.db), dst.db)
}
b := &Backup{src, dst, bkup}
return b, nil
}
// Close releases all resources associated with the backup operation. It is safe
// to call this method prior to backup completion to abort the operation.
// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish
func (b *Backup) Close() error {
if bkup := b.bkup; bkup != nil {
b.bkup = nil
if rc := C.sqlite3_backup_finish(bkup); rc != OK {
return libErr(rc, b.dst.db)
}
}
return nil
}
// Conn returns the source and destination connections that are used by this
// backup operation. The destination connection must not be used until the
// backup operation is closed.
func (b *Backup) Conn() (src, dst *Conn) {
return b.src, b.dst
}
// Step copies up to n pages to the destination database. If n is negative, all
// remaining pages are copied. io.EOF is returned upon successful backup
// completion.
// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupstep
func (b *Backup) Step(n int) error {
if b.bkup == nil {
return ErrBadBackup
}
if rc := C.sqlite3_backup_step(b.bkup, C.int(n)); rc != OK {
// Do not close automatically since that clears the progress info
if rc == DONE {
return io.EOF
}
return libErr(rc, b.dst.db)
}
return nil
}
// Progress returns the number of pages that still need to be backed up and the
// total number of pages in the source database. The values are updated after
// each call to Step and are reset to 0 after the backup is closed. The total
// number of pages may change if the source database is modified during the
// backup operation.
// https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining
func (b *Backup) Progress() (remaining, total int) {
if b.bkup != nil {
remaining = int(C.sqlite3_backup_remaining(b.bkup))
total = int(C.sqlite3_backup_pagecount(b.bkup))
}
return
}

238
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/const.go generated vendored

@ -0,0 +1,238 @@
// Copyright 2018 The go-sqlite-lite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite3
/*
#include "sqlite3.h"
*/
import "C"
// Fundamental SQLite data types. These are returned by Stmt.DataTypes method.
// https://www.sqlite.org/c3ref/c_blob.html
const (
INTEGER = C.SQLITE_INTEGER // 1
FLOAT = C.SQLITE_FLOAT // 2
TEXT = C.SQLITE_TEXT // 3
BLOB = C.SQLITE_BLOB // 4
NULL = C.SQLITE_NULL // 5
)
// Flags that can be provided to Open
// https://www.sqlite.org/c3ref/open.html
const (
OPEN_READONLY = C.SQLITE_OPEN_READONLY // Ok for sqlite3_open_v2()
OPEN_READWRITE = C.SQLITE_OPEN_READWRITE // Ok for sqlite3_open_v2()
OPEN_CREATE = C.SQLITE_OPEN_CREATE // Ok for sqlite3_open_v2()
OPEN_DELETEONCLOSE = C.SQLITE_OPEN_DELETEONCLOSE // VFS only
OPEN_EXCLUSIVE = C.SQLITE_OPEN_EXCLUSIVE // VFS only
OPEN_AUTOPROXY = C.SQLITE_OPEN_AUTOPROXY // VFS only
OPEN_URI = C.SQLITE_OPEN_URI // Ok for sqlite3_open_v2()
OPEN_MEMORY = C.SQLITE_OPEN_MEMORY // Ok for sqlite3_open_v2()
OPEN_MAIN_DB = C.SQLITE_OPEN_MAIN_DB // VFS only
OPEN_TEMP_DB = C.SQLITE_OPEN_TEMP_DB // VFS only
OPEN_TRANSIENT_DB = C.SQLITE_OPEN_TRANSIENT_DB // VFS only
OPEN_MAIN_JOURNAL = C.SQLITE_OPEN_MAIN_JOURNAL // VFS only
OPEN_TEMP_JOURNAL = C.SQLITE_OPEN_TEMP_JOURNAL // VFS only
OPEN_SUBJOURNAL = C.SQLITE_OPEN_SUBJOURNAL // VFS only
OPEN_MASTER_JOURNAL = C.SQLITE_OPEN_MASTER_JOURNAL // VFS only
OPEN_NOMUTEX = C.SQLITE_OPEN_NOMUTEX // Ok for sqlite3_open_v2()
OPEN_FULLMUTEX = C.SQLITE_OPEN_FULLMUTEX // Ok for sqlite3_open_v2()
OPEN_SHAREDCACHE = C.SQLITE_OPEN_SHAREDCACHE // Ok for sqlite3_open_v2()
OPEN_PRIVATECACHE = C.SQLITE_OPEN_PRIVATECACHE // Ok for sqlite3_open_v2()
OPEN_WAL = C.SQLITE_OPEN_WAL // VFS only
)
// General result codes returned by the SQLite API. When converted to an error,
// OK and ROW become nil, and DONE becomes either nil or io.EOF, depending on
// the context in which the statement is executed. All other codes are returned
// via the Error struct.
// https://www.sqlite.org/c3ref/c_abort.html
const (
OK = C.SQLITE_OK // 0 = Successful result
ERROR = C.SQLITE_ERROR // 1 = SQL error or missing database
INTERNAL = C.SQLITE_INTERNAL // 2 = Internal logic error in SQLite
PERM = C.SQLITE_PERM // 3 = Access permission denied
ABORT = C.SQLITE_ABORT // 4 = Callback routine requested an abort
BUSY = C.SQLITE_BUSY // 5 = The database file is locked
LOCKED = C.SQLITE_LOCKED // 6 = A table in the database is locked
NOMEM = C.SQLITE_NOMEM // 7 = A malloc() failed
READONLY = C.SQLITE_READONLY // 8 = Attempt to write a readonly database
INTERRUPT = C.SQLITE_INTERRUPT // 9 = Operation terminated by sqlite3_interrupt()
IOERR = C.SQLITE_IOERR // 10 = Some kind of disk I/O error occurred
CORRUPT = C.SQLITE_CORRUPT // 11 = The database disk image is malformed
NOTFOUND = C.SQLITE_NOTFOUND // 12 = Unknown opcode in sqlite3_file_control()
FULL = C.SQLITE_FULL // 13 = Insertion failed because database is full
CANTOPEN = C.SQLITE_CANTOPEN // 14 = Unable to open the database file
PROTOCOL = C.SQLITE_PROTOCOL // 15 = Database lock protocol error
EMPTY = C.SQLITE_EMPTY // 16 = Database is empty
SCHEMA = C.SQLITE_SCHEMA // 17 = The database schema changed
TOOBIG = C.SQLITE_TOOBIG // 18 = String or BLOB exceeds size limit
CONSTRAINT = C.SQLITE_CONSTRAINT // 19 = Abort due to constraint violation
MISMATCH = C.SQLITE_MISMATCH // 20 = Data type mismatch
MISUSE = C.SQLITE_MISUSE // 21 = Library used incorrectly
NOLFS = C.SQLITE_NOLFS // 22 = Uses OS features not supported on host
AUTH = C.SQLITE_AUTH // 23 = Authorization denied
FORMAT = C.SQLITE_FORMAT // 24 = Auxiliary database format error
RANGE = C.SQLITE_RANGE // 25 = 2nd parameter to sqlite3_bind out of range
NOTADB = C.SQLITE_NOTADB // 26 = File opened that is not a database file
NOTICE = C.SQLITE_NOTICE // 27 = Notifications from sqlite3_log()
WARNING = C.SQLITE_WARNING // 28 = Warnings from sqlite3_log()
ROW = C.SQLITE_ROW // 100 = sqlite3_step() has another row ready
DONE = C.SQLITE_DONE // 101 = sqlite3_step() has finished executing
)
// Extended result codes returned by the SQLite API. Extended result codes are
// enabled by default for all new Conn objects. Use Error.Code()&0xFF to convert
// an extended code to a general one.
// https://www.sqlite.org/c3ref/c_abort_rollback.html
const (
IOERR_READ = C.SQLITE_IOERR_READ // (SQLITE_IOERR | (1<<8))
IOERR_SHORT_READ = C.SQLITE_IOERR_SHORT_READ // (SQLITE_IOERR | (2<<8))
IOERR_WRITE = C.SQLITE_IOERR_WRITE // (SQLITE_IOERR | (3<<8))
IOERR_FSYNC = C.SQLITE_IOERR_FSYNC // (SQLITE_IOERR | (4<<8))
IOERR_DIR_FSYNC = C.SQLITE_IOERR_DIR_FSYNC // (SQLITE_IOERR | (5<<8))
IOERR_TRUNCATE = C.SQLITE_IOERR_TRUNCATE // (SQLITE_IOERR | (6<<8))
IOERR_FSTAT = C.SQLITE_IOERR_FSTAT // (SQLITE_IOERR | (7<<8))
IOERR_UNLOCK = C.SQLITE_IOERR_UNLOCK // (SQLITE_IOERR | (8<<8))
IOERR_RDLOCK = C.SQLITE_IOERR_RDLOCK // (SQLITE_IOERR | (9<<8))
IOERR_DELETE = C.SQLITE_IOERR_DELETE // (SQLITE_IOERR | (10<<8))
IOERR_BLOCKED = C.SQLITE_IOERR_BLOCKED // (SQLITE_IOERR | (11<<8))
IOERR_NOMEM = C.SQLITE_IOERR_NOMEM // (SQLITE_IOERR | (12<<8))
IOERR_ACCESS = C.SQLITE_IOERR_ACCESS // (SQLITE_IOERR | (13<<8))
IOERR_CHECKRESERVEDLOCK = C.SQLITE_IOERR_CHECKRESERVEDLOCK // (SQLITE_IOERR | (14<<8))
IOERR_LOCK = C.SQLITE_IOERR_LOCK // (SQLITE_IOERR | (15<<8))
IOERR_CLOSE = C.SQLITE_IOERR_CLOSE // (SQLITE_IOERR | (16<<8))
IOERR_DIR_CLOSE = C.SQLITE_IOERR_DIR_CLOSE // (SQLITE_IOERR | (17<<8))
IOERR_SHMOPEN = C.SQLITE_IOERR_SHMOPEN // (SQLITE_IOERR | (18<<8))
IOERR_SHMSIZE = C.SQLITE_IOERR_SHMSIZE // (SQLITE_IOERR | (19<<8))
IOERR_SHMLOCK = C.SQLITE_IOERR_SHMLOCK // (SQLITE_IOERR | (20<<8))
IOERR_SHMMAP = C.SQLITE_IOERR_SHMMAP // (SQLITE_IOERR | (21<<8))
IOERR_SEEK = C.SQLITE_IOERR_SEEK // (SQLITE_IOERR | (22<<8))
IOERR_DELETE_NOENT = C.SQLITE_IOERR_DELETE_NOENT // (SQLITE_IOERR | (23<<8))
IOERR_MMAP = C.SQLITE_IOERR_MMAP // (SQLITE_IOERR | (24<<8))
IOERR_GETTEMPPATH = C.SQLITE_IOERR_GETTEMPPATH // (SQLITE_IOERR | (25<<8))
IOERR_CONVPATH = C.SQLITE_IOERR_CONVPATH // (SQLITE_IOERR | (26<<8))
LOCKED_SHAREDCACHE = C.SQLITE_LOCKED_SHAREDCACHE // (SQLITE_LOCKED | (1<<8))
BUSY_RECOVERY = C.SQLITE_BUSY_RECOVERY // (SQLITE_BUSY | (1<<8))
BUSY_SNAPSHOT = C.SQLITE_BUSY_SNAPSHOT // (SQLITE_BUSY | (2<<8))
CANTOPEN_NOTEMPDIR = C.SQLITE_CANTOPEN_NOTEMPDIR // (SQLITE_CANTOPEN | (1<<8))
CANTOPEN_ISDIR = C.SQLITE_CANTOPEN_ISDIR // (SQLITE_CANTOPEN | (2<<8))
CANTOPEN_FULLPATH = C.SQLITE_CANTOPEN_FULLPATH // (SQLITE_CANTOPEN | (3<<8))
CANTOPEN_CONVPATH = C.SQLITE_CANTOPEN_CONVPATH // (SQLITE_CANTOPEN | (4<<8))
CORRUPT_VTAB = C.SQLITE_CORRUPT_VTAB // (SQLITE_CORRUPT | (1<<8))
READONLY_RECOVERY = C.SQLITE_READONLY_RECOVERY // (SQLITE_READONLY | (1<<8))
READONLY_CANTLOCK = C.SQLITE_READONLY_CANTLOCK // (SQLITE_READONLY | (2<<8))
READONLY_ROLLBACK = C.SQLITE_READONLY_ROLLBACK // (SQLITE_READONLY | (3<<8))
READONLY_DBMOVED = C.SQLITE_READONLY_DBMOVED // (SQLITE_READONLY | (4<<8))
ABORT_ROLLBACK = C.SQLITE_ABORT_ROLLBACK // (SQLITE_ABORT | (2<<8))
CONSTRAINT_CHECK = C.SQLITE_CONSTRAINT_CHECK // (SQLITE_CONSTRAINT | (1<<8))
CONSTRAINT_COMMITHOOK = C.SQLITE_CONSTRAINT_COMMITHOOK // (SQLITE_CONSTRAINT | (2<<8))
CONSTRAINT_FOREIGNKEY = C.SQLITE_CONSTRAINT_FOREIGNKEY // (SQLITE_CONSTRAINT | (3<<8))
CONSTRAINT_FUNCTION = C.SQLITE_CONSTRAINT_FUNCTION // (SQLITE_CONSTRAINT | (4<<8))
CONSTRAINT_NOTNULL = C.SQLITE_CONSTRAINT_NOTNULL // (SQLITE_CONSTRAINT | (5<<8))
CONSTRAINT_PRIMARYKEY = C.SQLITE_CONSTRAINT_PRIMARYKEY // (SQLITE_CONSTRAINT | (6<<8))
CONSTRAINT_TRIGGER = C.SQLITE_CONSTRAINT_TRIGGER // (SQLITE_CONSTRAINT | (7<<8))
CONSTRAINT_UNIQUE = C.SQLITE_CONSTRAINT_UNIQUE // (SQLITE_CONSTRAINT | (8<<8))
CONSTRAINT_VTAB = C.SQLITE_CONSTRAINT_VTAB // (SQLITE_CONSTRAINT | (9<<8))
CONSTRAINT_ROWID = C.SQLITE_CONSTRAINT_ROWID // (SQLITE_CONSTRAINT |(10<<8))
NOTICE_RECOVER_WAL = C.SQLITE_NOTICE_RECOVER_WAL // (SQLITE_NOTICE | (1<<8))
NOTICE_RECOVER_ROLLBACK = C.SQLITE_NOTICE_RECOVER_ROLLBACK // (SQLITE_NOTICE | (2<<8))
WARNING_AUTOINDEX = C.SQLITE_WARNING_AUTOINDEX // (SQLITE_WARNING | (1<<8))
)
// Codes used by SQLite to indicate the operation type when invoking authorizer
// and row update callbacks.
// https://www.sqlite.org/c3ref/c_alter_table.html
const (
CREATE_INDEX = C.SQLITE_CREATE_INDEX // 1
CREATE_TABLE = C.SQLITE_CREATE_TABLE // 2
CREATE_TEMP_INDEX = C.SQLITE_CREATE_TEMP_INDEX // 3
CREATE_TEMP_TABLE = C.SQLITE_CREATE_TEMP_TABLE // 4
CREATE_TEMP_TRIGGER = C.SQLITE_CREATE_TEMP_TRIGGER // 5
CREATE_TEMP_VIEW = C.SQLITE_CREATE_TEMP_VIEW // 6
CREATE_TRIGGER = C.SQLITE_CREATE_TRIGGER // 7
CREATE_VIEW = C.SQLITE_CREATE_VIEW // 8
DELETE = C.SQLITE_DELETE // 9
DROP_INDEX = C.SQLITE_DROP_INDEX // 10
DROP_TABLE = C.SQLITE_DROP_TABLE // 11
DROP_TEMP_INDEX = C.SQLITE_DROP_TEMP_INDEX // 12
DROP_TEMP_TABLE = C.SQLITE_DROP_TEMP_TABLE // 13
DROP_TEMP_TRIGGER = C.SQLITE_DROP_TEMP_TRIGGER // 14
DROP_TEMP_VIEW = C.SQLITE_DROP_TEMP_VIEW // 15
DROP_TRIGGER = C.SQLITE_DROP_TRIGGER // 16
DROP_VIEW = C.SQLITE_DROP_VIEW // 17
INSERT = C.SQLITE_INSERT // 18
PRAGMA = C.SQLITE_PRAGMA // 19
READ = C.SQLITE_READ // 20
SELECT = C.SQLITE_SELECT // 21
TRANSACTION = C.SQLITE_TRANSACTION // 22
UPDATE = C.SQLITE_UPDATE // 23
ATTACH = C.SQLITE_ATTACH // 24
DETACH = C.SQLITE_DETACH // 25
ALTER_TABLE = C.SQLITE_ALTER_TABLE // 26
REINDEX = C.SQLITE_REINDEX // 27
ANALYZE = C.SQLITE_ANALYZE // 28
CREATE_VTABLE = C.SQLITE_CREATE_VTABLE // 29
DROP_VTABLE = C.SQLITE_DROP_VTABLE // 30
FUNCTION = C.SQLITE_FUNCTION // 31
SAVEPOINT = C.SQLITE_SAVEPOINT // 32
RECURSIVE = C.SQLITE_RECURSIVE // 33
)
// Core SQLite performance counters that can be queried with Status.
// https://www.sqlite.org/c3ref/c_status_malloc_count.html
const (
STATUS_MEMORY_USED = C.SQLITE_STATUS_MEMORY_USED // 0
STATUS_PAGECACHE_USED = C.SQLITE_STATUS_PAGECACHE_USED // 1
STATUS_PAGECACHE_OVERFLOW = C.SQLITE_STATUS_PAGECACHE_OVERFLOW // 2
STATUS_SCRATCH_USED = C.SQLITE_STATUS_SCRATCH_USED // 3
STATUS_SCRATCH_OVERFLOW = C.SQLITE_STATUS_SCRATCH_OVERFLOW // 4
STATUS_MALLOC_SIZE = C.SQLITE_STATUS_MALLOC_SIZE // 5
STATUS_PARSER_STACK = C.SQLITE_STATUS_PARSER_STACK // 6
STATUS_PAGECACHE_SIZE = C.SQLITE_STATUS_PAGECACHE_SIZE // 7
STATUS_SCRATCH_SIZE = C.SQLITE_STATUS_SCRATCH_SIZE // 8
STATUS_MALLOC_COUNT = C.SQLITE_STATUS_MALLOC_COUNT // 9
)
// Connection performance counters that can be queried with Conn.Status.
// https://www.sqlite.org/c3ref/c_dbstatus_options.html
const (
DBSTATUS_LOOKASIDE_USED = C.SQLITE_DBSTATUS_LOOKASIDE_USED // 0
DBSTATUS_CACHE_USED = C.SQLITE_DBSTATUS_CACHE_USED // 1
DBSTATUS_SCHEMA_USED = C.SQLITE_DBSTATUS_SCHEMA_USED // 2
DBSTATUS_STMT_USED = C.SQLITE_DBSTATUS_STMT_USED // 3
DBSTATUS_LOOKASIDE_HIT = C.SQLITE_DBSTATUS_LOOKASIDE_HIT // 4
DBSTATUS_LOOKASIDE_MISS_SIZE = C.SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE // 5
DBSTATUS_LOOKASIDE_MISS_FULL = C.SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL // 6
DBSTATUS_CACHE_HIT = C.SQLITE_DBSTATUS_CACHE_HIT // 7
DBSTATUS_CACHE_MISS = C.SQLITE_DBSTATUS_CACHE_MISS // 8
DBSTATUS_CACHE_WRITE = C.SQLITE_DBSTATUS_CACHE_WRITE // 9
DBSTATUS_DEFERRED_FKS = C.SQLITE_DBSTATUS_DEFERRED_FKS // 10
)
// Statement performance counters that can be queried with Stmt.Status.
// https://www.sqlite.org/c3ref/c_stmtstatus_counter.html
const (
STMTSTATUS_FULLSCAN_STEP = C.SQLITE_STMTSTATUS_FULLSCAN_STEP // 1
STMTSTATUS_SORT = C.SQLITE_STMTSTATUS_SORT // 2
STMTSTATUS_AUTOINDEX = C.SQLITE_STMTSTATUS_AUTOINDEX // 3
STMTSTATUS_VM_STEP = C.SQLITE_STMTSTATUS_VM_STEP // 4
)
// Per-connection limits that can be queried and changed with Conn.Limit.
// https://www.sqlite.org/c3ref/c_limit_attached.html
const (
LIMIT_LENGTH = C.SQLITE_LIMIT_LENGTH // 0
LIMIT_SQL_LENGTH = C.SQLITE_LIMIT_SQL_LENGTH // 1
LIMIT_COLUMN = C.SQLITE_LIMIT_COLUMN // 2
LIMIT_EXPR_DEPTH = C.SQLITE_LIMIT_EXPR_DEPTH // 3
LIMIT_COMPOUND_SELECT = C.SQLITE_LIMIT_COMPOUND_SELECT // 4
LIMIT_VDBE_OP = C.SQLITE_LIMIT_VDBE_OP // 5
LIMIT_FUNCTION_ARG = C.SQLITE_LIMIT_FUNCTION_ARG // 6
LIMIT_ATTACHED = C.SQLITE_LIMIT_ATTACHED // 7
LIMIT_LIKE_PATTERN_LENGTH = C.SQLITE_LIMIT_LIKE_PATTERN_LENGTH // 8
LIMIT_VARIABLE_NUMBER = C.SQLITE_LIMIT_VARIABLE_NUMBER // 9
LIMIT_TRIGGER_DEPTH = C.SQLITE_LIMIT_TRIGGER_DEPTH // 10
)

182
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/io.go generated vendored

@ -0,0 +1,182 @@
// Copyright 2018 The go-sqlite-lite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite3
/*
#include "sqlite3.h"
*/
import "C"
import (
"io"
"runtime"
)
// ErrBlobFull is returned by BlobIO.Write when there isn't enough space left to
// write the provided bytes.
var ErrBlobFull = &Error{ERROR, "incremental write failed, no space left"}
// BlobIO is a handle to a single BLOB (binary large object) or TEXT value
// opened for incremental I/O. This allows the value to be treated as a file for
// reading and writing. The value length cannot be changed using this API; use
// an UPDATE statement for that. The recommended way of allocating space for a
// BLOB is to use the ZeroBlob type or the zeroblob() SQL function.
// https://www.sqlite.org/c3ref/blob.html
type BlobIO struct {
conn *Conn
blob *C.sqlite3_blob
row int64 // ROWID of the row containing the BLOB/TEXT value
len int // Value length in bytes
off int // Current read/write offset
}
// newBlobIO initializes an incremental I/O operation.
func newBlobIO(c *Conn, db, tbl, col string, row int64, rw bool) (*BlobIO, error) {
db += "\x00"
tbl += "\x00"
col += "\x00"
var blob *C.sqlite3_blob
rc := C.sqlite3_blob_open(c.db, cStr(db), cStr(tbl), cStr(col),
C.sqlite3_int64(row), cBool(rw), &blob)
if rc != OK {
return nil, libErr(rc, c.db)
}
b := &BlobIO{
conn: c,
blob: blob,
row: row,
len: int(C.sqlite3_blob_bytes(blob)),
}
runtime.SetFinalizer(b, (*BlobIO).Close)
return b, nil
}
// Close releases all resources associated with the incremental I/O operation.
// It is important to check the error returned by this method, since disk I/O
// and other types of errors may not be reported until the changes are actually
// committed to the database.
// https://www.sqlite.org/c3ref/blob_close.html
func (b *BlobIO) Close() error {
if blob := b.blob; blob != nil {
b.blob = nil
b.len = 0
b.off = 0
runtime.SetFinalizer(b, nil)
if rc := C.sqlite3_blob_close(blob); rc != OK {
return libErr(rc, b.conn.db)
}
}
return nil
}
// Conn returns the connection that that created this incremental I/O operation.
func (b *BlobIO) Conn() *Conn {
return b.conn
}
// Row returns the ROWID of the row containing the BLOB/TEXT value.
func (b *BlobIO) Row() int64 {
return b.row
}
// Len returns the length of the BLOB/TEXT value in bytes. It is not possible to
// read/write/seek beyond this length. The length changes to 0 if the I/O handle
// expires due to an update of any column in the same row. This condition is
// indicated by an ABORT error code returned from Read or Write. An expired
// handle is closed automatically and cannot be reopened. Any writes that
// occurred before the abort are not rolled back.
// https://www.sqlite.org/c3ref/blob_bytes.html
func (b *BlobIO) Len() int {
return b.len
}
// Read implements the io.Reader interface.
// https://www.sqlite.org/c3ref/blob_read.html
func (b *BlobIO) Read(p []byte) (n int, err error) {
if b.blob == nil {
return 0, ErrBadIO
}
if b.off >= b.len {
return 0, io.EOF
}
if n = b.len - b.off; len(p) < n {
n = len(p)
}
rc := C.sqlite3_blob_read(b.blob, cBytes(p), C.int(n), C.int(b.off))
return b.io(rc, n)
}
// Write implements the io.Writer interface. The number of bytes written is
// always either 0 or len(p). ErrBlobFull is returned if there isn't enough
// space left to write all of p.
// https://www.sqlite.org/c3ref/blob_write.html
func (b *BlobIO) Write(p []byte) (n int, err error) {
if b.blob == nil {
return 0, ErrBadIO
}
if n = len(p); b.off+n > b.len {
// Doesn't make sense to do a partial write. Better to return quickly
// and let the caller reallocate the BLOB.
return 0, ErrBlobFull
}
rc := C.sqlite3_blob_write(b.blob, cBytes(p), C.int(n), C.int(b.off))
return b.io(rc, n)
}
// Seek implements the io.Seeker interface.
func (b *BlobIO) Seek(offset int64, whence int) (ret int64, err error) {
if b.blob == nil {
return 0, ErrBadIO
}
switch whence {
case 0:
case 1:
offset += int64(b.off)
case 2:
offset += int64(b.len)
default:
return 0, pkgErr(MISUSE, "invalid whence for BlobIO.Seek (%d)", whence)
}
if offset < 0 || offset > int64(b.len) {
return 0, pkgErr(MISUSE, "invalid offset for BlobIO.Seek (%d)", offset)
}
b.off = int(offset)
return offset, nil
}
// Reopen closes the current value and opens another one in the same column,
// specified by its ROWID. If an error is encountered, the I/O handle becomes
// unusable and is automatically closed.
// https://www.sqlite.org/c3ref/blob_reopen.html
func (b *BlobIO) Reopen(row int64) error {
if b.blob == nil {
return ErrBadIO
}
if rc := C.sqlite3_blob_reopen(b.blob, C.sqlite3_int64(row)); rc != OK {
err := libErr(rc, b.conn.db)
b.Close()
return err
}
b.row = row
b.len = int(C.sqlite3_blob_bytes(b.blob))
b.off = 0
return nil
}
// io handles the completion of a single Read/Write call.
func (b *BlobIO) io(rc C.int, n int) (int, error) {
if rc == OK {
b.off += n
return n, nil
}
err := libErr(rc, b.conn.db)
if rc == ABORT {
b.Close()
}
return 0, err
}

460
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/session.go generated vendored

@ -0,0 +1,460 @@
// Copyright 2018 The go-sqlite-lite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// This code was adapted from David Crawshaw's sqlite driver.
// https://github.com/crawshaw/sqlite
// The license to the original code is as follows:
//
// Copyright (c) 2018 David Crawshaw <david@zentus.com>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package sqlite3
/*
#include "sqlite3.h"
extern int strm_r_tramp(void*, char*, int*);
extern int strm_w_tramp(void*, char*, int);
extern int xapply_conflict_tramp(void*, int, sqlite3_changeset_iter*);
extern int xapply_filter_tramp(void*, char*);
*/
import "C"
import (
"io"
"unsafe"
)
var strmWriterReg = newRegistry()
var strmReaderReg = newRegistry()
var xapplyReg = newRegistry()
type Session struct {
sess *C.sqlite3_session
}
// CreateSession creates a new session object.
// https://www.sqlite.org/session/sqlite3session_create.html
func (conn *Conn) CreateSession(db string) (*Session, error) {
db += "\x00"
s := &Session{}
rc := C.sqlite3session_create(conn.db, cStr(db), &s.sess)
if rc != OK {
return nil, errStr(rc)
}
return s, nil
}
// Close closes a session object previously created with CreateSession.
// https://www.sqlite.org/session/sqlite3session_delete.html
func (s *Session) Close() {
C.sqlite3session_delete(s.sess)
s.sess = nil
}
// Enable enables recording of changes by a Session.
// New Sessions start enabled.
// https://www.sqlite.org/session/sqlite3session_enable.html
func (s *Session) Enable() {
C.sqlite3session_enable(s.sess, 1)
}
// Disable disables recording of changes by a Session.
// https://www.sqlite.org/session/sqlite3session_enable.html
func (s *Session) Disable() {
C.sqlite3session_enable(s.sess, 0)
}
// IsEnabled queries if the session is currently enabled.
// https://www.sqlite.org/session/sqlite3session_enable.html
func (s *Session) IsEnabled() bool {
return C.sqlite3session_enable(s.sess, -1) != 0
}
// https://sqlite.org/session/sqlite3session_indirect.html
func (s *Session) IsIndirect() bool {
return C.sqlite3session_indirect(s.sess, -1) != 0
}
// https://sqlite.org/session/sqlite3session_indirect.html
func (s *Session) SetIndirect(indirect bool) {
C.sqlite3session_indirect(s.sess, cBool(indirect))
}
// https://sqlite.org/session/sqlite3session_isempty.html
func (s *Session) IsEmpty() bool {
return C.sqlite3session_isempty(s.sess) != 0
}
// Attach attaches a table to a session object. If the argument tab is equal
// to "", then changes are recorded for all tables in the database.
// https://www.sqlite.org/session/sqlite3session_attach.html
func (s *Session) Attach(tab string) error {
var zTab *C.char
if tab != "" {
zTab = cStr(tab + "\x00")
}
rc := C.sqlite3session_attach(s.sess, zTab)
if rc != OK {
return errStr(rc)
}
return nil
}
func (s *Session) Diff(fromDB, tbl string) error {
fromDB += "\x00"
tbl += "\x00"
// TODO: provide a pointer to get a more accurate error message
rc := C.sqlite3session_diff(s.sess, cStr(fromDB), cStr(tbl), nil)
if rc != OK {
return errStr(rc)
}
return nil
}
func (s *Session) Changeset(w io.Writer) error {
idx := strmWriterReg.register(w)
defer strmWriterReg.unregister(idx)
rc := C.sqlite3session_changeset_strm(s.sess, (*[0]byte)(C.strm_w_tramp), unsafe.Pointer(&idx))
if rc != OK {
return errStr(rc)
}
return nil
}
// https://www.sqlite.org/session/sqlite3session_patchset.html
func (s *Session) Patchset(w io.Writer) error {
idx := strmWriterReg.register(w)
defer strmWriterReg.unregister(idx)
rc := C.sqlite3session_patchset_strm(s.sess, (*[0]byte)(C.strm_w_tramp), unsafe.Pointer(&idx))
if rc != OK {
return errStr(rc)
}
return nil
}
// https://www.sqlite.org/session/sqlite3changeset_apply.html
func (conn *Conn) ChangesetApply(r io.Reader, filterFn func(tableName string) bool, conflictFn func(ConflictType, ChangesetIter) ConflictAction) error {
readerIdx := strmReaderReg.register(r)
defer strmReaderReg.unregister(readerIdx)
x := &xapply{
conn: conn,
filterFn: filterFn,
conflictFn: conflictFn,
}
xapplyIdx := xapplyReg.register(x)
defer xapplyReg.unregister(xapplyIdx)
var filterTramp, conflictTramp *[0]byte
if x.filterFn != nil {
filterTramp = (*[0]byte)(C.xapply_filter_tramp)
}
if x.conflictFn != nil {
conflictTramp = (*[0]byte)(C.xapply_conflict_tramp)
}
rc := C.sqlite3changeset_apply_strm(conn.db, (*[0]byte)(C.strm_r_tramp), unsafe.Pointer(&readerIdx), filterTramp, conflictTramp, unsafe.Pointer(&xapplyIdx))
if rc != OK {
return errStr(rc)
}
return nil
}
// https://www.sqlite.org/session/sqlite3changeset_invert.html
func ChangesetInvert(w io.Writer, r io.Reader) error {
readerIdx := strmReaderReg.register(r)
defer strmReaderReg.unregister(readerIdx)
writerIdx := strmWriterReg.register(w)
defer strmWriterReg.unregister(writerIdx)
rc := C.sqlite3changeset_invert_strm(
(*[0]byte)(C.strm_r_tramp), unsafe.Pointer(&readerIdx),
(*[0]byte)(C.strm_w_tramp), unsafe.Pointer(&writerIdx),
)
if rc != OK {
return errStr(rc)
}
return nil
}
// https://www.sqlite.org/session/sqlite3changeset_concat.html
func ChangesetConcat(w io.Writer, r1, r2 io.Reader) error {
readerIdx1 := strmReaderReg.register(r1)
defer strmReaderReg.unregister(readerIdx1)
readerIdx2 := strmReaderReg.register(r2)
defer strmReaderReg.unregister(readerIdx2)
writerIdx := strmWriterReg.register(w)
defer strmWriterReg.unregister(writerIdx)
rc := C.sqlite3changeset_concat_strm(
(*[0]byte)(C.strm_r_tramp), unsafe.Pointer(&readerIdx1),
(*[0]byte)(C.strm_r_tramp), unsafe.Pointer(&readerIdx2),
(*[0]byte)(C.strm_w_tramp), unsafe.Pointer(&writerIdx),
)
if rc != OK {
return errStr(rc)
}
return nil
}
type ChangesetIter struct {
ptr *C.sqlite3_changeset_iter
readerIdx *int
reader io.Reader
}
// https://www.sqlite.org/session/sqlite3changeset_start.html
func ChangesetIterStart(r io.Reader) (ChangesetIter, error) {
idx := strmReaderReg.register(r)
iter := ChangesetIter{
reader: r,
readerIdx: new(int),
}
*iter.readerIdx = idx
// rc := C.sqlite3changeset_start_strm(&iter.ptr, (*[0]byte)(C.strm_r_tramp), unsafe.Pointer(&iter.readerIdx))
rc := C.sqlite3changeset_start_strm(&iter.ptr, (*[0]byte)(C.strm_r_tramp), unsafe.Pointer(iter.readerIdx))
if rc != OK {
return ChangesetIter{}, errStr(rc)
}
return iter, nil
}
// https://www.sqlite.org/session/sqlite3changeset_finalize.html
func (iter ChangesetIter) Close() error {
rc := C.sqlite3changeset_finalize(iter.ptr)
iter.ptr = nil
strmReaderReg.unregister(*iter.readerIdx)
*iter.readerIdx = 0
if rc != OK {
return errStr(rc)
}
return nil
}
// https://www.sqlite.org/session/sqlite3changeset_old.html
func (iter ChangesetIter) Old(col int) (v Value, err error) {
rc := C.sqlite3changeset_old(iter.ptr, C.int(col), &v.ptr)
if rc != OK {
return Value{}, errStr(rc)
}
return v, nil
}
// https://www.sqlite.org/session/sqlite3changeset_new.html
func (iter ChangesetIter) New(col int) (v Value, err error) {
rc := C.sqlite3changeset_new(iter.ptr, C.int(col), &v.ptr)
if rc != OK {
return Value{}, errStr(rc)
}
return v, nil
}
// https://www.sqlite.org/session/sqlite3changeset_conflict.html
func (iter ChangesetIter) Conflict(col int) (v Value, err error) {
rc := C.sqlite3changeset_conflict(iter.ptr, C.int(col), &v.ptr)
if rc != OK {
return Value{}, errStr(rc)
}
return v, nil
}
func (iter ChangesetIter) Next() (rowReturned bool, err error) {
rc := C.sqlite3changeset_next(iter.ptr)
switch rc {
case ROW:
return true, nil
case DONE:
return false, nil
default:
return false, errStr(rc)
}
}
// https://www.sqlite.org/session/sqlite3changeset_op.html
func (iter ChangesetIter) Op() (table string, numCols int, opType OpType, indirect bool, err error) {
var zTab *C.char
var nCol, op, bIndirect C.int
rc := C.sqlite3changeset_op(iter.ptr, &zTab, &nCol, &op, &bIndirect)
if rc != OK {
return "", 0, 0, false, errStr(rc)
}
table = C.GoString(zTab)
numCols = int(nCol)
opType = OpType(op)
indirect = bIndirect != 0
return table, numCols, opType, indirect, nil
}
// https://www.sqlite.org/session/sqlite3changeset_fk_conflicts.html
func (iter ChangesetIter) FKConflicts() (int, error) {
var pnOut C.int
rc := C.sqlite3changeset_fk_conflicts(iter.ptr, &pnOut)
if rc != OK {
return 0, errStr(rc)
}
return int(pnOut), nil
}
// https://www.sqlite.org/session/sqlite3changeset_pk.html
func (iter ChangesetIter) PK() ([]bool, error) {
var pabPK *C.uchar
var pnCol C.int
rc := C.sqlite3changeset_pk(iter.ptr, &pabPK, &pnCol)
if rc != OK {
return nil, errStr(rc)
}
vals := (*[127]byte)(unsafe.Pointer(pabPK))[:pnCol:pnCol]
cols := make([]bool, pnCol)
for i, val := range vals {
if val != 0 {
cols[i] = true
}
}
return cols, nil
}
type OpType int
type ConflictType int
const (
CHANGESET_DATA = C.SQLITE_CHANGESET_DATA
CHANGESET_NOTFOUND = C.SQLITE_CHANGESET_NOTFOUND
CHANGESET_CONFLICT = C.SQLITE_CHANGESET_CONFLICT
CHANGESET_CONSTRAINT = C.SQLITE_CHANGESET_CONSTRAINT
CHANGESET_FOREIGN_KEY = C.SQLITE_CHANGESET_FOREIGN_KEY
)
type ConflictAction int
const (
CHANGESET_OMIT = C.SQLITE_CHANGESET_OMIT
CHANGESET_ABORT = C.SQLITE_CHANGESET_ABORT
CHANGESET_REPLACE = C.SQLITE_CHANGESET_REPLACE
)
type Changegroup struct {
ptr *C.sqlite3_changegroup
}
// https://www.sqlite.org/session/sqlite3changegroup_new.html
func NewChangegroup() (*Changegroup, error) {
c := &Changegroup{}
rc := C.sqlite3changegroup_new(&c.ptr)
if rc != OK {
return nil, errStr(rc)
}
return c, nil
}
// https://www.sqlite.org/session/sqlite3changegroup_add.html
func (cg Changegroup) Add(r io.Reader) error {
idx := strmReaderReg.register(r)
defer strmReaderReg.unregister(idx)
rc := C.sqlite3changegroup_add_strm(cg.ptr, (*[0]byte)(C.strm_r_tramp), unsafe.Pointer(&idx))
if rc != OK {
return errStr(rc)
}
return nil
}
// Delete deletes a Changegroup.
//
// https://www.sqlite.org/session/sqlite3changegroup_delete.html
func (cg Changegroup) Delete() {
C.sqlite3changegroup_delete(cg.ptr)
}
// https://www.sqlite.org/session/sqlite3changegroup_output.html
func (cg Changegroup) Output(w io.Writer) (err error) {
idx := strmWriterReg.register(w)
defer strmWriterReg.unregister(idx)
rc := C.sqlite3changegroup_output_strm(cg.ptr, (*[0]byte)(C.strm_w_tramp), unsafe.Pointer(&idx))
if rc != OK {
return errStr(rc)
}
return nil
}
//export strm_w_tramp
func strm_w_tramp(pOut unsafe.Pointer, pData *C.char, n C.int) C.int {
w := strmWriterReg.lookup(*(*int)(pOut)).(io.Writer)
b := (*[1 << 30]byte)(unsafe.Pointer(pData))[:n:n]
for len(b) > 0 {
nw, err := w.Write(b)
b = b[nw:]
if err != nil {
return C.SQLITE_IOERR
}
}
return C.SQLITE_OK
}
//export strm_r_tramp
func strm_r_tramp(pIn unsafe.Pointer, pData *C.char, pnData *C.int) C.int {
r := strmReaderReg.lookup(*(*int)(pIn)).(io.Reader)
b := (*[1 << 30]byte)(unsafe.Pointer(pData))[:*pnData:*pnData]
var n int
var err error
for n == 0 && err == nil {
// Technically an io.Reader is allowed to return (0, nil)
// and it is not treated as the end of the stream.
//
// So we spin here until the io.Reader is gracious enough
// to get off its butt and actually do something.
n, err = r.Read(b)
}
*pnData = C.int(n)
if err != nil && err != io.EOF {
return C.SQLITE_IOERR
}
return C.SQLITE_OK
}
type xapply struct {
id int
conn *Conn
filterFn func(string) bool
conflictFn func(ConflictType, ChangesetIter) ConflictAction
}
//export xapply_filter_tramp
func xapply_filter_tramp(pCtx unsafe.Pointer, zTab *C.char) C.int {
x := xapplyReg.lookup(*(*int)(pCtx)).(*xapply)
tableName := C.GoString(zTab)
if x.filterFn(tableName) {
return 1
}
return 0
}
//export xapply_conflict_tramp
func xapply_conflict_tramp(pCtx unsafe.Pointer, eConflict C.int, p *C.sqlite3_changeset_iter) C.int {
x := xapplyReg.lookup(*(*int)(pCtx)).(*xapply)
action := x.conflictFn(ConflictType(eConflict), ChangesetIter{ptr: p})
return C.int(action)
}

222880
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/sqlite3.c generated vendored

File diff suppressed because it is too large Load Diff

1339
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/sqlite3.go generated vendored

File diff suppressed because it is too large Load Diff

11753
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/sqlite3.h generated vendored

File diff suppressed because it is too large Load Diff

14
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/upgrading.md generated vendored

@ -0,0 +1,14 @@
# Upgrading sqlite
We need to make our own amalgamation, since we want to enable `SQLITE_ENABLE_UPDATE_DELETE_LIMIT` during the parser generator phase.
`-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1` seems to be the only important option when creating the amalgamation.
```sh
wget https://www.sqlite.org/2018/sqlite-src-XXXXXXX.zip
unzip sqlite-src-XXXXXXX.zip
cd sqlite-src-XXXXXXX
CFLAGS='-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1' ./configure
make sqlite3.c
cp sqlite3.c sqlite3.h ~/go/src/github.com/bvinc/go-sqlite-lite/sqlite3/
```

385
vendor/github.com/bvinc/go-sqlite-lite/sqlite3/util.go generated vendored

@ -0,0 +1,385 @@
// Copyright 2018 The go-sqlite-lite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite3
/*
#include "sqlite3.h"
*/
import "C"
import (
"fmt"
"reflect"
"sync"
"unsafe"
)
// NamedArgs is a name/value map of arguments passed to a prepared statement
// that uses ?NNN, :AAA, @AAA, and/or $AAA parameter formats. Name matching is
// case-sensitive and the prefix character (one of [?:@$]) must be included in
// the name. Names that are missing from the map are treated as NULL. Names that
// are not used in the prepared statement are ignored.
//
// It is not possible to mix named and anonymous ("?") parameters in the same
// statement.
// https://www.sqlite.org/lang_expr.html#varparam
type NamedArgs map[string]interface{}
type (
// RawString is a special string type that may be used for database input and
// output without the cost of an extra copy operation.
//
// When used as an argument to a statement, the contents are bound using
// SQLITE_STATIC instead of SQLITE_TRANSIENT flag. This requires the contents to
// remain valid and unmodified until the end of statement execution. In
// particular, the caller must keep a reference to the value to prevent it from
// being garbage collected.
//
// When used for retrieving query output, the internal string pointer is set
// to reference memory belonging to SQLite. The memory remains valid until
// another method is called on the Stmt object and should not be modified.
RawString string
// RawBytes is a special string type that may be used for database input and
// output without the cost of an extra copy operation.
//
// When used as an argument to a statement, the contents are bound using
// SQLITE_STATIC instead of SQLITE_TRANSIENT flag. This requires the contents to
// remain valid and unmodified until the end of statement execution. In
// particular, the caller must keep a reference to the value to prevent it from
// being garbage collected.
//
// When used for retrieving query output, the internal []byte pointer is set
// to reference memory belonging to SQLite. The memory remains valid until
// another method is called on the Stmt object and should not be modified.
RawBytes []byte
)
// Copy returns a Go-managed copy of s.
func (s RawString) Copy() string {
if s == "" {
return ""
}
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
return C.GoStringN((*C.char)(unsafe.Pointer(h.Data)), C.int(h.Len))
}
// Copy returns a Go-managed copy of b.
func (b RawBytes) Copy() []byte {
if len(b) == 0 {
if b == nil {
return nil
}
return []byte("")
}
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
return C.GoBytes(unsafe.Pointer(h.Data), C.int(h.Len))
}
type Value struct {
ptr *C.sqlite3_value
}
// ZeroBlob is a special argument type used to allocate a zero-filled BLOB of
// the specified length. The BLOB can then be opened for incremental I/O to
// efficiently transfer a large amount of data. The maximum BLOB size can be
// queried with Conn.Limit(LIMIT_LENGTH, -1).
type ZeroBlob int
// BusyFunc is a callback function invoked by SQLite when it is unable to
// acquire a lock on a table. Count is the number of times that the callback has
// been invoked for this locking event so far. If the function returns false,
// then the operation is aborted. Otherwise, the function should block for a
// while before returning true and letting SQLite make another locking attempt.
type BusyFunc func(count int) (retry bool)
// CommitFunc is a callback function invoked by SQLite before a transaction is
// committed. If the function returns true, the transaction is rolled back.
type CommitFunc func() (abort bool)
// RollbackFunc is a callback function invoked by SQLite when a transaction is
// rolled back.
type RollbackFunc func()
// UpdateFunc is a callback function invoked by SQLite when a row is updated,
// inserted, or deleted.
type UpdateFunc func(op int, db, tbl RawString, row int64)
// AuthorizerFunc is a callback function invoked by SQLite when statement is compiled.
type AuthorizerFunc func(op int, arg1, arg2, db, entity RawString) int
// Error is returned for all SQLite API result codes other than OK, ROW, and
// DONE.
type Error struct {
rc int
msg string
}
// NewError creates a new Error instance using the specified SQLite result code
// and error message.
func NewError(rc int, msg string) *Error {
return &Error{rc, msg}
}
func errStr(rc C.int) error {
return &Error{int(rc), C.GoString(C.sqlite3_errstr(rc))}
}
// libErr reports an error originating in SQLite. The error message is obtained
// from the database connection when possible, which may include some additional
// information. Otherwise, the result code is translated to a generic message.
func libErr(rc C.int, db *C.sqlite3) error {
if db != nil && rc == C.sqlite3_errcode(db) {
return &Error{int(rc), C.GoString(C.sqlite3_errmsg(db))}
}
return &Error{int(rc), C.GoString(C.sqlite3_errstr(rc))}
}
// pkgErr reports an error originating in this package.
func pkgErr(rc int, msg string, v ...interface{}) error {
if len(v) == 0 {
return &Error{rc, msg}
}
return &Error{rc, fmt.Sprintf(msg, v...)}
}
// Code returns the SQLite extended result code.
func (err *Error) Code() int {
return err.rc
}
// Error implements the error interface.
func (err *Error) Error() string {
return fmt.Sprintf("sqlite3: %s [%d]", err.msg, err.rc)
}
// Errors returned for access attempts to closed or invalid objects.
var (
ErrBadConn = &Error{MISUSE, "closed or invalid connection"}
ErrBadIO = &Error{MISUSE, "closed or invalid incremental I/O operation"}
ErrBadBackup = &Error{MISUSE, "closed or invalid backup operation"}
)
// Complete returns true if sql appears to contain a complete statement that is
// ready to be parsed. This does not validate the statement syntax.
// https://www.sqlite.org/c3ref/complete.html
func Complete(sql string) bool {
if initErr != nil {
return false
}
sql += "\x00"
return C.sqlite3_complete(cStr(sql)) == 1
}
// ReleaseMemory attempts to free n bytes of heap memory by deallocating
// non-essential memory held by the SQLite library. It returns the number of
// bytes actually freed.
//
// This function is currently a no-op because SQLite is not compiled with the
// SQLITE_ENABLE_MEMORY_MANAGEMENT option.
// https://www.sqlite.org/c3ref/release_memory.html
func ReleaseMemory(n int) int {
if initErr != nil {
return 0
}
return int(C.sqlite3_release_memory(C.int(n)))
}
// SoftHeapLimit sets and/or queries the soft limit on the amount of heap memory
// that may be allocated by SQLite. A negative value for n keeps the current
// limit, while 0 removes the limit. The previous limit value is returned, with
// negative values indicating an error.
// https://www.sqlite.org/c3ref/soft_heap_limit64.html
func SoftHeapLimit(n int64) int64 {
if initErr != nil {
return -1
}
return int64(C.sqlite3_soft_heap_limit64(C.sqlite3_int64(n)))
}
// SourceID returns the check-in identifier of SQLite within its configuration
// management system.
// https://www.sqlite.org/c3ref/c_source_id.html
func SourceID() string {
if initErr != nil {
return ""
}
return C.GoString(C.sqlite3_sourceid())
}
// Status returns the current and peak values of a core performance
// counter, specified by one of the STATUS constants. If reset is true, the peak
// value is reset back down to the current value after retrieval.
// https://www.sqlite.org/c3ref/status.html
func Status(op int, reset bool) (cur, peak int, err error) {
if initErr != nil {
return 0, 0, initErr
}
var cCur, cPeak C.int
rc := C.sqlite3_status(C.int(op), &cCur, &cPeak, cBool(reset))
if rc != OK {
return 0, 0, pkgErr(MISUSE, "invalid status op (%d)", op)
}
return int(cCur), int(cPeak), nil
}
// Version returns the SQLite version as a string in the format "X.Y.Z[.N]".
// https://www.sqlite.org/c3ref/libversion.html
func Version() string {
if initErr != nil {
return ""
}
return goStr(C.sqlite3_libversion())
}
// VersionNum returns the SQLite version as an integer in the format X*1000000 +
// Y*1000 + Z, where X is the major version, Y is the minor version, and Z is
// the release number.
func VersionNum() int {
if initErr != nil {
return 0
}
return int(C.sqlite3_libversion_number())
}
// raw casts s to a RawString.
func raw(s string) RawString {
return RawString(s)
}
// cStr returns a pointer to the first byte in s.
func cStr(s string) *C.char {
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
return (*C.char)(unsafe.Pointer(h.Data))
}
// cStrOffset returns the offset of p in s or -1 if p doesn't point into s.
func cStrOffset(s string, p *C.char) int {
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
if off := uintptr(unsafe.Pointer(p)) - h.Data; off < uintptr(h.Len) {
return int(off)
}
return -1
}
// cBytes returns a pointer to the first byte in b.
func cBytes(b []byte) unsafe.Pointer {
return unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&b)).Data)
}
// cBool returns a C representation of a Go bool (false = 0, true = 1).
func cBool(b bool) C.int {
if b {
return 1
}
return 0
}
// goStr returns a Go representation of a null-terminated C string.
func goStr(p *C.char) (s string) {
if p != nil && *p != 0 {
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
h.Data = uintptr(unsafe.Pointer(p))
for *p != 0 {
p = (*C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + 1)) // p++
}
h.Len = int(uintptr(unsafe.Pointer(p)) - h.Data)
}
return
}
// goStrN returns a Go representation of an n-byte C string.
func goStrN(p *C.char, n C.int) (s string) {
if n > 0 {
h := (*reflect.StringHeader)(unsafe.Pointer(&s))
h.Data = uintptr(unsafe.Pointer(p))
h.Len = int(n)
}
return
}
// goBytes returns a Go representation of an n-byte C array.
func goBytes(p unsafe.Pointer, n C.int) (b []byte) {
if n > 0 {
h := (*reflect.SliceHeader)(unsafe.Pointer(&b))
h.Data = uintptr(p)
h.Len = int(n)
h.Cap = int(n)
}
return
}
type registry struct {
mu *sync.Mutex
index int
vals map[int]interface{}
}
func newRegistry() *registry {
return &registry{
mu: &sync.Mutex{},
index: 0,
vals: make(map[int]interface{}),
}
}
func (r *registry) register(val interface{}) int {
r.mu.Lock()
defer r.mu.Unlock()
r.index++
for r.vals[r.index] != nil || r.index == 0 {
r.index++
}
r.vals[r.index] = val
return r.index
}
func (r *registry) lookup(i int) interface{} {
r.mu.Lock()
defer r.mu.Unlock()
return r.vals[i]
}
func (r *registry) unregister(i int) interface{} {
r.mu.Lock()
defer r.mu.Unlock()
prev := r.vals[i]
delete(r.vals, i)
return prev
}
//export go_busy_handler
func go_busy_handler(data unsafe.Pointer, count C.int) (retry C.int) {
idx := *(*int)(data)
fn := busyRegistry.lookup(idx).(BusyFunc)
return cBool(fn(int(count)))
}
//export go_commit_hook
func go_commit_hook(data unsafe.Pointer) (abort C.int) {
idx := *(*int)(data)
fn := commitRegistry.lookup(idx).(CommitFunc)
return cBool(fn())
}
//export go_rollback_hook
func go_rollback_hook(data unsafe.Pointer) {
idx := *(*int)(data)
fn := rollbackRegistry.lookup(idx).(RollbackFunc)
fn()
}
//export go_update_hook
func go_update_hook(data unsafe.Pointer, op C.int, db, tbl *C.char, row C.sqlite3_int64) {
idx := *(*int)(data)
fn := updateRegistry.lookup(idx).(UpdateFunc)
fn(int(op), raw(goStr(db)), raw(goStr(tbl)), int64(row))
}
//export go_set_authorizer
func go_set_authorizer(data unsafe.Pointer, op C.int, arg1, arg2, db, entity *C.char) C.int {
</