[freetds] Re: ping doesn't seem to work

Michael Peppler mpeppler at peppler.org
Thu Aug 26 02:15:04 EDT 2004


On Wed, 2004-08-25 at 22:40, Brian Millett wrote:
>     sub ping {
> 	my $dbh = shift;
> 	return 0 if DBD::Sybase::db::_isdead($dbh);
> 
> 	# Use "select 1" suggested by Henri Asseily.
> 	my $sth = $dbh->prepare("select 1");
> 
> 	return 0 if !$sth;
> 
> 	my $rc = $sth->execute;
> 	
> 	return 0 if(!defined($rc) && DBD::Sybase::db::_isdead($dbh));
> 
> 	$sth->finish;
> 	return 1;
>     }
> 
> Michael, I've noticed that the ping routine doesn't work with freetds.
> I'm using DBD-Sybase-1.0.4.6 with freetds-0.62.1-1 on a linux box to
> talk to a SQLServer 2000 box.  When the db goes down, the return code
> from DBD::Sybase::db::_isdead($dbh) is still 0.

I guess the problem is that FreeTDS's CTlib doesn't appear to report
that a connection has been disconnected in the clientmsg callback.
DBD::Sybase uses the following code:

static CS_RETCODE CS_PUBLIC
clientmsg_cb(context, connection, errmsg)
CS_CONTEXT	*context;
CS_CONNECTION	*connection;	
CS_CLIENTMSG	*errmsg;
{
....
	if(CS_NUMBER(errmsg->msgnumber) == 6) { /* disconnect */
	    imp_dbh->isDead = 1;
	}
...
}

Maybe someone on the freetds list can check into this to see if MS-SQL
reports the same error number for this situation (i.e. when a request is
made on a connection where the server has gone away.)

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
mpeppler at peppler.org                       http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions - http://www.peppler.org/resume.html




More information about the FreeTDS mailing list