Merge 'Enable checksums only if its opted in via feature flag' from Avinash Sajjanshetty

Reviewed-by: Nikita Sivukhin (@sivukhin)
Reviewed-by: bit-aloo (@Shourya742)

Closes #3523
This commit is contained in:
Pekka Enberg
2025-10-02 17:26:14 +03:00
committed by GitHub
3 changed files with 13 additions and 3 deletions

View File

@@ -132,6 +132,8 @@ pub enum CompletionError {
expected: u64,
actual: u64,
},
#[error("tursodb not compiled with checksum feature")]
ChecksumNotEnabled,
}
#[macro_export]

View File

@@ -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")]

View File

@@ -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,
}
}
}