Skip to content

Commit 1fb71c4

Browse files
author
Jan Mercl
committed
sqlite: review follow-ups for the _defensive DSN option
Documentation, one new validation rule, and test coverage on top of wsman's GitHub PR #6. No change to what _defensive itself does. conn.go: the comment above the db_config calls had been generalized to "connection-level sqlite3_db_config options are applied before applyQueryParams because the SQLite contract requires sqlite3_db_config(SQLITE_DBCONFIG_DQS_*) to be set before any statement is prepared". That contract is DQS-specific and does not extend to DEFENSIVE, which may be toggled at any point in a connection's life; defensive goes first because the PRAGMAs that follow must run under the restriction, which is a choice, not an API requirement. Restore the DQS comment verbatim on the DQS call and give _defensive its own rationale. sqlite.go: reject _defensive=1 together with _journal_mode=OFF (or _journal=OFF). SQLite turns PRAGMA journal_mode=OFF into a no-op that still reports success under defensive mode, so the combination previously opened a connection in which neither parameter had been honoured and nothing was reported. The check sits in the validation phase from v1.55.0, before any statement executes, so a rejected DSN still cannot leave the database half-configured. _pragma stays the documented exception: _pragma =journal_mode(OFF) alongside _defensive=1 runs and is silently ignored by SQLite. Only DSNs using _defensive can be affected and that parameter is new, so no DSN that opened before changes behavior. driver.go: expand the _defensive documentation to the depth of its _dqs and _error_rc neighbours -- what the mode observably does (writable_schema=ON, journal_mode=OFF and schema_version=N become silent no-ops; shadow-table and sqlite_dbpage writes error; reads, ordinary virtual table use and VACUUM are unaffected), the new _journal_mode conflict, and the two limits the name invites callers to overlook: it is a hardening measure rather than a sandbox for hostile files (this build has neither SQLITE_TRUSTED_SCHEMA=0 nor SQLITE_DQS=0 and there is no authorizer), and it is a property of the connection, not of the database file. defensive_test.go: rename TestUnmodifiedBehaviorIsNotAnADEDefensiveControl, whose "ADE" is an acronym from the contributor's downstream and means nothing here, to TestDefensiveAbsentOrFalseIsBaseline, and TestUnprotectedPoolIsA NegativeControl to TestDefensiveOffPoolIsANegativeControl so every test in the file groups under the feature. Add TestDefensiveRejectsJournalModeOff for the new rule, TestDefensiveDSNForms for the file: URI shape -- which keeps its query string all the way into sqlite3_open_v2, so SQLite parses _defensive too and must ignore it -- plus :memory: and shared-cache memory URIs, TestDefensiveLeavesOrdinaryUseIntact for the other half of the contract (fts5 create/insert/MATCH, foreign keys, VACUUM, integrity_check and every other DSN parameter that could collide, with direct fts5 shadow-table and sqlite_dbpage writes refused), and TestDefensiveIsPerConnection to pin the documented scope. Also adopt the file's `package sqlite // import ...` form. CHANGELOG.md: document both the parameter and the new conflict rule.
1 parent 9e95507 commit 1fb71c4

5 files changed

