Re: Coding issues using FreeTDS/DBD::Sybase in Perl

Brian Menges <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <D83C13F0C853364EB226DBEE584BBE614DACF25638@SERVEPATHMBX.servepath.com>
I did a md5sum on a DBD-Sybase module that I source compiled and the original, they are the same so it appears that they were both compiled with the same options (which my compile specified the SYBASE env variable as /usr/local/freetds).

[root@toolkit DBD-Sybase-1.10]# md5sum Sybase.pm
071ea2c211e5a56134ecd1992dbccf3d  Sybase.pm
[root@toolkit DBD-Sybase-1.10]# md5sum /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Sybase.pm
071ea2c211e5a56134ecd1992dbccf3d  /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Sybase.pm
[root@toolkit DBD-Sybase-1.10]# md5sum /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Sybase.pm.orig
071ea2c211e5a56134ecd1992dbccf3d  /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Sybase.pm.orig

So my stance would be that yes it was compiled and aware of FreeTDS.

Here's the source compile record, looks good to me:
---
[root@toolkit DBD-Sybase-1.10]# export SYBASE=/usr/local/freetds
[root@toolkit DBD-Sybase-1.10]# perl Makefile.PL
Unknown Client Library version - assuming FreeTDS.

By default DBD::Sybase 1.05 and later use the 'CHAINED' mode (where available)
when 'AutoCommit' is turned off. Versions 1.04 and older instead managed
the transactions explicitly with a 'BEGIN TRAN' before the first DML
statement. Using the 'CHAINED' mode is preferable as it is the way that
Sybase implements AutoCommit handling for both its ODBC and JDBC drivers.

Use 'CHAINED' mode by default (Y/N) [Y]:

Running in threaded mode - looking for _r libraries...

***NOTE***
There is an incompatibility between perl (5.8.x) built in threaded mode and
Sybase's threaded libraries, which means that signals delivered to the perl
process result in a segment violation.

I suggest building DBD::Sybase with the normal libraries in this case to get
reasonable behavior for signal handling.

Use the threaded (lib..._r) libraries [N]: y

No thread-safe Sybase libraries found
BLK api NOT available.
The DBD::Sybase module need access to a Sybase server to run the tests.
To clear an entry please enter 'undef'
Sybase server to use (default: SYBASE): xxx.xxx.xxx.xxx
User ID to log in to Sybase (default: sa): brian
Password (default: undef):
Sybase database to use on 192.168.2.36 (default: undef): xxxxxxxxxx

* Writing login information, including password, to file PWD.

Checking if your kit is complete...
Looks good
Note (probably harmless): No library found for -lcs
Note (probably harmless): No library found for -lsybtcl
Note (probably harmless): No library found for -lcomn
Note (probably harmless): No library found for -lintl
Note (probably harmless): No library found for -lblk
Multiple copies of Driver.xst found in: /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI/ /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/auto/DBI/ at Makefile.PL line 65
Using DBI 1.609 (for perl 5.008005 on i386-linux-thread-multi) installed in /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::Sybase
[root@toolkit DBD-Sybase-1.10]# make
cp dbd-sybase.pod blib/lib/DBD/dbd-sybase.pod
cp Sybase.pm blib/lib/DBD/Sybase.pm
/usr/bin/perl -p -e "s/~DRIVER~/Sybase/g" /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI/Driver.xst > Sybase.xsi
/usr/bin/perl /usr/lib/perl5/5.8.5/ExtUtils/xsubpp  -typemap /usr/lib/perl5/5.8.5/ExtUtils/typemap  Sybase.xs > Sybase.xsc && mv Sybase.xsc Sybase.c
gcc -c  -I/usr/local/freetds/include -DNO_THREADS  -DNO_BLK=1 -I/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4   -DVERSION=\"1.10\" -DXS_VERSION=\"1.10\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE"   Sybase.c
gcc -c  -I/usr/local/freetds/include -DNO_THREADS  -DNO_BLK=1 -I/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -m32 -march=i386 -mtune=pentium4   -DVERSION=\"1.10\" -DXS_VERSION=\"1.10\" -fPIC "-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE"   dbdimp.c
Running Mkbootstrap for DBD::Sybase ()
chmod 644 Sybase.bs
rm -f blib/arch/auto/DBD/Sybase/Sybase.so
LD_RUN_PATH="/usr/local/freetds/lib" gcc  -L/usr/local/freetds/lib -shared -L/usr/local/lib Sybase.o dbdimp.o  -o blib/arch/auto/DBD/Sybase/Sybase.so   \
   -L/usr/local/freetds/lib -lct -ldl -lm       \

