|
|
sybperl-l Archive
Up Prev Next
From: Marc Merlin <marcm at magic dot metawire dot com>
Subject: Re: How to find out when you're killed because of a deadlock?
Date: Apr 9 1998 11:15PM
On Thu, Apr 09, 1998 at 09:35:23AM -0400, David C Worenklein wrote:
>
> The answer is in the Sybase manuals, if you know where to look.
I am the RTFM kind of guy, but I'm not the Sybase DBA, so I don't have the
said manuals :-) (I did ask the DBA though, but he didn't know).
> Create your Sybase handle thus:
>
> my $db = new Sybase::DBlib($USER, $PWD, $SERVER, $APPNAME, {DEADLOCK => 0});
>
> Use this message handler:
>
> sub SybMsgHandler {
> my ($db, $message, $state, $severity, $text, $server, $procedure, $line) = @_;
Cool, good to know. Maybe it would be a good thing to add this to the manual
page, there is no mention of that command anywhere...
And Michael Peppler added:
> Whether dbsqlexec() returns FAIL for a problem or not depends on the
> query. If there is only one result set, dbsqlexec() will *normally*
Yes, I always launch queries one at a time.
> return FAIL, but you should always check the return code from
> dbresults() too (which will return FAIL if the query failed for any
> reason and dbsqlexec() returned SUCCEED).
I understand now that the Sybperl documentation is meant for those who know
Sybase well, or at least its C API (I suppose that Sybperl is something very
similar).
However, it would maybe be a good idea to provide a safe snipplet of code in
the man page, that people can re-use.
Something along of the lines of:
$db->dbcmd($query);
($db->dbsqlexec == &SUCCEED) or die "Problem with the following query: \"$query\": $!";
# During a deadlock, dbsqlexec can unfortunately return SUCCEED, so we also
# need to make sure that dbresults is different from FAIL
($db->dbresults != FAIL) or die "The following query failed: \"$query\": $!";
The minor problem is that this piece of code still doesn't seem to work
(meaning, I'm 98% sure that I had another undetected deadlock)
Can I test $db->dbresults against &SUCCEED instead?
Thanks a whole lot to the both of you, and the other ones who replied
Marc
--
Home page: http://magic.metawire.com/~merlin/ (browser friendly)
Finger merlin@magic.metawire.com for PGP key (key id 763BE901)
***** "God is real, unless declared integer." *****
|