]> 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 45b43995211ca97244daca79a47881f4255cb8b4..5dcb8a585dfee96099f4636396a42ce571851ee0 100644 (file)
@@ -23,7 +23,6 @@
  * http://www.cs.unibo.it/helm/.
  *)
 
-open Dbconn;;
 open Utility;;
 
 let cat l1 l2 =
@@ -33,19 +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
+             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)
+             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 tl)
+            cat result (pattern_ex handle tl)
 ;;