List.iter (insert_const_no dbd) uris;
List.iter (fun (uri, name, _) -> insert_name ~dbd ~uri ~name) metadata
-let clean ~(dbd:Mysql.dbd) ~owner =
+let clean ~(dbd:Mysql.dbd) =
let owned_uris = (* list of uris in list-of-columns format *)
let query =
(* sprintf
sprintf "SELECT source FROM %s" (obj_tbl ())
in
let result = Mysql.exec dbd query in
- Mysql.map result (fun cols ->
+ let uris = Mysql.map result (fun cols ->
match cols.(0) with
| Some src -> src
- | None -> assert false)
+ | None -> assert false) in
+ (* and now some stuff to remove #xpointers and duplicates *)
+ let cleaned_uris =
+ List.map (fun x -> Str.replace_first (Str.regexp "\#.*$") "" x) uris
+ in
+ let sorted_uris = List.fast_sort Pervasives.compare cleaned_uris in
+ match sorted_uris with
+ | [] -> sorted_uris
+ | he::tl ->
+ (* no List.remove dups ?? *)
+ snd(List.fold_left (fun (last,l) cur -> if cur <> last then
+ (cur,cur::l) else (last,l)) (he,[he]) tl)
in
let del_from tbl =
let query s =
(* TODO Zack indexing of variables and (perhaps?) incomplete proofs *)
(** remove from the db all metadata pertaining to a given owner *)
-val clean: dbd:Mysql.dbd -> owner:string -> unit
+val clean: dbd:Mysql.dbd -> unit