chmod 755 blib/arch/auto/DBD/Sybase/Sybase.so
cp Sybase.bs blib/arch/auto/DBD/Sybase/Sybase.bs
chmod 644 blib/arch/auto/DBD/Sybase/Sybase.bs
Manifying blib/man3/DBD::Sybase.3
---

After which I backed up my original, replaced it, and no go (same error).  I then did the md5sum and saw that they were exactly the same.

I do see though... that the '.so' files are different:
[root@toolkit DBD-Sybase-1.10]# md5sum blib/arch/auto/DBD/Sybase/Sybase.so /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Sybase/Sybase.so
573d30e025b8678a9c3c34696d959a85  blib/arch/auto/DBD/Sybase/Sybase.so
abfb74a927c6ecdc3dd9f0467345484d  /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Sybase/Sybase.so

---------------------------------------------------------
Brian S. Menges
Support Supervisor / Abuse Administrator
2 Harrison, Suite 200|San Francisco, CA|94105
D 415.869.7000|F 415.869.7001

Making IT Infrastructure: Simpler. Faster. Better.
 Please consider the environment before printing this email.


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Brian Menges
Sent: Friday, June 25, 2010 1:53 PM
To: FreeTDS Development Group
Subject: Re: [freetds] Coding issues using FreeTDS/DBD::Sybase in Perl

No the DBD::Sybase library wasn't source compiled, at least by downloading it specifically then compiling it.  I assume (since I'm inheriting the environment) that it was installed using CPAN, which would have auto-compiled it.  Is there a way to check how it was compiled, or would it be wise to remove the perl module then re-install it?

~B

---------------------------------------------------------
Brian S. Menges
Support Supervisor / Abuse Administrator
2 Harrison, Suite 200|San Francisco, CA|94105
D 415.869.7000|F 415.869.7001

Making IT Infrastructure: Simpler. Faster. Better.
 Please consider the environment before printing this email.


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Gil Rohde
Sent: Friday, June 25, 2010 1:48 PM
To: FreeTDS Development Group
Subject: Re: [freetds] Coding issues using FreeTDS/DBD::Sybase in Perl

Did you compile DBD::Sybase with the freetds libraries?  Make sure you set $SYBASE to the freetds install location and wouldn't hurt to set LD_LIBRARY_PATH as well to the freetds lib directory and then build DBD::Sybase. 

Gil
(Sent from my iPhone)

On Jun 25, 2010, at 2:17 PM, Brian Menges <[email protected]> wrote:

