X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2Fmqint.ml;h=64aea7d3373d682aada9ba33cf6604bcfd31ceb8;hb=515c1195a3b3ff86bf002091b4535bc812aa40ea;hp=01fbc1de1b102005a876ecfb62501a56854d8e6d;hpb=cef7b3b104313195d378890cd79656e5640eebec;p=helm.git diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index 01fbc1de1..64aea7d33 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -54,15 +54,23 @@ let check () = let status = Dbconn.pgc () in () -let stat = ref false +let stat = ref true 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 galax_db + +let set_database s = + if s = postgres_db || s = galax_db then dbname := s + else raise (Invalid_argument s) + +let get_database () = ! dbname (* valuta una MathQL.set_exp e ritorna un MathQL.resource_set *) @@ -97,7 +105,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,16 +114,16 @@ 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 = postgres_db 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); @@ -140,7 +148,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);