X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fhmysql%2FhMysql.ml;h=041f4392287bf0642a1d50a20259d5efa8c110cb;hb=99ca90bf28a25fcd1cd84596c37be43c97f74e6e;hp=94f3efe03fb97b2bc80f596534fbc3878aebb92d;hpb=55b82bd235d82ff7f0a40d980effe1efde1f5073;p=helm.git diff --git a/helm/software/components/hmysql/hMysql.ml b/helm/software/components/hmysql/hMysql.ml index 94f3efe03..041f43922 100644 --- a/helm/software/components/hmysql/hMysql.ml +++ b/helm/software/components/hmysql/hMysql.ml @@ -27,7 +27,15 @@ type dbd = Mysql.dbd option type result = Mysql.result option -type error_code = Mysql.error_code +type error_code = + | OK + | Table_exists_error + | Dup_keyname + | No_such_table + | No_such_index + | Bad_table_error + | GENERIC_ERROR of string +exception Error let profiler = HExtlib.profile "mysql" @@ -54,7 +62,10 @@ let escape s = let exec dbd s = match dbd with | None -> None - | Some dbd -> Some (profiler.HExtlib.profile (Mysql.exec dbd) s) + | Some dbd -> + try + Some (profiler.HExtlib.profile (Mysql.exec dbd) s) + with Mysql.Error _ -> raise Error let map res ~f = match res with @@ -65,16 +76,23 @@ let map res ~f = let iter res ~f = match res with - | None -> () + | None -> () | Some res -> let iter f = Mysql.iter res ~f in profiler.HExtlib.profile iter f let errno = function - | None -> Mysql.Connection_error - | Some dbd -> profiler.HExtlib.profile Mysql.errno dbd + | None -> GENERIC_ERROR "Mysql.Connection_error" + | Some dbd -> + match Mysql.errno dbd with + | Mysql.No_such_table -> No_such_table + | Mysql.Table_exists_error -> Table_exists_error + | Mysql.Dup_keyname -> Dup_keyname + | Mysql.No_such_table -> No_such_table + | Mysql.No_such_index -> No_such_index + | Mysql.Bad_table_error -> Bad_table_error + | _ -> GENERIC_ERROR "Mysql_generic_error" +;; -let status = function - | None -> Mysql.StatusError Mysql.Connection_error - | Some dbd -> profiler.HExtlib.profile Mysql.status dbd +let isMysql = true