[sqlite] remove proc_name_hum field

Summary: Since the unique string ID used as a key is also human-readable, remove the now-redundant `proc_name_hum` field, which is only used for debug purposes anyway.

Reviewed By: jberdine

Differential Revision: D23446223

fbshipit-source-id: 5027066ee
master
Nikos Gorogiannis 4 years ago committed by Facebook GitHub Bot
parent e9a6195b52
commit cb2243741c

@ -72,17 +72,16 @@ let store ~proc_desc (attr : ProcAttributes.t) =
let proc_uid = Procname.to_unique_id pname in let proc_uid = Procname.to_unique_id pname in
if should_try_to_update proc_uid akind then if should_try_to_update proc_uid akind then
let proc_name = Procname.SQLite.serialize pname in let proc_name = Procname.SQLite.serialize pname in
let proc_name_hum = Procname.to_string pname in
let attr_kind = int64_of_attributes_kind akind in let attr_kind = int64_of_attributes_kind akind in
let cfg = Procdesc.SQLite.serialize proc_desc in let cfg = Procdesc.SQLite.serialize proc_desc in
let proc_attributes = ProcAttributes.SQLite.serialize attr in let proc_attributes = ProcAttributes.SQLite.serialize attr in
let source_file = SourceFile.SQLite.serialize attr.loc.Location.file in let source_file = SourceFile.SQLite.serialize attr.loc.Location.file in
let callees = let callees =
Option.map proc_desc ~f:Procdesc.get_static_callees Option.value_map proc_desc ~f:Procdesc.get_static_callees ~default:[]
|> Option.value ~default:[] |> Procname.SQLiteList.serialize |> Procname.SQLiteList.serialize
in in
DBWriter.replace_attributes ~proc_uid ~proc_name ~proc_name_hum ~attr_kind ~source_file DBWriter.replace_attributes ~proc_uid ~proc_name ~attr_kind ~source_file ~proc_attributes ~cfg
~proc_attributes ~cfg ~callees ~callees
let find_file_capturing_procedure pname = let find_file_capturing_procedure pname =

