From: natile Date: Tue, 22 Oct 2002 08:45:57 +0000 (+0000) Subject: Switching interpreter patched, addedd: X-Git-Tag: BEFORE_METADATA_FOR_SORT_AND_REL~19 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=8a828144a6fe870f79603a47420d1fc3dd99071d;p=helm.git Switching interpreter patched, addedd: postgres_db galax_db get_database --- diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index 01fbc1de1..8062b11e6 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -60,9 +60,19 @@ let set_stat b = stat := b let get_stat () = ! stat -let dbname = ref "db-postgres" +let postgres_db = "postgres" -let set_database db = dbname := db +let galax_db = "galax" + +let dbname = ref postgres_db + +let set_database s = + match s with + postgres_db -> dbname := s + | galax_db -> dbname := s + | _ -> raise (Invalid_argument s) + +let get_database () = ! dbname (* valuta una MathQL.set_exp e ritorna un MathQL.resource_set *) @@ -79,7 +89,7 @@ let rec exec_set_exp c = function let ll1 = string_of_int (List.length rs1) in let ll2 = string_of_int (List.length rs2) in let diff = string_of_float (after -. before) in - if !stat then + if ! stat then (print_endline("INTERSECT(" ^ ll1 ^ "," ^ ll2 ^ ") = " ^ string_of_int (List.length res) ^ ": " ^ diff ^ "s"); flush stdout); @@ -89,7 +99,7 @@ let rec exec_set_exp c = function let res = union_ex (exec_set_exp c sexp1) (exec_set_exp c sexp2) in let after = Sys.time() in let diff = string_of_float (after -. before) in - if !stat then + if ! stat then (print_endline ("UNION: " ^ diff ^ "s"); flush stdout); res @@ -97,7 +107,7 @@ let rec exec_set_exp c = function let before = Sys.time() in let c1 = upd_svars c ((svar, exec_set_exp c sexp1) :: c.svars) in let res = exec_set_exp c1 sexp2 in - if !stat then + if ! stat then (print_string ("LETIN " ^ svar ^ " = " ^ string_of_int (List.length res) ^ ": "); print_endline (string_of_float (Sys.time() -. before) ^ "s"); flush stdout); @@ -106,23 +116,23 @@ let rec exec_set_exp c = function let before = Sys.time() in let c1 = upd_vvars c ((vvar, exec_val_exp c vexp) :: c.vvars) in let res = exec_set_exp c1 sexp in - if !stat then + if ! stat then (print_string ("LETIN " ^ vvar ^ " = " ^ string_of_int (List.length res) ^ ": "); print_endline (string_of_float (Sys.time() -. before) ^ "s"); flush stdout); res | MathQL.Relation (rop, path, sexp, attl) -> let before = Sys.time() in - if !dbname = "db-postgres" then + if ! dbname = "db-postgres" then (let res = relation_ex rop path (exec_set_exp c sexp) attl in - if !stat then + if ! stat then (print_string ("RELATION " ^ (List.hd path) ^ " = " ^ string_of_int(List.length res) ^ ": "); print_endline (string_of_float (Sys.time() -. before) ^ "s"); flush stdout); res) else (let res = relation_galax_ex rop path (exec_set_exp c sexp) attl in - if !stat then + if ! stat then (print_string ("RELATION-GALAX " ^ (List.hd path) ^ " = " ^ string_of_int(List.length res) ^ ": "); print_endline (string_of_float (Sys.time() -. before) ^ "s"); flush stdout); @@ -140,7 +150,7 @@ let rec exec_set_exp c = function else select_ex tl in let res = select_ex rset in - if !stat then + if ! stat then (print_string ("SELECT " ^ rvar ^ " = " ^ string_of_int (List.length res) ^ ": "); print_endline (string_of_float (Sys.time() -. before) ^ "s"); flush stdout); diff --git a/helm/ocaml/mathql_interpreter/mqint.mli b/helm/ocaml/mathql_interpreter/mqint.mli index f6f8827c6..414515308 100644 --- a/helm/ocaml/mathql_interpreter/mqint.mli +++ b/helm/ocaml/mathql_interpreter/mqint.mli @@ -23,14 +23,24 @@ * http://cs.unibo.it/helm/. *) -val init : string -> unit (* open database *) +val init : string -> unit (* open database *) -val execute : MathQL.query -> MathQL.result (* execute query *) +val execute : MathQL.query -> MathQL.result (* execute query *) -val close : unit -> unit (* close database *) +val close : unit -> unit (* close database *) -val check : unit -> unit (* check connection *) +val check : unit -> unit (* check connection *) + +val set_stat : bool -> unit (* set stat emission *) + +val get_stat : unit -> bool (* check stat emission *) + +val postgres_db : string (* postgres *) + +val galax_db : string (* galax *) + +val set_database : string -> unit (* switch postgres/galax *) + +val get_database : unit -> string (* check db used *) -val set_stat : bool -> unit (* set stat emission *) -val get_stat : unit -> bool (* check stat emission *)