On May 7, 12:47 am, Cyril Rohr <[email protected]> wrote:
> Hello everyone,
>
> When contacting a distant mysql server, I noticed that the sequel
> connect call hangs a long time before failing with the Mysql 110 error
> (connection timeout) when the server is down. I looked at the Mysql
> documentation for timeout options and it appears that a "connect-
> timeout" is available that allows to set a timeout for establishing
> the connection (in my case I don't want to wait more than 3 seconds).
> This timeout is different from the timeout that can be set via the
> "connect" method of the Mysql adapter in Sequel (server-side
> timeout).
> This "connect-timeout" option (and a lot of other options) can be set
> in the mysql configuration file (/etc/my.cnf on Debian), under the
> [client] flag.
>
> However, this configuration file doesn't seem to be taken into account
> by the sequel Mysql adapter. Reading the Mysql adapter source code, I
> noticed the following line at line 60 in mysql.rb:
>   conn.options(Mysql::OPT_LOCAL_INFILE, "client")
> which is the only option passed to the ruby mysql library. The problem
> is that, according to the mysql doc, the OPT_LOCAL_INFILE option
> allows for enabling the LOAD DATA INFILE directive [2]. I cannot see
> why this is an interesting option to enable, especially since the
> value that is passed to the mysql ruby library is "client", which
> doesn't mean anything.
> I guess the name of the option to pass should have been:
>   conn.options(Mysql::READ_DEFAULT_GROUP, "client")
> which effectively asks to read the options defined under the [client]
> tag in the mysql configuration file. Applying the attached patch, the
> options defined in the mysql configuration file are now taken into
> account.
>
> I really think we have a mismatch between names of the options, but if
> anyone has more info about the purpose of the original option, please
> do not hesitate to respond !
>
> Cyril
>
> [1]http://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
> [2]http://dev.mysql.com/doc/refman/5.1/en/load-data.html
>
> My Configuration:
> Debian GNU/Linux 5.0.1 (lenny)
> libmysql-ruby1.8
> sequel 3.0.0
>
> Patch:
> diff --git a/lib/sequel/adapters/mysql.rb b/lib/sequel/adapters/
> mysql.rb
> index 180a8ca..962f3fb 100644
> --- a/lib/sequel/adapters/mysql.rb
> +++ b/lib/sequel/adapters/mysql.rb
> @@ -79,7 +79,8 @@ module Sequel
>        def connect(server)
>          opts = server_opts(server)
>          conn = Mysql.init
> -        conn.options(Mysql::OPT_LOCAL_INFILE, "client")
> +        # reads additional options defined under the [client] tag in
> the mysql configuration file
> +        conn.options(Mysql::READ_DEFAULT_GROUP, "client")
>          if encoding = opts[:encoding] || opts[:charset]
>            # set charset _before_ the connect. using an option instead
> of "SET (NAMES|CHARACTER_SET_*)" works across reconnects
>            conn.options(Mysql::SET_CHARSET_NAME, encoding)

I plan to commit this unless a MySQL user here has an objection.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to