]> matita.cs.unibo.it Git - helm.git/blobdiff - components/library/libraryDb.ml
removed ugly printing
[helm.git] / components / library / libraryDb.ml
index 9e5a13bdb1623241975169b24168ace7bbb8b783..e82e91f97f1629295d149ba1d066d11234932218 100644 (file)
 
 (* $Id$ *)
 
-open Printf ;;
+let dbtype_of_string dbtype =
+   if dbtype = "library" then HSql.Library
+   else if dbtype = "user" then HSql.User
+   else if dbtype = "legacy" then HSql.Legacy
+   else raise (HSql.Error "HSql: wrong config file format")
 
 let parse_dbd_conf _ =
   let metadata = Helm_registry.get_list Helm_registry.string "db.metadata" in
@@ -33,12 +37,7 @@ let parse_dbd_conf _ =
     (fun s -> 
       match Pcre.split ~pat:"\\s+" s with
       | [path;db;user;pwd;dbtype] -> 
-           let dbtype = 
-             if dbtype = "library" then HSql.Library
-             else if dbtype = "user" then HSql.User
-             else if dbtype = "legacy" then HSql.Legacy
-             else raise (HSql.Error "HSql: wrong config file format")
-           in
+           let dbtype = dbtype_of_string dbtype in
            let pwd = if pwd = "none" then None else Some pwd in
            (* TODO parse port *)
            path, None, db, user, pwd, dbtype
@@ -105,7 +104,7 @@ let clean_owner_environment () =
       match HSql.errno dbtype dbd with 
       | HSql.No_such_table
       | HSql.Bad_table_error
-      | HSql.No_such_index -> prerr_endline statement; ()
+      | HSql.No_such_index -> ()
       | _ -> raise exn
     ) statements;
 ;;
@@ -176,10 +175,10 @@ let remove_uri uri =
   in
   let query table suri = 
     if HSql.isMysql dbtype dbd then 
-      sprintf "DELETE QUICK LOW_PRIORITY FROM %s WHERE source='%s'" table 
+      Printf.sprintf "DELETE QUICK LOW_PRIORITY FROM %s WHERE source='%s'" table 
         (HSql.escape dbtype dbd suri)
     else 
-      sprintf "DELETE FROM %s WHERE source='%s'" table 
+      Printf.sprintf "DELETE FROM %s WHERE source='%s'" table 
         (HSql.escape dbtype dbd suri)
   in
   List.iter (fun t -> 
@@ -201,7 +200,7 @@ let xpointers_of_ind uri =
     Pcre.replace ~pat:"([^\\\\])_" ~templ:"$1\\_" 
       (HSql.escape dbtype dbd s)
   in
-  let query = sprintf 
+  let query = Printf.sprintf 
     ("SELECT source FROM %s WHERE source LIKE '%s#xpointer%%' "
      ^^ HSql.escape_string_for_like dbtype dbd)
     name_tbl (escape (UriManager.string_of_uri uri))