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: Scott Edwards <supadupa at gmail dot com>
Subject: DBI->connect aka DBD::Sybase::db::_login fails with "no error string" - patch included
Date: Aug 24 2005 10:41PM

DBI.pm is returning a literal "no error string" in $DBI::errstr after
I attempt to connect to a mssql server.  I've provided source
snippets, dbi trace output, and a patch I've made in an attempt to
more clearly isolate the problem.  As far as I can guess, I think the
_login function exists in XS code.  I have no idea why it's passing
back a failure response, but not providing a helpfull error message
with it. ("it's broke" is about as usefull.)

My discovered answers from the Radiator mailing list, Google and
elsewhere are slim to none.  I'm working on a migration script to
siphon accounts stored in platypus, then carry on from there.

If someone has any suggestions to allow this to connect to the
database, please let me know.

I'm using:

FreeBSD 5.4-RELEASE x86 GENERIC kernel
${ENV}SYBASE = /usr/local
perl v5.8.7
Sybase.pm 1.02 (with my patch, down below)
FreeTDS 0.63

script snippet (greatly simplified)

@sqldsn = ("dbi:Sybase:platypus","platypus","******");  # masked - duh :)
DBI->connect(@sqldsn) or die($DBI::errstr);
die ($DBI::errstr) if ($DBI::errstr);

/usr/local/etc/freetds/freetds.conf
[platypus]
        host = 192.168.194.5
        port = 1433
        tds version = 8.0

Thank you,


Scott

======= DBI->trace(5) output:

    DBI 1.48-nothread default trace level set to 0x0/5 (pid 19397)
    -> DBI->connect(dbi:Sybase:platypus, platypus, ****)
    -> DBI->install_driver(Sybase) for freebsd perl=5.008007 pid=19397
ruid=3104 euid=3104
    syb_init() -> DBD::Sybase 1.02 initialized
    OpenClient version: freetds v0.63
       install_driver: DBD::Sybase version 1.02 loaded from
/usr/local/lib/perl5/site_perl/5.8.7/mach/DBD/Sybase.pm
    New DBI::dr (for DBD::Sybase::dr, parent=, id=)
    dbih_setup_handle(DBI::dr=HASH(0x8142924)=>DBI::dr=HASH(0x81c8460),
DBD::Sybase::dr, 0, Null!)
    dbih_make_com(Null!, 0, DBD::Sybase::dr, 88, 0) thr#0
    dbih_setup_attrib(DBI::dr=HASH(0x81c8460), Err, Null!)
SCALAR(0x81bf67c) (already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x81c8460), State, Null!)
SCALAR(0x81bf6c4) (already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x81c8460), Errstr, Null!)
SCALAR(0x81bf6a0) (already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x81c8460), TraceLevel, Null!) 0
(already defined)
    dbih_setup_attrib(DBI::dr=HASH(0x81c8460), FetchHashKeyName,
Null!) 'NAME' (already defined)
    <- install_driver= DBI::dr=HASH(0x8142924)
    !! warn: 0 CLEARED by call to connect method
    -> connect for DBD::Sybase::dr (DBI::dr=HASH(0x8142924)~0x81c8460
'platypus' 'platypus' **** HASH(0x81c879c))
Sybase.pm 79 drh= $VAR1 = bless( {
                 'Attribution' => 'Sybase DBD by Michael Peppler',
                 'FetchHashKeyName' => 'NAME',
                 'TraceLevel' => 0,
                 'ImplementorClass' => 'DBD::Sybase::dr',
                 'State' => \undef,
                 'Version' => '1.02',
                 'Errstr' => \undef,
                 'Name' => 'Sybase',
                 'Err' => \undef
               }, 'DBI::dr' );

         database= platypus
         user= platypus
         auth= ******
         attr= $VAR1 = {
          'AutoCommit' => 1,
          'Username' => 'platypus',
          'PrintError' => 1
        };

    New DBI::db (for DBD::Sybase::db, parent=DBI::dr=HASH(0x81c8460), id=)
    dbih_setup_handle(DBI::db=HASH(0x818d34c)=>DBI::db=HASH(0x81c87cc),
DBD::Sybase::db, 813865c, Null!)
    dbih_make_com(DBI::dr=HASH(0x81c8460), 8199610, DBD::Sybase::db,
2028, 0) thr#0
    dbih_setup_attrib(DBI::db=HASH(0x81c87cc), Err,
DBI::dr=HASH(0x81c8460)) SCALAR(0x8142e70) (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x81c87cc), State,
DBI::dr=HASH(0x81c8460)) SCALAR(0x8142ed0) (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x81c87cc), Errstr,
DBI::dr=HASH(0x81c8460)) SCALAR(0x8142ea0) (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x81c87cc), TraceLevel,
DBI::dr=HASH(0x81c8460)) 0 (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x81c87cc), FetchHashKeyName,
DBI::dr=HASH(0x81c8460)) 'NAME' (already defined)
    dbih_setup_attrib(DBI::db=HASH(0x81c87cc), HandleSetErr,
DBI::dr=HASH(0x81c8460)) undef (not defined)
    dbih_setup_attrib(DBI::db=HASH(0x81c87cc), HandleError,
DBI::dr=HASH(0x81c8460)) undef (not defined)
    -> FIRSTKEY in DBD::_::common for DBD::Sybase::db
