1

In using the erlang mysql module the exposed external functions are:

%% External exports
-export([start_link/5,
   start_link/6,
   start_link/7,
   start_link/8,

   start/5,
   start/6,
   start/7,
   start/8,

   connect/7,
   connect/8,
   connect/9,

   fetch/1,
   fetch/2,
   fetch/3,

   prepare/2,
   execute/1,
   execute/2,
   execute/3,
   execute/4,
   unprepare/1,
   get_prepared/1,
   get_prepared/2,

   transaction/2,
   transaction/3,

   get_result_field_info/1,
   get_result_rows/1,
   get_result_affected_rows/1,
   get_result_reason/1,

   encode/1,
   encode/2,
   asciz_binary/2
  ]).

From the this this, it is not apparent how to close a connection. How a connection closed?

1
  • Note that you can format code as code by indenting it an extra four spaces. The "101\n010" button will do this for you.
    – outis
    Commented Mar 28, 2010 at 10:30

2 Answers 2

1

I quickly browsed through the mysql_driver code. You're right - it doesn't seem to have a mechanism to close opened connections. In fact I actually don't even see proper clean-up code to close the open sockets when a gen_server let's say gets shutdown (in the terminate method).

1
  • Is it really necessary? The sockets will be closed when process terminates. What other cleanup do you mean? Commented Mar 1, 2013 at 10:36
1
{Type, Result} = mysql:start_link(P1, Host, User, Passwd, DB),

stop(Result) closes the connection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.