Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: deadlock detection in CTlib
Date: Feb 26 1998 3:55PM wrote:
> Michael
> How would I do deadlock detection with Sybase::CTlib. I know how to use
> dbgetuser
> data in DBlib but appart from ct_diag which I do not think is implemented
> how would I
> do this? Could this be a feature to put in?

The way I would normally do it doesn't currently work in CTlib
because the handle attributes aren't accessible in the server
callback. They will be in the next release, though (no, I don't know
when 2.10 will be released).

The way I'd do it goes something like this (remember this does
NOT work at the moment with Sybase::CTlib):

Create the connection with an additional hash variable, where you store
the latest error, as well as the latest SQL that was sent to the server:

$dbh = new Sybase::CTlib user, pwd, server, undef, { ERROR=>0, SQL=>''};

Now when you submit a query you do something like

$sql = 'insert foo values(...)';
$dbh->{SQL} = $sql;
while(($ret = $dbh->ct_execute) != CS_SUCCEED && $dbh->{ERROR} == 1205)
	print "retrying\n";
if($ret != CS_SUCCEED) {
	die "this really broke!";
while(($ret = $dbh->ct_results($restype)) == CS_SUCCEED) {
if($ret == CS_FAIL && $dbh->{ERROR} = 1205) {
	goto TRY_AGAIN;

And in the server callback it take the error no and set $dbh->{ERROR}.

You can still do this if you only have one open connection to Sybase,
as you can ignore the connection handle that comes in as an argument to
the callback and set the ERROR hash element of a global handle variable

Michael Peppler         -||-  Data Migrations Inc.    -||-
Int. Sybase User Group  -||-