@ -65,7 +65,7 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file
pp_if ?new_line condition title pp fmt (Sqlite3.column stmt column |> deserialize) pp_if ?new_line condition title pp fmt (Sqlite3.column stmt column |> deserialize)
in in
let pp_row stmt fmt source_file proc_name = let pp_row stmt fmt source_file proc_name =
let[@warning "-8"] (Sqlite3.Data.TEXT proc_name_hum) = Sqlite3.column stmt 1 in let[@warning "-8"] (Sqlite3.Data.TEXT proc_uid) = Sqlite3.column stmt 1 in
let dump_cfg fmt cfg_opt = let dump_cfg fmt cfg_opt =
match cfg_opt with match cfg_opt with
| None -> | None ->
@ -74,7 +74,7 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file
let path = DotCfg.emit_proc_desc source_file cfg in let path = DotCfg.emit_proc_desc source_file cfg in
F.fprintf fmt "'%s'" path F.fprintf fmt "'%s'" path
in in
Format.fprintf fmt "@[<v2>%s@,%a%a%a%a%a@]@\n" proc_name_hum Format.fprintf fmt "@[<v2>%s@,%a%a%a%a%a@]@\n" proc_uid
(pp_if source_file_cond "source_file" SourceFile.pp) (pp_if source_file_cond "source_file" SourceFile.pp)
source_file source_file
(pp_if proc_name_cond "proc_name" Procname.pp) (pp_if proc_name_cond "proc_name" Procname.pp)
@ -92,7 +92,7 @@ let pp_all ~filter ~proc_name:proc_name_cond ~attr_kind ~source_file:source_file
(* we could also register this statement but it's typically used only once per run so just prepare (* we could also register this statement but it's typically used only once per run so just prepare
it inside the function *) it inside the function *)
Sqlite3.prepare db Sqlite3.prepare db
"SELECT proc_name, proc_name_hum, attr_kind, source_file, proc_attributes, cfg FROM procedures" "SELECT proc_name, proc_uid, attr_kind, source_file, proc_attributes, cfg FROM procedures"
|> Container.iter ~fold:(SqliteUtils.result_fold_rows db ~log:"print all procedures") |> Container.iter ~fold:(SqliteUtils.result_fold_rows db ~log:"print all procedures")
~f:(fun stmt -> ~f:(fun stmt ->
let proc_name = Sqlite3.column stmt 0 |> Procname.SQLite.deserialize in let proc_name = Sqlite3.column stmt 0 |> Procname.SQLite.deserialize in

@ -31,7 +31,7 @@ module Implementation = struct
ResultsDatabase.register_statement ResultsDatabase.register_statement
{| {|
INSERT OR REPLACE INTO procedures INSERT OR REPLACE INTO procedures
SELECT :uid, :pname, :proc_name_hum, :akind, :sfile, :pattr, :cfg, :callees SELECT :uid, :pname, :akind, :sfile, :pattr, :cfg, :callees
FROM ( FROM (
SELECT NULL SELECT NULL
FROM ( FROM (
@ -43,24 +43,22 @@ module Implementation = struct
OR (attr_kind = :akind AND source_file <= :sfile) ) OR (attr_kind = :akind AND source_file <= :sfile) )
|} |}
in in
fun ~proc_uid ~proc_name ~proc_name_hum ~attr_kind ~source_file ~proc_attributes ~cfg ~callees -> fun ~proc_uid ~proc_name ~attr_kind ~source_file ~proc_attributes ~cfg ~callees ->
ResultsDatabase.with_registered_statement attribute_replace_statement ResultsDatabase.with_registered_statement attribute_replace_statement
~f:(fun db replace_stmt -> ~f:(fun db replace_stmt ->
Sqlite3.bind replace_stmt 1 (* :proc_uid *) (Sqlite3.Data.TEXT proc_uid) Sqlite3.bind replace_stmt 1 (* :proc_uid *) (Sqlite3.Data.TEXT proc_uid)
|> SqliteUtils.check_result_code db ~log:"replace bind proc_uid" ; |> SqliteUtils.check_result_code db ~log:"replace bind proc_uid" ;
Sqlite3.bind replace_stmt 2 (* :pname *) proc_name Sqlite3.bind replace_stmt 2 (* :pname *) proc_name
|> SqliteUtils.check_result_code db ~log:"replace bind proc_name" ; |> SqliteUtils.check_result_code db ~log:"replace bind proc_name" ;
Sqlite3.bind replace_stmt 3 (* :proc_name_hum *) (Sqlite3.Data.TEXT proc_name_hum) Sqlite3.bind replace_stmt 3 (* :akind *) (Sqlite3.Data.INT attr_kind)
|> SqliteUtils.check_result_code db ~log:"replace bind proc_name_hum" ;
Sqlite3.bind replace_stmt 4 (* :akind *) (Sqlite3.Data.INT attr_kind)
|> SqliteUtils.check_result_code db ~log:"replace bind attr_kind" ; |> SqliteUtils.check_result_code db ~log:"replace bind attr_kind" ;
Sqlite3.bind replace_stmt 5 (* :sfile *) source_file Sqlite3.bind replace_stmt 4 (* :sfile *) source_file
|> SqliteUtils.check_result_code db ~log:"replace bind source source_file" ; |> SqliteUtils.check_result_code db ~log:"replace bind source source_file" ;
Sqlite3.bind replace_stmt 6 (* :pattr *) proc_attributes Sqlite3.bind replace_stmt 5 (* :pattr *) proc_attributes
|> SqliteUtils.check_result_code db ~log:"replace bind proc proc_attributes" ; |> SqliteUtils.check_result_code db ~log:"replace bind proc proc_attributes" ;
Sqlite3.bind replace_stmt 7 (* :cfg *) cfg Sqlite3.bind replace_stmt 6 (* :cfg *) cfg
|> SqliteUtils.check_result_code db ~log:"replace bind cfg" ; |> SqliteUtils.check_result_code db ~log:"replace bind cfg" ;
Sqlite3.bind replace_stmt 8 (* :callees *) callees Sqlite3.bind replace_stmt 7 (* :callees *) callees
|> SqliteUtils.check_result_code db ~log:"replace bind callees" ; |> SqliteUtils.check_result_code db ~log:"replace bind callees" ;
SqliteUtils.result_unit db ~finalize:false ~log:"replace_attributes" replace_stmt ) SqliteUtils.result_unit db ~finalize:false ~log:"replace_attributes" replace_stmt )
@ -112,7 +110,6 @@ module Implementation = struct
SELECT SELECT
sub.proc_uid, sub.proc_uid,
sub.proc_name, sub.proc_name,
sub.proc_name_hum,
sub.attr_kind, sub.attr_kind,
sub.source_file, sub.source_file,
sub.proc_attributes, sub.proc_attributes,
@ -237,7 +234,6 @@ module Command = struct
| ReplaceAttributes of | ReplaceAttributes of
{ proc_uid: string { proc_uid: string
; proc_name: Sqlite3.Data.t ; proc_name: Sqlite3.Data.t
; proc_name_hum: string
; attr_kind: int64 ; attr_kind: int64
; source_file: Sqlite3.Data.t ; source_file: Sqlite3.Data.t
; proc_attributes: Sqlite3.Data.t ; proc_attributes: Sqlite3.Data.t
@ -289,11 +285,10 @@ module Command = struct
Implementation.merge infer_deps_file Implementation.merge infer_deps_file
| StoreSpec {proc_uid; proc_name; analysis_summary; report_summary} -> | StoreSpec {proc_uid; proc_name; analysis_summary; report_summary} ->
Implementation.store_spec ~proc_uid ~proc_name ~analysis_summary ~report_summary Implementation.store_spec ~proc_uid ~proc_name ~analysis_summary ~report_summary
| ReplaceAttributes | ReplaceAttributes {proc_uid; proc_name; attr_kind; source_file; proc_attributes; cfg; callees}
{proc_uid; proc_name; proc_name_hum; attr_kind; source_file; proc_attributes; cfg; callees}
-> ->
Implementation.replace_attributes ~proc_uid ~proc_name ~proc_name_hum ~attr_kind Implementation.replace_attributes ~proc_uid ~proc_name ~attr_kind ~source_file
~source_file ~proc_attributes ~cfg ~callees ~proc_attributes ~cfg ~callees
| ResetCaptureTables -> | ResetCaptureTables ->
Implementation.reset_capture_tables () Implementation.reset_capture_tables ()
| Terminate -> | Terminate ->
@ -397,11 +392,9 @@ let start () = Server.start ()
let stop () = Server.send Command.Terminate let stop () = Server.send Command.Terminate
let replace_attributes ~proc_uid ~proc_name ~proc_name_hum ~attr_kind ~source_file ~proc_attributes let replace_attributes ~proc_uid ~proc_name ~attr_kind ~source_file ~proc_attributes ~cfg ~callees =
~cfg ~callees =
perform perform
(ReplaceAttributes (ReplaceAttributes {proc_uid; proc_name; attr_kind; source_file; proc_attributes; cfg; callees})
{proc_uid; proc_name; proc_name_hum; attr_kind; source_file; proc_attributes; cfg; callees})
let add_source_file ~source_file ~tenv ~integer_type_widths ~proc_names = let add_source_file ~source_file ~tenv ~integer_type_widths ~proc_names =

@ -14,7 +14,6 @@ val use_daemon : bool
val replace_attributes : val replace_attributes :
proc_uid:string proc_uid:string
-> proc_name:Sqlite3.Data.t -> proc_name:Sqlite3.Data.t
-> proc_name_hum:string
-> attr_kind:int64 -> attr_kind:int64
-> source_file:Sqlite3.Data.t -> source_file:Sqlite3.Data.t
-> proc_attributes:Sqlite3.Data.t -> proc_attributes:Sqlite3.Data.t

@ -17,7 +17,6 @@ let procedures_schema prefix =
CREATE TABLE IF NOT EXISTS %sprocedures CREATE TABLE IF NOT EXISTS %sprocedures
( proc_uid TEXT PRIMARY KEY NOT NULL ( proc_uid TEXT PRIMARY KEY NOT NULL
, proc_name BLOB NOT NULL , proc_name BLOB NOT NULL
, proc_name_hum TEXT
, attr_kind INTEGER NOT NULL , attr_kind INTEGER NOT NULL
, source_file TEXT NOT NULL , source_file TEXT NOT NULL
, proc_attributes BLOB NOT NULL , proc_attributes BLOB NOT NULL

Loading…
Cancel
Save