]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/pattern.ml
debian version 0.4.3 (maybe, not tested)
[helm.git] / helm / ocaml / mathql_interpreter / pattern.ml
index a4cafa020e0e67d4e9a4c01ce023a213d0333518..5dcb8a585dfee96099f4636396a42ce571851ee0 100644 (file)
@@ -23,7 +23,6 @@
  * http://www.cs.unibo.it/helm/.
  *)
 
-open Dbconn;;
 open Utility;;
 
 let cat l1 l2 =
@@ -33,16 +32,22 @@ let cat l1 l2 =
         l1 @ l2
 ;;
 
-let rec pattern_ex l =
+let rec pattern_ex handle l =
   match l with
      [] -> []
    | s::tl -> let result = 
-             let c = pgc () in
-             let qq = "select uri from registry where uri ~ '" ^ s ^ "' order by registry.uri asc" in
-             print_endline qq ; flush stderr ;
+             let c = MQIConn.pgc handle in
+             let quoted_s =
+              Str.global_substitute (Str.regexp "'")
+               (function _ -> "\\'") s in
+             let qq = "select uri from registry where uri ~ '" ^ quoted_s ^ "' order by registry.uri asc" in
              let res = c#exec (qq) in
-             List.map (function uri -> (uri,[])) (pgresult_to_string_list res)
-             in
-            cat result (pattern_ex tl)
+             List.map (function uri -> (List.hd uri,[])) res#get_list
+             (*for i = 0 to res#ntuples do 
+            List.map (function uri -> (uri,[])) (res#get_tuple_list i)
+             done*)
+
+            in
+            cat result (pattern_ex handle tl)
 ;;