ygrek / ocaml-mysql

OCaml bindings to libmysqlclient
https://ygrek.org.ua/p/ocaml-mysql
GNU Lesser General Public License v2.1
23 stars 11 forks source link

incorrect error code on mysql restart #2

Closed ygrek closed 7 years ago

ygrek commented 9 years ago

moved from https://forge.ocamlcore.org/tracker/index.php?func=detail&aid=1463&group_id=137&atid=630

(installed version 1.2.0 from opam)

 $ ocaml
 OCaml version 4.02.1

 # #use "topfind";;
 [...]
 # #require "mysql";;
 /home/gds/.opam/4.02.1/lib/mysql: added to search path
 /home/gds/.opam/4.02.1/lib/mysql/mysql.cma: loaded

 # let dbh = Mysql.quick_connect ~user:"user" ~password:"password" ();;
 val dbh : Mysql.dbd = <abstr>

 (* now execute "sudo service mysql restart" from another console, then continue in ocaml toplevel *)

 # let stmt = Mysql.Prepared.create dbh "select 1";;
 Exception:
 Mysql.Error
 "Mysql.Prepared.create : mysql_stmt_prepare = 1. Query : select 1. Error : MySQL server has gone away".

 (* look, error description is correct *)

 # Mysql.errno dbh;;
 - : Mysql.error_code = Mysql.Unknown_error

 (* but error code is not. There should be Server_gone_error, Server_lost or Server_shutdown, or something that indicates connection error. *)
ygrek commented 9 years ago

@gdsfh I guess this is the problem in libmysqlclient, not much we can do about it. Can you write a C program that performs the same calls but shows correct error code?

ygrek commented 7 years ago

I believe it is how libmysqlclient works in such case, please reopen if it is not the case.