PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "W dot Phillip Moore" <wpm at ms dot com>
Subject: [PATCH] sybperl-2.10_01, nsql() bugs, other miscellany
Date: May 12 1999 4:10PM

The patch below is meant to be applied on top of the latest source
release at Michael's home page (sybperl-2.10_01) and provides the
following fixes and enhancements:

[*] nsql() bug: deadlock retry logic

Someone here jumped on this, since they were able to reliably
reproduce a deadlock scenario, and quickly found that the logic was
broken.  I was using next inside a labeled block, and should have
been using redo.  Oops.  :-/

[*] nsql() bug: per-row callback routine

If the data type is specified as HASH, this works.  If you give ARRAY,
then the data isn't passed at all (wrong variable).  That's what I get
for only testing HASH .  Oops again.

[*] Sybase::BCP exports $DB_ERROR

This allows the nsql() method to be used with Sybase::BCP objects,
which inherit from Sybase::DBlib.  The use of a global like this, one
could certainly argue is bad OO design, I suppose.  But it is what it
is (there's good reason, actually -- seperate discussion if you care
to know).

[*] CTlib/Makefile.PL: use of reentrant libs only on Solaris

The code will use the _r version of the ctlib libraries, if they
exist.  This is only know to link correctly on Solaris, and breaks
horribly with the libraries provided on IRIX, so the code is
restricted to Solaris.

[*] sybperl.pod

Labelled a few more things with =head2 directives, which gives a bit
more detail in the index built at the top of the page by pod2html.  

Now, in addition to applying this patch, if one does the following:

cd sybperl-2.10_01
ln -s ../pod/sybperl.pod CTlib/CTlib.pod
ln -s ../pod/sybperl.pod DBlib/DBlib.pod
ln -s ../pod/sybperl.pod Sybperl/Sybperl.pod

then MakeMaker will automagically build the corresponding man pages
for the docs as well (I recall someone had asked about this a
while back).

Michael, as before, please apply this to your master source archive.

diff -rc sybperl-2.10_01-orig/BCP/BCP.pm sybperl-2.10_01/BCP/BCP.pm
*** sybperl-2.10_01-orig/BCP/BCP.pm	Thu Mar  5 19:26:32 1998
--- sybperl-2.10_01/BCP/BCP.pm	Wed May 12 11:00:05 1999
***************
*** 281,287 ****
  use vars qw(@ISA @EXPORT $VERSION $Version);
  
  @ISA = qw(Exporter Sybase::DBlib);
! @EXPORT = qw(dbmsghandle dberrhandle TRUE FALSE INT_CANCEL SYBESMSG);
  
  use strict;
  
--- 281,287 ----
  use vars qw(@ISA @EXPORT $VERSION $Version);
  
  @ISA = qw(Exporter Sybase::DBlib);
! @EXPORT = qw(dbmsghandle dberrhandle TRUE FALSE INT_CANCEL SYBESMSG $DB_ERROR);
  
  use strict;
  
diff -rc sybperl-2.10_01-orig/CTlib/Makefile.PL sybperl-2.10_01/CTlib/Makefile.PL
*** sybperl-2.10_01-orig/CTlib/Makefile.PL	Fri Mar 26 18:43:36 1999
--- sybperl-2.10_01/CTlib/Makefile.PL	Wed May 12 11:07:45 1999
***************
*** 42,48 ****
      # Logic to replace normal libs with _r (re-entrant) libs if
      # usethreads is defined provided by W. Phillip Moore (wpm@ms.com)
      # I have no idea if this works on Win32 systems (probably not!)
