From 2bc579c1ef5a5291ae93fbf8aec3bc26584feaa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Tro=C3=9Fbach?= Date: Tue, 15 Sep 2026 08:02:16 +0200 Subject: [PATCH 1/2] Keep temporary data in memory unless SQLITE_TEMP_STORE is set Temporary files are not encrypted (see #148), so the documentation recommends SQLITE_TEMP_STORE=2 or 3. The build files set it to 2, but the source didn't, so builds of the amalgamation with other build scripts got SQLite's default 1, which writes temporary data to disk in plaintext. Define SQLITE_TEMP_STORE as 2 before including SQLite if it is not set. An explicit value is kept, and PRAGMA temp_store works as before. --- src/sqlite3mc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sqlite3mc.c b/src/sqlite3mc.c index 43d5a5d3..2f8eff70 100644 --- a/src/sqlite3mc.c +++ b/src/sqlite3mc.c @@ -133,6 +133,13 @@ SQLITE_API char *sqlite3_win32_utf8_to_mbcs_v2(const char*, int); SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*); #endif +/* +** Keep temporary data in memory by default, because temporary files are not encrypted +*/ +#ifndef SQLITE_TEMP_STORE +#define SQLITE_TEMP_STORE 2 +#endif + /* ** Include SQLite3 amalgamation */ From c5c18666cedda610b1592037b98081cfb1f2af37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Tro=C3=9Fbach?= Date: Tue, 15 Sep 2026 10:02:47 +0200 Subject: [PATCH 2/2] Move the SQLITE_TEMP_STORE default to the top of sqlite3mc.c Settings that deviate from SQLite's defaults should be easy to find, so the block now follows the file header. The comment also explains the possible values. --- src/sqlite3mc.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/sqlite3mc.c b/src/sqlite3mc.c index 2f8eff70..decc3e19 100644 --- a/src/sqlite3mc.c +++ b/src/sqlite3mc.c @@ -7,6 +7,21 @@ ** License: MIT */ +/* +** Keep temporary data in memory by default +** +** Temporary files (for example temporary tables, sort data and transient +** databases) are not encrypted. The default applies only if SQLITE_TEMP_STORE +** is not defined. Possible values: +** 0 = always use temporary files +** 1 = use temporary files, unless PRAGMA temp_store=MEMORY (SQLite's default) +** 2 = use memory, unless PRAGMA temp_store=FILE +** 3 = always use memory +*/ +#ifndef SQLITE_TEMP_STORE +#define SQLITE_TEMP_STORE 2 +#endif + /* ** If SQLite functions should be called through a dispatch table, ** thus hiding all SQLite function symbols from the linker, @@ -133,13 +148,6 @@ SQLITE_API char *sqlite3_win32_utf8_to_mbcs_v2(const char*, int); SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*); #endif -/* -** Keep temporary data in memory by default, because temporary files are not encrypted -*/ -#ifndef SQLITE_TEMP_STORE -#define SQLITE_TEMP_STORE 2 -#endif - /* ** Include SQLite3 amalgamation */