From 6d7dc6d183badc8aaf9c00cfacd14ab031b0c8e6 Mon Sep 17 00:00:00 2001 From: Avinash Sajjanshetty Date: Thu, 2 Oct 2025 16:01:56 +0530 Subject: [PATCH 1/2] enable checksums only if its opted in via feature flag --- core/storage/database.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/storage/database.rs b/core/storage/database.rs index c44aed214..79b7d0a7a 100644 --- a/core/storage/database.rs +++ b/core/storage/database.rs @@ -48,8 +48,12 @@ impl IOContext { impl Default for IOContext { fn default() -> Self { + #[cfg(feature = "checksum")] + let encryption_or_checksum = EncryptionOrChecksum::Checksum(ChecksumContext::default()); + #[cfg(not(feature = "checksum"))] + let encryption_or_checksum = EncryptionOrChecksum::None; Self { - encryption_or_checksum: EncryptionOrChecksum::Checksum(ChecksumContext::default()), + encryption_or_checksum, } } } From 09ba4615ba29e5da7d80cb1b0396833b7b541bf1 Mon Sep 17 00:00:00 2001 From: Avinash Sajjanshetty Date: Thu, 2 Oct 2025 16:11:18 +0530 Subject: [PATCH 2/2] return appropriate error if checksum was not compiled --- core/error.rs | 2 ++ core/storage/checksum.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/error.rs b/core/error.rs index 23ce9fe9b..87c686932 100644 --- a/core/error.rs +++ b/core/error.rs @@ -132,6 +132,8 @@ pub enum CompletionError { expected: u64, actual: u64, }, + #[error("tursodb not compiled with checksum feature")] + ChecksumNotEnabled, } #[macro_export] diff --git a/core/storage/checksum.rs b/core/storage/checksum.rs index e7ba78975..a67376048 100644 --- a/core/storage/checksum.rs +++ b/core/storage/checksum.rs @@ -15,7 +15,11 @@ impl ChecksumContext { #[cfg(not(feature = "checksum"))] pub fn add_checksum_to_page(&self, _page: &mut [u8], _page_id: usize) -> Result<()> { - Ok(()) + use crate::LimboError; + Err(LimboError::InternalError( + "tursodb must be recompiled with checksum feature in order to use checksums" + .to_string(), + )) } #[cfg(not(feature = "checksum"))] @@ -24,7 +28,7 @@ impl ChecksumContext { _page: &mut [u8], _page_id: usize, ) -> std::result::Result<(), CompletionError> { - Ok(()) + Err(CompletionError::ChecksumNotEnabled) } #[cfg(feature = "checksum")]