Add method to clean capture data

Summary:
There is currently a bug in incremental analysis because the capture data is not reset once the specs files have been invalidated. This has caused a problem where cost issues that should be reported are not spotted. I'm introducing this method so I can use it to fix incremental analysis.

This method is resurrected from D16602417

Reviewed By: ngorogiannis

Differential Revision: D17184401

fbshipit-source-id: e84925324
master
Phoebe Nichols 5 years ago committed by Facebook Github Bot
parent 224d44d79a
commit eb38b9c4c3

@ -152,6 +152,14 @@ module Implementation = struct
let canonicalize () = let canonicalize () =
let db = ResultsDatabase.get_database () in let db = ResultsDatabase.get_database () in
SqliteUtils.exec db ~log:"running VACUUM" ~stmt:"VACUUM" SqliteUtils.exec db ~log:"running VACUUM" ~stmt:"VACUUM"
let reset_capture_tables () =
let db = ResultsDatabase.get_database () in
SqliteUtils.exec db ~log:"drop procedures table" ~stmt:"DROP TABLE procedures" ;
ResultsDatabase.create_procedures_table db ;
SqliteUtils.exec db ~log:"drop source_files table" ~stmt:"DROP TABLE source_files" ;
ResultsDatabase.create_source_files_table db
end end
module Command = struct module Command = struct
@ -172,6 +180,7 @@ module Command = struct
| MarkAllSourceFilesStale | MarkAllSourceFilesStale
| MergeDBs of {infer_out_src: string} | MergeDBs of {infer_out_src: string}
| Vacuum | Vacuum
| ResetCaptureTables
| Handshake | Handshake
| Terminate | Terminate
@ -186,6 +195,8 @@ module Command = struct
"MergeDBs" "MergeDBs"
| Vacuum -> | Vacuum ->
"Vacuum" "Vacuum"
| ResetCaptureTables ->
"ResetCaptureTables"
| Handshake -> | Handshake ->
"Handshake" "Handshake"
| Terminate -> | Terminate ->
@ -206,6 +217,8 @@ module Command = struct
Implementation.merge_dbs ~infer_out_src Implementation.merge_dbs ~infer_out_src
| Vacuum -> | Vacuum ->
Implementation.canonicalize () Implementation.canonicalize ()
| ResetCaptureTables ->
Implementation.reset_capture_tables ()
| Handshake -> | Handshake ->
() ()
| Terminate -> | Terminate ->
@ -315,3 +328,5 @@ let mark_all_source_files_stale () = perform Command.MarkAllSourceFilesStale
let merge_dbs ~infer_out_src = Command.MergeDBs {infer_out_src} |> perform let merge_dbs ~infer_out_src = Command.MergeDBs {infer_out_src} |> perform
let canonicalize () = perform Command.Vacuum let canonicalize () = perform Command.Vacuum
let reset_capture_tables () = perform Command.ResetCaptureTables

@ -35,6 +35,8 @@ val merge_dbs : infer_out_src:string -> unit
val canonicalize : unit -> unit val canonicalize : unit -> unit
(** put the database on disk in deterministic form *) (** put the database on disk in deterministic form *)
val reset_capture_tables : unit -> unit [@@warning "-32"]
val start : unit -> unit val start : unit -> unit
val stop : unit -> unit val stop : unit -> unit

@ -17,7 +17,14 @@ val schema_hum : string
(** some human-readable string describing the tables *) (** some human-readable string describing the tables *)
val get_database : unit -> Sqlite3.db val get_database : unit -> Sqlite3.db
(** The results database. You should always use this function to access the database, as the connection to it may change during the execution (see [new_database_connection]). *) (** The results database. You should always use this function to access the database, as the
connection to it may change during the execution (see [new_database_connection]). *)
val create_procedures_table : Sqlite3.db -> unit
(** create a procedures table in the database*)
val create_source_files_table : Sqlite3.db -> unit
(** create a source files table in the database*)
val new_database_connection : unit -> unit val new_database_connection : unit -> unit
(** Closes the previous connection to the database (if any), and opens a new one. Needed after calls to fork(2). *) (** Closes the previous connection to the database (if any), and opens a new one. Needed after calls to fork(2). *)

Loading…
Cancel
Save