(* $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
(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
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;
;;
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 ->
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))