Merge upstream SQLite 3.46.1
This merges the version-3.46.1 tag (f3d536d378 "Version 3.46.1") of
upstream SQLite into libSQL. Conflicts were resolved with rename-following
(libsql vendors SQLite under libsql-sqlite3/, while upstream paths are at
the root).
== Path moves ==
* ext/intck/ — new upstream tree. After the merge tool placed the 9 files
at top-level ext/intck/, they were moved under libsql-sqlite3/ext/intck/
where libsql-sqlite3/Makefile.in already expects them (lines 472-473,
1269-1270).
== Resolved conflicts ==
src/pragma.c — integrity check
Upstream restructured how "wrong # of entries in index" is verified: the
per-table count loop at the end of integrity_check was replaced with a
single pre-pass using b-tree counts from OP_IntegrityCk. Took upstream's
refactored form and added an IsVectorIndex(pIdx) skip in the new
relocated loop, while keeping cnt++ unconditional so register indexing
into aRoot stays aligned. The existing per-row IsVectorIndex skip was
unaffected (both sides agreed there).
src/where.c
(1) Vector-index planner clash: kept libsql's
`if (pProbe->idxIsVector) opMask = 0;`
alongside upstream's refined
`if (pProbe->bLowQual && pSrc->fg.isIndexedBy==0)` (cherry-pick
626d619218 — low-quality indexes still considered when selected via
INDEXED BY).
(2) Took upstream's `wctrlFlags |= WHERE_KEEP_ALL_JOINS;` (cherry-pick
2fdb32316d — disables omit-noop-join when ORDER BY has 64+ terms).
The flag definition and consumer were already merged in
sqliteInt.h:3437 and where.c:6587.
src/shell.c.in
Pure adjacency. Kept libsql's `.init_wasm_func_table` command (under
LIBSQL_ENABLE_WASM_RUNTIME) alongside upstream's new `.intck` command,
in help text and in the command dispatch.
ext/wasm/GNUmakefile
Three independent edits coexisting:
* libsql's `-DSQLITE_OMIT_SHARED_MEM` (replacing upstream's OMIT_WAL,
from dfa4ce43c0 "ext/wasm: allow WAL mode")
* libsql's `-lm` (from 9280b8ee82 "link math lib" — needed for vector
search)
* upstream's new `C-PP.FILTER.global` / `SQLITE_C_IS_SEE` SEE filter
hook
These flags only affect the c-pp.c preprocessor binary, not the WASM
output (see the comment block above the rule), but preserving libsql's
intentional swap keeps the build self-consistent with sqliteInt.h:55-56
where SQLITE_OMIT_SHARED_MEM is defined.
tool/mksqlite3c.tcl
Kept libsql's `wasmedge_bindings.c` in the amalgamation source list.
ext/fts3/fts3.c, ext/fts3/fts3_write.c, ext/fts5/fts5_main.c,
ext/fts5/fts5_tokenize.c, ext/fts5/test/fts5integrity.test
All taken from upstream verbatim. These conflicts were an artifact of
the merge base being 3.45.0 while libsql HEAD already contained 3.45.1
content (from prior merges 9ed72eb5ae / f996bf9f18). For four of the
five files libsql had zero local changes. The fifth — fts5_tokenize.c —
had a libsql-local trigram-tokenizer crash fix (3e56d28d86, Aug 2024)
that is now superseded by upstream's a751fddd01 (cherry-picked into
3.46.1), which handles OOM-vs-syntax-error ordering more carefully.
autoconf/tea/configure.ac, configure, doc/testrunner.md,
test/mmapcorrupt.test, test/permutations.test
Mechanical — took upstream (version string bumps, doc updates,
ifcapable !mmap guard, test path globs for ext/rbu/ and ext/intck/).
== libsql-ffi bundle sync ==
* libsql-ffi/bundled/SQLite3MultipleCiphers/src/{fileio.c,series.c}
were updated to match upstream 3.46.1 byte-for-byte. The SQLite3
MultipleCiphers tree is independently vendored from sqlite3mc 1.8.1
and these two files are out-of-band synced to keep the cipher bundle
aligned with libsql's vendored SQLite. Note: the bundle's own
sqlite3.h still reports 3.45.1 — only sqlite3.c is overlaid at build
time from libsql-sqlite3 (build.rs:466-471). sqlar.c has a small
3.45.1→3.46.1 type-safety drift that was not mirrored.
* libsql-ffi/bundled/src/{sqlite3.c,sqlite3.h} and
libsql-ffi/bundled/bindings/session_bindgen.rs were regenerated via
`LIBSQL_DEV=1 cargo build --features multiple-ciphers,session`.
The new amalgamation reports SQLITE_VERSION "3.46.1" with
SQLITE_SOURCE_ID ending in "alt1" (libsql modification marker). P
Pekka Enberg committed
02c7bd6810f3705d7fc1213d44acf5cc023f580c