X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Flibrary%2FlibraryDb.ml;h=e82e91f97f1629295d149ba1d066d11234932218;hb=762a35d1dcf3ccbcc69701f9d479c450186ecc12;hp=9e5a13bdb1623241975169b24168ace7bbb8b783;hpb=111df95ac03f2ee21dfa2422a7f531f675b1c16d;p=helm.git diff --git a/helm/software/components/library/libraryDb.ml b/helm/software/components/library/libraryDb.ml index 9e5a13bdb..e82e91f97 100644 --- a/helm/software/components/library/libraryDb.ml +++ b/helm/software/components/library/libraryDb.ml @@ -25,7 +25,11 @@ (* $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))