DBD::Proxy breaking die within eval strangeness

From: Mark Addison (Mark.Addison_at_itn.co.uk)
Date: 01/19/05

  • Next message: Graeme St. Clair: "RE: Problem with connecting to an Oracle database using Perl"
    Date: Wed, 19 Jan 2005 17:37:42 -0000
    To: <dbi-users@perl.org>
    
    

    Hello,

    I'm having a very strange problem with DBD::Proxy and have ended
    up with brain meltdown - so now its your turn ;-)

    Basically, if I use DBD::Proxy to connect to a database (just doing
    a 'use DBD::Proxy' isn't enough), then localise $dbh->{AutoCommit}
    within an eval (to locally turn on transactions), die seems to break
    such that the die works (is catchable with eval) but it looses
    the value for $@, so doesn't actually look like an error.

    I've got it down to the following test script:

        #!/usr/bin/perl
        
        use strict;
        use DBI;
        
        # This connect must work to see the error
        my $dbh = DBI->connect() || die "Failed to connect: $DBI::errstr\n";
        
        eval {
            die "BANG!!!";
            print "Hello\n";
        };
        print "AutoCommit default Error:$@\n";
        
        eval {
            local $dbh->{ AutoCommit } = 0; # This breaks die!
            die "BANG!!!";
            print "Hello\n";
        };
        print "Local AutoCommit off Error:$@\n";

    If I run this with a normal DBD it works as expected. e.g.

     $ DBI_DSN='dbi:mysql:host=localhost;database=test' ./test.pl
     AutoCommit default Error:BANG!!! at ./test.pl line 10.
     Local AutoCommit off Error:BANG!!! at ./test.pl line 17.

    If I use DBD::Proxy it fails

     $
    DBI_DSN='dbi:Proxy:hostname=localhost;port12400;dsn=dbi:mysql:host=local
    host;database=test' ./test.pl
     AutoCommit default Error:BANG!!! at ./test.pl line 10.
     Local AutoCommit off Error:

    i.e. in the 2nd eval the die happens (we don't see Hello printed) but $@
    is
    empty.

    I've tried this using a proxy server running locally to mysql as well
    as a remote one talking to sqlserver with ODBC and get the same result,
    so I think its down to DBD::Proxy.

    After days looking at this I can't work out wtf is going on. DBD::Proxy
    is full of local $SIG{__DIE__}='DEFAULT' code but doesn't ever set it to
    anything else.

    I get the same result on 2 machines with the following setups

    perl v5.8.0 sun4-solaris
    DBI 1.46
    DBD::Proxy 0.2004
    DBI::ProxyServer 0.3005

    perl v5.6.1 i386-freebsd
    DBI 1.43
    DBD::Proxy 0.2004
    DBI::ProxyServer 0.3005

    cheers,
    mark

    --
    "In the beginning, there was nothing, which exploded." 
    This email (and any attachments) is intended solely for the individual(s) to whom addressed. 
    It may contain confidential and/or legally privileged information. 
    Any statement or opinions therein are not necessarily those of ITN unless specifically stated. 
    Any unauthorised use, disclosure or copying is prohibited. 
    If you have received this email in error, please notify the sender and delete it from your system. 
    Security and reliability of the e-mail and attachments are not guaranteed. 
    You must take full responsibility for virus checking.
    Independent Television News Limited, 
    Registered No. 548648 England,
    VAT Reg. No: GB 756 2995 81, 
    200 Gray's Inn Road, London WC1X 8XZ,
    Telephone: 020 7833 3000.
    

  • Next message: Graeme St. Clair: "RE: Problem with connecting to an Oracle database using Perl"