The following test case uses global handles (which I cannot recommend) and omits explicit destructor calls:
The following test case uses global handles (which I
cannot recommend) and omits explicit destructor calls:

  use DBI();
  $dbh = DBI->connect or die $DBI::errstr;
  $tbl = 'perl_dbd_test';
  $sth = $dbh->prepare("select * from $tbl");
  $sth->execute;

Here, disconnect() is called during the so called 'global
destruction phase'. The order of destruction in this phase
is quite undeterministic. The $mapi handle may be undefined,
which causes trouble in the mapi_disconnect() call.

This patch tests for a valid $mapi handle.

zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb,zyzyis/monetdb