--- /dev/null
+(* Copyright (C) 2004, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://helm.cs.unibo.it/
+ *)
+
+open Printf ;;
+
+let clean_owner_environment dbd owner =
+ 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.conclno_hyp_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 ;" 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);
+*)
+ (try
+ MetadataDb.clean ~dbd
+ with
+ exn ->
+ match Mysql.errno dbd with
+ | Mysql.No_such_table -> ()
+ | _ -> raise exn
+ | _ -> ()
+ );
+ List.iter (fun statement ->
+ try
+ ignore (Mysql.exec dbd statement)
+ with
+ exn ->
+ match Mysql.errno dbd with
+ | Mysql.No_such_table -> ()
+ | _ -> raise exn
+ | _ -> ()
+ ) statements
+;;
+
+let create_owner_environment dbd owner =
+ 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.conclno_hyp_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 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);
+*)
+ List.iter (fun statement ->
+ try
+ ignore (Mysql.exec dbd statement)
+ with
+ exn ->
+ let status = Mysql.status dbd in
+ match status with
+ | Mysql.StatusError Mysql.Table_exists_error -> ()
+ | Mysql.StatusError _ -> raise exn
+ | _ -> ()
+ ) statements
+;;
+