From: Enrico Tassi Date: Tue, 3 May 2005 14:43:12 +0000 (+0000) Subject: sync with SqlStatements X-Git-Tag: single_binding~112 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=11d81280208345b189c174e2ae19a6ab45e2b03a;p=helm.git sync with SqlStatements --- diff --git a/helm/matita/matitaDb.ml b/helm/matita/matitaDb.ml index a4f0f4f96..878bd4fe7 100644 --- a/helm/matita/matitaDb.ml +++ b/helm/matita/matitaDb.ml @@ -45,28 +45,14 @@ let clean_owner_environment () = let sort_tbl = MetadataTypes.sort_tbl () in let rel_tbl = MetadataTypes.rel_tbl () in let name_tbl = MetadataTypes.name_tbl () in - (*let conclno_tbl = MetadataTypes.conclno_tbl () in - let conclno_hyp_tbl = MetadataTypes.fullno_tbl () in*) let count_tbl = MetadataTypes.count_tbl () in - let statements = [ - sprintf "DROP TABLE %s ;" obj_tbl; - sprintf "DROP TABLE %s ;" sort_tbl; - sprintf "DROP TABLE %s ;" rel_tbl; - sprintf "DROP TABLE %s ;" name_tbl; - sprintf "DROP TABLE %s ;" count_tbl - (*sprintf "DROP TABLE %s ;" conclno_tbl; - sprintf "DROP TABLE %s ;" conclno_hyp_tbl*) ] in -(* -DROP INDEX refObj_source ON refObj (source); -DROP INDEX refObj_target ON refObj (h_occurrence); -DROP INDEX refObj_position ON refObj (h_position); -DROP INDEX refSort_source ON refSort (source); -DROP INDEX objectName_value ON objectName (value); -DROP INDEX no_inconcl_aux_source ON no_inconcl_aux (source); -DROP INDEX no_inconcl_aux_no ON no_inconcl_aux (no); -DROP INDEX no_concl_hyp_source ON no_concl_hyp (source); -DROP INDEX no_concl_hyp_no ON no_concl_hyp (no); -*) + let tbls = [ + (obj_tbl,`RefObj) ; (sort_tbl,`RefSort) ; (rel_tbl,`RefRel) ; + (name_tbl,`ObjectName) ; (count_tbl,`Count) ] + in + let statements = + (SqlStatements.drop_tables tbls) @ (SqlStatements.drop_indexes tbls) + in let owned_uris = try MetadataDb.clean ~dbd @@ -87,69 +73,26 @@ DROP INDEX no_concl_hyp_no ON no_concl_hyp (no); ignore (Mysql.exec dbd statement) with Mysql.Error _ as exn -> match Mysql.errno dbd with - | Mysql.Bad_table_error -> () + | Mysql.Bad_table_error + | Mysql.No_such_index | Mysql.No_such_table -> () | _ -> raise exn ) statements; ;; let create_owner_environment () = let dbd = instance () in - let owner = (Helm_registry.get "matita.owner") in let obj_tbl = MetadataTypes.obj_tbl () in let sort_tbl = MetadataTypes.sort_tbl () in let rel_tbl = MetadataTypes.rel_tbl () in let name_tbl = MetadataTypes.name_tbl () in - (*let conclno_tbl = MetadataTypes.conclno_tbl () in - let conclno_hyp_tbl = MetadataTypes.fullno_tbl ()*) let count_tbl = MetadataTypes.count_tbl () in - let statements = [ - sprintf "CREATE TABLE %s ( - source varchar(255) binary not null, - h_occurrence varchar(255) binary not null, - h_position varchar(255) binary not null, - h_depth integer - );" obj_tbl; - sprintf "CREATE TABLE %s ( - source varchar(255) binary not null, - h_position varchar(255) binary not null, - h_depth integer not null, - h_sort varchar(255) binary not null - );" sort_tbl; - sprintf "CREATE TABLE %s ( - source varchar(255) binary not null, - h_position varchar(255) binary not null, - h_depth integer not null - );" rel_tbl; - sprintf "CREATE TABLE %s ( - source varchar(255) binary not null, - value varchar(255) binary not null - );" name_tbl; - sprintf "CREATE TABLE %s ( - source varchar(255) binary unique not null, - conclusion smallint(6) not null, - hypothesis smallint(6) not null, - statement smallint(6) not null -);" count_tbl - - (* sprintf "CREATE TABLE %s ( - source varchar(255) binary not null, - no tinyint(4) not null - );" conclno_tbl; - sprintf "CREATE TABLE %s ( - source varchar(255) binary not null, - no tinyint(4) not null - );" conclno_hyp_tbl *)] in -(* -CREATE INDEX refObj_source ON refObj (source); -CREATE INDEX refObj_target ON refObj (h_occurrence); -CREATE INDEX refObj_position ON refObj (h_position); -CREATE INDEX refSort_source ON refSort (source); -CREATE INDEX objectName_value ON objectName (value); -CREATE INDEX no_inconcl_aux_source ON no_inconcl_aux (source); -CREATE INDEX no_inconcl_aux_no ON no_inconcl_aux (no); -CREATE INDEX no_concl_hyp_source ON no_concl_hyp (source); -CREATE INDEX no_concl_hyp_no ON no_concl_hyp (no); -*) + let tbls = [ + (obj_tbl,`RefObj) ; (sort_tbl,`RefSort) ; (rel_tbl,`RefRel) ; + (name_tbl,`ObjectName) ; (count_tbl,`Count) ] + in + let statements = + (SqlStatements.create_tables tbls) @ (SqlStatements.create_indexes tbls) + in List.iter (fun statement -> try ignore (Mysql.exec dbd statement)