|
|
|
@ -17,24 +17,24 @@ let database_filename = "results.db"
|
|
|
|
|
|
|
|
|
|
let database_fullpath = Config.results_dir ^/ database_filename
|
|
|
|
|
|
|
|
|
|
let create_attributes_table db =
|
|
|
|
|
let create_procedures_table db =
|
|
|
|
|
(* it would be nice to use "WITHOUT ROWID" here but ancient versions of sqlite do not support
|
|
|
|
|
it *)
|
|
|
|
|
SqliteUtils.exec db ~log:"creating attributes table"
|
|
|
|
|
SqliteUtils.exec db ~log:"creating procedures table"
|
|
|
|
|
~stmt:
|
|
|
|
|
{|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS attributes
|
|
|
|
|
CREATE TABLE IF NOT EXISTS procedures
|
|
|
|
|
( proc_name TEXT PRIMARY KEY
|
|
|
|
|
, attr_kind INTEGER NOT NULL
|
|
|
|
|
, source_file TEXT NOT NULL
|
|
|
|
|
, proc_attributes BLOB NOT NULL )|}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let create_cfg_table db =
|
|
|
|
|
SqliteUtils.exec db ~log:"creating cfg table"
|
|
|
|
|
let create_source_files_table db =
|
|
|
|
|
SqliteUtils.exec db ~log:"creating source_files table"
|
|
|
|
|
~stmt:
|
|
|
|
|
{|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS cfg
|
|
|
|
|
CREATE TABLE IF NOT EXISTS source_files
|
|
|
|
|
( source_file TEXT PRIMARY KEY
|
|
|
|
|
, cfgs BLOB NOT NULL )|}
|
|
|
|
|
|
|
|
|
@ -42,8 +42,8 @@ CREATE TABLE IF NOT EXISTS cfg
|
|
|
|
|
let create_db () =
|
|
|
|
|
let temp_db = Filename.temp_file ~in_dir:Config.results_dir database_filename ".tmp" in
|
|
|
|
|
let db = Sqlite3.db_open ~mutex:`FULL temp_db in
|
|
|
|
|
create_attributes_table db ;
|
|
|
|
|
create_cfg_table db ;
|
|
|
|
|
create_procedures_table db ;
|
|
|
|
|
create_source_files_table db ;
|
|
|
|
|
(* This should be the default but better be sure, otherwise we cannot access the database concurrently. This has to happen before setting WAL mode. *)
|
|
|
|
|
SqliteUtils.exec db ~log:"locking mode=NORMAL" ~stmt:"PRAGMA locking_mode=NORMAL" ;
|
|
|
|
|
( match Config.sqlite_vfs with
|
|
|
|
@ -70,10 +70,10 @@ let get_database () = Option.value_exn !database
|
|
|
|
|
|
|
|
|
|
let reset_capture_tables () =
|
|
|
|
|
let db = get_database () in
|
|
|
|
|
SqliteUtils.exec db ~log:"drop attributes table" ~stmt:"DROP TABLE attributes" ;
|
|
|
|
|
create_attributes_table db ;
|
|
|
|
|
SqliteUtils.exec db ~log:"drop cfg table" ~stmt:"DROP TABLE cfg" ;
|
|
|
|
|
create_cfg_table db
|
|
|
|
|
SqliteUtils.exec db ~log:"drop procedures table" ~stmt:"DROP TABLE procedures" ;
|
|
|
|
|
create_procedures_table db ;
|
|
|
|
|
SqliteUtils.exec db ~log:"drop source_files table" ~stmt:"DROP TABLE source_files" ;
|
|
|
|
|
create_source_files_table db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let db_canonicalize () =
|
|
|
|
|