Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Douglas Creager <dcreager@dcreager.net>
Hendrik van Antwerpen <hendrikvanantwerpen@github.com>
Akshay <nerdy@peppe.rs>
blusk <bluskript@gmail.com>
William Manley <will@stb-tester.com>
18 changes: 17 additions & 1 deletion stack-graphs/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const SCHEMA: &str = r#"
) STRICT;
"#;

const INDEXES: &str = r#"
CREATE INDEX IF NOT EXISTS idx_graphs_file ON graphs(file);
CREATE INDEX IF NOT EXISTS idx_file_paths_local_id ON file_paths(file, local_id);
CREATE INDEX IF NOT EXISTS idx_root_paths_symbol_stack ON root_paths(symbol_stack);
"#;

const PRAGMAS: &str = r#"
PRAGMA journal_mode = WAL;
PRAGMA foreign_keys = false;
Expand Down Expand Up @@ -147,6 +153,7 @@ impl SQLiteWriter {
pub fn open_in_memory() -> Result<Self> {
let mut conn = Connection::open_in_memory()?;
Self::init(&mut conn)?;
init_indexes(&mut conn)?;
Ok(Self { conn })
}

Expand All @@ -161,6 +168,7 @@ impl SQLiteWriter {
} else {
check_version(&conn)?;
}
init_indexes(&mut conn)?;
Ok(Self { conn })
}

Expand Down Expand Up @@ -432,9 +440,10 @@ impl SQLiteReader {
path.as_ref().to_string_lossy().to_string(),
));
}
let conn = Connection::open(path)?;
let mut conn = Connection::open(path)?;
set_pragmas_and_functions(&conn)?;
check_version(&conn)?;
init_indexes(&mut conn)?;
Ok(Self {
conn,
loaded_graphs: HashSet::new(),
Expand Down Expand Up @@ -781,6 +790,13 @@ fn set_pragmas_and_functions(conn: &Connection) -> Result<()> {
Ok(())
}

fn init_indexes(conn: &mut Connection) -> Result<()> {
let tx = conn.transaction()?;
tx.execute_batch(INDEXES)?;
tx.commit()?;
Ok(())
}

fn status_for_file<T: AsRef<str>>(
conn: &Connection,
file: &str,
Expand Down