(DBI::db=HASH(0x81c87cc)~INNER)
    <- FIRSTKEY= undef at
/usr/local/lib/perl5/5.8.7/mach/Data/Dumper.pm line 167 via
/usr/local/lib/perl5/5.8.7/mach/Data/Dumper.pm line 496
  91: DBI::_new_dbh(...) returns $VAR1 = bless( {}, 'DBI::db' );

  93: Performing DBD::Sybase::db::_login(...) (no success implies fail)
    <> DESTROY(DBI::db=HASH(0x818d34c)) ignored for outer handle
(inner DBI::db=HASH(0x81c87cc) has ref cnt 1)
    -> DESTROY for DBD::Sybase::db (DBI::db=HASH(0x81c87cc)~INNER)
         DESTROY for DBI::db=HASH(0x81c87cc) ignored - handle not initialised
    <- DESTROY= undef at
/usr/local/lib/perl5/site_perl/5.8.7/mach/DBI.pm line 598 via ./radius
line 74
    dbih_clearcom 0x818d34c (com 0x81bb804, type 2) done.

    <- connect= undef at
/usr/local/lib/perl5/site_perl/5.8.7/mach/DBI.pm line 598 via ./radius
line 64
    -> $DBI::errstr (&) FETCH from lasth=HASH
    >> DBD::Sybase::dr::errstr
    <- $DBI::errstr= undef
       DBI connect('platypus','platypus',...) failed: (no error string)
    -> $DBI::errstr (&) FETCH from lasth=HASH
    >> DBD::Sybase::dr::errstr
    <- $DBI::errstr= undef
$VAR1 = {
          'trace' => '42: eval{...} failed near line 108: Carp
/usr/local/lib/perl5/5.8.7/Carp.pm 271 DBI
connect(\'platypus\',\'platypus\',...) failed: (no error string) at
./radius line 74

',
          'eval' => 'Carp /usr/local/lib/perl5/5.8.7/Carp.pm 271 DBI
connect(\'platypus\',\'platypus\',...) failed: (no error string) at
./radius line 74
'
        };
    -- DBI::END
    -> disconnect_all for DBD::Sybase::dr (DBI::dr=HASH(0x8142924)~0x81c8460)
    <- disconnect_all= 1 at
/usr/local/lib/perl5/site_perl/5.8.7/mach/DBI.pm line 677 via ./radius
line 0
!   <> DESTROY(DBI::dr=HASH(0x8142924)) ignored for outer handle
(inner DBI::dr=HASH(0x81c8460) has ref cnt 1)
!   -> DESTROY in DBD::_::common for DBD::Sybase::dr
(DBI::dr=HASH(0x81c8460)~INNER)
!   <- DESTROY= undef during global destruction
    dbih_clearcom 0x8142924 (com 0x8199610, type 1) done.


===== 
supaplex@omni$ diff -u Sybase.pm.bak Sybase.pm
--- Sybase.pm.bak       Wed Dec 24 12:15:35 2003
+++ Sybase.pm   Wed Aug 24 15:22:38 2005
@@ -76,6 +76,11 @@
        my $ifile = '';
        my $server = $dbase || $ENV{DSQUERY} || 'SYBASE';

+       DBI->trace_msg("Sybase.pm ".__LINE__." drh=
".Data::Dumper::Dumper($drh)."\n",1);
+       DBI->trace_msg("\t database= $server"."\n",1);
+       DBI->trace_msg("\t user= $user\n",1);
+       DBI->trace_msg("\t auth= " . "*" x length($auth) ."\n",1);
+       DBI->trace_msg("\t attr= ".Data::Dumper::Dumper($attr)."\n",1);

         my($this) = DBI::_new_dbh($drh, {
            'Name' => $server,
@@ -83,7 +88,14 @@
            'CURRENT_USER' => $user,
            });

-       DBD::Sybase::db::_login($this, $server, $user, $auth, $attr)
or return undef;
+       DBI->trace_msg("  ".__LINE__.': DBI::_new_dbh(...) returns
'.Data::Dumper::Dumper($this)."\n",1);
+
+       DBI->trace_msg("  ".__LINE__.": Performing
DBD::Sybase::db::_login(...) (no success implies fail)\n" ,1);
+
+       DBD::Sybase::db::_login($this, $server, $user, $auth, $attr)
+               or return undef;
+
+       DBI->trace_msg("  ".__LINE__.': DBD::Sybase::db::_login(...)
success' ,1);

        # OK - let us see what sort of server we're connected to. We
        # need this because some of the SQL commands that we need to send
@@ -95,9 +107,11 @@
                if($row->[0] =~ /microsoft/i) {
                    $this->{syb_server_version} = -1;
                    #warn "Connected to MS-SQL\n";
+                   DBI->trace_msg("  ".__LINE__.': Connected to MS-SQL' ,3);
                } elsif($row->[0] =~ /adaptive server enterprise\/([\d\.]+)/i ||
                       $row->[0] =~ /sql server\/([\d\.]+)/i) {
                    $this->{syb_server_version} = $1;
+                   DBI->trace_msg("  ".__LINE__.': Connected to Sybase' ,3);
                    #warn "Connected to Sybase\n";
                }
            }