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 *)
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);
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
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);
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);
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);
* 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 *)