Dear all,

I experienced some problems with using MySQL API:
My problem is that if I don't use database a long time it is disconnected and when I 
try to connect again at first I use method mysql_ping(), which reopens connection and 
that's the point. Please see next code of MySQL API:

static my_bool mysql_reconnect(MYSQL *mysql)
{
  MYSQL tmp_mysql;      
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
local variable
  DBUG_ENTER("mysql_reconnect");

  if (!mysql->reconnect ||
      (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
  {
   /* Allov reconnect next time */
    mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
    DBUG_RETURN(1);
  }
  mysql_init(&tmp_mysql);
  tmp_mysql.options=mysql->options;
  bzero((char*) &mysql->options,sizeof(mysql->options));
  if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
                          mysql->db, mysql->port, mysql->unix_socket,
                          mysql->client_flag))
    DBUG_RETURN(1);
  tmp_mysql.free_me=mysql->free_me;
  mysql->free_me=0;
  mysql_close(mysql);
  *mysql=tmp_mysql;     
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
the in/out param is pointed to local variable. What's a wilderness?!?
  net_clear(&mysql->net);
  mysql->affected_rows= ~(my_ulonglong) 0;
  DBUG_RETURN(0);
}

This code was downloaded from www.mysql.com (today - 4th Feb 2002).
Is it really a bug or I just overlooked something? Thanks in advance!

Best regards
Gregor Skriniar

SIEMENS AG
ICM N PG U SE D6
D-13629 Berlin

Phone: +49 30 386 49590 
Fax: +49 30 386 49118
Email: [EMAIL PROTECTED]




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to