]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/mQIProperty.ml
MySql database support added
[helm.git] / helm / ocaml / mathql_interpreter / mQIProperty.ml
index a8b2e028df78c77edac94731a5817ab0fc7481e3..e721606de39867a283e5c51ec24f2b3ccf0ec974 100644 (file)
@@ -29,7 +29,6 @@
 module M = MathQL
 module I = M.I
 module U = AvsUtil
-module P = MQIPostgres
 module C = MQIConn
 module A = MQIMap
 
@@ -54,58 +53,6 @@ let cl_print l =
    in
    List.iter c_print l
 
-(* PostgreSQL backend  ******************************************************)
-
-let pg_query h table cols ct cfl =
-   let exec q = 
-      if C.set h C.Queries then C.log h (q ^ "\n");
-      P.exec (C.pgc h) q 
-   in
-   let rec iter f sep = function
-      | []           -> ""
-      | [head]       -> f head 
-      | head :: tail -> f head ^ sep ^ iter f sep tail
-   in
-   let avs_iter f sep v =
-      let aux a s = function
-         | true  -> a ^ (f s) ^ sep
-        | false -> a ^ (f s)
-      in
-      I.iter aux "" v
-   in
-   let pg_cols = iter (fun x -> x) ", " cols in
-   let pg_msval v = avs_iter P.quote ", " v in
-   let pg_con (pat, col, v) = 
-      if col <> "" then 
-         let f s = col ^ " ~ " ^ P.quote ("^" ^ s ^ "$") in
-        if pat then "(" ^ avs_iter f " or " v ^ ")"
-        else match I.single v with 
-           | Some s -> col ^ " = " ^ (P.quote s)     
-           | None   -> col ^ " in (" ^ pg_msval v ^ ")"
-      else "true"
-   in
-   let pg_cons l = iter pg_con " and " l in
-   let pg_cons_not l = "not (" ^ pg_cons l ^ ")" in
-   let pg_cons_not_l ll = iter pg_cons_not " and " ll in
-   let pg_where = match ct, cfl with
-      | [], []  -> ""
-      | lt, []  -> " where " ^ pg_cons lt
-      | [], llf -> " where " ^ pg_cons_not_l llf
-      | lt, llf -> " where " ^ pg_cons lt ^ " and " ^ pg_cons_not_l llf
-   in
-   if cols = [] then
-      let r = exec ("select count (source) from " ^ table ^ pg_where) in
-      match r with
-         | [[s]] when int_of_string s > 0 -> [[]]
-        | _                              -> []
-   else
-      exec ("select " ^ pg_cols ^ " from " ^ table ^ pg_where ^ 
-            " order by " ^ List.hd cols ^ " asc") (* desc *) 
-
-(* Galax backend  ***********************************************************)
-
-let gx_query h table cols ct cfl = not_supported "Galax"
-
 (* Common functions  ********************************************************)
 
 let pg_result subj el res =
@@ -134,8 +81,8 @@ let exec_single h mc ct cfl el table =
    let cons_false = List.map mk_con cfl in
    let other_cols = List.map (fun (p, _) -> conv p) el in 
    let cols = if first = "" then other_cols else first :: other_cols in
-   let low_level = if C.set h C.Galax then gx_query else pg_query in
-   let result = low_level h (C.resolve h table) cols cons_true cons_false in
+   let result, q = C.exec h (C.resolve h table) cols cons_true cons_false in
+   if C.set h C.Queries then C.log h (q ^ "\n");   
    pg_result first el result 
    
 let deadline = 100
@@ -150,14 +97,3 @@ let exec h refine mc ct cfl el =
       | _                                                 ->
          exec_single h mc ct cfl el table
    in exec_aux ct       
-
-(* funzioni vecchie  ********************************************************)
-
-let pg_name h s = 
-   let q = "select id from registry where uri = " ^ P.quote s in
-   match P.exec h q with
-      | [[id]] -> "t" ^ id
-      | _      -> ""
-
-let get_id b = if b then ["B"] else ["F"] 
-