Skip to main content

cartel_sqlite/runtime/
mod.rs

1use dope_core::driver::schedule::clock::timer;
2use o3::alloc;
3use std::mem;
4
5pub(crate) mod heap;
6mod layout;
7pub mod local;
8pub mod raw;
9pub(crate) mod slot;
10
11pub use layout::Layout;
12
13/// Proof that process-wide SQLite configuration is installed.
14#[derive(Clone, Copy, PartialEq, Eq)]
15pub struct Runtime(());
16
17impl Runtime {
18    /// Installs private native caches with a 20-page initial batch before workers start.
19    /// Requires writable static data and no statement logging or statement virtual table.
20    /// Build with `LIBSQLITE3_FLAGS=-USQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS`.
21    pub fn install(permit: raw::Permit) -> Result<Self, Error> {
22        let raw::Permit(()) = permit.initialize()?;
23        Ok(Self(()))
24    }
25}
26
27#[derive(Clone, Copy, Debug, PartialEq, Eq)]
28pub enum Error {
29    /// The native build shares page-cache allocations between connection arenas.
30    GlobalCache,
31    /// The native build retains unused global page-cache allocation statistics.
32    CacheStats,
33    /// The native statement virtual table measures memory after execution.
34    StatementVtab,
35    /// The native build emulates writable static data with fallible initialization.
36    WritableStatic,
37    /// The native SQL log can expand borrowed bindings during statement cleanup.
38    StatementLog,
39    Threading(crate::Code),
40    Initialization(crate::Code),
41    VfsMissing,
42    VfsOpen,
43    VfsFileSize {
44        actual: std::ffi::c_int,
45    },
46    VfsRegistration(crate::Code),
47    SqliteBytes,
48    SqliteCapacity,
49    /// Usable heap bytes exceed SQLite's signed statement memory counter.
50    SqliteMemory {
51        actual: usize,
52    },
53    StatementSqlBytes {
54        actual: usize,
55    },
56    CapacityOverflow,
57    Allocation(alloc::Error),
58    Layout,
59    TimerCapacity(timer::Exhausted),
60}
61
62const _: () = assert!(mem::size_of::<Runtime>() == 0);