From aaf8f13d6811614c345d329aca7b9b53392556d6 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 14:40:51 +0800 Subject: [PATCH 1/9] Add the nocurrenttime VFS A copy of the default VFS without the current time, selected with vfs=nocurrenttime. Date and time functions then give NULL for 'now', for calls without a time value and for the CURRENT_* keywords, so replicas that execute the same statements store the same values, whatever way 'now' reaches the function. --- sqlite3.go | 9 +++++ sqlite3_nocurrenttime.go | 67 +++++++++++++++++++++++++++++++++++ sqlite3_nocurrenttime_test.go | 59 ++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 sqlite3_nocurrenttime.go create mode 100644 sqlite3_nocurrenttime_test.go diff --git a/sqlite3.go b/sqlite3.go index 04b93efe..7173b454 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -1182,6 +1182,10 @@ func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) { // _crypto_key=XXX // Specify the SQLCipher encryption key, as text without quotes. // +// vfs=nocurrenttime +// Use a copy of the default VFS without the current time: 'now' and the +// CURRENT_* keywords give NULL, so results do not depend on when a query runs. +// // _auto_vacuum=X | _vacuum=X // 0 | none - Auto Vacuum disabled // 1 | full - Auto Vacuum FULL @@ -1637,6 +1641,11 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { if val := params.Get("vfs"); val != "" { vfsName = val } + if vfsName == noCurrentTimeVFS { + if err := registerNoCurrentTimeVFS(); err != nil { + return nil, err + } + } if !strings.HasPrefix(dsn, "file:") { dsn = dsn[:pos] diff --git a/sqlite3_nocurrenttime.go b/sqlite3_nocurrenttime.go new file mode 100644 index 00000000..23f379a6 --- /dev/null +++ b/sqlite3_nocurrenttime.go @@ -0,0 +1,67 @@ +//go:build cgo +// +build cgo + +package sqlite3 + +/* +#ifndef USE_LIBSQLITE3 +#include "sqlite3-binding.h" +#else +#include +#endif + +static sqlite3_vfs noCurrentTimeVfs; + +static int noCurrentTime(sqlite3_vfs *vfs, double *now) { + *now = 0; + return SQLITE_ERROR; +} + +static int noCurrentTimeInt64(sqlite3_vfs *vfs, sqlite3_int64 *now) { + *now = 0; + return SQLITE_ERROR; +} + +// Register a copy of the default VFS named "nocurrenttime" whose current time +// is unavailable. +static int _sqlite3_register_no_current_time_vfs(void) { + sqlite3_vfs *base = sqlite3_vfs_find(0); + if (base == 0) { + return SQLITE_ERROR; + } + noCurrentTimeVfs = *base; + noCurrentTimeVfs.zName = "nocurrenttime"; + noCurrentTimeVfs.pNext = 0; + noCurrentTimeVfs.xCurrentTime = noCurrentTime; + if (noCurrentTimeVfs.iVersion >= 2) { + noCurrentTimeVfs.xCurrentTimeInt64 = noCurrentTimeInt64; + } + return sqlite3_vfs_register(&noCurrentTimeVfs, 0); +} +*/ +import "C" + +import ( + "fmt" + "sync" +) + +// noCurrentTimeVFS is the VFS that the DSN parameter vfs=nocurrenttime selects. +// Date and time functions get no current time from it, so 'now' and the +// CURRENT_* keywords give NULL, and every connection computes the same results +// from the same data whenever it runs. +const noCurrentTimeVFS = "nocurrenttime" + +var ( + noCurrentTimeOnce sync.Once + noCurrentTimeErr error +) + +func registerNoCurrentTimeVFS() error { + noCurrentTimeOnce.Do(func() { + if rv := C._sqlite3_register_no_current_time_vfs(); rv != C.SQLITE_OK { + noCurrentTimeErr = fmt.Errorf("sqlite3: registering the %s VFS failed: %d", noCurrentTimeVFS, rv) + } + }) + return noCurrentTimeErr +} diff --git a/sqlite3_nocurrenttime_test.go b/sqlite3_nocurrenttime_test.go new file mode 100644 index 00000000..88791529 --- /dev/null +++ b/sqlite3_nocurrenttime_test.go @@ -0,0 +1,59 @@ +//go:build cgo +// +build cgo + +package sqlite3 + +import ( + "database/sql" + "path/filepath" + "testing" +) + +func TestNoCurrentTimeVFS(t *testing.T) { + path := filepath.Join(t.TempDir(), "nocurrenttime.db") + db, err := sql.Open("sqlite3", "file:"+path+"?vfs=nocurrenttime&_journal_mode=WAL") + if err != nil { + t.Fatal(err) + } + defer db.Close() + + // Files are read and written as with the default VFS. + if _, err := db.Exec("CREATE TABLE t (v TEXT); INSERT INTO t VALUES (date('2000-01-02'))"); err != nil { + t.Fatal(err) + } + var v string + if err := db.QueryRow("SELECT v FROM t").Scan(&v); err != nil || v != "2000-01-02" { + t.Fatalf("read back %q, err %v", v, err) + } + + for _, q := range []struct { + query string + args []any + }{ + {"SELECT date('now')", nil}, + {"SELECT date(?)", []any{"now"}}, + {"SELECT date('n' || 'ow')", nil}, + {"SELECT datetime()", nil}, + {"SELECT julianday('now')", nil}, + {"SELECT unixepoch()", nil}, + {"SELECT strftime('%Y')", nil}, + {"SELECT CURRENT_TIMESTAMP", nil}, + } { + var got sql.NullString + if err := db.QueryRow(q.query, q.args...).Scan(&got); err != nil { + t.Errorf("%s: %v", q.query, err) + } else if got.Valid { + t.Errorf("%s: got the current time %q, want NULL", q.query, got.String) + } + } + + plain, err := sql.Open("sqlite3", ":memory:") + if err != nil { + t.Fatal(err) + } + defer plain.Close() + var now sql.NullString + if err := plain.QueryRow("SELECT date('now')").Scan(&now); err != nil || !now.Valid { + t.Fatalf("the default VFS has no current time: %q, err %v", now.String, err) + } +} From 6ebb6c56a5f1a701d0f3249718ec1093340f6e84 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 14:40:51 +0800 Subject: [PATCH 2/9] Add the sqlite_omit_localtime build tag It builds SQLite with SQLITE_OMIT_LOCALTIME, which removes the localtime and utc modifiers whose results depend on the time zone of the host. --- sqlite3_opt_omit_localtime.go | 11 +++++++++++ sqlite3_opt_omit_localtime_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 sqlite3_opt_omit_localtime.go create mode 100644 sqlite3_opt_omit_localtime_test.go diff --git a/sqlite3_opt_omit_localtime.go b/sqlite3_opt_omit_localtime.go new file mode 100644 index 00000000..609b634f --- /dev/null +++ b/sqlite3_opt_omit_localtime.go @@ -0,0 +1,11 @@ +//go:build sqlite_omit_localtime + +package sqlite3 + +// Without the localtime and utc modifiers, date and time functions do not +// depend on the time zone of the host. + +/* +#cgo CFLAGS: -DSQLITE_OMIT_LOCALTIME +*/ +import "C" diff --git a/sqlite3_opt_omit_localtime_test.go b/sqlite3_opt_omit_localtime_test.go new file mode 100644 index 00000000..a5ba9d15 --- /dev/null +++ b/sqlite3_opt_omit_localtime_test.go @@ -0,0 +1,25 @@ +//go:build cgo && sqlite_omit_localtime +// +build cgo,sqlite_omit_localtime + +package sqlite3 + +import ( + "database/sql" + "testing" +) + +func TestOmitLocaltime(t *testing.T) { + db, err := sql.Open("sqlite3", ":memory:") + if err != nil { + t.Fatal(err) + } + defer db.Close() + for _, modifier := range []string{"localtime", "utc"} { + var got sql.NullString + if err := db.QueryRow("SELECT datetime('2000-01-01 12:00:00', ?)", modifier).Scan(&got); err != nil { + t.Errorf("%s: %v", modifier, err) + } else if got.Valid { + t.Errorf("%s: got %q, want NULL", modifier, got.String) + } + } +} From 5c551ab12a0ce83369fa7f76c116f577348fe3aa Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 14:40:51 +0800 Subject: [PATCH 3/9] Describe the deterministic date and time options in the README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index bd7511e7..2e38d7b1 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,20 @@ Pass the key in the DSN, `sql.Open("sqlite3", "file:test.db?_crypto_key=secret") - With a shared cache (`cache=shared`), a connection with a wrong key or no key can read a database that another connection of the process has opened with the right key. - Backups between an encrypted and a plain database fail; use `sqlcipher_export` to copy between them. +## Deterministic date and time + +For results that do not depend on when or where a query runs, as when several replicas execute the same statements: + +- `vfs=nocurrenttime` in the DSN uses a copy of the default VFS without the current time, so `'now'`, date and time functions called without a time value, and the `CURRENT_*` keywords give NULL. +- The `sqlite_omit_localtime` build tag removes the `localtime` and `utc` modifiers, which depend on the time zone of the host; they give NULL as well. + ## Changes from go-sqlite3 - `sqlite3-binding.c`, `sqlite3-binding.h` and `sqlite3ext.h` are generated from the SQLCipher sources. The `upgrade` tool, which replaces them with the official SQLite amalgamation, is removed. - The LibTomCrypt sources SQLCipher needs: the `tomcrypt*.h` headers and the `.c` files whose names do not start with `sqlite3`. - `sqlite3.go` defines the SQLCipher compile options, turns off the default logging of SQLCipher to stderr, and adds the `_crypto_key` DSN parameter. - `Exec` without arguments reports missing arguments again, which go-sqlite3 v1.14.52 does not. +- `sqlite3_nocurrenttime.go` adds the `nocurrenttime` VFS, and `sqlite3_opt_omit_localtime.go` the `sqlite_omit_localtime` tag. - `sqlite3_opt_icu.go` adds the libraries that a static link of ICU needs. - The CIFuzz workflow, which builds the OSS-Fuzz project of go-sqlite3, is removed. From c0d263519461f2fccacb0ff6081d71af27d2a68c Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 14:44:58 +0800 Subject: [PATCH 4/9] Test that Exec without arguments stops at missing arguments TestNotEnoughArgsErrorMessage only checks the error, which an Exec that ran the statement before failing would pass too. --- sqlite3_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sqlite3_test.go b/sqlite3_test.go index 4e7cf58d..5689dc7a 100644 --- a/sqlite3_test.go +++ b/sqlite3_test.go @@ -2249,6 +2249,33 @@ func TestNotEnoughArgsErrorMessage(t *testing.T) { }) } +// Exec without arguments must not run a statement whose arguments are +// missing, nor the statements after it. +func TestExecWithoutArgsStopsAtMissingArgs(t *testing.T) { + db, err := sql.Open("sqlite3", ":memory:") + if err != nil { + t.Fatal(err) + } + defer db.Close() + // Every connection to :memory: has its own database. + db.SetMaxOpenConns(1) + + if _, err := db.Exec("CREATE TABLE t (x INTEGER)"); err != nil { + t.Fatal(err) + } + _, err = db.Exec("INSERT INTO t VALUES (7); INSERT INTO t VALUES (?); INSERT INTO t VALUES (9)") + if err == nil { + t.Fatal("expected error, got nil") + } + var rows string + if err := db.QueryRow("SELECT group_concat(coalesce(x, 'NULL')) FROM t").Scan(&rows); err != nil { + t.Fatal(err) + } + if rows != "7" { + t.Errorf("got rows %q, want only the statement before the missing argument: \"7\"", rows) + } +} + // https://github.com/mattn/go-sqlite3/issues/1390 // sqlite3_prepare_v2 returns SQLITE_OK with a NULL statement handle when the // input contains no SQL (only whitespace or comments). Querying such input From f01f73c0ba13a9de34ac7cc450661eecc7276bfc Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 15:34:25 +0800 Subject: [PATCH 5/9] Revert "Test that Exec without arguments stops at missing arguments" This reverts commit c0d263519461f2fccacb0ff6081d71af27d2a68c, which does not belong to this change. The same test is in mattn/go-sqlite3#1471 and comes back with the next update from go-sqlite3. --- sqlite3_test.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/sqlite3_test.go b/sqlite3_test.go index 5689dc7a..4e7cf58d 100644 --- a/sqlite3_test.go +++ b/sqlite3_test.go @@ -2249,33 +2249,6 @@ func TestNotEnoughArgsErrorMessage(t *testing.T) { }) } -// Exec without arguments must not run a statement whose arguments are -// missing, nor the statements after it. -func TestExecWithoutArgsStopsAtMissingArgs(t *testing.T) { - db, err := sql.Open("sqlite3", ":memory:") - if err != nil { - t.Fatal(err) - } - defer db.Close() - // Every connection to :memory: has its own database. - db.SetMaxOpenConns(1) - - if _, err := db.Exec("CREATE TABLE t (x INTEGER)"); err != nil { - t.Fatal(err) - } - _, err = db.Exec("INSERT INTO t VALUES (7); INSERT INTO t VALUES (?); INSERT INTO t VALUES (9)") - if err == nil { - t.Fatal("expected error, got nil") - } - var rows string - if err := db.QueryRow("SELECT group_concat(coalesce(x, 'NULL')) FROM t").Scan(&rows); err != nil { - t.Fatal(err) - } - if rows != "7" { - t.Errorf("got rows %q, want only the statement before the missing argument: \"7\"", rows) - } -} - // https://github.com/mattn/go-sqlite3/issues/1390 // sqlite3_prepare_v2 returns SQLITE_OK with a NULL statement handle when the // input contains no SQL (only whitespace or comments). Querying such input From 0ff3fc7d35dfbfa95160d257b4a74d7574b7f701 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 15:36:32 +0800 Subject: [PATCH 6/9] Refuse to open with sqlite_omit_localtime when SQLite has localtime The tag only changes the bundled SQLite. With the libsqlite3 tag, a system SQLite kept the localtime and utc modifiers and the tag had no effect, without any sign of it. Open now fails then, as with _crypto_key and a SQLite without SQLCipher, and both checks share compileOptionUsed. --- sqlite3.go | 18 +++++++++++---- sqlite3_opt_omit_localtime.go | 2 ++ sqlite3_opt_omit_localtime_libsqlite3_test.go | 22 +++++++++++++++++++ sqlite3_opt_omit_localtime_omit.go | 5 +++++ sqlite3_opt_omit_localtime_test.go | 3 +-- 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 sqlite3_opt_omit_localtime_libsqlite3_test.go create mode 100644 sqlite3_opt_omit_localtime_omit.go diff --git a/sqlite3.go b/sqlite3.go index 7173b454..5fd5e796 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -381,6 +381,14 @@ func Version() (libVersion string, libVersionNumber int, sourceID string) { return libVersion, libVersionNumber, sourceID } +// compileOptionUsed reports whether SQLite was built with the option, named +// without the SQLITE_ prefix. +func compileOptionUsed(name string) bool { + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) + return C.sqlite3_compileoption_used(cname) != 0 +} + const ( // used by authorizer and pre_update_hook SQLITE_DELETE = C.SQLITE_DELETE @@ -1240,6 +1248,11 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { if C.sqlite3_threadsafe() == 0 { return nil, errors.New("sqlite library was not compiled for thread-safe operation") } + // The tag only changes the bundled SQLite: a system SQLite linked with the + // libsqlite3 tag may still have the localtime and utc modifiers. + if omitLocaltime && !compileOptionUsed("OMIT_LOCALTIME") { + return nil, errors.New("sqlite3: the sqlite_omit_localtime tag needs SQLite built with SQLITE_OMIT_LOCALTIME") + } var pkey string @@ -1326,10 +1339,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { if cryptoKey != "" { // Without SQLCipher, as with the libsqlite3 tag and a plain system SQLite, // PRAGMA key does nothing and the database would be written in plain text. - hasCodec := C.CString("HAS_CODEC") - used := C.sqlite3_compileoption_used(hasCodec) - C.free(unsafe.Pointer(hasCodec)) - if used == 0 { + if !compileOptionUsed("HAS_CODEC") { return nil, errors.New("sqlite3: _crypto_key needs SQLite built with SQLCipher") } // A NUL would cut the PRAGMA key statement short, and the syntax error diff --git a/sqlite3_opt_omit_localtime.go b/sqlite3_opt_omit_localtime.go index 609b634f..0abf7683 100644 --- a/sqlite3_opt_omit_localtime.go +++ b/sqlite3_opt_omit_localtime.go @@ -9,3 +9,5 @@ package sqlite3 #cgo CFLAGS: -DSQLITE_OMIT_LOCALTIME */ import "C" + +const omitLocaltime = true diff --git a/sqlite3_opt_omit_localtime_libsqlite3_test.go b/sqlite3_opt_omit_localtime_libsqlite3_test.go new file mode 100644 index 00000000..767498c4 --- /dev/null +++ b/sqlite3_opt_omit_localtime_libsqlite3_test.go @@ -0,0 +1,22 @@ +//go:build cgo && sqlite_omit_localtime && libsqlite3 + +package sqlite3 + +import ( + "database/sql" + "testing" +) + +func TestOmitLocaltimeWithoutTheOption(t *testing.T) { + if compileOptionUsed("OMIT_LOCALTIME") { + t.Skip("the system SQLite is built with SQLITE_OMIT_LOCALTIME") + } + db, err := sql.Open("sqlite3", ":memory:") + if err != nil { + t.Fatal(err) + } + defer db.Close() + if err := db.Ping(); err == nil { + t.Fatal("opened a database with the sqlite_omit_localtime tag and a SQLite that has localtime") + } +} diff --git a/sqlite3_opt_omit_localtime_omit.go b/sqlite3_opt_omit_localtime_omit.go new file mode 100644 index 00000000..1e77d545 --- /dev/null +++ b/sqlite3_opt_omit_localtime_omit.go @@ -0,0 +1,5 @@ +//go:build !sqlite_omit_localtime + +package sqlite3 + +const omitLocaltime = false diff --git a/sqlite3_opt_omit_localtime_test.go b/sqlite3_opt_omit_localtime_test.go index a5ba9d15..756c9335 100644 --- a/sqlite3_opt_omit_localtime_test.go +++ b/sqlite3_opt_omit_localtime_test.go @@ -1,5 +1,4 @@ -//go:build cgo && sqlite_omit_localtime -// +build cgo,sqlite_omit_localtime +//go:build cgo && sqlite_omit_localtime && !libsqlite3 package sqlite3 From 7168b7fa67a189bba652828016650c384f440a36 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 15:36:55 +0800 Subject: [PATCH 7/9] Refuse a DSN with more than one vfs parameter The driver took the first one and SQLite the last one, so vfs=nocurrenttime&vfs=unix registered the nocurrenttime VFS but opened the database with the default one, which has the current time. --- sqlite3.go | 5 +++++ sqlite3_nocurrenttime_test.go | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/sqlite3.go b/sqlite3.go index 5fd5e796..dfdb1645 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -1648,6 +1648,11 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { stmtCacheSize = iv } + // SQLite uses the last vfs parameter of a file: URI, while vfsName + // would be the first one. + if len(params["vfs"]) > 1 { + return nil, errors.New("sqlite3: more than one vfs parameter") + } if val := params.Get("vfs"); val != "" { vfsName = val } diff --git a/sqlite3_nocurrenttime_test.go b/sqlite3_nocurrenttime_test.go index 88791529..030f2ba1 100644 --- a/sqlite3_nocurrenttime_test.go +++ b/sqlite3_nocurrenttime_test.go @@ -57,3 +57,15 @@ func TestNoCurrentTimeVFS(t *testing.T) { t.Fatalf("the default VFS has no current time: %q, err %v", now.String, err) } } + +func TestMoreThanOneVFS(t *testing.T) { + // SQLite would open this with the last one, the default VFS. + db, err := sql.Open("sqlite3", "file:"+filepath.Join(t.TempDir(), "two.db")+"?vfs=nocurrenttime&vfs=unix") + if err != nil { + t.Fatal(err) + } + defer db.Close() + if err := db.Ping(); err == nil { + t.Fatal("opened a database with two vfs parameters") + } +} From 569a12b597708621701bb0f2ebfe7ac89ccdd5d7 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 15:37:22 +0800 Subject: [PATCH 8/9] Document what the nocurrenttime VFS and the localtime tag cover The doc comment of Open now lists date and time functions without a time value like the README, and the comment of the VFS no longer claims that all results are the same whenever a query runs: random() is not. Describe NOT NULL DEFAULT CURRENT_TIMESTAMP columns, the missing profile events, the libsqlite3 tag and the shallow copy of the default VFS. --- README.md | 4 +++- sqlite3.go | 5 +++-- sqlite3_nocurrenttime.go | 11 +++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2e38d7b1..5adbf156 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ Pass the key in the DSN, `sql.Open("sqlite3", "file:test.db?_crypto_key=secret") For results that do not depend on when or where a query runs, as when several replicas execute the same statements: - `vfs=nocurrenttime` in the DSN uses a copy of the default VFS without the current time, so `'now'`, date and time functions called without a time value, and the `CURRENT_*` keywords give NULL. -- The `sqlite_omit_localtime` build tag removes the `localtime` and `utc` modifiers, which depend on the time zone of the host; they give NULL as well. +- The `sqlite_omit_localtime` build tag removes the `localtime` and `utc` modifiers, which depend on the time zone of the host; they give NULL as well. The tag only changes the bundled SQLite, so with the `libsqlite3` tag, opening a database fails unless the system SQLite is built with `SQLITE_OMIT_LOCALTIME`. + +Without a current time, a column declared `NOT NULL DEFAULT CURRENT_TIMESTAMP` cannot get its default, and inserts that rely on it fail. SQLite also skips the profile callbacks of statements, so `sqlite_trace` profile events and SQLCipher's `PRAGMA cipher_profile` report nothing. ## Changes from go-sqlite3 diff --git a/sqlite3.go b/sqlite3.go index dfdb1645..a4aaf7d3 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -1191,8 +1191,9 @@ func (c *SQLiteConn) begin(ctx context.Context) (driver.Tx, error) { // Specify the SQLCipher encryption key, as text without quotes. // // vfs=nocurrenttime -// Use a copy of the default VFS without the current time: 'now' and the -// CURRENT_* keywords give NULL, so results do not depend on when a query runs. +// Use a copy of the default VFS without the current time: 'now', date and +// time functions without a time value and the CURRENT_* keywords give NULL, +// so results do not depend on when a query runs. // // _auto_vacuum=X | _vacuum=X // 0 | none - Auto Vacuum disabled diff --git a/sqlite3_nocurrenttime.go b/sqlite3_nocurrenttime.go index 23f379a6..558c2544 100644 --- a/sqlite3_nocurrenttime.go +++ b/sqlite3_nocurrenttime.go @@ -23,7 +23,9 @@ static int noCurrentTimeInt64(sqlite3_vfs *vfs, sqlite3_int64 *now) { } // Register a copy of the default VFS named "nocurrenttime" whose current time -// is unavailable. +// is unavailable. The copy shares the methods and pAppData of the default VFS, +// which suits the unix and win32 VFSes, but not a default VFS that checks its +// own name or extends sqlite3_vfs. static int _sqlite3_register_no_current_time_vfs(void) { sqlite3_vfs *base = sqlite3_vfs_find(0); if (base == 0) { @@ -47,9 +49,10 @@ import ( ) // noCurrentTimeVFS is the VFS that the DSN parameter vfs=nocurrenttime selects. -// Date and time functions get no current time from it, so 'now' and the -// CURRENT_* keywords give NULL, and every connection computes the same results -// from the same data whenever it runs. +// Date and time functions get no current time from it, so 'now', date and time +// functions without a time value and the CURRENT_* keywords give NULL, and +// their results do not depend on when a query runs. Without a current time, +// SQLite also skips the profile callbacks of statements. const noCurrentTimeVFS = "nocurrenttime" var ( From 41561377457f6170e2141cc7816c05afb88f6f30 Mon Sep 17 00:00:00 2001 From: Jin Xu Date: Wed, 4 Nov 2026 15:37:29 +0800 Subject: [PATCH 9/9] Drop the // +build lines of the new files go.mod requires Go 1.21, which only reads //go:build. --- sqlite3_nocurrenttime.go | 1 - sqlite3_nocurrenttime_test.go | 1 - 2 files changed, 2 deletions(-) diff --git a/sqlite3_nocurrenttime.go b/sqlite3_nocurrenttime.go index 558c2544..1b10f9ab 100644 --- a/sqlite3_nocurrenttime.go +++ b/sqlite3_nocurrenttime.go @@ -1,5 +1,4 @@ //go:build cgo -// +build cgo package sqlite3 diff --git a/sqlite3_nocurrenttime_test.go b/sqlite3_nocurrenttime_test.go index 030f2ba1..5475105b 100644 --- a/sqlite3_nocurrenttime_test.go +++ b/sqlite3_nocurrenttime_test.go @@ -1,5 +1,4 @@ //go:build cgo -// +build cgo package sqlite3