Tim,

You may recall that my original patches for ProxyServer.pm turned 
'RaiseError' off around $sth->execute().  Your suggestion for 
reconfiguring error handling worked, insofar as getting the SQLSTATE and 
error message back from the remote database.

However, when the application turns 'RaiseError' off there is still an
important semantic difference between the behavior of a local database and
a proxied database.  Here's a scenario:

# Client application

# Global error handler for entire app.
$ENV{__DIE__} = sub { $dbh->rollback };

# One of many subroutines using two of many statement handles.
sub mysub {

  $sth2->{RaiseError} = 0;

  $sth1->execute();
  while ( my @data = $sth1->fetchrow_array() ) {
    # Setup some bound variables..
    if ( $sth2->execute() ) {
        $dbh->commmit;
    } else {
        my $errmsg = $sth2->errmsg();
        # show message from some misbehavior we can tolerate..
    }
  }
}

Now, the problem is that Perl does not respect a hierarchy for die 
handlers!  The first time that $sth2->execute() fails, the PlRPC module 
throws an exception locally to propagate the one on the server (since they 
are always turned on.)  Our handler is (silently) invoked, calling a 
rollback on the database and invalidating the active $sth1 handle in the 
process.  We never see the exception, since it's then caught by an eval{} 
in the DBI module, which knows not to rethrow it since RaiseError is off.

When the local row cache is exhausted and a "real" fetch is made at the
server, DB2 (and, I assume, many other RDBMS flavors) blows up with a
function sequence error (attempt to fetch from an invalidated statement
handle) on sth1.

This will not and does not malfunction when connected to a local database, 
since no exception is thrown by anyone concerned.

I just spent about 20-min. chasing this down, and am renewing my request
that we reconsider the "always die on error" behavior on the server.  I
may not be seeing the forest for the trees, so please let me know your
thoughts before I start coding?

Steve

-- 
----------------------------------------------------------------
Steven N. Hirsch       tie-line: 446-6557     ext: 802-769-6557

Staff Engineer                     Methodology Integration Team
ASIC Product Development           IBM Microelectronics
----------------------------------------------------------------

Reply via email to