> I'm starting to get a little flustered and according to what I've read in documentation (brief) and examples from web searching, I'm stuck and it is driving me nuts <breath>.
> 
> So let me start with the basics:
> 
> DBD::Sybase version 1.10 loaded from /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Sybase.pm
> 
> 
> [10:03:17]$ tsql -C
> Compile-time settings (established with the "configure" script)
>                            Version: freetds v0.82
>             freetds.conf directory: /usr/local/etc
>     MS db-lib source compatibility: no
>        Sybase binary compatibility: no
>                      Thread safety: yes
>                      iconv library: yes
>                        TDS version: 5.0
>                              iODBC: no
>                           unixodbc: no
> 
> [10:59:43]$ ls -la /usr/local/etc/freetds.conf 
> lrwxrwxrwx  1 root root 25 Feb 15  2006 /usr/local/etc/freetds.conf -> /etc/freetds/freetds.conf
> 
> [11:02:08]$ cat /etc/freetds/freetds.conf
> [global]
>        tds version = 4.2
>        initial block size = 512
>        swap broken dates = no
>        swap broken money = no
>        try server login = yes
>        try domain login = no
>        cross domain login = no
>        text size = 64512
> 
> [griddbstage]
>    host = griddbstage
>    port = 1433
>    tds version = 7.0
> 
> --
> 
> Now, with the above configuration I can connect using the command line to my database:
> 
> [11:02:30]$ tsql -S griddbstage -U brian -D gogrid
> locale is "en_US.UTF-8"
> locale charset is "UTF-8"
> Password: 
> Default database being set to gogrid
> 1> exit
> 
> But attempts to use perl have resulted in a message that plagued me earlier at the command line:
> 
> use DBI;
> ...
> DBI->trace(4);
> my $c_ggdb = DBI->connect("DBI:Sybase:$dbserv",$dbuser,$dbpass)
> or die "Cannot log into $dbserv\n";
> ...
> 
> With the trace as follows:
> 
> ---
>    DBI 1.609-ithread default trace level set to 0x0/4 (pid 26790) at ggsmtp.pl line 106
>    -> DBI->connect(DBI:Sybase:griddbstage, brian, ****)
>    -> DBI->install_driver(Sybase) for linux perl=5.008005 pid=26790 ruid=2632 euid=2632
>       install_driver: DBD::Sybase version 1.10 loaded from /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBD/Sybase.pm
>    <- install_driver= DBI::dr=HASH(0x977dc84)
>    !! warn: 0 CLEARED by call to connect method
>    -> connect for DBD::Sybase::dr (DBI::dr=HASH(0x977dc84)~0x977de70 'griddbstage' 'brian' **** HASH(0x96af038)) thr#9362008
>    syb_db_login() -> using global CS_LOCALE data
>    clientmsg_cb -> Unable to connect: Adaptive Server is unavailable or does not exist
>    <> DESTROY(DBI::db=HASH(0x9783bf0)) ignored for outer handle (inner DBI::db=HASH(0x9783b90) has ref cnt 1)
>    -> DESTROY for DBD::Sybase::db (DBI::db=HASH(0x9783b90)~INNER) thr#9362008
>         DESTROY for DBI::db=HASH(0x9783b90) ignored - handle not initialised
>       ERROR: 41 'OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
> Server griddbstage, database
> Message String: Unable to connect: Adaptive Server is unavailable or does not exist
> ' (err#0)
>    <- DESTROY= undef at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI.pm line 653 via  at ./ggsmtp.pl line 107
>    dbih_clearcom 0x9783b90 (com 0x9784300, type 2) done.
> 
>    !! ERROR: 41 'OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
> Server griddbstage, database
> Message String: Unable to connect: Adaptive Server is unavailable or does not exist
> ' (err#0)
>    <- connect= undef at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI.pm line 653
>    -> $DBI::errstr (&) FETCH from lasth=HASH
>>> DBD::Sybase::dr::errstr
>    <- $DBI::errstr= 'OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
> Server griddbstage, database
> Message String: Unable to connect: Adaptive Server is unavailable or does not exist
> '
>       DBI connect('griddbstage','brian',...) failed: OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
> Server griddbstage, database
> Message String: Unable to connect: Adaptive Server is unavailable or does not exist
> 
> DBI connect('griddbstage','brian',...) failed: OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (41)
> Server griddbstage, database
> Message String: Unable to connect: Adaptive Server is unavailable or does not exist
> at ./ggsmtp.pl line 107
> Cannot log into griddbstage
>    -- DBI::END ($@: , $!: )
>    !! ERROR: 41 CLEARED by call to disconnect_all method
>    -> disconnect_all for DBD::Sybase::dr (DBI::dr=HASH(0x977dc84)~0x977de70) thr#9362008
>    <- disconnect_all= 1 at /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/DBI.pm line 732 via  at ./ggsmtp.pl line 0
> !   <> DESTROY(DBI::dr=HASH(0x977dc84)) ignored for outer handle (inner DBI::dr=HASH(0x977de70) has ref cnt 1)
> !   -> DESTROY in DBD::_::common for DBD::Sybase::dr (DBI::dr=HASH(0x977de70)~INNER) thr#9362008
> !   <- DESTROY= undef during global destruction
>    dbih_clearcom 0x977de70 (com 0x97813a8, type 1) done.
> ---
> 
> I'm not sure if this is the right place to be asking this, because I can force my perl program down to system cmd line and read from there... but I shouldn't have to kluge this.  Should I be addressing this with DBD::Sybase or here?  I'm horribly confused, and wondering if I'm just missing something stupidly obvious.
> 
> Appreciate the help.
> 
> ---------------------------------------------------------
> Brian S. Menges
> Support Supervisor / Abuse Administrator
> 2 Harrison, Suite 200|San Francisco, CA|94105
> D 415.869.7000|F 415.869.7001
> 
> Making IT Infrastructure: Simpler. Faster. Better.
>  Please consider the environment before printing this email.
> _______________________________________________
> FreeTDS mailing list
> [email protected]
> http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.