let instance =
let dbd = lazy (
- HMysql.quick_connect
+ HSql.quick_connect
~host:(Helm_registry.get "db.host")
~user:(Helm_registry.get "db.user")
~database:(Helm_registry.get "db.database")
let owned_uris =
try
MetadataDb.clean ~dbd
- with Mysql.Error _ as exn ->
- match HMysql.errno dbd with
- | Mysql.No_such_table -> []
+ with HSql.Error as exn ->
+ match HSql.errno dbd with
+ | HSql.No_such_table -> []
| _ -> raise exn
in
List.iter
owned_uris;
List.iter (fun statement ->
try
- ignore (HMysql.exec dbd statement)
- with Mysql.Error _ as exn ->
- match HMysql.errno dbd with
- | Mysql.Bad_table_error
- | Mysql.No_such_index | Mysql.No_such_table -> ()
+ ignore (HSql.exec dbd statement)
+ with HSql.Error as exn ->
+ match HSql.errno dbd with
+ | HSql.No_such_table
+ | HSql.Bad_table_error
+ | HSql.No_such_index -> prerr_endline statement; ()
| _ -> raise exn
) statements;
;;
in
List.iter (fun statement ->
try
- ignore (HMysql.exec dbd statement)
+ ignore (HSql.exec dbd statement)
with
- exn ->
- let status = HMysql.status dbd in
- match status with
- | Mysql.StatusError Mysql.Table_exists_error -> ()
- | Mysql.StatusError Mysql.Dup_keyname -> ()
- | Mysql.StatusError _ -> raise exn
- | _ -> ()
+ HSql.Error ->
+ let status = HSql.errno dbd in
+ match status with
+ | HSql.Table_exists_error -> ()
+ | HSql.Dup_keyname -> ()
+ | HSql.GENERIC_ERROR _ ->
+ prerr_endline statement;
+ raise HSql.Error
+ | _ -> ()
+
+
) statements
;;
let dbd = instance () in
let suri = UriManager.string_of_uri uri in
- let query table suri = sprintf
- "DELETE QUICK LOW_PRIORITY FROM %s WHERE source='%s'" table (HMysql.escape suri)
+ let query table suri =
+ if HSql.isMysql then
+ sprintf "DELETE QUICK LOW_PRIORITY FROM %s WHERE source='%s'" table (HSql.escape suri)
+ else sprintf "DELETE FROM %s WHERE source='%s'" table (HSql.escape suri)
in
List.iter (fun t ->
try
- ignore (HMysql.exec dbd (query t suri))
+ ignore (HSql.exec dbd (query t suri))
with
exn -> raise exn (* no errors should be accepted *)
)
let name_tbl = MetadataTypes.name_tbl () in
let query = sprintf
"SELECT source FROM %s WHERE source LIKE '%s#xpointer%%'" name_tbl
- (HMysql.escape (UriManager.string_of_uri uri))
+ (HSql.escape (UriManager.string_of_uri uri))
in
- let rc = HMysql.exec dbd query in
+ let rc = HSql.exec dbd query in
let l = ref [] in
- HMysql.iter rc (fun a -> match a.(0) with None ->()|Some a -> l := a:: !l);
+ HSql.iter rc (fun a -> match a.(0) with None ->()|Some a -> l := a:: !l);
List.map UriManager.uri_of_string !l