|
|
@ -9,7 +9,7 @@
|
|
|
|
open! IStd
|
|
|
|
open! IStd
|
|
|
|
module L = Logging
|
|
|
|
module L = Logging
|
|
|
|
|
|
|
|
|
|
|
|
let merge_attributes_table ~db_file =
|
|
|
|
let merge_procedures_table ~db_file =
|
|
|
|
let db = ResultsDatabase.get_database () in
|
|
|
|
let db = ResultsDatabase.get_database () in
|
|
|
|
(* Do the merge purely in SQL for great speed. The query works by doing a left join between the
|
|
|
|
(* Do the merge purely in SQL for great speed. The query works by doing a left join between the
|
|
|
|
sub-table and the main one, and applying the same "more defined" logic as in Attributes in the
|
|
|
|
sub-table and the main one, and applying the same "more defined" logic as in Attributes in the
|
|
|
@ -17,11 +17,11 @@ let merge_attributes_table ~db_file =
|
|
|
|
NULL). All the rows that pass this filter are inserted/updated into the main table. *)
|
|
|
|
NULL). All the rows that pass this filter are inserted/updated into the main table. *)
|
|
|
|
Sqlite3.exec db
|
|
|
|
Sqlite3.exec db
|
|
|
|
{|
|
|
|
|
{|
|
|
|
|
INSERT OR REPLACE INTO attributes
|
|
|
|
INSERT OR REPLACE INTO procedures
|
|
|
|
SELECT sub.proc_name, sub.attr_kind, sub.source_file, sub.proc_attributes
|
|
|
|
SELECT sub.proc_name, sub.attr_kind, sub.source_file, sub.proc_attributes
|
|
|
|
FROM (
|
|
|
|
FROM (
|
|
|
|
attached.attributes AS sub
|
|
|
|
attached.procedures AS sub
|
|
|
|
LEFT OUTER JOIN attributes AS main
|
|
|
|
LEFT OUTER JOIN procedures AS main
|
|
|
|
ON sub.proc_name = main.proc_name )
|
|
|
|
ON sub.proc_name = main.proc_name )
|
|
|
|
WHERE
|
|
|
|
WHERE
|
|
|
|
main.attr_kind IS NULL
|
|
|
|
main.attr_kind IS NULL
|
|
|
@ -29,13 +29,14 @@ WHERE
|
|
|
|
OR (main.attr_kind = sub.attr_kind AND main.source_file < sub.source_file)
|
|
|
|
OR (main.attr_kind = sub.attr_kind AND main.source_file < sub.source_file)
|
|
|
|
|}
|
|
|
|
|}
|
|
|
|
|> SqliteUtils.check_sqlite_error db
|
|
|
|
|> SqliteUtils.check_sqlite_error db
|
|
|
|
~log:(Printf.sprintf "copying attributes of database '%s'" db_file)
|
|
|
|
~log:(Printf.sprintf "copying procedures of database '%s'" db_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let merge_cfg_table ~db_file =
|
|
|
|
let merge_source_files_table ~db_file =
|
|
|
|
let db = ResultsDatabase.get_database () in
|
|
|
|
let db = ResultsDatabase.get_database () in
|
|
|
|
Sqlite3.exec db "INSERT OR REPLACE INTO cfg SELECT * FROM attached.cfg"
|
|
|
|
Sqlite3.exec db "INSERT OR REPLACE INTO source_files SELECT * FROM attached.source_files"
|
|
|
|
|> SqliteUtils.check_sqlite_error db ~log:(Printf.sprintf "copying cfg of database '%s'" db_file)
|
|
|
|
|> SqliteUtils.check_sqlite_error db
|
|
|
|
|
|
|
|
~log:(Printf.sprintf "copying source_files of database '%s'" db_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let merge ~db_file =
|
|
|
|
let merge ~db_file =
|
|
|
@ -43,8 +44,8 @@ let merge ~db_file =
|
|
|
|
Sqlite3.exec main_db (Printf.sprintf "ATTACH '%s' AS attached" db_file)
|
|
|
|
Sqlite3.exec main_db (Printf.sprintf "ATTACH '%s' AS attached" db_file)
|
|
|
|
|> SqliteUtils.check_sqlite_error ~fatal:true main_db
|
|
|
|
|> SqliteUtils.check_sqlite_error ~fatal:true main_db
|
|
|
|
~log:(Printf.sprintf "attaching database '%s'" db_file) ;
|
|
|
|
~log:(Printf.sprintf "attaching database '%s'" db_file) ;
|
|
|
|
merge_attributes_table ~db_file ;
|
|
|
|
merge_procedures_table ~db_file ;
|
|
|
|
merge_cfg_table ~db_file ;
|
|
|
|
merge_source_files_table ~db_file ;
|
|
|
|
Sqlite3.exec main_db "DETACH attached"
|
|
|
|
Sqlite3.exec main_db "DETACH attached"
|
|
|
|
|> SqliteUtils.check_sqlite_error ~fatal:true main_db
|
|
|
|
|> SqliteUtils.check_sqlite_error ~fatal:true main_db
|
|
|
|
~log:(Printf.sprintf "detaching database '%s'" db_file) ;
|
|
|
|
~log:(Printf.sprintf "detaching database '%s'" db_file) ;
|
|
|
|