INNER CODE UNIT · Rust

init_db

aannoo/hcom · src/db/mod.rs:283

    pub fn init_db(&self) -> Result<()> {
        // Skip if already at current version (avoids DROP VIEW race with concurrent readers)
        let current: i32 = self
            .conn
            .query_row("PRAGMA user_version", [], |row| row.get(0))?;
        if current == SCHEMA_VERSION {
            return Ok(());
        }

        let tx = Transaction::new_unchecked(&self.conn, TransactionBehavior::Immediate)?;
        // A concurrent initializer may have finished while we acquired the
        // write lock. Avoid rebuilding its view after it published the schema.
        let current: i32 = tx.query_row("PRAGMA user_version", [], |row| row.get(0))?;
        if current == SCHEMA_VERSION {
            return Ok(());
        }

        tx.execute_batch(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…