Merge pull request #21365 from containers/renovate/github.com-mattn-go-sqlite3-1.x

Update module github.com/mattn/go-sqlite3 to v1.14.20
This commit is contained in:
openshift-merge-bot[bot]
2024-01-25 18:38:36 +00:00
committed by GitHub
43 changed files with 5980 additions and 2819 deletions

2
go.mod
View File

@ -41,7 +41,7 @@ require (
github.com/json-iterator/go v1.1.12 github.com/json-iterator/go v1.1.12
github.com/linuxkit/virtsock v0.0.0-20220523201153-1a23e78aa7a2 github.com/linuxkit/virtsock v0.0.0-20220523201153-1a23e78aa7a2
github.com/mattn/go-shellwords v1.0.12 github.com/mattn/go-shellwords v1.0.12
github.com/mattn/go-sqlite3 v1.14.19 github.com/mattn/go-sqlite3 v1.14.20
github.com/mdlayher/vsock v1.2.1 github.com/mdlayher/vsock v1.2.1
github.com/moby/term v0.5.0 github.com/moby/term v0.5.0
github.com/nxadm/tail v1.4.11 github.com/nxadm/tail v1.4.11

4
go.sum
View File

@ -761,8 +761,8 @@ github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vq
github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk= github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= github.com/mattn/go-sqlite3 v1.14.20 h1:BAZ50Ns0OFBNxdAqFhbZqdPcht1Xlb16pDCqkq1spr0=
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/go-sqlite3 v1.14.20/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=

View File

@ -100,13 +100,13 @@ func preUpdateHookTrampoline(handle unsafe.Pointer, dbHandle uintptr, op int, db
// Use handles to avoid passing Go pointers to C. // Use handles to avoid passing Go pointers to C.
type handleVal struct { type handleVal struct {
db *SQLiteConn db *SQLiteConn
val interface{} val any
} }
var handleLock sync.Mutex var handleLock sync.Mutex
var handleVals = make(map[unsafe.Pointer]handleVal) var handleVals = make(map[unsafe.Pointer]handleVal)
func newHandle(db *SQLiteConn, v interface{}) unsafe.Pointer { func newHandle(db *SQLiteConn, v any) unsafe.Pointer {
handleLock.Lock() handleLock.Lock()
defer handleLock.Unlock() defer handleLock.Unlock()
val := handleVal{db: db, val: v} val := handleVal{db: db, val: v}
@ -124,7 +124,7 @@ func lookupHandleVal(handle unsafe.Pointer) handleVal {
return handleVals[handle] return handleVals[handle]
} }
func lookupHandle(handle unsafe.Pointer) interface{} { func lookupHandle(handle unsafe.Pointer) any {
return lookupHandleVal(handle).val return lookupHandleVal(handle).val
} }
@ -238,7 +238,7 @@ func callbackArg(typ reflect.Type) (callbackArgConverter, error) {
switch typ.Kind() { switch typ.Kind() {
case reflect.Interface: case reflect.Interface:
if typ.NumMethod() != 0 { if typ.NumMethod() != 0 {
return nil, errors.New("the only supported interface type is interface{}") return nil, errors.New("the only supported interface type is any")
} }
return callbackArgGeneric, nil return callbackArgGeneric, nil
case reflect.Slice: case reflect.Slice:
@ -360,11 +360,11 @@ func callbackRetGeneric(ctx *C.sqlite3_context, v reflect.Value) error {
} }
cb, err := callbackRet(v.Elem().Type()) cb, err := callbackRet(v.Elem().Type())
if err != nil { if err != nil {
return err return err
} }
return cb(ctx, v.Elem()) return cb(ctx, v.Elem())
} }
func callbackRet(typ reflect.Type) (callbackRetConverter, error) { func callbackRet(typ reflect.Type) (callbackRetConverter, error) {

View File

@ -23,7 +23,7 @@ var errNilPtr = errors.New("destination pointer is nil") // embedded in descript
// convertAssign copies to dest the value in src, converting it if possible. // convertAssign copies to dest the value in src, converting it if possible.
// An error is returned if the copy would result in loss of information. // An error is returned if the copy would result in loss of information.
// dest should be a pointer type. // dest should be a pointer type.
func convertAssign(dest, src interface{}) error { func convertAssign(dest, src any) error {
// Common cases, without reflect. // Common cases, without reflect.
switch s := src.(type) { switch s := src.(type) {
case string: case string:
@ -55,7 +55,7 @@ func convertAssign(dest, src interface{}) error {
} }
*d = string(s) *d = string(s)
return nil return nil
case *interface{}: case *any:
if d == nil { if d == nil {
return errNilPtr return errNilPtr
} }
@ -97,7 +97,7 @@ func convertAssign(dest, src interface{}) error {
} }
case nil: case nil:
switch d := dest.(type) { switch d := dest.(type) {
case *interface{}: case *any:
if d == nil { if d == nil {
return errNilPtr return errNilPtr
} }
@ -149,7 +149,7 @@ func convertAssign(dest, src interface{}) error {
*d = bv.(bool) *d = bv.(bool)
} }
return err return err
case *interface{}: case *any:
*d = src *d = src
return nil return nil
} }
@ -256,7 +256,7 @@ func cloneBytes(b []byte) []byte {
return c return c
} }
func asString(src interface{}) string { func asString(src any) string {
switch v := src.(type) { switch v := src.(type) {
case string: case string:
return v return v

View File

@ -5,63 +5,63 @@ This works as a driver for database/sql.
Installation Installation
go get github.com/mattn/go-sqlite3 go get github.com/mattn/go-sqlite3
Supported Types # Supported Types
Currently, go-sqlite3 supports the following data types. Currently, go-sqlite3 supports the following data types.
+------------------------------+ +------------------------------+
|go | sqlite3 | |go | sqlite3 |
|----------|-------------------| |----------|-------------------|
|nil | null | |nil | null |
|int | integer | |int | integer |
|int64 | integer | |int64 | integer |
|float64 | float | |float64 | float |
|bool | integer | |bool | integer |
|[]byte | blob | |[]byte | blob |
|string | text | |string | text |
|time.Time | timestamp/datetime| |time.Time | timestamp/datetime|
+------------------------------+ +------------------------------+
SQLite3 Extension # SQLite3 Extension
You can write your own extension module for sqlite3. For example, below is an You can write your own extension module for sqlite3. For example, below is an
extension for a Regexp matcher operation. extension for a Regexp matcher operation.
#include <pcre.h> #include <pcre.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <sqlite3ext.h> #include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1 SQLITE_EXTENSION_INIT1
static void regexp_func(sqlite3_context *context, int argc, sqlite3_value **argv) { static void regexp_func(sqlite3_context *context, int argc, sqlite3_value **argv) {
if (argc >= 2) { if (argc >= 2) {
const char *target = (const char *)sqlite3_value_text(argv[1]); const char *target = (const char *)sqlite3_value_text(argv[1]);
const char *pattern = (const char *)sqlite3_value_text(argv[0]); const char *pattern = (const char *)sqlite3_value_text(argv[0]);
const char* errstr = NULL; const char* errstr = NULL;
int erroff = 0; int erroff = 0;
int vec[500]; int vec[500];
int n, rc; int n, rc;
pcre* re = pcre_compile(pattern, 0, &errstr, &erroff, NULL); pcre* re = pcre_compile(pattern, 0, &errstr, &erroff, NULL);
rc = pcre_exec(re, NULL, target, strlen(target), 0, 0, vec, 500); rc = pcre_exec(re, NULL, target, strlen(target), 0, 0, vec, 500);
if (rc <= 0) { if (rc <= 0) {
sqlite3_result_error(context, errstr, 0); sqlite3_result_error(context, errstr, 0);
return; return;
} }
sqlite3_result_int(context, 1); sqlite3_result_int(context, 1);
} }
} }
#ifdef _WIN32 #ifdef _WIN32
__declspec(dllexport) __declspec(dllexport)
#endif #endif
int sqlite3_extension_init(sqlite3 *db, char **errmsg, int sqlite3_extension_init(sqlite3 *db, char **errmsg,
const sqlite3_api_routines *api) { const sqlite3_api_routines *api) {
SQLITE_EXTENSION_INIT2(api); SQLITE_EXTENSION_INIT2(api);
return sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8, return sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8,
(void*)db, regexp_func, NULL, NULL); (void*)db, regexp_func, NULL, NULL);
} }
It needs to be built as a so/dll shared library. And you need to register It needs to be built as a so/dll shared library. And you need to register
the extension module like below. the extension module like below.
@ -77,7 +77,7 @@ Then, you can use this extension.
rows, err := db.Query("select text from mytable where name regexp '^golang'") rows, err := db.Query("select text from mytable where name regexp '^golang'")
Connection Hook # Connection Hook
You can hook and inject your code when the connection is established by setting You can hook and inject your code when the connection is established by setting
ConnectHook to get the SQLiteConn. ConnectHook to get the SQLiteConn.
@ -95,13 +95,13 @@ You can also use database/sql.Conn.Raw (Go >= 1.13):
conn, err := db.Conn(context.Background()) conn, err := db.Conn(context.Background())
// if err != nil { ... } // if err != nil { ... }
defer conn.Close() defer conn.Close()
err = conn.Raw(func (driverConn interface{}) error { err = conn.Raw(func (driverConn any) error {
sqliteConn := driverConn.(*sqlite3.SQLiteConn) sqliteConn := driverConn.(*sqlite3.SQLiteConn)
// ... use sqliteConn // ... use sqliteConn
}) })
// if err != nil { ... } // if err != nil { ... }
Go SQlite3 Extensions # Go SQlite3 Extensions
If you want to register Go functions as SQLite extension functions If you want to register Go functions as SQLite extension functions
you can make a custom driver by calling RegisterFunction from you can make a custom driver by calling RegisterFunction from
@ -130,6 +130,5 @@ You can then use the custom driver by passing its name to sql.Open.
} }
See the documentation of RegisterFunc for more details. See the documentation of RegisterFunc for more details.
*/ */
package sqlite3 package sqlite3

File diff suppressed because it is too large Load Diff

View File

@ -147,9 +147,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()]. ** [sqlite_version()] and [sqlite_source_id()].
*/ */
#define SQLITE_VERSION "3.44.0" #define SQLITE_VERSION "3.45.0"
#define SQLITE_VERSION_NUMBER 3044000 #define SQLITE_VERSION_NUMBER 3045000
#define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301" #define SQLITE_SOURCE_ID "2024-01-15 17:01:13 1066602b2b1976fe58b5150777cced894af17c803e068f5918390d6915b46e1d"
/* /*
** CAPI3REF: Run-Time Library Version Numbers ** CAPI3REF: Run-Time Library Version Numbers
@ -3955,15 +3955,17 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
** </ul> ** </ul>
** **
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
** text that describes the error, as either UTF-8 or UTF-16 respectively. ** text that describes the error, as either UTF-8 or UTF-16 respectively,
** or NULL if no error message is available.
** (See how SQLite handles [invalid UTF] for exceptions to this rule.) ** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
** ^(Memory to hold the error message string is managed internally. ** ^(Memory to hold the error message string is managed internally.
** The application does not need to worry about freeing the result. ** The application does not need to worry about freeing the result.
** However, the error string might be overwritten or deallocated by ** However, the error string might be overwritten or deallocated by
** subsequent calls to other SQLite interface functions.)^ ** subsequent calls to other SQLite interface functions.)^
** **
** ^The sqlite3_errstr() interface returns the English-language text ** ^The sqlite3_errstr(E) interface returns the English-language text
** that describes the [result code], as UTF-8. ** that describes the [result code] E, as UTF-8, or NULL if E is not an
** result code for which a text error message is available.
** ^(Memory to hold the error message string is managed internally ** ^(Memory to hold the error message string is managed internally
** and must not be freed by the application)^. ** and must not be freed by the application)^.
** **
@ -5574,13 +5576,27 @@ SQLITE_API int sqlite3_create_window_function(
** </dd> ** </dd>
** **
** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd> ** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd>
** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
** [sqlite3_value_subtype()] to inspect the sub-types of its arguments. ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
** Specifying this flag makes no difference for scalar or aggregate user ** This flag instructs SQLite to omit some corner-case optimizations that
** functions. However, if it is not specified for a user-defined window ** might disrupt the operation of the [sqlite3_value_subtype()] function,
** function, then any sub-types belonging to arguments passed to the window ** causing it to return zero rather than the correct subtype().
** function may be discarded before the window function is called (i.e. ** SQL functions that invokes [sqlite3_value_subtype()] should have this
** sqlite3_value_subtype() will always return 0). ** property. If the SQLITE_SUBTYPE property is omitted, then the return
** value from [sqlite3_value_subtype()] might sometimes be zero even though
** a non-zero subtype was specified by the function argument expression.
**
** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call
** [sqlite3_result_subtype()] to cause a sub-type to be associated with its
** result.
** Every function that invokes [sqlite3_result_subtype()] should have this
** property. If it does not, then the call to [sqlite3_result_subtype()]
** might become a no-op if the function is used as term in an
** [expression index]. On the other hand, SQL functions that never invoke
** [sqlite3_result_subtype()] should avoid setting this property, as the
** purpose of this property is to disable certain optimizations that are
** incompatible with subtypes.
** </dd> ** </dd>
** </dl> ** </dl>
*/ */
@ -5588,6 +5604,7 @@ SQLITE_API int sqlite3_create_window_function(
#define SQLITE_DIRECTONLY 0x000080000 #define SQLITE_DIRECTONLY 0x000080000
#define SQLITE_SUBTYPE 0x000100000 #define SQLITE_SUBTYPE 0x000100000
#define SQLITE_INNOCUOUS 0x000200000 #define SQLITE_INNOCUOUS 0x000200000
#define SQLITE_RESULT_SUBTYPE 0x001000000
/* /*
** CAPI3REF: Deprecated Functions ** CAPI3REF: Deprecated Functions
@ -5784,6 +5801,12 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
** information can be used to pass a limited amount of context from ** information can be used to pass a limited amount of context from
** one SQL function to another. Use the [sqlite3_result_subtype()] ** one SQL function to another. Use the [sqlite3_result_subtype()]
** routine to set the subtype for the return value of an SQL function. ** routine to set the subtype for the return value of an SQL function.
**
** Every [application-defined SQL function] that invoke this interface
** should include the [SQLITE_SUBTYPE] property in the text
** encoding argument when the function is [sqlite3_create_function|registered].
** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
** might return zero instead of the upstream subtype in some corner cases.
*/ */
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*); SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value*);
@ -5914,14 +5937,22 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
** <li> ^(when sqlite3_set_auxdata() is invoked again on the same ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
** parameter)^, or ** parameter)^, or
** <li> ^(during the original sqlite3_set_auxdata() call when a memory ** <li> ^(during the original sqlite3_set_auxdata() call when a memory
** allocation error occurs.)^ </ul> ** allocation error occurs.)^
** <li> ^(during the original sqlite3_set_auxdata() call if the function
** is evaluated during query planning instead of during query execution,
** as sometimes happens with [SQLITE_ENABLE_STAT4].)^ </ul>
** **
** Note the last bullet in particular. The destructor X in ** Note the last two bullets in particular. The destructor X in
** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
** should be called near the end of the function implementation and the ** should be called near the end of the function implementation and the
** function implementation should not make any use of P after ** function implementation should not make any use of P after
** sqlite3_set_auxdata() has been called. ** sqlite3_set_auxdata() has been called. Furthermore, a call to
** sqlite3_get_auxdata() that occurs immediately after a corresponding call
** to sqlite3_set_auxdata() might still return NULL if an out-of-memory
** condition occurred during the sqlite3_set_auxdata() call or if the
** function is being evaluated during query planning rather than during
** query execution.
** **
** ^(In practice, auxiliary data is preserved between function calls for ** ^(In practice, auxiliary data is preserved between function calls for
** function parameters that are compile-time constants, including literal ** function parameters that are compile-time constants, including literal
@ -6195,6 +6226,20 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
** higher order bits are discarded. ** higher order bits are discarded.
** The number of subtype bytes preserved by SQLite might increase ** The number of subtype bytes preserved by SQLite might increase
** in future releases of SQLite. ** in future releases of SQLite.
**
** Every [application-defined SQL function] that invokes this interface
** should include the [SQLITE_RESULT_SUBTYPE] property in its
** text encoding argument when the SQL function is
** [sqlite3_create_function|registered]. If the [SQLITE_RESULT_SUBTYPE]
** property is omitted from the function that invokes sqlite3_result_subtype(),
** then in some cases the sqlite3_result_subtype() might fail to set
** the result subtype.
**
** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any
** SQL function that invokes the sqlite3_result_subtype() interface
** and that does not have the SQLITE_RESULT_SUBTYPE property will raise
** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1
** by default.
*/ */
SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int); SQLITE_API void sqlite3_result_subtype(sqlite3_context*,unsigned int);
@ -7995,9 +8040,11 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
** **
** ^(Some systems (for example, Windows 95) do not support the operation ** ^(Some systems (for example, Windows 95) do not support the operation
** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
** will always return SQLITE_BUSY. The SQLite core only ever uses ** will always return SQLITE_BUSY. In most cases the SQLite core only uses
** sqlite3_mutex_try() as an optimization so this is acceptable ** sqlite3_mutex_try() as an optimization, so this is acceptable
** behavior.)^ ** behavior. The exceptions are unix builds that set the
** SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working
** sqlite3_mutex_try() is required.)^
** **
** ^The sqlite3_mutex_leave() routine exits a mutex that was ** ^The sqlite3_mutex_leave() routine exits a mutex that was
** previously entered by the same thread. The behavior ** previously entered by the same thread. The behavior
@ -8256,6 +8303,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ASSERT 12
#define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_ALWAYS 13
#define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */ #define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */
#define SQLITE_TESTCTRL_JSON_SELFCHECK 14
#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
#define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */ #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */ #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
@ -12769,8 +12817,11 @@ struct Fts5PhraseIter {
** created with the "columnsize=0" option. ** created with the "columnsize=0" option.
** **
** xColumnText: ** xColumnText:
** This function attempts to retrieve the text of column iCol of the ** If parameter iCol is less than zero, or greater than or equal to the
** current document. If successful, (*pz) is set to point to a buffer ** number of columns in the table, SQLITE_RANGE is returned.
**
** Otherwise, this function attempts to retrieve the text of column iCol of
** the current document. If successful, (*pz) is set to point to a buffer
** containing the text in utf-8 encoding, (*pn) is set to the size in bytes ** containing the text in utf-8 encoding, (*pn) is set to the size in bytes
** (not characters) of the buffer and SQLITE_OK is returned. Otherwise, ** (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
** if an error occurs, an SQLite error code is returned and the final values ** if an error occurs, an SQLite error code is returned and the final values
@ -12780,8 +12831,10 @@ struct Fts5PhraseIter {
** Returns the number of phrases in the current query expression. ** Returns the number of phrases in the current query expression.
** **
** xPhraseSize: ** xPhraseSize:
** Returns the number of tokens in phrase iPhrase of the query. Phrases ** If parameter iCol is less than zero, or greater than or equal to the
** are numbered starting from zero. ** number of phrases in the current query, as returned by xPhraseCount,
** 0 is returned. Otherwise, this function returns the number of tokens in
** phrase iPhrase of the query. Phrases are numbered starting from zero.
** **
** xInstCount: ** xInstCount:
** Set *pnInst to the total number of occurrences of all phrases within ** Set *pnInst to the total number of occurrences of all phrases within
@ -12797,12 +12850,13 @@ struct Fts5PhraseIter {
** Query for the details of phrase match iIdx within the current row. ** Query for the details of phrase match iIdx within the current row.
** Phrase matches are numbered starting from zero, so the iIdx argument ** Phrase matches are numbered starting from zero, so the iIdx argument
** should be greater than or equal to zero and smaller than the value ** should be greater than or equal to zero and smaller than the value
** output by xInstCount(). ** output by xInstCount(). If iIdx is less than zero or greater than
** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned.
** **
** Usually, output parameter *piPhrase is set to the phrase number, *piCol ** Otherwise, output parameter *piPhrase is set to the phrase number, *piCol
** to the column in which it occurs and *piOff the token offset of the ** to the column in which it occurs and *piOff the token offset of the
** first token of the phrase. Returns SQLITE_OK if successful, or an error ** first token of the phrase. SQLITE_OK is returned if successful, or an
** code (i.e. SQLITE_NOMEM) if an error occurs. ** error code (i.e. SQLITE_NOMEM) if an error occurs.
** **
** This API can be quite slow if used with an FTS5 table created with the ** This API can be quite slow if used with an FTS5 table created with the
** "detail=none" or "detail=column" option. ** "detail=none" or "detail=column" option.
@ -12828,6 +12882,10 @@ struct Fts5PhraseIter {
** Invoking Api.xUserData() returns a copy of the pointer passed as ** Invoking Api.xUserData() returns a copy of the pointer passed as
** the third argument to pUserData. ** the third argument to pUserData.
** **
** If parameter iPhrase is less than zero, or greater than or equal to
** the number of phrases in the query, as returned by xPhraseCount(),
** this function returns SQLITE_RANGE.
**
** If the callback function returns any value other than SQLITE_OK, the ** If the callback function returns any value other than SQLITE_OK, the
** query is abandoned and the xQueryPhrase function returns immediately. ** query is abandoned and the xQueryPhrase function returns immediately.
** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. ** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
@ -12942,9 +13000,42 @@ struct Fts5PhraseIter {
** **
** xPhraseNextColumn() ** xPhraseNextColumn()
** See xPhraseFirstColumn above. ** See xPhraseFirstColumn above.
**
** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken)
** This is used to access token iToken of phrase iPhrase of the current
** query. Before returning, output parameter *ppToken is set to point
** to a buffer containing the requested token, and *pnToken to the
** size of this buffer in bytes.
**
** If iPhrase or iToken are less than zero, or if iPhrase is greater than
** or equal to the number of phrases in the query as reported by
** xPhraseCount(), or if iToken is equal to or greater than the number of
** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken
are both zeroed.
**
** The output text is not a copy of the query text that specified the
** token. It is the output of the tokenizer module. For tokendata=1
** tables, this includes any embedded 0x00 and trailing data.
**
** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken)
** This is used to access token iToken of phrase hit iIdx within the
** current row. If iIdx is less than zero or greater than or equal to the
** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise,
** output variable (*ppToken) is set to point to a buffer containing the
** matching document token, and (*pnToken) to the size of that buffer in
** bytes. This API is not available if the specified token matches a
** prefix query term. In that case both output variables are always set
** to 0.
**
** The output text is not a copy of the document text that was tokenized.
** It is the output of the tokenizer module. For tokendata=1 tables, this
** includes any embedded 0x00 and trailing data.
**
** This API can be quite slow if used with an FTS5 table created with the
** "detail=none" or "detail=column" option.
*/ */
struct Fts5ExtensionApi { struct Fts5ExtensionApi {
int iVersion; /* Currently always set to 2 */ int iVersion; /* Currently always set to 3 */
void *(*xUserData)(Fts5Context*); void *(*xUserData)(Fts5Context*);
@ -12979,6 +13070,13 @@ struct Fts5ExtensionApi {
int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*); int (*xPhraseFirstColumn)(Fts5Context*, int iPhrase, Fts5PhraseIter*, int*);
void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol); void (*xPhraseNextColumn)(Fts5Context*, Fts5PhraseIter*, int *piCol);
/* Below this point are iVersion>=3 only */
int (*xQueryToken)(Fts5Context*,
int iPhrase, int iToken,
const char **ppToken, int *pnToken
);
int (*xInstToken)(Fts5Context*, int iIdx, int iToken, const char**, int*);
}; };
/* /*

View File

@ -607,10 +607,9 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
// RegisterFunc makes a Go function available as a SQLite function. // RegisterFunc makes a Go function available as a SQLite function.
// //
// The Go function can have arguments of the following types: any // The Go function can have arguments of the following types: any
// numeric type except complex, bool, []byte, string and // numeric type except complex, bool, []byte, string and any.
// interface{}. interface{} arguments are given the direct translation // any arguments are given the direct translation of the SQLite data type:
// of the SQLite data type: int64 for INTEGER, float64 for FLOAT, // int64 for INTEGER, float64 for FLOAT, []byte for BLOB, string for TEXT.
// []byte for BLOB, string for TEXT.
// //
// The function can additionally be variadic, as long as the type of // The function can additionally be variadic, as long as the type of
// the variadic argument is one of the above. // the variadic argument is one of the above.
@ -620,7 +619,7 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
// optimizations in its queries. // optimizations in its queries.
// //
// See _example/go_custom_funcs for a detailed example. // See _example/go_custom_funcs for a detailed example.
func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error { func (c *SQLiteConn) RegisterFunc(name string, impl any, pure bool) error {
var fi functionInfo var fi functionInfo
fi.f = reflect.ValueOf(impl) fi.f = reflect.ValueOf(impl)
t := fi.f.Type() t := fi.f.Type()
@ -702,7 +701,7 @@ func sqlite3CreateFunction(db *C.sqlite3, zFunctionName *C.char, nArg C.int, eTe
// return an error in addition to their other return values. // return an error in addition to their other return values.
// //
// See _example/go_custom_funcs for a detailed example. // See _example/go_custom_funcs for a detailed example.
func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error { func (c *SQLiteConn) RegisterAggregator(name string, impl any, pure bool) error {
var ai aggInfo var ai aggInfo
ai.constructor = reflect.ValueOf(impl) ai.constructor = reflect.ValueOf(impl)
t := ai.constructor.Type() t := ai.constructor.Type()
@ -976,103 +975,104 @@ func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) {
// The argument is may be either in parentheses or it may be separated from // The argument is may be either in parentheses or it may be separated from
// the pragma name by an equal sign. The two syntaxes yield identical results. // the pragma name by an equal sign. The two syntaxes yield identical results.
// In many pragmas, the argument is a boolean. The boolean can be one of: // In many pragmas, the argument is a boolean. The boolean can be one of:
// 1 yes true on //
// 0 no false off // 1 yes true on
// 0 no false off
// //
// You can specify a DSN string using a URI as the filename. // You can specify a DSN string using a URI as the filename.
// test.db
// file:test.db?cache=shared&mode=memory
// :memory:
// file::memory:
// //
// mode // test.db
// Access mode of the database. // file:test.db?cache=shared&mode=memory
// https://www.sqlite.org/c3ref/open.html // :memory:
// Values: // file::memory:
// - ro
// - rw
// - rwc
// - memory
// //
// cache // mode
// SQLite Shared-Cache Mode // Access mode of the database.
// https://www.sqlite.org/sharedcache.html // https://www.sqlite.org/c3ref/open.html
// Values: // Values:
// - shared // - ro
// - private // - rw
// - rwc
// - memory
// //
// immutable=Boolean // cache
// The immutable parameter is a boolean query parameter that indicates // SQLite Shared-Cache Mode
// that the database file is stored on read-only media. When immutable is set, // https://www.sqlite.org/sharedcache.html
// SQLite assumes that the database file cannot be changed, // Values:
// even by a process with higher privilege, // - shared
// and so the database is opened read-only and all locking and change detection is disabled. // - private
// Caution: Setting the immutable property on a database file that //
// does in fact change can result in incorrect query results and/or SQLITE_CORRUPT errors. // immutable=Boolean
// The immutable parameter is a boolean query parameter that indicates
// that the database file is stored on read-only media. When immutable is set,
// SQLite assumes that the database file cannot be changed,
// even by a process with higher privilege,
// and so the database is opened read-only and all locking and change detection is disabled.
// Caution: Setting the immutable property on a database file that
// does in fact change can result in incorrect query results and/or SQLITE_CORRUPT errors.
// //
// go-sqlite3 adds the following query parameters to those used by SQLite: // go-sqlite3 adds the following query parameters to those used by SQLite:
// _loc=XXX
// Specify location of time format. It's possible to specify "auto".
// //
// _mutex=XXX // _loc=XXX
// Specify mutex mode. XXX can be "no", "full". // Specify location of time format. It's possible to specify "auto".
// //
// _txlock=XXX // _mutex=XXX
// Specify locking behavior for transactions. XXX can be "immediate", // Specify mutex mode. XXX can be "no", "full".
// "deferred", "exclusive".
// //
// _auto_vacuum=X | _vacuum=X // _txlock=XXX
// 0 | none - Auto Vacuum disabled // Specify locking behavior for transactions. XXX can be "immediate",
// 1 | full - Auto Vacuum FULL // "deferred", "exclusive".
// 2 | incremental - Auto Vacuum Incremental
// //
// _busy_timeout=XXX"| _timeout=XXX // _auto_vacuum=X | _vacuum=X
// Specify value for sqlite3_busy_timeout. // 0 | none - Auto Vacuum disabled
// 1 | full - Auto Vacuum FULL
// 2 | incremental - Auto Vacuum Incremental
// //
// _case_sensitive_like=Boolean | _cslike=Boolean // _busy_timeout=XXX"| _timeout=XXX
// https://www.sqlite.org/pragma.html#pragma_case_sensitive_like // Specify value for sqlite3_busy_timeout.
// Default or disabled the LIKE operation is case-insensitive.
// When enabling this options behaviour of LIKE will become case-sensitive.
// //
// _defer_foreign_keys=Boolean | _defer_fk=Boolean // _case_sensitive_like=Boolean | _cslike=Boolean
// Defer Foreign Keys until outermost transaction is committed. // https://www.sqlite.org/pragma.html#pragma_case_sensitive_like
// Default or disabled the LIKE operation is case-insensitive.
// When enabling this options behaviour of LIKE will become case-sensitive.
// //
// _foreign_keys=Boolean | _fk=Boolean // _defer_foreign_keys=Boolean | _defer_fk=Boolean
// Enable or disable enforcement of foreign keys. // Defer Foreign Keys until outermost transaction is committed.
// //
// _ignore_check_constraints=Boolean // _foreign_keys=Boolean | _fk=Boolean
// This pragma enables or disables the enforcement of CHECK constraints. // Enable or disable enforcement of foreign keys.
// The default setting is off, meaning that CHECK constraints are enforced by default.
// //
// _journal_mode=MODE | _journal=MODE // _ignore_check_constraints=Boolean
// Set journal mode for the databases associated with the current connection. // This pragma enables or disables the enforcement of CHECK constraints.
// https://www.sqlite.org/pragma.html#pragma_journal_mode // The default setting is off, meaning that CHECK constraints are enforced by default.
// //
// _locking_mode=X | _locking=X // _journal_mode=MODE | _journal=MODE
// Sets the database connection locking-mode. // Set journal mode for the databases associated with the current connection.
// The locking-mode is either NORMAL or EXCLUSIVE. // https://www.sqlite.org/pragma.html#pragma_journal_mode
// https://www.sqlite.org/pragma.html#pragma_locking_mode
// //
// _query_only=Boolean // _locking_mode=X | _locking=X
// The query_only pragma prevents all changes to database files when enabled. // Sets the database connection locking-mode.
// The locking-mode is either NORMAL or EXCLUSIVE.
// https://www.sqlite.org/pragma.html#pragma_locking_mode
// //
// _recursive_triggers=Boolean | _rt=Boolean // _query_only=Boolean
// Enable or disable recursive triggers. // The query_only pragma prevents all changes to database files when enabled.
// //
// _secure_delete=Boolean|FAST // _recursive_triggers=Boolean | _rt=Boolean
// When secure_delete is on, SQLite overwrites deleted content with zeros. // Enable or disable recursive triggers.
// https://www.sqlite.org/pragma.html#pragma_secure_delete
// //
// _synchronous=X | _sync=X // _secure_delete=Boolean|FAST
// Change the setting of the "synchronous" flag. // When secure_delete is on, SQLite overwrites deleted content with zeros.
// https://www.sqlite.org/pragma.html#pragma_synchronous // https://www.sqlite.org/pragma.html#pragma_secure_delete
//
// _writable_schema=Boolean
// When this pragma is on, the SQLITE_MASTER tables in which database
// can be changed using ordinary UPDATE, INSERT, and DELETE statements.
// Warning: misuse of this pragma can easily result in a corrupt database file.
// //
// _synchronous=X | _sync=X
// Change the setting of the "synchronous" flag.
// https://www.sqlite.org/pragma.html#pragma_synchronous
// //
// _writable_schema=Boolean
// When this pragma is on, the SQLITE_MASTER tables in which database
// can be changed using ordinary UPDATE, INSERT, and DELETE statements.
// Warning: misuse of this pragma can easily result in a corrupt database file.
func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
if C.sqlite3_threadsafe() == 0 { if C.sqlite3_threadsafe() == 0 {
return nil, errors.New("sqlite library was not compiled for thread-safe operation") return nil, errors.New("sqlite library was not compiled for thread-safe operation")

View File

@ -50,15 +50,15 @@ import (
// perhaps using a cryptographic hash function like SHA1. // perhaps using a cryptographic hash function like SHA1.
// CryptEncoderSHA1 encodes a password with SHA1 // CryptEncoderSHA1 encodes a password with SHA1
func CryptEncoderSHA1(pass []byte, hash interface{}) []byte { func CryptEncoderSHA1(pass []byte, hash any) []byte {
h := sha1.Sum(pass) h := sha1.Sum(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA1 encodes a password with SHA1 with the // CryptEncoderSSHA1 encodes a password with SHA1 with the
// configured salt. // configured salt.
func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA1(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha1.Sum(p) h := sha1.Sum(p)
@ -67,15 +67,15 @@ func CryptEncoderSSHA1(salt string) func(pass []byte, hash interface{}) []byte {
} }
// CryptEncoderSHA256 encodes a password with SHA256 // CryptEncoderSHA256 encodes a password with SHA256
func CryptEncoderSHA256(pass []byte, hash interface{}) []byte { func CryptEncoderSHA256(pass []byte, hash any) []byte {
h := sha256.Sum256(pass) h := sha256.Sum256(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA256 encodes a password with SHA256 // CryptEncoderSSHA256 encodes a password with SHA256
// with the configured salt // with the configured salt
func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA256(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha256.Sum256(p) h := sha256.Sum256(p)
@ -84,15 +84,15 @@ func CryptEncoderSSHA256(salt string) func(pass []byte, hash interface{}) []byte
} }
// CryptEncoderSHA384 encodes a password with SHA384 // CryptEncoderSHA384 encodes a password with SHA384
func CryptEncoderSHA384(pass []byte, hash interface{}) []byte { func CryptEncoderSHA384(pass []byte, hash any) []byte {
h := sha512.Sum384(pass) h := sha512.Sum384(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA384 encodes a password with SHA384 // CryptEncoderSSHA384 encodes a password with SHA384
// with the configured salt // with the configured salt
func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA384(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha512.Sum384(p) h := sha512.Sum384(p)
@ -101,15 +101,15 @@ func CryptEncoderSSHA384(salt string) func(pass []byte, hash interface{}) []byte
} }
// CryptEncoderSHA512 encodes a password with SHA512 // CryptEncoderSHA512 encodes a password with SHA512
func CryptEncoderSHA512(pass []byte, hash interface{}) []byte { func CryptEncoderSHA512(pass []byte, hash any) []byte {
h := sha512.Sum512(pass) h := sha512.Sum512(pass)
return h[:] return h[:]
} }
// CryptEncoderSSHA512 encodes a password with SHA512 // CryptEncoderSSHA512 encodes a password with SHA512
// with the configured salt // with the configured salt
func CryptEncoderSSHA512(salt string) func(pass []byte, hash interface{}) []byte { func CryptEncoderSSHA512(salt string) func(pass []byte, hash any) []byte {
return func(pass []byte, hash interface{}) []byte { return func(pass []byte, hash any) []byte {
s := []byte(salt) s := []byte(salt)
p := append(pass, s...) p := append(pass, s...)
h := sha512.Sum512(p) h := sha512.Sum512(p)

View File

@ -3,8 +3,8 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build cgo //go:build cgo && go1.8
// +build go1.8 // +build cgo,go1.8
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build libsqlite3
// +build libsqlite3 // +build libsqlite3
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !sqlite_omit_load_extension
// +build !sqlite_omit_load_extension // +build !sqlite_omit_load_extension
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_omit_load_extension
// +build sqlite_omit_load_extension // +build sqlite_omit_load_extension
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_allow_uri_authority
// +build sqlite_allow_uri_authority // +build sqlite_allow_uri_authority
package sqlite3 package sqlite3

View File

@ -4,8 +4,8 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build !windows //go:build !windows && sqlite_app_armor
// +build sqlite_app_armor // +build !windows,sqlite_app_armor
package sqlite3 package sqlite3

View File

@ -1,3 +1,4 @@
//go:build sqlite_column_metadata
// +build sqlite_column_metadata // +build sqlite_column_metadata
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_foreign_keys
// +build sqlite_foreign_keys // +build sqlite_foreign_keys
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_fts5 || fts5
// +build sqlite_fts5 fts5 // +build sqlite_fts5 fts5
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_icu || icu
// +build sqlite_icu icu // +build sqlite_icu icu
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_introspect
// +build sqlite_introspect // +build sqlite_introspect
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_math_functions
// +build sqlite_math_functions // +build sqlite_math_functions
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_preupdate_hook
// +build sqlite_preupdate_hook // +build sqlite_preupdate_hook
package sqlite3 package sqlite3
@ -54,10 +55,10 @@ func (d *SQLitePreUpdateData) Count() int {
return int(C.sqlite3_preupdate_count(d.Conn.db)) return int(C.sqlite3_preupdate_count(d.Conn.db))
} }
func (d *SQLitePreUpdateData) row(dest []interface{}, new bool) error { func (d *SQLitePreUpdateData) row(dest []any, new bool) error {
for i := 0; i < d.Count() && i < len(dest); i++ { for i := 0; i < d.Count() && i < len(dest); i++ {
var val *C.sqlite3_value var val *C.sqlite3_value
var src interface{} var src any
// Initially I tried making this just a function pointer argument, but // Initially I tried making this just a function pointer argument, but
// it's absurdly complicated to pass C function pointers. // it's absurdly complicated to pass C function pointers.
@ -95,7 +96,7 @@ func (d *SQLitePreUpdateData) row(dest []interface{}, new bool) error {
// Old populates dest with the row data to be replaced. This works similar to // Old populates dest with the row data to be replaced. This works similar to
// database/sql's Rows.Scan() // database/sql's Rows.Scan()
func (d *SQLitePreUpdateData) Old(dest ...interface{}) error { func (d *SQLitePreUpdateData) Old(dest ...any) error {
if d.Op == SQLITE_INSERT { if d.Op == SQLITE_INSERT {
return errors.New("There is no old row for INSERT operations") return errors.New("There is no old row for INSERT operations")
} }
@ -104,7 +105,7 @@ func (d *SQLitePreUpdateData) Old(dest ...interface{}) error {
// New populates dest with the replacement row data. This works similar to // New populates dest with the replacement row data. This works similar to
// database/sql's Rows.Scan() // database/sql's Rows.Scan()
func (d *SQLitePreUpdateData) New(dest ...interface{}) error { func (d *SQLitePreUpdateData) New(dest ...any) error {
if d.Op == SQLITE_DELETE { if d.Op == SQLITE_DELETE {
return errors.New("There is no new row for DELETE operations") return errors.New("There is no new row for DELETE operations")
} }

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !sqlite_preupdate_hook && cgo
// +build !sqlite_preupdate_hook,cgo // +build !sqlite_preupdate_hook,cgo
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_secure_delete
// +build sqlite_secure_delete // +build sqlite_secure_delete
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_secure_delete_fast
// +build sqlite_secure_delete_fast // +build sqlite_secure_delete_fast
package sqlite3 package sqlite3

View File

@ -1,3 +1,4 @@
//go:build !libsqlite3 || sqlite_serialize
// +build !libsqlite3 sqlite_serialize // +build !libsqlite3 sqlite_serialize
package sqlite3 package sqlite3

View File

@ -1,3 +1,4 @@
//go:build libsqlite3 && !sqlite_serialize
// +build libsqlite3,!sqlite_serialize // +build libsqlite3,!sqlite_serialize
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_stat4
// +build sqlite_stat4 // +build sqlite_stat4
package sqlite3 package sqlite3

View File

@ -3,8 +3,8 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build cgo //go:build cgo && sqlite_unlock_notify
// +build sqlite_unlock_notify // +build cgo,sqlite_unlock_notify
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_userauth
// +build sqlite_userauth // +build sqlite_userauth
package sqlite3 package sqlite3
@ -79,7 +80,7 @@ var (
// If a database contains the SQLITE_USER table, then the // If a database contains the SQLITE_USER table, then the
// call to Authenticate must be invoked with an // call to Authenticate must be invoked with an
// appropriate username and password prior to enable read and write // appropriate username and password prior to enable read and write
//access to the database. // access to the database.
// //
// Return SQLITE_OK on success or SQLITE_ERROR if the username/password // Return SQLITE_OK on success or SQLITE_ERROR if the username/password
// combination is incorrect or unknown. // combination is incorrect or unknown.
@ -103,9 +104,10 @@ func (c *SQLiteConn) Authenticate(username, password string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authenticate(username, password string) int { func (c *SQLiteConn) authenticate(username, password string) int {
// Allocate C Variables // Allocate C Variables
cuser := C.CString(username) cuser := C.CString(username)
@ -155,9 +157,10 @@ func (c *SQLiteConn) AuthUserAdd(username, password string, admin bool) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authUserAdd(username, password string, admin int) int { func (c *SQLiteConn) authUserAdd(username, password string, admin int) int {
// Allocate C Variables // Allocate C Variables
cuser := C.CString(username) cuser := C.CString(username)
@ -207,9 +210,10 @@ func (c *SQLiteConn) AuthUserChange(username, password string, admin bool) error
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authUserChange(username, password string, admin int) int { func (c *SQLiteConn) authUserChange(username, password string, admin int) int {
// Allocate C Variables // Allocate C Variables
cuser := C.CString(username) cuser := C.CString(username)
@ -249,9 +253,10 @@ func (c *SQLiteConn) AuthUserDelete(username string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authUserDelete(username string) int { func (c *SQLiteConn) authUserDelete(username string) int {
// Allocate C Variables // Allocate C Variables
cuser := C.CString(username) cuser := C.CString(username)
@ -280,8 +285,9 @@ func (c *SQLiteConn) AuthEnabled() (exists bool) {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// 0 - Disabled //
// 1 - Enabled // 0 - Disabled
// 1 - Enabled
func (c *SQLiteConn) authEnabled() int { func (c *SQLiteConn) authEnabled() int {
return int(C._sqlite3_auth_enabled(c.db)) return int(C._sqlite3_auth_enabled(c.db))
} }

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !sqlite_userauth
// +build !sqlite_userauth // +build !sqlite_userauth
package sqlite3 package sqlite3
@ -17,7 +18,7 @@ import (
// If a database contains the SQLITE_USER table, then the // If a database contains the SQLITE_USER table, then the
// call to Authenticate must be invoked with an // call to Authenticate must be invoked with an
// appropriate username and password prior to enable read and write // appropriate username and password prior to enable read and write
//access to the database. // access to the database.
// //
// Return SQLITE_OK on success or SQLITE_ERROR if the username/password // Return SQLITE_OK on success or SQLITE_ERROR if the username/password
// combination is incorrect or unknown. // combination is incorrect or unknown.
@ -34,9 +35,10 @@ func (c *SQLiteConn) Authenticate(username, password string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authenticate(username, password string) int { func (c *SQLiteConn) authenticate(username, password string) int {
// NOOP // NOOP
return 0 return 0
@ -65,9 +67,10 @@ func (c *SQLiteConn) AuthUserAdd(username, password string, admin bool) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authUserAdd(username, password string, admin int) int { func (c *SQLiteConn) authUserAdd(username, password string, admin int) int {
// NOOP // NOOP
return 0 return 0
@ -96,9 +99,10 @@ func (c *SQLiteConn) AuthUserChange(username, password string, admin bool) error
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authUserChange(username, password string, admin int) int { func (c *SQLiteConn) authUserChange(username, password string, admin int) int {
// NOOP // NOOP
return 0 return 0
@ -122,9 +126,10 @@ func (c *SQLiteConn) AuthUserDelete(username string) error {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// C.SQLITE_OK (0) //
// C.SQLITE_ERROR (1) // C.SQLITE_OK (0)
// C.SQLITE_AUTH (23) // C.SQLITE_ERROR (1)
// C.SQLITE_AUTH (23)
func (c *SQLiteConn) authUserDelete(username string) int { func (c *SQLiteConn) authUserDelete(username string) int {
// NOOP // NOOP
return 0 return 0
@ -142,8 +147,9 @@ func (c *SQLiteConn) AuthEnabled() (exists bool) {
// It is however exported for usage within SQL by the user. // It is however exported for usage within SQL by the user.
// //
// Returns: // Returns:
// 0 - Disabled //
// 1 - Enabled // 0 - Disabled
// 1 - Enabled
func (c *SQLiteConn) authEnabled() int { func (c *SQLiteConn) authEnabled() int {
// NOOP // NOOP
return 0 return 0

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_vacuum_full
// +build sqlite_vacuum_full // +build sqlite_vacuum_full
package sqlite3 package sqlite3

View File

@ -4,6 +4,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_vacuum_incr
// +build sqlite_vacuum_incr // +build sqlite_vacuum_incr
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_vtable || vtable
// +build sqlite_vtable vtable // +build sqlite_vtable vtable
package sqlite3 package sqlite3
@ -516,7 +517,7 @@ func goMDestroy(pClientData unsafe.Pointer) {
func goVFilter(pCursor unsafe.Pointer, idxNum C.int, idxName *C.char, argc C.int, argv **C.sqlite3_value) *C.char { func goVFilter(pCursor unsafe.Pointer, idxNum C.int, idxName *C.char, argc C.int, argv **C.sqlite3_value) *C.char {
vtc := lookupHandle(pCursor).(*sqliteVTabCursor) vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc] args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
vals := make([]interface{}, 0, argc) vals := make([]any, 0, argc)
for _, v := range args { for _, v := range args {
conv, err := callbackArgGeneric(v) conv, err := callbackArgGeneric(v)
if err != nil { if err != nil {
@ -588,7 +589,7 @@ func goVUpdate(pVTab unsafe.Pointer, argc C.int, argv **C.sqlite3_value, pRowid
if v, ok := vt.vTab.(VTabUpdater); ok { if v, ok := vt.vTab.(VTabUpdater); ok {
// convert argv // convert argv
args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc] args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
vals := make([]interface{}, 0, argc) vals := make([]any, 0, argc)
for _, v := range args { for _, v := range args {
conv, err := callbackArgGeneric(v) conv, err := callbackArgGeneric(v)
if err != nil { if err != nil {
@ -662,9 +663,9 @@ type VTab interface {
// deleted. // deleted.
// See: https://sqlite.org/vtab.html#xupdate // See: https://sqlite.org/vtab.html#xupdate
type VTabUpdater interface { type VTabUpdater interface {
Delete(interface{}) error Delete(any) error
Insert(interface{}, []interface{}) (int64, error) Insert(any, []any) (int64, error)
Update(interface{}, []interface{}) error Update(any, []any) error
} }
// VTabCursor describes cursors that point into the virtual table and are used // VTabCursor describes cursors that point into the virtual table and are used
@ -673,7 +674,7 @@ type VTabCursor interface {
// http://sqlite.org/vtab.html#xclose // http://sqlite.org/vtab.html#xclose
Close() error Close() error
// http://sqlite.org/vtab.html#xfilter // http://sqlite.org/vtab.html#xfilter
Filter(idxNum int, idxStr string, vals []interface{}) error Filter(idxNum int, idxStr string, vals []any) error
// http://sqlite.org/vtab.html#xnext // http://sqlite.org/vtab.html#xnext
Next() error Next() error
// http://sqlite.org/vtab.html#xeof // http://sqlite.org/vtab.html#xeof

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !windows
// +build !windows // +build !windows
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build solaris
// +build solaris // +build solaris
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build sqlite_trace || trace
// +build sqlite_trace trace // +build sqlite_trace trace
package sqlite3 package sqlite3

View File

@ -74,7 +74,7 @@ func scanType(cdt string) reflect.Type {
case SQLITE_TIME: case SQLITE_TIME:
return reflect.TypeOf(sql.NullTime{}) return reflect.TypeOf(sql.NullTime{})
} }
return reflect.TypeOf(new(interface{})) return reflect.TypeOf(new(any))
} }
func databaseTypeConvSqlite(t string) int { func databaseTypeConvSqlite(t string) int {

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build cgo
// +build cgo // +build cgo
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build windows
// +build windows // +build windows
package sqlite3 package sqlite3

View File

@ -3,6 +3,7 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
//go:build !cgo
// +build !cgo // +build !cgo
package sqlite3 package sqlite3
@ -28,10 +29,10 @@ type (
) )
func (SQLiteDriver) Open(s string) (driver.Conn, error) { return nil, errorMsg } func (SQLiteDriver) Open(s string) (driver.Conn, error) { return nil, errorMsg }
func (c *SQLiteConn) RegisterAggregator(string, interface{}, bool) error { return errorMsg } func (c *SQLiteConn) RegisterAggregator(string, any, bool) error { return errorMsg }
func (c *SQLiteConn) RegisterAuthorizer(func(int, string, string, string) int) {} func (c *SQLiteConn) RegisterAuthorizer(func(int, string, string, string) int) {}
func (c *SQLiteConn) RegisterCollation(string, func(string, string) int) error { return errorMsg } func (c *SQLiteConn) RegisterCollation(string, func(string, string) int) error { return errorMsg }
func (c *SQLiteConn) RegisterCommitHook(func() int) {} func (c *SQLiteConn) RegisterCommitHook(func() int) {}
func (c *SQLiteConn) RegisterFunc(string, interface{}, bool) error { return errorMsg } func (c *SQLiteConn) RegisterFunc(string, any, bool) error { return errorMsg }
func (c *SQLiteConn) RegisterRollbackHook(func()) {} func (c *SQLiteConn) RegisterRollbackHook(func()) {}
func (c *SQLiteConn) RegisterUpdateHook(func(int, string, string, int64)) {} func (c *SQLiteConn) RegisterUpdateHook(func(int, string, string, int64)) {}

4
vendor/modules.txt vendored
View File

@ -763,8 +763,8 @@ github.com/mattn/go-runewidth
# github.com/mattn/go-shellwords v1.0.12 # github.com/mattn/go-shellwords v1.0.12
## explicit; go 1.13 ## explicit; go 1.13
github.com/mattn/go-shellwords github.com/mattn/go-shellwords
# github.com/mattn/go-sqlite3 v1.14.19 # github.com/mattn/go-sqlite3 v1.14.20
## explicit; go 1.16 ## explicit; go 1.19
github.com/mattn/go-sqlite3 github.com/mattn/go-sqlite3
# github.com/mdlayher/socket v0.4.1 # github.com/mdlayher/socket v0.4.1
## explicit; go 1.20 ## explicit; go 1.20