List Info

Thread: Extra connection parameters for MySQL




Extra connection parameters for MySQL
user name
2007-10-12 07:40:14
Hello Neko,

  I'd like to add a support to extra parameters in mysql
connections.
  In particular, I am interested in connect_timeout
parameter, as it
  usually defaults to 0 and this means nearly infinite
waiting time.
  Any ideas what's the best way to add this? I was thinking
to add a
  parameter specifying the name of my.cnf section to read -
this would
  be relatively simple - but maybe there are better
approaches.

-- 
Best regards,
 Michael                          mailto:mikecomapping.com


-- 
Neko : One VM to run them all
(http://nekovm.org)

Re: Extra connection parameters for MySQL
country flaguser name
France
2007-10-12 11:46:12
Michael Pliskin a écrit :
> Hello Neko,
> 
>   I'd like to add a support to extra parameters in
mysql connections.
>   In particular, I am interested in connect_timeout
parameter, as it
>   usually defaults to 0 and this means nearly infinite
waiting time.

Really ? When the server is down, I think there's still a
timeout, but 
maybe there is no timeout during the time of login'in ?

>   Any ideas what's the best way to add this? I was
thinking to add a
>   parameter specifying the name of my.cnf section to
read - this would
>   be relatively simple - but maybe there are better
approaches.

I'm using the C function mysql_real_connect to connect to
the database.

There is no possibility to do extra configuration here, but
there is a 
"mysql_options" api function that can be called
between "mysql_init" and 
"mysql_real_connect" 
(http://dev.mysql.com/doc/refman/5.0/en/mysql-options.ht
ml)

The best would maybe be to completely wrap each of the
useful 
configuration parameters, but that require some additional
work.

Nicolas

-- 
Neko : One VM to run them all
(http://nekovm.org)

Re: Extra connection parameters for MySQL
user name
2007-10-12 11:49:43
Hello Nicolas,

> Really ? When the server is down, I think there's still
a timeout, but
> maybe there is no timeout during the time of login'in
?

Well this depends on defaults in my.cnf (my.ini) file -
[client]
section is read by all client programs. If nothing is
specified, 0 is
assumed (at least my findings show that). And this timeout
is exactly
for server being down - the way to exploit it is to put a
firewall
between server and client - then client won't be rejected
immediately
like when server is down but will hang forever instead if no
timeout
is specified.

> I'm using the C function mysql_real_connect to connect
to the database.

> There is no possibility to do extra configuration here,
but there is a
> "mysql_options" api function that can be
called between "mysql_init" and
> "mysql_real_connect" 
> (http://dev.mysql.com/doc/refman/5.0/en/mysql-options.ht
ml)

> The best would maybe be to completely wrap each of the
useful 
> configuration parameters, but that require some
additional work.

Well for now I just settled with putting the timeout I need
into
[client] of my.cnf, but in the future it might be nice to
make smth
like 'Additional parameters' structure with all these params
being
set.. I can try to implement this and send a patch
sometimes.

-- 
Best regards,
 Michael                          mailto:mikecomapping.com


-- 
Neko : One VM to run them all
(http://nekovm.org)

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )