diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs index 4f8241351..89ce26603 100644 --- a/bindings/python/src/lib.rs +++ b/bindings/python/src/lib.rs @@ -4,6 +4,7 @@ use limbo_core::IO; use pyo3::prelude::*; use pyo3::types::PyList; use pyo3::types::PyTuple; +use std::rc::Rc; use std::sync::{Arc, Mutex}; mod errors; @@ -198,7 +199,7 @@ fn stmt_is_dml(sql: &str) -> bool { #[pyclass] #[derive(Clone)] pub struct Connection { - conn: Arc>, + conn: Arc>>, io: Arc, } @@ -238,7 +239,7 @@ pub fn connect(path: &str) -> Result { })?); let db = limbo_core::Database::open_file(io.clone(), path) .map_err(|e| PyErr::new::(format!("Failed to open database: {:?}", e)))?; - let conn: limbo_core::Connection = db.connect(); + let conn: Rc = db.connect(); Ok(Connection { conn: Arc::new(Mutex::new(conn)), io, diff --git a/bindings/wasm/lib.rs b/bindings/wasm/lib.rs index 6527a0da3..16adb5215 100644 --- a/bindings/wasm/lib.rs +++ b/bindings/wasm/lib.rs @@ -1,11 +1,12 @@ -use limbo_core::{OpenFlags, Result, IO}; +use limbo_core::{OpenFlags, Page, Result, IO}; +use std::cell::RefCell; use std::rc::Rc; use std::sync::Arc; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct Database { - _inner: limbo_core::Database, + _inner: Rc, } #[allow(clippy::arc_with_non_send_sync)] @@ -16,7 +17,7 @@ impl Database { let io = Arc::new(PlatformIO { vfs: VFS::new() }); let file = io.open_file(path, limbo_core::OpenFlags::None).unwrap(); let page_io = Rc::new(DatabaseStorage::new(file)); - let wal = Rc::new(Wal {}); + let wal = Rc::new(RefCell::new(Wal {})); let inner = limbo_core::Database::open(io, page_io, wal).unwrap(); Database { _inner: inner } } @@ -78,7 +79,7 @@ pub struct PlatformIO { } impl limbo_core::IO for PlatformIO { - fn open_file(&self, path: &str, flags: OpenFlags) -> Result> { + fn open_file(&self, path: &str, _flags: OpenFlags) -> Result> { let fd = self.vfs.open(path); Ok(Rc::new(File { vfs: VFS::new(), @@ -179,9 +180,10 @@ impl limbo_core::Wal for Wal { } fn append_frame( - &self, - _page: Rc>, + &mut self, + _page: Rc>, _db_size: u32, + _pager: &limbo_core::Pager, ) -> Result<()> { todo!() } @@ -190,10 +192,18 @@ impl limbo_core::Wal for Wal { &self, _frame_id: u64, _page: Rc>, - _buffer_pool: Rc, + _buffer_pool: Rc, ) -> Result<()> { todo!() } + + fn should_checkpoint(&self) -> bool { + todo!() + } + + fn checkpoint(&mut self, _pager: &limbo_core::Pager) -> Result { + todo!() + } } #[wasm_bindgen(module = "/vfs.js")] diff --git a/core/lib.rs b/core/lib.rs index c4a332a6d..f7c09983e 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -24,7 +24,6 @@ use std::sync::{Arc, OnceLock}; use std::{cell::RefCell, rc::Rc}; #[cfg(feature = "fs")] use storage::database::FileStorage; -use storage::pager::Pager; use storage::sqlite3_ondisk::DatabaseHeader; #[cfg(feature = "fs")] use storage::wal::WalFile; @@ -39,8 +38,11 @@ pub use io::OpenFlags; #[cfg(feature = "fs")] pub use io::PlatformIO; pub use io::{Buffer, Completion, File, WriteCompletion, IO}; +pub use storage::buffer_pool::BufferPool; pub use storage::database::DatabaseStorage; pub use storage::pager::Page; +pub use storage::pager::Pager; +pub use storage::wal::CheckpointStatus; pub use storage::wal::Wal; pub use types::Value; diff --git a/simulator/main.rs b/simulator/main.rs index d9ebe320e..519e4c2f7 100644 --- a/simulator/main.rs +++ b/simulator/main.rs @@ -1,4 +1,4 @@ -use limbo_core::{Database, File, PlatformIO, Result, IO}; +use limbo_core::{Database, File, OpenFlags, PlatformIO, Result, IO}; use rand::prelude::*; use rand_chacha::ChaCha8Rng; use std::cell::RefCell; @@ -92,7 +92,7 @@ impl SimulatorIO { impl IO for SimulatorIO { fn open_file(&self, path: &str, flags: OpenFlags) -> Result> { - let inner = self.inner.open_file(path)?; + let inner = self.inner.open_file(path, flags)?; let file = Rc::new(SimulatorFile { inner, fault: RefCell::new(false),