Skip to content

Commit 61eaaff

Browse files
committed
Merge remote-tracking branch 'mattn/master'
Tag 1.14.17 from upstream, bringing in SQLite 3.42.0.
2 parents c9bfb54 + f08f1b6 commit 61eaaff

File tree

8 files changed

+11152
-5030
lines changed

8 files changed

+11152
-5030
lines changed

_example/vtable/vtable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (v *ghRepoTable) Open() (sqlite3.VTabCursor, error) {
6262
return &ghRepoCursor{0, repos}, nil
6363
}
6464

65-
func (v *ghRepoTable) BestIndex(cst []sqlite3.InfoConstraint, ob []sqlite3.InfoOrderBy) (*sqlite3.IndexResult, error) {
65+
func (v *ghRepoTable) BestIndex(csts []sqlite3.InfoConstraint, ob []sqlite3.InfoOrderBy) (*sqlite3.IndexResult, error) {
6666
used := make([]bool, len(csts))
6767
return &sqlite3.IndexResult{
6868
IdxNum: 0,

sqlite3-binding.c

Lines changed: 10734 additions & 4834 deletions
Large diffs are not rendered by default.

sqlite3-binding.h

Lines changed: 379 additions & 147 deletions
Large diffs are not rendered by default.

sqlite3.go

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -841,17 +841,17 @@ func lastError(db *C.sqlite3) error {
841841

842842
// Exec implements Execer.
843843
func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, error) {
844-
list := make([]namedValue, len(args))
844+
list := make([]driver.NamedValue, len(args))
845845
for i, v := range args {
846-
list[i] = namedValue{
846+
list[i] = driver.NamedValue{
847847
Ordinal: i + 1,
848848
Value: v,
849849
}
850850
}
851851
return c.exec(context.Background(), query, list)
852852
}
853853

854-
func (c *SQLiteConn) exec(ctx context.Context, query string, args []namedValue) (driver.Result, error) {
854+
func (c *SQLiteConn) exec(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
855855
start := 0
856856
for {
857857
s, err := c.prepare(ctx, query)
@@ -860,7 +860,7 @@ func (c *SQLiteConn) exec(ctx context.Context, query string, args []namedValue)
860860
}
861861
var res driver.Result
862862
if s.(*SQLiteStmt).s != nil {
863-
stmtArgs := make([]namedValue, 0, len(args))
863+
stmtArgs := make([]driver.NamedValue, 0, len(args))
864864
na := s.NumInput()
865865
if len(args)-start < na {
866866
s.Close()
@@ -898,28 +898,22 @@ func (c *SQLiteConn) exec(ctx context.Context, query string, args []namedValue)
898898
}
899899
}
900900

901-
type namedValue struct {
902-
Name string
903-
Ordinal int
904-
Value driver.Value
905-
}
906-
907901
// Query implements Queryer.
908902
func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, error) {
909-
list := make([]namedValue, len(args))
903+
list := make([]driver.NamedValue, len(args))
910904
for i, v := range args {
911-
list[i] = namedValue{
905+
list[i] = driver.NamedValue{
912906
Ordinal: i + 1,
913907
Value: v,
914908
}
915909
}
916910
return c.query(context.Background(), query, list)
917911
}
918912

919-
func (c *SQLiteConn) query(ctx context.Context, query string, args []namedValue) (driver.Rows, error) {
913+
func (c *SQLiteConn) query(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
920914
start := 0
921915
for {
922-
stmtArgs := make([]namedValue, 0, len(args))
916+
stmtArgs := make([]driver.NamedValue, 0, len(args))
923917
s, err := c.prepare(ctx, query)
924918
if err != nil {
925919
return nil, err
@@ -1916,7 +1910,7 @@ func (s *SQLiteStmt) NumInput() int {
19161910

19171911
var placeHolder = []byte{0}
19181912

1919-
func (s *SQLiteStmt) bind(args []namedValue) error {
1913+
func (s *SQLiteStmt) bind(args []driver.NamedValue) error {
19201914
rv := C.sqlite3_reset(s.s)
19211915
if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
19221916
return s.c.lastError()
@@ -1986,17 +1980,17 @@ func (s *SQLiteStmt) bind(args []namedValue) error {
19861980

19871981
// Query the statement with arguments. Return records.
19881982
func (s *SQLiteStmt) Query(args []driver.Value) (driver.Rows, error) {
1989-
list := make([]namedValue, len(args))
1983+
list := make([]driver.NamedValue, len(args))
19901984
for i, v := range args {
1991-
list[i] = namedValue{
1985+
list[i] = driver.NamedValue{
19921986
Ordinal: i + 1,
19931987
Value: v,
19941988
}
19951989
}
19961990
return s.query(context.Background(), list)
19971991
}
19981992

1999-
func (s *SQLiteStmt) query(ctx context.Context, args []namedValue) (driver.Rows, error) {
1993+
func (s *SQLiteStmt) query(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
20001994
if err := s.bind(args); err != nil {
20011995
return nil, err
20021996
}
@@ -2026,9 +2020,9 @@ func (r *SQLiteResult) RowsAffected() (int64, error) {
20262020

20272021
// Exec execute the statement with arguments. Return result object.
20282022
func (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
2029-
list := make([]namedValue, len(args))
2023+
list := make([]driver.NamedValue, len(args))
20302024
for i, v := range args {
2031-
list[i] = namedValue{
2025+
list[i] = driver.NamedValue{
20322026
Ordinal: i + 1,
20332027
Value: v,
20342028
}
@@ -2045,7 +2039,7 @@ func isInterruptErr(err error) bool {
20452039
}
20462040

20472041
// exec executes a query that doesn't return rows. Attempts to honor context timeout.
2048-
func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result, error) {
2042+
func (s *SQLiteStmt) exec(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
20492043
if ctx.Done() == nil {
20502044
return s.execSync(args)
20512045
}
@@ -2077,7 +2071,7 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result
20772071
return rv.r, rv.err
20782072
}
20792073

2080-
func (s *SQLiteStmt) execSync(args []namedValue) (driver.Result, error) {
2074+
func (s *SQLiteStmt) execSync(args []driver.NamedValue) (driver.Result, error) {
20812075
if err := s.bind(args); err != nil {
20822076
C.sqlite3_reset(s.s)
20832077
C.sqlite3_clear_bindings(s.s)

sqlite3_go18.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,12 @@ func (c *SQLiteConn) Ping(ctx context.Context) error {
2525

2626
// QueryContext implement QueryerContext.
2727
func (c *SQLiteConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
28-
list := make([]namedValue, len(args))
29-
for i, nv := range args {
30-
list[i] = namedValue(nv)
31-
}
32-
return c.query(ctx, query, list)
28+
return c.query(ctx, query, args)
3329
}
3430

3531
// ExecContext implement ExecerContext.
3632
func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
37-
list := make([]namedValue, len(args))
38-
for i, nv := range args {
39-
list[i] = namedValue(nv)
40-
}
41-
return c.exec(ctx, query, list)
33+
return c.exec(ctx, query, args)
4234
}
4335

4436
// PrepareContext implement ConnPrepareContext.
@@ -53,18 +45,10 @@ func (c *SQLiteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver
5345

5446
// QueryContext implement QueryerContext.
5547
func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
56-
list := make([]namedValue, len(args))
57-
for i, nv := range args {
58-
list[i] = namedValue(nv)
59-
}
60-
return s.query(ctx, list)
48+
return s.query(ctx, args)
6149
}
6250

6351
// ExecContext implement ExecerContext.
6452
func (s *SQLiteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
65-
list := make([]namedValue, len(args))
66-
for i, nv := range args {
67-
list[i] = namedValue(nv)
68-
}
69-
return s.exec(ctx, list)
53+
return s.exec(ctx, args)
7054
}

sqlite3_libsqlite3.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ package sqlite3
1010
/*
1111
#cgo CFLAGS: -DUSE_LIBSQLITE3
1212
#cgo linux LDFLAGS: -lsqlite3
13-
#cgo darwin LDFLAGS: -L/usr/local/opt/sqlite/lib -lsqlite3
14-
#cgo darwin CFLAGS: -I/usr/local/opt/sqlite/include
13+
#cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/sqlite/lib -lsqlite3
14+
#cgo darwin,amd64 CFLAGS: -I/usr/local/opt/sqlite/include
15+
#cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/sqlite/lib -lsqlite3
16+
#cgo darwin,arm64 CFLAGS: -I/opt/homebrew/opt/sqlite/include
1517
#cgo openbsd LDFLAGS: -lsqlite3
1618
#cgo solaris LDFLAGS: -lsqlite3
1719
#cgo windows LDFLAGS: -lsqlite3

sqlite3_opt_icu.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ package sqlite3
1010
/*
1111
#cgo LDFLAGS: -licuuc -licui18n
1212
#cgo CFLAGS: -DSQLITE_ENABLE_ICU
13-
#cgo darwin CFLAGS: -I/usr/local/opt/icu4c/include
14-
#cgo darwin LDFLAGS: -L/usr/local/opt/icu4c/lib
13+
#cgo darwin,amd64 CFLAGS: -I/usr/local/opt/icu4c/include
14+
#cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/icu4c/lib
15+
#cgo darwin,arm64 CFLAGS: -I/opt/homebrew/opt/icu4c/include
16+
#cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/icu4c/lib
1517
#cgo openbsd LDFLAGS: -lsqlite3
1618
*/
1719
import "C"

sqlite3ext.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ struct sqlite3_api_routines {
336336
const char *(*filename_journal)(const char*);
337337
const char *(*filename_wal)(const char*);
338338
/* Version 3.32.0 and later */
339-
char *(*create_filename)(const char*,const char*,const char*,
339+
const char *(*create_filename)(const char*,const char*,const char*,
340340
int,const char**);
341-
void (*free_filename)(char*);
341+
void (*free_filename)(const char*);
342342
sqlite3_file *(*database_file_object)(const char*);
343343
/* Version 3.34.0 and later */
344344
int (*txn_state)(sqlite3*,const char*);
@@ -362,6 +362,10 @@ struct sqlite3_api_routines {
362362
unsigned char *(*serialize)(sqlite3*,const char *,sqlite3_int64*,
363363
unsigned int);
364364
const char *(*db_name)(sqlite3*,int);
365+
/* Version 3.40.0 and later */
366+
int (*value_encoding)(sqlite3_value*);
367+
/* Version 3.41.0 and later */
368+
int (*is_interrupted)(sqlite3*);
365369
};
366370

367371
/*
@@ -686,6 +690,10 @@ typedef int (*sqlite3_loadext_entry)(
686690
#define sqlite3_serialize sqlite3_api->serialize
687691
#endif
688692
#define sqlite3_db_name sqlite3_api->db_name
693+
/* Version 3.40.0 and later */
694+
#define sqlite3_value_encoding sqlite3_api->value_encoding
695+
/* Version 3.41.0 and later */
696+
#define sqlite3_is_interrupted sqlite3_api->is_interrupted
689697
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
690698

691699
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)

0 commit comments

Comments
 (0)