Re: issues connecting with perl DBD::ODBC

"Kulik, Scott" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <367B33A3B0BA27429CC76B74A71EECC44A1A68@snaex01.ms.severstalna.com>
Michael Higgins you are the man!  I was able to export LD_BIND_NOW=1 and
the script ran with no problems the first time!  I was also able to use
the DSN in my DBI connect statement:

my $dbh = DBI->connect('dbi:ODBC:PTT', 'user', 'pass', {PrintError =>
0});

However, like you mentioned...if I wanted to set the environment
variable in the perl code I had to put in a BEGIN block like the
following:

BEGIN {
        $ENV{'PERL_DL_NONLAZY'} = 1;
}

This should probably be noted on the documentation pages since I assume
anyone running a similar linux such as redhat 3 will experience the same
issue.

Also, I did try removing the tabs from the odbc.ini but that didn't seem
to help.  Thanks for the suggestion there though.

Thanks again everyone!  I would have never figured that out by myself!

Scott K

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael Higgins
Sent: Wednesday, June 24, 2009 1:42 AM
To: [email protected]
Subject: Re: [freetds] issues connecting with perl DBD::ODBC

On Tue, 23 Jun 2009 17:59:16 -0400
"Kulik, Scott" <[email protected]> wrote:

> If I try to use a format similar to:
> 
> my
>
$DSN="Driver=FreeTDS;Server=localhost;ServerName=TREX;Port=1799;Database
> =TREX;UID=_user;PWD=_pass";
> my $dbh = DBI->connect("dbi:ODBC:$DSN",'_user','_pass');
> 
> like mentioned in the last response I always get a segmentation fault.

Sorry, I missed that.

Anyway, you may want to try doing this same kind of connect, but with
one of, however you want to set it:

export LD_BIND_NOW=1 

or 

export PERL_DL_NONLAZY=1

... which works with DBI if I just set %ENV in a BEGIN block. This
didn't work with DBIx-Class (though LD_BIND_NOW did if set outside the
script).

If that makes a difference to the segfault (it does for me), then I
think maybe you can connect in any way. IOW, I think the problem,
whatever it is, is what causes the segfault. It is just a different
result of the same underlying problem, but things are in fact handled
differently depending on what is in the connect string.

I think there's some SQL_ERROR library that isn't available at connect,
but perhaps could be. When the library is preloaded, then you get normal
error responses, which prompts the right behaviour, a second attempt at
a SQL connect. This is mostly a guess, though, inferred from reading.

Finally, I just put /usr/lib/libtdsodbc.so in /etc/ld.so.preload ...
which may, or may not be right, or right for your distro, but hopefully
you see the point. I think there is something wrong in the library
linking from unixODBC to FreeTDS when called with DBD::ODBC. I know
squat about it... though I can say this above is what works for me.

Good luck!

-- 
 |\  /|        |   |          ~ ~  
 | \/ |        |---|          `|` ?
 |    |ichael  |   |iggins    \^ /
 michael.higgins[at]evolone[dot]org
_______________________________________________
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.