]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/mqint.ml
Switching interpreter.
[helm.git] / helm / ocaml / mathql_interpreter / mqint.ml
index e1dc6f8d988f7fe0034ad06120fc64423f09f313..01fbc1de1b102005a876ecfb62501a56854d8e6d 100644 (file)
@@ -43,13 +43,16 @@ open Diff;;
 open Relation;;
 open Func;;
 
+
+exception BooleExpTrue
+
 let init connection_param = Dbconn.init connection_param 
 
 let close () = Dbconn.close ()
 
-let check () = Dbconn.pgc ()
-
-exception BooleExpTrue
+let check () = 
+   let status = Dbconn.pgc () 
+   in ()
 
 let stat = ref false
 
@@ -57,6 +60,10 @@ let set_stat b = stat := b
 
 let get_stat () = ! stat
 
+let dbname = ref "db-postgres"
+
+let set_database db = dbname := db  
+
 (* valuta una MathQL.set_exp e ritorna un MathQL.resource_set *)
 
 let rec exec_set_exp c = function
@@ -106,12 +113,22 @@ let rec exec_set_exp c = function
        res
    | MathQL.Relation (rop, path, sexp, attl) -> 
         let before = Sys.time() in
-        let res = relation_ex rop path (exec_set_exp c sexp) attl in
-       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   
+       if !dbname = "db-postgres" then
+        (let res = relation_ex rop path (exec_set_exp c sexp) attl in
+        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
+         (print_string ("RELATION-GALAX " ^ (List.hd path) ^ " = " ^ string_of_int(List.length res) ^ ": ");
+          print_endline (string_of_float (Sys.time() -. before) ^ "s");
+          flush stdout);
+         res) 
+       
+       
    | MathQL.Select (rvar, sexp, bexp) ->
         let before = Sys.time() in
         let rset = (exec_set_exp c sexp) in
@@ -181,7 +198,7 @@ and exec_val_exp c = function
    | MathQL.VVar s -> List.assoc s c.vvars                               
    | MathQL.RefOf sexp -> List.map (fun (s,_) -> s) (exec_set_exp c sexp)
    | MathQL.Fun (s, vexp) -> fun_ex s (exec_val_exp c vexp)
-   | _ -> assert false
+   | MathQL.Attribute (rop, path, vexp) -> [] 
 
 (* valuta una MathQL.set_exp nel contesto vuoto e ritorna un MathQL.resource_set *)
 and execute x =