From 04c5d4195605f6fc3e3a2727684ccf846ba06841 Mon Sep 17 00:00:00 2001 From: reugenio Date: Sun, 14 Dec 2025 19:38:45 +0100 Subject: [PATCH] fix: Change SQLITE_THREADSAFE=0 to THREADSAFE=2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL FIX: SQLite was compiled single-threaded but the library provides a ConnectionPool which implies multi-threaded usage. THREADSAFE=2 (multi-thread mode) allows different connections to be used from different threads, which is exactly what ConnectionPool needs. Updated: build.zig, README.md, CLAUDE.md, docs/ARCHITECTURE.md Reported by: Gemini audit (2025-12-14) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 2 +- README.md | 2 +- build.zig | 2 +- docs/ARCHITECTURE.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 54d553d..d4f972f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -59,7 +59,7 @@ src/ ## SQLite Flags ``` --DSQLITE_THREADSAFE=0 # Single-threaded +-DSQLITE_THREADSAFE=2 # Multi-thread (required for ConnectionPool) -DSQLITE_ENABLE_FTS5 # Full-text search -DSQLITE_ENABLE_JSON1 # JSON functions -DSQLITE_ENABLE_RTREE # R-Tree spatial diff --git a/README.md b/README.md index 66d0200..28ebcd9 100644 --- a/README.md +++ b/README.md @@ -330,7 +330,7 @@ El build incluye los siguientes flags optimizados: ``` -DSQLITE_DQS=0 # Disable double-quoted strings --DSQLITE_THREADSAFE=0 # Single-threaded (más rápido) +-DSQLITE_THREADSAFE=2 # Multi-thread (required for ConnectionPool) (más rápido) -DSQLITE_ENABLE_FTS5 # Full-text search v5 -DSQLITE_ENABLE_JSON1 # JSON functions -DSQLITE_ENABLE_RTREE # R-Tree spatial index diff --git a/build.zig b/build.zig index d05a973..2c6ce9e 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void { // SQLite compile flags for optimal embedded use const sqlite_flags: []const []const u8 = &.{ "-DSQLITE_DQS=0", // Disable double-quoted strings as identifiers - "-DSQLITE_THREADSAFE=0", // Single-threaded for speed + "-DSQLITE_THREADSAFE=2", // Multi-thread: different connections can be used from different threads (required for ConnectionPool) "-DSQLITE_DEFAULT_MEMSTATUS=0", // Disable memory usage tracking "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", // Normal WAL sync "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS", // LIKE doesn't match BLOBs diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index f2ee4b9..22b640b 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -277,7 +277,7 @@ zcatsql_mod.addCSourceFile(.{ // Flags de optimizacion const sqlite_flags: []const []const u8 = &.{ "-DSQLITE_DQS=0", - "-DSQLITE_THREADSAFE=0", + "-DSQLITE_THREADSAFE=2", "-DSQLITE_DEFAULT_MEMSTATUS=0", // ... }; @@ -288,7 +288,7 @@ const sqlite_flags: []const []const u8 = &.{ | Flag | Proposito | |------|-----------| | `SQLITE_DQS=0` | Deshabilita double-quoted strings como identificadores | -| `SQLITE_THREADSAFE=0` | Single-threaded (mas rapido) | +| `SQLITE_THREADSAFE=2` | Multi-thread (ConnectionPool) | | `SQLITE_DEFAULT_MEMSTATUS=0` | Sin tracking de memoria | | `SQLITE_ENABLE_FTS5` | Full-text search habilitado | | `SQLITE_ENABLE_JSON1` | Funciones JSON habilitadas |