!     if ( $Config{usethreads} eq 'define' ) {
  	opendir(SYBLIB,"$SYBASE/lib")
  	    or die "Unable to opendir $SYBASE/lib: $!\n";
  	
--- 42,48 ----
      # Logic to replace normal libs with _r (re-entrant) libs if
      # usethreads is defined provided by W. Phillip Moore (wpm@ms.com)
      # I have no idea if this works on Win32 systems (probably not!)
!     if ( $Config{usethreads} eq 'define' && $Config{osname} =~ /solaris/ ) {
  	opendir(SYBLIB,"$SYBASE/lib")
  	    or die "Unable to opendir $SYBASE/lib: $!\n";
  	
diff -rc sybperl-2.10_01-orig/DBlib/DBlib.pm sybperl-2.10_01/DBlib/DBlib.pm
*** sybperl-2.10_01-orig/DBlib/DBlib.pm	Fri Mar 26 13:51:57 1999
--- sybperl-2.10_01/DBlib/DBlib.pm	Wed May 12 11:05:06 1999
***************
*** 421,427 ****
  		    carp "SQL deadlock encountered.  Retrying...\n" if $retryverbose;
  		    undef $DB_ERROR;
  		    sleep($retrysleep);
! 		    next DEADLOCK;
  		}
  		else {
  		    carp "SQL deadlock retry failed $nsql_deadlock_retrycount times.  Aborting.\n"
--- 441,447 ----
  		    carp "SQL deadlock encountered.  Retrying...\n" if $retryverbose;
  		    undef $DB_ERROR;
  		    sleep($retrysleep);
! 		    redo DEADLOCK;
  		}
  		else {
  		    carp "SQL deadlock retry failed $nsql_deadlock_retrycount times.  Aborting.\n"
***************
*** 442,448 ****
  		    undef $DB_ERROR;
  		    @res = ();
  		    sleep($retrysleep);
! 		    next DEADLOCK;
  		}
  		else {
  		    carp "SQL deadlock retry failed $nsql_deadlock_retrycount times.  Aborting.\n"
--- 462,468 ----
  		    undef $DB_ERROR;
  		    @res = ();
  		    sleep($retrysleep);
! 		    redo DEADLOCK;
  		}
  		else {
  		    carp "SQL deadlock retry failed $nsql_deadlock_retrycount times.  Aborting.\n"
***************
*** 470,476 ****
  		while ( @data = $db->dbnextrow ) {
  		    grep(s/\s+$//g,@data) if $nsql_strip_whitespace;
  		    if ( ref $callback eq "CODE" ) {
! 			unless ( $callback->(%data) ) {
  			    $db->dbcancel();
  			    $DB_ERROR = "User-defined callback subroutine failed\n";
  			    return;
--- 490,496 ----
  		while ( @data = $db->dbnextrow ) {
  		    grep(s/\s+$//g,@data) if $nsql_strip_whitespace;
  		    if ( ref $callback eq "CODE" ) {
! 			unless ( $callback->(@data) ) {
  			    $db->dbcancel();
  			    $DB_ERROR = "User-defined callback subroutine failed\n";
  			    return;
diff -rc sybperl-2.10_01-orig/pod/sybperl.pod sybperl-2.10_01/pod/sybperl.pod
*** sybperl-2.10_01-orig/pod/sybperl.pod	Fri Mar 26 18:41:13 1999
--- sybperl-2.10_01/pod/sybperl.pod	Wed May 12 11:41:37 1999
***************
*** 506,512 ****
  
  =back
  
! =head2 BCP Routines:
  
  See also the B module.
  
--- 506,512 ----
  
  =back
  
! =head2 BCP Routines
  
  See also the B module.
  
***************
*** 590,596 ****
  
  =back
  
! B
  
  B In this version it is possible to avoid calling the routines
  below and still get B calculations done with the correct
--- 590,596 ----
  
  =back
  
! =head2 DBMONEY Routines
  
  B In this version it is possible to avoid calling the routines
  below and still get B calculations done with the correct
***************
*** 653,659 ****
  
  =back
  
! B
  
  B Check out eg/rpc-example.pl for an example on how to use
  these calls.
--- 653,659 ----
  
  =back
  
! =head2 RPC Routines
  
  B Check out eg/rpc-example.pl for an example on how to use
  these calls.
***************
*** 690,696 ****
  
  =back
  
! B
  
  =over 8
  
--- 690,696 ----
  
  =back
  
! =head2 Registered procedure execution
  
  =over 8
  
***************
*** 708,714 ****
  
  =back
  
! B
  
  =over 8
  
--- 708,714 ----
  
  =back
  
! =head2 Two Phase Commit Routines
  
  =over 8
  
***************
*** 736,742 ****
  
  =back
  
! B
  
  =over 8
  
--- 736,742 ----
  
  =back
  
! =head2 Exported Routines
  
  =over 8
  
***************
*** 787,793 ****
  
  =back
  
! B
  
  These routines are not part of the DB-library API, but have been added
  because they can make our life as programers easier, and exploit
--- 787,793 ----
  
  =back
  
! =head2 High Level Wrapper Functions (sql() and nsql())
  
  These routines are not part of the DB-library API, but have been added
  because they can make our life as programers easier, and exploit
***************
*** 987,996 ****
  the retries fail, then nsql() will return an error, like it normally
  does.  If you want the code to try forever, then set the retry count
  to -1.
!   
  =back
  
! B
  
  Most of the #defines from sybdb.h can be accessed as
  B (eg B) Additional constants are:
--- 987,996 ----
  the retries fail, then nsql() will return an error, like it normally
  does.  If you want the code to try forever, then set the retry count
  to -1.
! 
  =back
  
! =head2 Constants
  
  Most of the #defines from sybdb.h can be accessed as
  B (eg B) Additional constants are:
***************
*** 1007,1013 ****
  
  =back
  
! =head2 Attributes:
  
  The behaviour of certain aspects of the Sybase::CTlib module can be
  controled via global or connection specific attributes. The global
--- 1007,1013 ----
  
  =back
  
! =head2 Attributes
  
  The behaviour of certain aspects of the Sybase::CTlib module can be
  controled via global or connection specific attributes. The global