Lines changed: 287 additions & 16 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
- 2026-08-09 v1.57.0:
4+
- Add an opt-in `_defensive` DSN query parameter that turns on SQLite's defensive mode for the connection, disabling the SQL-level features that let ordinary statements deliberately corrupt the database file. When `_defensive=1` (or any `strconv.ParseBool` true value) is supplied, the driver calls `sqlite3_db_config` with `SQLITE_DBCONFIG_DEFENSIVE` immediately after `sqlite3_open_v2` and before every other parameter is applied, so the PRAGMAs the driver itself runs, the `_pragma` list, and every statement the caller prepares are all subject to it. On such a connection `PRAGMA writable_schema=ON`, `PRAGMA journal_mode=OFF` and `PRAGMA schema_version=N` become silent no-ops, and writes to a virtual table's shadow tables (fts5's `_data`, `_idx` and so on) and to `sqlite_dbpage` fail with "table ... may not be modified"; reading those tables, ordinary use of the virtual tables that own them, and `VACUUM` are unaffected. The flag has no PRAGMA equivalent, so `sqlite3_db_config` — and therefore a DSN parameter — is the only way to reach it short of dropping to `modernc.org/sqlite/lib`. The value is parsed before `sqlite3_open_v2`, so an invalid one fails the connection without creating the database file, and the parameter must appear at most once: a repeated `_defensive` is an error rather than letting the first value silently win. Absence of the parameter, or `_defensive=0`, leaves SQLite's default behavior unchanged; existing DSNs continue to work byte-for-byte. Two limits are worth stating plainly, since the name invites more confidence than the flag earns. Defensive mode is a hardening measure, not a sandbox for hostile database files: it is one of several steps [SQLite recommends](https://www.sqlite.org/security.html) for that purpose, and this build compiles with neither `SQLITE_TRUSTED_SCHEMA=0` nor `SQLITE_DQS=0` and exposes no authorizer. And it is a property of the connection, not of the database file — a second handle opened on the same file without the parameter is unrestricted.
5+
- Reject the one DSN combination defensive mode would otherwise swallow in silence. `_defensive=1` together with `_journal_mode=OFF` (or `_journal=OFF`) now fails the connection instead of opening one in which neither parameter was honoured: SQLite turns `PRAGMA journal_mode=OFF` into a no-op that still reports success, so the driver would have accepted the mode, executed it, and left the journal untouched without telling anyone. The check runs in the validation phase introduced in v1.55.0, before any statement executes, so a rejected DSN cannot leave the database half-configured. `_pragma` remains the exception it has always been: `_pragma=journal_mode(OFF)` alongside `_defensive=1` still runs and is still silently ignored by SQLite. Only DSNs using `_defensive` can be affected, and that parameter is new, so no DSN that opened before changes behavior.
6+
- See [GitHub pull request #6](https://github.com/modernc-org/sqlite/pull/6), thanks wsman!
7+
38
- 2026-08-03 v1.56.0:
49
- Re-vendor the transpiled SQLite sources, picking up `modernc.org/libsqlite3`'s fix for an upstream **data-corruption bug in SQLite 3.53.3's journal rollback**. The SQLite version is unchanged at [3.53.3](https://sqlite.org/releaselog/3_53_3.html); what changes is that the amalgamation is now patched before it is transpiled. 3.53.3 reworked `readSuperJournal()` to return the super-journal name through a `char**` out-parameter, and `pager_playback()` now tests that pointer where it used to test `zSuper[0]`. A crash during the commit of a multi-database (ATTACH) transaction can leave the super-journal name and its checksum zeroed while the name length and the trailing magic survive; the checksum is a plain byte sum, so an all-zero name still validates and `readSuperJournal()` hands back a non-NULL pointer to an empty string. `pager_playback()` then calls `sqlite3OsAccess(pVfs, "", SQLITE_ACCESS_EXISTS)`, gets ENOENT, and deletes the hot journal without playing it back — leaving the database corrupted. This is not a transpilation artifact: a plain gcc build of the stock 3.53.3 amalgamation fails on the same bytes while 3.53.2 recovers them, and it is what has been making upstream's own `test/crash.test` fail intermittently, in roughly 2% of runs, on every platform. The patch restores the pre-3.53.3 behaviour of reporting a `(nul)` super-journal name and will be dropped once upstream ships its own fix. Every supported target carries it.
510
- Two targets change beyond that patch. On `linux/s390x` the regenerated transpile allocates C bit-fields MSB-first, as the big-endian platform ABI requires, rather than LSB-first; this comes from `modernc.org/cc/v4` v4.29.1 and touches bit-field accesses throughout the SQLite core, s390x being this module's only big-endian target. On `linux/riscv64` the transpile was regenerated on a host running GCC 11.4.0 where the previous one used GCC 13.3.0, which drops a handful of unexported compiler-predefined macro constants (the `__FLT16_*` family, `__DBL_IS_IEC_60559__` and friends) and changes the `COMPILER=gcc-13.3.0` entry `PRAGMA compile_options` reports to `COMPILER=gcc-11.4.0`; no SQLite code generation differs. Every other target's generated code is byte-identical to v1.55.0 apart from the journal-rollback patch above.

‎conn.go‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,28 @@ func newConn(dsn string) (*conn, error) {
127127
defer libc.Xfree(c.tls, zMain)
128128
c.inMemory = libc.GoString(sqlite3.Xsqlite3_db_filename(c.tls, c.db, zMain)) == ""
129129

130-
// Connection-level sqlite3_db_config options are applied before
131-
// applyQueryParams because the SQLite contract
132-
// requires sqlite3_db_config(SQLITE_DBCONFIG_DQS_*) to be set before
133-
// any statement is prepared on the connection. applyQueryParams runs
134-
// user-supplied PRAGMA statements, so it must come after.
130+
// _defensive is applied first so that everything the driver and the
131+
// caller run afterwards is already subject to the restriction: the
132+
// PRAGMAs applyQueryParams executes, the _pragma list, and every
133+
// statement prepared on the connection. Unlike the DBCONFIG_DQS_*
134+
// flags below this ordering is a choice rather than an API contract;
135+
// SQLITE_DBCONFIG_DEFENSIVE may be toggled at any point in a
136+
// connection's life.
135137
if err = applyDefensiveConfig(c, defensiveMode); err != nil {
136138
c.Close()
137139
return nil, err
138140
}
139141

142+
// _dqs is applied before applyQueryParams because the SQLite contract
143+
// requires sqlite3_db_config(SQLITE_DBCONFIG_DQS_*) to be set before
144+
// any statement is prepared on the connection. applyQueryParams runs
145+
// user-supplied PRAGMA statements, so it must come after.
140146
if err = applyDQSConfig(c, query); err != nil {
141147
c.Close()
142148
return nil, err
143149
}
144150

145-
if err = applyQueryParams(c, query); err != nil {
151+
if err = applyQueryParams(c, query, defensiveMode); err != nil {
146152
c.Close()
147153
return nil, err
148154
}

‎defensive_test.go‎

Lines changed: 223 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
package sqlite
5+
package sqlite // import "modernc.org/sqlite"
66

77
import (
88
"context"
@@ -166,7 +166,7 @@ func TestDefensiveModeAppliesToEveryPhysicalConnection(t *testing.T) {
166166
}
167167
}
168168

169-
func TestUnprotectedPoolIsANegativeControl(t *testing.T) {
169+
func TestDefensiveOffPoolIsANegativeControl(t *testing.T) {
170170
dbPath := filepath.Join(t.TempDir(), "pool-control.db")
171171
db, err := sql.Open("sqlite", dbPath+"?_defensive=0")
172172
if err != nil {
@@ -231,7 +231,7 @@ func TestDefensiveBooleanForms(t *testing.T) {
231231
}
232232
}
233233

234-
func TestUnmodifiedBehaviorIsNotAnADEDefensiveControl(t *testing.T) {
234+
func TestDefensiveAbsentOrFalseIsBaseline(t *testing.T) {
235235
for _, suffix := range []string{"", "?_defensive=0", "?_defensive=false", "?_defensive=FALSE", "?_defensive=f"} {
236236
t.Run(suffix, func(t *testing.T) {
237237
dbPath := filepath.Join(t.TempDir(), "negative-control.db")
@@ -257,3 +257,223 @@ func TestUnmodifiedBehaviorIsNotAnADEDefensiveControl(t *testing.T) {
257257
})
258258
}
259259
}
260+
261+
// TestDefensiveRejectsJournalModeOff covers the one shorthand DSN key
262+
// defensive mode silently neuters. SQLite turns PRAGMA journal_mode=OFF into
263+
// a no-op that still reports success, so accepting the combination would
264+
// honour neither parameter without saying so; applyQueryParams rejects it in
265+
// the validation phase, before any statement runs.
266+
func TestDefensiveRejectsJournalModeOff(t *testing.T) {
267+
for _, tc := range []struct {
268+
query string
269+
wantErr string
270+
}{
271+
{"?_defensive=1&_journal_mode=OFF", "cannot take effect under _defensive"},
272+
{"?_defensive=1&_journal_mode=off", "cannot take effect under _defensive"},
273+
{"?_defensive=1&_journal=OFF", "cannot take effect under _defensive"},
274+
{"?_defensive=true&_journal_mode=Off", "cannot take effect under _defensive"},
275+
// The combination is only rejected when defensive mode would
276+
// actually suppress the mode change.
277+
{"?_defensive=0&_journal_mode=OFF", ""},
278+
{"?_journal_mode=OFF", ""},
279+
{"?_defensive=1&_journal_mode=WAL", ""},
280+
} {
281+
t.Run(tc.query, func(t *testing.T) {
282+
dbPath := filepath.Join(t.TempDir(), "journal.db")
283+
db, err := sql.Open("sqlite", dbPath+tc.query)
284+
if err != nil {
285+
t.Fatal(err)
286+
}
287+
defer db.Close()
288+
err = db.Ping()
289+
if tc.wantErr == "" {
290+
if err != nil {
291+
t.Fatalf("Ping = %v, want success", err)
292+
}
293+
return
294+
}
295+
if err == nil || !strings.Contains(err.Error(), tc.wantErr) {
296+
t.Fatalf("Ping error = %v, want substring %q", err, tc.wantErr)
297+
}
298+
// The rejection belongs to the validation phase, so it must
299+
// not have run the PRAGMAs that precede it. journal_mode is
300+
// persistent, so a database converted here would outlive the
301+
// failed Open.
302+
var mode string
303+
check, err := sql.Open("sqlite", dbPath)
304+
if err != nil {
305+
t.Fatal(err)
306+
}
307+
defer check.Close()
308+
if err := check.QueryRow("PRAGMA journal_mode").Scan(&mode); err != nil {
309+
t.Fatal(err)
310+
}
311+
if strings.EqualFold(mode, "off") {
312+
t.Fatalf("rejected DSN still converted the database: journal_mode=%q", mode)
313+
}
314+
})
315+
}
316+
}
317+
318+
// TestDefensiveDSNForms pins the option to the DSN shapes newConn handles
319+
// differently. A file: DSN keeps its query string all the way into
320+
// sqlite3_open_v2, so SQLite parses _defensive too and must ignore it; any
321+
// other DSN has the query stripped before the open.
322+
func TestDefensiveDSNForms(t *testing.T) {
323+
for _, tc := range []struct{ name, dsn string }{
324+
{"path", filepath.Join(t.TempDir(), "path.db") + "?_defensive=1"},
325+
{"file_uri", "file:" + filepath.Join(t.TempDir(), "uri.db") + "?_defensive=1"},
326+
{"memory", ":memory:?_defensive=1"},
327+
{"file_memory", "file::memory:?cache=shared&mode=memory&_defensive=1"},
328+
} {
329+
t.Run(tc.name, func(t *testing.T) {
330+
db, err := sql.Open("sqlite", tc.dsn)
331+
if err != nil {
332+
t.Fatal(err)
333+
}
334+
defer db.Close()
335+
db.SetMaxOpenConns(1)
336+
if _, err := db.Exec("CREATE TABLE t(a)"); err != nil {
337+
t.Fatal(err)
338+
}
339+
var before, after int64
340+
if err := db.QueryRow("PRAGMA schema_version").Scan(&before); err != nil {
341+
t.Fatal(err)
342+
}
343+
if _, err := db.Exec(fmt.Sprintf("PRAGMA schema_version=%d", before+41)); err != nil {
344+
t.Fatal(err)
345+
}
346+
if err := db.QueryRow("PRAGMA schema_version").Scan(&after); err != nil {
347+
t.Fatal(err)
348+
}
349+
if after != before {
350+
t.Fatalf("defensive mode not applied for %q: before=%d after=%d", tc.dsn, before, after)
351+
}
352+
})
353+
}
354+
}
355+
356+
// TestDefensiveLeavesOrdinaryUseIntact is the other half of the contract: the
357+
// option restricts the operations documented on Driver.Open and nothing else.
358+
// It runs alongside every other DSN parameter that could plausibly collide
359+
// with it and exercises the features whose implementation touches the
360+
// machinery defensive mode guards.
361+
func TestDefensiveLeavesOrdinaryUseIntact(t *testing.T) {
362+
dbPath := filepath.Join(t.TempDir(), "workload.db")
363+
db, err := sql.Open("sqlite", dbPath+"?_defensive=1&_journal_mode=WAL&_auto_vacuum=FULL"+
364+
"&_foreign_keys=1&_busy_timeout=1000&_synchronous=NORMAL&_txlock=immediate&_dqs=0"+
365+
"&_pragma=cache_size(-2000)")
366+
if err != nil {
367+
t.Fatal(err)
368+
}
369+
defer db.Close()
370+
db.SetMaxOpenConns(1)
371+
372+
for _, q := range []struct{ pragma, want string }{
373+
{"journal_mode", "wal"},
374+
{"auto_vacuum", "1"},
375+
{"foreign_keys", "1"},
376+
{"busy_timeout", "1000"},
377+
{"synchronous", "1"},
378+
} {
379+
var got string
380+
if err := db.QueryRow("PRAGMA " + q.pragma).Scan(&got); err != nil {
381+
t.Fatalf("PRAGMA %s: %v", q.pragma, err)
382+
}
383+
if !strings.EqualFold(got, q.want) {
384+
t.Errorf("PRAGMA %s = %q, want %q", q.pragma, got, q.want)
385+
}
386+
}
387+
388+
// _dqs is applied after _defensive; it must still have taken effect.
389+
if _, err := db.Exec(`CREATE TABLE t(a TEXT)`); err != nil {
390+
t.Fatal(err)
391+
}
392+
if _, err := db.Exec(`INSERT INTO t VALUES("bare-string")`); err == nil {
393+
t.Error(`_dqs=0 did not take effect alongside _defensive=1`)
394+
}
395+
396+
if _, err := db.Exec(`
397+
CREATE TABLE parent(id INTEGER PRIMARY KEY);
398+
CREATE TABLE child(id INTEGER PRIMARY KEY, p INTEGER REFERENCES parent(id));
399+
INSERT INTO parent VALUES(1);
400+
`); err != nil {
401+
t.Fatal(err)
402+
}
403+
if _, err := db.Exec(`INSERT INTO child VALUES(1, 99)`); err == nil {
404+
t.Error("foreign key enforcement lost under defensive mode")
405+
}
406+
407+
// Ordinary use of a virtual table that owns shadow tables keeps working;
408+
// only direct writes to the shadow tables are refused.
409+
if _, err := db.Exec(`CREATE VIRTUAL TABLE ft USING fts5(body)`); err != nil {
410+
t.Fatalf("CREATE VIRTUAL TABLE fts5: %v", err)
411+
}
412+
if _, err := db.Exec(`INSERT INTO ft(body) VALUES('hello world')`); err != nil {
413+
t.Fatalf("fts5 INSERT: %v", err)
414+
}
415+
var n int
416+
if err := db.QueryRow(`SELECT count(*) FROM ft WHERE ft MATCH 'hello'`).Scan(&n); err != nil {
417+
t.Fatalf("fts5 MATCH: %v", err)
418+
}
419+
if n != 1 {
420+
t.Errorf("fts5 MATCH count = %d, want 1", n)
421+
}
422+
if _, err := db.Exec(`INSERT INTO ft_data(id, block) VALUES(999, x'00')`); err == nil {
423+
t.Error("direct fts5 shadow-table write succeeded under defensive mode")
424+
}
425+
if err := db.QueryRow(`SELECT count(*) FROM sqlite_dbpage`).Scan(&n); err != nil {
426+
t.Errorf("reading sqlite_dbpage: %v", err)
427+
}
428+
if _, err := db.Exec(`UPDATE sqlite_dbpage SET data=zeroblob(4096) WHERE pgno=1`); err == nil {
429+
t.Error("sqlite_dbpage write succeeded under defensive mode")
430+
}
431+
432+
if _, err := db.Exec(`VACUUM`); err != nil {
433+
t.Errorf("VACUUM under defensive mode: %v", err)
434+
}
435+
var integrity string
436+
if err := db.QueryRow(`PRAGMA integrity_check`).Scan(&integrity); err != nil {
437+
t.Fatal(err)
438+
}
439+
if integrity != "ok" {
440+
t.Errorf("integrity_check = %q, want ok", integrity)
441+
}
442+
}
443+
444+
// TestDefensiveIsPerConnection documents the scope of the option: it is a
445+
// property of the connection, not of the database file, so a second handle
446+
// opened without it is unrestricted. Driver.Open says so; this pins it.
447+
func TestDefensiveIsPerConnection(t *testing.T) {
448+
ctx := context.Background()
449+
dbPath := filepath.Join(t.TempDir(), "scope.db")
450+
451+
hard, err := sql.Open("sqlite", dbPath+"?_defensive=1")
452+
if err != nil {
453+
t.Fatal(err)
454+
}
455+
defer hard.Close()
456+
hard.SetMaxOpenConns(1)
457+
if _, err := hard.ExecContext(ctx, "CREATE TABLE protected(id INTEGER PRIMARY KEY)"); err != nil {
458+
t.Fatal(err)
459+
}
460+
if _, err := hard.ExecContext(ctx, "PRAGMA writable_schema=ON"); err != nil {
461+
t.Fatal(err)
462+
}
463+
if _, err := hard.ExecContext(ctx, "DELETE FROM sqlite_schema WHERE name='protected'"); err == nil {
464+
t.Fatal("defensive connection allowed a direct sqlite_schema write")
465+
}
466+
467+
soft, err := sql.Open("sqlite", dbPath)
468+
if err != nil {
469+
t.Fatal(err)
470+
}
471+
defer soft.Close()
472+
soft.SetMaxOpenConns(1)
473+
if _, err := soft.ExecContext(ctx, "PRAGMA writable_schema=ON"); err != nil {
474+
t.Fatal(err)
475+
}
476+
if _, err := soft.ExecContext(ctx, "DELETE FROM sqlite_schema WHERE name='protected'"); err != nil {
477+
t.Fatalf("a handle opened without _defensive should be unrestricted, got %v", err)
478+
}
479+
}

‎driver.go‎

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,39 @@ func newDriver() *Driver { return d }
163163
// https://www.sqlite.org/quirks.html#dblquote and
164164
// https://gitlab.com/cznic/sqlite/-/issues/61
165165
//
166-
// _defensive: Opt-in toggle for SQLite's defensive connection mode. Accepts
167-
// the values strconv.ParseBool understands. When true, the driver calls
168-
// sqlite3_db_config(SQLITE_DBCONFIG_DEFENSIVE) before any user-supplied PRAGMA
169-
// or statement is prepared. Duplicate or invalid values fail connection
170-
// creation. Absence or false preserves SQLite's default behavior. See:
171-
// https://www.sqlite.org/c3ref/c_dbconfig_defensive.html
166+
// _defensive: Opt-in toggle for SQLite's defensive connection mode, which
167+
// disables the SQL-level features that let ordinary statements deliberately
168+
// corrupt the database file. Accepts the values strconv.ParseBool understands
169+
// ("0"/"1", "false"/"true", "f"/"t", case-insensitive). When absent or set to
170+
// a false value SQLite's default is unchanged. When set to a true value the
171+
// driver calls sqlite3_db_config(SQLITE_DBCONFIG_DEFENSIVE) immediately after
172+
// sqlite3_open_v2 and before any other parameter is applied, so the PRAGMAs
173+
// this driver runs, the _pragma list, and every statement the caller prepares
174+
// are all subject to it. The parameter is parsed before sqlite3_open_v2, so an
175+
// invalid value fails the connection without creating the database file, and
176+
// it must appear at most once: a repeated _defensive is an error rather than
177+
// letting the first value silently win.
178+
//
179+
// On such a connection PRAGMA writable_schema=ON, PRAGMA journal_mode=OFF and
180+
// PRAGMA schema_version=N become silent no-ops, and writes to a virtual
181+
// table's shadow tables (fts5's _data, _idx and so on) and to sqlite_dbpage
182+
// fail with "table ... may not be modified". Reading those tables, ordinary
183+
// use of the virtual tables that own them, and VACUUM are unaffected.
184+
//
185+
// Because journal_mode=OFF is one of the operations defensive mode suppresses,
186+
// a true _defensive combined with _journal_mode=OFF (or _journal=OFF) is
187+
// rejected rather than silently honouring neither. The unvalidated _pragma
188+
// list is the exception, as always: _pragma=journal_mode(OFF) alongside
189+
// _defensive=1 runs and is silently ignored by SQLite.
190+
//
191+
// Defensive mode is a hardening measure, not a sandbox for hostile database
192+
// files. It is one of several steps SQLite recommends for that purpose (see
193+
// https://www.sqlite.org/security.html); this build compiles with neither
194+
// SQLITE_TRUSTED_SCHEMA=0 nor SQLITE_DQS=0 and the driver exposes no
195+
// authorizer, so _defensive=1 alone does not make opening an untrusted file
196+
// safe. It is also a property of the connection, not of the database: another
197+
// connection to the same file, opened without the parameter, is unrestricted.
198+
// See: https://www.sqlite.org/c3ref/c_dbconfig_defensive.html
172199
//
173200
// _error_rc: Opt-in error-string reporting mode for synthesised errors.
174201
// Accepts the values strconv.ParseBool understands ("0"/"1",

0 commit comments

Comments
 (0)
⌂ 换网址