fix: Change SQLITE_THREADSAFE=0 to THREADSAFE=2

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 <noreply@anthropic.com>
This commit is contained in:
reugenio 2025-12-14 19:38:45 +01:00
parent e7805d9db9
commit 04c5d41956
4 changed files with 5 additions and 5 deletions

View file

@ -59,7 +59,7 @@ src/
## SQLite Flags ## SQLite Flags
``` ```
-DSQLITE_THREADSAFE=0 # Single-threaded -DSQLITE_THREADSAFE=2 # Multi-thread (required for ConnectionPool)
-DSQLITE_ENABLE_FTS5 # Full-text search -DSQLITE_ENABLE_FTS5 # Full-text search
-DSQLITE_ENABLE_JSON1 # JSON functions -DSQLITE_ENABLE_JSON1 # JSON functions
-DSQLITE_ENABLE_RTREE # R-Tree spatial -DSQLITE_ENABLE_RTREE # R-Tree spatial

View file

@ -330,7 +330,7 @@ El build incluye los siguientes flags optimizados:
``` ```
-DSQLITE_DQS=0 # Disable double-quoted strings -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_FTS5 # Full-text search v5
-DSQLITE_ENABLE_JSON1 # JSON functions -DSQLITE_ENABLE_JSON1 # JSON functions
-DSQLITE_ENABLE_RTREE # R-Tree spatial index -DSQLITE_ENABLE_RTREE # R-Tree spatial index

View file

@ -7,7 +7,7 @@ pub fn build(b: *std.Build) void {
// SQLite compile flags for optimal embedded use // SQLite compile flags for optimal embedded use
const sqlite_flags: []const []const u8 = &.{ const sqlite_flags: []const []const u8 = &.{
"-DSQLITE_DQS=0", // Disable double-quoted strings as identifiers "-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_MEMSTATUS=0", // Disable memory usage tracking
"-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", // Normal WAL sync "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", // Normal WAL sync
"-DSQLITE_LIKE_DOESNT_MATCH_BLOBS", // LIKE doesn't match BLOBs "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS", // LIKE doesn't match BLOBs

View file

@ -277,7 +277,7 @@ zcatsql_mod.addCSourceFile(.{
// Flags de optimizacion // Flags de optimizacion
const sqlite_flags: []const []const u8 = &.{ const sqlite_flags: []const []const u8 = &.{
"-DSQLITE_DQS=0", "-DSQLITE_DQS=0",
"-DSQLITE_THREADSAFE=0", "-DSQLITE_THREADSAFE=2",
"-DSQLITE_DEFAULT_MEMSTATUS=0", "-DSQLITE_DEFAULT_MEMSTATUS=0",
// ... // ...
}; };
@ -288,7 +288,7 @@ const sqlite_flags: []const []const u8 = &.{
| Flag | Proposito | | Flag | Proposito |
|------|-----------| |------|-----------|
| `SQLITE_DQS=0` | Deshabilita double-quoted strings como identificadores | | `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_DEFAULT_MEMSTATUS=0` | Sin tracking de memoria |
| `SQLITE_ENABLE_FTS5` | Full-text search habilitado | | `SQLITE_ENABLE_FTS5` | Full-text search habilitado |
| `SQLITE_ENABLE_JSON1` | Funciones JSON habilitadas | | `SQLITE_ENABLE_JSON1` | Funciones JSON habilitadas |