1 (* Copyright (C) 2004, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://helm.cs.unibo.it/
28 let clean_owner_environment dbd owner =
29 let obj_tbl = MetadataTypes.obj_tbl () in
30 let sort_tbl = MetadataTypes.sort_tbl () in
31 let rel_tbl = MetadataTypes.rel_tbl () in
32 let name_tbl = MetadataTypes.name_tbl () in
33 let conclno_tbl = MetadataTypes.conclno_tbl () in
34 let conclno_hyp_tbl = MetadataTypes.conclno_hyp_tbl () in
36 sprintf "DROP TABLE %s ;" obj_tbl;
37 sprintf "DROP TABLE %s ;" sort_tbl;
38 sprintf "DROP TABLE %s ;" rel_tbl;
39 sprintf "DROP TABLE %s ;" name_tbl;
40 sprintf "DROP TABLE %s ;" conclno_tbl;
41 sprintf "DROP TABLE %s ;" conclno_hyp_tbl ] in
43 DROP INDEX refObj_source ON refObj (source);
44 DROP INDEX refObj_target ON refObj (h_occurrence);
45 DROP INDEX refObj_position ON refObj (h_position);
46 DROP INDEX refSort_source ON refSort (source);
47 DROP INDEX objectName_value ON objectName (value);
48 DROP INDEX no_inconcl_aux_source ON no_inconcl_aux (source);
49 DROP INDEX no_inconcl_aux_no ON no_inconcl_aux (no);
50 DROP INDEX no_concl_hyp_source ON no_concl_hyp (source);
51 DROP INDEX no_concl_hyp_no ON no_concl_hyp (no);
57 match Mysql.errno dbd with
58 | Mysql.No_such_table -> ()
62 List.iter (fun statement ->
64 ignore (Mysql.exec dbd statement)
67 match Mysql.errno dbd with
68 | Mysql.No_such_table -> ()
74 let create_owner_environment dbd owner =
75 let obj_tbl = MetadataTypes.obj_tbl () in
76 let sort_tbl = MetadataTypes.sort_tbl () in
77 let rel_tbl = MetadataTypes.rel_tbl () in
78 let name_tbl = MetadataTypes.name_tbl () in
79 let conclno_tbl = MetadataTypes.conclno_tbl () in
80 let conclno_hyp_tbl = MetadataTypes.conclno_hyp_tbl () in
82 sprintf "CREATE TABLE %s (
83 source varchar(255) binary not null,
84 h_occurrence varchar(255) binary not null,
85 h_position varchar(255) binary not null,
88 sprintf "CREATE TABLE %s (
89 source varchar(255) binary not null,
90 h_position varchar(255) binary not null,
91 h_depth integer not null,
92 h_sort varchar(255) binary not null
94 sprintf "CREATE TABLE %s (
95 source varchar(255) binary not null,
96 h_position varchar(255) binary not null,
97 h_depth integer not null
99 sprintf "CREATE TABLE %s (
100 source varchar(255) binary not null,
101 value varchar(255) binary not null
103 sprintf "CREATE TABLE %s (
104 source varchar(255) binary not null,
105 no tinyint(4) not null
107 sprintf "CREATE TABLE %s (
108 source varchar(255) binary not null,
109 no tinyint(4) not null
110 );" conclno_hyp_tbl ] in
112 CREATE INDEX refObj_source ON refObj (source);
113 CREATE INDEX refObj_target ON refObj (h_occurrence);
114 CREATE INDEX refObj_position ON refObj (h_position);
115 CREATE INDEX refSort_source ON refSort (source);
116 CREATE INDEX objectName_value ON objectName (value);
117 CREATE INDEX no_inconcl_aux_source ON no_inconcl_aux (source);
118 CREATE INDEX no_inconcl_aux_no ON no_inconcl_aux (no);
119 CREATE INDEX no_concl_hyp_source ON no_concl_hyp (source);
120 CREATE INDEX no_concl_hyp_no ON no_concl_hyp (no);
122 List.iter (fun statement ->
124 ignore (Mysql.exec dbd statement)
127 let status = Mysql.status dbd in
129 | Mysql.StatusError Mysql.Table_exists_error -> ()
130 | Mysql.StatusError _ -> raise exn