SIGN IN SIGN UP

Merge upstream SQLite 3.46.1 (#2238)

Updates libSQL's vendored SQLite from 3.45.1 → 3.46.1 (upstream tag
version-3.46.1, f3d536d378).

Despite libSQL claiming to be 3.46.1 in the version strings, it was
based on upstream version 3.45.1 (9ed72eb5ae).

What's in here:

- libsql-sqlite3/ — the vendored SQLite source tree merged up to 3.46.1,
with libSQL's modifications preserved (vector indexes, extra pragmas,
WASM tweaks, etc.).
- libsql-ffi/bundled/ — regenerated amalgamation (sqlite3.c/sqlite3.h
now report SQLITE_VERSION "3.46.1" with the …alt1 libSQL source-id
marker) and session_bindgen.rs, via LIBSQL_DEV=1 cargo build --features
multiple-ciphers,session. The SQLite3MultipleCiphers fileio.c/series.c
were out-of-band synced to match 3.46.1.
- Tooling — scripts/sqlite-diff (diffs only upstream's src/ artifacts
between two trees) and scripts/update-sqlite-bundle.sh, so future bumps
are reproducible.
- ext/intck/ is new from upstream and was relocated under
libsql-sqlite3/ where Makefile.in already expects it.

Conflicts resolved:

- src/pragma.c (integrity_check) — upstream replaced the per-table count
loop with a single pre-pass using b-tree counts from OP_IntegrityCk.
Took upstream's refactored form and re-added the IsVectorIndex(pIdx)
skip in the relocated loop, keeping cnt++ unconditional so aRoot
register indexing stays aligned. The existing per-row vector-index skip
was untouched.
- src/where.c — kept libSQL's if (pProbe->idxIsVector) opMask = 0;
alongside upstream's refined bLowQual && pSrc->fg.isIndexedBy==0
(cherry-pick 626d619218); took upstream's WHERE_KEEP_ALL_JOINS
(cherry-pick 2fdb32316d).
- src/shell.c.in — libSQL's .init_wasm_func_table and upstream's new
.intck command coexist.
- ext/wasm/GNUmakefile — preserved libSQL's -DSQLITE_OMIT_SHARED_MEM and
-lm next to upstream's new SEE filter hook (c-pp preprocessor only; no
effect on WASM output).
- tool/mksqlite3c.tcl — kept wasmedge_bindings.c in the amalgamation
source list.
- FTS3/FTS5 + mechanical files — taken from upstream; these were
merge-base artifacts (base 3.45.0 vs HEAD already at 3.45.1). libSQL's
local trigram-tokenizer crash fix (3e56d28d86) is now superseded by
upstream's a751fddd01.

How this was verified:

The `libsql-sqlite3/src` tree was diffed against both clean upstream
bases using scripts/sqlite-diff and compared the two patches — they
should differ only in context lines and hunk offsets (upstream code that
changed between releases), never in libSQL's actual +/- content.

```
scripts/sqlite-diff <clean-3.45.1> libsql-sqlite3 > libsql-sqlite3-3.45.1.patch
scripts/sqlite-diff <clean-3.46.1> libsql-sqlite3 > libsql-sqlite3-3.46.1.patch
```

The diffs are the same except for a single divergence is the `PRAGMA
integrity_check vector-index` guard, which is the same libSQL change in
two shapes because upstream refactored that loop between releases:

- vs 3.45.1: if( IsVectorIndex(pIdx) ) continue;
- vs 3.46.1: folded into upstream's new check → if(
pIdx->pPartIdxWhere==0 && !IsVectorIndex(pIdx) ){

Both skip vector indexes during integrity check — identical semantics.
Ground truth confirms the tree is correctly ported (src/pragma.c:1804).

Test plan:

* SQLite TCL test suite
P
Pekka Enberg committed
7251ec0e2dea5f878f5c8d3a00b1d21197d8cc31
Committed by GitHub <noreply@github.com> on 5/27/2026, 6:12:38 AM